cnagent 2.1.18 → 2.1.22

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 +1262 -119
package/tools/dist/cn.js CHANGED
@@ -11879,6 +11879,7 @@ var require_cn_lib = __commonJS({
11879
11879
  "_build/default/tools/src/cn/output/tools/src/cn/cn_lib.js"(exports2, module2) {
11880
11880
  "use strict";
11881
11881
  var Caml_obj = require_caml_obj();
11882
+ var Caml_option2 = require_caml_option();
11882
11883
  var Stdlib__List2 = require_list();
11883
11884
  var Stdlib__Option2 = require_option();
11884
11885
  var Stdlib__String2 = require_string();
@@ -11908,6 +11909,13 @@ var require_cn_lib = __commonJS({
11908
11909
  function non_empty(s) {
11909
11910
  return Stdlib__String2.trim(s) !== "";
11910
11911
  }
11912
+ var Inbox = {};
11913
+ var Outbox = {};
11914
+ var Peer = {};
11915
+ var Queue = {};
11916
+ var Mca = {};
11917
+ var Gtd = {};
11918
+ var Out = {};
11911
11919
  function string_of_agent_op(id) {
11912
11920
  switch (id.TAG) {
11913
11921
  case /* Ack */
@@ -12140,19 +12148,19 @@ var require_cn_lib = __commonJS({
12140
12148
  case /* Inbox */
12141
12149
  1:
12142
12150
  switch (t._0) {
12143
- case /* In_check */
12151
+ case /* Check */
12144
12152
  0:
12145
12153
  return "inbox check";
12146
- case /* In_process */
12154
+ case /* Process */
12147
12155
  1:
12148
12156
  return "inbox process";
12149
- case /* In_flush */
12157
+ case /* Flush */
12150
12158
  2:
12151
12159
  return "inbox flush";
12152
12160
  }
12153
12161
  case /* Outbox */
12154
12162
  2:
12155
- if (t._0 === /* Out_check */
12163
+ if (t._0 === /* Check */
12156
12164
  0) {
12157
12165
  return "outbox check";
12158
12166
  } else {
@@ -12165,13 +12173,13 @@ var require_cn_lib = __commonJS({
12165
12173
  /* tag */
12166
12174
  typeof n$1 === "number" || typeof n$1 === "string"
12167
12175
  ) {
12168
- if (n$1 === /* P_list */
12176
+ if (n$1 === /* List */
12169
12177
  0) {
12170
12178
  return "peer list";
12171
12179
  } else {
12172
12180
  return "peer sync";
12173
12181
  }
12174
- } else if (n$1.TAG === /* P_add */
12182
+ } else if (n$1.TAG === /* Add */
12175
12183
  0) {
12176
12184
  return "peer add " + n$1._0;
12177
12185
  } else {
@@ -12179,7 +12187,7 @@ var require_cn_lib = __commonJS({
12179
12187
  }
12180
12188
  case /* Queue */
12181
12189
  4:
12182
- if (t._0 === /* Q_list */
12190
+ if (t._0 === /* List */
12183
12191
  0) {
12184
12192
  return "queue list";
12185
12193
  } else {
@@ -12209,24 +12217,58 @@ var require_cn_lib = __commonJS({
12209
12217
  9:
12210
12218
  const t$1 = t._0;
12211
12219
  switch (t$1.TAG) {
12212
- case /* G_delete */
12220
+ case /* Delete */
12213
12221
  0:
12214
12222
  return "delete " + t$1._0;
12215
- case /* G_defer */
12223
+ case /* Defer */
12216
12224
  1:
12217
12225
  return "defer " + t$1._0;
12218
- case /* G_delegate */
12226
+ case /* Delegate */
12219
12227
  2:
12220
12228
  return "delegate " + (t$1._0 + (" " + t$1._1));
12221
- case /* G_do */
12229
+ case /* Do */
12222
12230
  3:
12223
12231
  return "do " + t$1._0;
12224
- case /* G_done */
12232
+ case /* Done */
12225
12233
  4:
12226
12234
  return "done " + t$1._0;
12227
12235
  }
12228
- case /* Commit */
12236
+ case /* Out */
12229
12237
  10:
12238
+ const match2 = t._0;
12239
+ switch (match2.TAG) {
12240
+ case /* Do */
12241
+ 0:
12242
+ const match$1 = match2._0;
12243
+ switch (match$1.TAG) {
12244
+ case /* Reply */
12245
+ 0:
12246
+ return "out do reply";
12247
+ case /* Send */
12248
+ 1:
12249
+ return "out do send " + match$1.to_;
12250
+ case /* Surface */
12251
+ 2:
12252
+ return "out do surface";
12253
+ case /* Noop */
12254
+ 3:
12255
+ return "out do noop";
12256
+ case /* Commit */
12257
+ 4:
12258
+ return "out do commit " + match$1.artifact;
12259
+ }
12260
+ case /* Defer */
12261
+ 1:
12262
+ return "out defer";
12263
+ case /* Delegate */
12264
+ 2:
12265
+ return "out delegate " + match2.to_;
12266
+ case /* Delete */
12267
+ 3:
12268
+ return "out delete";
12269
+ }
12270
+ case /* Commit */
12271
+ 11:
12230
12272
  const m = t._0;
12231
12273
  if (m !== void 0) {
12232
12274
  return "commit " + m;
@@ -12234,7 +12276,7 @@ var require_cn_lib = __commonJS({
12234
12276
  return "commit";
12235
12277
  }
12236
12278
  case /* Save */
12237
- 11:
12279
+ 12:
12238
12280
  const m$1 = t._0;
12239
12281
  if (m$1 !== void 0) {
12240
12282
  return "save " + m$1;
@@ -12263,7 +12305,7 @@ var require_cn_lib = __commonJS({
12263
12305
  function parse_inbox_cmd(param) {
12264
12306
  if (!param) {
12265
12307
  return (
12266
- /* In_check */
12308
+ /* Check */
12267
12309
  0
12268
12310
  );
12269
12311
  }
@@ -12273,7 +12315,7 @@ var require_cn_lib = __commonJS({
12273
12315
  return;
12274
12316
  } else {
12275
12317
  return (
12276
- /* In_check */
12318
+ /* Check */
12277
12319
  0
12278
12320
  );
12279
12321
  }
@@ -12282,7 +12324,7 @@ var require_cn_lib = __commonJS({
12282
12324
  return;
12283
12325
  } else {
12284
12326
  return (
12285
- /* In_flush */
12327
+ /* Flush */
12286
12328
  2
12287
12329
  );
12288
12330
  }
@@ -12291,7 +12333,7 @@ var require_cn_lib = __commonJS({
12291
12333
  return;
12292
12334
  } else {
12293
12335
  return (
12294
- /* In_process */
12336
+ /* Process */
12295
12337
  1
12296
12338
  );
12297
12339
  }
@@ -12302,7 +12344,7 @@ var require_cn_lib = __commonJS({
12302
12344
  function parse_outbox_cmd(param) {
12303
12345
  if (!param) {
12304
12346
  return (
12305
- /* Out_check */
12347
+ /* Check */
12306
12348
  0
12307
12349
  );
12308
12350
  }
@@ -12312,7 +12354,7 @@ var require_cn_lib = __commonJS({
12312
12354
  return;
12313
12355
  } else {
12314
12356
  return (
12315
- /* Out_check */
12357
+ /* Check */
12316
12358
  0
12317
12359
  );
12318
12360
  }
@@ -12321,7 +12363,7 @@ var require_cn_lib = __commonJS({
12321
12363
  return;
12322
12364
  } else {
12323
12365
  return (
12324
- /* Out_flush */
12366
+ /* Flush */
12325
12367
  1
12326
12368
  );
12327
12369
  }
@@ -12332,7 +12374,7 @@ var require_cn_lib = __commonJS({
12332
12374
  function parse_peer_cmd(param) {
12333
12375
  if (!param) {
12334
12376
  return (
12335
- /* P_list */
12377
+ /* List */
12336
12378
  0
12337
12379
  );
12338
12380
  }
@@ -12346,7 +12388,7 @@ var require_cn_lib = __commonJS({
12346
12388
  if (match$1 && !match$1.tl) {
12347
12389
  return {
12348
12390
  TAG: (
12349
- /* P_add */
12391
+ /* Add */
12350
12392
  0
12351
12393
  ),
12352
12394
  _0: match2.hd,
@@ -12360,7 +12402,7 @@ var require_cn_lib = __commonJS({
12360
12402
  return;
12361
12403
  } else {
12362
12404
  return (
12363
- /* P_list */
12405
+ /* List */
12364
12406
  0
12365
12407
  );
12366
12408
  }
@@ -12369,7 +12411,7 @@ var require_cn_lib = __commonJS({
12369
12411
  if (match$2 && !match$2.tl) {
12370
12412
  return {
12371
12413
  TAG: (
12372
- /* P_remove */
12414
+ /* Remove */
12373
12415
  1
12374
12416
  ),
12375
12417
  _0: match$2.hd
@@ -12382,7 +12424,7 @@ var require_cn_lib = __commonJS({
12382
12424
  return;
12383
12425
  } else {
12384
12426
  return (
12385
- /* P_sync */
12427
+ /* Sync */
12386
12428
  1
12387
12429
  );
12388
12430
  }
@@ -12393,7 +12435,7 @@ var require_cn_lib = __commonJS({
12393
12435
  function parse_queue_cmd(param) {
12394
12436
  if (!param) {
12395
12437
  return (
12396
- /* Q_list */
12438
+ /* List */
12397
12439
  0
12398
12440
  );
12399
12441
  }
@@ -12403,7 +12445,7 @@ var require_cn_lib = __commonJS({
12403
12445
  return;
12404
12446
  } else {
12405
12447
  return (
12406
- /* Q_clear */
12448
+ /* Clear */
12407
12449
  1
12408
12450
  );
12409
12451
  }
@@ -12412,7 +12454,7 @@ var require_cn_lib = __commonJS({
12412
12454
  return;
12413
12455
  } else {
12414
12456
  return (
12415
- /* Q_list */
12457
+ /* List */
12416
12458
  0
12417
12459
  );
12418
12460
  }
@@ -12423,7 +12465,7 @@ var require_cn_lib = __commonJS({
12423
12465
  function parse_mca_cmd(param) {
12424
12466
  if (!param) {
12425
12467
  return (
12426
- /* M_list */
12468
+ /* List */
12427
12469
  0
12428
12470
  );
12429
12471
  }
@@ -12437,7 +12479,7 @@ var require_cn_lib = __commonJS({
12437
12479
  )) {
12438
12480
  return {
12439
12481
  TAG: (
12440
- /* M_add */
12482
+ /* Add */
12441
12483
  0
12442
12484
  ),
12443
12485
  _0: Stdlib__String2.concat(" ", rest)
@@ -12450,7 +12492,7 @@ var require_cn_lib = __commonJS({
12450
12492
  return;
12451
12493
  } else {
12452
12494
  return (
12453
- /* M_list */
12495
+ /* List */
12454
12496
  0
12455
12497
  );
12456
12498
  }
@@ -12468,7 +12510,7 @@ var require_cn_lib = __commonJS({
12468
12510
  if (match2) {
12469
12511
  return {
12470
12512
  TAG: (
12471
- /* G_defer */
12513
+ /* Defer */
12472
12514
  1
12473
12515
  ),
12474
12516
  _0: match2.hd,
@@ -12486,7 +12528,7 @@ var require_cn_lib = __commonJS({
12486
12528
  if (match$2 && !match$2.tl) {
12487
12529
  return {
12488
12530
  TAG: (
12489
- /* G_delegate */
12531
+ /* Delegate */
12490
12532
  2
12491
12533
  ),
12492
12534
  _0: match$1.hd,
@@ -12500,7 +12542,7 @@ var require_cn_lib = __commonJS({
12500
12542
  if (match$3 && !match$3.tl) {
12501
12543
  return {
12502
12544
  TAG: (
12503
- /* G_delete */
12545
+ /* Delete */
12504
12546
  0
12505
12547
  ),
12506
12548
  _0: match$3.hd
@@ -12513,7 +12555,7 @@ var require_cn_lib = __commonJS({
12513
12555
  if (match$4 && !match$4.tl) {
12514
12556
  return {
12515
12557
  TAG: (
12516
- /* G_do */
12558
+ /* Do */
12517
12559
  3
12518
12560
  ),
12519
12561
  _0: match$4.hd
@@ -12526,7 +12568,7 @@ var require_cn_lib = __commonJS({
12526
12568
  if (match$5 && !match$5.tl) {
12527
12569
  return {
12528
12570
  TAG: (
12529
- /* G_done */
12571
+ /* Done */
12530
12572
  4
12531
12573
  ),
12532
12574
  _0: match$5.hd
@@ -12538,6 +12580,287 @@ var require_cn_lib = __commonJS({
12538
12580
  return;
12539
12581
  }
12540
12582
  }
12583
+ function parse_flags_from_args(_acc, _param) {
12584
+ while (true) {
12585
+ const param = _param;
12586
+ const acc = _acc;
12587
+ if (!param) {
12588
+ return acc;
12589
+ }
12590
+ switch (param.hd) {
12591
+ case "--artifact":
12592
+ const match2 = param.tl;
12593
+ if (match2) {
12594
+ _param = match2.tl;
12595
+ _acc = {
12596
+ hd: [
12597
+ "artifact",
12598
+ match2.hd
12599
+ ],
12600
+ tl: acc
12601
+ };
12602
+ continue;
12603
+ }
12604
+ _param = param.tl;
12605
+ continue;
12606
+ case "--desc":
12607
+ const match$1 = param.tl;
12608
+ if (match$1) {
12609
+ _param = match$1.tl;
12610
+ _acc = {
12611
+ hd: [
12612
+ "desc",
12613
+ match$1.hd
12614
+ ],
12615
+ tl: acc
12616
+ };
12617
+ continue;
12618
+ }
12619
+ _param = param.tl;
12620
+ continue;
12621
+ case "--id":
12622
+ const match$2 = param.tl;
12623
+ if (match$2) {
12624
+ _param = match$2.tl;
12625
+ _acc = {
12626
+ hd: [
12627
+ "id",
12628
+ match$2.hd
12629
+ ],
12630
+ tl: acc
12631
+ };
12632
+ continue;
12633
+ }
12634
+ _param = param.tl;
12635
+ continue;
12636
+ case "--message":
12637
+ const match$3 = param.tl;
12638
+ if (match$3) {
12639
+ _param = match$3.tl;
12640
+ _acc = {
12641
+ hd: [
12642
+ "message",
12643
+ match$3.hd
12644
+ ],
12645
+ tl: acc
12646
+ };
12647
+ continue;
12648
+ }
12649
+ _param = param.tl;
12650
+ continue;
12651
+ case "--reason":
12652
+ const match$4 = param.tl;
12653
+ if (match$4) {
12654
+ _param = match$4.tl;
12655
+ _acc = {
12656
+ hd: [
12657
+ "reason",
12658
+ match$4.hd
12659
+ ],
12660
+ tl: acc
12661
+ };
12662
+ continue;
12663
+ }
12664
+ _param = param.tl;
12665
+ continue;
12666
+ case "--to":
12667
+ const match$5 = param.tl;
12668
+ if (match$5) {
12669
+ _param = match$5.tl;
12670
+ _acc = {
12671
+ hd: [
12672
+ "to",
12673
+ match$5.hd
12674
+ ],
12675
+ tl: acc
12676
+ };
12677
+ continue;
12678
+ }
12679
+ _param = param.tl;
12680
+ continue;
12681
+ default:
12682
+ _param = param.tl;
12683
+ continue;
12684
+ }
12685
+ }
12686
+ ;
12687
+ }
12688
+ function get_flag(key, flags) {
12689
+ return Stdlib__List2.find_map((function(param) {
12690
+ if (Caml_obj.caml_equal(param[0], key)) {
12691
+ return Caml_option2.some(param[1]);
12692
+ }
12693
+ }), flags);
12694
+ }
12695
+ function parse_out_cmd(args2) {
12696
+ const flags = parse_flags_from_args(
12697
+ /* [] */
12698
+ 0,
12699
+ args2
12700
+ );
12701
+ if (!args2) {
12702
+ return;
12703
+ }
12704
+ switch (args2.hd) {
12705
+ case "defer":
12706
+ return Stdlib__Option2.map((function(r) {
12707
+ return {
12708
+ TAG: (
12709
+ /* Defer */
12710
+ 1
12711
+ ),
12712
+ reason: r
12713
+ };
12714
+ }), get_flag("reason", flags));
12715
+ case "delegate":
12716
+ return Stdlib__Option2.map((function(t) {
12717
+ return {
12718
+ TAG: (
12719
+ /* Delegate */
12720
+ 2
12721
+ ),
12722
+ to_: t
12723
+ };
12724
+ }), get_flag("to", flags));
12725
+ case "delete":
12726
+ return Stdlib__Option2.map((function(r) {
12727
+ return {
12728
+ TAG: (
12729
+ /* Delete */
12730
+ 3
12731
+ ),
12732
+ reason: r
12733
+ };
12734
+ }), get_flag("reason", flags));
12735
+ case "do":
12736
+ const match2 = args2.tl;
12737
+ if (!match2) {
12738
+ return;
12739
+ }
12740
+ switch (match2.hd) {
12741
+ case "commit":
12742
+ return Stdlib__Option2.map((function(a) {
12743
+ return {
12744
+ TAG: (
12745
+ /* Do */
12746
+ 0
12747
+ ),
12748
+ _0: {
12749
+ TAG: (
12750
+ /* Commit */
12751
+ 4
12752
+ ),
12753
+ artifact: a
12754
+ }
12755
+ };
12756
+ }), get_flag("artifact", flags));
12757
+ case "noop":
12758
+ const r = get_flag("reason", flags);
12759
+ if (r === void 0) {
12760
+ return;
12761
+ }
12762
+ const r_lower = Stdlib__String2.lowercase_ascii(r);
12763
+ if (Stdlib__List2.mem(r_lower, {
12764
+ hd: "ack",
12765
+ tl: {
12766
+ hd: "ok",
12767
+ tl: {
12768
+ hd: "done",
12769
+ tl: {
12770
+ hd: "yes",
12771
+ tl: {
12772
+ hd: "no",
12773
+ tl: {
12774
+ hd: "acknowledged",
12775
+ tl: {
12776
+ hd: "noted",
12777
+ tl: (
12778
+ /* [] */
12779
+ 0
12780
+ )
12781
+ }
12782
+ }
12783
+ }
12784
+ }
12785
+ }
12786
+ }
12787
+ }) || r.length < 10) {
12788
+ return;
12789
+ } else {
12790
+ return {
12791
+ TAG: (
12792
+ /* Do */
12793
+ 0
12794
+ ),
12795
+ _0: {
12796
+ TAG: (
12797
+ /* Noop */
12798
+ 3
12799
+ ),
12800
+ reason: r
12801
+ }
12802
+ };
12803
+ }
12804
+ case "reply":
12805
+ return Stdlib__Option2.map((function(m) {
12806
+ return {
12807
+ TAG: (
12808
+ /* Do */
12809
+ 0
12810
+ ),
12811
+ _0: {
12812
+ TAG: (
12813
+ /* Reply */
12814
+ 0
12815
+ ),
12816
+ message: m
12817
+ }
12818
+ };
12819
+ }), get_flag("message", flags));
12820
+ case "send":
12821
+ const match$1 = get_flag("to", flags);
12822
+ const match$2 = get_flag("message", flags);
12823
+ if (match$1 !== void 0 && match$2 !== void 0) {
12824
+ return {
12825
+ TAG: (
12826
+ /* Do */
12827
+ 0
12828
+ ),
12829
+ _0: {
12830
+ TAG: (
12831
+ /* Send */
12832
+ 1
12833
+ ),
12834
+ to_: match$1,
12835
+ message: match$2
12836
+ }
12837
+ };
12838
+ } else {
12839
+ return;
12840
+ }
12841
+ case "surface":
12842
+ return Stdlib__Option2.map((function(d) {
12843
+ return {
12844
+ TAG: (
12845
+ /* Do */
12846
+ 0
12847
+ ),
12848
+ _0: {
12849
+ TAG: (
12850
+ /* Surface */
12851
+ 2
12852
+ ),
12853
+ desc: d
12854
+ }
12855
+ };
12856
+ }), get_flag("desc", flags));
12857
+ default:
12858
+ return;
12859
+ }
12860
+ default:
12861
+ return;
12862
+ }
12863
+ }
12541
12864
  function join_rest(rest) {
12542
12865
  if (rest) {
12543
12866
  return Stdlib__String2.concat(" ", rest);
@@ -12569,7 +12892,7 @@ var require_cn_lib = __commonJS({
12569
12892
  return {
12570
12893
  TAG: (
12571
12894
  /* Commit */
12572
- 10
12895
+ 11
12573
12896
  ),
12574
12897
  _0: join_rest(param.tl)
12575
12898
  };
@@ -12704,6 +13027,16 @@ var require_cn_lib = __commonJS({
12704
13027
  5
12705
13028
  );
12706
13029
  }
13030
+ case "out":
13031
+ return Stdlib__Option2.map((function(c) {
13032
+ return {
13033
+ TAG: (
13034
+ /* Out */
13035
+ 10
13036
+ ),
13037
+ _0: c
13038
+ };
13039
+ }), parse_out_cmd(param.tl));
12707
13040
  case "outbox":
12708
13041
  return Stdlib__Option2.map((function(c) {
12709
13042
  return {
@@ -12787,7 +13120,7 @@ var require_cn_lib = __commonJS({
12787
13120
  return {
12788
13121
  TAG: (
12789
13122
  /* Save */
12790
- 11
13123
+ 12
12791
13124
  ),
12792
13125
  _0: join_rest(param.tl)
12793
13126
  };
@@ -13260,12 +13593,19 @@ var require_cn_lib = __commonJS({
13260
13593
  );
13261
13594
  }
13262
13595
  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.18";
13596
+ var version = "2.1.21";
13264
13597
  module2.exports = {
13265
13598
  starts_with,
13266
13599
  strip_prefix,
13267
13600
  ends_with,
13268
13601
  non_empty,
13602
+ Inbox,
13603
+ Outbox,
13604
+ Peer,
13605
+ Queue,
13606
+ Mca,
13607
+ Gtd,
13608
+ Out,
13269
13609
  string_of_agent_op,
13270
13610
  parse_agent_op,
13271
13611
  extract_ops,
@@ -13277,6 +13617,9 @@ var require_cn_lib = __commonJS({
13277
13617
  parse_queue_cmd,
13278
13618
  parse_mca_cmd,
13279
13619
  parse_gtd_cmd,
13620
+ parse_flags_from_args,
13621
+ get_flag,
13622
+ parse_out_cmd,
13280
13623
  join_rest,
13281
13624
  parse_command,
13282
13625
  default_flags,
@@ -26510,7 +26853,8 @@ function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
26510
26853
  _1: "%s-%s.md"
26511
26854
  }), peer_name, branch_slug);
26512
26855
  const inbox_path = Path.join(inbox_dir, inbox_file);
26513
- if (Fs.existsSync(inbox_path)) {
26856
+ const archived_path = Path.join(Path.join(inbox_dir, "_archived"), inbox_file);
26857
+ if (Fs.existsSync(inbox_path) || Fs.existsSync(archived_path)) {
26514
26858
  return;
26515
26859
  }
26516
26860
  const meta_0 = [
@@ -32142,69 +32486,843 @@ function run_mca_list(hub_path) {
32142
32486
  }
32143
32487
  console.log("(no MCAs)");
32144
32488
  }
32145
- function mca_cycle_path(hub_path) {
32146
- return Path.join(hub_path, "state/.mca-cycle");
32147
- }
32148
- function get_mca_cycle(hub_path) {
32149
- const path = Path.join(hub_path, "state/.mca-cycle");
32150
- if (Fs.existsSync(path)) {
32151
- return Stdlib__Option.value(Stdlib.int_of_string_opt(Stdlib__String.trim(Fs.readFileSync(path, "utf8"))), 0);
32152
- } else {
32153
- return 0;
32154
- }
32155
- }
32156
- function increment_mca_cycle(hub_path) {
32157
- const current = get_mca_cycle(hub_path);
32158
- const next = current + 1 | 0;
32159
- const prim1 = String(next);
32160
- const prim0 = Path.join(hub_path, "state/.mca-cycle");
32161
- Fs.writeFileSync(prim0, prim1);
32162
- return next;
32163
- }
32164
- function mca_count(hub_path) {
32165
- const dir = Path.join(hub_path, "state/mca");
32166
- if (Fs.existsSync(dir)) {
32167
- return Stdlib__List.length(Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir))));
32168
- } else {
32169
- return 0;
32170
- }
32171
- }
32172
- function queue_mca_review(hub_path) {
32173
- const dir = Path.join(hub_path, "state/mca");
32174
- const mcas = Stdlib__List.sort(Stdlib__String.compare, Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir))));
32175
- const mca_list = Stdlib__String.concat("\n", Stdlib__List.map((function(file) {
32176
- const content = Fs.readFileSync(Path.join(dir, file), "utf8");
32177
- const meta = Cn_lib.parse_frontmatter(content);
32178
- const id = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
32179
- if (param[0] === "id") {
32180
- return param[1];
32181
- }
32182
- }), meta), "?");
32183
- const by = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
32184
- if (param[0] === "surfaced-by") {
32185
- return param[1];
32186
- }
32187
- }), meta), "?");
32188
- const lines = Stdlib__String.split_on_char(
32189
- /* '\n' */
32190
- 10,
32191
- content
32192
- );
32193
- const skip_fm = function(_in_fm, _rest) {
32194
- while (true) {
32195
- const rest = _rest;
32196
- const in_fm = _in_fm;
32197
- if (!rest) {
32198
- return (
32199
- /* [] */
32200
- 0
32201
- );
32202
- }
32203
- if (rest.hd === "---") {
32204
- const rest$1 = rest.tl;
32205
- if (in_fm) {
32206
- if (in_fm) {
32207
- return rest$1;
32489
+ function run_out(hub_path, name, gtd) {
32490
+ const inp = Path.join(hub_path, "state/input.md");
32491
+ const input_meta = Fs.existsSync(inp) ? Cn_lib.parse_frontmatter(Fs.readFileSync(inp, "utf8")) : void 0;
32492
+ const input_id = input_meta !== void 0 ? Stdlib__List.find_map((function(param) {
32493
+ if (param[0] === "id") {
32494
+ return param[1];
32495
+ }
32496
+ }), input_meta) : void 0;
32497
+ const input_from = input_meta !== void 0 ? Stdlib__List.find_map((function(param) {
32498
+ if (param[0] === "from") {
32499
+ return param[1];
32500
+ }
32501
+ }), input_meta) : void 0;
32502
+ const outp = Path.join(hub_path, "state/output.md");
32503
+ const id = Stdlib__Option.value(input_id, "unknown");
32504
+ let match2;
32505
+ switch (gtd.TAG) {
32506
+ case /* Do */
32507
+ 0:
32508
+ const match$1 = gtd._0;
32509
+ switch (match$1.TAG) {
32510
+ case /* Reply */
32511
+ 0:
32512
+ match2 = [
32513
+ "do",
32514
+ Curry._1(Stdlib__Printf.sprintf({
32515
+ TAG: (
32516
+ /* Format */
32517
+ 0
32518
+ ),
32519
+ _0: {
32520
+ TAG: (
32521
+ /* String_literal */
32522
+ 11
32523
+ ),
32524
+ _0: "reply: ",
32525
+ _1: {
32526
+ TAG: (
32527
+ /* String */
32528
+ 2
32529
+ ),
32530
+ _0: (
32531
+ /* No_padding */
32532
+ 0
32533
+ ),
32534
+ _1: (
32535
+ /* End_of_format */
32536
+ 0
32537
+ )
32538
+ }
32539
+ },
32540
+ _1: "reply: %s"
32541
+ }), match$1.message)
32542
+ ];
32543
+ break;
32544
+ case /* Send */
32545
+ 1:
32546
+ match2 = [
32547
+ "do",
32548
+ Curry._2(Stdlib__Printf.sprintf({
32549
+ TAG: (
32550
+ /* Format */
32551
+ 0
32552
+ ),
32553
+ _0: {
32554
+ TAG: (
32555
+ /* String_literal */
32556
+ 11
32557
+ ),
32558
+ _0: "send: ",
32559
+ _1: {
32560
+ TAG: (
32561
+ /* String */
32562
+ 2
32563
+ ),
32564
+ _0: (
32565
+ /* No_padding */
32566
+ 0
32567
+ ),
32568
+ _1: {
32569
+ TAG: (
32570
+ /* Char_literal */
32571
+ 12
32572
+ ),
32573
+ _0: (
32574
+ /* '|' */
32575
+ 124
32576
+ ),
32577
+ _1: {
32578
+ TAG: (
32579
+ /* String */
32580
+ 2
32581
+ ),
32582
+ _0: (
32583
+ /* No_padding */
32584
+ 0
32585
+ ),
32586
+ _1: (
32587
+ /* End_of_format */
32588
+ 0
32589
+ )
32590
+ }
32591
+ }
32592
+ }
32593
+ },
32594
+ _1: "send: %s|%s"
32595
+ }), match$1.to_, match$1.message)
32596
+ ];
32597
+ break;
32598
+ case /* Surface */
32599
+ 2:
32600
+ match2 = [
32601
+ "do",
32602
+ Curry._1(Stdlib__Printf.sprintf({
32603
+ TAG: (
32604
+ /* Format */
32605
+ 0
32606
+ ),
32607
+ _0: {
32608
+ TAG: (
32609
+ /* String_literal */
32610
+ 11
32611
+ ),
32612
+ _0: "surface: ",
32613
+ _1: {
32614
+ TAG: (
32615
+ /* String */
32616
+ 2
32617
+ ),
32618
+ _0: (
32619
+ /* No_padding */
32620
+ 0
32621
+ ),
32622
+ _1: (
32623
+ /* End_of_format */
32624
+ 0
32625
+ )
32626
+ }
32627
+ },
32628
+ _1: "surface: %s"
32629
+ }), match$1.desc)
32630
+ ];
32631
+ break;
32632
+ case /* Noop */
32633
+ 3:
32634
+ match2 = [
32635
+ "do",
32636
+ Curry._1(Stdlib__Printf.sprintf({
32637
+ TAG: (
32638
+ /* Format */
32639
+ 0
32640
+ ),
32641
+ _0: {
32642
+ TAG: (
32643
+ /* String_literal */
32644
+ 11
32645
+ ),
32646
+ _0: "noop: ",
32647
+ _1: {
32648
+ TAG: (
32649
+ /* String */
32650
+ 2
32651
+ ),
32652
+ _0: (
32653
+ /* No_padding */
32654
+ 0
32655
+ ),
32656
+ _1: (
32657
+ /* End_of_format */
32658
+ 0
32659
+ )
32660
+ }
32661
+ },
32662
+ _1: "noop: %s"
32663
+ }), match$1.reason)
32664
+ ];
32665
+ break;
32666
+ case /* Commit */
32667
+ 4:
32668
+ match2 = [
32669
+ "do",
32670
+ Curry._1(Stdlib__Printf.sprintf({
32671
+ TAG: (
32672
+ /* Format */
32673
+ 0
32674
+ ),
32675
+ _0: {
32676
+ TAG: (
32677
+ /* String_literal */
32678
+ 11
32679
+ ),
32680
+ _0: "commit: ",
32681
+ _1: {
32682
+ TAG: (
32683
+ /* String */
32684
+ 2
32685
+ ),
32686
+ _0: (
32687
+ /* No_padding */
32688
+ 0
32689
+ ),
32690
+ _1: (
32691
+ /* End_of_format */
32692
+ 0
32693
+ )
32694
+ }
32695
+ },
32696
+ _1: "commit: %s"
32697
+ }), match$1.artifact)
32698
+ ];
32699
+ break;
32700
+ }
32701
+ break;
32702
+ case /* Defer */
32703
+ 1:
32704
+ match2 = [
32705
+ "defer",
32706
+ Curry._1(Stdlib__Printf.sprintf({
32707
+ TAG: (
32708
+ /* Format */
32709
+ 0
32710
+ ),
32711
+ _0: {
32712
+ TAG: (
32713
+ /* String_literal */
32714
+ 11
32715
+ ),
32716
+ _0: "reason: ",
32717
+ _1: {
32718
+ TAG: (
32719
+ /* String */
32720
+ 2
32721
+ ),
32722
+ _0: (
32723
+ /* No_padding */
32724
+ 0
32725
+ ),
32726
+ _1: (
32727
+ /* End_of_format */
32728
+ 0
32729
+ )
32730
+ }
32731
+ },
32732
+ _1: "reason: %s"
32733
+ }), gtd.reason)
32734
+ ];
32735
+ break;
32736
+ case /* Delegate */
32737
+ 2:
32738
+ match2 = [
32739
+ "delegate",
32740
+ Curry._1(Stdlib__Printf.sprintf({
32741
+ TAG: (
32742
+ /* Format */
32743
+ 0
32744
+ ),
32745
+ _0: {
32746
+ TAG: (
32747
+ /* String_literal */
32748
+ 11
32749
+ ),
32750
+ _0: "to: ",
32751
+ _1: {
32752
+ TAG: (
32753
+ /* String */
32754
+ 2
32755
+ ),
32756
+ _0: (
32757
+ /* No_padding */
32758
+ 0
32759
+ ),
32760
+ _1: (
32761
+ /* End_of_format */
32762
+ 0
32763
+ )
32764
+ }
32765
+ },
32766
+ _1: "to: %s"
32767
+ }), gtd.to_)
32768
+ ];
32769
+ break;
32770
+ case /* Delete */
32771
+ 3:
32772
+ match2 = [
32773
+ "delete",
32774
+ Curry._1(Stdlib__Printf.sprintf({
32775
+ TAG: (
32776
+ /* Format */
32777
+ 0
32778
+ ),
32779
+ _0: {
32780
+ TAG: (
32781
+ /* String_literal */
32782
+ 11
32783
+ ),
32784
+ _0: "reason: ",
32785
+ _1: {
32786
+ TAG: (
32787
+ /* String */
32788
+ 2
32789
+ ),
32790
+ _0: (
32791
+ /* No_padding */
32792
+ 0
32793
+ ),
32794
+ _1: (
32795
+ /* End_of_format */
32796
+ 0
32797
+ )
32798
+ }
32799
+ },
32800
+ _1: "reason: %s"
32801
+ }), gtd.reason)
32802
+ ];
32803
+ break;
32804
+ }
32805
+ const gtd_type = match2[0];
32806
+ const content = Curry._4(Stdlib__Printf.sprintf({
32807
+ TAG: (
32808
+ /* Format */
32809
+ 0
32810
+ ),
32811
+ _0: {
32812
+ TAG: (
32813
+ /* String_literal */
32814
+ 11
32815
+ ),
32816
+ _0: "---\nid: ",
32817
+ _1: {
32818
+ TAG: (
32819
+ /* String */
32820
+ 2
32821
+ ),
32822
+ _0: (
32823
+ /* No_padding */
32824
+ 0
32825
+ ),
32826
+ _1: {
32827
+ TAG: (
32828
+ /* String_literal */
32829
+ 11
32830
+ ),
32831
+ _0: "\ngtd: ",
32832
+ _1: {
32833
+ TAG: (
32834
+ /* String */
32835
+ 2
32836
+ ),
32837
+ _0: (
32838
+ /* No_padding */
32839
+ 0
32840
+ ),
32841
+ _1: {
32842
+ TAG: (
32843
+ /* Char_literal */
32844
+ 12
32845
+ ),
32846
+ _0: (
32847
+ /* '\n' */
32848
+ 10
32849
+ ),
32850
+ _1: {
32851
+ TAG: (
32852
+ /* String */
32853
+ 2
32854
+ ),
32855
+ _0: (
32856
+ /* No_padding */
32857
+ 0
32858
+ ),
32859
+ _1: {
32860
+ TAG: (
32861
+ /* String_literal */
32862
+ 11
32863
+ ),
32864
+ _0: "\ncreated: ",
32865
+ _1: {
32866
+ TAG: (
32867
+ /* String */
32868
+ 2
32869
+ ),
32870
+ _0: (
32871
+ /* No_padding */
32872
+ 0
32873
+ ),
32874
+ _1: {
32875
+ TAG: (
32876
+ /* String_literal */
32877
+ 11
32878
+ ),
32879
+ _0: "\n---\n",
32880
+ _1: (
32881
+ /* End_of_format */
32882
+ 0
32883
+ )
32884
+ }
32885
+ }
32886
+ }
32887
+ }
32888
+ }
32889
+ }
32890
+ }
32891
+ }
32892
+ },
32893
+ _1: "---\nid: %s\ngtd: %s\n%s\ncreated: %s\n---\n"
32894
+ }), id, gtd_type, match2[1], (/* @__PURE__ */ new Date()).toISOString());
32895
+ Fs.writeFileSync(outp, content);
32896
+ log_action(hub_path, "out", Curry._2(Stdlib__Printf.sprintf({
32897
+ TAG: (
32898
+ /* Format */
32899
+ 0
32900
+ ),
32901
+ _0: {
32902
+ TAG: (
32903
+ /* String_literal */
32904
+ 11
32905
+ ),
32906
+ _0: "id:",
32907
+ _1: {
32908
+ TAG: (
32909
+ /* String */
32910
+ 2
32911
+ ),
32912
+ _0: (
32913
+ /* No_padding */
32914
+ 0
32915
+ ),
32916
+ _1: {
32917
+ TAG: (
32918
+ /* String_literal */
32919
+ 11
32920
+ ),
32921
+ _0: " gtd:",
32922
+ _1: {
32923
+ TAG: (
32924
+ /* String */
32925
+ 2
32926
+ ),
32927
+ _0: (
32928
+ /* No_padding */
32929
+ 0
32930
+ ),
32931
+ _1: (
32932
+ /* End_of_format */
32933
+ 0
32934
+ )
32935
+ }
32936
+ }
32937
+ }
32938
+ },
32939
+ _1: "id:%s gtd:%s"
32940
+ }), id, gtd_type));
32941
+ const msg = Curry._2(Stdlib__Printf.sprintf({
32942
+ TAG: (
32943
+ /* Format */
32944
+ 0
32945
+ ),
32946
+ _0: {
32947
+ TAG: (
32948
+ /* String_literal */
32949
+ 11
32950
+ ),
32951
+ _0: "Output: ",
32952
+ _1: {
32953
+ TAG: (
32954
+ /* String */
32955
+ 2
32956
+ ),
32957
+ _0: (
32958
+ /* No_padding */
32959
+ 0
32960
+ ),
32961
+ _1: {
32962
+ TAG: (
32963
+ /* String_literal */
32964
+ 11
32965
+ ),
32966
+ _0: " (",
32967
+ _1: {
32968
+ TAG: (
32969
+ /* String */
32970
+ 2
32971
+ ),
32972
+ _0: (
32973
+ /* No_padding */
32974
+ 0
32975
+ ),
32976
+ _1: {
32977
+ TAG: (
32978
+ /* Char_literal */
32979
+ 12
32980
+ ),
32981
+ _0: (
32982
+ /* ')' */
32983
+ 41
32984
+ ),
32985
+ _1: (
32986
+ /* End_of_format */
32987
+ 0
32988
+ )
32989
+ }
32990
+ }
32991
+ }
32992
+ }
32993
+ },
32994
+ _1: "Output: %s (%s)"
32995
+ }), gtd_type, id);
32996
+ console.log(color("32", "\xE2\x9C\x93 ") + msg);
32997
+ if (input_from === void 0) {
32998
+ return;
32999
+ }
33000
+ if (!(input_from !== name && input_from !== "system")) {
33001
+ return;
33002
+ }
33003
+ const notify_msg = Curry._3(Stdlib__Printf.sprintf({
33004
+ TAG: (
33005
+ /* Format */
33006
+ 0
33007
+ ),
33008
+ _0: {
33009
+ TAG: (
33010
+ /* String_literal */
33011
+ 11
33012
+ ),
33013
+ _0: "[auto] ",
33014
+ _1: {
33015
+ TAG: (
33016
+ /* String */
33017
+ 2
33018
+ ),
33019
+ _0: (
33020
+ /* No_padding */
33021
+ 0
33022
+ ),
33023
+ _1: {
33024
+ TAG: (
33025
+ /* String_literal */
33026
+ 11
33027
+ ),
33028
+ _0: ": ",
33029
+ _1: {
33030
+ TAG: (
33031
+ /* String */
33032
+ 2
33033
+ ),
33034
+ _0: (
33035
+ /* No_padding */
33036
+ 0
33037
+ ),
33038
+ _1: {
33039
+ TAG: (
33040
+ /* String_literal */
33041
+ 11
33042
+ ),
33043
+ _0: " on ",
33044
+ _1: {
33045
+ TAG: (
33046
+ /* String */
33047
+ 2
33048
+ ),
33049
+ _0: (
33050
+ /* No_padding */
33051
+ 0
33052
+ ),
33053
+ _1: (
33054
+ /* End_of_format */
33055
+ 0
33056
+ )
33057
+ }
33058
+ }
33059
+ }
33060
+ }
33061
+ }
33062
+ },
33063
+ _1: "[auto] %s: %s on %s"
33064
+ }), name, gtd_type, id);
33065
+ const outbox_dir = Path.join(hub_path, "threads/outbox");
33066
+ ensure_dir(outbox_dir);
33067
+ const notify_file = Curry._2(Stdlib__Printf.sprintf({
33068
+ TAG: (
33069
+ /* Format */
33070
+ 0
33071
+ ),
33072
+ _0: {
33073
+ TAG: (
33074
+ /* String */
33075
+ 2
33076
+ ),
33077
+ _0: (
33078
+ /* No_padding */
33079
+ 0
33080
+ ),
33081
+ _1: {
33082
+ TAG: (
33083
+ /* String_literal */
33084
+ 11
33085
+ ),
33086
+ _0: "-auto-notify-",
33087
+ _1: {
33088
+ TAG: (
33089
+ /* String */
33090
+ 2
33091
+ ),
33092
+ _0: (
33093
+ /* No_padding */
33094
+ 0
33095
+ ),
33096
+ _1: {
33097
+ TAG: (
33098
+ /* String_literal */
33099
+ 11
33100
+ ),
33101
+ _0: ".md",
33102
+ _1: (
33103
+ /* End_of_format */
33104
+ 0
33105
+ )
33106
+ }
33107
+ }
33108
+ }
33109
+ },
33110
+ _1: "%s-auto-notify-%s.md"
33111
+ }), input_from, id);
33112
+ const notify_content = Curry._3(Stdlib__Printf.sprintf({
33113
+ TAG: (
33114
+ /* Format */
33115
+ 0
33116
+ ),
33117
+ _0: {
33118
+ TAG: (
33119
+ /* String_literal */
33120
+ 11
33121
+ ),
33122
+ _0: "---\nto: ",
33123
+ _1: {
33124
+ TAG: (
33125
+ /* String */
33126
+ 2
33127
+ ),
33128
+ _0: (
33129
+ /* No_padding */
33130
+ 0
33131
+ ),
33132
+ _1: {
33133
+ TAG: (
33134
+ /* String_literal */
33135
+ 11
33136
+ ),
33137
+ _0: "\ncreated: ",
33138
+ _1: {
33139
+ TAG: (
33140
+ /* String */
33141
+ 2
33142
+ ),
33143
+ _0: (
33144
+ /* No_padding */
33145
+ 0
33146
+ ),
33147
+ _1: {
33148
+ TAG: (
33149
+ /* String_literal */
33150
+ 11
33151
+ ),
33152
+ _0: "\nauto: true\n---\n\n",
33153
+ _1: {
33154
+ TAG: (
33155
+ /* String */
33156
+ 2
33157
+ ),
33158
+ _0: (
33159
+ /* No_padding */
33160
+ 0
33161
+ ),
33162
+ _1: {
33163
+ TAG: (
33164
+ /* Char_literal */
33165
+ 12
33166
+ ),
33167
+ _0: (
33168
+ /* '\n' */
33169
+ 10
33170
+ ),
33171
+ _1: (
33172
+ /* End_of_format */
33173
+ 0
33174
+ )
33175
+ }
33176
+ }
33177
+ }
33178
+ }
33179
+ }
33180
+ }
33181
+ },
33182
+ _1: "---\nto: %s\ncreated: %s\nauto: true\n---\n\n%s\n"
33183
+ }), input_from, (/* @__PURE__ */ new Date()).toISOString(), notify_msg);
33184
+ const prim0 = Path.join(outbox_dir, notify_file);
33185
+ Fs.writeFileSync(prim0, notify_content);
33186
+ log_action(hub_path, "out.notify", Curry._2(Stdlib__Printf.sprintf({
33187
+ TAG: (
33188
+ /* Format */
33189
+ 0
33190
+ ),
33191
+ _0: {
33192
+ TAG: (
33193
+ /* String_literal */
33194
+ 11
33195
+ ),
33196
+ _0: "to:",
33197
+ _1: {
33198
+ TAG: (
33199
+ /* String */
33200
+ 2
33201
+ ),
33202
+ _0: (
33203
+ /* No_padding */
33204
+ 0
33205
+ ),
33206
+ _1: {
33207
+ TAG: (
33208
+ /* String_literal */
33209
+ 11
33210
+ ),
33211
+ _0: " id:",
33212
+ _1: {
33213
+ TAG: (
33214
+ /* String */
33215
+ 2
33216
+ ),
33217
+ _0: (
33218
+ /* No_padding */
33219
+ 0
33220
+ ),
33221
+ _1: (
33222
+ /* End_of_format */
33223
+ 0
33224
+ )
33225
+ }
33226
+ }
33227
+ }
33228
+ },
33229
+ _1: "to:%s id:%s"
33230
+ }), input_from, id));
33231
+ const msg$1 = Curry._1(Stdlib__Printf.sprintf({
33232
+ TAG: (
33233
+ /* Format */
33234
+ 0
33235
+ ),
33236
+ _0: {
33237
+ TAG: (
33238
+ /* String_literal */
33239
+ 11
33240
+ ),
33241
+ _0: "Notified ",
33242
+ _1: {
33243
+ TAG: (
33244
+ /* String */
33245
+ 2
33246
+ ),
33247
+ _0: (
33248
+ /* No_padding */
33249
+ 0
33250
+ ),
33251
+ _1: (
33252
+ /* End_of_format */
33253
+ 0
33254
+ )
33255
+ }
33256
+ },
33257
+ _1: "Notified %s"
33258
+ }), input_from);
33259
+ console.log(color("32", "\xE2\x9C\x93 ") + msg$1);
33260
+ exec_in(hub_path, "git add -A && git commit -m '[auto] notify' && git push");
33261
+ console.log(color("32", "\xE2\x9C\x93 ") + "Pushed notification");
33262
+ }
33263
+ function mca_cycle_path(hub_path) {
33264
+ return Path.join(hub_path, "state/.mca-cycle");
33265
+ }
33266
+ function get_mca_cycle(hub_path) {
33267
+ const path = Path.join(hub_path, "state/.mca-cycle");
33268
+ if (Fs.existsSync(path)) {
33269
+ return Stdlib__Option.value(Stdlib.int_of_string_opt(Stdlib__String.trim(Fs.readFileSync(path, "utf8"))), 0);
33270
+ } else {
33271
+ return 0;
33272
+ }
33273
+ }
33274
+ function increment_mca_cycle(hub_path) {
33275
+ const current = get_mca_cycle(hub_path);
33276
+ const next = current + 1 | 0;
33277
+ const prim1 = String(next);
33278
+ const prim0 = Path.join(hub_path, "state/.mca-cycle");
33279
+ Fs.writeFileSync(prim0, prim1);
33280
+ return next;
33281
+ }
33282
+ function mca_count(hub_path) {
33283
+ const dir = Path.join(hub_path, "state/mca");
33284
+ if (Fs.existsSync(dir)) {
33285
+ return Stdlib__List.length(Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir))));
33286
+ } else {
33287
+ return 0;
33288
+ }
33289
+ }
33290
+ function queue_mca_review(hub_path) {
33291
+ const dir = Path.join(hub_path, "state/mca");
33292
+ const mcas = Stdlib__List.sort(Stdlib__String.compare, Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir))));
33293
+ const mca_list = Stdlib__String.concat("\n", Stdlib__List.map((function(file) {
33294
+ const content = Fs.readFileSync(Path.join(dir, file), "utf8");
33295
+ const meta = Cn_lib.parse_frontmatter(content);
33296
+ const id = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
33297
+ if (param[0] === "id") {
33298
+ return param[1];
33299
+ }
33300
+ }), meta), "?");
33301
+ const by = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
33302
+ if (param[0] === "surfaced-by") {
33303
+ return param[1];
33304
+ }
33305
+ }), meta), "?");
33306
+ const lines = Stdlib__String.split_on_char(
33307
+ /* '\n' */
33308
+ 10,
33309
+ content
33310
+ );
33311
+ const skip_fm = function(_in_fm, _rest) {
33312
+ while (true) {
33313
+ const rest = _rest;
33314
+ const in_fm = _in_fm;
33315
+ if (!rest) {
33316
+ return (
33317
+ /* [] */
33318
+ 0
33319
+ );
33320
+ }
33321
+ if (rest.hd === "---") {
33322
+ const rest$1 = rest.tl;
33323
+ if (in_fm) {
33324
+ if (in_fm) {
33325
+ return rest$1;
32208
33326
  }
32209
33327
  } else {
32210
33328
  _rest = rest$1;
@@ -33100,6 +34218,7 @@ function run_init(name) {
33100
34218
  const prim0$3 = Path.join(hub_dir, "state/peers.md");
33101
34219
  Fs.writeFileSync(prim0$3, peers);
33102
34220
  exec_in(hub_dir, "git init");
34221
+ update_runtime(hub_dir);
33103
34222
  exec_in(hub_dir, "git add -A");
33104
34223
  exec_in(hub_dir, Curry._1(Stdlib__Printf.sprintf({
33105
34224
  TAG: (
@@ -33136,7 +34255,6 @@ function run_init(name) {
33136
34255
  },
33137
34256
  _1: "git commit -m 'Initialize %s hub'"
33138
34257
  }), hub_name));
33139
- update_runtime(hub_dir);
33140
34258
  const msg$1 = Curry._1(Stdlib__Printf.sprintf({
33141
34259
  TAG: (
33142
34260
  /* Format */
@@ -34239,6 +35357,26 @@ function run_update_with_cron(hub_path) {
34239
35357
  run_update(void 0);
34240
35358
  update_cron(hub_path);
34241
35359
  update_runtime(hub_path);
35360
+ console.log(color("36", "Auto-committing runtime changes..."));
35361
+ exec_in(hub_path, "git add state/runtime.md");
35362
+ const commit_result = exec_in(hub_path, "git commit -m 'chore: cn update runtime'");
35363
+ if (commit_result !== void 0) {
35364
+ console.log(color("32", "\xE2\x9C\x93 ") + "Committed runtime changes");
35365
+ const match2 = exec_in(hub_path, "git remote get-url origin 2>/dev/null");
35366
+ if (match2 !== void 0) {
35367
+ console.log(color("36", "Pushing to origin..."));
35368
+ const match$1 = exec_in(hub_path, "git push origin HEAD 2>&1");
35369
+ if (match$1 !== void 0) {
35370
+ console.log(color("32", "\xE2\x9C\x93 ") + "Pushed to origin");
35371
+ } else {
35372
+ console.log(color("33", "\xE2\x9A\xA0 ") + "Push failed - push manually");
35373
+ }
35374
+ return;
35375
+ }
35376
+ console.log(color("2", "No origin remote - skipping push"));
35377
+ return;
35378
+ }
35379
+ console.log(color("2", "No runtime changes to commit"));
34242
35380
  }
34243
35381
  function drop(n, lst) {
34244
35382
  let _n = n;
@@ -34374,15 +35512,15 @@ if (cmd !== void 0) {
34374
35512
  case /* Inbox */
34375
35513
  1:
34376
35514
  switch (cmd._0) {
34377
- case /* In_check */
35515
+ case /* Check */
34378
35516
  0:
34379
35517
  inbox_check(hub_path$1, name);
34380
35518
  break;
34381
- case /* In_process */
35519
+ case /* Process */
34382
35520
  1:
34383
35521
  inbox_process(hub_path$1);
34384
35522
  break;
34385
- case /* In_flush */
35523
+ case /* Flush */
34386
35524
  2:
34387
35525
  inbox_flush(hub_path$1, name);
34388
35526
  break;
@@ -34390,7 +35528,7 @@ if (cmd !== void 0) {
34390
35528
  break;
34391
35529
  case /* Outbox */
34392
35530
  2:
34393
- if (cmd._0 === /* Out_check */
35531
+ if (cmd._0 === /* Check */
34394
35532
  0) {
34395
35533
  outbox_check(hub_path$1);
34396
35534
  } else {
@@ -34404,13 +35542,13 @@ if (cmd !== void 0) {
34404
35542
  /* tag */
34405
35543
  typeof n === "number" || typeof n === "string"
34406
35544
  ) {
34407
- if (n === /* P_list */
35545
+ if (n === /* List */
34408
35546
  0) {
34409
35547
  run_peer_list(hub_path$1);
34410
35548
  } else {
34411
35549
  run_peer_sync(hub_path$1);
34412
35550
  }
34413
- } else if (n.TAG === /* P_add */
35551
+ } else if (n.TAG === /* Add */
34414
35552
  0) {
34415
35553
  run_peer_add(hub_path$1, n._0, n._1);
34416
35554
  } else {
@@ -34419,7 +35557,7 @@ if (cmd !== void 0) {
34419
35557
  break;
34420
35558
  case /* Queue */
34421
35559
  4:
34422
- if (cmd._0 === /* Q_list */
35560
+ if (cmd._0 === /* List */
34423
35561
  0) {
34424
35562
  run_queue_list(hub_path$1);
34425
35563
  } else {
@@ -34454,34 +35592,38 @@ if (cmd !== void 0) {
34454
35592
  9:
34455
35593
  const t = cmd._0;
34456
35594
  switch (t.TAG) {
34457
- case /* G_delete */
35595
+ case /* Delete */
34458
35596
  0:
34459
35597
  gtd_delete(hub_path$1, t._0);
34460
35598
  break;
34461
- case /* G_defer */
35599
+ case /* Defer */
34462
35600
  1:
34463
35601
  gtd_defer(hub_path$1, t._0, t._1);
34464
35602
  break;
34465
- case /* G_delegate */
35603
+ case /* Delegate */
34466
35604
  2:
34467
35605
  gtd_delegate(hub_path$1, name, t._0, t._1);
34468
35606
  break;
34469
- case /* G_do */
35607
+ case /* Do */
34470
35608
  3:
34471
35609
  gtd_do(hub_path$1, t._0);
34472
35610
  break;
34473
- case /* G_done */
35611
+ case /* Done */
34474
35612
  4:
34475
35613
  gtd_done(hub_path$1, t._0);
34476
35614
  break;
34477
35615
  }
34478
35616
  break;
34479
- case /* Commit */
35617
+ case /* Out */
34480
35618
  10:
35619
+ run_out(hub_path$1, name, cmd._0);
35620
+ break;
35621
+ case /* Commit */
35622
+ 11:
34481
35623
  run_commit(hub_path$1, name, cmd._0);
34482
35624
  break;
34483
35625
  case /* Save */
34484
- 11:
35626
+ 12:
34485
35627
  run_commit(hub_path$1, name, cmd._0);
34486
35628
  run_push(hub_path$1);
34487
35629
  break;
@@ -34601,6 +35743,7 @@ module.exports = {
34601
35743
  run_queue_clear,
34602
35744
  run_mca_add,
34603
35745
  run_mca_list,
35746
+ run_out,
34604
35747
  mca_cycle_path,
34605
35748
  mca_review_interval,
34606
35749
  get_mca_cycle,