From f1c7ef4c8645d75cd10b7a259174919847cbdf8d Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Thu, 9 Apr 2026 02:32:00 +0000 Subject: [PATCH 1/2] feat(examples): add ticket CLI example with plugin support Run wedow/ticket issue tracker inside bashkit, exercising VFS mounts, PATH-based plugin discovery, awk scripts, and YAML frontmatter parsing. Adds CI step to run the example on every push. --- .github/workflows/ci.yml | 3 ++ examples/README.md | 11 ++++ examples/ticket-cli.sh | 108 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100755 examples/ticket-cli.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbcdc70e..f951f249 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,6 +135,9 @@ jobs: cargo build -p bashkit-cli --features realfs bash examples/realfs_mount.sh + - name: Run ticket CLI example + run: bash examples/ticket-cli.sh + # External API dependency — don't block CI on Anthropic outages - name: Run LLM agent example continue-on-error: true diff --git a/examples/README.md b/examples/README.md index bb9239ae..6ae78d6a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,6 +10,17 @@ cargo build -p bashkit-cli --features realfs bash examples/realfs_mount.sh ``` +## ticket-cli.sh + +Run the [wedow/ticket](https://github.com/wedow/ticket) issue tracker inside +bashkit. Exercises plugin discovery via PATH, awk-heavy scripts, YAML +frontmatter parsing, dependency trees, and filtered listing — all interpreted. + +```bash +cargo build -p bashkit-cli --features realfs +bash examples/ticket-cli.sh +``` + ## Python Python examples use [PEP 723](https://peps.python.org/pep-0723/) inline script metadata. diff --git a/examples/ticket-cli.sh b/examples/ticket-cli.sh new file mode 100755 index 00000000..a8a86bb2 --- /dev/null +++ b/examples/ticket-cli.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +# Run the wedow/ticket issue tracker inside bashkit with plugin support. +# +# Demonstrates: VFS mounts, PATH-based plugin discovery, complex bash scripts +# with awk, sed, and YAML frontmatter parsing — all interpreted by bashkit. +# +# Prerequisites: +# cargo build -p bashkit-cli --features realfs +# +# Usage: +# bash examples/ticket-cli.sh +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +BASHKIT="${BASHKIT:-$PROJECT_ROOT/target/debug/bashkit}" + +# Build if binary doesn't exist +if [[ ! -x "$BASHKIT" ]]; then + echo "Building bashkit CLI with realfs support..." + cargo build -p bashkit-cli --features realfs --quiet +fi + +TICKET_DIR="${TICKET_DIR:-/tmp/bashkit-ticket-example}" +WORK_DIR=$(mktemp -d) +trap 'rm -rf "$WORK_DIR"' EXIT + +if [[ ! -d "$TICKET_DIR" ]]; then + echo "Cloning wedow/ticket..." + git clone --depth 1 https://github.com/wedow/ticket "$TICKET_DIR" +fi + +echo "--- Running ticket CLI inside bashkit ---" +echo "" + +"$BASHKIT" \ + --mount-ro "$TICKET_DIR:/ticket" \ + --mount-rw "$WORK_DIR:/work" \ + --timeout 60 \ + -c ' +export PATH="/ticket/plugins:$PATH" +export TK_SCRIPT="/ticket/ticket" +cd /work + +# --- 1. Create tickets --- +echo "=== Create tickets ===" +id1=$(/ticket/ticket create "Fix auth bypass" -t bug -p 1 -a alice --tags security,backend -d "JWT validation skipped on /admin routes") +id2=$(/ticket/ticket create "Add rate limiting" -t feature -p 2 -a bob --tags api,backend -d "Throttle API to 100 req/min per key") +id3=$(/ticket/ticket create "Update API docs" -t chore -p 3 -a alice --tags docs -d "Document new rate-limit headers") +echo "Created: $id1, $id2, $id3" + +# --- 2. Plugin: list tickets (ticket-ls) --- +echo "" +echo "=== Plugin: ticket-ls ===" +/ticket/ticket ls + +# --- 3. Manage workflow --- +echo "" +echo "=== Workflow: start, deps, notes ===" +/ticket/ticket start "$id1" +/ticket/ticket dep "$id3" "$id2" +/ticket/ticket add-note "$id1" "Root cause: missing middleware on /admin/* routes" + +# --- 4. Show a ticket with full detail --- +echo "" +echo "=== Show ticket ===" +/ticket/ticket show "$id1" + +# --- 5. Check ready vs blocked --- +echo "" +echo "=== Ready tickets ===" +/ticket/ticket ready +echo "" +echo "=== Blocked tickets ===" +/ticket/ticket blocked + +# --- 6. Dependency tree --- +echo "" +echo "=== Dependency tree ===" +/ticket/ticket dep tree "$id3" + +# --- 7. Close a ticket, check unblocking --- +echo "" +echo "=== Close rate-limiting ticket ===" +/ticket/ticket close "$id2" +echo "" +echo "=== Blocked after closing dep ===" +/ticket/ticket blocked + +# --- 8. Plugin: query as JSON --- +echo "" +echo "=== Plugin: ticket-query (JSON) ===" +/ticket/ticket query + +# --- 9. Plugin: list with filters --- +echo "" +echo "=== Plugin: ticket-ls --status=open ===" +/ticket/ticket ls --status=open +echo "" +echo "=== Plugin: ticket-ls -a alice ===" +/ticket/ticket ls -a alice + +echo "" +echo "=== Done ===" +' + +echo "" +echo "Success!" From 85118b7f2732d23010a15ec13dfc3466fcff238c Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Thu, 9 Apr 2026 02:40:59 +0000 Subject: [PATCH 2/2] refactor(examples): align ticket-cli.sh with harness example structure Use exec, named WORK_DIR with default, persistent clone cache, trailing comment block for discoverable commands. --- examples/ticket-cli.sh | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/examples/ticket-cli.sh b/examples/ticket-cli.sh index a8a86bb2..4339df5c 100755 --- a/examples/ticket-cli.sh +++ b/examples/ticket-cli.sh @@ -5,7 +5,7 @@ # with awk, sed, and YAML frontmatter parsing — all interpreted by bashkit. # # Prerequisites: -# cargo build -p bashkit-cli --features realfs +# - cargo build -p bashkit-cli --features realfs # # Usage: # bash examples/ticket-cli.sh @@ -21,19 +21,17 @@ if [[ ! -x "$BASHKIT" ]]; then cargo build -p bashkit-cli --features realfs --quiet fi -TICKET_DIR="${TICKET_DIR:-/tmp/bashkit-ticket-example}" -WORK_DIR=$(mktemp -d) -trap 'rm -rf "$WORK_DIR"' EXIT +TICKET_DIR="${TICKET_DIR:-/tmp/bashkit-ticket}" +WORK_DIR="${WORK_DIR:-/tmp/bashkit-ticket-work}" if [[ ! -d "$TICKET_DIR" ]]; then echo "Cloning wedow/ticket..." git clone --depth 1 https://github.com/wedow/ticket "$TICKET_DIR" fi -echo "--- Running ticket CLI inside bashkit ---" -echo "" +mkdir -p "$WORK_DIR" -"$BASHKIT" \ +exec "$BASHKIT" \ --mount-ro "$TICKET_DIR:/ticket" \ --mount-rw "$WORK_DIR:/work" \ --timeout 60 \ @@ -42,31 +40,31 @@ export PATH="/ticket/plugins:$PATH" export TK_SCRIPT="/ticket/ticket" cd /work -# --- 1. Create tickets --- +# --- Create tickets --- echo "=== Create tickets ===" id1=$(/ticket/ticket create "Fix auth bypass" -t bug -p 1 -a alice --tags security,backend -d "JWT validation skipped on /admin routes") id2=$(/ticket/ticket create "Add rate limiting" -t feature -p 2 -a bob --tags api,backend -d "Throttle API to 100 req/min per key") id3=$(/ticket/ticket create "Update API docs" -t chore -p 3 -a alice --tags docs -d "Document new rate-limit headers") echo "Created: $id1, $id2, $id3" -# --- 2. Plugin: list tickets (ticket-ls) --- +# --- Plugin: list tickets (ticket-ls) --- echo "" echo "=== Plugin: ticket-ls ===" /ticket/ticket ls -# --- 3. Manage workflow --- +# --- Manage workflow --- echo "" echo "=== Workflow: start, deps, notes ===" /ticket/ticket start "$id1" /ticket/ticket dep "$id3" "$id2" /ticket/ticket add-note "$id1" "Root cause: missing middleware on /admin/* routes" -# --- 4. Show a ticket with full detail --- +# --- Show a ticket with full detail --- echo "" echo "=== Show ticket ===" /ticket/ticket show "$id1" -# --- 5. Check ready vs blocked --- +# --- Check ready vs blocked --- echo "" echo "=== Ready tickets ===" /ticket/ticket ready @@ -74,12 +72,12 @@ echo "" echo "=== Blocked tickets ===" /ticket/ticket blocked -# --- 6. Dependency tree --- +# --- Dependency tree --- echo "" echo "=== Dependency tree ===" /ticket/ticket dep tree "$id3" -# --- 7. Close a ticket, check unblocking --- +# --- Close a ticket, check unblocking --- echo "" echo "=== Close rate-limiting ticket ===" /ticket/ticket close "$id2" @@ -87,12 +85,12 @@ echo "" echo "=== Blocked after closing dep ===" /ticket/ticket blocked -# --- 8. Plugin: query as JSON --- +# --- Plugin: query as JSON --- echo "" echo "=== Plugin: ticket-query (JSON) ===" /ticket/ticket query -# --- 9. Plugin: list with filters --- +# --- Plugin: list with filters --- echo "" echo "=== Plugin: ticket-ls --status=open ===" /ticket/ticket ls --status=open @@ -100,9 +98,9 @@ echo "" echo "=== Plugin: ticket-ls -a alice ===" /ticket/ticket ls -a alice -echo "" -echo "=== Done ===" +# Other commands that work inside bashkit: +# /ticket/ticket show — display ticket with relationships +# /ticket/ticket link — link tickets together +# /ticket/ticket dep cycle — find dependency cycles +# /ticket/ticket reopen — reopen a closed ticket ' - -echo "" -echo "Success!"