rempug 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,308 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { basename, join } from "node:path";
6
+ import { deflateSync, inflateSync } from "node:zlib";
7
+ import { parseBrief } from "./brief.js";
8
+ import { RempugError } from "./errors.js";
9
+ import { gitFiles, gitInfo, isGitRepo } from "./git.js";
10
+ import { covers } from "./scope.js";
11
+ /** Berkas di atas ukuran ini hanya disimpan hash-nya, tanpa isi. */
12
+ const BATAS_BERKAS = 1024 * 1024;
13
+ const WAKTU_CEK_MS = 10 * 60_000;
14
+ const sha1 = (isi) => createHash("sha1").update(isi).digest("hex");
15
+ const biner = (isi) => isi.subarray(0, 8000).includes(0);
16
+ function baca(repo, path) {
17
+ try {
18
+ return readFileSync(join(repo, path));
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
24
+ /**
25
+ * Menyimpan isi berkas dalam cakupan tugas (terlacak dan baru) ke ledger, supaya perubahan agent
26
+ * dapat dihitung sendiri nanti. Tidak menulis apa pun ke repo, termasuk `.git`.
27
+ */
28
+ export function takeSnapshot(ledger, task, repo) {
29
+ if (!isGitRepo(repo))
30
+ throw new RempugError(`tugas edit membutuhkan repo git: ${repo}`);
31
+ const berkas = gitFiles(repo, task.scope ?? []);
32
+ for (const path of berkas) {
33
+ const isi = baca(repo, path);
34
+ if (!isi)
35
+ continue;
36
+ const simpan = isi.length <= BATAS_BERKAS && !biner(isi);
37
+ ledger.addSnapshot(task.id, path, sha1(isi), simpan ? deflateSync(isi) : null);
38
+ }
39
+ return berkas.length;
40
+ }
41
+ /** `[tambah, hapus]` antara dua berkas, atau `"biner"`. `/dev/null` berarti berkas tidak ada. */
42
+ function numstat(lama, baru) {
43
+ const hasil = spawnSync("git", ["diff", "--no-index", "--numstat", "--", lama, baru], {
44
+ encoding: "utf8",
45
+ maxBuffer: 64 * 1024 * 1024,
46
+ });
47
+ const cocok = /^(\S+)\t(\S+)\t/m.exec(hasil.stdout);
48
+ if (!cocok)
49
+ return [0, 0];
50
+ return cocok[1] === "-" ? "biner" : [Number(cocok[1]), Number(cocok[2])];
51
+ }
52
+ /** Berkas yang berubah sejak snapshot, dengan jumlah baris +/−; dihitung dari isi, bukan dari klaim agent. */
53
+ export function computeChanges(ledger, task, repo) {
54
+ const dir = mkdtempSync(join(tmpdir(), "rempug-diff-"));
55
+ try {
56
+ const snapshots = ledger.getSnapshots(task.id);
57
+ const ada = new Set(snapshots.map((s) => s.path));
58
+ const hasil = [];
59
+ const hitung = (path, status, lama, baru) => {
60
+ const n = numstat(lama, baru);
61
+ hasil.push(n === "biner"
62
+ ? { path, status, plus: 0, minus: 0, biner: true }
63
+ : { path, status, plus: n[0], minus: n[1] });
64
+ };
65
+ snapshots.forEach((s, i) => {
66
+ const sekarang = baca(repo, s.path);
67
+ if (sekarang && sha1(sekarang) === s.hash)
68
+ return;
69
+ if (!s.content || (sekarang && biner(sekarang))) {
70
+ hasil.push({
71
+ path: s.path,
72
+ status: sekarang ? "M" : "D",
73
+ plus: 0,
74
+ minus: 0,
75
+ biner: true,
76
+ });
77
+ return;
78
+ }
79
+ const lama = join(dir, `lama-${i}`);
80
+ writeFileSync(lama, inflateSync(s.content));
81
+ if (sekarang)
82
+ hitung(s.path, "M", lama, join(repo, s.path));
83
+ else
84
+ hitung(s.path, "D", lama, "/dev/null");
85
+ });
86
+ for (const path of gitFiles(repo, task.scope ?? [])) {
87
+ if (ada.has(path))
88
+ continue;
89
+ const sekarang = baca(repo, path);
90
+ if (!sekarang)
91
+ continue;
92
+ if (biner(sekarang))
93
+ hasil.push({ path, status: "A", plus: 0, minus: 0, biner: true });
94
+ else
95
+ hitung(path, "A", "/dev/null", join(repo, path));
96
+ }
97
+ return hasil.sort((a, b) => a.path.localeCompare(b.path));
98
+ }
99
+ finally {
100
+ rmSync(dir, { recursive: true, force: true });
101
+ }
102
+ }
103
+ /** Diff unified satu berkas terhadap snapshot, dipotong supaya tidak membanjiri orkestrator. */
104
+ export function unifiedDiff(ledger, task, repo, path, maksBaris = 200) {
105
+ const snapshot = ledger.getSnapshots(task.id).find((s) => s.path === path);
106
+ const sekarang = baca(repo, path);
107
+ if (!snapshot && !sekarang)
108
+ throw new RempugError(`${path} tidak ada di snapshot T${task.id} maupun di disk`);
109
+ const dir = mkdtempSync(join(tmpdir(), "rempug-diff-"));
110
+ try {
111
+ let lama = "/dev/null";
112
+ if (snapshot?.content) {
113
+ lama = join(dir, "lama");
114
+ writeFileSync(lama, inflateSync(snapshot.content));
115
+ }
116
+ const baru = sekarang ? join(repo, path) : "/dev/null";
117
+ const hasil = spawnSync("git", ["diff", "--no-index", "--no-color", "--", lama, baru], {
118
+ encoding: "utf8",
119
+ maxBuffer: 64 * 1024 * 1024,
120
+ });
121
+ // Git menambah awalan a/ dan b/ di depan path absolut, jadi awalan itu ikut diganti.
122
+ const teks = hasil.stdout
123
+ .replaceAll(`a${lama}`, `a/${path}`)
124
+ .replaceAll(`b${baru}`, `b/${path}`);
125
+ if (!teks.trim())
126
+ return `(tidak ada perubahan pada ${path})`;
127
+ const baris = teks.trimEnd().split("\n");
128
+ if (baris.length <= maksBaris)
129
+ return baris.join("\n");
130
+ return [
131
+ ...baris.slice(0, maksBaris),
132
+ `… ${baris.length - maksBaris} baris lagi dipotong`,
133
+ ].join("\n");
134
+ }
135
+ finally {
136
+ rmSync(dir, { recursive: true, force: true });
137
+ }
138
+ }
139
+ function parsePorcelain(teks) {
140
+ const peta = new Map();
141
+ for (const baris of (teks ?? "").split("\n").filter(Boolean)) {
142
+ let path = baris.slice(3);
143
+ if (path.includes(" -> "))
144
+ path = path.split(" -> ").pop();
145
+ peta.set(path.replace(/^"|"$/g, ""), baris);
146
+ }
147
+ return peta;
148
+ }
149
+ /**
150
+ * Berkas yang berubah sejak tugas dikirim tetapi di luar cakupan tugas ini dan tugas edit lain yang berjalan bersamaan.
151
+ * Hanya nama: bisa pelanggaran agent, bisa juga hasil edit user sendiri.
152
+ */
153
+ export function outsideScope(ledger, task, repo) {
154
+ const awal = parsePorcelain(task.porcelain);
155
+ const kini = parsePorcelain(gitInfo(repo).porcelain);
156
+ // Tugas edit lain yang jendela waktunya beririsan juga mengubah berkas di repo ini, jadi perubahan
157
+ // di cakupan mereka bukan "di luar cakupan" milik tugas ini, walau mereka sudah selesai lebih dulu.
158
+ const akhir = task.repliedAt ?? ledger.now();
159
+ const milikLain = ledger
160
+ .listTasks(task.repo)
161
+ .filter((t) => t.id !== task.id &&
162
+ t.mode === "edit" &&
163
+ t.status !== "antri" &&
164
+ t.sentAt <= akhir &&
165
+ (t.repliedAt ?? Number.POSITIVE_INFINITY) >= task.sentAt)
166
+ .flatMap((t) => t.scope ?? []);
167
+ return [...kini]
168
+ .filter(([path, baris]) => awal.get(path) !== baris)
169
+ .map(([path]) => path)
170
+ .filter((path) => !covers(task.scope ?? [], path) && !covers(milikLain, path))
171
+ .sort();
172
+ }
173
+ const POLA_GAGAL = [
174
+ /Found (\d+) errors?/i,
175
+ /Tests?:?\s+(\d+) failed/i,
176
+ /ℹ fail (\d+)/,
177
+ /(\d+) failing/i,
178
+ ];
179
+ /** Jumlah kegagalan dari keluaran alat yang dikenal (tsc, biome, vitest, jest, node:test); kosong bila tidak jelas. */
180
+ export function parseFailureCount(keluaran) {
181
+ for (const pola of POLA_GAGAL) {
182
+ const n = Number(pola.exec(keluaran)?.[1]);
183
+ if (n > 0)
184
+ return n;
185
+ }
186
+ return undefined;
187
+ }
188
+ const PEMBUNGKUS = new Set([
189
+ "yarn",
190
+ "npm",
191
+ "pnpm",
192
+ "npx",
193
+ "node",
194
+ "run",
195
+ "exec",
196
+ "dlx",
197
+ "sh",
198
+ "bash",
199
+ "bun",
200
+ "bunx",
201
+ ]);
202
+ /** Nama alat dari perintah, melewati pembungkus dan opsi: `yarn tsc -b` → `tsc`. */
203
+ export function checkLabel(cmd) {
204
+ const token = cmd
205
+ .split(/\s+/)
206
+ .filter(Boolean)
207
+ .find((t) => !PEMBUNGKUS.has(t) && !t.startsWith("-"));
208
+ return token ? basename(token) : cmd;
209
+ }
210
+ /** Menjalankan perintah cek satu per satu (semuanya, walau ada yang gagal) di root repo. */
211
+ export function runChecks(perintah, cwd, waktuMs = WAKTU_CEK_MS) {
212
+ return perintah.map((cmd) => {
213
+ const hasil = spawnSync("sh", ["-c", cmd], {
214
+ cwd,
215
+ encoding: "utf8",
216
+ timeout: waktuMs,
217
+ killSignal: "SIGKILL",
218
+ maxBuffer: 32 * 1024 * 1024,
219
+ });
220
+ const keluaran = `${hasil.stdout ?? ""}${hasil.stderr ?? ""}${hasil.error && !hasil.stdout ? `\n${hasil.error.message}` : ""}`;
221
+ const timeout = hasil.error?.code === "ETIMEDOUT";
222
+ const ok = !hasil.error && hasil.status === 0;
223
+ return {
224
+ cmd,
225
+ label: checkLabel(cmd),
226
+ ok,
227
+ kode: hasil.status,
228
+ timeout,
229
+ gagal: ok ? undefined : parseFailureCount(keluaran),
230
+ ekor: keluaran.trimEnd().split("\n").slice(-10).join("\n"),
231
+ };
232
+ });
233
+ }
234
+ const pendek = (sha) => (sha ?? "?").slice(0, 7);
235
+ /** Satu baris ringkas hasil verifikasi, mis. `T12 codex ✓ 3 file +41/−7 | scope OK | tsc ✓ vitest ✗(2)`. */
236
+ export function formatLine(task, hasil) {
237
+ const kepala = `T${task.id} ${task.agent}`;
238
+ if (hasil.pelanggaran)
239
+ return `${kepala} ⚠ pelanggaran: ${hasil.pelanggaran}`;
240
+ const tanda = hasil.ok ? "✓" : "✗";
241
+ const cek = hasil.cek.map((c) => c.ok
242
+ ? `${c.label} ✓`
243
+ : c.timeout
244
+ ? `${c.label} ⏱`
245
+ : c.gagal
246
+ ? `${c.label} ✗(${c.gagal})`
247
+ : `${c.label} ✗`);
248
+ const bagian = [];
249
+ if (task.mode === "edit") {
250
+ const luar = hasil.luarCakupan;
251
+ bagian.push(`${hasil.perubahan.length} file +${hasil.plus}/−${hasil.minus}`);
252
+ bagian.push(luar.length === 0
253
+ ? "scope OK"
254
+ : `scope ⚠ ${luar.length} di luar: ${luar.slice(0, 3).join(", ")}${luar.length > 3 ? "…" : ""}`);
255
+ }
256
+ else {
257
+ const baris = (task.replySummary ?? "").split("\n")[0] ?? "";
258
+ bagian.push(`${task.mode} | ${baris.length > 100 ? `${baris.slice(0, 99)}…` : baris}`.trimEnd());
259
+ }
260
+ // Untuk tugas baca, bagian pertama sudah memuat "baca | ringkasan"; cek menyusul setelahnya.
261
+ const dasar = `${kepala} ${tanda} ${task.mode === "edit" ? bagian.join(" | ") : bagian[0]}`;
262
+ const akhir = [
263
+ ...(cek.length ? [cek.join(" ")] : []),
264
+ ...(hasil.tanpaPaham ? ["⚠ tanpa paham"] : []),
265
+ ];
266
+ return [dasar, ...akhir].join(" | ");
267
+ }
268
+ /**
269
+ * Memverifikasi tugas yang sudah dibalas agent: perubahan berkas, cek penerimaan, dan commit.
270
+ * Mengubah status menjadi selesai, gagal, atau pelanggaran, dan menulis satu event.
271
+ */
272
+ export function verifyTask(ledger, id, options = {}) {
273
+ const task = ledger.getTask(id);
274
+ if (!task)
275
+ throw new RempugError(`tugas T${id} tidak ada`);
276
+ if (task.status !== "memverifikasi")
277
+ throw new RempugError(`tugas T${id} berstatus ${task.status}; tidak sedang memverifikasi`);
278
+ const parsed = parseBrief(task.brief);
279
+ // CEK dijalankan sebagai perintah shell hanya untuk tugas edit. Pada tugas baca dan browser ia adalah
280
+ // deskripsi bukti yang harus dilaporkan agent; menjalankannya sebagai shell menggagalkan tugas yang benar.
281
+ const cek = parsed.ok && task.mode === "edit" ? parsed.brief.cek : [];
282
+ const edit = task.mode === "edit";
283
+ const git = gitInfo(task.repo);
284
+ let pelanggaran;
285
+ if (task.headSha && git.head && task.headSha !== git.head)
286
+ pelanggaran = `HEAD berubah (${pendek(task.headSha)}→${pendek(git.head)})`;
287
+ else if (task.branch && git.branch && task.branch !== git.branch)
288
+ pelanggaran = `branch berubah (${task.branch}→${git.branch})`;
289
+ const perubahan = edit ? computeChanges(ledger, task, task.repo) : [];
290
+ const hasilCek = runChecks(cek, task.repo, options.waktuCekMs);
291
+ const hasil = {
292
+ ok: !pelanggaran && hasilCek.every((c) => c.ok),
293
+ pelanggaran,
294
+ perubahan,
295
+ plus: perubahan.reduce((n, f) => n + f.plus, 0),
296
+ minus: perubahan.reduce((n, f) => n + f.minus, 0),
297
+ luarCakupan: edit ? outsideScope(ledger, task, task.repo) : [],
298
+ cek: hasilCek,
299
+ tanpaPaham: edit && !task.paham,
300
+ linha: "",
301
+ };
302
+ hasil.linha = formatLine(task, hasil);
303
+ const status = pelanggaran ? "pelanggaran" : hasil.ok ? "selesai" : "gagal";
304
+ ledger.patch(id, { verify: JSON.stringify(hasil) });
305
+ ledger.setStatus(id, status);
306
+ ledger.addEvent(id, status, hasil.linha);
307
+ return hasil;
308
+ }
@@ -0,0 +1,51 @@
1
+ import { KONSUMEN } from "./send.js";
2
+ export function kejadianTertunda(ledger, repo, konsumen = KONSUMEN) {
3
+ const kursor = ledger.getConsumer(konsumen)?.lastEventId;
4
+ return kursor === undefined ? [] : ledger.eventsAfter(kursor, repo);
5
+ }
6
+ /** Satu baris penanda bila ada kejadian yang belum disampaikan; ditempel di awal keluaran perintah lain. */
7
+ export function penandaTertunda(ledger, repo, konsumen = KONSUMEN) {
8
+ const n = kejadianTertunda(ledger, repo, konsumen).length;
9
+ return n > 0
10
+ ? `[${n} kejadian belum disampaikan: jalankan \`rempug terima\`]`
11
+ : undefined;
12
+ }
13
+ /** Mengambil kejadian tertunda dan memajukan kursor; dipakai saat `watch` tidak berjalan. */
14
+ export function terima(ledger, repo, konsumen = KONSUMEN) {
15
+ const baru = kejadianTertunda(ledger, repo, konsumen);
16
+ for (const e of baru)
17
+ ledger.advanceConsumer(konsumen, e.id);
18
+ return baru.map((e) => e.line);
19
+ }
20
+ function tidur(ms, sinyal) {
21
+ return new Promise((resolve) => {
22
+ const selesai = () => {
23
+ clearTimeout(timer);
24
+ sinyal?.removeEventListener("abort", selesai);
25
+ resolve();
26
+ };
27
+ const timer = setTimeout(selesai, ms);
28
+ sinyal?.addEventListener("abort", selesai, { once: true });
29
+ });
30
+ }
31
+ /**
32
+ * Mencetak satu baris per kejadian sampai dihentikan. Kursor disimpan per konsumen, jadi `watch`
33
+ * yang dipasang ulang menerima dulu semua yang terlewat. Konsumen baru hanya menerima kejadian
34
+ * sesudah ia mulai. Tidak mencetak apa pun saat sepi, karena tiap baris menjadi satu notifikasi.
35
+ */
36
+ export async function watch(opsi) {
37
+ const { ledger, repo, konsumen = KONSUMEN, tulis, sinyal } = opsi;
38
+ ledger.ensureConsumer(konsumen, ledger.maxEventId(repo));
39
+ while (!sinyal?.aborted) {
40
+ const baru = kejadianTertunda(ledger, repo, konsumen);
41
+ for (const e of baru) {
42
+ tulis(e.line);
43
+ // Maju setelah menulis: bila proses mati di antaranya, kejadian dikirim ulang, bukan hilang.
44
+ ledger.advanceConsumer(konsumen, e.id);
45
+ }
46
+ if (baru.length === 0)
47
+ ledger.touchConsumer(konsumen);
48
+ await opsi.tiapSiklus?.();
49
+ await tidur(opsi.intervalMs ?? 1000, sinyal);
50
+ }
51
+ }
@@ -0,0 +1,119 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { z } from "zod";
4
+ import { run } from "./commands.js";
5
+ import { UsageError } from "./core/errors.js";
6
+ /** Menjalankan perintah CLI yang setara dan membungkus keluarannya sebagai hasil tool. */
7
+ async function panggil(dasar, { argv, stdin }) {
8
+ const out = [];
9
+ const err = [];
10
+ const kode = await run(argv, {
11
+ ...dasar,
12
+ io: {
13
+ stdout: (teks) => void out.push(teks),
14
+ stderr: (teks) => void err.push(teks),
15
+ stdin: async () => {
16
+ if (stdin === undefined)
17
+ throw new UsageError("perintah ini membutuhkan isi teks");
18
+ return stdin;
19
+ },
20
+ },
21
+ });
22
+ const teks = [...out, ...err].join("\n") || "(kosong)";
23
+ return {
24
+ content: [{ type: "text", text: teks }],
25
+ isError: kode !== 0,
26
+ };
27
+ }
28
+ const bendera = (nama, nilai) => nilai ? [`--${nama}`] : [];
29
+ const opsi = (nama, nilai) => nilai === undefined ? [] : [`--${nama}`, String(nilai)];
30
+ /**
31
+ * Server MCP: pembungkus tipis di atas perintah CLI yang sama, jadi perilakunya identik.
32
+ * `watch` sengaja tidak diekspos karena panjang umur; ia dijalankan lewat Monitor dari CLI.
33
+ */
34
+ export async function jalankanMcp(dasar, versi) {
35
+ const server = new McpServer({ name: "rempug", version: versi });
36
+ const id = z.number().int().positive().describe("ID tugas, mis. 12");
37
+ // Tipe kondisional registerTool tidak dapat diselesaikan untuk skema bergenerik, jadi pendaftaran dipersempit
38
+ // di satu titik ini; tiap tool tetap bertipe ketat lewat parameter `bangun`.
39
+ const daftar = server.registerTool.bind(server);
40
+ function alat(nama, deskripsi, masukan, bangun) {
41
+ daftar(nama, { description: deskripsi, inputSchema: masukan }, (a) => panggil(dasar, bangun(a)));
42
+ }
43
+ alat("scan", "Pindai pane tmux dan beri skor kandidat agent (JSON).", {}, () => ({ argv: ["scan"] }));
44
+ alat("register", "Daftarkan agent dari pane tmux lalu probe cara mengirimnya; mengembalikan status kesiapan.", {
45
+ nama: z.string().describe("nama pendek, mis. codex"),
46
+ target: z.string().describe("sesi:window.pane, dari scan"),
47
+ jenis: z.string().optional(),
48
+ kemampuan: z.array(z.string()).optional().describe("mis. playwright"),
49
+ tanpaProbe: z.boolean().optional(),
50
+ }, (a) => ({
51
+ argv: [
52
+ "register",
53
+ a.nama,
54
+ "--target",
55
+ a.target,
56
+ ...opsi("jenis", a.jenis),
57
+ ...opsi("kemampuan", a.kemampuan?.join(",")),
58
+ ...bendera("tanpa-probe", a.tanpaProbe),
59
+ ],
60
+ }));
61
+ alat("probe", "Ukur ulang cara mengirim ke agent. `profil` (JSON) menguji satu profil usulan.", { nama: z.string(), profil: z.string().optional() }, (a) => ({ argv: ["probe", a.nama, ...opsi("profil", a.profil)] }));
62
+ alat("ls", "Daftar agent: status siap/sibuk/hilang/tidak-andal, kemampuan, tugas aktif.", {}, () => ({ argv: ["ls"] }));
63
+ alat("status", "Satu baris kondisi agent; membersihkan agent yang sesinya hilang.", {}, () => ({ argv: ["status"] }));
64
+ alat("send", "Kirim tugas ke agent. Brief wajib memuat TUJUAN, CAKUPAN (edit <path...>|baca|browser), LANGKAH bernomor, CEK, BALASAN. Kembali segera dengan ID.", {
65
+ agent: z.string(),
66
+ brief: z.string().describe("teks brief berlabel"),
67
+ queue: z.boolean().optional().describe("antre bila agent sibuk"),
68
+ after: z
69
+ .number()
70
+ .int()
71
+ .positive()
72
+ .optional()
73
+ .describe("tunggu tugas ini selesai dulu"),
74
+ teliti: z.boolean().optional().describe("selalu tinjau rencana agent"),
75
+ centang: z
76
+ .string()
77
+ .optional()
78
+ .describe("berkas#nomor tasks.md yang dicentang bila lulus"),
79
+ }, (a) => ({
80
+ argv: [
81
+ "send",
82
+ a.agent,
83
+ ...bendera("queue", a.queue),
84
+ ...opsi("after", a.after),
85
+ ...bendera("teliti", a.teliti),
86
+ ...opsi("centang", a.centang),
87
+ ],
88
+ stdin: a.brief,
89
+ }));
90
+ alat("brief", "Baca teks tugas (untuk agent); ini menandai brief diterima.", { id }, (a) => ({ argv: ["brief", String(a.id)] }));
91
+ alat("paham", "Konfirmasi pemahaman tugas edit sebelum bekerja (CAKUPAN, CEK, RENCANA, ASUMSI, PERTANYAAN).", { id, isi: z.string() }, (a) => ({ argv: ["paham", String(a.id)], stdin: a.isi }));
92
+ alat("tunggu", "Tunggu jawaban klarifikasi; ulangi sampai LANJUT.", { id }, (a) => ({ argv: ["tunggu", String(a.id)] }));
93
+ alat("jawab", "Jawab klarifikasi atau pertanyaan agent.", { id, teks: z.string() }, (a) => ({ argv: ["jawab", String(a.id)], stdin: a.teks }));
94
+ alat("reply", "Balas tugas (HASIL, BUKTI, BLOCKER) dan mulai verifikasi; gagal=true bila tidak bisa menyelesaikan.", { id, isi: z.string(), gagal: z.boolean().optional() }, (a) => ({
95
+ argv: ["reply", String(a.id), ...bendera("gagal", a.gagal)],
96
+ stdin: a.isi,
97
+ }));
98
+ alat("log", "Satu baris per tugas di repo ini.", { n: z.number().int().positive().optional() }, (a) => ({
99
+ argv: ["log", ...opsi("n", a.n)],
100
+ }));
101
+ alat("show", "Ringkasan satu tugas; penuh=true menambah brief, balasan lengkap, dan perubahan.", { id, penuh: z.boolean().optional() }, (a) => ({
102
+ argv: ["show", String(a.id), ...bendera("penuh", a.penuh)],
103
+ }));
104
+ alat("diff", "Daftar file yang berubah, atau hunk satu file bila `berkas` diberikan.", { id, berkas: z.string().optional() }, (a) => ({
105
+ argv: ["diff", String(a.id), ...(a.berkas ? [a.berkas] : [])],
106
+ }));
107
+ alat("report", "Laporan pekerjaan. Untuk menjawab MANUSIA selalu manusia=true (kalimat biasa tanpa ID atau simbol); tanpa itu keluarannya hanya untuk orkestrator. md menulis berkas Markdown.", { md: z.string().optional(), manusia: z.boolean().optional() }, (a) => ({
108
+ argv: ["report", ...opsi("md", a.md), ...bendera("manusia", a.manusia)],
109
+ }));
110
+ alat("layar", "Layar mentah pane agent; hanya bila benar-benar perlu.", { agent: z.string(), baris: z.number().int().positive().optional() }, (a) => ({
111
+ argv: ["layar", a.agent, ...opsi("baris", a.baris)],
112
+ }));
113
+ alat("terima", "Ambil kejadian yang belum disampaikan (saat watch tidak berjalan).", {}, () => ({ argv: ["terima"] }));
114
+ const tutup = new Promise((resolve) => {
115
+ server.server.onclose = resolve;
116
+ });
117
+ await server.connect(new StdioServerTransport());
118
+ await tutup;
119
+ }
@@ -0,0 +1,31 @@
1
+ /** Versi Node minimum: `node:sqlite` bawaan tersedia tanpa flag mulai 22.13. */
2
+ export const MIN_NODE = "22.13.0";
3
+ function parse(version) {
4
+ const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
5
+ if (!match)
6
+ return undefined;
7
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
8
+ }
9
+ /**
10
+ * Memeriksa versi Node terhadap minimum. Harus dipanggil sebelum modul yang
11
+ * memakai `node:sqlite` dimuat, supaya pengguna mendapat pesan jelas, bukan galat impor.
12
+ */
13
+ export function checkNodeVersion(current, min = MIN_NODE) {
14
+ const have = parse(current);
15
+ const need = parse(min);
16
+ if (have && need) {
17
+ const [hMajor, hMinor, hPatch] = have;
18
+ const [nMajor, nMinor, nPatch] = need;
19
+ const ok = hMajor !== nMajor
20
+ ? hMajor > nMajor
21
+ : hMinor !== nMinor
22
+ ? hMinor > nMinor
23
+ : hPatch >= nPatch;
24
+ if (ok)
25
+ return { ok: true };
26
+ }
27
+ return {
28
+ ok: false,
29
+ message: `rempug membutuhkan Node ${min} atau lebih baru; yang terpasang: ${current}.`,
30
+ };
31
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "matcher": "startup|resume",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "rempug status 2>/dev/null || true"
10
+ }
11
+ ]
12
+ }
13
+ ]
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
- "name": "rempug",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "rempug",
3
+ "version": "0.1.1",
4
+ "description": "Distribusi kerja dari agent orkestrator ke agent CLI lain lewat tmux, hemat token.",
5
+ "keywords": [
6
+ "agent",
7
+ "orchestrator",
8
+ "tmux",
9
+ "mcp",
10
+ "cli"
11
+ ],
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "bin": {
15
+ "rempug": "dist/src/cli.js"
16
+ },
17
+ "files": [
18
+ "dist/src",
19
+ "skills",
20
+ ".claude-plugin",
21
+ "hooks",
22
+ ".mcp.json",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "engines": {
27
+ "node": ">=22.13"
28
+ },
29
+ "os": [
30
+ "linux",
31
+ "darwin"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "typecheck": "tsc --noEmit",
36
+ "check": "biome check .",
37
+ "test": "npm run build && node --test \"dist/test/**/*.test.js\"",
38
+ "prepublishOnly": "npm run build"
39
+ },
40
+ "devDependencies": {
41
+ "@biomejs/biome": "^2.6.8",
42
+ "@semantic-release/changelog": "^7.0.0",
43
+ "@semantic-release/git": "^11.0.1",
44
+ "@types/node": "^22.20.5",
45
+ "semantic-release": "^25.0.9",
46
+ "typescript": "^7.0.2"
47
+ },
48
+ "dependencies": {
49
+ "@modelcontextprotocol/sdk": "^1.32.2",
50
+ "zod": "^4.6.7"
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/dianramdhani/rempug.git"
55
+ },
56
+ "homepage": "https://github.com/dianramdhani/rempug#readme",
57
+ "bugs": {
58
+ "url": "https://github.com/dianramdhani/rempug/issues"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public",
62
+ "provenance": true
63
+ }
64
+ }