catenext 0.3.0 → 0.5.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 +33 -0
- package/README.md +140 -81
- package/dist/index.js +615 -253
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,6 +13,8 @@ import { z as z5 } from "zod";
|
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
var IdSchema = z.uuid();
|
|
15
15
|
var SlugSchema = z.string().min(1).max(64).regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Harus slug huruf kecil (a-z, 0-9, '-' atau '_')");
|
|
16
|
+
var PROJECT_LAYOUTS = ["monorepo", "polyrepo"];
|
|
17
|
+
var ProjectLayoutSchema = z.enum(PROJECT_LAYOUTS);
|
|
16
18
|
var RepoNameSchema = SlugSchema;
|
|
17
19
|
var RoleSchema = SlugSchema.max(32);
|
|
18
20
|
var AgentAliasSchema = SlugSchema.max(32);
|
|
@@ -148,7 +150,7 @@ var TASK_EVENTS = [
|
|
|
148
150
|
"claim",
|
|
149
151
|
// agent: TODO | REVISION_REQUESTED -> IN_PROGRESS
|
|
150
152
|
"complete",
|
|
151
|
-
// agent: IN_PROGRESS ->
|
|
153
|
+
// agent: IN_PROGRESS -> NEEDS_REVIEW (PR wajib di complete_handoff)
|
|
152
154
|
"report_blocker",
|
|
153
155
|
// agent: IN_PROGRESS -> BLOCKED
|
|
154
156
|
"release",
|
|
@@ -223,6 +225,8 @@ var ProjectSchema = z5.object({
|
|
|
223
225
|
workspace_id: IdSchema,
|
|
224
226
|
name: z5.string().min(1).max(120),
|
|
225
227
|
detected_stack: z5.array(z5.string()),
|
|
228
|
+
/** monorepo = satu git (claim wajib worktree); polyrepo = clone terpisah per Cloud repo. */
|
|
229
|
+
layout: ProjectLayoutSchema.default("polyrepo"),
|
|
226
230
|
agent_connected_at: IsoDateTimeSchema.nullable(),
|
|
227
231
|
created_at: IsoDateTimeSchema,
|
|
228
232
|
updated_at: IsoDateTimeSchema
|
|
@@ -292,11 +296,13 @@ var ProjectMetricsSchema = z5.object({
|
|
|
292
296
|
});
|
|
293
297
|
var CreateProjectInput = z5.object({
|
|
294
298
|
name: z5.string().trim().min(1).max(120),
|
|
295
|
-
detected_stack: z5.array(z5.string().min(1).max(40)).max(20).default([])
|
|
299
|
+
detected_stack: z5.array(z5.string().min(1).max(40)).max(20).default([]),
|
|
300
|
+
layout: ProjectLayoutSchema.default("polyrepo")
|
|
296
301
|
});
|
|
297
302
|
var UpdateProjectInput = z5.object({
|
|
298
303
|
name: z5.string().trim().min(1).max(120).optional(),
|
|
299
|
-
detected_stack: z5.array(z5.string().min(1).max(40)).max(20).optional()
|
|
304
|
+
detected_stack: z5.array(z5.string().min(1).max(40)).max(20).optional(),
|
|
305
|
+
layout: ProjectLayoutSchema.optional()
|
|
300
306
|
});
|
|
301
307
|
var CreateEpicInput = z5.object({
|
|
302
308
|
title: z5.string().trim().min(1).max(200),
|
|
@@ -559,10 +565,34 @@ var SaveDocumentOutput = z8.object({
|
|
|
559
565
|
});
|
|
560
566
|
|
|
561
567
|
// shared/src/mcp-tools.ts
|
|
562
|
-
import { z as
|
|
568
|
+
import { z as z11 } from "zod";
|
|
563
569
|
|
|
564
|
-
// shared/src/
|
|
570
|
+
// shared/src/search.ts
|
|
565
571
|
import { z as z9 } from "zod";
|
|
572
|
+
var SEARCH_SOURCES = ["document", "skill", "task"];
|
|
573
|
+
var SearchSourceSchema = z9.enum(SEARCH_SOURCES);
|
|
574
|
+
var SearchContextInput = z9.object({
|
|
575
|
+
query: z9.string().trim().min(1).max(500),
|
|
576
|
+
sources: z9.array(SearchSourceSchema).min(1).max(3).default(["document", "skill", "task"]),
|
|
577
|
+
limit: z9.number().int().min(1).max(20).default(8)
|
|
578
|
+
});
|
|
579
|
+
var SearchHitSchema = z9.object({
|
|
580
|
+
source: SearchSourceSchema,
|
|
581
|
+
ref: z9.string().min(1).max(200),
|
|
582
|
+
title: z9.string().min(1).max(300),
|
|
583
|
+
snippet: z9.string().max(800),
|
|
584
|
+
score: z9.number()
|
|
585
|
+
});
|
|
586
|
+
var SearchContextOutput = z9.object({
|
|
587
|
+
hits: z9.array(SearchHitSchema),
|
|
588
|
+
reranked: z9.boolean(),
|
|
589
|
+
/** true bila embedding/rerank memakai fallback lokal (tanpa API key provider). */
|
|
590
|
+
degraded: z9.boolean().default(false)
|
|
591
|
+
});
|
|
592
|
+
var LOCAL_EMBED_DIMS = 64;
|
|
593
|
+
|
|
594
|
+
// shared/src/skill.ts
|
|
595
|
+
import { z as z10 } from "zod";
|
|
566
596
|
var SKILL_LIMITS = {
|
|
567
597
|
maxWords: 500,
|
|
568
598
|
maxWhenToUseLength: 160,
|
|
@@ -570,9 +600,9 @@ var SKILL_LIMITS = {
|
|
|
570
600
|
maxCodeBlockLines: 15
|
|
571
601
|
};
|
|
572
602
|
var SkillNameSchema = SlugSchema.max(48);
|
|
573
|
-
var SkillFrontmatterSchema =
|
|
603
|
+
var SkillFrontmatterSchema = z10.object({
|
|
574
604
|
name: SkillNameSchema,
|
|
575
|
-
when_to_use:
|
|
605
|
+
when_to_use: z10.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
|
|
576
606
|
updated_at: IsoDateTimeSchema
|
|
577
607
|
});
|
|
578
608
|
function longestCodeBlockLines(markdown) {
|
|
@@ -584,14 +614,14 @@ function longestCodeBlockLines(markdown) {
|
|
|
584
614
|
}
|
|
585
615
|
return longest;
|
|
586
616
|
}
|
|
587
|
-
var SkillContentSchema =
|
|
617
|
+
var SkillContentSchema = z10.string().min(1).refine((s) => countWords(s) <= SKILL_LIMITS.maxWords, {
|
|
588
618
|
message: `Skill maksimal ${SKILL_LIMITS.maxWords} kata`
|
|
589
619
|
}).refine((s) => longestCodeBlockLines(s) <= SKILL_LIMITS.maxCodeBlockLines, {
|
|
590
620
|
message: `Blok kode maksimal ${SKILL_LIMITS.maxCodeBlockLines} baris; rujuk path file, jangan menyalin kode`
|
|
591
621
|
});
|
|
592
|
-
var SkillIndexEntrySchema =
|
|
622
|
+
var SkillIndexEntrySchema = z10.object({
|
|
593
623
|
name: SkillNameSchema,
|
|
594
|
-
when_to_use:
|
|
624
|
+
when_to_use: z10.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
|
|
595
625
|
repo_name: RepoNameSchema
|
|
596
626
|
});
|
|
597
627
|
function skillPath(name) {
|
|
@@ -603,149 +633,158 @@ var PersonaFilter = {
|
|
|
603
633
|
agent_alias: AgentAliasSchema.optional(),
|
|
604
634
|
role: RoleSchema.optional()
|
|
605
635
|
};
|
|
606
|
-
var PersonaReposSchema =
|
|
607
|
-
var PersonaSchema =
|
|
636
|
+
var PersonaReposSchema = z11.array(RepoNameSchema).max(10);
|
|
637
|
+
var PersonaSchema = z11.object({
|
|
608
638
|
alias: AgentAliasSchema,
|
|
609
639
|
role: RoleSchema,
|
|
610
|
-
rules:
|
|
640
|
+
rules: z11.array(z11.string().min(1).max(300)).max(30),
|
|
611
641
|
repos: PersonaReposSchema.default([])
|
|
612
642
|
});
|
|
613
|
-
var DependencyHandoffSchema =
|
|
643
|
+
var DependencyHandoffSchema = z11.object({
|
|
614
644
|
task_id: IdSchema,
|
|
615
|
-
title:
|
|
645
|
+
title: z11.string(),
|
|
616
646
|
handoff_summary: HandoffSummarySchema,
|
|
617
|
-
integrated_commit:
|
|
647
|
+
integrated_commit: z11.object({ branch: z11.string(), sha: CommitShaSchema }).optional()
|
|
618
648
|
});
|
|
619
|
-
var GetProjectContextInput =
|
|
620
|
-
var GetProjectContextOutput =
|
|
621
|
-
project:
|
|
649
|
+
var GetProjectContextInput = z11.object({ ...PersonaFilter, lease_id: IdSchema.optional() });
|
|
650
|
+
var GetProjectContextOutput = z11.object({
|
|
651
|
+
project: z11.object({
|
|
622
652
|
id: IdSchema,
|
|
623
|
-
name:
|
|
653
|
+
name: z11.string(),
|
|
624
654
|
repo_name: RepoNameSchema,
|
|
625
|
-
stack:
|
|
655
|
+
stack: z11.array(z11.string()),
|
|
656
|
+
layout: z11.enum(["monorepo", "polyrepo"]).default("polyrepo")
|
|
626
657
|
}),
|
|
627
658
|
/** Aturan keras untuk agen (mis. jangan mengedit config MCP). Statis di atas agar ramah cache. */
|
|
628
|
-
directives:
|
|
659
|
+
directives: z11.array(z11.string()),
|
|
629
660
|
persona: PersonaSchema.optional(),
|
|
630
|
-
epic_summary:
|
|
661
|
+
epic_summary: z11.string().max(1e3).optional(),
|
|
631
662
|
/** Tier 1: indeks skill saja, isi lengkap lewat load_skill. */
|
|
632
|
-
skills:
|
|
663
|
+
skills: z11.array(SkillIndexEntrySchema),
|
|
633
664
|
skill_revision: CommitShaSchema.optional(),
|
|
634
665
|
/**
|
|
635
666
|
* Handoff dari dependensi langsung task aktif (dependency-scoped context). Jika belum ada
|
|
636
667
|
* task aktif: handoff dependensi task yang siap diklaim (maks. 5).
|
|
637
668
|
*/
|
|
638
|
-
recent_handoffs:
|
|
669
|
+
recent_handoffs: z11.array(DependencyHandoffSchema),
|
|
639
670
|
/** Repo yang dikenal proyek, agar orchestrator tahu ke mana task bisa diarahkan. */
|
|
640
|
-
project_repos:
|
|
671
|
+
project_repos: z11.array(RepoNameSchema).default([]),
|
|
641
672
|
/** Indeks dokumen proyek di Cloud (blueprint, ERD, ...); isi lewat get_document. */
|
|
642
|
-
documents:
|
|
673
|
+
documents: z11.array(DocumentIndexEntrySchema).default([])
|
|
643
674
|
});
|
|
644
|
-
var GetProjectBoardInput =
|
|
675
|
+
var GetProjectBoardInput = z11.object({
|
|
645
676
|
epic_id: IdSchema.optional(),
|
|
646
677
|
/** Tanpa filter: semua status. */
|
|
647
|
-
status:
|
|
648
|
-
limit:
|
|
678
|
+
status: z11.array(TaskStatusSchema).max(7).optional(),
|
|
679
|
+
limit: z11.number().int().min(1).max(200).default(100)
|
|
649
680
|
});
|
|
650
|
-
var BoardTaskSchema =
|
|
681
|
+
var BoardTaskSchema = z11.object({
|
|
651
682
|
id: IdSchema,
|
|
652
|
-
title:
|
|
683
|
+
title: z11.string(),
|
|
653
684
|
epic_id: IdSchema,
|
|
654
685
|
status: TaskStatusSchema,
|
|
655
686
|
target_repo: RepoNameSchema.nullable(),
|
|
656
687
|
role: RoleSchema.nullable(),
|
|
657
688
|
persona: AgentAliasSchema.nullable(),
|
|
658
|
-
depends_on:
|
|
689
|
+
depends_on: z11.array(IdSchema),
|
|
659
690
|
/** TODO/REVISION_REQUESTED dengan semua dependensi DONE. */
|
|
660
|
-
is_ready:
|
|
661
|
-
is_stale:
|
|
662
|
-
revision_count:
|
|
691
|
+
is_ready: z11.boolean(),
|
|
692
|
+
is_stale: z11.boolean(),
|
|
693
|
+
revision_count: z11.number().int().min(0),
|
|
663
694
|
/** Repo yang sedang memegang lease (IN_PROGRESS). */
|
|
664
695
|
locked_by_repo: RepoNameSchema.nullable(),
|
|
665
|
-
blocker_reason:
|
|
696
|
+
blocker_reason: z11.string().nullable()
|
|
666
697
|
});
|
|
667
|
-
var GetProjectBoardOutput =
|
|
668
|
-
epics:
|
|
669
|
-
|
|
698
|
+
var GetProjectBoardOutput = z11.object({
|
|
699
|
+
epics: z11.array(
|
|
700
|
+
z11.object({
|
|
670
701
|
id: IdSchema,
|
|
671
|
-
title:
|
|
672
|
-
counts:
|
|
702
|
+
title: z11.string(),
|
|
703
|
+
counts: z11.record(z11.string(), z11.number().int())
|
|
673
704
|
})
|
|
674
705
|
),
|
|
675
706
|
/** Repo yang dikenal proyek (dari task, skill, dan persona) beserta persona pemegangnya. */
|
|
676
|
-
repos:
|
|
677
|
-
personas:
|
|
678
|
-
tasks:
|
|
679
|
-
truncated:
|
|
707
|
+
repos: z11.array(z11.object({ repo: RepoNameSchema, personas: z11.array(AgentAliasSchema) })),
|
|
708
|
+
personas: z11.array(PersonaSchema),
|
|
709
|
+
tasks: z11.array(BoardTaskSchema),
|
|
710
|
+
truncated: z11.boolean()
|
|
680
711
|
});
|
|
681
|
-
var GetReadyTasksInput =
|
|
712
|
+
var GetReadyTasksInput = z11.object({
|
|
682
713
|
...PersonaFilter,
|
|
683
714
|
lease_id: IdSchema.optional(),
|
|
684
|
-
limit:
|
|
715
|
+
limit: z11.number().int().min(1).max(50).default(10)
|
|
685
716
|
});
|
|
686
|
-
var GetReadyTasksOutput =
|
|
687
|
-
tasks:
|
|
717
|
+
var GetReadyTasksOutput = z11.object({
|
|
718
|
+
tasks: z11.array(TaskSummarySchema)
|
|
688
719
|
});
|
|
689
|
-
var ClaimTaskInput =
|
|
690
|
-
worktree:
|
|
720
|
+
var ClaimTaskInput = z11.object({
|
|
721
|
+
worktree: z11.object({
|
|
691
722
|
session_id: IdSchema,
|
|
692
|
-
branch:
|
|
723
|
+
branch: z11.string().min(1).max(255).regex(/^[a-zA-Z0-9_./-]+$/).refine((s) => s !== "HEAD" && !s.startsWith("-") && !s.includes(".."))
|
|
693
724
|
}).optional(),
|
|
694
725
|
task_id: IdSchema,
|
|
695
726
|
/** Alias persona yang sedang dipakai agen. Task milik persona lain ditolak. */
|
|
696
727
|
agent_alias: AgentAliasSchema.optional()
|
|
697
728
|
});
|
|
698
|
-
var ClaimTaskOutput =
|
|
699
|
-
task:
|
|
729
|
+
var ClaimTaskOutput = z11.object({
|
|
730
|
+
task: z11.object({
|
|
700
731
|
id: IdSchema,
|
|
701
|
-
title:
|
|
702
|
-
prompt_instruction:
|
|
703
|
-
status:
|
|
732
|
+
title: z11.string(),
|
|
733
|
+
prompt_instruction: z11.string(),
|
|
734
|
+
status: z11.literal("IN_PROGRESS"),
|
|
704
735
|
role: RoleSchema.optional(),
|
|
705
736
|
target_repo: RepoNameSchema.optional(),
|
|
706
|
-
revision_count:
|
|
737
|
+
revision_count: z11.number().int().min(0)
|
|
707
738
|
}),
|
|
708
739
|
/** Persona penanggung jawab task (atau persona agen): ikuti aturan dan batas wilayahnya. */
|
|
709
740
|
persona: PersonaSchema.optional(),
|
|
710
741
|
lease_expires_at: IsoDateTimeSchema,
|
|
711
742
|
lease_id: IdSchema.optional(),
|
|
712
|
-
dependencies:
|
|
743
|
+
dependencies: z11.array(DependencyHandoffSchema),
|
|
713
744
|
/** Diisi bila task diambil dari REVISION_REQUESTED. */
|
|
714
|
-
revision:
|
|
715
|
-
review_feedback:
|
|
745
|
+
revision: z11.object({
|
|
746
|
+
review_feedback: z11.string(),
|
|
716
747
|
previous_handoff: HandoffSummarySchema.nullable()
|
|
717
748
|
}).optional(),
|
|
718
749
|
/** Peringatan bila branch lokal berbeda dari git_branch handoff dependensi. */
|
|
719
|
-
warnings:
|
|
750
|
+
warnings: z11.array(z11.string()).default([])
|
|
720
751
|
});
|
|
721
|
-
var CompleteHandoffInput =
|
|
752
|
+
var CompleteHandoffInput = z11.object({
|
|
722
753
|
lease_id: IdSchema.optional(),
|
|
723
754
|
task_id: IdSchema,
|
|
724
755
|
handoff_summary: HandoffSummarySchema
|
|
756
|
+
}).superRefine((input, ctx) => {
|
|
757
|
+
if (!input.handoff_summary.pull_request) {
|
|
758
|
+
ctx.addIssue({
|
|
759
|
+
code: "custom",
|
|
760
|
+
message: "pull_request wajib: buat PR di branch kerja lalu sertakan url, base_branch, dan head_sha.",
|
|
761
|
+
path: ["handoff_summary", "pull_request"]
|
|
762
|
+
});
|
|
763
|
+
}
|
|
725
764
|
});
|
|
726
|
-
var CompleteHandoffOutput =
|
|
765
|
+
var CompleteHandoffOutput = z11.object({
|
|
727
766
|
task_id: IdSchema,
|
|
728
|
-
status:
|
|
729
|
-
unlocked_task_ids:
|
|
767
|
+
status: z11.literal("NEEDS_REVIEW"),
|
|
768
|
+
unlocked_task_ids: z11.array(IdSchema),
|
|
730
769
|
/** Mis. saran mereset sesi chat (1 Task = 1 Fresh Session). */
|
|
731
|
-
next_step_hint:
|
|
770
|
+
next_step_hint: z11.string()
|
|
732
771
|
});
|
|
733
|
-
var ReportBlockerInput =
|
|
772
|
+
var ReportBlockerInput = z11.object({
|
|
734
773
|
lease_id: IdSchema.optional(),
|
|
735
774
|
task_id: IdSchema,
|
|
736
775
|
category: BlockerCategorySchema,
|
|
737
|
-
reason:
|
|
776
|
+
reason: z11.string().min(10).max(1e3)
|
|
738
777
|
});
|
|
739
|
-
var ReportBlockerOutput =
|
|
778
|
+
var ReportBlockerOutput = z11.object({
|
|
740
779
|
task_id: IdSchema,
|
|
741
|
-
status:
|
|
780
|
+
status: z11.literal("BLOCKED")
|
|
742
781
|
});
|
|
743
782
|
var MANAGE_TASK_ACTIONS = ["request_revision", "assign"];
|
|
744
|
-
var ManageTaskInput =
|
|
745
|
-
action:
|
|
783
|
+
var ManageTaskInput = z11.object({
|
|
784
|
+
action: z11.enum(MANAGE_TASK_ACTIONS),
|
|
746
785
|
task_id: IdSchema,
|
|
747
786
|
/** Wajib untuk request_revision: apa yang harus diperbaiki (feedback manusia/orchestrator). */
|
|
748
|
-
feedback:
|
|
787
|
+
feedback: z11.string().trim().min(5).max(2e3).optional(),
|
|
749
788
|
/** Persona penanggung jawab baru. null = lepas persona (task diambil berdasarkan role). */
|
|
750
789
|
agent_alias: AgentAliasSchema.nullable().optional(),
|
|
751
790
|
/** Role task tanpa persona tertentu. Diabaikan bila agent_alias diisi (role ikut persona). */
|
|
@@ -766,31 +805,31 @@ var ManageTaskInput = z10.object({
|
|
|
766
805
|
});
|
|
767
806
|
}
|
|
768
807
|
});
|
|
769
|
-
var ManageTaskOutput =
|
|
808
|
+
var ManageTaskOutput = z11.object({
|
|
770
809
|
task_id: IdSchema,
|
|
771
810
|
status: TaskStatusSchema,
|
|
772
811
|
persona: AgentAliasSchema.nullable(),
|
|
773
812
|
role: RoleSchema.nullable(),
|
|
774
|
-
revision_count:
|
|
775
|
-
stale_task_ids:
|
|
813
|
+
revision_count: z11.number().int().min(0),
|
|
814
|
+
stale_task_ids: z11.array(IdSchema)
|
|
776
815
|
});
|
|
777
816
|
var MAX_TASKS_PER_PLAN = 30;
|
|
778
|
-
var PlanRefSchema =
|
|
779
|
-
var PlannedTaskSchema =
|
|
817
|
+
var PlanRefSchema = z11.string().min(1).max(40).regex(/^[a-z0-9][a-z0-9_-]*$/, "ref harus huruf kecil, angka, '-' atau '_'");
|
|
818
|
+
var PlannedTaskSchema = z11.object({
|
|
780
819
|
ref: PlanRefSchema,
|
|
781
|
-
title:
|
|
782
|
-
prompt_instruction:
|
|
820
|
+
title: z11.string().min(1).max(200),
|
|
821
|
+
prompt_instruction: z11.string().min(1).max(8e3),
|
|
783
822
|
/** Berisi ref task lain dalam rencana ini, atau UUID task yang sudah ada. */
|
|
784
|
-
depends_on:
|
|
823
|
+
depends_on: z11.array(z11.union([PlanRefSchema, IdSchema])).max(10).default([]),
|
|
785
824
|
target_repo: RepoNameSchema.optional(),
|
|
786
825
|
role: RoleSchema.optional(),
|
|
787
826
|
/** Alias persona penanggung jawab (lihat list_personas). Role task mengikuti persona ini. */
|
|
788
827
|
persona: AgentAliasSchema.optional(),
|
|
789
|
-
requires_approval:
|
|
828
|
+
requires_approval: z11.boolean().default(false)
|
|
790
829
|
});
|
|
791
|
-
var CreateTasksInput =
|
|
830
|
+
var CreateTasksInput = z11.object({
|
|
792
831
|
epic_id: IdSchema,
|
|
793
|
-
tasks:
|
|
832
|
+
tasks: z11.array(PlannedTaskSchema).min(1).max(MAX_TASKS_PER_PLAN)
|
|
794
833
|
}).superRefine((plan, ctx) => {
|
|
795
834
|
const refs = /* @__PURE__ */ new Set();
|
|
796
835
|
plan.tasks.forEach((t, i) => {
|
|
@@ -833,58 +872,58 @@ var CreateTasksInput = z10.object({
|
|
|
833
872
|
});
|
|
834
873
|
}
|
|
835
874
|
});
|
|
836
|
-
var CreateTasksOutput =
|
|
837
|
-
created:
|
|
838
|
-
|
|
839
|
-
ref:
|
|
875
|
+
var CreateTasksOutput = z11.object({
|
|
876
|
+
created: z11.array(
|
|
877
|
+
z11.object({
|
|
878
|
+
ref: z11.string(),
|
|
840
879
|
task_id: IdSchema,
|
|
841
880
|
status: TaskStatusSchema
|
|
842
881
|
})
|
|
843
882
|
)
|
|
844
883
|
});
|
|
845
|
-
var LoadSkillInput =
|
|
884
|
+
var LoadSkillInput = z11.object({
|
|
846
885
|
name: SkillNameSchema,
|
|
847
886
|
revision: CommitShaSchema.optional()
|
|
848
887
|
});
|
|
849
|
-
var LoadSkillOutput =
|
|
888
|
+
var LoadSkillOutput = z11.object({
|
|
850
889
|
name: SkillNameSchema,
|
|
851
890
|
revision: CommitShaSchema.optional(),
|
|
852
|
-
when_to_use:
|
|
853
|
-
content:
|
|
891
|
+
when_to_use: z11.string(),
|
|
892
|
+
content: z11.string()
|
|
854
893
|
});
|
|
855
|
-
var SaveRepoSkillInput =
|
|
894
|
+
var SaveRepoSkillInput = z11.object({
|
|
856
895
|
name: SkillNameSchema,
|
|
857
|
-
when_to_use:
|
|
896
|
+
when_to_use: z11.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
|
|
858
897
|
content: SkillContentSchema
|
|
859
898
|
});
|
|
860
|
-
var SaveRepoSkillOutput =
|
|
861
|
-
path:
|
|
862
|
-
created:
|
|
899
|
+
var SaveRepoSkillOutput = z11.object({
|
|
900
|
+
path: z11.string(),
|
|
901
|
+
created: z11.boolean()
|
|
863
902
|
});
|
|
864
|
-
var EpicSummarySchema =
|
|
903
|
+
var EpicSummarySchema = z11.object({
|
|
865
904
|
id: IdSchema,
|
|
866
|
-
title:
|
|
867
|
-
description:
|
|
905
|
+
title: z11.string(),
|
|
906
|
+
description: z11.string().nullable(),
|
|
868
907
|
/** Jumlah task per status, mis. { DRAFT: 3, TODO: 1 }. */
|
|
869
|
-
task_counts:
|
|
908
|
+
task_counts: z11.record(z11.string(), z11.number().int().min(0))
|
|
870
909
|
});
|
|
871
|
-
var ListEpicsInput =
|
|
872
|
-
var ListEpicsOutput =
|
|
873
|
-
epics:
|
|
910
|
+
var ListEpicsInput = z11.object({});
|
|
911
|
+
var ListEpicsOutput = z11.object({
|
|
912
|
+
epics: z11.array(EpicSummarySchema)
|
|
874
913
|
});
|
|
875
|
-
var CreateEpicToolInput =
|
|
876
|
-
title:
|
|
877
|
-
description:
|
|
914
|
+
var CreateEpicToolInput = z11.object({
|
|
915
|
+
title: z11.string().trim().min(1).max(200),
|
|
916
|
+
description: z11.string().max(4e3).optional()
|
|
878
917
|
});
|
|
879
|
-
var CreateEpicToolOutput =
|
|
918
|
+
var CreateEpicToolOutput = z11.object({
|
|
880
919
|
epic: EpicSummarySchema
|
|
881
920
|
});
|
|
882
|
-
var ListPersonasInput =
|
|
883
|
-
var ListPersonasOutput =
|
|
884
|
-
personas:
|
|
921
|
+
var ListPersonasInput = z11.object({});
|
|
922
|
+
var ListPersonasOutput = z11.object({
|
|
923
|
+
personas: z11.array(
|
|
885
924
|
PersonaSchema.extend({
|
|
886
925
|
/** "project" = khusus proyek ini (bisa diubah agen); "workspace" = global, hanya dari Web. */
|
|
887
|
-
scope:
|
|
926
|
+
scope: z11.enum(["project", "workspace"])
|
|
888
927
|
})
|
|
889
928
|
)
|
|
890
929
|
});
|
|
@@ -893,13 +932,13 @@ var UpsertPersonaInput = PersonaSchema.extend({
|
|
|
893
932
|
* Tidak dikirim = aturan dipertahankan; persona proyek baru mewarisi aturan persona master
|
|
894
933
|
* (workspace) dengan alias yang sama.
|
|
895
934
|
*/
|
|
896
|
-
rules:
|
|
935
|
+
rules: z11.array(z11.string().trim().min(1).max(300)).max(30).optional(),
|
|
897
936
|
/** Tidak dikirim = repo persona yang ada dipertahankan. */
|
|
898
937
|
repos: PersonaReposSchema.optional()
|
|
899
938
|
});
|
|
900
|
-
var UpsertPersonaOutput =
|
|
939
|
+
var UpsertPersonaOutput = z11.object({
|
|
901
940
|
persona: PersonaSchema,
|
|
902
|
-
created:
|
|
941
|
+
created: z11.boolean()
|
|
903
942
|
});
|
|
904
943
|
function tool(description, input, output) {
|
|
905
944
|
return { description, input, output };
|
|
@@ -908,13 +947,18 @@ var MCP_TOOLS = {
|
|
|
908
947
|
release_task: tool(
|
|
909
948
|
"Lepas lease task supaya sesi lain bisa mengambilnya.",
|
|
910
949
|
ReleaseTaskInput,
|
|
911
|
-
|
|
950
|
+
z11.object({ task_id: IdSchema, status: z11.enum(["TODO", "REVISION_REQUESTED"]) })
|
|
912
951
|
),
|
|
913
952
|
get_project_board: tool(
|
|
914
953
|
"Khusus orchestrator: papan seluruh proyek lintas repo (epic, task, status, persona, repo, dependensi) untuk membagi, melanjutkan, dan menyerahkan task.",
|
|
915
954
|
GetProjectBoardInput,
|
|
916
955
|
GetProjectBoardOutput
|
|
917
956
|
),
|
|
957
|
+
search_context: tool(
|
|
958
|
+
"Cari semantik di dokumen Cloud, indeks skill, dan task proyek (embedding + cache; rerank bila tersedia). Pakai sebelum load_skill/get_document buta.",
|
|
959
|
+
SearchContextInput,
|
|
960
|
+
SearchContextOutput
|
|
961
|
+
),
|
|
918
962
|
get_document: tool(
|
|
919
963
|
"Baca isi dokumen proyek di Cloud (blueprint, ERD, arsitektur, kontrak API, keputusan) berdasarkan slug dari get_project_context.",
|
|
920
964
|
GetDocumentInput,
|
|
@@ -932,7 +976,7 @@ var MCP_TOOLS = {
|
|
|
932
976
|
),
|
|
933
977
|
review_pull_request: tool(
|
|
934
978
|
"Antrean, claim, hasil review, atau cek merge pull request.",
|
|
935
|
-
|
|
979
|
+
z11.object({ request: ReviewInput }),
|
|
936
980
|
ReviewOutput
|
|
937
981
|
),
|
|
938
982
|
get_project_context: tool(
|
|
@@ -946,12 +990,12 @@ var MCP_TOOLS = {
|
|
|
946
990
|
GetReadyTasksOutput
|
|
947
991
|
),
|
|
948
992
|
claim_task: tool(
|
|
949
|
-
"Kunci task (lease 30 menit) dan ambil instruksi lengkap, handoff dependensi, serta aturan persona
|
|
993
|
+
"Kunci task (lease 30 menit) dan ambil instruksi lengkap, handoff dependensi, serta aturan persona. Bila project.layout=monorepo, kirim worktree (branch + session_id). Polyrepo: worktree opsional. Kirim agent_alias bila bekerja sebagai persona tertentu.",
|
|
950
994
|
ClaimTaskInput,
|
|
951
995
|
ClaimTaskOutput
|
|
952
996
|
),
|
|
953
997
|
complete_handoff: tool(
|
|
954
|
-
"Selesaikan task dengan
|
|
998
|
+
"Selesaikan task dengan handoff terstruktur; pull_request wajib (url, base_branch, head_sha). Status selalu NEEDS_REVIEW sampai manusia approve/merge PR. Commit di branch kerja OK; jangan merge ke default branch sendiri.",
|
|
955
999
|
CompleteHandoffInput,
|
|
956
1000
|
CompleteHandoffOutput
|
|
957
1001
|
),
|
|
@@ -1030,11 +1074,11 @@ var ORCHESTRATOR_RULES = [
|
|
|
1030
1074
|
"",
|
|
1031
1075
|
"### Alur subagent (persona)",
|
|
1032
1076
|
"",
|
|
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.",
|
|
1077
|
+
"1. Pastikan berada di folder repo yang dipegang. `get_ready_tasks` dan `claim_task` dengan `agent_alias: <alias>`; patuhi aturan persona di hasil claim. Bila `layout` proyek = `monorepo`, claim wajib mode worktree. Task di kolom Revisi didahulukan dan membawa feedback revisinya.",
|
|
1034
1078
|
"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
|
|
1037
|
-
"5. Laporkan ke orchestrator: task, status, dan perintah verifikasi.",
|
|
1079
|
+
"3. Kerjakan, jalankan tes, commit di branch/worktree kerja (boleh commit sewaktu-waktu; jangan merge ke default branch).",
|
|
1080
|
+
"4. Buat PR, lalu `complete_handoff` dengan `pull_request` wajib (status \u2192 NEEDS_REVIEW), atau `report_blocker` bila buntu.",
|
|
1081
|
+
"5. Laporkan ke orchestrator: task, status, URL PR, dan perintah verifikasi.",
|
|
1038
1082
|
"",
|
|
1039
1083
|
"Subagent hanya mengerjakan satu task per pemanggilan dan tidak memanggil `create_tasks`, `manage_task`, `upsert_persona`, atau `save_document`."
|
|
1040
1084
|
];
|
|
@@ -1042,7 +1086,7 @@ var CLI_FALLBACK_RULES = [
|
|
|
1042
1086
|
"### Tanpa tool MCP",
|
|
1043
1087
|
"",
|
|
1044
1088
|
"- 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
|
|
1089
|
+
'- Subagent: `catenext next --as <alias>`, `catenext claim <task_id> --as <alias> [--worktree]` (wajib `--worktree` di monorepo), kerjakan & commit di branch, buat PR, lalu `catenext done <task_id> --notes "..." --verify "..." --pr <url> --base <branch>`.',
|
|
1046
1090
|
'- Bila buntu: `catenext block <task_id> --category <missing_env|ambiguous_requirement|failing_tests|dependency_issue|other> --reason "..."`.'
|
|
1047
1091
|
];
|
|
1048
1092
|
var GENERAL_RULES = [
|
|
@@ -1050,9 +1094,9 @@ var GENERAL_RULES = [
|
|
|
1050
1094
|
];
|
|
1051
1095
|
|
|
1052
1096
|
// shared/src/quota.ts
|
|
1053
|
-
import { z as
|
|
1097
|
+
import { z as z12 } from "zod";
|
|
1054
1098
|
var PLANS = ["free", "pro", "team"];
|
|
1055
|
-
var PlanSchema =
|
|
1099
|
+
var PlanSchema = z12.enum(PLANS);
|
|
1056
1100
|
var QUOTA_DIMENSIONS = [
|
|
1057
1101
|
/** Jumlah proyek di workspace. */
|
|
1058
1102
|
"projects",
|
|
@@ -1077,38 +1121,42 @@ var QUOTA_DIMENSIONS = [
|
|
|
1077
1121
|
/** Task yang dipindah ke kolom Revisi per bulan oleh manusia (Web) atau orchestrator. */
|
|
1078
1122
|
"revisions_per_month",
|
|
1079
1123
|
/** Task yang sedang dikerjakan bersamaan (IN_PROGRESS) di workspace. */
|
|
1080
|
-
"active_tasks"
|
|
1124
|
+
"active_tasks",
|
|
1125
|
+
/** Panggilan search_context per hari kalender. */
|
|
1126
|
+
"search_queries_per_day",
|
|
1127
|
+
/** Total karakter teks yang diindeks embedding per workspace. */
|
|
1128
|
+
"indexed_chars"
|
|
1081
1129
|
];
|
|
1082
|
-
var QuotaDimensionSchema =
|
|
1130
|
+
var QuotaDimensionSchema = z12.enum(QUOTA_DIMENSIONS);
|
|
1083
1131
|
var QUOTA_WARNING_HEADER = "x-catenext-quota-warning";
|
|
1084
|
-
var QuotaExceededDetailsSchema =
|
|
1132
|
+
var QuotaExceededDetailsSchema = z12.object({
|
|
1085
1133
|
dimension: QuotaDimensionSchema,
|
|
1086
1134
|
plan: PlanSchema,
|
|
1087
|
-
limit:
|
|
1088
|
-
used:
|
|
1135
|
+
limit: z12.number().int(),
|
|
1136
|
+
used: z12.number().int(),
|
|
1089
1137
|
/** Kapan kuota bulanan direset; null untuk kuota jumlah (proyek, persona, ...). */
|
|
1090
1138
|
reset_at: IsoDateTimeSchema.nullable(),
|
|
1091
|
-
upgrade_url:
|
|
1139
|
+
upgrade_url: z12.string()
|
|
1092
1140
|
});
|
|
1093
|
-
var UsageItemSchema =
|
|
1141
|
+
var UsageItemSchema = z12.object({
|
|
1094
1142
|
dimension: QuotaDimensionSchema,
|
|
1095
|
-
label:
|
|
1096
|
-
used:
|
|
1097
|
-
limit:
|
|
1143
|
+
label: z12.string(),
|
|
1144
|
+
used: z12.number().int().min(0),
|
|
1145
|
+
limit: z12.number().int().nullable()
|
|
1098
1146
|
});
|
|
1099
|
-
var UsageOutput =
|
|
1147
|
+
var UsageOutput = z12.object({
|
|
1100
1148
|
plan: PlanSchema,
|
|
1101
|
-
plans:
|
|
1102
|
-
|
|
1149
|
+
plans: z12.array(
|
|
1150
|
+
z12.object({
|
|
1103
1151
|
plan: PlanSchema,
|
|
1104
|
-
available:
|
|
1105
|
-
limits:
|
|
1152
|
+
available: z12.boolean(),
|
|
1153
|
+
limits: z12.record(z12.string(), z12.number().nullable())
|
|
1106
1154
|
})
|
|
1107
1155
|
),
|
|
1108
1156
|
period_start: IsoDateTimeSchema,
|
|
1109
1157
|
reset_at: IsoDateTimeSchema,
|
|
1110
|
-
retention_days:
|
|
1111
|
-
usage:
|
|
1158
|
+
retention_days: z12.number().int().nullable(),
|
|
1159
|
+
usage: z12.array(UsageItemSchema)
|
|
1112
1160
|
});
|
|
1113
1161
|
|
|
1114
1162
|
// src/index.ts
|
|
@@ -1271,7 +1319,7 @@ async function findProjectRoot(start = process.cwd()) {
|
|
|
1271
1319
|
import { chmod, mkdir, readFile as readFile2, rename, writeFile } from "node:fs/promises";
|
|
1272
1320
|
import { homedir } from "node:os";
|
|
1273
1321
|
import { join as join2 } from "node:path";
|
|
1274
|
-
import { z as
|
|
1322
|
+
import { z as z13 } from "zod";
|
|
1275
1323
|
function catenextHome() {
|
|
1276
1324
|
return process.env.CATENEXT_HOME ?? join2(homedir(), ".catenext");
|
|
1277
1325
|
}
|
|
@@ -1280,10 +1328,10 @@ function credentialsPath() {
|
|
|
1280
1328
|
}
|
|
1281
1329
|
var PRODUCTION_API_URL = "https://catenext.mapan.digital";
|
|
1282
1330
|
var DEFAULT_API_URL = PRODUCTION_API_URL;
|
|
1283
|
-
var CredentialsSchema =
|
|
1284
|
-
api_key:
|
|
1285
|
-
api_url:
|
|
1286
|
-
saved_at:
|
|
1331
|
+
var CredentialsSchema = z13.object({
|
|
1332
|
+
api_key: z13.string().startsWith(API_KEY_PREFIX),
|
|
1333
|
+
api_url: z13.url().optional(),
|
|
1334
|
+
saved_at: z13.string().optional()
|
|
1287
1335
|
});
|
|
1288
1336
|
var CredentialsError = class extends Error {
|
|
1289
1337
|
constructor(message) {
|
|
@@ -1460,12 +1508,178 @@ async function deviceLogin(opts) {
|
|
|
1460
1508
|
}
|
|
1461
1509
|
|
|
1462
1510
|
// src/fallback.ts
|
|
1463
|
-
import { execFile } from "node:child_process";
|
|
1511
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
1464
1512
|
import { randomUUID } from "node:crypto";
|
|
1465
|
-
import { promisify } from "node:util";
|
|
1513
|
+
import { promisify as promisify2 } from "node:util";
|
|
1466
1514
|
|
|
1467
1515
|
// src/planning.ts
|
|
1468
|
-
import { readFile as
|
|
1516
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
1517
|
+
|
|
1518
|
+
// src/code-search.ts
|
|
1519
|
+
import { execFile } from "node:child_process";
|
|
1520
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
1521
|
+
import { mkdir as mkdir2, readdir, readFile as readFile3, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
1522
|
+
import { join as join3, relative } from "node:path";
|
|
1523
|
+
import { promisify } from "node:util";
|
|
1524
|
+
var execFileAsync = promisify(execFile);
|
|
1525
|
+
var CACHE_DIR = ".catenext/cache/code-embeddings";
|
|
1526
|
+
var TEXT_EXT = /* @__PURE__ */ new Set([
|
|
1527
|
+
".ts",
|
|
1528
|
+
".tsx",
|
|
1529
|
+
".js",
|
|
1530
|
+
".jsx",
|
|
1531
|
+
".mjs",
|
|
1532
|
+
".cjs",
|
|
1533
|
+
".md",
|
|
1534
|
+
".mdx",
|
|
1535
|
+
".json",
|
|
1536
|
+
".yml",
|
|
1537
|
+
".yaml",
|
|
1538
|
+
".toml",
|
|
1539
|
+
".css",
|
|
1540
|
+
".scss",
|
|
1541
|
+
".html",
|
|
1542
|
+
".py",
|
|
1543
|
+
".rs",
|
|
1544
|
+
".go",
|
|
1545
|
+
".java",
|
|
1546
|
+
".kt",
|
|
1547
|
+
".swift",
|
|
1548
|
+
".sql",
|
|
1549
|
+
".sh"
|
|
1550
|
+
]);
|
|
1551
|
+
function hashEmbed(text2, dims = LOCAL_EMBED_DIMS) {
|
|
1552
|
+
const vec = new Array(dims).fill(0);
|
|
1553
|
+
const tokens = text2.toLowerCase().split(/[^a-z0-9_\u00c0-\u024f]+/i).filter(Boolean);
|
|
1554
|
+
for (const tok of tokens) {
|
|
1555
|
+
const h = createHash2("sha256").update(tok).digest();
|
|
1556
|
+
const i = h.readUInt32BE(0) % dims;
|
|
1557
|
+
const sign = (h[4] ?? 0) & 1 ? 1 : -1;
|
|
1558
|
+
vec[i] = (vec[i] ?? 0) + sign;
|
|
1559
|
+
}
|
|
1560
|
+
if (tokens.length === 0) vec[0] = 1;
|
|
1561
|
+
let s = 0;
|
|
1562
|
+
for (const x of vec) s += x * x;
|
|
1563
|
+
const n = Math.sqrt(s) || 1;
|
|
1564
|
+
return vec.map((x) => x / n);
|
|
1565
|
+
}
|
|
1566
|
+
function cosine(a, b) {
|
|
1567
|
+
const n = Math.min(a.length, b.length);
|
|
1568
|
+
let dot = 0;
|
|
1569
|
+
for (let i = 0; i < n; i++) dot += (a[i] ?? 0) * (b[i] ?? 0);
|
|
1570
|
+
return dot;
|
|
1571
|
+
}
|
|
1572
|
+
function sha256(text2) {
|
|
1573
|
+
return createHash2("sha256").update(text2, "utf8").digest("hex");
|
|
1574
|
+
}
|
|
1575
|
+
async function listTrackedFiles(root) {
|
|
1576
|
+
try {
|
|
1577
|
+
const { stdout } = await execFileAsync("git", ["ls-files", "-z"], {
|
|
1578
|
+
cwd: root,
|
|
1579
|
+
maxBuffer: 2e7
|
|
1580
|
+
});
|
|
1581
|
+
return stdout.split("\0").filter(Boolean).filter((p) => {
|
|
1582
|
+
const ext = p.includes(".") ? `.${p.split(".").pop()?.toLowerCase()}` : "";
|
|
1583
|
+
return TEXT_EXT.has(ext) && !p.startsWith(".catenext/cache/");
|
|
1584
|
+
});
|
|
1585
|
+
} catch {
|
|
1586
|
+
return walkFallback(root, root);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
async function walkFallback(root, dir) {
|
|
1590
|
+
const out = [];
|
|
1591
|
+
let entries;
|
|
1592
|
+
try {
|
|
1593
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
1594
|
+
} catch {
|
|
1595
|
+
return out;
|
|
1596
|
+
}
|
|
1597
|
+
for (const e of entries) {
|
|
1598
|
+
if (e.name === "node_modules" || e.name === ".git" || e.name === "dist" || e.name === ".next")
|
|
1599
|
+
continue;
|
|
1600
|
+
const abs = join3(dir, e.name);
|
|
1601
|
+
if (e.isDirectory()) {
|
|
1602
|
+
out.push(...await walkFallback(root, abs));
|
|
1603
|
+
continue;
|
|
1604
|
+
}
|
|
1605
|
+
const rel = relative(root, abs);
|
|
1606
|
+
const ext = rel.includes(".") ? `.${rel.split(".").pop()?.toLowerCase()}` : "";
|
|
1607
|
+
if (TEXT_EXT.has(ext)) out.push(rel);
|
|
1608
|
+
}
|
|
1609
|
+
return out;
|
|
1610
|
+
}
|
|
1611
|
+
async function loadEntry(cacheRoot, rel) {
|
|
1612
|
+
const key = sha256(rel).slice(0, 24);
|
|
1613
|
+
try {
|
|
1614
|
+
return JSON.parse(await readFile3(join3(cacheRoot, `${key}.json`), "utf8"));
|
|
1615
|
+
} catch {
|
|
1616
|
+
return null;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
async function saveEntry(cacheRoot, rel, entry) {
|
|
1620
|
+
const key = sha256(rel).slice(0, 24);
|
|
1621
|
+
await writeFile2(join3(cacheRoot, `${key}.json`), JSON.stringify({ ...entry, path: rel }));
|
|
1622
|
+
}
|
|
1623
|
+
async function searchLocalCode(root, query, limit = 8) {
|
|
1624
|
+
const cacheRoot = join3(root, CACHE_DIR);
|
|
1625
|
+
await mkdir2(cacheRoot, { recursive: true });
|
|
1626
|
+
const files = await listTrackedFiles(root);
|
|
1627
|
+
const qVec = hashEmbed(query);
|
|
1628
|
+
const scored = [];
|
|
1629
|
+
for (const rel of files) {
|
|
1630
|
+
const abs = join3(root, rel);
|
|
1631
|
+
let st;
|
|
1632
|
+
try {
|
|
1633
|
+
st = await stat(abs);
|
|
1634
|
+
} catch {
|
|
1635
|
+
continue;
|
|
1636
|
+
}
|
|
1637
|
+
if (st.size > 2e5) continue;
|
|
1638
|
+
let text2;
|
|
1639
|
+
try {
|
|
1640
|
+
text2 = await readFile3(abs, "utf8");
|
|
1641
|
+
} catch {
|
|
1642
|
+
continue;
|
|
1643
|
+
}
|
|
1644
|
+
const sha = sha256(text2);
|
|
1645
|
+
let entry = await loadEntry(cacheRoot, rel);
|
|
1646
|
+
if (!entry || entry.sha !== sha) {
|
|
1647
|
+
const snippet = text2.slice(0, 400).replace(/\s+/g, " ").trim();
|
|
1648
|
+
entry = { sha, vector: hashEmbed(text2.slice(0, 8e3)), snippet, mtimeMs: st.mtimeMs };
|
|
1649
|
+
await saveEntry(cacheRoot, rel, entry);
|
|
1650
|
+
}
|
|
1651
|
+
scored.push({
|
|
1652
|
+
source: "code",
|
|
1653
|
+
ref: rel,
|
|
1654
|
+
title: rel,
|
|
1655
|
+
snippet: entry.snippet,
|
|
1656
|
+
score: cosine(qVec, entry.vector)
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
scored.sort((a, b) => b.score - a.score);
|
|
1660
|
+
return {
|
|
1661
|
+
hits: scored.slice(0, limit),
|
|
1662
|
+
degraded: true,
|
|
1663
|
+
note: process.env.CATENEXT_EMBEDDING_API_KEY ? void 0 : "Tanpa CATENEXT_EMBEDDING_API_KEY: embedding kode memakai hash lokal (degraded)."
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
async function keywordFallback(root, query, limit = 8) {
|
|
1667
|
+
try {
|
|
1668
|
+
const { stdout } = await execFileAsync("rg", ["-l", "--max-count", "1", "-i", query, "."], {
|
|
1669
|
+
cwd: root,
|
|
1670
|
+
maxBuffer: 5e6
|
|
1671
|
+
});
|
|
1672
|
+
return stdout.split("\n").map((l) => l.trim()).filter(Boolean).slice(0, limit).map((rel) => ({
|
|
1673
|
+
source: "code",
|
|
1674
|
+
ref: rel,
|
|
1675
|
+
title: rel,
|
|
1676
|
+
snippet: `Keyword match: ${query}`,
|
|
1677
|
+
score: 0.1
|
|
1678
|
+
}));
|
|
1679
|
+
} catch {
|
|
1680
|
+
return [];
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1469
1683
|
|
|
1470
1684
|
// src/scrubber.ts
|
|
1471
1685
|
var redact = (kind) => `[REDACTED:${kind}]`;
|
|
@@ -1604,7 +1818,7 @@ async function readJsonInput(file) {
|
|
|
1604
1818
|
});
|
|
1605
1819
|
process.stdin.on("end", () => res(data));
|
|
1606
1820
|
process.stdin.on("error", rej);
|
|
1607
|
-
}) : await
|
|
1821
|
+
}) : await readFile4(file, "utf8");
|
|
1608
1822
|
} catch (err) {
|
|
1609
1823
|
throw new PlanningInputError(`Tidak bisa membaca ${file}: ${err.message}`);
|
|
1610
1824
|
}
|
|
@@ -1713,7 +1927,7 @@ async function docGet(api, slug, asJson) {
|
|
|
1713
1927
|
console.log(res.content);
|
|
1714
1928
|
}
|
|
1715
1929
|
async function docSave(api, slug, opts) {
|
|
1716
|
-
const content = await
|
|
1930
|
+
const content = await readFile4(opts.file, "utf8");
|
|
1717
1931
|
const body = prepare(
|
|
1718
1932
|
SaveDocumentInput,
|
|
1719
1933
|
{
|
|
@@ -1731,9 +1945,66 @@ async function docSave(api, slug, opts) {
|
|
|
1731
1945
|
`\u2713 Dokumen "${res.document.slug}" ${res.created ? "dibuat" : "diperbarui"} (v${res.document.version}).`
|
|
1732
1946
|
);
|
|
1733
1947
|
}
|
|
1948
|
+
var CLOUD_SOURCES = new Set(SEARCH_SOURCES);
|
|
1949
|
+
async function searchShow(api, query, opts) {
|
|
1950
|
+
const scrubbed = scrubDeep({ query }, /* @__PURE__ */ new Set());
|
|
1951
|
+
if (scrubbed.total > 0) console.error(`! ${describeRedactions(scrubbed)}`);
|
|
1952
|
+
const q = String(scrubbed.value.query).trim();
|
|
1953
|
+
if (!q) throw new PlanningInputError("Query kosong.");
|
|
1954
|
+
const wanted = opts.source?.length ? opts.source : ["document", "skill", "task", "code"];
|
|
1955
|
+
const cloudSources = wanted.filter(
|
|
1956
|
+
(s) => CLOUD_SOURCES.has(s)
|
|
1957
|
+
);
|
|
1958
|
+
const wantCode = wanted.includes("code");
|
|
1959
|
+
const limit = opts.limit ?? 8;
|
|
1960
|
+
let cloud = null;
|
|
1961
|
+
if (cloudSources.length > 0) {
|
|
1962
|
+
const body = prepare(SearchContextInput, { query: q, sources: cloudSources, limit }, [
|
|
1963
|
+
"sources",
|
|
1964
|
+
"limit"
|
|
1965
|
+
]);
|
|
1966
|
+
cloud = await api.post("search", body);
|
|
1967
|
+
}
|
|
1968
|
+
let codeHits = [];
|
|
1969
|
+
let codeNote;
|
|
1970
|
+
if (wantCode) {
|
|
1971
|
+
const root = await findProjectRoot();
|
|
1972
|
+
if (root) {
|
|
1973
|
+
try {
|
|
1974
|
+
const local = await searchLocalCode(root, q, limit);
|
|
1975
|
+
codeHits = local.hits;
|
|
1976
|
+
codeNote = local.note;
|
|
1977
|
+
if (codeHits.length === 0) codeHits = await keywordFallback(root, q, limit);
|
|
1978
|
+
} catch (err) {
|
|
1979
|
+
codeNote = `Indeks kode gagal: ${err.message}. Fallback keyword.`;
|
|
1980
|
+
codeHits = await keywordFallback(root, q, limit);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
const merged = [
|
|
1985
|
+
...(cloud?.hits ?? []).map((h) => ({ ...h, origin: "cloud" })),
|
|
1986
|
+
...codeHits.map((h) => ({ ...h, origin: "local" }))
|
|
1987
|
+
].sort((a, b) => b.score - a.score).slice(0, limit);
|
|
1988
|
+
const payload = {
|
|
1989
|
+
hits: merged,
|
|
1990
|
+
reranked: cloud?.reranked ?? false,
|
|
1991
|
+
degraded: cloud?.degraded ?? true,
|
|
1992
|
+
...codeNote ? { note: codeNote } : {}
|
|
1993
|
+
};
|
|
1994
|
+
if (opts.json) return console.log(JSON.stringify(payload, null, 2));
|
|
1995
|
+
if (merged.length === 0) return console.log("Tidak ada hasil.");
|
|
1996
|
+
for (const h of merged) {
|
|
1997
|
+
console.log(
|
|
1998
|
+
`${h.score.toFixed(3)} [${h.source}] ${h.ref} ${h.title}
|
|
1999
|
+
${h.snippet.slice(0, 120)}`
|
|
2000
|
+
);
|
|
2001
|
+
}
|
|
2002
|
+
if (payload.degraded) console.error("! Mode degraded (embedding/rerank lokal atau tanpa key).");
|
|
2003
|
+
if (codeNote) console.error(`! ${codeNote}`);
|
|
2004
|
+
}
|
|
1734
2005
|
|
|
1735
2006
|
// src/fallback.ts
|
|
1736
|
-
var exec =
|
|
2007
|
+
var exec = promisify2(execFile2);
|
|
1737
2008
|
async function git(args, cwd) {
|
|
1738
2009
|
try {
|
|
1739
2010
|
const { stdout } = await exec("git", args, { cwd });
|
|
@@ -1770,8 +2041,9 @@ async function taskNext(api, opts) {
|
|
|
1770
2041
|
}
|
|
1771
2042
|
console.log(
|
|
1772
2043
|
`
|
|
1773
|
-
Ambil satu: catenext claim ${res.tasks[0]?.id}${opts.as ? ` --as ${opts.as}` : ""}`
|
|
2044
|
+
Ambil satu: catenext claim ${res.tasks[0]?.id}${opts.as ? ` --as ${opts.as}` : ""} [--worktree]`
|
|
1774
2045
|
);
|
|
2046
|
+
console.log(" (Monorepo: --worktree wajib. Polyrepo: opsional.)");
|
|
1775
2047
|
}
|
|
1776
2048
|
function renderClaim(res) {
|
|
1777
2049
|
const out = [];
|
|
@@ -1811,12 +2083,23 @@ function renderClaim(res) {
|
|
|
1811
2083
|
out.push(
|
|
1812
2084
|
"## Setelah selesai",
|
|
1813
2085
|
"",
|
|
1814
|
-
|
|
2086
|
+
"Commit di branch/worktree ini OK. Jangan merge ke default branch \u2014 serahkan lewat PR.",
|
|
2087
|
+
`catenext done ${res.task.id} --notes "<ringkasan>" --verify "<perintah tes>" --pr <url> --base <branch>${res.lease_id ? ` --lease ${res.lease_id}` : ""}`,
|
|
1815
2088
|
`Bila buntu: catenext block ${res.task.id} --category <kategori> --reason "<alasan spesifik>"`
|
|
1816
2089
|
);
|
|
1817
2090
|
return out.join("\n");
|
|
1818
2091
|
}
|
|
1819
2092
|
async function taskClaim(api, taskId, opts) {
|
|
2093
|
+
if (!opts.worktree) {
|
|
2094
|
+
const ctx = await api.post("context", {
|
|
2095
|
+
...opts.as ? { agent_alias: opts.as } : {}
|
|
2096
|
+
});
|
|
2097
|
+
if (ctx.project.layout === "monorepo") {
|
|
2098
|
+
throw new PlanningInputError(
|
|
2099
|
+
"Proyek ini layout monorepo: claim wajib --worktree (branch/sesi terpisah). Contoh: catenext claim <id> --worktree"
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
1820
2103
|
const branch = opts.worktree ? await git(["symbolic-ref", "--short", "HEAD"], process.cwd()) : null;
|
|
1821
2104
|
if (opts.worktree && !branch)
|
|
1822
2105
|
throw new PlanningInputError("Checkout branch kerja sebelum memakai --worktree.");
|
|
@@ -1844,8 +2127,11 @@ function buildHandoff(opts, gitState) {
|
|
|
1844
2127
|
"Tidak bisa membaca branch/commit git. Jalankan di dalam repo git dan commit pekerjaan Anda dulu."
|
|
1845
2128
|
);
|
|
1846
2129
|
}
|
|
1847
|
-
if (
|
|
1848
|
-
throw new PlanningInputError(
|
|
2130
|
+
if (!opts.pr || !opts.base) {
|
|
2131
|
+
throw new PlanningInputError(
|
|
2132
|
+
"--pr dan --base wajib: buat PR di branch kerja lalu `catenext done \u2026 --pr <url> --base <branch>`."
|
|
2133
|
+
);
|
|
2134
|
+
}
|
|
1849
2135
|
const files = opts.file.length ? opts.file : gitState.changedFiles;
|
|
1850
2136
|
return {
|
|
1851
2137
|
files_modified: files.slice(0, HANDOFF_LIMITS.maxFilesModified),
|
|
@@ -1854,7 +2140,7 @@ function buildHandoff(opts, gitState) {
|
|
|
1854
2140
|
notes_for_next_agent: opts.notes,
|
|
1855
2141
|
git_branch: gitState.branch,
|
|
1856
2142
|
last_commit_hash: gitState.commit,
|
|
1857
|
-
|
|
2143
|
+
pull_request: { url: opts.pr, base_branch: opts.base, head_sha: gitState.commit }
|
|
1858
2144
|
};
|
|
1859
2145
|
}
|
|
1860
2146
|
async function taskDone(api, taskId, opts) {
|
|
@@ -1866,9 +2152,7 @@ async function taskDone(api, taskId, opts) {
|
|
|
1866
2152
|
);
|
|
1867
2153
|
const res = await api.post("complete", body);
|
|
1868
2154
|
if (opts.json) return console.log(JSON.stringify(res, null, 2));
|
|
1869
|
-
console.log(
|
|
1870
|
-
res.status === "DONE" ? `\u2713 Task selesai (DONE). ${res.unlocked_task_ids.length} task hilir terbuka.` : "\u2713 Handoff terkirim, menunggu review (NEEDS_REVIEW)."
|
|
1871
|
-
);
|
|
2155
|
+
console.log("\u2713 Handoff + PR terkirim (NEEDS_REVIEW). Menunggu review/merge manusia.");
|
|
1872
2156
|
console.log(` ${res.next_step_hint}`);
|
|
1873
2157
|
}
|
|
1874
2158
|
async function taskBlock(api, taskId, opts) {
|
|
@@ -1922,8 +2206,8 @@ async function taskManage(api, input, json2) {
|
|
|
1922
2206
|
}
|
|
1923
2207
|
|
|
1924
2208
|
// src/init/index.ts
|
|
1925
|
-
import { mkdir as
|
|
1926
|
-
import { basename, dirname as dirname2, join as
|
|
2209
|
+
import { mkdir as mkdir3, readFile as readFile6, rename as rename2, writeFile as writeFile3 } from "node:fs/promises";
|
|
2210
|
+
import { basename, dirname as dirname2, join as join5, resolve as resolve2 } from "node:path";
|
|
1927
2211
|
import { createTwoFilesPatch } from "diff";
|
|
1928
2212
|
|
|
1929
2213
|
// src/init/agents-md.ts
|
|
@@ -2004,17 +2288,17 @@ function updateConfig(source, changes) {
|
|
|
2004
2288
|
}
|
|
2005
2289
|
|
|
2006
2290
|
// src/init/detect.ts
|
|
2007
|
-
import { readFile as
|
|
2008
|
-
import { join as
|
|
2009
|
-
var exists = async (p) =>
|
|
2291
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
2292
|
+
import { join as join4 } from "node:path";
|
|
2293
|
+
var exists = async (p) => readFile5(p, "utf8").then(
|
|
2010
2294
|
(s) => s,
|
|
2011
2295
|
() => null
|
|
2012
2296
|
);
|
|
2013
2297
|
async function detectStack(root) {
|
|
2014
2298
|
const stack = /* @__PURE__ */ new Set();
|
|
2015
|
-
const goMod = await exists(
|
|
2299
|
+
const goMod = await exists(join4(root, "go.mod"));
|
|
2016
2300
|
if (goMod !== null) stack.add("go");
|
|
2017
|
-
const pkg = await exists(
|
|
2301
|
+
const pkg = await exists(join4(root, "package.json"));
|
|
2018
2302
|
if (pkg !== null) {
|
|
2019
2303
|
stack.add("node");
|
|
2020
2304
|
try {
|
|
@@ -2036,32 +2320,43 @@ async function detectStack(root) {
|
|
|
2036
2320
|
} catch {
|
|
2037
2321
|
}
|
|
2038
2322
|
}
|
|
2039
|
-
const composer = await exists(
|
|
2323
|
+
const composer = await exists(join4(root, "composer.json"));
|
|
2040
2324
|
if (composer !== null) {
|
|
2041
2325
|
stack.add("php");
|
|
2042
2326
|
if (composer.includes('"laravel/framework"')) stack.add("laravel");
|
|
2043
2327
|
}
|
|
2044
|
-
if (await exists(
|
|
2045
|
-
else if (await exists(
|
|
2046
|
-
if (await exists(
|
|
2328
|
+
if (await exists(join4(root, "pyproject.toml")) !== null) stack.add("python");
|
|
2329
|
+
else if (await exists(join4(root, "requirements.txt")) !== null) stack.add("python");
|
|
2330
|
+
if (await exists(join4(root, "Cargo.toml")) !== null) stack.add("rust");
|
|
2047
2331
|
return [...stack].slice(0, 20);
|
|
2048
2332
|
}
|
|
2049
2333
|
|
|
2050
2334
|
// src/init/gitignore.ts
|
|
2051
2335
|
var CACHE_IGNORE = ".catenext/cache.json";
|
|
2336
|
+
var CACHE_DIR_IGNORE = ".catenext/cache/";
|
|
2052
2337
|
var COVERS = /* @__PURE__ */ new Set([
|
|
2053
2338
|
CACHE_IGNORE,
|
|
2054
2339
|
`/${CACHE_IGNORE}`,
|
|
2055
2340
|
".catenext/cache.json",
|
|
2056
|
-
".catenext/*.json"
|
|
2341
|
+
".catenext/*.json",
|
|
2342
|
+
CACHE_DIR_IGNORE,
|
|
2343
|
+
`/${CACHE_DIR_IGNORE}`,
|
|
2344
|
+
".catenext/cache"
|
|
2057
2345
|
]);
|
|
2058
2346
|
function ensureGitignore(source) {
|
|
2059
2347
|
const text2 = source ?? "";
|
|
2060
2348
|
const lines = text2.split(/\r?\n/).map((l) => l.trim());
|
|
2061
|
-
if (lines.some((l) => COVERS.has(l))) return text2;
|
|
2062
2349
|
const eol = text2.includes("\r\n") ? "\r\n" : "\n";
|
|
2350
|
+
const missing = [];
|
|
2351
|
+
if (!lines.some((l) => COVERS.has(l) || l === CACHE_IGNORE)) missing.push(CACHE_IGNORE);
|
|
2352
|
+
if (!lines.some(
|
|
2353
|
+
(l) => l === CACHE_DIR_IGNORE || l === ".catenext/cache" || l === `/${CACHE_DIR_IGNORE}`
|
|
2354
|
+
)) {
|
|
2355
|
+
missing.push(CACHE_DIR_IGNORE);
|
|
2356
|
+
}
|
|
2357
|
+
if (missing.length === 0) return text2;
|
|
2063
2358
|
const prefix = text2 === "" ? "" : text2.endsWith("\n") ? eol : `${eol}${eol}`;
|
|
2064
|
-
return `${text2}${prefix}# Catenext: cache lokal, jangan di-commit${eol}${
|
|
2359
|
+
return `${text2}${prefix}# Catenext: cache lokal, jangan di-commit${eol}${missing.join(eol)}${eol}`;
|
|
2065
2360
|
}
|
|
2066
2361
|
|
|
2067
2362
|
// src/init/mcp-config.ts
|
|
@@ -2123,7 +2418,7 @@ function readMcpEntry(source) {
|
|
|
2123
2418
|
}
|
|
2124
2419
|
|
|
2125
2420
|
// src/init/index.ts
|
|
2126
|
-
var readOrNull = (p) =>
|
|
2421
|
+
var readOrNull = (p) => readFile6(p, "utf8").then(
|
|
2127
2422
|
(s) => s,
|
|
2128
2423
|
() => null
|
|
2129
2424
|
);
|
|
@@ -2141,7 +2436,7 @@ async function planInit(opts) {
|
|
|
2141
2436
|
);
|
|
2142
2437
|
}
|
|
2143
2438
|
const changes = [];
|
|
2144
|
-
const configBefore = await readOrNull(
|
|
2439
|
+
const configBefore = await readOrNull(join5(root, CONFIG_PATH));
|
|
2145
2440
|
let configAfter;
|
|
2146
2441
|
if (configBefore === null) {
|
|
2147
2442
|
if (!opts.projectId) {
|
|
@@ -2165,7 +2460,7 @@ async function planInit(opts) {
|
|
|
2165
2460
|
}
|
|
2166
2461
|
changes.push({ path: CONFIG_PATH, before: configBefore, after: configAfter });
|
|
2167
2462
|
for (const adapter of ADAPTERS) {
|
|
2168
|
-
const before = await readOrNull(
|
|
2463
|
+
const before = await readOrNull(join5(root, adapter.path));
|
|
2169
2464
|
const entry = {
|
|
2170
2465
|
command: opts.mcpCommand.command,
|
|
2171
2466
|
args: [...opts.mcpCommand.args, "mcp", ...adapter.extraArgs]
|
|
@@ -2176,14 +2471,14 @@ async function planInit(opts) {
|
|
|
2176
2471
|
after: upsertMcpEntry(before, entry, adapter.path)
|
|
2177
2472
|
});
|
|
2178
2473
|
}
|
|
2179
|
-
const gitignoreBefore = await readOrNull(
|
|
2474
|
+
const gitignoreBefore = await readOrNull(join5(root, ".gitignore"));
|
|
2180
2475
|
changes.push({
|
|
2181
2476
|
path: ".gitignore",
|
|
2182
2477
|
before: gitignoreBefore,
|
|
2183
2478
|
after: ensureGitignore(gitignoreBefore)
|
|
2184
2479
|
});
|
|
2185
2480
|
if (opts.agentsMd !== false) {
|
|
2186
|
-
const before = await readOrNull(
|
|
2481
|
+
const before = await readOrNull(join5(root, AGENTS_MD));
|
|
2187
2482
|
changes.push({ path: AGENTS_MD, before, after: upsertAgentsBlock(before) });
|
|
2188
2483
|
}
|
|
2189
2484
|
return changes.filter((c) => c.before !== c.after);
|
|
@@ -2203,29 +2498,29 @@ function renderDiff(changes) {
|
|
|
2203
2498
|
}
|
|
2204
2499
|
async function applyInit(root, changes) {
|
|
2205
2500
|
for (const c of changes) {
|
|
2206
|
-
const target =
|
|
2207
|
-
await
|
|
2501
|
+
const target = join5(resolve2(root), c.path);
|
|
2502
|
+
await mkdir3(dirname2(target), { recursive: true });
|
|
2208
2503
|
const tmp = `${target}.catenext-${process.pid}.tmp`;
|
|
2209
|
-
await
|
|
2504
|
+
await writeFile3(tmp, c.after);
|
|
2210
2505
|
await rename2(tmp, target);
|
|
2211
2506
|
}
|
|
2212
2507
|
}
|
|
2213
2508
|
|
|
2214
2509
|
// src/maintenance.ts
|
|
2215
2510
|
import { existsSync } from "node:fs";
|
|
2216
|
-
import { copyFile, mkdir as
|
|
2217
|
-
import { dirname as dirname3, isAbsolute, join as
|
|
2511
|
+
import { copyFile, mkdir as mkdir5, readFile as readFile9, rename as rename4, rm, rmdir, writeFile as writeFile5 } from "node:fs/promises";
|
|
2512
|
+
import { dirname as dirname3, isAbsolute, join as join9, resolve as resolve3 } from "node:path";
|
|
2218
2513
|
import { applyEdits as applyEdits2, modify as modify2, parse as parse4, visit } from "jsonc-parser";
|
|
2219
2514
|
|
|
2220
2515
|
// src/node-command.ts
|
|
2221
2516
|
import { accessSync, constants, realpathSync } from "node:fs";
|
|
2222
|
-
import { delimiter, join as
|
|
2517
|
+
import { delimiter, join as join6 } from "node:path";
|
|
2223
2518
|
function stableNodeCommand(execPath, pathEnv, resolveReal = realpathSync, isExecutable = defaultIsExecutable) {
|
|
2224
2519
|
const target = safeReal(execPath, resolveReal);
|
|
2225
2520
|
for (const dir of (pathEnv ?? "").split(delimiter)) {
|
|
2226
2521
|
if (!dir) continue;
|
|
2227
2522
|
for (const name of process.platform === "win32" ? ["node.exe", "node"] : ["node"]) {
|
|
2228
|
-
const candidate =
|
|
2523
|
+
const candidate = join6(dir, name);
|
|
2229
2524
|
if (!isExecutable(candidate)) continue;
|
|
2230
2525
|
return safeReal(candidate, resolveReal) === target ? "node" : execPath;
|
|
2231
2526
|
}
|
|
@@ -2255,19 +2550,19 @@ function npxLaunch(entry) {
|
|
|
2255
2550
|
}
|
|
2256
2551
|
|
|
2257
2552
|
// src/skills.ts
|
|
2258
|
-
import { execFile as
|
|
2259
|
-
import { mkdir as
|
|
2260
|
-
import { join as
|
|
2261
|
-
import { promisify as
|
|
2553
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
2554
|
+
import { mkdir as mkdir4, readdir as readdir2, readFile as readFile7, rename as rename3, writeFile as writeFile4 } from "node:fs/promises";
|
|
2555
|
+
import { join as join7 } from "node:path";
|
|
2556
|
+
import { promisify as promisify3 } from "node:util";
|
|
2262
2557
|
import { parse as parse3, stringify } from "yaml";
|
|
2263
|
-
var SKILLS_DIR =
|
|
2558
|
+
var SKILLS_DIR = join7(".catenext", "skills");
|
|
2264
2559
|
var SkillError = class extends Error {
|
|
2265
2560
|
constructor(message) {
|
|
2266
2561
|
super(message);
|
|
2267
2562
|
this.name = "SkillError";
|
|
2268
2563
|
}
|
|
2269
2564
|
};
|
|
2270
|
-
var exec2 =
|
|
2565
|
+
var exec2 = promisify3(execFile3);
|
|
2271
2566
|
var FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
2272
2567
|
function parseSkill(source, fileName) {
|
|
2273
2568
|
const m = FRONTMATTER.exec(source);
|
|
@@ -2301,7 +2596,7 @@ ${skill.content.trim()}
|
|
|
2301
2596
|
async function listSkills(root) {
|
|
2302
2597
|
let files;
|
|
2303
2598
|
try {
|
|
2304
|
-
files = await
|
|
2599
|
+
files = await readdir2(join7(root, SKILLS_DIR));
|
|
2305
2600
|
} catch {
|
|
2306
2601
|
return { skills: [], invalid: [] };
|
|
2307
2602
|
}
|
|
@@ -2309,7 +2604,7 @@ async function listSkills(root) {
|
|
|
2309
2604
|
const invalid = [];
|
|
2310
2605
|
for (const file of files.filter((f) => f.endsWith(".md")).sort()) {
|
|
2311
2606
|
try {
|
|
2312
|
-
const skill = parseSkill(await
|
|
2607
|
+
const skill = parseSkill(await readFile7(join7(root, SKILLS_DIR, file), "utf8"), file);
|
|
2313
2608
|
if (`${skill.name}.md` !== file) {
|
|
2314
2609
|
throw new SkillError(`${file}: name "${skill.name}" harus sama dengan nama file.`);
|
|
2315
2610
|
}
|
|
@@ -2344,7 +2639,7 @@ async function loadSkill(root, name, revision) {
|
|
|
2344
2639
|
}
|
|
2345
2640
|
let source;
|
|
2346
2641
|
try {
|
|
2347
|
-
source = await
|
|
2642
|
+
source = await readFile7(join7(root, SKILLS_DIR, file), "utf8");
|
|
2348
2643
|
} catch {
|
|
2349
2644
|
const { skills } = await listSkills(root);
|
|
2350
2645
|
const names = skills.map((s) => s.name).join(", ") || "(belum ada)";
|
|
@@ -2359,20 +2654,20 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
|
|
|
2359
2654
|
if (!when || when.length > SKILL_LIMITS.maxWhenToUseLength) {
|
|
2360
2655
|
throw new SkillError(`when_to_use wajib, maks ${SKILL_LIMITS.maxWhenToUseLength} karakter.`);
|
|
2361
2656
|
}
|
|
2362
|
-
const dir =
|
|
2363
|
-
await
|
|
2364
|
-
const target =
|
|
2657
|
+
const dir = join7(root, SKILLS_DIR);
|
|
2658
|
+
await mkdir4(dir, { recursive: true });
|
|
2659
|
+
const target = join7(dir, `${name}.md`);
|
|
2365
2660
|
let created = true;
|
|
2366
2661
|
try {
|
|
2367
|
-
await
|
|
2662
|
+
await readFile7(target);
|
|
2368
2663
|
created = false;
|
|
2369
2664
|
} catch {
|
|
2370
2665
|
}
|
|
2371
2666
|
const skill = { name, when_to_use: when, updated_at: now.toISOString(), content };
|
|
2372
2667
|
const tmp = `${target}.${process.pid}.tmp`;
|
|
2373
|
-
await
|
|
2668
|
+
await writeFile4(tmp, renderSkill(skill), "utf8");
|
|
2374
2669
|
await rename3(tmp, target);
|
|
2375
|
-
return { path:
|
|
2670
|
+
return { path: join7(SKILLS_DIR, `${name}.md`), created, skill };
|
|
2376
2671
|
}
|
|
2377
2672
|
async function committedSkillIndex(root, previous) {
|
|
2378
2673
|
const config = { cwd: root };
|
|
@@ -2409,9 +2704,9 @@ async function committedSkillIndex(root, previous) {
|
|
|
2409
2704
|
}
|
|
2410
2705
|
|
|
2411
2706
|
// src/subagents.ts
|
|
2412
|
-
import { readdir as
|
|
2413
|
-
import { join as
|
|
2414
|
-
var SUBAGENTS_DIR =
|
|
2707
|
+
import { readdir as readdir3, readFile as readFile8 } from "node:fs/promises";
|
|
2708
|
+
import { join as join8 } from "node:path";
|
|
2709
|
+
var SUBAGENTS_DIR = join8(".claude", "agents");
|
|
2415
2710
|
var SUBAGENT_MARKER = "<!-- catenext:persona -->";
|
|
2416
2711
|
function renderSubagent(p) {
|
|
2417
2712
|
const rules = p.rules.length > 0 ? p.rules.map((r) => `- ${r}`) : ["- (belum ada aturan)"];
|
|
@@ -2434,12 +2729,12 @@ function renderSubagent(p) {
|
|
|
2434
2729
|
"",
|
|
2435
2730
|
`1. \`get_project_context\` dengan \`agent_alias: ${alias}\`.`,
|
|
2436
2731
|
`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
|
|
2439
|
-
"5. `complete_handoff` dengan
|
|
2440
|
-
"6. Laporkan ke orchestrator (pemanggil): task
|
|
2732
|
+
`3. \`claim_task\` dengan \`task_id\` dan \`agent_alias: ${alias}\`. Bila \`layout\`=monorepo, sertakan \`worktree\`. Patuhi field \`persona\` di hasilnya.`,
|
|
2733
|
+
"4. Kerjakan, jalankan tes, commit di branch/worktree (jangan merge ke default branch).",
|
|
2734
|
+
"5. Buat PR, lalu `complete_handoff` dengan `pull_request` wajib, atau `report_blocker` bila buntu.",
|
|
2735
|
+
"6. Laporkan ke orchestrator (pemanggil): task, status, URL PR, dan perintah verifikasi.",
|
|
2441
2736
|
"",
|
|
2442
|
-
`Tanpa tool MCP: \`catenext next --as ${p.alias}\`, \`catenext claim <id> --as ${p.alias}\`, \`catenext done <id>
|
|
2737
|
+
`Tanpa tool MCP: \`catenext next --as ${p.alias}\`, \`catenext claim <id> --as ${p.alias} [--worktree]\`, \`catenext done <id> --notes "..." --pr <url> --base <branch>\`.`,
|
|
2443
2738
|
"",
|
|
2444
2739
|
"## Batas subagent",
|
|
2445
2740
|
"",
|
|
@@ -2453,7 +2748,7 @@ function renderSubagent(p) {
|
|
|
2453
2748
|
""
|
|
2454
2749
|
].join("\n");
|
|
2455
2750
|
}
|
|
2456
|
-
var readOrNull2 = (p) =>
|
|
2751
|
+
var readOrNull2 = (p) => readFile8(p, "utf8").then(
|
|
2457
2752
|
(s) => s,
|
|
2458
2753
|
() => null
|
|
2459
2754
|
);
|
|
@@ -2462,9 +2757,9 @@ async function planSubagents(root, personas) {
|
|
|
2462
2757
|
const skipped = [];
|
|
2463
2758
|
const wanted = /* @__PURE__ */ new Set();
|
|
2464
2759
|
for (const p of personas) {
|
|
2465
|
-
const path =
|
|
2760
|
+
const path = join8(SUBAGENTS_DIR, `${p.alias}.md`);
|
|
2466
2761
|
wanted.add(path);
|
|
2467
|
-
const before = await readOrNull2(
|
|
2762
|
+
const before = await readOrNull2(join8(root, path));
|
|
2468
2763
|
if (before !== null && !before.includes(SUBAGENT_MARKER)) {
|
|
2469
2764
|
skipped.push(path);
|
|
2470
2765
|
continue;
|
|
@@ -2474,23 +2769,23 @@ async function planSubagents(root, personas) {
|
|
|
2474
2769
|
}
|
|
2475
2770
|
for (const path of await catenextSubagentFiles(root)) {
|
|
2476
2771
|
if (!wanted.has(path)) {
|
|
2477
|
-
edits.push({ path, before: await readOrNull2(
|
|
2772
|
+
edits.push({ path, before: await readOrNull2(join8(root, path)), after: null });
|
|
2478
2773
|
}
|
|
2479
2774
|
}
|
|
2480
2775
|
return { edits, skipped };
|
|
2481
2776
|
}
|
|
2482
2777
|
async function catenextSubagentFiles(root) {
|
|
2483
|
-
const names = await
|
|
2778
|
+
const names = await readdir3(join8(root, SUBAGENTS_DIR)).catch(() => []);
|
|
2484
2779
|
const out = [];
|
|
2485
2780
|
for (const n of names.filter((n2) => n2.endsWith(".md")).sort()) {
|
|
2486
|
-
const path =
|
|
2487
|
-
if ((await readOrNull2(
|
|
2781
|
+
const path = join8(SUBAGENTS_DIR, n);
|
|
2782
|
+
if ((await readOrNull2(join8(root, path)))?.includes(SUBAGENT_MARKER)) out.push(path);
|
|
2488
2783
|
}
|
|
2489
2784
|
return out;
|
|
2490
2785
|
}
|
|
2491
2786
|
|
|
2492
2787
|
// src/maintenance.ts
|
|
2493
|
-
var readOrNull3 = (p) =>
|
|
2788
|
+
var readOrNull3 = (p) => readFile9(p, "utf8").then(
|
|
2494
2789
|
(s) => s,
|
|
2495
2790
|
() => null
|
|
2496
2791
|
);
|
|
@@ -2551,7 +2846,7 @@ async function planSync(opts) {
|
|
|
2551
2846
|
const edits = [];
|
|
2552
2847
|
const findings = [];
|
|
2553
2848
|
for (const adapter of ADAPTERS) {
|
|
2554
|
-
const before = await readOrNull3(
|
|
2849
|
+
const before = await readOrNull3(join9(root, adapter.path));
|
|
2555
2850
|
if (before !== null && before.trim() !== "" && !isValidJsonObject(before)) {
|
|
2556
2851
|
if (!opts.fix) {
|
|
2557
2852
|
findings.push({
|
|
@@ -2614,12 +2909,12 @@ async function planSync(opts) {
|
|
|
2614
2909
|
);
|
|
2615
2910
|
if (after !== before) edits.push({ path: adapter.path, before, after });
|
|
2616
2911
|
}
|
|
2617
|
-
const gitignore = await readOrNull3(
|
|
2912
|
+
const gitignore = await readOrNull3(join9(root, ".gitignore"));
|
|
2618
2913
|
const gitignoreAfter = ensureGitignore(gitignore);
|
|
2619
2914
|
if (gitignoreAfter !== gitignore) {
|
|
2620
2915
|
edits.push({ path: ".gitignore", before: gitignore, after: gitignoreAfter });
|
|
2621
2916
|
}
|
|
2622
|
-
const agents = await readOrNull3(
|
|
2917
|
+
const agents = await readOrNull3(join9(root, AGENTS_MD));
|
|
2623
2918
|
if (agents?.includes(BLOCK_START)) {
|
|
2624
2919
|
const after = upsertAgentsBlock(agents);
|
|
2625
2920
|
if (after !== agents) edits.push({ path: AGENTS_MD, before: agents, after });
|
|
@@ -2643,7 +2938,7 @@ async function planRemove(opts) {
|
|
|
2643
2938
|
const root = resolve3(opts.root);
|
|
2644
2939
|
const edits = [];
|
|
2645
2940
|
for (const adapter of ADAPTERS) {
|
|
2646
|
-
const before = await readOrNull3(
|
|
2941
|
+
const before = await readOrNull3(join9(root, adapter.path));
|
|
2647
2942
|
if (before === null || countEntries(before) === 0) continue;
|
|
2648
2943
|
const stripped = removeMcpEntries(before);
|
|
2649
2944
|
const doc2 = parse4(stripped, [], { allowTrailingComma: true });
|
|
@@ -2651,34 +2946,41 @@ async function planRemove(opts) {
|
|
|
2651
2946
|
const emptyDoc = Object.keys(doc2 ?? {}).every((k) => k === "mcpServers") && Object.keys(servers ?? {}).length === 0 && !/\/\/|\/\*/.test(stripped);
|
|
2652
2947
|
edits.push({ path: adapter.path, before, after: emptyDoc ? null : stripped });
|
|
2653
2948
|
}
|
|
2654
|
-
const gitignore = await readOrNull3(
|
|
2949
|
+
const gitignore = await readOrNull3(join9(root, ".gitignore"));
|
|
2655
2950
|
if (gitignore !== null) {
|
|
2656
2951
|
const eol = gitignore.includes("\r\n") ? "\r\n" : "\n";
|
|
2657
2952
|
const lines = gitignore.split(/\r?\n/);
|
|
2658
|
-
const
|
|
2659
|
-
|
|
2660
|
-
|
|
2953
|
+
const catenextIgnore = /* @__PURE__ */ new Set([CACHE_IGNORE, CACHE_DIR_IGNORE, ".catenext/cache"]);
|
|
2954
|
+
const kept = lines.filter((l, i) => {
|
|
2955
|
+
const t = l.trim();
|
|
2956
|
+
if (catenextIgnore.has(t)) return false;
|
|
2957
|
+
if (l.startsWith("# Catenext:")) {
|
|
2958
|
+
const next = lines[i + 1]?.trim();
|
|
2959
|
+
if (next && catenextIgnore.has(next)) return false;
|
|
2960
|
+
}
|
|
2961
|
+
return true;
|
|
2962
|
+
});
|
|
2661
2963
|
if (kept.length !== lines.length) {
|
|
2662
2964
|
const text2 = kept.join(eol).replace(/(\r?\n)+$/, "");
|
|
2663
2965
|
edits.push({ path: ".gitignore", before: gitignore, after: text2 ? `${text2}${eol}` : null });
|
|
2664
2966
|
}
|
|
2665
2967
|
}
|
|
2666
|
-
const agents = await readOrNull3(
|
|
2968
|
+
const agents = await readOrNull3(join9(root, AGENTS_MD));
|
|
2667
2969
|
if (agents?.includes(BLOCK_START)) {
|
|
2668
2970
|
edits.push({ path: AGENTS_MD, before: agents, after: removeAgentsBlock(agents) });
|
|
2669
2971
|
}
|
|
2670
2972
|
for (const p of await catenextSubagentFiles(root)) {
|
|
2671
|
-
edits.push({ path: p, before: await readOrNull3(
|
|
2973
|
+
edits.push({ path: p, before: await readOrNull3(join9(root, p)), after: null });
|
|
2672
2974
|
}
|
|
2673
|
-
for (const p of [CONFIG_PATH,
|
|
2674
|
-
const before = await readOrNull3(
|
|
2975
|
+
for (const p of [CONFIG_PATH, join9(".catenext", "cache.json")]) {
|
|
2976
|
+
const before = await readOrNull3(join9(root, p));
|
|
2675
2977
|
if (before !== null) edits.push({ path: p, before, after: null });
|
|
2676
2978
|
}
|
|
2677
2979
|
if (opts.all) {
|
|
2678
2980
|
const { skills, invalid } = await listSkills(root);
|
|
2679
2981
|
for (const f of [...skills.map((s) => `${s.name}.md`), ...invalid.map((i) => i.file)]) {
|
|
2680
|
-
const p =
|
|
2681
|
-
edits.push({ path: p, before: await readOrNull3(
|
|
2982
|
+
const p = join9(SKILLS_DIR, f);
|
|
2983
|
+
edits.push({ path: p, before: await readOrNull3(join9(root, p)), after: null });
|
|
2682
2984
|
}
|
|
2683
2985
|
}
|
|
2684
2986
|
return edits;
|
|
@@ -2686,19 +2988,19 @@ async function planRemove(opts) {
|
|
|
2686
2988
|
async function applyFileEdits(root, edits) {
|
|
2687
2989
|
const base = resolve3(root);
|
|
2688
2990
|
for (const e of edits) {
|
|
2689
|
-
const target =
|
|
2991
|
+
const target = join9(base, e.path);
|
|
2690
2992
|
if (e.after === null) {
|
|
2691
2993
|
await rm(target, { force: true });
|
|
2692
2994
|
continue;
|
|
2693
2995
|
}
|
|
2694
|
-
await
|
|
2996
|
+
await mkdir5(dirname3(target), { recursive: true });
|
|
2695
2997
|
if (e.backup && e.before !== null) await copyFile(target, `${target}.bak`);
|
|
2696
2998
|
const tmp = `${target}.catenext-${process.pid}.tmp`;
|
|
2697
|
-
await
|
|
2999
|
+
await writeFile5(tmp, e.after);
|
|
2698
3000
|
await rename4(tmp, target);
|
|
2699
3001
|
}
|
|
2700
3002
|
for (const dir of [SKILLS_DIR, ".catenext", ".cursor", SUBAGENTS_DIR, ".claude"]) {
|
|
2701
|
-
await rmdir(
|
|
3003
|
+
await rmdir(join9(base, dir)).catch(() => {
|
|
2702
3004
|
});
|
|
2703
3005
|
}
|
|
2704
3006
|
}
|
|
@@ -2715,12 +3017,13 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
2715
3017
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2716
3018
|
var SERVER_INSTRUCTIONS = [
|
|
2717
3019
|
"Catenext mengatur estafet task antar-agen AI untuk repo ini.",
|
|
2718
|
-
"Alur: get_project_context -> get_ready_tasks -> claim_task -> kerjakan &
|
|
3020
|
+
"Alur: get_project_context -> get_ready_tasks -> claim_task (worktree wajib jika layout=monorepo) -> kerjakan & commit di branch -> buat PR -> complete_handoff (pull_request wajib \u2192 NEEDS_REVIEW).",
|
|
2719
3021
|
"Merencanakan: list_epics/create_epic -> create_tasks (masuk DRAFT, disetujui manusia di Web sebelum bisa dikerjakan).",
|
|
2720
3022
|
"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
3023
|
'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
3024
|
"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
3025
|
"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.",
|
|
3026
|
+
"Sebelum load_skill atau get_document buta, boleh search_context (query singkat) untuk menemukan dokumen/skill/task relevan (embedding + cache; rerank bila tersedia).",
|
|
2724
3027
|
"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).",
|
|
2725
3028
|
"Bila buntu, panggil report_blocker. Jangan menyalin kode atau secret ke handoff; rujuk path file.",
|
|
2726
3029
|
"Jangan mengedit .catenext/config.yaml atau file konfigurasi MCP IDE."
|
|
@@ -2808,15 +3111,27 @@ function createCatenextMcpServer(opts) {
|
|
|
2808
3111
|
server.registerTool(
|
|
2809
3112
|
"claim_task",
|
|
2810
3113
|
{ description: MCP_TOOLS.claim_task.description, inputSchema: MCP_TOOLS.claim_task.input },
|
|
2811
|
-
(input) => call(
|
|
2812
|
-
|
|
3114
|
+
(input) => call(async ({ api, config }) => {
|
|
3115
|
+
const agentAlias = input.agent_alias ?? config.overrides?.default_agent_alias;
|
|
3116
|
+
if (!input.worktree) {
|
|
3117
|
+
const ctx = await api.post("context", {
|
|
3118
|
+
...agentAlias ? { agent_alias: agentAlias } : {}
|
|
3119
|
+
});
|
|
3120
|
+
if (ctx.project?.layout === "monorepo") {
|
|
3121
|
+
return text(
|
|
3122
|
+
"Proyek layout monorepo: claim_task wajib worktree { branch, session_id }. Checkout branch kerja lalu kirim worktree, atau catenext claim <id> --worktree.",
|
|
3123
|
+
true
|
|
3124
|
+
);
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
return json(
|
|
2813
3128
|
await api.post("claim", {
|
|
2814
3129
|
task_id: input.task_id,
|
|
2815
3130
|
worktree: input.worktree,
|
|
2816
|
-
agent_alias:
|
|
3131
|
+
agent_alias: agentAlias
|
|
2817
3132
|
})
|
|
2818
|
-
)
|
|
2819
|
-
)
|
|
3133
|
+
);
|
|
3134
|
+
})
|
|
2820
3135
|
);
|
|
2821
3136
|
server.registerTool(
|
|
2822
3137
|
"complete_handoff",
|
|
@@ -2938,6 +3253,28 @@ ${zodIssues(parsed.error)}`, true);
|
|
|
2938
3253
|
(api, payload) => api.put("documents", payload)
|
|
2939
3254
|
)
|
|
2940
3255
|
);
|
|
3256
|
+
server.registerTool(
|
|
3257
|
+
"search_context",
|
|
3258
|
+
{
|
|
3259
|
+
description: MCP_TOOLS.search_context.description,
|
|
3260
|
+
inputSchema: MCP_TOOLS.search_context.input
|
|
3261
|
+
},
|
|
3262
|
+
(input) => call(async ({ api }) => {
|
|
3263
|
+
const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["sources", "limit"]));
|
|
3264
|
+
const parsed = SearchContextInput.safeParse(scrubbed.value);
|
|
3265
|
+
if (!parsed.success) {
|
|
3266
|
+
return text(`Input ditolak sebelum dikirim:
|
|
3267
|
+
${zodIssues(parsed.error)}`, true);
|
|
3268
|
+
}
|
|
3269
|
+
const notes = [];
|
|
3270
|
+
if (scrubbed.total > 0) {
|
|
3271
|
+
const note = describeRedactions(scrubbed);
|
|
3272
|
+
log(note);
|
|
3273
|
+
notes.push(note);
|
|
3274
|
+
}
|
|
3275
|
+
return json(await api.post("search", parsed.data), notes);
|
|
3276
|
+
})
|
|
3277
|
+
);
|
|
2941
3278
|
server.registerTool(
|
|
2942
3279
|
"list_epics",
|
|
2943
3280
|
{ description: MCP_TOOLS.list_epics.description, inputSchema: MCP_TOOLS.list_epics.input },
|
|
@@ -3072,8 +3409,8 @@ async function runMcpServer(opts) {
|
|
|
3072
3409
|
}
|
|
3073
3410
|
|
|
3074
3411
|
// src/verify.ts
|
|
3075
|
-
import { readFile as
|
|
3076
|
-
import { join as
|
|
3412
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
3413
|
+
import { join as join10 } from "node:path";
|
|
3077
3414
|
async function verifySetup(root, config) {
|
|
3078
3415
|
const lines = [];
|
|
3079
3416
|
let tokenLine;
|
|
@@ -3113,7 +3450,7 @@ async function verifySetup(root, config) {
|
|
|
3113
3450
|
const missing = [];
|
|
3114
3451
|
const stale = [];
|
|
3115
3452
|
for (const adapter of ADAPTERS) {
|
|
3116
|
-
const src = await
|
|
3453
|
+
const src = await readFile10(join10(root, adapter.path), "utf8").catch(() => null);
|
|
3117
3454
|
const entry = src ? readMcpEntry(src) : null;
|
|
3118
3455
|
if (!entry) missing.push(adapter.label);
|
|
3119
3456
|
else if (entryIsStale(entry)) stale.push(adapter.label);
|
|
@@ -3137,7 +3474,7 @@ function formatChecks(lines) {
|
|
|
3137
3474
|
}
|
|
3138
3475
|
|
|
3139
3476
|
// src/index.ts
|
|
3140
|
-
var VERSION = "0.
|
|
3477
|
+
var VERSION = "0.5.0";
|
|
3141
3478
|
var program = new Command();
|
|
3142
3479
|
program.name("catenext").description("Estafet tugas & konteks antar-agen AI coding").version(VERSION);
|
|
3143
3480
|
async function friendly(fn) {
|
|
@@ -3307,8 +3644,33 @@ doc.command("list").option("--json", "Keluaran JSON").action(
|
|
|
3307
3644
|
doc.command("get").argument("<slug>").option("--json", "Keluaran JSON").action(
|
|
3308
3645
|
(slug, opts) => friendly(async () => docGet(await cliApi(), slug, Boolean(opts.json)))
|
|
3309
3646
|
);
|
|
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(
|
|
3311
|
-
|
|
3647
|
+
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(
|
|
3648
|
+
"--expected-version <n>",
|
|
3649
|
+
"Versi yang Anda baca (0 = dokumen baru); mencegah menimpa sesi lain. Jangan pakai --version (bentrok flag versi CLI)."
|
|
3650
|
+
).option("--json", "Keluaran JSON").action(
|
|
3651
|
+
(slug, opts) => friendly(
|
|
3652
|
+
async () => docSave(await cliApi(), slug, {
|
|
3653
|
+
file: opts.file,
|
|
3654
|
+
title: opts.title,
|
|
3655
|
+
kind: opts.kind,
|
|
3656
|
+
version: opts.expectedVersion,
|
|
3657
|
+
json: opts.json
|
|
3658
|
+
})
|
|
3659
|
+
)
|
|
3660
|
+
);
|
|
3661
|
+
program.command("search").description("Cari semantik di dokumen/skill/task Cloud dan/atau kode lokal").argument("<query>", "Query pencarian").option(
|
|
3662
|
+
"--source <src>",
|
|
3663
|
+
"Sumber: document|skill|task|code (bisa diulang)",
|
|
3664
|
+
(v, prev) => [...prev, v],
|
|
3665
|
+
[]
|
|
3666
|
+
).option("-n, --limit <n>", "Jumlah hasil", (v) => Number.parseInt(v, 10), 8).option("--json", "Keluaran JSON").action(
|
|
3667
|
+
(query, opts) => friendly(
|
|
3668
|
+
async () => searchShow(await cliApi(), query, {
|
|
3669
|
+
source: opts.source.length ? opts.source : void 0,
|
|
3670
|
+
limit: opts.limit,
|
|
3671
|
+
json: opts.json
|
|
3672
|
+
})
|
|
3673
|
+
)
|
|
3312
3674
|
);
|
|
3313
3675
|
var collect = (v, prev) => [...prev, v];
|
|
3314
3676
|
var AGENT_OPT = [
|
|
@@ -3319,7 +3681,7 @@ var AGENT_OPT = [
|
|
|
3319
3681
|
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(
|
|
3320
3682
|
(opts) => friendly(async () => taskNext(await cliApi(opts.agent), opts))
|
|
3321
3683
|
);
|
|
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
|
|
3684
|
+
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 + lease sesi (wajib di proyek layout monorepo)").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
|
|
3323
3685
|
(taskId, opts) => friendly(async () => taskClaim(await cliApi(opts.agent), taskId, opts))
|
|
3324
3686
|
);
|
|
3325
3687
|
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(
|
|
@@ -3332,7 +3694,7 @@ program.command("done").description("Selesaikan task dengan handoff terstruktur
|
|
|
3332
3694
|
"File yang diubah (boleh diulang; default dari git)",
|
|
3333
3695
|
collect,
|
|
3334
3696
|
[]
|
|
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(
|
|
3697
|
+
).option("--verify <cmd>", "Perintah verifikasi, mis. pnpm test").option("--pr <url>", "URL pull request GitHub (wajib bersama --base)").option("--base <branch>", "Branch tujuan PR (wajib bersama --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(
|
|
3336
3698
|
(taskId, opts) => friendly(async () => taskDone(await cliApi(opts.agent), taskId, opts))
|
|
3337
3699
|
);
|
|
3338
3700
|
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(
|