hanoman 0.1.8 → 0.1.10

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.8",
3
- "sha": "a749553",
4
- "builtAt": "2026-07-31T17:13:08.743Z"
2
+ "version": "0.1.10",
3
+ "sha": "db30c30",
4
+ "builtAt": "2026-08-01T02:45:06.324Z"
5
5
  }
package/dist/cli.js CHANGED
@@ -155,81 +155,6 @@ var init_agent_cli = __esm({
155
155
  }
156
156
  });
157
157
 
158
- // ../runner/src/paths.ts
159
- import { homedir } from "node:os";
160
- import { dirname, isAbsolute, join, resolve } from "node:path";
161
- function resolveHome(env = process.env, home = homedir()) {
162
- const v = env.HANOMAN_HOME?.trim();
163
- return v ? v : join(home, ".hanoman");
164
- }
165
- function schemeOf(raw) {
166
- return raw.split("://")[0] ?? "?";
167
- }
168
- function resolveDbUrl(env, schemaDir) {
169
- const own = env.HANOMAN_DATABASE_URL?.trim();
170
- if (own) {
171
- if (!own.startsWith("file:")) {
172
- throw new Error(
173
- `HANOMAN_DATABASE_URL harus URL SQLite \`file:\u2026\` sejak ADR-0086 (dapat \`${schemeOf(own)}\`). Masih punya data Postgres? Pindahkan sekali: hanoman migrate-from-postgres --from "<url-postgres>"`
174
- );
175
- }
176
- return absoluteFileUrl(own, schemaDir);
177
- }
178
- const raw = env.DATABASE_URL?.trim();
179
- if (!raw || !raw.startsWith("file:")) return `file:${join(resolveHome(env), "hanoman.db")}`;
180
- return absoluteFileUrl(raw, schemaDir);
181
- }
182
- function absoluteFileUrl(raw, schemaDir) {
183
- const p = raw.slice("file:".length);
184
- if (p.startsWith(":")) return raw;
185
- return `file:${isAbsolute(p) ? p : resolve(schemaDir, p)}`;
186
- }
187
- function dbUrlNotice(env) {
188
- if (env.HANOMAN_DATABASE_URL?.trim()) return null;
189
- const raw = env.DATABASE_URL?.trim();
190
- if (!raw || raw.startsWith("file:")) return null;
191
- return `hanoman: DATABASE_URL bertipe \`${schemeOf(raw)}\` DIABAIKAN \u2014 hanoman memakai SQLite (ADR-0086), dan var itu biasanya milik project lain.
192
- \u2022 Punya data Postgres hanoman? Pindahkan sekali: hanoman migrate-from-postgres --from "<url>"
193
- \u2022 Mau menunjuk berkas DB tertentu? Pakai HANOMAN_DATABASE_URL=file:/path/hanoman.db (atau --db)`;
194
- }
195
- function dbFilePath(url) {
196
- if (!url.startsWith("file:")) throw new Error(`bukan URL SQLite: ${url}`);
197
- return url.slice("file:".length);
198
- }
199
- function prismaCliPath(resolver) {
200
- for (const spec of ["prisma/build/index.js", "prisma/package.json"]) {
201
- try {
202
- const p = resolver(spec);
203
- return spec.endsWith("package.json") ? join(dirname(p), "build", "index.js") : p;
204
- } catch {
205
- }
206
- }
207
- throw new Error("CLI prisma tak ditemukan \u2014 `prisma` wajib terpasang sebagai dependency");
208
- }
209
- var init_paths = __esm({
210
- "../runner/src/paths.ts"() {
211
- "use strict";
212
- }
213
- });
214
-
215
- // ../runner/src/index.ts
216
- var init_src = __esm({
217
- "../runner/src/index.ts"() {
218
- "use strict";
219
- init_types();
220
- init_prompt();
221
- init_reverse_standard();
222
- init_git();
223
- init_settings();
224
- init_goal();
225
- init_goal_spec();
226
- init_codex_settings();
227
- init_agent_cli();
228
- init_verify_scope();
229
- init_paths();
230
- }
231
- });
232
-
233
158
  // ../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
