@yunuseon/kayra 0.13.0 → 0.13.1

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.
@@ -62,7 +62,9 @@ shell.
62
62
 
63
63
  `main` is protected: it changes only through a PR with green `checks`, for
64
64
  admins too. Merging and pushing a tag both ask the operator (kayra's guard);
65
- that is expected, say what you are doing.
65
+ that is expected, say what you are doing. In auto mode the guard refuses
66
+ them instead: stop, give the operator the exact command, and continue once
67
+ they ran it (or switched the session to Manual and said so).
66
68
 
67
69
  ```bash
68
70
  gh pr merge <n> --repo yunuseon/kayra --merge --delete-branch
@@ -58,7 +58,9 @@ Commit (the message names the release and anything the fleet changed),
58
58
  push, open the PR the fleet's way, wait for its checks (GitHub:
59
59
  `gh pr checks --watch`; Forgejo: `tea api /repos/<owner>/<repo>/commits/<sha>/status`
60
60
  until `success`), then merge. Merges ask the operator (kayra's guard); that
61
- is expected. Remove the worktree and the local branch.
61
+ is expected. In auto mode the guard refuses them, and every non-multipass
62
+ deploy below, instead: stop, give the operator the exact command, continue
63
+ once they ran it. Remove the worktree and the local branch.
62
64
 
63
65
  ## 3. Deploy, server by server
64
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yunuseon/kayra",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "A self-hosted app platform and the CLI that runs it: Traefik, Authelia, a registry, rootless BuildKit and a small deployer per server, set up with OpenTofu and Ansible.",
5
5
  "license": "MIT",
6
6
  "author": "Yunus Öztürk",
@@ -5,8 +5,12 @@
5
5
  # command that changes something real waits for the operator to approve it,
6
6
  # in that moment.
7
7
  #
8
- # Reads the hook's JSON on stdin; prints a permissionDecision "ask" with the
9
- # reason for:
8
+ # Reads the hook's JSON on stdin; prints a permissionDecision with the reason
9
+ # for the commands below: "ask" in a mode that shows the operator a prompt
10
+ # (default, acceptEdits, plan), "deny" in one that approves by itself (auto,
11
+ # dontAsk, bypassPermissions) or an unknown one, where an "ask" would let the
12
+ # command through unseen. Denied, the agent stops and says so; the operator
13
+ # runs the command, or switches the session to Manual for it.
10
14
  # - kayra commands that change a server (up, provision, setup, deploy,
11
15
  # apps, adopt, down, app purge|deploy|rollback, job) unless --dry-run or
12
16
  # the server is a multipass one (its server.yml under the project)
@@ -25,13 +29,19 @@
25
29
  # =============================================================================
26
30
  set -uo pipefail
27
31
 
28
- command="$(jq -r '.tool_input.command // empty' 2>/dev/null)"
32
+ input="$(cat)"
33
+ command="$(jq -r '.tool_input.command // empty' <<< "$input" 2>/dev/null)"
29
34
  [ -n "$command" ] || exit 0
35
+ mode="$(jq -r '.permission_mode // empty' <<< "$input" 2>/dev/null)"
30
36
  project="${CLAUDE_PROJECT_DIR:-$PWD}"
31
37
 
32
38
  ask() {
33
- jq -n --arg reason "$1" \
34
- '{hookSpecificOutput: {hookEventName: "PreToolUse", permissionDecision: "ask", permissionDecisionReason: ("guard: " + $reason)}}'
39
+ case "$mode" in
40
+ default|acceptEdits|plan) decision=ask reason="guard: $1" ;;
41
+ *) decision=deny reason="guard: $1. This session approves by itself (${mode:-no permission mode}), so the guard refuses instead of asking: tell the operator, who runs it or switches the session to Manual for it." ;;
42
+ esac
43
+ jq -n --arg decision "$decision" --arg reason "$reason" \
44
+ '{hookSpecificOutput: {hookEventName: "PreToolUse", permissionDecision: $decision, permissionDecisionReason: $reason}}'
35
45
  exit 0
36
46
  }
37
47
  has() { grep -qE -- "$1" <<< "$command"; }