@integrity-labs/agt-cli 0.27.139 → 0.27.141

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/dist/bin/agt.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  success,
29
29
  table,
30
30
  warn
31
- } from "../chunk-PSH4UXVY.js";
31
+ } from "../chunk-BEB6BF3E.js";
32
32
  import {
33
33
  CHANNEL_REGISTRY,
34
34
  DEPLOYMENT_TEMPLATES,
@@ -4934,7 +4934,7 @@ import { execFileSync, execSync } from "child_process";
4934
4934
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4935
4935
  import chalk18 from "chalk";
4936
4936
  import ora16 from "ora";
4937
- var cliVersion = true ? "0.27.139" : "dev";
4937
+ var cliVersion = true ? "0.27.141" : "dev";
4938
4938
  async function fetchLatestVersion() {
4939
4939
  const host2 = getHost();
4940
4940
  if (!host2) return null;
@@ -5857,7 +5857,7 @@ function handleError(err) {
5857
5857
  }
5858
5858
 
5859
5859
  // src/bin/agt.ts
5860
- var cliVersion2 = true ? "0.27.139" : "dev";
5860
+ var cliVersion2 = true ? "0.27.141" : "dev";
5861
5861
  var program = new Command();
5862
5862
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
5863
5863
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -4664,6 +4664,136 @@ function provisionIsolationHook(codeName) {
4664
4664
  settings["hooks"] = hooks;
4665
4665
  writeFileSync5(settingsPath, JSON.stringify(settings, null, 2));
4666
4666
  }
4667
+ function provisionAutoKanbanProgressHook(codeName) {
4668
+ const projectDir = getProjectDir(codeName);
4669
+ const claudeDir = join4(projectDir, ".claude");
4670
+ mkdirSync4(claudeDir, { recursive: true });
4671
+ const hookScriptPath = join4(claudeDir, "agt-auto-kanban-progress-hook.sh");
4672
+ const hookScript = `#!/usr/bin/env bash
4673
+ # Auto-generated by Augmented (ENG-6179 / ENG-6241) \u2014 PostToolUse auto-progress.
4674
+ # Maps the agent's latest tool action onto its active in-thread kanban progress
4675
+ # card. Best-effort, silent, throttled; every path degrades to exit 0 and the
4676
+ # push is fire-and-forget so it never blocks or fails a tool call.
4677
+ # Canonical source: packages/claudecode-plugin-augmented/hooks/auto-kanban-progress.sh
4678
+
4679
+ # Best-effort: any unexpected error just exits clean.
4680
+ trap 'exit 0' ERR
4681
+
4682
+ # Hook input (stdin canonical; CLAUDE_HOOK_INPUT kept as a fallback).
4683
+ INPUT="$(cat 2>/dev/null || true)"
4684
+ [ -n "$INPUT" ] || INPUT="\${CLAUDE_HOOK_INPUT:-}"
4685
+ [ -n "$INPUT" ] || exit 0
4686
+ command -v jq >/dev/null 2>&1 || exit 0
4687
+ command -v curl >/dev/null 2>&1 || exit 0
4688
+
4689
+ TOOL="$(printf '%s' "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null || true)"
4690
+ [ -n "$TOOL" ] || exit 0
4691
+
4692
+ # Skip tools that aren't "work the requester wants narrated". kanban_* (incl.
4693
+ # the explicit kanban_progress) and channel/status tools would only produce
4694
+ # noise \u2014 and a kanban_done clears the step anyway.
4695
+ case "$TOOL" in
4696
+ *kanban*|*reply*|*ask_user*|*send_message*|*direct_chat*|status_*|TodoWrite|ExitPlanMode) exit 0 ;;
4697
+ esac
4698
+
4699
+ # Identity + endpoint.
4700
+ PROJECT_DIR="\${CLAUDE_PROJECT_DIR:-$PWD}"
4701
+ AGENT_ID="\${AGT_AGENT_ID:-}"
4702
+ if [ -z "$AGENT_ID" ] && [ -f "$PROJECT_DIR/.mcp.json" ]; then
4703
+ # The manager writes AGT_AGENT_ID literally into every augmented MCP server's
4704
+ # env block; take the first non-empty one.
4705
+ AGENT_ID="$(jq -r '[.mcpServers[]?.env?.AGT_AGENT_ID // empty] | map(select(. != "")) | .[0] // empty' "$PROJECT_DIR/.mcp.json" 2>/dev/null || true)"
4706
+ fi
4707
+ HOST="\${AGT_HOST:-}"
4708
+ KEY="\${AGT_API_KEY:-}"
4709
+ [ -n "$AGENT_ID" ] && [ -n "$HOST" ] && [ -n "$KEY" ] || exit 0
4710
+
4711
+ # Throttle: at most one push per ~15s per agent.
4712
+ STATE_DIR="\${HOME:-/tmp}/.augmented/.auto-progress/\${AGENT_ID}"
4713
+ mkdir -p "$STATE_DIR" 2>/dev/null || exit 0
4714
+ STAMP="$STATE_DIR/last-push"
4715
+ NOW="$(date +%s)"
4716
+ if [ -f "$STAMP" ]; then
4717
+ LAST="$(cat "$STAMP" 2>/dev/null || echo 0)"
4718
+ case "$LAST" in ''|*[!0-9]*) LAST=0 ;; esac
4719
+ [ $(( NOW - LAST )) -ge 15 ] || exit 0
4720
+ fi
4721
+
4722
+ # Derive the one-line "what I'm doing right now" step.
4723
+ STEP="$(printf '%s' "$INPUT" | jq -r '
4724
+ def base(p): (p | tostring | ltrimstr("./") | split("/") | last);
4725
+ .tool_name as $t | (.tool_input // {}) as $i |
4726
+ if $t == "Bash" then ($i.description // ("Running: " + (($i.command // "") | tostring | .[0:80])))
4727
+ elif $t == "Edit" then ("Editing " + base($i.file_path // $i.filePath // "a file"))
4728
+ elif $t == "MultiEdit" then ("Editing " + base($i.file_path // $i.filePath // "a file"))
4729
+ elif $t == "Write" then ("Writing " + base($i.file_path // $i.filePath // "a file"))
4730
+ elif $t == "NotebookEdit" then ("Editing " + base($i.notebook_path // "a notebook"))
4731
+ elif $t == "Read" then ("Reading " + base($i.file_path // $i.filePath // "a file"))
4732
+ elif $t == "Grep" then ("Searching for " + (($i.pattern // "") | tostring | .[0:60]))
4733
+ elif $t == "Glob" then ("Finding files: " + (($i.pattern // "") | tostring | .[0:60]))
4734
+ elif $t == "WebSearch" then ("Searching the web: " + (($i.query // "") | tostring | .[0:60]))
4735
+ elif $t == "WebFetch" then ("Fetching " + (($i.url // "") | tostring | .[0:80]))
4736
+ elif ($t == "Task" or $t == "Agent") then ("Working on: " + (($i.description // "a subtask") | tostring | .[0:80]))
4737
+ elif ($t | startswith("mcp__")) then ("Using " + ($t | sub("^mcp__"; "") | gsub("__"; " / ")))
4738
+ else ("Working (" + $t + ")")
4739
+ end
4740
+ ' 2>/dev/null || true)"
4741
+ STEP="$(printf '%s' "$STEP" | tr '\\n\\t' ' ' | sed 's/ */ /g' | cut -c1-240)"
4742
+ [ -n "$STEP" ] || exit 0
4743
+
4744
+ # Stamp BEFORE the network call so a slow API can't unthrottle us.
4745
+ printf '%s' "$NOW" > "$STAMP" 2>/dev/null || true
4746
+
4747
+ # Bearer JWT (exchange tlk_ -> JWT, cached with expiry).
4748
+ TOKEN_FILE="$STATE_DIR/token"
4749
+ TOKEN=""
4750
+ if [ -f "$TOKEN_FILE" ]; then
4751
+ T_EXP="$(jq -r '.exp // 0' "$TOKEN_FILE" 2>/dev/null || echo 0)"
4752
+ case "$T_EXP" in ''|*[!0-9]*) T_EXP=0 ;; esac
4753
+ [ $(( T_EXP - NOW )) -gt 300 ] && TOKEN="$(jq -r '.token // empty' "$TOKEN_FILE" 2>/dev/null || true)"
4754
+ fi
4755
+ if [ -z "$TOKEN" ]; then
4756
+ EX="$(curl -fsS --max-time 5 -X POST "$HOST/host/exchange" \\
4757
+ -H 'Content-Type: application/json' \\
4758
+ -d "{\\"host_key\\":\\"$KEY\\"}" 2>/dev/null || true)"
4759
+ TOKEN="$(printf '%s' "$EX" | jq -r '.token // empty' 2>/dev/null || true)"
4760
+ [ -n "$TOKEN" ] || exit 0
4761
+ EXP_ISO="$(printf '%s' "$EX" | jq -r '.expires_at // empty' 2>/dev/null || true)"
4762
+ # GNU date (Linux hosts) first, then BSD date (macOS dev machines), then a
4763
+ # safe 30-min fallback so a parse miss doesn't poison the token cache.
4764
+ EXP_EPOCH="$(date -d "$EXP_ISO" +%s 2>/dev/null \\
4765
+ || date -j -f '%Y-%m-%dT%H:%M:%SZ' "$EXP_ISO" +%s 2>/dev/null \\
4766
+ || echo $(( NOW + 1800 )))"
4767
+ ( umask 177; printf '{"token":"%s","exp":%s}' "$TOKEN" "$EXP_EPOCH" > "$TOKEN_FILE" 2>/dev/null || true )
4768
+ fi
4769
+
4770
+ # Fire-and-forget the push (never block the agent's tool flow).
4771
+ BODY="$(jq -nc --arg a "$AGENT_ID" --arg s "$STEP" '{agent_id:$a, step:$s}' 2>/dev/null || printf '{"agent_id":"%s","step":"%s"}' "$AGENT_ID" "$STEP")"
4772
+ ( curl -fsS --max-time 4 -X POST "$HOST/host/kanban/auto-progress" \\
4773
+ -H 'Content-Type: application/json' \\
4774
+ -H "Authorization: Bearer $TOKEN" \\
4775
+ -d "$BODY" >/dev/null 2>&1 || true ) &
4776
+
4777
+ exit 0
4778
+ `;
4779
+ writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
4780
+ const settingsPath = join4(claudeDir, "settings.local.json");
4781
+ let settings = {};
4782
+ try {
4783
+ settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
4784
+ } catch {
4785
+ }
4786
+ const hooks = settings["hooks"] ?? {};
4787
+ hooks["PostToolUse"] = [
4788
+ {
4789
+ hooks: [
4790
+ { type: "command", command: hookScriptPath }
4791
+ ]
4792
+ }
4793
+ ];
4794
+ settings["hooks"] = hooks;
4795
+ writeFileSync5(settingsPath, JSON.stringify(settings, null, 2));
4796
+ }
4667
4797
  function provisionOrientHook(codeName) {
4668
4798
  const projectDir = getProjectDir(codeName);
4669
4799
  const claudeDir = join4(projectDir, ".claude");
@@ -7700,6 +7830,7 @@ export {
7700
7830
  CHANNEL_SECRET_ENV_KEYS,
7701
7831
  provisionStopHook,
7702
7832
  provisionIsolationHook,
7833
+ provisionAutoKanbanProgressHook,
7703
7834
  provisionOrientHook,
7704
7835
  setJsonMode,
7705
7836
  isJsonMode,
@@ -7731,4 +7862,4 @@ export {
7731
7862
  managerInstallSystemUnitCommand,
7732
7863
  managerUninstallSystemUnitCommand
7733
7864
  };
7734
- //# sourceMappingURL=chunk-PSH4UXVY.js.map
7865
+ //# sourceMappingURL=chunk-BEB6BF3E.js.map