catenext 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -40,18 +40,26 @@ var init_common = __esm({
40
40
 
41
41
  // shared/src/review.ts
42
42
  import { z as z2 } from "zod";
43
- var CommitShaSchema, PullRequestUrlSchema, PullRequestRefSchema, REVIEW_STAGES, ReviewStageSchema, PullRequestStateSchema, ReviewDecisionSchema, ReviewInput, ReviewEntrySchema, ReviewOutput;
43
+ var CommitShaSchema, PULL_REQUEST_URL_RE, PULL_REQUEST_URL_MSG, UrlConstructor, PullRequestUrlSchema, PullRequestRefSchema, REVIEW_STAGES, ReviewStageSchema, PullRequestStateSchema, ReviewDecisionSchema, ReviewInput, ReviewEntrySchema, ReviewOutput;
44
44
  var init_review = __esm({
45
45
  "shared/src/review.ts"() {
46
46
  "use strict";
47
47
  init_common();
48
48
  CommitShaSchema = z2.string().regex(/^[0-9a-f]{40}$/);
49
- PullRequestUrlSchema = z2.string().max(240).regex(
50
- /^https:\/\/github\.com\/[a-z\d][a-z\d-]*\/[a-z\d_.-]+\/pull\/[1-9]\d*$/i,
51
- "Gunakan URL pull request GitHub."
52
- );
49
+ PULL_REQUEST_URL_RE = /^https?:\/\/[a-z\d](?:[a-z\d-]*[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]*[a-z\d])?)*(?::\d{1,5})?(?:\/[a-z\d_][a-z\d._-]*){2,}(?:\/pull|\/(?:-\/)?merge_requests|\/pull-requests|\/pulls)\/[1-9]\d*$/i;
50
+ PULL_REQUEST_URL_MSG = "Gunakan URL pull/merge request GitHub, GitLab, Bitbucket, atau Gitea yang valid.";
51
+ UrlConstructor = globalThis.URL;
52
+ PullRequestUrlSchema = z2.string().max(240).regex(PULL_REQUEST_URL_RE, PULL_REQUEST_URL_MSG).refine((value) => {
53
+ if (!UrlConstructor) return true;
54
+ try {
55
+ const parsed = new UrlConstructor(value);
56
+ return (parsed.protocol === "http:" || parsed.protocol === "https:") && !parsed.username && !parsed.password && !parsed.search && !parsed.hash;
57
+ } catch {
58
+ return false;
59
+ }
60
+ }, PULL_REQUEST_URL_MSG);
53
61
  PullRequestRefSchema = z2.object({
54
- url: PullRequestUrlSchema,
62
+ url: PullRequestUrlSchema.optional(),
55
63
  base_branch: z2.string().min(1).max(255),
56
64
  head_sha: CommitShaSchema
57
65
  });
@@ -336,6 +344,7 @@ var init_api = __esm({
336
344
  prompt_instruction: z5.string().min(1).max(8e3).optional(),
337
345
  target_repo: RepoNameSchema.nullable().optional(),
338
346
  role: RoleSchema.nullable().optional(),
347
+ persona: AgentAliasSchema.nullable().optional(),
339
348
  persona_id: IdSchema.nullable().optional(),
340
349
  requires_approval: z5.boolean().optional(),
341
350
  position: z5.number().finite().optional(),
@@ -450,7 +459,9 @@ var init_brief = __esm({
450
459
  /** Registered external/extra workspace roots for this project. */
451
460
  workspace_roots: z6.array(WorkspaceRootSchema).max(20).default([]),
452
461
  /** Cold-start file: master prompt, then AGENTS.md for full rules. */
453
- read_first: z6.literal("CATENEXT.md").default("CATENEXT.md")
462
+ read_first: z6.literal("CATENEXT.md").default("CATENEXT.md"),
463
+ /** Session locale preference from session_prefs (when configured). */
464
+ locale: z6.string().optional()
454
465
  });
455
466
  ManageRootsInput = z6.object({
456
467
  action: z6.enum(["list", "add", "remove"]),
@@ -795,7 +806,9 @@ var init_mcp_tools = __esm({
795
806
  /** Indeks dokumen proyek lokal (blueprint, ERD, ...); isi lewat get_document. */
796
807
  documents: z11.array(DocumentIndexEntrySchema).default([]),
797
808
  /** External/extra workspace roots registered for this project. */
798
- workspace_roots: z11.array(WorkspaceRootSchema).max(20).default([])
809
+ workspace_roots: z11.array(WorkspaceRootSchema).max(20).default([]),
810
+ /** Session locale preference from session_prefs (when configured). */
811
+ locale: z11.string().optional()
799
812
  });
800
813
  GetProjectBoardInput = z11.object({
801
814
  epic_id: IdSchema.optional(),
@@ -1341,9 +1354,79 @@ var init_orchestrator = __esm({
1341
1354
  });
1342
1355
 
1343
1356
  // shared/src/templates.ts
1357
+ function findEpicTemplate(id) {
1358
+ return EPIC_TEMPLATES.find((t) => t.id === id);
1359
+ }
1360
+ var EPIC_TEMPLATES;
1344
1361
  var init_templates = __esm({
1345
1362
  "shared/src/templates.ts"() {
1346
1363
  "use strict";
1364
+ EPIC_TEMPLATES = [
1365
+ {
1366
+ id: "fitur-login",
1367
+ name: "Fitur login",
1368
+ summary: "Backend auth, form login, lalu tes E2E. Contoh estafet backend -> UI -> QA.",
1369
+ epic: {
1370
+ title: "Fitur login email + password",
1371
+ description: "Pengguna bisa mendaftar, login, dan logout dengan email + password.\n\nSelesai bila: password di-hash, sesi bertahan setelah reload, pesan error jelas, dan alur utama punya tes."
1372
+ },
1373
+ tasks: [
1374
+ {
1375
+ ref: "api",
1376
+ title: "Skema user & endpoint auth",
1377
+ role: "backend",
1378
+ depends_on: [],
1379
+ prompt_instruction: "Buat tabel/model user (email unik, hash password) dan endpoint daftar, login, logout, serta 'me'. Pakai library hashing standar di stack ini. Tulis tes unit untuk validasi input dan password salah. Di handoff, catat path route, bentuk respons, dan cara sesi disimpan (cookie/token)."
1380
+ },
1381
+ {
1382
+ ref: "ui",
1383
+ title: "Form login & state sesi di UI",
1384
+ role: "ui",
1385
+ depends_on: ["api"],
1386
+ prompt_instruction: "Baca handoff task backend untuk path & bentuk respons. Buat halaman daftar dan login, tampilkan error dari API, simpan state sesi, dan arahkan pengguna yang belum login ke halaman login. Jangan mengubah kontrak API; bila perlu perubahan, laporkan lewat report_blocker."
1387
+ },
1388
+ {
1389
+ ref: "e2e",
1390
+ title: "Tes E2E alur login",
1391
+ role: "testing",
1392
+ depends_on: ["api", "ui"],
1393
+ prompt_instruction: "Tulis tes end-to-end: daftar -> logout -> login -> reload tetap login -> password salah menampilkan error. Gunakan runner tes yang sudah ada di repo bila ada. Di handoff, tulis perintah persis untuk menjalankan tes ini."
1394
+ }
1395
+ ]
1396
+ },
1397
+ {
1398
+ id: "crud-api",
1399
+ name: "Resource CRUD + dokumentasi",
1400
+ summary: "Model & migrasi, endpoint CRUD dengan validasi, lalu dokumentasi & tes integrasi.",
1401
+ epic: {
1402
+ title: "Resource CRUD baru",
1403
+ description: "Tambah satu resource (ganti nama 'item' sesuai kebutuhan) dengan operasi buat, baca, ubah, hapus.\n\nSelesai bila: migrasi bisa dijalankan ulang, input divalidasi, daftar mendukung paginasi, dan endpoint terdokumentasi."
1404
+ },
1405
+ tasks: [
1406
+ {
1407
+ ref: "model",
1408
+ title: "Model & migrasi resource",
1409
+ role: "backend",
1410
+ depends_on: [],
1411
+ prompt_instruction: "Buat model dan migrasi untuk resource 'item' (id, nama, deskripsi, timestamps). Ikuti konvensi ORM/migrasi yang sudah ada. Di handoff, catat nama tabel, kolom, dan perintah migrasi."
1412
+ },
1413
+ {
1414
+ ref: "endpoints",
1415
+ title: "Endpoint CRUD dengan validasi",
1416
+ role: "backend",
1417
+ depends_on: ["model"],
1418
+ prompt_instruction: "Buat endpoint list (paginasi cursor), detail, create, update, delete untuk 'item' dengan validasi input dan kode status yang tepat (400/404/409). Tambahkan tes unit untuk validasi."
1419
+ },
1420
+ {
1421
+ ref: "docs",
1422
+ title: "Dokumentasi & tes integrasi",
1423
+ role: "testing",
1424
+ depends_on: ["endpoints"],
1425
+ prompt_instruction: "Dokumentasikan setiap endpoint (contoh request/response) di README atau file docs yang ada, dan tulis tes integrasi untuk alur buat -> ubah -> hapus. Simpan konvensi penting sebagai skill repo lewat save_repo_skill."
1426
+ }
1427
+ ]
1428
+ }
1429
+ ];
1347
1430
  }
1348
1431
  });
1349
1432
 
@@ -5191,6 +5274,295 @@ var init_local_service = __esm({
5191
5274
  }
5192
5275
  return out;
5193
5276
  }
5277
+ async updateEpic(epicId, input) {
5278
+ if (this.caller === "agent") {
5279
+ fail("permission_denied", "Pembaruan epic hanya lewat CLI manusia.");
5280
+ }
5281
+ if (!IdSchema.safeParse(epicId).success) {
5282
+ fail("invalid_input", "epic_id harus UUID yang valid.");
5283
+ }
5284
+ const parsed = UpdateEpicInput.safeParse(scrubDeep(input, DEFAULT_SCRUB_SKIP_KEYS).value);
5285
+ if (!parsed.success) {
5286
+ const paths = [
5287
+ ...new Set(parsed.error.issues.map((issue) => issue.path.join(".") || "(root)"))
5288
+ ];
5289
+ fail("invalid_input", `Input updateEpic tidak valid: ${paths.join(", ")}.`, {
5290
+ fields: paths
5291
+ });
5292
+ }
5293
+ const existed = existsSync3(this.stateFile);
5294
+ const out = await this.store.transaction(
5295
+ this.config.project_id,
5296
+ this.config.repo_name,
5297
+ (project, dirty) => {
5298
+ const epic2 = project.epics.find((e) => e.id === epicId);
5299
+ if (!epic2) fail("not_found", "Epic tidak ditemukan di proyek ini.");
5300
+ let changed = false;
5301
+ if (parsed.data.title !== void 0 && parsed.data.title !== epic2.title) {
5302
+ epic2.title = parsed.data.title;
5303
+ changed = true;
5304
+ }
5305
+ if (parsed.data.description !== void 0) {
5306
+ const nextDesc = parsed.data.description ?? null;
5307
+ if (nextDesc !== epic2.description) {
5308
+ epic2.description = nextDesc;
5309
+ changed = true;
5310
+ }
5311
+ }
5312
+ if (changed) dirty();
5313
+ const counts2 = /* @__PURE__ */ new Map();
5314
+ for (const t of project.tasks) {
5315
+ if (t.epicId === epic2.id) counts2.set(t.status, (counts2.get(t.status) ?? 0) + 1);
5316
+ }
5317
+ return { ...epic2, task_counts: Object.fromEntries(counts2) };
5318
+ }
5319
+ );
5320
+ if (!existed && process.platform !== "win32" && existsSync3(this.stateFile)) {
5321
+ await chmod(this.stateFile, 384);
5322
+ }
5323
+ return out;
5324
+ }
5325
+ async updateTask(taskId, input) {
5326
+ if (this.caller === "agent") {
5327
+ fail("permission_denied", "Pembaruan task hanya lewat CLI manusia.");
5328
+ }
5329
+ if (!IdSchema.safeParse(taskId).success) {
5330
+ fail("invalid_input", "task_id harus UUID yang valid.");
5331
+ }
5332
+ const skipKeys = /* @__PURE__ */ new Set([...DEFAULT_SCRUB_SKIP_KEYS, "persona", "role", "target_repo"]);
5333
+ const parsed = UpdateTaskInput.safeParse(scrubDeep(input, skipKeys).value);
5334
+ if (!parsed.success) {
5335
+ const paths = [
5336
+ ...new Set(parsed.error.issues.map((issue) => issue.path.join(".") || "(root)"))
5337
+ ];
5338
+ fail("invalid_input", `Input updateTask tidak valid: ${paths.join(", ")}.`, {
5339
+ fields: paths
5340
+ });
5341
+ }
5342
+ const existed = existsSync3(this.stateFile);
5343
+ const out = await this.store.transaction(
5344
+ this.config.project_id,
5345
+ this.config.repo_name,
5346
+ (project, dirty, _db, afterSave) => {
5347
+ const task3 = project.tasks.find((t) => t.id === taskId);
5348
+ if (!task3) fail("not_found", "Task tidak ditemukan di proyek ini.");
5349
+ const data = parsed.data;
5350
+ const changedFields = [];
5351
+ if (data.target_repo !== void 0 && data.target_repo !== task3.target) {
5352
+ if (task3.lease && data.target_repo && task3.lease.repo !== data.target_repo) {
5353
+ fail(
5354
+ "task_locked",
5355
+ "Tidak bisa mengubah target_repo saat task sedang dipegang repo lain."
5356
+ );
5357
+ }
5358
+ task3.target = data.target_repo;
5359
+ changedFields.push("target_repo");
5360
+ }
5361
+ if (data.persona !== void 0) {
5362
+ if (data.persona === null) {
5363
+ if (task3.persona !== null) {
5364
+ task3.persona = null;
5365
+ changedFields.push("persona");
5366
+ }
5367
+ } else {
5368
+ const p = project.personas.find((row) => row.alias === data.persona);
5369
+ if (!p)
5370
+ fail("persona_not_found", `Persona "${data.persona}" tidak ditemukan di proyek ini.`);
5371
+ if (task3.target && !allowsRepo(p, task3.target)) {
5372
+ fail(
5373
+ "persona_repo_mismatch",
5374
+ `Persona "${p.alias}" tidak memegang repo "${task3.target}".`
5375
+ );
5376
+ }
5377
+ if (task3.persona !== p.alias) {
5378
+ task3.persona = p.alias;
5379
+ changedFields.push("persona");
5380
+ }
5381
+ if (data.role === void 0 && task3.role !== p.role) {
5382
+ task3.role = p.role;
5383
+ changedFields.push("role");
5384
+ }
5385
+ }
5386
+ } else if (task3.persona && data.target_repo !== void 0 && task3.target) {
5387
+ const currentPersona = project.personas.find((row) => row.alias === task3.persona);
5388
+ if (currentPersona && !allowsRepo(currentPersona, task3.target)) {
5389
+ fail(
5390
+ "persona_repo_mismatch",
5391
+ `Persona "${currentPersona.alias}" tidak memegang repo "${task3.target}".`
5392
+ );
5393
+ }
5394
+ }
5395
+ if (data.role !== void 0 && data.role !== task3.role) {
5396
+ task3.role = data.role;
5397
+ changedFields.push("role");
5398
+ }
5399
+ if (data.title !== void 0 && data.title !== task3.title) {
5400
+ task3.title = data.title;
5401
+ changedFields.push("title");
5402
+ }
5403
+ if (data.prompt_instruction !== void 0 && data.prompt_instruction !== task3.instruction) {
5404
+ task3.instruction = data.prompt_instruction;
5405
+ changedFields.push("prompt_instruction");
5406
+ }
5407
+ if (data.requires_approval !== void 0 && data.requires_approval !== task3.requiresApproval) {
5408
+ task3.requiresApproval = data.requires_approval;
5409
+ changedFields.push("requires_approval");
5410
+ }
5411
+ if (data.is_stale === false && task3.stale) {
5412
+ task3.stale = false;
5413
+ changedFields.push("is_stale");
5414
+ }
5415
+ if (changedFields.length > 0) {
5416
+ dirty();
5417
+ const nowIso = (/* @__PURE__ */ new Date()).toISOString();
5418
+ afterSave((txDb) => {
5419
+ insertTaskEvents(txDb, this.config.project_id, [
5420
+ {
5421
+ task_id: task3.id,
5422
+ event: "update",
5423
+ actor: this.caller,
5424
+ note: changedFields.join(", "),
5425
+ detail: { fields: changedFields },
5426
+ created_at: nowIso
5427
+ }
5428
+ ]);
5429
+ });
5430
+ }
5431
+ return structuredClone(task3);
5432
+ }
5433
+ );
5434
+ if (!existed && process.platform !== "win32" && existsSync3(this.stateFile)) {
5435
+ await chmod(this.stateFile, 384);
5436
+ }
5437
+ return out;
5438
+ }
5439
+ async cancelTask(taskId) {
5440
+ if (this.caller === "agent") {
5441
+ fail("permission_denied", "Pembatalan task hanya lewat CLI manusia.");
5442
+ }
5443
+ if (!IdSchema.safeParse(taskId).success) {
5444
+ fail("invalid_input", "task_id harus UUID yang valid.");
5445
+ }
5446
+ const existed = existsSync3(this.stateFile);
5447
+ const out = await this.store.transaction(
5448
+ this.config.project_id,
5449
+ this.config.repo_name,
5450
+ (project, dirty, _db, afterSave) => {
5451
+ const idx = project.tasks.findIndex((t) => t.id === taskId);
5452
+ const task3 = project.tasks[idx];
5453
+ if (!task3) fail("not_found", "Task tidak ditemukan di proyek ini.");
5454
+ if (task3.status === "IN_PROGRESS" && task3.lease && Date.parse(task3.lease.expiresAt) > Date.now()) {
5455
+ fail(
5456
+ "task_locked",
5457
+ "Task sedang dikerjakan (IN_PROGRESS); lepas lease terlebih dahulu sebelum membatalkan."
5458
+ );
5459
+ }
5460
+ const dependents = project.tasks.filter(
5461
+ (other) => other.id !== taskId && other.dependencies.includes(taskId)
5462
+ );
5463
+ if (dependents.length > 0) {
5464
+ fail(
5465
+ "has_dependents",
5466
+ `Task masih menjadi dependensi ${dependents.length} task lain; perbarui dependensi terlebih dahulu.`,
5467
+ { dependent_task_ids: dependents.map((t) => t.id) }
5468
+ );
5469
+ }
5470
+ const previousStatus = task3.status;
5471
+ const title = task3.title;
5472
+ project.tasks.splice(idx, 1);
5473
+ dirty();
5474
+ const nowIso = (/* @__PURE__ */ new Date()).toISOString();
5475
+ afterSave((txDb) => {
5476
+ insertTaskEvents(txDb, this.config.project_id, [
5477
+ {
5478
+ task_id: taskId,
5479
+ event: "cancel",
5480
+ actor: this.caller,
5481
+ note: title,
5482
+ detail: { from: previousStatus },
5483
+ created_at: nowIso
5484
+ }
5485
+ ]);
5486
+ });
5487
+ return {
5488
+ task_id: taskId,
5489
+ title,
5490
+ previous_status: previousStatus,
5491
+ cancelled: true
5492
+ };
5493
+ }
5494
+ );
5495
+ if (!existed && process.platform !== "win32" && existsSync3(this.stateFile)) {
5496
+ await chmod(this.stateFile, 384);
5497
+ }
5498
+ return out;
5499
+ }
5500
+ async setTaskDependencies(taskId, input) {
5501
+ if (this.caller === "agent") {
5502
+ fail("permission_denied", "Pembaruan dependensi hanya lewat CLI manusia.");
5503
+ }
5504
+ if (!IdSchema.safeParse(taskId).success) {
5505
+ fail("invalid_input", "task_id harus UUID yang valid.");
5506
+ }
5507
+ const skipKeys = /* @__PURE__ */ new Set([...DEFAULT_SCRUB_SKIP_KEYS, "depends_on"]);
5508
+ const parsed = SetDependenciesInput.safeParse(scrubDeep(input, skipKeys).value);
5509
+ if (!parsed.success) {
5510
+ const paths = [
5511
+ ...new Set(parsed.error.issues.map((issue) => issue.path.join(".") || "(root)"))
5512
+ ];
5513
+ fail("invalid_input", `Input setTaskDependencies tidak valid: ${paths.join(", ")}.`, {
5514
+ fields: paths
5515
+ });
5516
+ }
5517
+ const nextDeps = [...new Set(parsed.data.depends_on)];
5518
+ if (nextDeps.includes(taskId)) {
5519
+ fail("dependency_cycle", "Task tidak boleh bergantung pada dirinya sendiri.");
5520
+ }
5521
+ const existed = existsSync3(this.stateFile);
5522
+ const out = await this.store.transaction(
5523
+ this.config.project_id,
5524
+ this.config.repo_name,
5525
+ (project, dirty, _db, afterSave) => {
5526
+ const task3 = project.tasks.find((t) => t.id === taskId);
5527
+ if (!task3) fail("not_found", "Task tidak ditemukan di proyek ini.");
5528
+ const taskIds = new Set(project.tasks.map((t) => t.id));
5529
+ for (const depId of nextDeps) {
5530
+ if (!taskIds.has(depId)) {
5531
+ fail("dependency_not_found", `Task dependensi ${depId} tidak ditemukan di proyek ini.`);
5532
+ }
5533
+ }
5534
+ const edges = project.tasks.flatMap((t) => {
5535
+ const deps = t.id === task3.id ? nextDeps : t.dependencies;
5536
+ return deps.map((dependsOn) => ({ task: t.id, dependsOn }));
5537
+ });
5538
+ const cycle = findCycle(edges);
5539
+ if (cycle) {
5540
+ fail("dependency_cycle", `Dependensi melingkar terdeteksi: ${cycle.join(" -> ")}.`, {
5541
+ cycle
5542
+ });
5543
+ }
5544
+ task3.dependencies = nextDeps;
5545
+ dirty();
5546
+ const nowIso = (/* @__PURE__ */ new Date()).toISOString();
5547
+ afterSave((txDb) => {
5548
+ insertTaskEvents(txDb, this.config.project_id, [
5549
+ {
5550
+ task_id: task3.id,
5551
+ event: "set_dependencies",
5552
+ actor: this.caller,
5553
+ detail: { depends_on: nextDeps },
5554
+ created_at: nowIso
5555
+ }
5556
+ ]);
5557
+ });
5558
+ return { task_id: task3.id, depends_on: [...task3.dependencies] };
5559
+ }
5560
+ );
5561
+ if (!existed && process.platform !== "win32" && existsSync3(this.stateFile)) {
5562
+ await chmod(this.stateFile, 384);
5563
+ }
5564
+ return out;
5565
+ }
5194
5566
  async callTool(name, input) {
5195
5567
  const contract = MCP_TOOLS[name];
5196
5568
  const parsed = contract.input.safeParse(scrubDeep(input, DEFAULT_SCRUB_SKIP_KEYS).value);
@@ -5617,7 +5989,8 @@ var init_local_service = __esm({
5617
5989
  draft_count: draft.length,
5618
5990
  pending_approvals,
5619
5991
  workspace_roots: workspaceRoots,
5620
- read_first: "CATENEXT.md"
5992
+ read_first: "CATENEXT.md",
5993
+ ...this.project.session_prefs?.locale ? { locale: this.project.session_prefs.locale } : {}
5621
5994
  };
5622
5995
  }
5623
5996
  workspaceRootSummaries() {
@@ -5746,7 +6119,8 @@ var init_local_service = __esm({
5746
6119
  recent_handoffs: [...recent.values()].slice(0, active ? void 0 : 5),
5747
6120
  project_repos: this.repos(),
5748
6121
  documents: this.project.documents.map(recordIndex).sort((a, b) => a.kind.localeCompare(b.kind) || a.slug.localeCompare(b.slug)),
5749
- workspace_roots: this.workspaceRootSummaries()
6122
+ workspace_roots: this.workspaceRootSummaries(),
6123
+ ...this.project.session_prefs?.locale ? { locale: this.project.session_prefs.locale } : {}
5750
6124
  };
5751
6125
  }
5752
6126
  claim(input) {
@@ -5949,7 +6323,7 @@ var init_local_service = __esm({
5949
6323
  git_branch: handoff.git_branch,
5950
6324
  last_commit_hash: handoff.last_commit_hash,
5951
6325
  files_count: handoff.files_modified.length,
5952
- ...handoff.pull_request ? { pr_url: handoff.pull_request.url } : {}
6326
+ ...handoff.pull_request?.url ? { pr_url: handoff.pull_request.url } : {}
5953
6327
  }
5954
6328
  });
5955
6329
  this.dirty();
@@ -6181,7 +6555,9 @@ var init_local_service = __esm({
6181
6555
  title: task3.title,
6182
6556
  status,
6183
6557
  review: {
6184
- ...review4.ref,
6558
+ ...review4.ref.url ? { url: review4.ref.url } : {},
6559
+ base_branch: review4.ref.base_branch,
6560
+ head_sha: review4.ref.head_sha,
6185
6561
  stage,
6186
6562
  checked_at: review4.updatedAt,
6187
6563
  reviewer: review4.lease?.reviewer ?? review4.decision?.reviewer ?? null,
@@ -6525,10 +6901,10 @@ function renderClaudeEntry() {
6525
6901
  ""
6526
6902
  ].join("\n");
6527
6903
  }
6528
- async function planEntryPointers(root, platforms) {
6904
+ async function planEntryPointers(root, platforms, opts = {}) {
6529
6905
  const edits = [];
6530
6906
  const masterBefore = await readRepoFile(root, MASTER_PROMPT_FILE);
6531
- if (masterBefore === null || masterBefore.includes(MASTER_MARKER)) {
6907
+ if (opts.force || masterBefore === null || masterBefore.includes(MASTER_MARKER)) {
6532
6908
  const masterAfter = renderMasterPrompt();
6533
6909
  if (masterAfter !== masterBefore) {
6534
6910
  edits.push({ path: MASTER_PROMPT_FILE, before: masterBefore, after: masterAfter });
@@ -6538,7 +6914,7 @@ async function planEntryPointers(root, platforms) {
6538
6914
  const path = PLATFORM_ENTRY_FILES[platform];
6539
6915
  if (!path) continue;
6540
6916
  const before = await readRepoFile(root, path);
6541
- if (before !== null && !before.includes(ENTRY_MARKER)) continue;
6917
+ if (!opts.force && before !== null && !before.includes(ENTRY_MARKER)) continue;
6542
6918
  const after = platform === "claude-code" ? renderClaudeEntry() : renderEntryPointer(platform, path);
6543
6919
  if (after !== before) edits.push({ path, before, after });
6544
6920
  }
@@ -7307,14 +7683,14 @@ function renderOrchestratorStub(ctx) {
7307
7683
  ""
7308
7684
  ].join("\n");
7309
7685
  }
7310
- async function planDir(root, dir, personas, ctx, platform) {
7686
+ async function planDir(root, dir, personas, ctx, platform, force = false) {
7311
7687
  const edits = [];
7312
7688
  const skipped = [];
7313
7689
  const wanted = /* @__PURE__ */ new Set();
7314
7690
  const orchPath = join11(dir, "orchestrator.md");
7315
7691
  wanted.add(orchPath);
7316
7692
  const orchBefore = await readOrNull(join11(root, orchPath));
7317
- if (orchBefore !== null && !orchBefore.includes(ORCHESTRATOR_MARKER) && !orchBefore.includes(SUBAGENT_MARKER)) {
7693
+ if (!force && orchBefore !== null && !orchBefore.includes(ORCHESTRATOR_MARKER) && !orchBefore.includes(SUBAGENT_MARKER)) {
7318
7694
  skipped.push(orchPath);
7319
7695
  } else {
7320
7696
  const orchAfter = platform === "opencode" ? renderOrchestratorAgent(ctx) : renderOrchestratorStub(ctx);
@@ -7325,7 +7701,7 @@ async function planDir(root, dir, personas, ctx, platform) {
7325
7701
  const path = join11(dir, `${p.alias}.md`);
7326
7702
  wanted.add(path);
7327
7703
  const before = await readOrNull(join11(root, path));
7328
- if (before !== null && !before.includes(SUBAGENT_MARKER)) {
7704
+ if (!force && before !== null && !before.includes(SUBAGENT_MARKER)) {
7329
7705
  skipped.push(path);
7330
7706
  continue;
7331
7707
  }
@@ -7339,7 +7715,7 @@ async function planDir(root, dir, personas, ctx, platform) {
7339
7715
  }
7340
7716
  return { edits, skipped };
7341
7717
  }
7342
- async function planSubagents(root, personas, platforms = ["claude-code"], ctx = {}) {
7718
+ async function planSubagents(root, personas, platforms = ["claude-code"], ctx = {}, opts = {}) {
7343
7719
  const fullCtx = {
7344
7720
  stack: ctx.stack ?? [],
7345
7721
  personas,
@@ -7353,9 +7729,8 @@ async function planSubagents(root, personas, platforms = ["claude-code"], ctx =
7353
7729
  const dir = SUBAGENT_DIRS[platform];
7354
7730
  if (dir) plannedDirs.set(dir, platform);
7355
7731
  }
7356
- if (plannedDirs.size === 0) plannedDirs.set(SUBAGENTS_DIR, "claude-code");
7357
7732
  for (const [dir, platform] of plannedDirs) {
7358
- const planned = await planDir(root, dir, personas, fullCtx, platform);
7733
+ const planned = await planDir(root, dir, personas, fullCtx, platform, Boolean(opts.force));
7359
7734
  edits.push(...planned.edits);
7360
7735
  skipped.push(...planned.skipped);
7361
7736
  }
@@ -7371,10 +7746,10 @@ async function catenextAgentFilesIn(root, dir) {
7371
7746
  }
7372
7747
  return out;
7373
7748
  }
7374
- async function catenextSubagentFiles(root) {
7749
+ async function catenextSubagentFiles(root, platforms) {
7750
+ const dirs = platforms ? new Set(platforms.map((p) => SUBAGENT_DIRS[p]).filter((d) => Boolean(d))) : new Set(Object.values(SUBAGENT_DIRS).filter((d) => Boolean(d)));
7375
7751
  const out = [];
7376
- for (const dir of new Set(Object.values(SUBAGENT_DIRS))) {
7377
- if (!dir) continue;
7752
+ for (const dir of dirs) {
7378
7753
  out.push(...await catenextAgentFilesIn(root, dir));
7379
7754
  }
7380
7755
  return out;
@@ -7444,7 +7819,7 @@ async function planSync(opts) {
7444
7819
  }
7445
7820
  const stale = current.entry ? entryIsStale(current.entry) : false;
7446
7821
  const needsFix = current.count > 1 || stale || current.entry && (!current.compatible || !entryMatchesRoot(current.entry, root, adapter));
7447
- if (needsFix && !opts.fix) {
7822
+ if (needsFix && !opts.fix && !opts.force) {
7448
7823
  for (const id of adapter.ids) failed.add(id);
7449
7824
  findings.push({
7450
7825
  level: "fixable",
@@ -7452,18 +7827,20 @@ async function planSync(opts) {
7452
7827
  });
7453
7828
  continue;
7454
7829
  }
7455
- if (!current.entry || needsFix) {
7456
- const base = current.entry && !stale ? entryBase(current.entry) : null;
7830
+ if (!current.entry || needsFix || opts.force) {
7831
+ const base = current.entry && !stale && !opts.force ? entryBase(current.entry) : null;
7457
7832
  const after = changeMcp(
7458
7833
  before,
7459
7834
  adapter,
7460
7835
  scopedEntry(root, adapter, base ?? opts.defaultCommand())
7461
7836
  );
7462
7837
  add(adapter.path, before, after);
7463
- findings.push({
7464
- level: "ok",
7465
- message: `${adapter.path}: entri catenext ${current.count ? "diperbaiki" : "ditambahkan"}.`
7466
- });
7838
+ if (before !== after || !current.entry || needsFix) {
7839
+ findings.push({
7840
+ level: "ok",
7841
+ message: `${adapter.path}: entri catenext ${current.count ? needsFix ? "diperbaiki" : "diperbarui" : "ditambahkan"}.`
7842
+ });
7843
+ }
7467
7844
  }
7468
7845
  for (const id of adapter.ids) configured.add(id);
7469
7846
  } catch (error) {
@@ -7475,13 +7852,17 @@ async function planSync(opts) {
7475
7852
  const tracked = [...configured].filter(
7476
7853
  (platform) => previous.includes(platform) || !failed.has(platform)
7477
7854
  );
7478
- if (tracked.length !== previous.length && configBefore !== null) {
7855
+ const previousSet = new Set(previous);
7856
+ const trackedSet = new Set(tracked);
7857
+ const platformsChanged = trackedSet.size !== previousSet.size || tracked.some((platform) => !previousSet.has(platform));
7858
+ if (platformsChanged && configBefore !== null) {
7479
7859
  add(CONFIG_PATH, configBefore, updateConfig(configBefore, { platforms: tracked }));
7480
7860
  }
7481
7861
  const gitignore = await readRepoFile(root, ".gitignore");
7482
7862
  add(".gitignore", gitignore, ensureGitignore(gitignore));
7483
7863
  const agents = await readRepoFile(root, AGENTS_MD);
7484
- if (agents?.includes(BLOCK_START)) add(AGENTS_MD, agents, upsertAgentsBlock(agents));
7864
+ if (agents?.includes(BLOCK_START) || opts.force)
7865
+ add(AGENTS_MD, agents, upsertAgentsBlock(agents));
7485
7866
  return { edits, findings };
7486
7867
  }
7487
7868
  async function planRemove(opts) {
@@ -7509,7 +7890,29 @@ async function planRemove(opts) {
7509
7890
  const agents = await readRepoFile(root, AGENTS_MD);
7510
7891
  if (agents?.includes(BLOCK_START)) add(AGENTS_MD, agents, removeAgentsBlock(agents));
7511
7892
  }
7512
- if (!opts.platforms || selected.includes("claude-code")) {
7893
+ const masterPrompt = await readRepoFile(root, MASTER_PROMPT_FILE);
7894
+ if (masterPrompt?.includes(MASTER_MARKER) && (!opts.platforms || previous.length > 0 && remaining.length === 0)) {
7895
+ add(MASTER_PROMPT_FILE, masterPrompt, null);
7896
+ }
7897
+ const entryPlatforms = opts.platforms ? selected : SUPPORTED_PLATFORMS;
7898
+ for (const path of new Set(
7899
+ entryPlatforms.map((platform) => PLATFORM_ENTRY_FILES[platform]).filter((path2) => Boolean(path2))
7900
+ )) {
7901
+ const before = await readRepoFile(root, path);
7902
+ if (before?.includes(ENTRY_MARKER)) add(path, before, null);
7903
+ }
7904
+ if (opts.platforms) {
7905
+ const remainingDirs = new Set(
7906
+ remaining.map((platform) => SUBAGENT_DIRS[platform]).filter((d) => Boolean(d))
7907
+ );
7908
+ const removable = selected.filter((platform) => {
7909
+ const dir = SUBAGENT_DIRS[platform];
7910
+ return dir && !remainingDirs.has(dir);
7911
+ });
7912
+ for (const path of await catenextSubagentFiles(root, removable)) {
7913
+ add(path, await readRepoFile(root, path), null);
7914
+ }
7915
+ } else {
7513
7916
  for (const path of await catenextSubagentFiles(root)) {
7514
7917
  add(path, await readRepoFile(root, path), null);
7515
7918
  }
@@ -7538,6 +7941,7 @@ var init_maintenance = __esm({
7538
7941
  "src/maintenance.ts"() {
7539
7942
  "use strict";
7540
7943
  init_src();
7944
+ init_entry_pointers();
7541
7945
  init_config2();
7542
7946
  init_agents_md();
7543
7947
  init_config_file();
@@ -7616,13 +8020,87 @@ async function epicList(service, asJson) {
7616
8020
  }
7617
8021
  for (const e of res.epics) console.log(`${e.id} ${e.title} (${counts(e.task_counts)})`);
7618
8022
  }
7619
- async function epicCreate(service, title, description, asJson) {
7620
- const body = prepare(CreateEpicToolInput, { title, description }, []);
8023
+ function epicTemplates(asJson) {
8024
+ if (asJson) return console.log(JSON.stringify({ templates: EPIC_TEMPLATES }, null, 2));
8025
+ for (const t of EPIC_TEMPLATES) {
8026
+ console.log(`${t.id.padEnd(14)} ${t.name} \u2014 ${t.summary} (${t.tasks.length} task)`);
8027
+ }
8028
+ }
8029
+ async function epicCreate(service, title, opts) {
8030
+ const asJson = Boolean(opts.json);
8031
+ if (opts.template) {
8032
+ const tpl = findEpicTemplate(opts.template);
8033
+ if (!tpl) {
8034
+ throw new PlanningInputError(
8035
+ `Template epic tidak ditemukan: ${opts.template}. Jalankan \`catenext epic templates\` untuk daftar template.`
8036
+ );
8037
+ }
8038
+ const epicBody = prepare(
8039
+ CreateEpicToolInput,
8040
+ {
8041
+ title: title ?? tpl.epic.title,
8042
+ description: opts.description ?? tpl.epic.description
8043
+ },
8044
+ []
8045
+ );
8046
+ const epicRes = await service.callTool("create_epic", epicBody);
8047
+ const tasksBody = prepare(
8048
+ CreateTasksInput,
8049
+ {
8050
+ epic_id: epicRes.epic.id,
8051
+ tasks: tpl.tasks.map((t) => ({
8052
+ ref: t.ref,
8053
+ title: t.title,
8054
+ prompt_instruction: t.prompt_instruction,
8055
+ depends_on: t.depends_on,
8056
+ ...t.role ? { role: t.role } : {}
8057
+ }))
8058
+ },
8059
+ ["epic_id", "ref", "depends_on", "target_repo", "role", "persona"]
8060
+ );
8061
+ const tasksRes = await service.callTool("create_tasks", tasksBody);
8062
+ if (asJson) {
8063
+ return console.log(
8064
+ JSON.stringify({ epic: epicRes.epic, created: tasksRes.created }, null, 2)
8065
+ );
8066
+ }
8067
+ console.log(
8068
+ `\u2713 Epic "${epicRes.epic.title}" dibuat dari template "${tpl.id}": ${epicRes.epic.id}`
8069
+ );
8070
+ for (const t of tasksRes.created) {
8071
+ console.log(`+ ${t.ref.padEnd(16)} ${t.task_id} ${t.status}`);
8072
+ }
8073
+ console.log(
8074
+ `
8075
+ \u2713 ${tasksRes.created.length} task diajukan sebagai DRAFT. Tinjau lalu setujui dengan catenext task approve <id> sebelum agen bisa mengambilnya.`
8076
+ );
8077
+ return;
8078
+ }
8079
+ if (!title) {
8080
+ throw new PlanningInputError("Judul epic wajib diisi jika tidak memakai --template.");
8081
+ }
8082
+ const body = prepare(CreateEpicToolInput, { title, description: opts.description }, []);
7621
8083
  const res = await service.callTool("create_epic", body);
7622
8084
  if (asJson) return console.log(JSON.stringify(res, null, 2));
7623
8085
  console.log(`\u2713 Epic "${res.epic.title}" dibuat: ${res.epic.id}`);
7624
8086
  console.log(` Lanjut: catenext task create --epic ${res.epic.id} --file rencana.json`);
7625
8087
  }
8088
+ async function epicUpdate(service, epicId, opts) {
8089
+ if (opts.title === void 0 && opts.description === void 0) {
8090
+ throw new PlanningInputError("Berikan minimal --title atau --description.");
8091
+ }
8092
+ const body = prepare(
8093
+ UpdateEpicInput,
8094
+ {
8095
+ ...opts.title !== void 0 ? { title: opts.title } : {},
8096
+ ...opts.description !== void 0 ? { description: opts.description } : {}
8097
+ },
8098
+ []
8099
+ );
8100
+ const updated = await service.updateEpic(epicId, body);
8101
+ if (opts.json) return console.log(JSON.stringify({ epic: updated }, null, 2));
8102
+ console.log(`\u2713 Epic "${updated.title}" diperbarui: ${updated.id}`);
8103
+ }
7626
8104
  async function readJsonInput(file) {
7627
8105
  let raw;
7628
8106
  try {
@@ -7644,10 +8122,36 @@ async function readJsonInput(file) {
7644
8122
  throw new PlanningInputError(`${file} bukan JSON yang valid.`);
7645
8123
  }
7646
8124
  }
7647
- async function taskCreate(service, epicId, file, asJson) {
7648
- const plan = await readJsonInput(file);
7649
- const tasks = Array.isArray(plan) ? plan : plan?.tasks;
7650
- const body = prepare(CreateTasksInput, { epic_id: epicId, tasks }, [
8125
+ async function taskCreate(service, opts) {
8126
+ let tasks;
8127
+ if (opts.file !== void 0) {
8128
+ if (opts.title !== void 0 || opts.prompt !== void 0 || opts.ref !== void 0 || opts.persona !== void 0 || opts.role !== void 0 || opts.repo !== void 0 || opts.dependsOn?.length || opts.requiresApproval) {
8129
+ throw new PlanningInputError(
8130
+ "Jangan gabungkan --file dengan flag inline (--title, --prompt, --ref, --persona, --role, --repo, --depends-on, --requires-approval)."
8131
+ );
8132
+ }
8133
+ const plan = await readJsonInput(opts.file);
8134
+ tasks = Array.isArray(plan) ? plan : plan?.tasks;
8135
+ } else {
8136
+ if (!opts.title || !opts.prompt) {
8137
+ throw new PlanningInputError(
8138
+ "Wajib isi --file <path> atau mode inline (--title dan --prompt)."
8139
+ );
8140
+ }
8141
+ tasks = [
8142
+ {
8143
+ ref: opts.ref ?? "t1",
8144
+ title: opts.title,
8145
+ prompt_instruction: opts.prompt,
8146
+ ...opts.repo ? { target_repo: opts.repo } : {},
8147
+ ...opts.role ? { role: opts.role } : {},
8148
+ ...opts.persona ? { persona: opts.persona } : {},
8149
+ ...opts.dependsOn?.length ? { depends_on: opts.dependsOn } : {},
8150
+ ...opts.requiresApproval ? { requires_approval: true } : {}
8151
+ }
8152
+ ];
8153
+ }
8154
+ const body = prepare(CreateTasksInput, { epic_id: opts.epic, tasks }, [
7651
8155
  "epic_id",
7652
8156
  "ref",
7653
8157
  "depends_on",
@@ -7656,13 +8160,48 @@ async function taskCreate(service, epicId, file, asJson) {
7656
8160
  "persona"
7657
8161
  ]);
7658
8162
  const res = await service.callTool("create_tasks", body);
7659
- if (asJson) return console.log(JSON.stringify(res, null, 2));
8163
+ if (opts.json) return console.log(JSON.stringify(res, null, 2));
7660
8164
  for (const t of res.created) console.log(`+ ${t.ref.padEnd(16)} ${t.task_id} ${t.status}`);
7661
8165
  console.log(
7662
8166
  `
7663
8167
  \u2713 ${res.created.length} task diajukan sebagai DRAFT. Tinjau lalu setujui dengan catenext task approve <id> sebelum agen bisa mengambilnya.`
7664
8168
  );
7665
8169
  }
8170
+ async function taskUpdate(service, taskId, opts) {
8171
+ if (opts.title === void 0 && opts.prompt === void 0 && opts.persona === void 0 && opts.role === void 0 && opts.repo === void 0 && !opts.clearStale) {
8172
+ throw new PlanningInputError(
8173
+ "Berikan minimal satu field untuk diperbarui (--title, --prompt, --persona, --role, --repo, atau --clear-stale)."
8174
+ );
8175
+ }
8176
+ const body = prepare(
8177
+ UpdateTaskInput,
8178
+ {
8179
+ ...opts.title !== void 0 ? { title: opts.title } : {},
8180
+ ...opts.prompt !== void 0 ? { prompt_instruction: opts.prompt } : {},
8181
+ ...opts.persona !== void 0 ? { persona: opts.persona } : {},
8182
+ ...opts.role !== void 0 ? { role: opts.role } : {},
8183
+ ...opts.repo !== void 0 ? { target_repo: opts.repo } : {},
8184
+ ...opts.clearStale ? { is_stale: false } : {}
8185
+ },
8186
+ ["persona", "role", "target_repo"]
8187
+ );
8188
+ const updated = await service.updateTask(taskId, body);
8189
+ if (opts.json) return console.log(JSON.stringify({ task: updated }, null, 2));
8190
+ console.log(`\u2713 Task "${updated.title}" diperbarui (${updated.id}).`);
8191
+ }
8192
+ async function taskCancel(service, taskId, opts) {
8193
+ const res = await service.cancelTask(taskId);
8194
+ if (opts.json) return console.log(JSON.stringify(res, null, 2));
8195
+ console.log(
8196
+ `\u2713 Task "${res.title}" (${res.task_id}) dibatalkan (status sebelumnya: ${res.previous_status}).`
8197
+ );
8198
+ }
8199
+ async function taskDeps(service, taskId, depIds, opts) {
8200
+ const body = prepare(SetDependenciesInput, { depends_on: depIds }, ["depends_on"]);
8201
+ const res = await service.setTaskDependencies(taskId, body);
8202
+ if (opts.json) return console.log(JSON.stringify(res, null, 2));
8203
+ console.log(`\u2713 Dependensi task ${res.task_id} diperbarui (${res.depends_on.length} dependensi).`);
8204
+ }
7666
8205
  async function personaList(service, asJson) {
7667
8206
  const res = await service.callTool("list_personas", {});
7668
8207
  if (asJson) return console.log(JSON.stringify(res, null, 2));
@@ -8035,11 +8574,14 @@ async function taskReview(service, input, json2) {
8035
8574
  if (json2) console.log(JSON.stringify(result, null, 2));
8036
8575
  else if ("reviews" in result) {
8037
8576
  if (!result.reviews.length) console.log("Belum ada PR yang bisa Anda review di repo ini.");
8038
- for (const item of result.reviews)
8039
- console.log(`${item.task_id} ${item.title} ${item.review.url}`);
8577
+ for (const item of result.reviews) {
8578
+ const target = item.review.url ?? `(lokal base: ${item.review.base_branch})`;
8579
+ console.log(`${item.task_id} ${item.title} ${target}`);
8580
+ }
8040
8581
  } else {
8041
8582
  console.log(`${result.title} ${result.status} \xB7 ${result.review.stage}`);
8042
- console.log(`${result.review.url} @ ${result.review.head_sha}`);
8583
+ const target = result.review.url ?? `(lokal base: ${result.review.base_branch})`;
8584
+ console.log(`${target} @ ${result.review.head_sha}`);
8043
8585
  if (result.lease_id)
8044
8586
  console.log(`Lease review: ${result.lease_id} (sampai ${result.lease_expires_at})`);
8045
8587
  if (result.notes_for_next_agent) console.log(result.notes_for_next_agent);
@@ -8484,7 +9026,7 @@ function formatChecks(lines) {
8484
9026
  }
8485
9027
 
8486
9028
  // src/index.ts
8487
- var VERSION = "0.7.0";
9029
+ var VERSION = "0.8.0";
8488
9030
  var program = new Command();
8489
9031
  program.name("catenext").description("Estafet tugas & konteks antar-agen AI coding").version(VERSION);
8490
9032
  async function friendly(fn) {
@@ -8615,16 +9157,30 @@ var epic = program.command("epic").description("Kelola epic proyek ini dari term
8615
9157
  epic.command("list").description("Daftar epic beserta jumlah task per status").option("--json", "Keluaran JSON").action(
8616
9158
  (opts) => friendly(async () => epicList(await cliService(), Boolean(opts.json)))
8617
9159
  );
8618
- epic.command("create").description("Buat epic baru").argument("<title>", 'Judul epic, mis. "Fitur login"').option("-d, --description <text>", "Deskripsi / kriteria selesai").option("--json", "Keluaran JSON").action(
8619
- (title, opts) => friendly(
8620
- async () => epicCreate(await cliService(), title, opts.description, Boolean(opts.json))
8621
- )
9160
+ epic.command("templates").description("Daftar template epic bawaan").option("--json", "Keluaran JSON").action((opts) => friendly(async () => epicTemplates(Boolean(opts.json))));
9161
+ epic.command("create").description("Buat epic baru (opsional dari --template)").argument("[title]", 'Judul epic, mis. "Fitur login" (wajib tanpa --template)').option("-d, --description <text>", "Deskripsi / kriteria selesai").option(
9162
+ "-t, --template <id>",
9163
+ "Buat epic + draft task dari template (mis. fitur-login, crud-api)"
9164
+ ).option("--json", "Keluaran JSON").action(
9165
+ (title, opts) => friendly(async () => epicCreate(await cliService(), title, opts))
9166
+ );
9167
+ epic.command("update").description("Perbarui judul atau deskripsi epic").argument("<epic_id>", "ID epic yang ingin diperbarui").option("--title <text>", "Judul baru").option("-d, --description <text>", "Deskripsi baru").option("--json", "Keluaran JSON").action(
9168
+ (epicId, opts) => friendly(async () => epicUpdate(await cliService(), epicId, opts))
8622
9169
  );
8623
- var task2 = program.command("task").description("Ajukan rencana task (masuk DRAFT)");
9170
+ var task2 = program.command("task").description("Ajukan dan kelola rencana task (masuk DRAFT)");
8624
9171
  task2.command("create").description(
8625
- "Ajukan task berdependensi dari file JSON (array task atau { tasks: [...] }); pakai '-' untuk stdin"
8626
- ).requiredOption("--epic <id>", "epic_id tujuan (lihat `catenext epic list`)").requiredOption("-f, --file <path>", "File rencana JSON, atau '-' untuk stdin").option("--json", "Keluaran JSON").action(
8627
- (opts) => friendly(async () => taskCreate(await cliService(), opts.epic, opts.file, Boolean(opts.json)))
9172
+ "Ajukan task berdependensi dari file JSON (--file / '-' stdin) atau inline (--title & --prompt)"
9173
+ ).requiredOption("--epic <id>", "epic_id tujuan (lihat `catenext epic list`)").option("-f, --file <path>", "File rencana JSON, atau '-' untuk stdin").option("--title <text>", "Judul task (mode inline)").option("--prompt <text>", "Instruksi task (mode inline)").option("--ref <ref>", "Referensi task lokal untuk mode inline (default: t1)").option("--persona <alias>", "Alias persona penanggung jawab (mode inline)").option("--role <role>", "Role task (mode inline)").option("--repo <name>", "Target repo (mode inline)").option("--depends-on <ids...>", "Daftar UUID dependensi (mode inline)").option("--requires-approval", "Wajibkan persetujuan (mode inline)").option("--json", "Keluaran JSON").action(
9174
+ (opts) => friendly(async () => taskCreate(await cliService(), opts))
9175
+ );
9176
+ task2.command("update").description("Perbarui detail task (judul, prompt, persona, role, repo, atau hapus stale)").argument("<task_id>").option("--title <text>", "Judul baru").option("--prompt <text>", "Instruksi baru").option("--persona <alias>", "Alias persona baru").option("--role <role>", "Role baru").option("--repo <name>", "Target repo baru").option("--clear-stale", "Bersihkan flag stale (is_stale=false)").option("--json", "Keluaran JSON").action(
9177
+ (taskId, opts) => friendly(async () => taskUpdate(await cliService(), taskId, opts))
9178
+ );
9179
+ task2.command("cancel").description("Batalkan (hapus) task yang belum/tidak dikunci dan tanpa task dependen").argument("<task_id>").option("--json", "Keluaran JSON").action(
9180
+ (taskId, opts) => friendly(async () => taskCancel(await cliService(), taskId, opts))
9181
+ );
9182
+ task2.command("deps").description("Atur ulang daftar UUID dependensi task (validasi eksistensi & siklus DAG)").argument("<task_id>").argument("[dep_ids...]", "Daftar UUID dependensi baru (kosongkan untuk menghapus semua)").option("--json", "Keluaran JSON").action(
9183
+ (taskId, depIds, opts) => friendly(async () => taskDeps(await cliService(), taskId, depIds, opts))
8628
9184
  );
8629
9185
  task2.command("approve").description("Setujui rencana satu task lokal (DRAFT menjadi TODO)").argument("<task_id>").option("--json", "Keluaran JSON").action(
8630
9186
  (taskId, opts) => friendly(
@@ -8798,7 +9354,7 @@ program.command("done").description("Selesaikan task dengan handoff terstruktur
8798
9354
  "File yang diubah (boleh diulang; default dari git)",
8799
9355
  collect,
8800
9356
  []
8801
- ).option("--verify <cmd>", "Perintah verifikasi, mis. pnpm test").option("--pr <url>", "URL pull request GitHub (opsional, harus bersama --base)").option("--base <branch>", "Branch tujuan PR (opsional, harus bersama --pr)").option("--lease <id>", "Lease worktree dari claim").option("--handoff <file>", "File JSON handoff_summary lengkap, atau '-' untuk stdin").option("--json", "Keluaran JSON").action(
9357
+ ).option("--verify <cmd>", "Perintah verifikasi, mis. pnpm test").option("--pr <url>", "URL pull/merge request (opsional, harus bersama --base)").option("--base <branch>", "Branch tujuan PR (opsional, harus bersama --pr)").option("--lease <id>", "Lease worktree dari claim").option("--handoff <file>", "File JSON handoff_summary lengkap, atau '-' untuk stdin").option("--json", "Keluaran JSON").action(
8802
9358
  (taskId, opts) => friendly(async () => taskDone(await cliService(), taskId, opts))
8803
9359
  );
8804
9360
  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("--json", "Keluaran JSON").action(
@@ -8868,7 +9424,7 @@ review3.command("claim").argument("<task_id>").option("--as <alias>", "Persona r
8868
9424
  )
8869
9425
  )
8870
9426
  );
8871
- review3.command("refresh").description("Baca informasi PR yang tercatat lokal; tidak meminta status dari GitHub").argument("<task_id>").option("--json").action(
9427
+ review3.command("refresh").description("Baca informasi PR yang tercatat lokal; tidak meminta status dari host Git").argument("<task_id>").option("--json").action(
8872
9428
  (taskId, opts) => friendly(
8873
9429
  async () => taskReview(await cliService(), { action: "refresh", task_id: taskId }, Boolean(opts.json))
8874
9430
  )
@@ -8915,7 +9471,7 @@ program.command("verify").description("Verifikasi config, state lokal, dan entri
8915
9471
  if (checks.some((check) => !check.ok)) process.exitCode = 1;
8916
9472
  })
8917
9473
  );
8918
- program.command("sync").description("Selaraskan entri MCP, .gitignore, dan petunjuk agen; periksa skill repo lokal").option(...PLATFORM_OPT).option("--dry-run", "Tampilkan perubahan tanpa menulis ke disk").option("--fix", "Perbaiki entri MCP yang duplikat, basi (path hilang), atau file yang rusak").action(
9474
+ program.command("sync").description("Selaraskan entri MCP, .gitignore, dan petunjuk agen; periksa skill repo lokal").option(...PLATFORM_OPT).option("--dry-run", "Tampilkan perubahan tanpa menulis ke disk").option("--fix", "Perbaiki entri MCP yang duplikat, basi (path hilang), atau file yang rusak").option("--force", "Paksa perbarui entri MCP, CATENEXT.md, pointer platform, dan stub agen").action(
8919
9475
  (opts) => friendly(async () => {
8920
9476
  const root = await requireRoot();
8921
9477
  const config = await readConfig(root);
@@ -8923,6 +9479,7 @@ program.command("sync").description("Selaraskan entri MCP, .gitignore, dan petun
8923
9479
  root,
8924
9480
  platforms: opts.platform,
8925
9481
  fix: Boolean(opts.fix),
9482
+ force: Boolean(opts.force),
8926
9483
  defaultCommand: defaultMcpCommand
8927
9484
  });
8928
9485
  for (const f of plan.findings) console.log(`${f.level === "ok" ? "\u2022" : "!"} ${f.message}`);
@@ -8941,13 +9498,19 @@ program.command("sync").description("Selaraskan entri MCP, .gitignore, dan petun
8941
9498
  const platforms = opts.platform?.length ? opts.platform : configuredPlatforms(config);
8942
9499
  const service = await cliService(root);
8943
9500
  const { personas } = await service.callTool("list_personas", {});
8944
- const sub = await planSubagents(root, personas, platforms, {
8945
- stack: config.stack ?? [],
8946
- repoName: config.repo_name,
8947
- layout: config.layout
8948
- });
9501
+ const sub = await planSubagents(
9502
+ root,
9503
+ personas,
9504
+ platforms,
9505
+ {
9506
+ stack: config.stack ?? [],
9507
+ repoName: config.repo_name,
9508
+ layout: config.layout
9509
+ },
9510
+ { force: Boolean(opts.force) }
9511
+ );
8949
9512
  const { planEntryPointers: planEntryPointers2 } = await Promise.resolve().then(() => (init_entry_pointers(), entry_pointers_exports));
8950
- const pointers = await planEntryPointers2(root, platforms);
9513
+ const pointers = await planEntryPointers2(root, platforms, { force: Boolean(opts.force) });
8951
9514
  const agentEdits = [...sub.edits, ...pointers];
8952
9515
  await applyFileEdits(root, agentEdits);
8953
9516
  for (const l of summarize(agentEdits)) console.log(l);