cnagent 2.1.17 → 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 +110 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnagent",
3
- "version": "2.1.17",
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
@@ -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.17";
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
  }
@@ -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,