diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 50c5282..1a7ae14 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -5,54 +5,50 @@ on: branches: - main +permissions: {} + jobs: - changed-files: + common-checks: + name: Common Checks + permissions: + contents: read + pull-requests: read + uses: nownabe/workflows/.github/workflows/pr.yaml@95b6433077e235025af5d3d012aebf75e00354a4 # v1.0.2 + + filter: + name: Filter runs-on: ubuntu-latest timeout-minutes: 5 permissions: contents: read + pull-requests: read outputs: - github-actions: ${{ steps.changed-files.outputs.github-actions_any_changed }} - rust: ${{ steps.changed-files.outputs.rust_any_changed }} + changes: ${{ toJSON(steps.filter.outputs) }} steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - id: filter + uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v3.0.2 with: - persist-credentials: false - - - name: Detect changed files - id: changed-files - uses: tj-actions/changed-files@7dee1b0c1557f278e5c7dc244927139d78c0e22a # v47.0.4 - with: - files_yaml: | - github-actions: - - .github/** + filters: | rust: - '**/*.rs' - Cargo.toml - Cargo.lock - rust-toolchain.toml - check-github-actions: - needs: changed-files - if: needs.changed-files.outputs.github-actions == 'true' - uses: ./.github/workflows/reusable-check-github-actions.yaml - permissions: - contents: read - check-rust: - needs: changed-files - if: needs.changed-files.outputs.rust == 'true' + needs: filter + if: ${{ fromJSON(needs.filter.outputs.changes).rust == 'true' }} uses: ./.github/workflows/reusable-check-rust.yaml permissions: contents: read - status: + result: + name: Pull Request Checks runs-on: ubuntu-latest timeout-minutes: 5 if: always() needs: - - check-github-actions + - common-checks - check-rust permissions: {} steps: diff --git a/.github/workflows/reusable-check-github-actions.yaml b/.github/workflows/reusable-check-github-actions.yaml deleted file mode 100644 index f188833..0000000 --- a/.github/workflows/reusable-check-github-actions.yaml +++ /dev/null @@ -1,57 +0,0 @@ -name: Check GitHub Actions - -on: - workflow_call: - -jobs: - actionlint: - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - contents: read - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: Run actionlint - uses: raven-actions/actionlint@205b530c5d9fa8f44ae9ed59f341a0db994aa6f8 # v2.1.2 - - zizmor: - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - contents: read - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: Run zizmor - uses: zizmorcore/zizmor-action@0dce2577a4760a2749d8cfb7a84b7d5585ebcb7d # v0.5.0 - with: - advanced-security: false - - ghalint: - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - contents: read - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: Setup Go - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 - with: - go-version: stable - - - name: Install ghalint - run: go install github.com/suzuki-shunsuke/ghalint/cmd/ghalint@v1.5.5 - - - name: Run ghalint - run: ghalint run diff --git a/AGENTS.md b/AGENTS.md index 8b8e5f9..90baf93 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,11 +41,11 @@ src/ Single binary, three subcommands: -| Subcommand | Purpose | -|---|---| -| (none) | TUI mode — renders tree view, polls tmux, listens on IPC | -| `hook` | Hook mode — called by Claude Code hooks, sends AgentState via IPC | -| `notify` | Notify mode — called by tmux hooks, sends refresh signal via IPC | +| Subcommand | Purpose | +| ---------- | ----------------------------------------------------------------- | +| (none) | TUI mode — renders tree view, polls tmux, listens on IPC | +| `hook` | Hook mode — called by Claude Code hooks, sends AgentState via IPC | +| `notify` | Notify mode — called by tmux hooks, sends refresh signal via IPC | ### Data Flow @@ -62,6 +62,7 @@ Anthropic API ──(usage, polling ~600s)─────←── chikuwa TUI Unix domain socket at `$XDG_RUNTIME_DIR/chikuwa.sock` (fallback: `/tmp/chikuwa.sock`). Two message types: + - AgentState JSON (one line) → `AppEvent::AgentStateUpdate` - `"notify"` string → `AppEvent::TmuxChanged` @@ -77,6 +78,7 @@ The TUI spawns four concurrent tasks: ### Agent State Merging When an `AgentStateUpdate` arrives: + - `SessionEnd` → remove agent from state map - Otherwise → merge with existing state: - Preserve `session_id` if incoming is `None` @@ -86,27 +88,27 @@ When an `AgentStateUpdate` arrives: ### Hook Event Mapping -| Claude Code Event | AgentStatus | -|---|---| -| `SessionStart` | `Started` | -| `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `SubagentStart`, `SubagentStop` | `Running` | -| `Stop` | `Waiting` | -| `PermissionRequest` | `Permission` | -| `Notification` (containing "permission_prompt") | `Permission` | -| `SessionEnd` | `Ended` | +| Claude Code Event | AgentStatus | +| ------------------------------------------------------------------------------------------------------ | ------------ | +| `SessionStart` | `Started` | +| `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `SubagentStart`, `SubagentStop` | `Running` | +| `Stop` | `Waiting` | +| `PermissionRequest` | `Permission` | +| `Notification` (containing "permission_prompt") | `Permission` | +| `SessionEnd` | `Ended` | ### Tool Detail Extraction (`hook.rs`) -| Tool | Detail Source | -|---|---| -| `Bash` | `tool_input.command` | -| `Read` | `tool_input.file_path` (+ `:offset` if present) | -| `Write`, `Edit` | `tool_input.file_path` | -| `NotebookEdit` | `tool_input.notebook_path` | -| `Grep`, `Glob` | `tool_input.pattern` | -| `WebFetch` | `tool_input.url` | -| `WebSearch` | `tool_input.query` | -| `Task` | `tool_input.description` | +| Tool | Detail Source | +| --------------- | ----------------------------------------------- | +| `Bash` | `tool_input.command` | +| `Read` | `tool_input.file_path` (+ `:offset` if present) | +| `Write`, `Edit` | `tool_input.file_path` | +| `NotebookEdit` | `tool_input.notebook_path` | +| `Grep`, `Glob` | `tool_input.pattern` | +| `WebFetch` | `tool_input.url` | +| `WebSearch` | `tool_input.query` | +| `Task` | `tool_input.description` | ## Key Types diff --git a/README.md b/README.md index 874ab0b..1aa8aea 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,11 @@ A sidebar TUI for monitoring multiple AI agents (Claude Code, etc.) running in t A single binary that operates in three modes: -| Mode | Command | Description | -|---|---|---| -| TUI | `chikuwa` | Displays tmux sessions/windows/panes as a tree with real-time agent status | -| Hook | `chikuwa hook` | Called from Claude Code hooks; reads event JSON from stdin to update agent status via IPC | -| Notify | `chikuwa notify` | Called from tmux hooks; signals the TUI to refresh immediately | +| Mode | Command | Description | +| ------ | ---------------- | ----------------------------------------------------------------------------------------- | +| TUI | `chikuwa` | Displays tmux sessions/windows/panes as a tree with real-time agent status | +| Hook | `chikuwa hook` | Called from Claude Code hooks; reads event JSON from stdin to update agent status via IPC | +| Notify | `chikuwa notify` | Called from tmux hooks; signals the TUI to refresh immediately | ``` Claude Code ──(hooks)──→ chikuwa hook ──(IPC)──→ chikuwa (TUI) @@ -91,20 +91,20 @@ chikuwa #### Options -| Flag | Description | -|---|---| +| Flag | Description | +| ---------------- | ------------------------------------------------------------------------------------- | | `--store-events` | Log all received hook events to `$XDG_RUNTIME_DIR/chikuwa/events.jsonl` for debugging | ### Key Bindings -| Key | Action | -|---|---| -| `j` / `↓` | Move down | -| `k` / `↑` | Move up | +| Key | Action | +| ----------------- | ------------------------------------- | +| `j` / `↓` | Move down | +| `k` / `↑` | Move up | | `Enter` / `Space` | Toggle session collapse / switch tmux | -| `g` | Jump to top | -| `G` | Jump to bottom | -| `q` / `Ctrl+C` | Quit | +| `g` | Jump to top | +| `G` | Jump to bottom | +| `q` / `Ctrl+C` | Quit | Mouse clicks on tree items are also supported. @@ -115,17 +115,17 @@ Add the following to `~/.claude/settings.json`: ```json { "hooks": { - "SessionStart": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "UserPromptSubmit": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "PreToolUse": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "PostToolUse": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "PostToolUseFailure": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "PermissionRequest": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "Notification": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "Stop": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "SubagentStart": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "SubagentStop": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}], - "SessionEnd": [{"hooks": [{"type": "command", "command": "chikuwa hook"}]}] + "SessionStart": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "PreToolUse": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "PostToolUse": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "PostToolUseFailure": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "PermissionRequest": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "Notification": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "Stop": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "SubagentStart": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "SubagentStop": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }], + "SessionEnd": [{ "hooks": [{ "type": "command", "command": "chikuwa hook" }] }] } } ``` diff --git a/release-plz.toml b/release-plz.toml index f9c2e3d..8de5a35 100644 --- a/release-plz.toml +++ b/release-plz.toml @@ -4,13 +4,13 @@ git_release_draft = true [changelog] commit_parsers = [ - { message = "^feat", group = "Added" }, - { message = "^fix", group = "Fixed" }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", skip = true }, - { message = "^doc", skip = true }, - { message = "^style", skip = true }, - { message = "^test", skip = true }, - { message = "^chore", skip = true }, - { message = "^ci", skip = true }, + { message = "^feat", group = "Added" }, + { message = "^fix", group = "Fixed" }, + { message = "^perf", group = "Performance" }, + { message = "^refactor", skip = true }, + { message = "^doc", skip = true }, + { message = "^style", skip = true }, + { message = "^test", skip = true }, + { message = "^chore", skip = true }, + { message = "^ci", skip = true }, ]