234
159
  var util, objectUtil, ZodParsedType, getParsedType;
235
160
  var init_util = __esm({
@@ -4602,7 +4527,12 @@ var init_agent = __esm({
4602
4527
  // baris jejak & bisa menggerakkan sesi), dan SPEC-405 sudah membuktikan apa yang terjadi saat
4603
4528
  // endpoint tulis menumpang prefix status yang dipetakan tanpa melihat method (AC-5).
4604
4529
  "lead:read",
4605
- "lead:write"
4530
+ "lead:write",
4531
+ // SPEC-450 · ADR-0094 · custom agent. Domain TERSENDIRI, dipetakan MENURUT METHOD: menulis
4532
+ // definisi agen mengubah apa yang dilihat SETIAP sesi baru di seluruh workspace, jadi izin
4533
+ // baca tak pernah cukup untuk itu (kelas bug SPEC-405).
4534
+ "agents:read",
4535
+ "agents:write"
4606
4536
  ];
4607
4537
  zCapability = external_exports.enum(CAPABILITY_IDS);
4608
4538
  zCapabilityInfo = external_exports.object({
@@ -4636,6 +4566,70 @@ var init_agent = __esm({
4636
4566
  }
4637
4567
  });
4638
4568
 
4569
+ // ../shared/src/custom-agent.ts
4570
+ var AGENT_NAME_RE, zCustomAgent, zCreateCustomAgent, zUpdateCustomAgent;
4571
+ var init_custom_agent = __esm({
4572
+ "../shared/src/custom-agent.ts"() {
4573
+ "use strict";
4574
+ init_zod();
4575
+ AGENT_NAME_RE = /^[a-z][a-z0-9-]{1,39}$/;
4576
+ zCustomAgent = external_exports.object({
4577
+ id: external_exports.string(),
4578
+ projectId: external_exports.string().nullable(),
4579
+ name: external_exports.string().regex(AGENT_NAME_RE),
4580
+ description: external_exports.string(),
4581
+ instructions: external_exports.string(),
4582
+ tools: external_exports.array(external_exports.string()).nullable(),
4583
+ model: external_exports.string().nullable(),
4584
+ mentions: external_exports.array(external_exports.string()).nullable(),
4585
+ enabled: external_exports.boolean(),
4586
+ createdAt: external_exports.string(),
4587
+ updatedAt: external_exports.string()
4588
+ });
4589
+ zCreateCustomAgent = external_exports.object({
4590
+ projectId: external_exports.string().nullable().optional(),
4591
+ name: external_exports.string().regex(AGENT_NAME_RE),
4592
+ description: external_exports.string().trim().min(1).max(500),
4593
+ instructions: external_exports.string().trim().min(1).max(2e4),
4594
+ tools: external_exports.array(external_exports.string()).nullable().optional(),
4595
+ model: external_exports.string().nullable().optional(),
4596
+ mentions: external_exports.array(external_exports.string()).nullable().optional(),
4597
+ enabled: external_exports.boolean().optional()
4598
+ });
4599
+ zUpdateCustomAgent = zCreateCustomAgent.omit({ name: true, projectId: true }).partial();
4600
+ }
4601
+ });
4602
+
4603
+ // ../shared/src/github.ts
4604
+ var zGithubIssueStatus, zNormalIssue, zGithubIssueView;
4605
+ var init_github = __esm({
4606
+ "../shared/src/github.ts"() {
4607
+ "use strict";
4608
+ init_zod();
4609
+ zGithubIssueStatus = external_exports.enum(["new", "accepted", "rejected"]);
4610
+ zNormalIssue = external_exports.object({
4611
+ number: external_exports.number().int().positive(),
4612
+ title: external_exports.string(),
4613
+ body: external_exports.string(),
4614
+ authorLogin: external_exports.string(),
4615
+ labels: external_exports.array(external_exports.string()),
4616
+ url: external_exports.string(),
4617
+ issueState: external_exports.enum(["open", "closed"]),
4618
+ issueCreatedAt: external_exports.string(),
4619
+ // ISO-8601 apa adanya dari GitHub
4620
+ issueUpdatedAt: external_exports.string()
4621
+ });
4622
+ zGithubIssueView = zNormalIssue.extend({
4623
+ id: external_exports.string(),
4624
+ projectId: external_exports.string(),
4625
+ repoSlug: external_exports.string(),
4626
+ status: zGithubIssueStatus,
4627
+ specId: external_exports.string().nullable(),
4628
+ pulledAt: external_exports.string()
4629
+ });
4630
+ }
4631
+ });
4632
+
4639
4633
  // ../shared/src/lead.ts
4640
4634
  var zLeadGate, zLeadKind, zLeadConfidence, zLeadStatus, LEAD_ACTIONS, zLeadAction, zLeadVerdict, zLeadAsk, zLeadOverride;
4641
4635
  var init_lead = __esm({
@@ -5222,6 +5216,9 @@ var init_api = __esm({
5222
5216
  leadDecisions: `${API}/lead/decisions`,
5223
5217
  leadDecisionOverride: (id) => `${API}/lead/decisions/${encodeURIComponent(id)}/override`,
5224
5218
  leadDecisionCancel: (id) => `${API}/lead/decisions/${encodeURIComponent(id)}/cancel`,
5219
+ // SPEC-450 · ADR-0094 · katalog custom agent. `?projectId=` → himpunan EFEKTIF (global+project).
5220
+ customAgents: `${API}/custom-agents`,
5221
+ customAgent: (id) => `${API}/custom-agents/${encodeURIComponent(id)}`,
5225
5222
  // SPEC-268 · ADR-0066 · pemicu sync manual (cookie-authed)
5226
5223
  syncNow: `${API}/sync/now`,
5227
5224
  // SPEC-270 · ADR-0067 · antrean konflik rekonsil (cookie-authed)
@@ -5244,6 +5241,14 @@ var init_api = __esm({
5244
5241
  ticketUnlink: (id) => `${API}/tickets/${id}/unlink`,
5245
5242
  // SPEC-271 · lepas tautan backlog
5246
5243
  ticketReject: (id) => `${API}/tickets/${id}/reject`,
5244
+ // SPEC-471 · ADR-0095 · tarik & triase issue GitHub (di belakang gate cookie, capability `support`).
5245
+ // hanoman TIDAK PERNAH menulis ke GitHub — tak ada path komentar/close di sini, dan itu disengaja.
5246
+ githubPull: (id) => `${API}/projects/${encodeURIComponent(id)}/github/pull`,
5247
+ githubIssues: (id) => `${API}/projects/${encodeURIComponent(id)}/github/issues`,
5248
+ githubIssuesAccept: `${API}/github-issues/accept`,
5249
+ githubIssueAccept: (id) => `${API}/github-issues/${encodeURIComponent(id)}/accept`,
5250
+ githubIssueReject: (id) => `${API}/github-issues/${encodeURIComponent(id)}/reject`,
5251
+ githubIssueUnlink: (id) => `${API}/github-issues/${encodeURIComponent(id)}/unlink`,
5247
5252
  // SPEC-361 · ADR-0078 · unduh dokumen: query ditempelkan ke URL endpoint dokumen yang sudah ada
5248
5253
  // (tak ada endpoint ekspor terpisah). `base` bisa sudah membawa query, mis. ideFile(?path=…).
5249
5254
  download: (base, fmt) => `${base}${base.includes("?") ? "&" : "?"}download=${fmt}`
@@ -5406,6 +5411,28 @@ var init_config_registry = __esm({
5406
5411
  // vps
5407
5412
  { key: "HANOMAN_SSH_KEY_DIR", group: "vps", label: "Dir key SSH", kind: "path", apply: "new-session", category: "knob", help: "Default ~/.hanoman." },
5408
5413
  { key: "HANOMAN_SSH_BIN", group: "vps", label: "Biner ssh", kind: "path", apply: "new-session", category: "knob", default: "ssh" },
5414
+ // github (SPEC-471 · ADR-0095 · tarik issue → backlog). Dua mode auth, satu jalur kode:
5415
+ // `gh` memakai keyring mesin; bila GITHUB_TOKEN diisi ia diteruskan sebagai GH_TOKEN ke
5416
+ // proses gh DAN dipakai jalur REST (hub VPS yang tak punya keyring).
5417
+ {
5418
+ key: "GITHUB_TOKEN",
5419
+ group: "github",
5420
+ label: "GitHub token",
5421
+ kind: "secret",
5422
+ apply: "live",
5423
+ category: "credential",
5424
+ help: "PAT scope `repo` (atau `public_repo`). Kosong = andalkan `gh auth login` di mesin ini."
5425
+ },
5426
+ {
5427
+ key: "HANOMAN_GH_BIN",
5428
+ group: "github",
5429
+ label: "Biner gh",
5430
+ kind: "path",
5431
+ apply: "live",
5432
+ category: "knob",
5433
+ default: "gh",
5434
+ help: "Absen = tarik issue lewat HTTPS langsung ke api.github.com."
5435
+ },
5409
5436
  // runtime
5410
5437
  { key: "HANOMAN_EVENTS_TICK_MS", group: "runtime", label: "Interval events (ms)", kind: "int", apply: "live", category: "knob", default: "1000", min: 100 },
5411
5438
  { key: "HANOMAN_UPDATE_FETCH", group: "runtime", label: "Deteksi update saat boot", kind: "bool", apply: "live", category: "knob", default: "1" },
@@ -5491,12 +5518,14 @@ var init_semver = __esm({
5491
5518
  });
5492
5519
 
5493
5520
  // ../shared/src/index.ts
5494
- var init_src2 = __esm({
5521
+ var init_src = __esm({
5495
5522
  "../shared/src/index.ts"() {
5496
5523
  "use strict";
5497
5524
  init_enums();
5498
5525
  init_entities();
5499
5526
  init_agent();
5527
+ init_custom_agent();
5528
+ init_github();
5500
5529
  init_lead();
5501
5530
  init_dto();
5502
5531
  init_api();
@@ -5509,6 +5538,90 @@ var init_src2 = __esm({
5509
5538
  }
5510
5539
  });
5511
5540
 
5541
+ // ../runner/src/custom-agents.ts
5542
+ var init_custom_agents = __esm({
5543
+ "../runner/src/custom-agents.ts"() {
5544
+ "use strict";
5545
+ init_src();
5546
+ }
5547
+ });
5548
+
5549
+ // ../runner/src/paths.ts
5550
+ import { homedir } from "node:os";
5551
+ import { dirname, isAbsolute, join, resolve } from "node:path";
5552
+ function resolveHome(env = process.env, home = homedir()) {
5553
+ const v = env.HANOMAN_HOME?.trim();
5554
+ return v ? v : join(home, ".hanoman");
5555
+ }
5556
+ function schemeOf(raw) {
5557
+ return raw.split("://")[0] ?? "?";
5558
+ }
5559
+ function resolveDbUrl(env, schemaDir) {
5560
+ const own = env.HANOMAN_DATABASE_URL?.trim();
5561
+ if (own) {
5562
+ if (!own.startsWith("file:")) {
5563
+ throw new Error(
5564
+ `HANOMAN_DATABASE_URL harus URL SQLite \`file:\u2026\` sejak ADR-0086 (dapat \`${schemeOf(own)}\`). Masih punya data Postgres? Pindahkan sekali: hanoman migrate-from-postgres --from "<url-postgres>"`
5565
+ );
5566
+ }
5567
+ return absoluteFileUrl(own, schemaDir);
5568
+ }
5569
+ const raw = env.DATABASE_URL?.trim();
5570
+ if (!raw || !raw.startsWith("file:")) return `file:${join(resolveHome(env), "hanoman.db")}`;
5571
+ return absoluteFileUrl(raw, schemaDir);
5572
+ }
5573
+ function absoluteFileUrl(raw, schemaDir) {
5574
+ const p = raw.slice("file:".length);
5575
+ if (p.startsWith(":")) return raw;
5576
+ return `file:${isAbsolute(p) ? p : resolve(schemaDir, p)}`;
5577
+ }
5578
+ function dbUrlNotice(env) {
5579
+ if (env.HANOMAN_DATABASE_URL?.trim()) return null;
5580
+ const raw = env.DATABASE_URL?.trim();
5581
+ if (!raw || raw.startsWith("file:")) return null;
5582
+ return `hanoman: DATABASE_URL bertipe \`${schemeOf(raw)}\` DIABAIKAN \u2014 hanoman memakai SQLite (ADR-0086), dan var itu biasanya milik project lain.
5583
+ \u2022 Punya data Postgres hanoman? Pindahkan sekali: hanoman migrate-from-postgres --from "<url>"
5584
+ \u2022 Mau menunjuk berkas DB tertentu? Pakai HANOMAN_DATABASE_URL=file:/path/hanoman.db (atau --db)`;
5585
+ }
5586
+ function dbFilePath(url) {
5587
+ if (!url.startsWith("file:")) throw new Error(`bukan URL SQLite: ${url}`);
5588
+ return url.slice("file:".length);
5589
+ }
5590
+ function prismaCliPath(resolver) {
5591
+ for (const spec of ["prisma/build/index.js", "prisma/package.json"]) {
5592
+ try {
5593
+ const p = resolver(spec);
5594
+ return spec.endsWith("package.json") ? join(dirname(p), "build", "index.js") : p;
5595
+ } catch {
5596
+ }
5597
+ }
5598
+ throw new Error("CLI prisma tak ditemukan \u2014 `prisma` wajib terpasang sebagai dependency");
5599
+ }
5600
+ var init_paths = __esm({
5601
+ "../runner/src/paths.ts"() {
5602
+ "use strict";
5603
+ }
5604
+ });
5605
+
5606
+ // ../runner/src/index.ts
5607
+ var init_src2 = __esm({
5608
+ "../runner/src/index.ts"() {
5609
+ "use strict";
5610
+ init_types();
5611
+ init_prompt();
5612
+ init_reverse_standard();
5613
+ init_git();
5614
+ init_settings();
5615
+ init_goal();
5616
+ init_goal_spec();
5617
+ init_codex_settings();
5618
+ init_agent_cli();
5619
+ init_custom_agents();
5620
+ init_verify_scope();
5621
+ init_paths();
5622
+ }
5623
+ });
5624
+
5512
5625
  // src/layout.ts
5513
5626
  import { join as join2, resolve as resolve2 } from "node:path";
5514
5627
  function resolveLayout(distDir2, exists) {
@@ -5597,7 +5710,7 @@ var PKG, INSTALL_ARGS, DEFAULT_REGISTRY;
5597
5710
  var init_update = __esm({
5598
5711
  "src/commands/update.ts"() {
5599
5712
  "use strict";
5600
- init_src2();
5713
+ init_src();
5601
5714
  init_router();
5602
5715
  PKG = "hanoman";
5603
5716
  INSTALL_ARGS = ["i", "-g", `${PKG}@latest`];
@@ -5883,8 +5996,8 @@ var MAX_UPDATE_RESTARTS;
5883
5996
  var init_start = __esm({
5884
5997
  "src/commands/start.ts"() {
5885
5998
  "use strict";
5886
- init_src();
5887
5999
  init_src2();
6000
+ init_src();
5888
6001
  init_layout();
5889
6002
  init_update();
5890
6003
  MAX_UPDATE_RESTARTS = 5;
@@ -5908,6 +6021,12 @@ function doctorReport(p) {
5908
6021
  { mark: p.tmux ? "\u2713" : "\u2717", text: p.tmux ?? "tmux \u2014 TAK ADA (wajib: sesi agen hidup di tmux)", fatal: !p.tmux },
5909
6022
  { mark: p.claude ? "\u2713" : "\xB7", text: p.claude ? `claude ${p.claude}` : "claude \u2014 tak ada", fatal: false },
5910
6023
  { mark: p.codex ? "\u2713" : "\xB7", text: p.codex ? `codex ${p.codex}` : "codex \u2014 tak ada", fatal: false },
6024
+ // SPEC-471 · ADR-0095 · `gh` opsional: tanpa dia tarik issue jatuh ke HTTPS + GITHUB_TOKEN.
6025
+ {
6026
+ mark: p.gh ? "\u2713" : "\xB7",
6027
+ text: p.gh ? `gh ${p.gh}` : "gh \u2014 tak ada (tarik issue akan lewat HTTP + GITHUB_TOKEN)",
6028
+ fatal: false
6029
+ },
5911
6030
  { mark: p.homeWritable ? "\u2713" : "\u2717", text: `data dir ${p.homeWritable ? "bisa ditulis" : "TAK bisa ditulis"}`, fatal: !p.homeWritable },
5912
6031
  { mark: p.web ? "\u2713" : "!", text: p.web ? "aset dashboard ada" : "aset dashboard tak ada \u2014 API jalan, dashboard tidak", fatal: false },
5913
6032
  { mark: "\xB7", text: `db ${p.db}`, fatal: false }
@@ -5948,6 +6067,7 @@ async function doctor(_argv, ctx) {
5948
6067
  tmux: version("tmux", ["-V"]),
5949
6068
  claude: version(ctx.env.HANOMAN_CLAUDE_BIN ?? "claude", ["--version"]),
5950
6069
  codex: version(ctx.env.HANOMAN_CODEX_BIN ?? "codex", ["--version"]),
6070
+ gh: version(ctx.env.HANOMAN_GH_BIN ?? "gh", ["--version"]),
5951
6071
  homeWritable,
5952
6072
  web: layout.web !== null,
5953
6073
  db
@@ -5965,7 +6085,7 @@ ${notice}
5965
6085
  var init_doctor = __esm({
5966
6086
  "src/commands/doctor.ts"() {
5967
6087
  "use strict";
5968
- init_src();
6088
+ init_src2();
5969
6089
  init_layout();
5970
6090
  init_start();
5971
6091
  }
@@ -6124,12 +6244,14 @@ var PG_ORDER, CHUNK, INT8_OID, delegateKey;
6124
6244
  var init_migrate_pg = __esm({
6125
6245
  "src/commands/migrate-pg.ts"() {
6126
6246
  "use strict";
6127
- init_src();
6247
+ init_src2();
6128
6248
  init_layout();
6129
6249
  init_start();
6130
6250
  PG_ORDER = [
6251
+ // SPEC-450 · ADR-0094 · CustomAgent sesudah Project (FK projectId nullable → cascade).
6131
6252
  "Project",
6132
6253
  "Spec",
6254
+ "CustomAgent",
6133
6255
  "Setting",
6134
6256
  "Notification",
6135
6257
  "User",
@@ -6150,7 +6272,11 @@ var init_migrate_pg = __esm({
6150
6272
  "RuntimeConfig",
6151
6273
  "LeadDecision",
6152
6274
  "Ticket",
6153
- "TicketAttachment"
6275
+ "TicketAttachment",
6276
+ // SPEC-471 · ADR-0095 · GithubIssue sesudah Project (FK projectId) DAN sesudah Spec: `specId`
6277
+ // memang tanpa FK, tapi memindahkannya lebih awal membuat urutan tabel tak lagi mencerminkan
6278
+ // arah tautannya bagi pembaca berikutnya.
6279
+ "GithubIssue"
6154
6280
  ];
6155
6281
  CHUNK = 200;
6156
6282
  INT8_OID = 20;
@@ -6169,7 +6295,7 @@ function loadConfig(repoRoot) {
6169
6295
  var init_config2 = __esm({
6170
6296
  "src/config.ts"() {
6171
6297
  "use strict";
6172
- init_src2();
6298
+ init_src();
6173
6299
  }
6174
6300
  });
6175
6301
 
@@ -6264,7 +6390,7 @@ function scanCoverage(cwd) {
6264
6390
  var init_verify = __esm({
6265
6391
  "src/verify.ts"() {
6266
6392
  "use strict";
6267
- init_src2();
6393
+ init_src();
6268
6394
  init_repo();
6269
6395
  init_docs_model();
6270
6396
  }
@@ -6358,7 +6484,7 @@ async function docs_index_default(args, ctx) {
6358
6484
  var init_docs_index = __esm({
6359
6485
  "src/commands/docs-index.ts"() {
6360
6486
  "use strict";
6361
- init_src2();
6487
+ init_src();
6362
6488
  init_repo();
6363
6489
  init_docs_model();
6364
6490
  init_index_edit();