cnagent 2.2.6 → 2.2.7
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 +188 -108
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.7";
|
|
13602
13602
|
module2.exports = {
|
|
13603
13603
|
starts_with,
|
|
13604
13604
|
strip_prefix,
|
|
@@ -26699,6 +26699,78 @@ function inbox_check(hub_path, name) {
|
|
|
26699
26699
|
return;
|
|
26700
26700
|
}
|
|
26701
26701
|
}
|
|
26702
|
+
function delete_remote_branch(hub_path, branch) {
|
|
26703
|
+
const cmd2 = Curry._1(Stdlib__Printf.sprintf({
|
|
26704
|
+
TAG: (
|
|
26705
|
+
/* Format */
|
|
26706
|
+
0
|
|
26707
|
+
),
|
|
26708
|
+
_0: {
|
|
26709
|
+
TAG: (
|
|
26710
|
+
/* String_literal */
|
|
26711
|
+
11
|
|
26712
|
+
),
|
|
26713
|
+
_0: "git push origin --delete ",
|
|
26714
|
+
_1: {
|
|
26715
|
+
TAG: (
|
|
26716
|
+
/* String */
|
|
26717
|
+
2
|
|
26718
|
+
),
|
|
26719
|
+
_0: (
|
|
26720
|
+
/* No_padding */
|
|
26721
|
+
0
|
|
26722
|
+
),
|
|
26723
|
+
_1: {
|
|
26724
|
+
TAG: (
|
|
26725
|
+
/* String_literal */
|
|
26726
|
+
11
|
|
26727
|
+
),
|
|
26728
|
+
_0: " 2>/dev/null",
|
|
26729
|
+
_1: (
|
|
26730
|
+
/* End_of_format */
|
|
26731
|
+
0
|
|
26732
|
+
)
|
|
26733
|
+
}
|
|
26734
|
+
}
|
|
26735
|
+
},
|
|
26736
|
+
_1: "git push origin --delete %s 2>/dev/null"
|
|
26737
|
+
}), branch);
|
|
26738
|
+
const match2 = exec_in(hub_path, cmd2);
|
|
26739
|
+
if (match2 !== void 0) {
|
|
26740
|
+
log_action(hub_path, "branch.delete", branch);
|
|
26741
|
+
console.log(color("2", Curry._1(Stdlib__Printf.sprintf({
|
|
26742
|
+
TAG: (
|
|
26743
|
+
/* Format */
|
|
26744
|
+
0
|
|
26745
|
+
),
|
|
26746
|
+
_0: {
|
|
26747
|
+
TAG: (
|
|
26748
|
+
/* String_literal */
|
|
26749
|
+
11
|
|
26750
|
+
),
|
|
26751
|
+
_0: " Deleted remote: ",
|
|
26752
|
+
_1: {
|
|
26753
|
+
TAG: (
|
|
26754
|
+
/* String */
|
|
26755
|
+
2
|
|
26756
|
+
),
|
|
26757
|
+
_0: (
|
|
26758
|
+
/* No_padding */
|
|
26759
|
+
0
|
|
26760
|
+
),
|
|
26761
|
+
_1: (
|
|
26762
|
+
/* End_of_format */
|
|
26763
|
+
0
|
|
26764
|
+
)
|
|
26765
|
+
}
|
|
26766
|
+
},
|
|
26767
|
+
_1: " Deleted remote: %s"
|
|
26768
|
+
}), branch)));
|
|
26769
|
+
return true;
|
|
26770
|
+
} else {
|
|
26771
|
+
return false;
|
|
26772
|
+
}
|
|
26773
|
+
}
|
|
26702
26774
|
function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
|
|
26703
26775
|
const diff_cmd = Curry._2(Stdlib__Printf.sprintf({
|
|
26704
26776
|
TAG: (
|
|
@@ -26752,18 +26824,40 @@ function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
|
|
|
26752
26824
|
},
|
|
26753
26825
|
_1: "git diff main...origin/%s --name-only 2>/dev/null || git diff master...origin/%s --name-only"
|
|
26754
26826
|
}), branch, branch);
|
|
26755
|
-
|
|
26756
|
-
|
|
26827
|
+
const files = Stdlib__List.filter(is_md_file, Stdlib__Option.value(
|
|
26828
|
+
Stdlib__Option.map(split_lines, exec_in(hub_path, diff_cmd)),
|
|
26829
|
+
/* [] */
|
|
26830
|
+
0
|
|
26831
|
+
));
|
|
26832
|
+
const match2 = Stdlib__List.rev(Stdlib__String.split_on_char(
|
|
26833
|
+
/* '/' */
|
|
26834
|
+
47,
|
|
26835
|
+
branch
|
|
26836
|
+
));
|
|
26837
|
+
const branch_slug = match2 ? match2.hd : branch;
|
|
26838
|
+
const inbox_file = Curry._2(Stdlib__Printf.sprintf({
|
|
26839
|
+
TAG: (
|
|
26840
|
+
/* Format */
|
|
26841
|
+
0
|
|
26842
|
+
),
|
|
26843
|
+
_0: {
|
|
26757
26844
|
TAG: (
|
|
26758
|
-
/*
|
|
26845
|
+
/* String */
|
|
26846
|
+
2
|
|
26847
|
+
),
|
|
26848
|
+
_0: (
|
|
26849
|
+
/* No_padding */
|
|
26759
26850
|
0
|
|
26760
26851
|
),
|
|
26761
|
-
|
|
26852
|
+
_1: {
|
|
26762
26853
|
TAG: (
|
|
26763
|
-
/*
|
|
26764
|
-
|
|
26854
|
+
/* Char_literal */
|
|
26855
|
+
12
|
|
26856
|
+
),
|
|
26857
|
+
_0: (
|
|
26858
|
+
/* '-' */
|
|
26859
|
+
45
|
|
26765
26860
|
),
|
|
26766
|
-
_0: "git show origin/",
|
|
26767
26861
|
_1: {
|
|
26768
26862
|
TAG: (
|
|
26769
26863
|
/* String */
|
|
@@ -26775,65 +26869,41 @@ function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
|
|
|
26775
26869
|
),
|
|
26776
26870
|
_1: {
|
|
26777
26871
|
TAG: (
|
|
26778
|
-
/*
|
|
26779
|
-
|
|
26780
|
-
),
|
|
26781
|
-
_0: (
|
|
26782
|
-
/* ':' */
|
|
26783
|
-
58
|
|
26872
|
+
/* String_literal */
|
|
26873
|
+
11
|
|
26784
26874
|
),
|
|
26785
|
-
|
|
26786
|
-
|
|
26787
|
-
|
|
26788
|
-
|
|
26789
|
-
|
|
26790
|
-
_0: (
|
|
26791
|
-
/* No_padding */
|
|
26792
|
-
0
|
|
26793
|
-
),
|
|
26794
|
-
_1: (
|
|
26795
|
-
/* End_of_format */
|
|
26796
|
-
0
|
|
26797
|
-
)
|
|
26798
|
-
}
|
|
26875
|
+
_0: ".md",
|
|
26876
|
+
_1: (
|
|
26877
|
+
/* End_of_format */
|
|
26878
|
+
0
|
|
26879
|
+
)
|
|
26799
26880
|
}
|
|
26800
26881
|
}
|
|
26801
|
-
}
|
|
26802
|
-
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
|
|
26806
|
-
|
|
26807
|
-
|
|
26808
|
-
|
|
26809
|
-
|
|
26810
|
-
|
|
26811
|
-
|
|
26812
|
-
)
|
|
26813
|
-
|
|
26814
|
-
|
|
26815
|
-
|
|
26816
|
-
/* Format */
|
|
26817
|
-
0
|
|
26818
|
-
),
|
|
26819
|
-
_0: {
|
|
26882
|
+
}
|
|
26883
|
+
},
|
|
26884
|
+
_1: "%s-%s.md"
|
|
26885
|
+
}), peer_name, branch_slug);
|
|
26886
|
+
const inbox_path = Path.join(inbox_dir, inbox_file);
|
|
26887
|
+
const archived_path = Path.join(Path.join(inbox_dir, "_archived"), inbox_file);
|
|
26888
|
+
if (Fs.existsSync(inbox_path) || Fs.existsSync(archived_path)) {
|
|
26889
|
+
delete_remote_branch(hub_path, branch);
|
|
26890
|
+
return (
|
|
26891
|
+
/* [] */
|
|
26892
|
+
0
|
|
26893
|
+
);
|
|
26894
|
+
} else {
|
|
26895
|
+
return Stdlib__List.filter_map((function(file) {
|
|
26896
|
+
const show_cmd = Curry._2(Stdlib__Printf.sprintf({
|
|
26820
26897
|
TAG: (
|
|
26821
|
-
/*
|
|
26822
|
-
2
|
|
26823
|
-
),
|
|
26824
|
-
_0: (
|
|
26825
|
-
/* No_padding */
|
|
26898
|
+
/* Format */
|
|
26826
26899
|
0
|
|
26827
26900
|
),
|
|
26828
|
-
|
|
26901
|
+
_0: {
|
|
26829
26902
|
TAG: (
|
|
26830
|
-
/*
|
|
26831
|
-
|
|
26832
|
-
),
|
|
26833
|
-
_0: (
|
|
26834
|
-
/* '-' */
|
|
26835
|
-
45
|
|
26903
|
+
/* String_literal */
|
|
26904
|
+
11
|
|
26836
26905
|
),
|
|
26906
|
+
_0: "git show origin/",
|
|
26837
26907
|
_1: {
|
|
26838
26908
|
TAG: (
|
|
26839
26909
|
/* String */
|
|
@@ -26845,64 +26915,73 @@ function materialize_branch(hub_path, inbox_dir, peer_name, branch) {
|
|
|
26845
26915
|
),
|
|
26846
26916
|
_1: {
|
|
26847
26917
|
TAG: (
|
|
26848
|
-
/*
|
|
26849
|
-
|
|
26918
|
+
/* Char_literal */
|
|
26919
|
+
12
|
|
26850
26920
|
),
|
|
26851
|
-
_0:
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
26855
|
-
|
|
26921
|
+
_0: (
|
|
26922
|
+
/* ':' */
|
|
26923
|
+
58
|
|
26924
|
+
),
|
|
26925
|
+
_1: {
|
|
26926
|
+
TAG: (
|
|
26927
|
+
/* String */
|
|
26928
|
+
2
|
|
26929
|
+
),
|
|
26930
|
+
_0: (
|
|
26931
|
+
/* No_padding */
|
|
26932
|
+
0
|
|
26933
|
+
),
|
|
26934
|
+
_1: (
|
|
26935
|
+
/* End_of_format */
|
|
26936
|
+
0
|
|
26937
|
+
)
|
|
26938
|
+
}
|
|
26856
26939
|
}
|
|
26857
26940
|
}
|
|
26858
|
-
}
|
|
26859
|
-
|
|
26860
|
-
|
|
26861
|
-
|
|
26862
|
-
|
|
26863
|
-
|
|
26864
|
-
|
|
26865
|
-
|
|
26866
|
-
|
|
26867
|
-
|
|
26868
|
-
|
|
26869
|
-
|
|
26870
|
-
];
|
|
26871
|
-
const meta_1 = {
|
|
26872
|
-
hd: [
|
|
26873
|
-
"branch",
|
|
26874
|
-
branch
|
|
26875
|
-
],
|
|
26876
|
-
tl: {
|
|
26941
|
+
},
|
|
26942
|
+
_1: "git show origin/%s:%s"
|
|
26943
|
+
}), branch, file);
|
|
26944
|
+
const content = exec_in(hub_path, show_cmd);
|
|
26945
|
+
if (content === void 0) {
|
|
26946
|
+
return;
|
|
26947
|
+
}
|
|
26948
|
+
const meta_0 = [
|
|
26949
|
+
"from",
|
|
26950
|
+
peer_name
|
|
26951
|
+
];
|
|
26952
|
+
const meta_1 = {
|
|
26877
26953
|
hd: [
|
|
26878
|
-
"
|
|
26879
|
-
|
|
26954
|
+
"branch",
|
|
26955
|
+
branch
|
|
26880
26956
|
],
|
|
26881
26957
|
tl: {
|
|
26882
26958
|
hd: [
|
|
26883
|
-
"
|
|
26884
|
-
|
|
26959
|
+
"file",
|
|
26960
|
+
file
|
|
26885
26961
|
],
|
|
26886
|
-
tl:
|
|
26887
|
-
|
|
26888
|
-
|
|
26889
|
-
|
|
26962
|
+
tl: {
|
|
26963
|
+
hd: [
|
|
26964
|
+
"received",
|
|
26965
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
26966
|
+
],
|
|
26967
|
+
tl: (
|
|
26968
|
+
/* [] */
|
|
26969
|
+
0
|
|
26970
|
+
)
|
|
26971
|
+
}
|
|
26890
26972
|
}
|
|
26891
|
-
}
|
|
26892
|
-
|
|
26893
|
-
|
|
26894
|
-
|
|
26895
|
-
|
|
26896
|
-
|
|
26897
|
-
|
|
26898
|
-
|
|
26899
|
-
|
|
26900
|
-
|
|
26901
|
-
|
|
26902
|
-
|
|
26903
|
-
/* [] */
|
|
26904
|
-
0
|
|
26905
|
-
)));
|
|
26973
|
+
};
|
|
26974
|
+
const meta = {
|
|
26975
|
+
hd: meta_0,
|
|
26976
|
+
tl: meta_1
|
|
26977
|
+
};
|
|
26978
|
+
const prim1 = Cn_lib.update_frontmatter(content, meta);
|
|
26979
|
+
Fs.writeFileSync(inbox_path, prim1);
|
|
26980
|
+
log_action(hub_path, "inbox.materialize", inbox_file);
|
|
26981
|
+
delete_remote_branch(hub_path, branch);
|
|
26982
|
+
return inbox_file;
|
|
26983
|
+
}), files);
|
|
26984
|
+
}
|
|
26906
26985
|
}
|
|
26907
26986
|
function inbox_process(hub_path) {
|
|
26908
26987
|
console.log(color("36", "Processing inbox..."));
|
|
@@ -36237,6 +36316,7 @@ module.exports = {
|
|
|
36237
36316
|
split_lines,
|
|
36238
36317
|
get_peer_branches,
|
|
36239
36318
|
inbox_check,
|
|
36319
|
+
delete_remote_branch,
|
|
36240
36320
|
materialize_branch,
|
|
36241
36321
|
inbox_process,
|
|
36242
36322
|
outbox_check,
|