cnagent 2.1.16 → 2.1.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tools/dist/cn.js +157 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnagent",
3
- "version": "2.1.16",
3
+ "version": "2.1.18",
4
4
  "description": "Coherent Network agent CLI — everything runs through cn",
5
5
  "keywords": [
6
6
  "cn-agent",
package/tools/dist/cn.js CHANGED
@@ -12140,19 +12140,19 @@ var require_cn_lib = __commonJS({
12140
12140
  case /* Inbox */
12141
12141
  1:
12142
12142
  switch (t._0) {
12143
- case /* Inbox_check */
12143
+ case /* In_check */
12144
12144
  0:
12145
12145
  return "inbox check";
12146
- case /* Inbox_process */
12146
+ case /* In_process */
12147
12147
  1:
12148
12148
  return "inbox process";
12149
- case /* Inbox_flush */
12149
+ case /* In_flush */
12150
12150
  2:
12151
12151
  return "inbox flush";
12152
12152
  }
12153
12153
  case /* Outbox */
12154
12154
  2:
12155
- if (t._0 === /* Outbox_check */
12155
+ if (t._0 === /* Out_check */
12156
12156
  0) {
12157
12157
  return "outbox check";
12158
12158
  } else {
@@ -12165,13 +12165,13 @@ var require_cn_lib = __commonJS({
12165
12165
  /* tag */
12166
12166
  typeof n$1 === "number" || typeof n$1 === "string"
12167
12167
  ) {
12168
- if (n$1 === /* Peer_list */
12168
+ if (n$1 === /* P_list */
12169
12169
  0) {
12170
12170
  return "peer list";
12171
12171
  } else {
12172
12172
  return "peer sync";
12173
12173
  }
12174
- } else if (n$1.TAG === /* Peer_add */
12174
+ } else if (n$1.TAG === /* P_add */
12175
12175
  0) {
12176
12176
  return "peer add " + n$1._0;
12177
12177
  } else {
@@ -12179,7 +12179,7 @@ var require_cn_lib = __commonJS({
12179
12179
  }
12180
12180
  case /* Queue */
12181
12181
  4:
12182
- if (t._0 === /* Queue_list */
12182
+ if (t._0 === /* Q_list */
12183
12183
  0) {
12184
12184
  return "queue list";
12185
12185
  } else {
@@ -12209,19 +12209,19 @@ var require_cn_lib = __commonJS({
12209
12209
  9:
12210
12210
  const t$1 = t._0;
12211
12211
  switch (t$1.TAG) {
12212
- case /* GtdDelete */
12212
+ case /* G_delete */
12213
12213
  0:
12214
12214
  return "delete " + t$1._0;
12215
- case /* GtdDefer */
12215
+ case /* G_defer */
12216
12216
  1:
12217
12217
  return "defer " + t$1._0;
12218
- case /* GtdDelegate */
12218
+ case /* G_delegate */
12219
12219
  2:
12220
12220
  return "delegate " + (t$1._0 + (" " + t$1._1));
12221
- case /* GtdDo */
12221
+ case /* G_do */
12222
12222
  3:
12223
12223
  return "do " + t$1._0;
12224
- case /* GtdDone */
12224
+ case /* G_done */
12225
12225
  4:
12226
12226
  return "done " + t$1._0;
12227
12227
  }
@@ -12263,7 +12263,7 @@ var require_cn_lib = __commonJS({
12263
12263
  function parse_inbox_cmd(param) {
12264
12264
  if (!param) {
12265
12265
  return (
12266
- /* Inbox_check */
12266
+ /* In_check */
12267
12267
  0
12268
12268
  );
12269
12269
  }
@@ -12273,7 +12273,7 @@ var require_cn_lib = __commonJS({
12273
12273
  return;
12274
12274
  } else {
12275
12275
  return (
12276
- /* Inbox_check */
12276
+ /* In_check */
12277
12277
  0
12278
12278
  );
12279
12279
  }
@@ -12282,7 +12282,7 @@ var require_cn_lib = __commonJS({
12282
12282
  return;
12283
12283
  } else {
12284
12284
  return (
12285
- /* Inbox_flush */
12285
+ /* In_flush */
12286
12286
  2
12287
12287
  );
12288
12288
  }
@@ -12291,7 +12291,7 @@ var require_cn_lib = __commonJS({
12291
12291
  return;
12292
12292
  } else {
12293
12293
  return (
12294
- /* Inbox_process */
12294
+ /* In_process */
12295
12295
  1
12296
12296
  );
12297
12297
  }
@@ -12302,7 +12302,7 @@ var require_cn_lib = __commonJS({
12302
12302
  function parse_outbox_cmd(param) {
12303
12303
  if (!param) {
12304
12304
  return (
12305
- /* Outbox_check */
12305
+ /* Out_check */
12306
12306
  0
12307
12307
  );
12308
12308
  }
@@ -12312,7 +12312,7 @@ var require_cn_lib = __commonJS({
12312
12312
  return;
12313
12313
  } else {
12314
12314
  return (
12315
- /* Outbox_check */
12315
+ /* Out_check */
12316
12316
  0
12317
12317
  );
12318
12318
  }
@@ -12321,7 +12321,7 @@ var require_cn_lib = __commonJS({
12321
12321
  return;
12322
12322
  } else {
12323
12323
  return (
12324
- /* Outbox_flush */
12324
+ /* Out_flush */
12325
12325
  1
12326
12326
  );
12327
12327
  }
@@ -12332,7 +12332,7 @@ var require_cn_lib = __commonJS({
12332
12332
  function parse_peer_cmd(param) {
12333
12333
  if (!param) {
12334
12334
  return (
12335
- /* Peer_list */
12335
+ /* P_list */
12336
12336
  0
12337
12337
  );
12338
12338
  }
@@ -12346,7 +12346,7 @@ var require_cn_lib = __commonJS({
12346
12346
  if (match$1 && !match$1.tl) {
12347
12347
  return {
12348
12348
  TAG: (
12349
- /* Peer_add */
12349
+ /* P_add */
12350
12350
  0
12351
12351
  ),
12352
12352
  _0: match2.hd,
@@ -12360,7 +12360,7 @@ var require_cn_lib = __commonJS({
12360
12360
  return;
12361
12361
  } else {
12362
12362
  return (
12363
- /* Peer_list */
12363
+ /* P_list */
12364
12364
  0
12365
12365
  );
12366
12366
  }
@@ -12369,7 +12369,7 @@ var require_cn_lib = __commonJS({
12369
12369
  if (match$2 && !match$2.tl) {
12370
12370
  return {
12371
12371
  TAG: (
12372
- /* Peer_remove */
12372
+ /* P_remove */
12373
12373
  1
12374
12374
  ),
12375
12375
  _0: match$2.hd
@@ -12382,7 +12382,7 @@ var require_cn_lib = __commonJS({
12382
12382
  return;
12383
12383
  } else {
12384
12384
  return (
12385
- /* Peer_sync */
12385
+ /* P_sync */
12386
12386
  1
12387
12387
  );
12388
12388
  }
@@ -12393,7 +12393,7 @@ var require_cn_lib = __commonJS({
12393
12393
  function parse_queue_cmd(param) {
12394
12394
  if (!param) {
12395
12395
  return (
12396
- /* Queue_list */
12396
+ /* Q_list */
12397
12397
  0
12398
12398
  );
12399
12399
  }
@@ -12403,7 +12403,7 @@ var require_cn_lib = __commonJS({
12403
12403
  return;
12404
12404
  } else {
12405
12405
  return (
12406
- /* Queue_clear */
12406
+ /* Q_clear */
12407
12407
  1
12408
12408
  );
12409
12409
  }
@@ -12412,7 +12412,7 @@ var require_cn_lib = __commonJS({
12412
12412
  return;
12413
12413
  } else {
12414
12414
  return (
12415
- /* Queue_list */
12415
+ /* Q_list */
12416
12416
  0
12417
12417
  );
12418
12418
  }
@@ -12423,7 +12423,7 @@ var require_cn_lib = __commonJS({
12423
12423
  function parse_mca_cmd(param) {
12424
12424
  if (!param) {
12425
12425
  return (
12426
- /* Mca_list */
12426
+ /* M_list */
12427
12427
  0
12428
12428
  );
12429
12429
  }
@@ -12437,7 +12437,7 @@ var require_cn_lib = __commonJS({
12437
12437
  )) {
12438
12438
  return {
12439
12439
  TAG: (
12440
- /* Mca_add */
12440
+ /* M_add */
12441
12441
  0
12442
12442
  ),
12443
12443
  _0: Stdlib__String2.concat(" ", rest)
@@ -12450,7 +12450,7 @@ var require_cn_lib = __commonJS({
12450
12450
  return;
12451
12451
  } else {
12452
12452
  return (
12453
- /* Mca_list */
12453
+ /* M_list */
12454
12454
  0
12455
12455
  );
12456
12456
  }
@@ -12468,7 +12468,7 @@ var require_cn_lib = __commonJS({
12468
12468
  if (match2) {
12469
12469
  return {
12470
12470
  TAG: (
12471
- /* GtdDefer */
12471
+ /* G_defer */
12472
12472
  1
12473
12473
  ),
12474
12474
  _0: match2.hd,
@@ -12486,7 +12486,7 @@ var require_cn_lib = __commonJS({
12486
12486
  if (match$2 && !match$2.tl) {
12487
12487
  return {
12488
12488
  TAG: (
12489
- /* GtdDelegate */
12489
+ /* G_delegate */
12490
12490
  2
12491
12491
  ),
12492
12492
  _0: match$1.hd,
@@ -12500,7 +12500,7 @@ var require_cn_lib = __commonJS({
12500
12500
  if (match$3 && !match$3.tl) {
12501
12501
  return {
12502
12502
  TAG: (
12503
- /* GtdDelete */
12503
+ /* G_delete */
12504
12504
  0
12505
12505
  ),
12506
12506
  _0: match$3.hd
@@ -12513,7 +12513,7 @@ var require_cn_lib = __commonJS({
12513
12513
  if (match$4 && !match$4.tl) {
12514
12514
  return {
12515
12515
  TAG: (
12516
- /* GtdDo */
12516
+ /* G_do */
12517
12517
  3
12518
12518
  ),
12519
12519
  _0: match$4.hd
@@ -12526,7 +12526,7 @@ var require_cn_lib = __commonJS({
12526
12526
  if (match$5 && !match$5.tl) {
12527
12527
  return {
12528
12528
  TAG: (
12529
- /* GtdDone */
12529
+ /* G_done */
12530
12530
  4
12531
12531
  ),
12532
12532
  _0: match$5.hd
@@ -13260,7 +13260,7 @@ var require_cn_lib = __commonJS({
13260
13260
  );
13261
13261
  }
13262
13262
  var help_text = "cn - Coherent Network agent CLI\n\nUsage: cn <command> [options]\n\nCommands:\n # Agent decisions (output)\n delete <thread> GTD: discard\n defer <thread> GTD: postpone\n delegate <t> <peer> GTD: forward\n do <thread> GTD: claim/start\n done <thread> GTD: complete \xE2\x86\x92 archive\n reply <thread> <msg> Append to thread\n send <peer> <msg> Message to peer (or self)\n \n # cn operations (orchestrator)\n sync Fetch inbound + send outbound\n process Queue inbox \xE2\x86\x92 input.md \xE2\x86\x92 wake agent\n queue [list|clear] View or clear the task queue\n mca [list|add <desc>] Surface MCAs for community pickup\n inbox List inbox threads\n outbox List outbox threads\n next Get next inbox item (with cadence)\n read <thread> Read thread with cadence\n \n # Hub management\n init [name] Create new hub\n status Show hub state\n commit [msg] Stage + commit\n push Push to origin\n save [msg] Commit + push\n peer Manage peers\n doctor Health check\n update Update cn to latest version\n\nAliases:\n i = inbox, o = outbox, s = status, d = doctor\n\nFlags:\n --help, -h Show help\n --version, -V Show version\n --json Machine-readable output\n --quiet, -q Minimal output\n --dry-run Show what would happen\n\nActor Model:\n cn runs on cron (every 5 min). It:\n 1. Syncs peers \xE2\x86\x92 queues new inbox items to state/queue/\n 2. If input.md empty \xE2\x86\x92 pops from queue \xE2\x86\x92 writes input.md \xE2\x86\x92 wakes agent\n Agent reads input.md, processes, deletes when done.\n";
13263
- var version = "2.1.16";
13263
+ var version = "2.1.18";
13264
13264
  module2.exports = {
13265
13265
  starts_with,
13266
13266
  strip_prefix,
@@ -32450,6 +32450,107 @@ function queue_mca_review(hub_path) {
32450
32450
  }), Stdlib__List.length(mcas));
32451
32451
  console.log(color("32", "\xE2\x9C\x93 ") + msg);
32452
32452
  }
32453
+ function auto_save(hub_path, name) {
32454
+ const status = exec_in(hub_path, "git status --porcelain");
32455
+ if (status === void 0) {
32456
+ return;
32457
+ }
32458
+ if (Stdlib__String.trim(status) === "") {
32459
+ return;
32460
+ }
32461
+ exec_in(hub_path, "git add -A");
32462
+ const msg = Curry._2(Stdlib__Printf.sprintf({
32463
+ TAG: (
32464
+ /* Format */
32465
+ 0
32466
+ ),
32467
+ _0: {
32468
+ TAG: (
32469
+ /* String */
32470
+ 2
32471
+ ),
32472
+ _0: (
32473
+ /* No_padding */
32474
+ 0
32475
+ ),
32476
+ _1: {
32477
+ TAG: (
32478
+ /* String_literal */
32479
+ 11
32480
+ ),
32481
+ _0: ": auto-save ",
32482
+ _1: {
32483
+ TAG: (
32484
+ /* String */
32485
+ 2
32486
+ ),
32487
+ _0: (
32488
+ /* No_padding */
32489
+ 0
32490
+ ),
32491
+ _1: (
32492
+ /* End_of_format */
32493
+ 0
32494
+ )
32495
+ }
32496
+ }
32497
+ },
32498
+ _1: "%s: auto-save %s"
32499
+ }), name, Stdlib__String.sub((/* @__PURE__ */ new Date()).toISOString(), 0, 10));
32500
+ const match2 = exec_in(hub_path, Curry._1(Stdlib__Printf.sprintf({
32501
+ TAG: (
32502
+ /* Format */
32503
+ 0
32504
+ ),
32505
+ _0: {
32506
+ TAG: (
32507
+ /* String_literal */
32508
+ 11
32509
+ ),
32510
+ _0: 'git commit -m "',
32511
+ _1: {
32512
+ TAG: (
32513
+ /* String */
32514
+ 2
32515
+ ),
32516
+ _0: (
32517
+ /* No_padding */
32518
+ 0
32519
+ ),
32520
+ _1: {
32521
+ TAG: (
32522
+ /* Char_literal */
32523
+ 12
32524
+ ),
32525
+ _0: (
32526
+ /* '"' */
32527
+ 34
32528
+ ),
32529
+ _1: (
32530
+ /* End_of_format */
32531
+ 0
32532
+ )
32533
+ }
32534
+ }
32535
+ },
32536
+ _1: 'git commit -m "%s"'
32537
+ }), msg));
32538
+ if (match2 !== void 0) {
32539
+ log_action(hub_path, "auto-save.commit", msg);
32540
+ console.log(color("32", "\xE2\x9C\x93 ") + "Auto-committed changes");
32541
+ const match$1 = exec_in(hub_path, "git push");
32542
+ if (match$1 !== void 0) {
32543
+ log_action(hub_path, "auto-save.push", "success");
32544
+ console.log(color("32", "\xE2\x9C\x93 ") + "Auto-pushed to origin");
32545
+ } else {
32546
+ log_action(hub_path, "auto-save.push", "failed");
32547
+ console.log(color("33", "\xE2\x9A\xA0 ") + "Auto-push failed");
32548
+ }
32549
+ return;
32550
+ }
32551
+ log_action(hub_path, "auto-save.commit", "failed");
32552
+ console.log(color("33", "\xE2\x9A\xA0 ") + "Auto-commit failed");
32553
+ }
32453
32554
  function run_process(hub_path, name) {
32454
32555
  console.log(color("36", "cn process: actor loop..."));
32455
32556
  const queued = queue_inbox_items(hub_path);
@@ -32505,8 +32606,13 @@ function run_process(hub_path, name) {
32505
32606
  const inp = Path.join(hub_path, "state/input.md");
32506
32607
  const outp = Path.join(hub_path, "state/output.md");
32507
32608
  if (Fs.existsSync(inp) && Fs.existsSync(outp)) {
32508
- if (archive_io_pair(hub_path, name) && feed_next_input(hub_path)) {
32509
- return wake_agent(void 0);
32609
+ if (archive_io_pair(hub_path, name)) {
32610
+ auto_save(hub_path, name);
32611
+ if (feed_next_input(hub_path)) {
32612
+ return wake_agent(void 0);
32613
+ } else {
32614
+ return;
32615
+ }
32510
32616
  } else {
32511
32617
  return;
32512
32618
  }
@@ -34268,15 +34374,15 @@ if (cmd !== void 0) {
34268
34374
  case /* Inbox */
34269
34375
  1:
34270
34376
  switch (cmd._0) {
34271
- case /* Inbox_check */
34377
+ case /* In_check */
34272
34378
  0:
34273
34379
  inbox_check(hub_path$1, name);
34274
34380
  break;
34275
- case /* Inbox_process */
34381
+ case /* In_process */
34276
34382
  1:
34277
34383
  inbox_process(hub_path$1);
34278
34384
  break;
34279
- case /* Inbox_flush */
34385
+ case /* In_flush */
34280
34386
  2:
34281
34387
  inbox_flush(hub_path$1, name);
34282
34388
  break;
@@ -34284,7 +34390,7 @@ if (cmd !== void 0) {
34284
34390
  break;
34285
34391
  case /* Outbox */
34286
34392
  2:
34287
- if (cmd._0 === /* Outbox_check */
34393
+ if (cmd._0 === /* Out_check */
34288
34394
  0) {
34289
34395
  outbox_check(hub_path$1);
34290
34396
  } else {
@@ -34298,13 +34404,13 @@ if (cmd !== void 0) {
34298
34404
  /* tag */
34299
34405
  typeof n === "number" || typeof n === "string"
34300
34406
  ) {
34301
- if (n === /* Peer_list */
34407
+ if (n === /* P_list */
34302
34408
  0) {
34303
34409
  run_peer_list(hub_path$1);
34304
34410
  } else {
34305
34411
  run_peer_sync(hub_path$1);
34306
34412
  }
34307
- } else if (n.TAG === /* Peer_add */
34413
+ } else if (n.TAG === /* P_add */
34308
34414
  0) {
34309
34415
  run_peer_add(hub_path$1, n._0, n._1);
34310
34416
  } else {
@@ -34313,7 +34419,7 @@ if (cmd !== void 0) {
34313
34419
  break;
34314
34420
  case /* Queue */
34315
34421
  4:
34316
- if (cmd._0 === /* Queue_list */
34422
+ if (cmd._0 === /* Q_list */
34317
34423
  0) {
34318
34424
  run_queue_list(hub_path$1);
34319
34425
  } else {
@@ -34348,23 +34454,23 @@ if (cmd !== void 0) {
34348
34454
  9:
34349
34455
  const t = cmd._0;
34350
34456
  switch (t.TAG) {
34351
- case /* GtdDelete */
34457
+ case /* G_delete */
34352
34458
  0:
34353
34459
  gtd_delete(hub_path$1, t._0);
34354
34460
  break;
34355
- case /* GtdDefer */
34461
+ case /* G_defer */
34356
34462
  1:
34357
34463
  gtd_defer(hub_path$1, t._0, t._1);
34358
34464
  break;
34359
- case /* GtdDelegate */
34465
+ case /* G_delegate */
34360
34466
  2:
34361
34467
  gtd_delegate(hub_path$1, name, t._0, t._1);
34362
34468
  break;
34363
- case /* GtdDo */
34469
+ case /* G_do */
34364
34470
  3:
34365
34471
  gtd_do(hub_path$1, t._0);
34366
34472
  break;
34367
- case /* GtdDone */
34473
+ case /* G_done */
34368
34474
  4:
34369
34475
  gtd_done(hub_path$1, t._0);
34370
34476
  break;
@@ -34501,6 +34607,7 @@ module.exports = {
34501
34607
  increment_mca_cycle,
34502
34608
  mca_count,
34503
34609
  queue_mca_review,
34610
+ auto_save,
34504
34611
  run_process,
34505
34612
  update_runtime,
34506
34613
  run_init,