cnagent 2.2.7 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tools/dist/cn.js +479 -73
package/package.json
CHANGED
package/tools/dist/cn.js
CHANGED
|
@@ -13598,7 +13598,7 @@ var require_cn_lib = __commonJS({
|
|
|
13598
13598
|
);
|
|
13599
13599
|
}
|
|
13600
13600
|
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 in Queue inbox \xE2\x86\x92 input.md \xE2\x86\x92 wake agent (alias: inbound, process)\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";
|
|
13601
|
-
var version = "2.2.
|
|
13601
|
+
var version = "2.2.9";
|
|
13602
13602
|
module2.exports = {
|
|
13603
13603
|
starts_with,
|
|
13604
13604
|
strip_prefix,
|
|
@@ -26829,6 +26829,34 @@ function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
|
|
|
26829
26829
|
/* [] */
|
|
26830
26830
|
0
|
|
26831
26831
|
));
|
|
26832
|
+
const trigger = Stdlib__Option.value(Stdlib__Option.map(Stdlib__String.trim, exec_in(hub_path, Curry._1(Stdlib__Printf.sprintf({
|
|
26833
|
+
TAG: (
|
|
26834
|
+
/* Format */
|
|
26835
|
+
0
|
|
26836
|
+
),
|
|
26837
|
+
_0: {
|
|
26838
|
+
TAG: (
|
|
26839
|
+
/* String_literal */
|
|
26840
|
+
11
|
|
26841
|
+
),
|
|
26842
|
+
_0: "git rev-parse origin/",
|
|
26843
|
+
_1: {
|
|
26844
|
+
TAG: (
|
|
26845
|
+
/* String */
|
|
26846
|
+
2
|
|
26847
|
+
),
|
|
26848
|
+
_0: (
|
|
26849
|
+
/* No_padding */
|
|
26850
|
+
0
|
|
26851
|
+
),
|
|
26852
|
+
_1: (
|
|
26853
|
+
/* End_of_format */
|
|
26854
|
+
0
|
|
26855
|
+
)
|
|
26856
|
+
}
|
|
26857
|
+
},
|
|
26858
|
+
_1: "git rev-parse origin/%s"
|
|
26859
|
+
}), branch))), "unknown");
|
|
26832
26860
|
const match2 = Stdlib__List.rev(Stdlib__String.split_on_char(
|
|
26833
26861
|
/* '/' */
|
|
26834
26862
|
47,
|
|
@@ -26956,18 +26984,24 @@ function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
|
|
|
26956
26984
|
],
|
|
26957
26985
|
tl: {
|
|
26958
26986
|
hd: [
|
|
26959
|
-
"
|
|
26960
|
-
|
|
26987
|
+
"trigger",
|
|
26988
|
+
trigger
|
|
26961
26989
|
],
|
|
26962
26990
|
tl: {
|
|
26963
26991
|
hd: [
|
|
26964
|
-
"
|
|
26965
|
-
|
|
26992
|
+
"file",
|
|
26993
|
+
file
|
|
26966
26994
|
],
|
|
26967
|
-
tl:
|
|
26968
|
-
|
|
26969
|
-
|
|
26970
|
-
|
|
26995
|
+
tl: {
|
|
26996
|
+
hd: [
|
|
26997
|
+
"received",
|
|
26998
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
26999
|
+
],
|
|
27000
|
+
tl: (
|
|
27001
|
+
/* [] */
|
|
27002
|
+
0
|
|
27003
|
+
)
|
|
27004
|
+
}
|
|
26971
27005
|
}
|
|
26972
27006
|
}
|
|
26973
27007
|
};
|
|
@@ -26977,7 +27011,44 @@ function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
|
|
|
26977
27011
|
};
|
|
26978
27012
|
const prim1 = Cn_lib.update_frontmatter(content, meta);
|
|
26979
27013
|
Fs.writeFileSync(inbox_path, prim1);
|
|
26980
|
-
log_action(hub_path, "inbox.materialize",
|
|
27014
|
+
log_action(hub_path, "inbox.materialize", Curry._2(Stdlib__Printf.sprintf({
|
|
27015
|
+
TAG: (
|
|
27016
|
+
/* Format */
|
|
27017
|
+
0
|
|
27018
|
+
),
|
|
27019
|
+
_0: {
|
|
27020
|
+
TAG: (
|
|
27021
|
+
/* String */
|
|
27022
|
+
2
|
|
27023
|
+
),
|
|
27024
|
+
_0: (
|
|
27025
|
+
/* No_padding */
|
|
27026
|
+
0
|
|
27027
|
+
),
|
|
27028
|
+
_1: {
|
|
27029
|
+
TAG: (
|
|
27030
|
+
/* String_literal */
|
|
27031
|
+
11
|
|
27032
|
+
),
|
|
27033
|
+
_0: " trigger:",
|
|
27034
|
+
_1: {
|
|
27035
|
+
TAG: (
|
|
27036
|
+
/* String */
|
|
27037
|
+
2
|
|
27038
|
+
),
|
|
27039
|
+
_0: (
|
|
27040
|
+
/* No_padding */
|
|
27041
|
+
0
|
|
27042
|
+
),
|
|
27043
|
+
_1: (
|
|
27044
|
+
/* End_of_format */
|
|
27045
|
+
0
|
|
27046
|
+
)
|
|
27047
|
+
}
|
|
27048
|
+
}
|
|
27049
|
+
},
|
|
27050
|
+
_1: "%s trigger:%s"
|
|
27051
|
+
}), inbox_file, trigger));
|
|
26981
27052
|
delete_remote_branch(hub_path, branch);
|
|
26982
27053
|
return inbox_file;
|
|
26983
27054
|
}), files);
|
|
@@ -31511,29 +31582,23 @@ function execute_op(hub_path, name, input_id, op) {
|
|
|
31511
31582
|
return;
|
|
31512
31583
|
}
|
|
31513
31584
|
}
|
|
31585
|
+
function generate_trigger(param) {
|
|
31586
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
31587
|
+
}
|
|
31514
31588
|
function archive_io_pair(hub_path, name) {
|
|
31515
31589
|
const inp = Path.join(hub_path, "state/input.md");
|
|
31516
31590
|
const outp = Path.join(hub_path, "state/output.md");
|
|
31517
|
-
const
|
|
31518
|
-
const
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
return false;
|
|
31523
|
-
} else {
|
|
31524
|
-
return true;
|
|
31525
|
-
}
|
|
31526
|
-
}
|
|
31527
|
-
if (match$1 === void 0) {
|
|
31528
|
-
return false;
|
|
31529
|
-
}
|
|
31530
|
-
if (match2 === match$1) {
|
|
31591
|
+
const arg = generate_trigger(void 0);
|
|
31592
|
+
const trigger = (function(param) {
|
|
31593
|
+
return Stdlib__Option.value(param, arg);
|
|
31594
|
+
})(get_file_id(inp));
|
|
31595
|
+
if (Fs.existsSync(outp)) {
|
|
31531
31596
|
const logs_in = Path.join(hub_path, "logs/input");
|
|
31532
31597
|
const logs_out = Path.join(hub_path, "logs/output");
|
|
31533
31598
|
ensure_dir(logs_in);
|
|
31534
31599
|
ensure_dir(logs_out);
|
|
31535
31600
|
const output_content = Fs.readFileSync(outp, "utf8");
|
|
31536
|
-
const archive_name =
|
|
31601
|
+
const archive_name = trigger + ".md";
|
|
31537
31602
|
const prim1 = Fs.readFileSync(inp, "utf8");
|
|
31538
31603
|
const prim0 = Path.join(logs_in, archive_name);
|
|
31539
31604
|
Fs.writeFileSync(prim0, prim1);
|
|
@@ -31570,7 +31635,7 @@ function archive_io_pair(hub_path, name) {
|
|
|
31570
31635
|
},
|
|
31571
31636
|
_1: "Executing: %s"
|
|
31572
31637
|
}), Cn_lib.string_of_agent_op(op))));
|
|
31573
|
-
execute_op(hub_path, name,
|
|
31638
|
+
execute_op(hub_path, name, trigger, op);
|
|
31574
31639
|
}), ops);
|
|
31575
31640
|
Fs.unlinkSync(inp);
|
|
31576
31641
|
Fs.unlinkSync(outp);
|
|
@@ -31584,7 +31649,7 @@ function archive_io_pair(hub_path, name) {
|
|
|
31584
31649
|
/* String_literal */
|
|
31585
31650
|
11
|
|
31586
31651
|
),
|
|
31587
|
-
_0: "
|
|
31652
|
+
_0: "trigger:",
|
|
31588
31653
|
_1: {
|
|
31589
31654
|
TAG: (
|
|
31590
31655
|
/* String */
|
|
@@ -31625,8 +31690,8 @@ function archive_io_pair(hub_path, name) {
|
|
|
31625
31690
|
}
|
|
31626
31691
|
}
|
|
31627
31692
|
},
|
|
31628
|
-
_1: "
|
|
31629
|
-
}),
|
|
31693
|
+
_1: "trigger:%s ops:%d"
|
|
31694
|
+
}), trigger, Stdlib__List.length(ops)));
|
|
31630
31695
|
const msg = Curry._2(Stdlib__Printf.sprintf({
|
|
31631
31696
|
TAG: (
|
|
31632
31697
|
/* Format */
|
|
@@ -31637,7 +31702,7 @@ function archive_io_pair(hub_path, name) {
|
|
|
31637
31702
|
/* String_literal */
|
|
31638
31703
|
11
|
|
31639
31704
|
),
|
|
31640
|
-
_0: "Archived
|
|
31705
|
+
_0: "Archived: ",
|
|
31641
31706
|
_1: {
|
|
31642
31707
|
TAG: (
|
|
31643
31708
|
/* String */
|
|
@@ -31685,12 +31750,46 @@ function archive_io_pair(hub_path, name) {
|
|
|
31685
31750
|
}
|
|
31686
31751
|
}
|
|
31687
31752
|
},
|
|
31688
|
-
_1: "Archived
|
|
31689
|
-
}),
|
|
31753
|
+
_1: "Archived: %s (%d ops)"
|
|
31754
|
+
}), trigger, Stdlib__List.length(ops));
|
|
31690
31755
|
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
31691
31756
|
return true;
|
|
31692
31757
|
}
|
|
31693
|
-
console.log(color("
|
|
31758
|
+
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
31759
|
+
TAG: (
|
|
31760
|
+
/* Format */
|
|
31761
|
+
0
|
|
31762
|
+
),
|
|
31763
|
+
_0: {
|
|
31764
|
+
TAG: (
|
|
31765
|
+
/* String_literal */
|
|
31766
|
+
11
|
|
31767
|
+
),
|
|
31768
|
+
_0: "Waiting: trigger=",
|
|
31769
|
+
_1: {
|
|
31770
|
+
TAG: (
|
|
31771
|
+
/* String */
|
|
31772
|
+
2
|
|
31773
|
+
),
|
|
31774
|
+
_0: (
|
|
31775
|
+
/* No_padding */
|
|
31776
|
+
0
|
|
31777
|
+
),
|
|
31778
|
+
_1: {
|
|
31779
|
+
TAG: (
|
|
31780
|
+
/* String_literal */
|
|
31781
|
+
11
|
|
31782
|
+
),
|
|
31783
|
+
_0: ", no output yet",
|
|
31784
|
+
_1: (
|
|
31785
|
+
/* End_of_format */
|
|
31786
|
+
0
|
|
31787
|
+
)
|
|
31788
|
+
}
|
|
31789
|
+
}
|
|
31790
|
+
},
|
|
31791
|
+
_1: "Waiting: trigger=%s, no output yet"
|
|
31792
|
+
}), trigger)));
|
|
31694
31793
|
return false;
|
|
31695
31794
|
}
|
|
31696
31795
|
function queue_inbox_items(hub_path) {
|
|
@@ -31706,13 +31805,20 @@ function queue_inbox_items(hub_path) {
|
|
|
31706
31805
|
if (is_queued) {
|
|
31707
31806
|
return;
|
|
31708
31807
|
}
|
|
31709
|
-
const
|
|
31808
|
+
const arg = Path.basename(file, ".md");
|
|
31809
|
+
const trigger = (function(param) {
|
|
31810
|
+
return Stdlib__Option.value(param, arg);
|
|
31811
|
+
})(Stdlib__List.find_map((function(param) {
|
|
31812
|
+
if (param[0] === "trigger") {
|
|
31813
|
+
return param[1];
|
|
31814
|
+
}
|
|
31815
|
+
}), meta));
|
|
31710
31816
|
const from = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
31711
31817
|
if (param[0] === "from") {
|
|
31712
31818
|
return param[1];
|
|
31713
31819
|
}
|
|
31714
31820
|
}), meta), "unknown");
|
|
31715
|
-
queue_add(hub_path,
|
|
31821
|
+
queue_add(hub_path, trigger, from, content);
|
|
31716
31822
|
const prim1 = Cn_lib.update_frontmatter(content, {
|
|
31717
31823
|
hd: [
|
|
31718
31824
|
"queued-for-processing",
|
|
@@ -31778,7 +31884,7 @@ function queue_inbox_items(hub_path) {
|
|
|
31778
31884
|
}
|
|
31779
31885
|
},
|
|
31780
31886
|
_1: "Queued: %s (from %s)"
|
|
31781
|
-
}),
|
|
31887
|
+
}), trigger, from);
|
|
31782
31888
|
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
31783
31889
|
return file;
|
|
31784
31890
|
}), Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(inbox_dir)))));
|
|
@@ -33899,7 +34005,7 @@ function mca_count(hub_path) {
|
|
|
33899
34005
|
return 0;
|
|
33900
34006
|
}
|
|
33901
34007
|
}
|
|
33902
|
-
function queue_mca_review(hub_path) {
|
|
34008
|
+
function queue_mca_review(hub_path, name) {
|
|
33903
34009
|
const dir = Path.join(hub_path, "state/mca");
|
|
33904
34010
|
const mcas = Stdlib__List.sort(Stdlib__String.compare, Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir))));
|
|
33905
34011
|
const mca_list = Stdlib__String.concat("\n", Stdlib__List.map((function(file) {
|
|
@@ -34032,7 +34138,8 @@ function queue_mca_review(hub_path) {
|
|
|
34032
34138
|
_1: "- [%s] %s (by %s)"
|
|
34033
34139
|
}), id, Stdlib__String.trim(desc), by);
|
|
34034
34140
|
}), mcas));
|
|
34035
|
-
const
|
|
34141
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
34142
|
+
const event_file = Curry._1(Stdlib__Printf.sprintf({
|
|
34036
34143
|
TAG: (
|
|
34037
34144
|
/* Format */
|
|
34038
34145
|
0
|
|
@@ -34042,7 +34149,7 @@ function queue_mca_review(hub_path) {
|
|
|
34042
34149
|
/* String_literal */
|
|
34043
34150
|
11
|
|
34044
34151
|
),
|
|
34045
|
-
_0: "mca-review-",
|
|
34152
|
+
_0: "threads/system/mca-review-",
|
|
34046
34153
|
_1: {
|
|
34047
34154
|
TAG: (
|
|
34048
34155
|
/* String */
|
|
@@ -34052,15 +34159,81 @@ function queue_mca_review(hub_path) {
|
|
|
34052
34159
|
/* No_padding */
|
|
34053
34160
|
0
|
|
34054
34161
|
),
|
|
34055
|
-
_1:
|
|
34056
|
-
|
|
34162
|
+
_1: {
|
|
34163
|
+
TAG: (
|
|
34164
|
+
/* String_literal */
|
|
34165
|
+
11
|
|
34166
|
+
),
|
|
34167
|
+
_0: ".md",
|
|
34168
|
+
_1: (
|
|
34169
|
+
/* End_of_format */
|
|
34170
|
+
0
|
|
34171
|
+
)
|
|
34172
|
+
}
|
|
34173
|
+
}
|
|
34174
|
+
},
|
|
34175
|
+
_1: "threads/system/mca-review-%s.md"
|
|
34176
|
+
}), ts);
|
|
34177
|
+
const body = Curry._2(Stdlib__Printf.sprintf({
|
|
34178
|
+
TAG: (
|
|
34179
|
+
/* Format */
|
|
34180
|
+
0
|
|
34181
|
+
),
|
|
34182
|
+
_0: {
|
|
34183
|
+
TAG: (
|
|
34184
|
+
/* String_literal */
|
|
34185
|
+
11
|
|
34186
|
+
),
|
|
34187
|
+
_0: "---\ntype: mca-review\ncreated: ",
|
|
34188
|
+
_1: {
|
|
34189
|
+
TAG: (
|
|
34190
|
+
/* String */
|
|
34191
|
+
2
|
|
34192
|
+
),
|
|
34193
|
+
_0: (
|
|
34194
|
+
/* No_padding */
|
|
34057
34195
|
0
|
|
34058
|
-
)
|
|
34196
|
+
),
|
|
34197
|
+
_1: {
|
|
34198
|
+
TAG: (
|
|
34199
|
+
/* String_literal */
|
|
34200
|
+
11
|
|
34201
|
+
),
|
|
34202
|
+
_0: "\n---\n\n# MCA Review\n\nReview the MCA queue below. Identify the highest priority MCA with:\n- Lowest cost to complete\n- Highest probability of success\n\nIf you can do it now, do it. Otherwise, explain why not.\n\n## Open MCAs\n\n",
|
|
34203
|
+
_1: {
|
|
34204
|
+
TAG: (
|
|
34205
|
+
/* String */
|
|
34206
|
+
2
|
|
34207
|
+
),
|
|
34208
|
+
_0: (
|
|
34209
|
+
/* No_padding */
|
|
34210
|
+
0
|
|
34211
|
+
),
|
|
34212
|
+
_1: {
|
|
34213
|
+
TAG: (
|
|
34214
|
+
/* Char_literal */
|
|
34215
|
+
12
|
|
34216
|
+
),
|
|
34217
|
+
_0: (
|
|
34218
|
+
/* '\n' */
|
|
34219
|
+
10
|
|
34220
|
+
),
|
|
34221
|
+
_1: (
|
|
34222
|
+
/* End_of_format */
|
|
34223
|
+
0
|
|
34224
|
+
)
|
|
34225
|
+
}
|
|
34226
|
+
}
|
|
34227
|
+
}
|
|
34059
34228
|
}
|
|
34060
34229
|
},
|
|
34061
|
-
_1: "mca-review
|
|
34062
|
-
}), (/* @__PURE__ */ new Date()).toISOString()
|
|
34063
|
-
const
|
|
34230
|
+
_1: "---\ntype: mca-review\ncreated: %s\n---\n\n# MCA Review\n\nReview the MCA queue below. Identify the highest priority MCA with:\n- Lowest cost to complete\n- Highest probability of success\n\nIf you can do it now, do it. Otherwise, explain why not.\n\n## Open MCAs\n\n%s\n"
|
|
34231
|
+
}), (/* @__PURE__ */ new Date()).toISOString(), mca_list);
|
|
34232
|
+
const system_dir = Path.join(hub_path, "threads/system");
|
|
34233
|
+
ensure_dir(system_dir);
|
|
34234
|
+
const prim0 = Path.join(hub_path, event_file);
|
|
34235
|
+
Fs.writeFileSync(prim0, body);
|
|
34236
|
+
exec_in(hub_path, Curry._1(Stdlib__Printf.sprintf({
|
|
34064
34237
|
TAG: (
|
|
34065
34238
|
/* Format */
|
|
34066
34239
|
0
|
|
@@ -34070,7 +34243,7 @@ function queue_mca_review(hub_path) {
|
|
|
34070
34243
|
/* String_literal */
|
|
34071
34244
|
11
|
|
34072
34245
|
),
|
|
34073
|
-
_0: "
|
|
34246
|
+
_0: "git add '",
|
|
34074
34247
|
_1: {
|
|
34075
34248
|
TAG: (
|
|
34076
34249
|
/* String */
|
|
@@ -34086,8 +34259,8 @@ function queue_mca_review(hub_path) {
|
|
|
34086
34259
|
12
|
|
34087
34260
|
),
|
|
34088
34261
|
_0: (
|
|
34089
|
-
/* '\
|
|
34090
|
-
|
|
34262
|
+
/* '\'' */
|
|
34263
|
+
39
|
|
34091
34264
|
),
|
|
34092
34265
|
_1: (
|
|
34093
34266
|
/* End_of_format */
|
|
@@ -34096,10 +34269,9 @@ function queue_mca_review(hub_path) {
|
|
|
34096
34269
|
}
|
|
34097
34270
|
}
|
|
34098
34271
|
},
|
|
34099
|
-
_1: "
|
|
34100
|
-
}),
|
|
34101
|
-
|
|
34102
|
-
log_action(hub_path, "mca.review-queued", Curry._1(Stdlib__Printf.sprintf({
|
|
34272
|
+
_1: "git add '%s'"
|
|
34273
|
+
}), event_file));
|
|
34274
|
+
exec_in(hub_path, Curry._1(Stdlib__Printf.sprintf({
|
|
34103
34275
|
TAG: (
|
|
34104
34276
|
/* Format */
|
|
34105
34277
|
0
|
|
@@ -34109,33 +34281,117 @@ function queue_mca_review(hub_path) {
|
|
|
34109
34281
|
/* String_literal */
|
|
34110
34282
|
11
|
|
34111
34283
|
),
|
|
34112
|
-
_0: "
|
|
34284
|
+
_0: "git commit -m '",
|
|
34113
34285
|
_1: {
|
|
34114
34286
|
TAG: (
|
|
34115
|
-
/*
|
|
34116
|
-
|
|
34287
|
+
/* String */
|
|
34288
|
+
2
|
|
34117
34289
|
),
|
|
34118
34290
|
_0: (
|
|
34119
|
-
/* Int_d */
|
|
34120
|
-
0
|
|
34121
|
-
),
|
|
34122
|
-
_1: (
|
|
34123
34291
|
/* No_padding */
|
|
34124
34292
|
0
|
|
34125
34293
|
),
|
|
34126
|
-
|
|
34127
|
-
|
|
34294
|
+
_1: {
|
|
34295
|
+
TAG: (
|
|
34296
|
+
/* String_literal */
|
|
34297
|
+
11
|
|
34298
|
+
),
|
|
34299
|
+
_0: ": system event mca-review'",
|
|
34300
|
+
_1: (
|
|
34301
|
+
/* End_of_format */
|
|
34302
|
+
0
|
|
34303
|
+
)
|
|
34304
|
+
}
|
|
34305
|
+
}
|
|
34306
|
+
},
|
|
34307
|
+
_1: "git commit -m '%s: system event mca-review'"
|
|
34308
|
+
}), name));
|
|
34309
|
+
const arg = Curry._1(Stdlib__Printf.sprintf({
|
|
34310
|
+
TAG: (
|
|
34311
|
+
/* Format */
|
|
34312
|
+
0
|
|
34313
|
+
),
|
|
34314
|
+
_0: {
|
|
34315
|
+
TAG: (
|
|
34316
|
+
/* String_literal */
|
|
34317
|
+
11
|
|
34318
|
+
),
|
|
34319
|
+
_0: "mca-review-",
|
|
34320
|
+
_1: {
|
|
34321
|
+
TAG: (
|
|
34322
|
+
/* String */
|
|
34323
|
+
2
|
|
34324
|
+
),
|
|
34325
|
+
_0: (
|
|
34326
|
+
/* No_padding */
|
|
34128
34327
|
0
|
|
34129
34328
|
),
|
|
34130
|
-
|
|
34329
|
+
_1: (
|
|
34131
34330
|
/* End_of_format */
|
|
34132
34331
|
0
|
|
34133
34332
|
)
|
|
34134
34333
|
}
|
|
34135
34334
|
},
|
|
34136
|
-
_1: "
|
|
34137
|
-
}),
|
|
34138
|
-
const
|
|
34335
|
+
_1: "mca-review-%s"
|
|
34336
|
+
}), ts);
|
|
34337
|
+
const trigger = (function(param) {
|
|
34338
|
+
return Stdlib__Option.value(param, arg);
|
|
34339
|
+
})(Stdlib__Option.map(Stdlib__String.trim, exec_in(hub_path, "git rev-parse HEAD")));
|
|
34340
|
+
queue_add(hub_path, trigger, "system", body);
|
|
34341
|
+
log_action(hub_path, "mca.review-queued", Curry._2(Stdlib__Printf.sprintf({
|
|
34342
|
+
TAG: (
|
|
34343
|
+
/* Format */
|
|
34344
|
+
0
|
|
34345
|
+
),
|
|
34346
|
+
_0: {
|
|
34347
|
+
TAG: (
|
|
34348
|
+
/* String_literal */
|
|
34349
|
+
11
|
|
34350
|
+
),
|
|
34351
|
+
_0: "trigger:",
|
|
34352
|
+
_1: {
|
|
34353
|
+
TAG: (
|
|
34354
|
+
/* String */
|
|
34355
|
+
2
|
|
34356
|
+
),
|
|
34357
|
+
_0: (
|
|
34358
|
+
/* No_padding */
|
|
34359
|
+
0
|
|
34360
|
+
),
|
|
34361
|
+
_1: {
|
|
34362
|
+
TAG: (
|
|
34363
|
+
/* String_literal */
|
|
34364
|
+
11
|
|
34365
|
+
),
|
|
34366
|
+
_0: " count:",
|
|
34367
|
+
_1: {
|
|
34368
|
+
TAG: (
|
|
34369
|
+
/* Int */
|
|
34370
|
+
4
|
|
34371
|
+
),
|
|
34372
|
+
_0: (
|
|
34373
|
+
/* Int_d */
|
|
34374
|
+
0
|
|
34375
|
+
),
|
|
34376
|
+
_1: (
|
|
34377
|
+
/* No_padding */
|
|
34378
|
+
0
|
|
34379
|
+
),
|
|
34380
|
+
_2: (
|
|
34381
|
+
/* No_precision */
|
|
34382
|
+
0
|
|
34383
|
+
),
|
|
34384
|
+
_3: (
|
|
34385
|
+
/* End_of_format */
|
|
34386
|
+
0
|
|
34387
|
+
)
|
|
34388
|
+
}
|
|
34389
|
+
}
|
|
34390
|
+
}
|
|
34391
|
+
},
|
|
34392
|
+
_1: "trigger:%s count:%d"
|
|
34393
|
+
}), trigger, Stdlib__List.length(mcas)));
|
|
34394
|
+
const msg = Curry._2(Stdlib__Printf.sprintf({
|
|
34139
34395
|
TAG: (
|
|
34140
34396
|
/* Format */
|
|
34141
34397
|
0
|
|
@@ -34168,16 +34424,26 @@ function queue_mca_review(hub_path) {
|
|
|
34168
34424
|
/* String_literal */
|
|
34169
34425
|
11
|
|
34170
34426
|
),
|
|
34171
|
-
_0: " MCAs)",
|
|
34172
|
-
_1:
|
|
34173
|
-
|
|
34174
|
-
|
|
34175
|
-
|
|
34427
|
+
_0: " MCAs) trigger:",
|
|
34428
|
+
_1: {
|
|
34429
|
+
TAG: (
|
|
34430
|
+
/* String */
|
|
34431
|
+
2
|
|
34432
|
+
),
|
|
34433
|
+
_0: (
|
|
34434
|
+
/* No_padding */
|
|
34435
|
+
0
|
|
34436
|
+
),
|
|
34437
|
+
_1: (
|
|
34438
|
+
/* End_of_format */
|
|
34439
|
+
0
|
|
34440
|
+
)
|
|
34441
|
+
}
|
|
34176
34442
|
}
|
|
34177
34443
|
}
|
|
34178
34444
|
},
|
|
34179
|
-
_1: "Queued MCA review (%d MCAs)"
|
|
34180
|
-
}), Stdlib__List.length(mcas));
|
|
34445
|
+
_1: "Queued MCA review (%d MCAs) trigger:%s"
|
|
34446
|
+
}), Stdlib__List.length(mcas), Stdlib__String.sub(trigger, 0, 7));
|
|
34181
34447
|
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
34182
34448
|
}
|
|
34183
34449
|
function auto_save(hub_path, name) {
|
|
@@ -34331,7 +34597,7 @@ function run_inbound(hub_path, name) {
|
|
|
34331
34597
|
}
|
|
34332
34598
|
const cycle = increment_mca_cycle(hub_path);
|
|
34333
34599
|
if (cycle % 5 === 0 && mca_count(hub_path) > 0) {
|
|
34334
|
-
queue_mca_review(hub_path);
|
|
34600
|
+
queue_mca_review(hub_path, name);
|
|
34335
34601
|
}
|
|
34336
34602
|
const inp = Path.join(hub_path, "state/input.md");
|
|
34337
34603
|
const outp = Path.join(hub_path, "state/output.md");
|
|
@@ -35993,6 +36259,143 @@ function run_update_with_cron(hub_path) {
|
|
|
35993
36259
|
}
|
|
35994
36260
|
console.log(color("2", "No runtime changes to commit"));
|
|
35995
36261
|
}
|
|
36262
|
+
function self_update_check(param) {
|
|
36263
|
+
const args2 = Stdlib__Array.to_list(process.argv);
|
|
36264
|
+
const is_skip_cmd = Stdlib__List.exists((function(a) {
|
|
36265
|
+
if (a === "--help" || a === "-h" || a === "--version" || a === "-V") {
|
|
36266
|
+
return true;
|
|
36267
|
+
} else {
|
|
36268
|
+
return a === "help";
|
|
36269
|
+
}
|
|
36270
|
+
}), args2);
|
|
36271
|
+
if (is_skip_cmd) {
|
|
36272
|
+
return;
|
|
36273
|
+
}
|
|
36274
|
+
const latest_raw = exec("npm view cnagent version --fetch-timeout=5000 2>/dev/null");
|
|
36275
|
+
if (latest_raw === void 0) {
|
|
36276
|
+
return;
|
|
36277
|
+
}
|
|
36278
|
+
const latest = Stdlib__String.trim(latest_raw);
|
|
36279
|
+
if (!(latest !== Cn_lib.version && latest !== "")) {
|
|
36280
|
+
return;
|
|
36281
|
+
}
|
|
36282
|
+
console.log(color("36", Curry._2(Stdlib__Printf.sprintf({
|
|
36283
|
+
TAG: (
|
|
36284
|
+
/* Format */
|
|
36285
|
+
0
|
|
36286
|
+
),
|
|
36287
|
+
_0: {
|
|
36288
|
+
TAG: (
|
|
36289
|
+
/* String_literal */
|
|
36290
|
+
11
|
|
36291
|
+
),
|
|
36292
|
+
_0: "Updating cn ",
|
|
36293
|
+
_1: {
|
|
36294
|
+
TAG: (
|
|
36295
|
+
/* String */
|
|
36296
|
+
2
|
|
36297
|
+
),
|
|
36298
|
+
_0: (
|
|
36299
|
+
/* No_padding */
|
|
36300
|
+
0
|
|
36301
|
+
),
|
|
36302
|
+
_1: {
|
|
36303
|
+
TAG: (
|
|
36304
|
+
/* String_literal */
|
|
36305
|
+
11
|
|
36306
|
+
),
|
|
36307
|
+
_0: " \xE2\x86\x92 ",
|
|
36308
|
+
_1: {
|
|
36309
|
+
TAG: (
|
|
36310
|
+
/* String */
|
|
36311
|
+
2
|
|
36312
|
+
),
|
|
36313
|
+
_0: (
|
|
36314
|
+
/* No_padding */
|
|
36315
|
+
0
|
|
36316
|
+
),
|
|
36317
|
+
_1: {
|
|
36318
|
+
TAG: (
|
|
36319
|
+
/* String_literal */
|
|
36320
|
+
11
|
|
36321
|
+
),
|
|
36322
|
+
_0: "...",
|
|
36323
|
+
_1: (
|
|
36324
|
+
/* End_of_format */
|
|
36325
|
+
0
|
|
36326
|
+
)
|
|
36327
|
+
}
|
|
36328
|
+
}
|
|
36329
|
+
}
|
|
36330
|
+
}
|
|
36331
|
+
},
|
|
36332
|
+
_1: "Updating cn %s \xE2\x86\x92 %s..."
|
|
36333
|
+
}), Cn_lib.version, latest)));
|
|
36334
|
+
const match2 = exec("npm install -g cnagent@latest 2>/dev/null");
|
|
36335
|
+
if (match2 !== void 0) {
|
|
36336
|
+
const msg = Curry._1(Stdlib__Printf.sprintf({
|
|
36337
|
+
TAG: (
|
|
36338
|
+
/* Format */
|
|
36339
|
+
0
|
|
36340
|
+
),
|
|
36341
|
+
_0: {
|
|
36342
|
+
TAG: (
|
|
36343
|
+
/* String_literal */
|
|
36344
|
+
11
|
|
36345
|
+
),
|
|
36346
|
+
_0: "Updated to cn ",
|
|
36347
|
+
_1: {
|
|
36348
|
+
TAG: (
|
|
36349
|
+
/* String */
|
|
36350
|
+
2
|
|
36351
|
+
),
|
|
36352
|
+
_0: (
|
|
36353
|
+
/* No_padding */
|
|
36354
|
+
0
|
|
36355
|
+
),
|
|
36356
|
+
_1: (
|
|
36357
|
+
/* End_of_format */
|
|
36358
|
+
0
|
|
36359
|
+
)
|
|
36360
|
+
}
|
|
36361
|
+
},
|
|
36362
|
+
_1: "Updated to cn %s"
|
|
36363
|
+
}), latest);
|
|
36364
|
+
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
36365
|
+
const args_str = Stdlib__String.concat(" ", Stdlib__List.tl(args2));
|
|
36366
|
+
exec(Curry._1(Stdlib__Printf.sprintf({
|
|
36367
|
+
TAG: (
|
|
36368
|
+
/* Format */
|
|
36369
|
+
0
|
|
36370
|
+
),
|
|
36371
|
+
_0: {
|
|
36372
|
+
TAG: (
|
|
36373
|
+
/* String_literal */
|
|
36374
|
+
11
|
|
36375
|
+
),
|
|
36376
|
+
_0: "cn ",
|
|
36377
|
+
_1: {
|
|
36378
|
+
TAG: (
|
|
36379
|
+
/* String */
|
|
36380
|
+
2
|
|
36381
|
+
),
|
|
36382
|
+
_0: (
|
|
36383
|
+
/* No_padding */
|
|
36384
|
+
0
|
|
36385
|
+
),
|
|
36386
|
+
_1: (
|
|
36387
|
+
/* End_of_format */
|
|
36388
|
+
0
|
|
36389
|
+
)
|
|
36390
|
+
}
|
|
36391
|
+
},
|
|
36392
|
+
_1: "cn %s"
|
|
36393
|
+
}), args_str));
|
|
36394
|
+
process.exit(0);
|
|
36395
|
+
return;
|
|
36396
|
+
}
|
|
36397
|
+
console.log(color("33", "\xE2\x9A\xA0 ") + "Self-update failed - continuing with current version");
|
|
36398
|
+
}
|
|
35996
36399
|
function drop(n, lst) {
|
|
35997
36400
|
let _n = n;
|
|
35998
36401
|
let _lst = lst;
|
|
@@ -36014,6 +36417,7 @@ function drop(n, lst) {
|
|
|
36014
36417
|
}
|
|
36015
36418
|
;
|
|
36016
36419
|
}
|
|
36420
|
+
self_update_check(void 0);
|
|
36017
36421
|
var args = drop(2, Stdlib__Array.to_list(process.argv));
|
|
36018
36422
|
var match = Cn_lib.parse_flags(args);
|
|
36019
36423
|
var cmd_args = match[1];
|
|
@@ -36351,6 +36755,7 @@ module.exports = {
|
|
|
36351
36755
|
get_file_id,
|
|
36352
36756
|
mca_dir,
|
|
36353
36757
|
execute_op,
|
|
36758
|
+
generate_trigger,
|
|
36354
36759
|
archive_io_pair,
|
|
36355
36760
|
queue_inbox_items,
|
|
36356
36761
|
feed_next_input,
|
|
@@ -36380,5 +36785,6 @@ module.exports = {
|
|
|
36380
36785
|
update_cron,
|
|
36381
36786
|
run_update,
|
|
36382
36787
|
run_update_with_cron,
|
|
36788
|
+
self_update_check,
|
|
36383
36789
|
drop
|
|
36384
36790
|
};
|