kata-cli 0.7.0__tar.gz

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 (139) hide show
  1. kata_cli-0.7.0/.claude/settings.json +26 -0
  2. kata_cli-0.7.0/.claude/skills/cicd/SKILL.md +169 -0
  3. kata_cli-0.7.0/.claude/skills/cicd/scripts/_resolve-nick.sh +43 -0
  4. kata_cli-0.7.0/.claude/skills/cicd/scripts/portability-lint.sh +61 -0
  5. kata_cli-0.7.0/.claude/skills/cicd/scripts/pr-reply.sh +77 -0
  6. kata_cli-0.7.0/.claude/skills/cicd/scripts/pr-status.sh +163 -0
  7. kata_cli-0.7.0/.claude/skills/cicd/scripts/workflow.sh +157 -0
  8. kata_cli-0.7.0/.claude/skills/code-lookup/SKILL.md +100 -0
  9. kata_cli-0.7.0/.claude/skills/code-lookup/scripts/classify.sh +4 -0
  10. kata_cli-0.7.0/.claude/skills/code-lookup/scripts/grep.sh +4 -0
  11. kata_cli-0.7.0/.claude/skills/code-lookup/scripts/recent.sh +4 -0
  12. kata_cli-0.7.0/.claude/skills/communicate/SKILL.md +322 -0
  13. kata_cli-0.7.0/.claude/skills/communicate/scripts/fetch-issues.sh +59 -0
  14. kata_cli-0.7.0/.claude/skills/communicate/scripts/mesh-message.sh +74 -0
  15. kata_cli-0.7.0/.claude/skills/communicate/scripts/post-comment.sh +65 -0
  16. kata_cli-0.7.0/.claude/skills/communicate/scripts/post-issue.sh +71 -0
  17. kata_cli-0.7.0/.claude/skills/communicate/scripts/templates/skill-update-brief.md +101 -0
  18. kata_cli-0.7.0/.claude/skills/eval/SKILL.md +263 -0
  19. kata_cli-0.7.0/.claude/skills/repo-map/SKILL.md +106 -0
  20. kata_cli-0.7.0/.claude/skills/repo-map/scripts/connections.sh +4 -0
  21. kata_cli-0.7.0/.claude/skills/repo-map/scripts/graph.sh +4 -0
  22. kata_cli-0.7.0/.claude/skills/repo-map/scripts/profile.sh +4 -0
  23. kata_cli-0.7.0/.claude/skills/run-tests/SKILL.md +50 -0
  24. kata_cli-0.7.0/.claude/skills/run-tests/scripts/test.sh +52 -0
  25. kata_cli-0.7.0/.claude/skills/sonarclaude/SKILL.md +84 -0
  26. kata_cli-0.7.0/.claude/skills/sonarclaude/scripts/sonar.sh +263 -0
  27. kata_cli-0.7.0/.claude/skills/version-bump/SKILL.md +66 -0
  28. kata_cli-0.7.0/.claude/skills/version-bump/scripts/bump.py +178 -0
  29. kata_cli-0.7.0/.claude/skills.local.yaml.example +19 -0
  30. kata_cli-0.7.0/.flake8 +19 -0
  31. kata_cli-0.7.0/.github/workflows/publish.yml +103 -0
  32. kata_cli-0.7.0/.github/workflows/security-checks.yml +41 -0
  33. kata_cli-0.7.0/.github/workflows/tests.yml +130 -0
  34. kata_cli-0.7.0/.gitignore +234 -0
  35. kata_cli-0.7.0/.markdownlint-cli2.yaml +22 -0
  36. kata_cli-0.7.0/.pre-commit-config.yaml +37 -0
  37. kata_cli-0.7.0/CHANGELOG.md +229 -0
  38. kata_cli-0.7.0/CLAUDE.md +143 -0
  39. kata_cli-0.7.0/LICENSE +21 -0
  40. kata_cli-0.7.0/PKG-INFO +36 -0
  41. kata_cli-0.7.0/README.md +18 -0
  42. kata_cli-0.7.0/culture.yaml +3 -0
  43. kata_cli-0.7.0/docs/eval-rounds/2026-05-15-round-01.md +101 -0
  44. kata_cli-0.7.0/docs/eval-rounds/2026-05-15-smoke-02-examples.md +385 -0
  45. kata_cli-0.7.0/docs/skill-sources.md +29 -0
  46. kata_cli-0.7.0/docs/superpowers/plans/2026-05-15-repo-map.md +3148 -0
  47. kata_cli-0.7.0/docs/superpowers/plans/2026-05-15-scripts-eval-harness.md +3019 -0
  48. kata_cli-0.7.0/docs/superpowers/plans/2026-05-16-seer-classify.md +1461 -0
  49. kata_cli-0.7.0/docs/superpowers/specs/2026-05-15-repo-map-design.md +386 -0
  50. kata_cli-0.7.0/docs/superpowers/specs/2026-05-15-scripts-eval-harness-design.md +534 -0
  51. kata_cli-0.7.0/docs/superpowers/specs/2026-05-16-seer-classify-design.md +275 -0
  52. kata_cli-0.7.0/experiments/__init__.py +0 -0
  53. kata_cli-0.7.0/experiments/scripts_eval/README.md +56 -0
  54. kata_cli-0.7.0/experiments/scripts_eval/RUNBOOK.md +188 -0
  55. kata_cli-0.7.0/experiments/scripts_eval/__init__.py +0 -0
  56. kata_cli-0.7.0/experiments/scripts_eval/_io.py +62 -0
  57. kata_cli-0.7.0/experiments/scripts_eval/backfill.py +343 -0
  58. kata_cli-0.7.0/experiments/scripts_eval/corpus.py +132 -0
  59. kata_cli-0.7.0/experiments/scripts_eval/corpus.yaml +304 -0
  60. kata_cli-0.7.0/experiments/scripts_eval/hooks/__init__.py +0 -0
  61. kata_cli-0.7.0/experiments/scripts_eval/hooks/post_tool.py +116 -0
  62. kata_cli-0.7.0/experiments/scripts_eval/hooks/pre_tool.py +73 -0
  63. kata_cli-0.7.0/experiments/scripts_eval/judge.py +479 -0
  64. kata_cli-0.7.0/experiments/scripts_eval/judge_rubric.md +28 -0
  65. kata_cli-0.7.0/experiments/scripts_eval/manifest.py +102 -0
  66. kata_cli-0.7.0/experiments/scripts_eval/report.py +143 -0
  67. kata_cli-0.7.0/experiments/scripts_eval/results/.gitkeep +0 -0
  68. kata_cli-0.7.0/experiments/scripts_eval/summarize.py +272 -0
  69. kata_cli-0.7.0/experiments/scripts_eval/switch-arm.sh +91 -0
  70. kata_cli-0.7.0/experiments/scripts_eval/trial.py +367 -0
  71. kata_cli-0.7.0/experiments/scripts_eval/validate.py +82 -0
  72. kata_cli-0.7.0/pyproject.toml +90 -0
  73. kata_cli-0.7.0/seer/__init__.py +34 -0
  74. kata_cli-0.7.0/seer/__main__.py +8 -0
  75. kata_cli-0.7.0/seer/cli/__init__.py +117 -0
  76. kata_cli-0.7.0/seer/cli/_commands/__init__.py +1 -0
  77. kata_cli-0.7.0/seer/cli/_commands/classify.py +40 -0
  78. kata_cli-0.7.0/seer/cli/_commands/explain.py +44 -0
  79. kata_cli-0.7.0/seer/cli/_commands/grep.py +44 -0
  80. kata_cli-0.7.0/seer/cli/_commands/learn.py +49 -0
  81. kata_cli-0.7.0/seer/cli/_commands/recent.py +52 -0
  82. kata_cli-0.7.0/seer/cli/_commands/whoami.py +42 -0
  83. kata_cli-0.7.0/seer/cli/_errors.py +59 -0
  84. kata_cli-0.7.0/seer/cli/_output.py +47 -0
  85. kata_cli-0.7.0/seer/lookup/__init__.py +25 -0
  86. kata_cli-0.7.0/seer/lookup/ast_scope.py +74 -0
  87. kata_cli-0.7.0/seer/lookup/classify.py +301 -0
  88. kata_cli-0.7.0/seer/lookup/grep_context.py +160 -0
  89. kata_cli-0.7.0/seer/lookup/recent_outline.py +304 -0
  90. kata_cli-0.7.0/seer/lookup/render.py +41 -0
  91. kata_cli-0.7.0/seer/repo/__init__.py +9 -0
  92. kata_cli-0.7.0/seer/repo/__main__.py +228 -0
  93. kata_cli-0.7.0/seer/repo/config.py +57 -0
  94. kata_cli-0.7.0/seer/repo/connections.py +298 -0
  95. kata_cli-0.7.0/seer/repo/detect.py +86 -0
  96. kata_cli-0.7.0/seer/repo/errors.py +81 -0
  97. kata_cli-0.7.0/seer/repo/graph.py +182 -0
  98. kata_cli-0.7.0/seer/repo/manifest.py +36 -0
  99. kata_cli-0.7.0/seer/repo/profile.py +700 -0
  100. kata_cli-0.7.0/seer/repo/render.py +470 -0
  101. kata_cli-0.7.0/sonar-project.properties +17 -0
  102. kata_cli-0.7.0/tests/__init__.py +0 -0
  103. kata_cli-0.7.0/tests/scripts_eval/__init__.py +0 -0
  104. kata_cli-0.7.0/tests/scripts_eval/fixtures/.gitkeep +0 -0
  105. kata_cli-0.7.0/tests/scripts_eval/fixtures/corpus_minimal.yaml +28 -0
  106. kata_cli-0.7.0/tests/scripts_eval/fixtures/sidechain_min.jsonl +70 -0
  107. kata_cli-0.7.0/tests/scripts_eval/test_backfill.py +290 -0
  108. kata_cli-0.7.0/tests/scripts_eval/test_corpus.py +60 -0
  109. kata_cli-0.7.0/tests/scripts_eval/test_hooks_post_tool.py +104 -0
  110. kata_cli-0.7.0/tests/scripts_eval/test_hooks_pre_tool.py +91 -0
  111. kata_cli-0.7.0/tests/scripts_eval/test_io.py +44 -0
  112. kata_cli-0.7.0/tests/scripts_eval/test_judge.py +513 -0
  113. kata_cli-0.7.0/tests/scripts_eval/test_manifest.py +70 -0
  114. kata_cli-0.7.0/tests/scripts_eval/test_report.py +102 -0
  115. kata_cli-0.7.0/tests/scripts_eval/test_summarize.py +332 -0
  116. kata_cli-0.7.0/tests/scripts_eval/test_trial.py +336 -0
  117. kata_cli-0.7.0/tests/scripts_eval/test_validate.py +106 -0
  118. kata_cli-0.7.0/tests/test_ast_scope.py +78 -0
  119. kata_cli-0.7.0/tests/test_classify.py +319 -0
  120. kata_cli-0.7.0/tests/test_classify_render.py +80 -0
  121. kata_cli-0.7.0/tests/test_cli_chassis.py +48 -0
  122. kata_cli-0.7.0/tests/test_cli_errors.py +84 -0
  123. kata_cli-0.7.0/tests/test_cli_output.py +104 -0
  124. kata_cli-0.7.0/tests/test_cli_stubs.py +71 -0
  125. kata_cli-0.7.0/tests/test_grep_cmd.py +153 -0
  126. kata_cli-0.7.0/tests/test_grep_context.py +172 -0
  127. kata_cli-0.7.0/tests/test_package.py +53 -0
  128. kata_cli-0.7.0/tests/test_recent_cmd.py +141 -0
  129. kata_cli-0.7.0/tests/test_recent_outline.py +266 -0
  130. kata_cli-0.7.0/tests/test_repo_cli.py +160 -0
  131. kata_cli-0.7.0/tests/test_repo_config.py +76 -0
  132. kata_cli-0.7.0/tests/test_repo_connections.py +113 -0
  133. kata_cli-0.7.0/tests/test_repo_detect.py +76 -0
  134. kata_cli-0.7.0/tests/test_repo_errors.py +52 -0
  135. kata_cli-0.7.0/tests/test_repo_graph.py +118 -0
  136. kata_cli-0.7.0/tests/test_repo_manifest.py +62 -0
  137. kata_cli-0.7.0/tests/test_repo_profile.py +691 -0
  138. kata_cli-0.7.0/tests/test_repo_render.py +465 -0
  139. kata_cli-0.7.0/uv.lock +1086 -0
@@ -0,0 +1,26 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "Agent",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "uv run --group experiments python -m experiments.scripts_eval.hooks.pre_tool"
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "PostToolUse": [
15
+ {
16
+ "matcher": ".*",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "uv run --group experiments python -m experiments.scripts_eval.hooks.post_tool"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
26
+ }
@@ -0,0 +1,169 @@
1
+ ---
2
+ name: cicd
3
+ description: >
4
+ Steward's CI/CD lane, layered on `agex pr`. Delegates lint / open /
5
+ read / reply / delta to agex; adds two steward extensions — `status`
6
+ (SonarCloud quality gate + hotspots + unresolved-thread tally) and
7
+ `await` (read --wait + status with non-zero exit on Sonar ERROR or
8
+ unresolved threads). Use when: creating PRs in steward, handling
9
+ review feedback, polling CI status, or the user says "create PR",
10
+ "review comments", "address feedback", "resolve threads". Renamed
11
+ from `pr-review` in steward 0.7.0; rebased on agex in 0.12.0.
12
+ seer-cli divergence: `scripts/portability-lint.sh` drops the GNU-only
13
+ `xargs -r` flag for BSD/macOS portability — see `docs/skill-sources.md`.
14
+ ---
15
+
16
+ # CI/CD — Steward edition
17
+
18
+ `agex pr` (in `agentculture/agex-cli`) is the upstream for the
19
+ five core PR-lifecycle verbs — `lint`, `open`, `read`, `reply`,
20
+ `delta`. Steward used to vendor parallel scripts for each; in 0.12.0
21
+ those vendored copies were dropped in favor of delegating to `agex`.
22
+ What's left in this skill is **the steward-specific gating layer**:
23
+
24
+ - `status` — SonarCloud quality gate, OPEN issues, hotspots, deploy
25
+ preview URL, unresolved-inline-thread tally.
26
+ - `await` — composes `agex pr read --wait` with `status` and gates on
27
+ Sonar `ERROR` / unresolved threads. The single command to run after
28
+ pushing a fix when you want "wake me when this PR is triage-able."
29
+
30
+ Those two are the steward unique surface today. They're filed as a
31
+ feature ask upstream
32
+ ([agex-cli#41](https://github.com/agentculture/agex-cli/issues/41));
33
+ once they land they migrate out of this skill.
34
+
35
+ The workflow is encapsulated in `scripts/workflow.sh` — follow that
36
+ (or call `agex pr` directly).
37
+
38
+ ## Prerequisites
39
+
40
+ Hard requirements: `agex` (>=0.1), `gh` (GitHub CLI), `jq`, `bash`,
41
+ `python3` (stdlib only), `curl` (used by `pr-status.sh`).
42
+
43
+ Install agex once:
44
+
45
+ ```bash
46
+ uv tool install agex-cli # or: pip install --user agex-cli
47
+ ```
48
+
49
+ Soft requirement: `PyYAML` is needed **only for suffix mode** of the
50
+ sibling `agent-config` skill, where it parses Culture's server
51
+ manifest. Every `cicd` script works without it; suffix mode prints a
52
+ clear install hint when invoked without it.
53
+
54
+ Per-machine paths (sibling-project layout) live in
55
+ `.claude/skills.local.yaml`; see the committed `.example` for the
56
+ schema. `agex pr delta` reads the same file.
57
+
58
+ ## How to run
59
+
60
+ `scripts/workflow.sh` is the entry point. Subcommands:
61
+
62
+ | Command | What it does |
63
+ |---------|--------------|
64
+ | `workflow.sh lint` | `agex pr lint --exit-on-violation` — portability + alignment-trigger check. |
65
+ | `workflow.sh open [gh-flags]` | `agex pr open --delayed-read`. Creates the PR, then polls 180s for an initial briefing. `--title TITLE` required; body via `--body-file PATH` or stdin. |
66
+ | `workflow.sh read [PR] [--wait N]` | `agex pr read`. One-shot briefing (CI checks, SonarCloud gate + new issues, all comments, next-step footer). Pass `--wait N` to poll up to N seconds for required reviewers. |
67
+ | `workflow.sh reply <PR>` | `agex pr reply <PR>` — batch JSONL replies (stdin) + thread resolve. agex auto-signs from `culture.yaml`. |
68
+ | `workflow.sh delta` | `agex pr delta` — sibling alignment dump. |
69
+ | `workflow.sh status <PR>` | **Steward extension.** `pr-status.sh` — Sonar gate, OPEN issues, hotspots, unresolved-thread breakdown, deploy preview URL. Authoritative gate for `await`. |
70
+ | `workflow.sh await <PR>` | **Steward extension.** `agex pr read --wait` then `status`. Exits non-zero on Sonar ERROR or unresolved threads. Tunables: `STEWARD_PR_AWAIT_WAIT` (default 1800s passed to `--wait`), `STEWARD_PR_AWAIT_SECONDS` (legacy fixed pre-sleep, deprecated). |
71
+ | `workflow.sh help` | Print the list. |
72
+
73
+ You can also call `agex pr <verb>` directly — `workflow.sh` is a
74
+ typing-saver around the same verbs. The steward `status` and `await`
75
+ extensions only have shell entry points.
76
+
77
+ The vendored single-comment helper `pr-reply.sh` (plus its
78
+ `_resolve-nick.sh` dependency) is still shipped — pinned by
79
+ `tests/test_pr_reply_signature.py` and `tests/test_resolve_nick.py`,
80
+ and useful when a one-off reply doesn't merit batch JSONL. It is not
81
+ called by `workflow.sh` anymore. The vendored `portability-lint.sh`
82
+ is also still shipped — `steward doctor`'s portability check runs it
83
+ directly against target repos. Both are scheduled for follow-up
84
+ migration to agex.
85
+
86
+ ## Long waits (background polling)
87
+
88
+ `agex pr read --wait N` polls in-session for up to N seconds. The
89
+ Anthropic prompt cache has a 5-minute TTL; sleeping past it burns
90
+ context every cache miss. Two ways to drive the wait:
91
+
92
+ - **Synchronous** — `workflow.sh await <PR>` after `gh pr create` /
93
+ `workflow.sh open`. Fine when readiness is expected within ~5
94
+ minutes.
95
+ - **Asynchronous** — for longer waits, run `agex pr read --wait NNN`
96
+ inside a background subagent (Agent tool, `run_in_background: true`)
97
+ so the main session only pays the cache cost when readiness fires.
98
+ The subagent's only job is to invoke `agex pr read --wait` and echo
99
+ its headline back. The parent triages with `workflow.sh await`
100
+ when the notification arrives. The user can interrupt with
101
+ TaskStop.
102
+
103
+ This pattern was originally borrowed from sibling repo
104
+ [`agentculture/cfafi`](https://github.com/agentculture/cfafi)'s `poll`
105
+ skill. The async guidance is also filed upstream
106
+ ([agex-cli#41](https://github.com/agentculture/agex-cli/issues/41)).
107
+
108
+ ## Conventions
109
+
110
+ `agex pr` emits a **"Next step:"** footer at the end of every command
111
+ that names the right next verb (the same chain `agex learn cicd`
112
+ documents) — follow that rather than memorizing an order. `workflow.sh
113
+ help` mirrors the verb table when you need the steward-flavored
114
+ extensions (`status`, `await`) on top.
115
+
116
+ Branch naming: `fix/<desc>`, `feat/<desc>`, `docs/<desc>`,
117
+ `skill/<name>`. PR / comment signature: `- <nick> (Claude)`, where
118
+ `<nick>` is resolved by `agex` from the agent's own `culture.yaml`
119
+ (first agent's `suffix`), falling back to the git-repo basename. agex
120
+ auto-appends the signature on `pr open` and `pr reply` only when the
121
+ body isn't already signed.
122
+
123
+ ## Triage rules
124
+
125
+ For every comment, decide **FIX** or **PUSHBACK** with reasoning.
126
+
127
+ Default to **FIX** for: portability complaints (always valid for
128
+ Steward — recurring bug class), test or doc requests, style nits
129
+ aligned with workspace conventions.
130
+
131
+ Default to **PUSHBACK** for: architecture opinions that conflict with
132
+ workspace `CLAUDE.md` or the all-backends rule; greenfield
133
+ false-positives (e.g. "add tests" before there's any source — defer
134
+ to a later PR, don't refuse).
135
+
136
+ ### Alignment-delta rule
137
+
138
+ If the PR touches `CLAUDE.md`, `culture.yaml`, or anything under
139
+ `.claude/skills/`, run `workflow.sh delta` **before** declaring FIX or
140
+ PUSHBACK on each comment. Note any sibling that needs a follow-up PR
141
+ and mention it in your reply.
142
+
143
+ ## Greenfield-aware steps
144
+
145
+ The lint and the workflow script are always-on. Stack-specific steps
146
+ are conditional and currently no-op (greenfield repo):
147
+
148
+ ```bash
149
+ [ -d tests ] && [ -f pyproject.toml ] && uv run pytest tests/ -x -q
150
+ [ -f pyproject.toml ] && bump_version_per_project_convention # see project README
151
+ [ -f .markdownlint-cli2.yaml ] && markdownlint-cli2 "$(git diff --name-only --cached '*.md')"
152
+ ```
153
+
154
+ Revisit each line as the corresponding stack element actually lands.
155
+ A `pr lint --extra=tests,version,markdown` ask is filed upstream
156
+ ([agex-cli#41](https://github.com/agentculture/agex-cli/issues/41)).
157
+
158
+ ## Reply etiquette
159
+
160
+ Every comment must get a reply — no silent fixes. `agex pr reply`
161
+ includes thread-resolve by default. Reference the review-comment IDs
162
+ in the fix-up commit message.
163
+
164
+ The `status` extension queries SonarCloud directly (it predates the
165
+ upstream Sonar integration in `agex pr read`). Both surfaces are
166
+ trustworthy — `agex pr read` for display in the briefing, `status` for
167
+ the gate. Steward isn't yet a registered mesh agent, so the
168
+ post-merge IRC ping that Culture's `pr-review` includes is still
169
+ skipped — that returns when Steward joins the mesh.
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Resolve the agent's nick for GitHub message signing.
5
+ # Order: first agent's `suffix` in <repo-root>/culture.yaml,
6
+ # then basename of the git repo root.
7
+ # Prints the nick to stdout. Always exits 0 — pr-reply.sh needs *some*
8
+ # nick to sign with — but if a culture.yaml exists and we couldn't
9
+ # extract a suffix from it, emits a stderr warning so a misconfigured
10
+ # manifest doesn't silently mask itself behind the basename fallback.
11
+
12
+ repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)"
13
+ if [[ -z "$repo_root" ]]; then
14
+ repo_root="$PWD"
15
+ fi
16
+
17
+ manifest="$repo_root/culture.yaml"
18
+
19
+ if [[ -f "$manifest" ]]; then
20
+ if ! command -v python3 >/dev/null 2>&1; then
21
+ echo "_resolve-nick: python3 not found; cannot parse $manifest, falling back to repo basename" >&2
22
+ else
23
+ nick="$(python3 - "$manifest" <<'PY' 2>/dev/null || true
24
+ import re, sys
25
+ path = sys.argv[1]
26
+ with open(path, encoding="utf-8") as f:
27
+ for raw in f:
28
+ line = raw.rstrip("\n")
29
+ m = re.match(r"^[\s-]*\s*suffix:\s*(\S+)", line)
30
+ if m:
31
+ print(m.group(1).strip("'\""))
32
+ break
33
+ PY
34
+ )"
35
+ if [[ -n "$nick" ]]; then
36
+ printf '%s\n' "$nick"
37
+ exit 0
38
+ fi
39
+ echo "_resolve-nick: $manifest exists but no suffix could be parsed; falling back to repo basename" >&2
40
+ fi
41
+ fi
42
+
43
+ basename "$repo_root"
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bash
2
+ # Portability lint: catch path leaks and per-user config dependencies in
3
+ # committed docs/configs before they ship in a PR. Steward's recurring bug
4
+ # class.
5
+ #
6
+ # Usage: portability-lint.sh [--all]
7
+ # default: lint files modified vs HEAD (staged + unstaged)
8
+ # --all: lint all tracked files
9
+ #
10
+ # Exits 0 if clean, 1 if any leak is found.
11
+
12
+ set -euo pipefail
13
+
14
+ mode="${1:-diff}"
15
+ case "$mode" in
16
+ --all) files=$(git ls-files -- ':(exclude)*.lock') ;;
17
+ diff|--diff) files=$(git diff --diff-filter=AMR --name-only HEAD -- ':(exclude)*.lock') ;;
18
+ *) echo "Usage: $(basename "$0") [--all]" >&2; exit 2 ;;
19
+ esac
20
+
21
+ [ -z "$files" ] && { echo "(no files to check)"; exit 0; }
22
+
23
+ # ----- Check 1: hard-coded /home/<user>/... paths -----
24
+ # seer-cli divergence: `xargs -r` is GNU-only and fails on BSD/macOS xargs.
25
+ # `$files` is already guarded non-empty above, so `-r` is redundant — dropped.
26
+ hits1=$(echo "$files" | xargs grep -nE '/home/[a-z][a-z0-9_-]+/' 2>/dev/null || true)
27
+
28
+ # ----- Check 2: per-user dotfile *config* refs in committed docs/configs -----
29
+ # Carve-outs (allowed, NOT flagged):
30
+ # - ~/.claude/skills/<x>/scripts/ vendored tool calls
31
+ # - ~/.culture/ Culture mesh data this skill is supposed to read
32
+ md_yaml=$(echo "$files" | grep -E '\.(md|ya?ml|toml|json|jsonc)$' || true)
33
+ if [ -n "$md_yaml" ]; then
34
+ # seer-cli divergence: `xargs -r` is GNU-only; `$md_yaml` is guarded
35
+ # non-empty by the enclosing `if`, so `-r` is redundant — dropped.
36
+ hits2=$(echo "$md_yaml" | xargs grep -nE '~/\.[A-Za-z]' 2>/dev/null \
37
+ | grep -vE '~/\.claude/skills/[^[:space:]"]+/scripts/' \
38
+ | grep -vE '~/\.culture/' \
39
+ || true)
40
+ else
41
+ hits2=""
42
+ fi
43
+
44
+ fail=0
45
+ if [ -n "$hits1" ]; then
46
+ echo "❌ Hard-coded /home/<user>/ paths:"
47
+ echo "$hits1" | sed 's/^/ /'
48
+ echo " Fix: use ../sibling, repo URL, or \$WORKSPACE/sibling instead."
49
+ fail=1
50
+ fi
51
+ if [ -n "$hits2" ]; then
52
+ [ "$fail" -eq 1 ] && echo
53
+ echo "❌ Per-user ~/.<dotfile> config refs in committed doc/config:"
54
+ echo "$hits2" | sed 's/^/ /'
55
+ echo " Allowed carve-outs: ~/.claude/skills/.../scripts/ (tool calls), ~/.culture/ (mesh data)."
56
+ echo " Otherwise: commit a repo-local config or document a portable lookup."
57
+ fail=1
58
+ fi
59
+
60
+ [ "$fail" -eq 0 ] && echo "✓ portability lint clean ($(echo "$files" | wc -l | tr -d ' ') files checked)"
61
+ exit $fail
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Reply to a PR review comment, optionally resolve its thread.
5
+ # Usage: pr-reply.sh [--repo OWNER/REPO] [--resolve] PR_NUMBER COMMENT_ID "body"
6
+
7
+ REPO=""
8
+ RESOLVE=false
9
+ PRINT_BODY=false
10
+
11
+ while [[ $# -gt 0 ]]; do
12
+ case "$1" in
13
+ --repo) REPO="$2"; shift 2 ;;
14
+ --resolve) RESOLVE=true; shift ;;
15
+ --print-body) PRINT_BODY=true; shift ;;
16
+ *) break ;;
17
+ esac
18
+ done
19
+
20
+ PR_NUMBER="${1:?Usage: pr-reply.sh [--repo OWNER/REPO] [--resolve] [--print-body] PR_NUMBER COMMENT_ID \"body\"}"
21
+ COMMENT_ID="${2:?Missing COMMENT_ID}"
22
+ BODY="${3:?Missing reply body}"
23
+
24
+ if [[ "$PRINT_BODY" != true && -z "$REPO" ]]; then
25
+ REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
26
+ fi
27
+
28
+ # Sign with the agent's nick. Resolved per invocation so siblings that
29
+ # vendor this skill pick up their own culture.yaml suffix automatically.
30
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
31
+ NICK="$("$SCRIPT_DIR/_resolve-nick.sh")"
32
+ SIG="- ${NICK} (Claude)"
33
+ if ! printf '%s' "$BODY" | grep -qFx -- "$SIG"; then
34
+ BODY="${BODY}
35
+
36
+ ${SIG}"
37
+ fi
38
+
39
+ if [[ "$PRINT_BODY" == true ]]; then
40
+ printf '%s\n' "$BODY"
41
+ exit 0
42
+ fi
43
+
44
+ # Post reply
45
+ REPLY_URL=$(gh api "repos/$REPO/pulls/$PR_NUMBER/comments/$COMMENT_ID/replies" \
46
+ -f body="$BODY" \
47
+ --jq '.html_url')
48
+ echo "Replied: $REPLY_URL"
49
+
50
+ # Resolve thread if requested
51
+ if [[ "$RESOLVE" == true ]]; then
52
+ # Find the thread ID for this comment
53
+ THREAD_ID=$(gh api graphql -f query="
54
+ {
55
+ repository(owner: \"${REPO%%/*}\", name: \"${REPO##*/}\") {
56
+ pullRequest(number: $PR_NUMBER) {
57
+ reviewThreads(first: 100) {
58
+ nodes {
59
+ id
60
+ comments(first: 100) {
61
+ nodes { databaseId }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }" --jq ".data.repository.pullRequest.reviewThreads.nodes[] | select(any(.comments.nodes[]; .databaseId == $COMMENT_ID)) | .id")
68
+
69
+ if [[ -n "$THREAD_ID" ]]; then
70
+ RESOLVED=$(gh api graphql -f query="
71
+ mutation { resolveReviewThread(input: {threadId: \"$THREAD_ID\"}) { thread { isResolved } } }
72
+ " --jq '.data.resolveReviewThread.thread.isResolved')
73
+ echo "Resolved: $RESOLVED (thread $THREAD_ID)"
74
+ else
75
+ echo "Warning: could not find thread for comment $COMMENT_ID"
76
+ fi
77
+ fi
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env bash
2
+ # pr-status.sh — one-shot status overview for a Steward PR.
3
+ #
4
+ # Combines five things review feedback usually scatters across:
5
+ # 1. PR state (open / merged / closed) + branch + author
6
+ # 2. CI checks (build / lint / unit / sonarcloud / cf-pages / etc.)
7
+ # 3. Review-bot pipeline status (Copilot, qodo, SonarCloud, Cloudflare)
8
+ # 4. SonarCloud quality gate + open-issue count
9
+ # 5. Inline-thread resolved-vs-unresolved tally
10
+ #
11
+ # Usage: scripts/pr-status.sh [--repo OWNER/REPO] [--sonar-key KEY] PR_NUMBER
12
+ #
13
+ # Defaults:
14
+ # --repo auto-detected via `gh repo view`
15
+ # --sonar-key derived from repo as `<owner>_<name>` (SonarCloud convention)
16
+ #
17
+ # Requires: gh, jq, curl, python3.
18
+
19
+ set -euo pipefail
20
+
21
+ REPO=""
22
+ SONAR_KEY=""
23
+
24
+ while [[ $# -gt 0 ]]; do
25
+ case "$1" in
26
+ --repo) REPO="$2"; shift 2 ;;
27
+ --sonar-key) SONAR_KEY="$2"; shift 2 ;;
28
+ *) break ;;
29
+ esac
30
+ done
31
+
32
+ PR_NUMBER="${1:?Usage: pr-status.sh [--repo OWNER/REPO] [--sonar-key KEY] PR_NUMBER}"
33
+
34
+ if [[ -z "$REPO" ]]; then
35
+ REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
36
+ fi
37
+ # Sonar key precedence: explicit --sonar-key flag > SONAR_PROJECT_KEY env >
38
+ # `<owner>_<repo>` derivation. Mirrors pr-comments.sh so SKILL.md's claim
39
+ # that the env var works for both scripts is true.
40
+ if [[ -z "$SONAR_KEY" ]]; then
41
+ SONAR_KEY="${SONAR_PROJECT_KEY:-${REPO%%/*}_${REPO##*/}}"
42
+ fi
43
+
44
+ # ── 1. PR header ──────────────────────────────────────────────────────────
45
+ PR_JSON=$(gh pr view "$PR_NUMBER" --json \
46
+ number,title,state,isDraft,mergedAt,mergedBy,baseRefName,headRefName,author,url)
47
+
48
+ echo "════════════════════════════════════════════════════════════════════"
49
+ echo "$PR_JSON" | jq -r '
50
+ "PR #\(.number) — \(.title)",
51
+ " \(.url)",
52
+ " Author: \(.author.login)",
53
+ " Branch: \(.headRefName) → \(.baseRefName)",
54
+ " State: \(if .state == "MERGED" then "MERGED at \(.mergedAt) by \(.mergedBy.login)" elif .state == "OPEN" and .isDraft then "OPEN (draft)" else .state end)"
55
+ '
56
+ echo "════════════════════════════════════════════════════════════════════"
57
+
58
+ # ── 2. CI checks ──────────────────────────────────────────────────────────
59
+ echo
60
+ echo "── CI checks ─────────────────────────────────────────────────────────"
61
+ # `gh pr checks` exits non-zero when checks are still pending/failing.
62
+ # We don't care about its exit code here; capture and pretty-print.
63
+ CHECKS=$(gh pr checks "$PR_NUMBER" 2>/dev/null || true)
64
+ if [[ -z "$CHECKS" ]]; then
65
+ echo " (no checks reported)"
66
+ else
67
+ echo "$CHECKS" | awk -F'\t' '
68
+ {
69
+ name = $1
70
+ state = $2
71
+ dur = $3
72
+ sym = "?"
73
+ if (state == "pass") sym = "✅"
74
+ else if (state == "fail") sym = "❌"
75
+ else if (state == "skipping") sym = "⏭"
76
+ else if (state == "pending" || state == "queued" || state == "in_progress") sym = "…"
77
+ printf " %s %-22s %-10s %s\n", sym, name, state, dur
78
+ }
79
+ '
80
+ fi
81
+
82
+ # ── 3. Review bots & comment pipeline ────────────────────────────────────
83
+ echo
84
+ echo "── Review pipeline ───────────────────────────────────────────────────"
85
+
86
+ # Inline-thread tally via GraphQL (resolved vs unresolved).
87
+ THREADS_JSON=$(gh api graphql -f query="
88
+ {
89
+ repository(owner: \"${REPO%%/*}\", name: \"${REPO##*/}\") {
90
+ pullRequest(number: $PR_NUMBER) {
91
+ reviewThreads(first: 100) {
92
+ nodes { id isResolved comments(first: 1) { nodes { author { login } } } }
93
+ }
94
+ }
95
+ }
96
+ }" --jq '.data.repository.pullRequest.reviewThreads.nodes')
97
+
98
+ INLINE_TOTAL=$(echo "$THREADS_JSON" | jq 'length')
99
+ INLINE_RESOLVED=$(echo "$THREADS_JSON" | jq '[.[] | select(.isResolved)] | length')
100
+ INLINE_PENDING=$((INLINE_TOTAL - INLINE_RESOLVED))
101
+
102
+ # Per-bot inline counts.
103
+ COPILOT_INLINE=$(echo "$THREADS_JSON" | jq '[.[] | select((.comments.nodes[0].author.login // "") | startswith("Copilot"))] | length')
104
+ QODO_INLINE=$(echo "$THREADS_JSON" | jq '[.[] | select((.comments.nodes[0].author.login // "") | startswith("qodo"))] | length')
105
+
106
+ # Issue-level comments (qodo summary, sonarcloud quality-gate body, cf-pages preview, etc.).
107
+ # Skip --paginate to avoid array concatenation; per_page=100 covers typical PRs.
108
+ ISSUE=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments?per_page=100")
109
+ QODO_ISSUE=$(echo "$ISSUE" | jq '[.[] | select((.user.login // "") | startswith("qodo"))] | length')
110
+ SONARQUBE_ISSUE=$(echo "$ISSUE" | jq '[.[] | select((.user.login // "") | startswith("sonarqubecloud"))] | length')
111
+ CFPAGES_ISSUE=$(echo "$ISSUE" | jq '[.[] | select((.user.login // "") | test("cloudflare"))] | length')
112
+ COPILOT_TOPLEVEL=$(gh api "repos/$REPO/pulls/$PR_NUMBER/reviews?per_page=100" \
113
+ | jq '[.[] | select((.user.login // "") | startswith("copilot")) | select((.body // "") != "")] | length')
114
+
115
+ # Cloudflare deploy URL hidden in issue-comment bodies (look for pages.dev).
116
+ CF_URL=$(echo "$ISSUE" | jq -r '[.[].body // "" | scan("https?://[a-z0-9.-]+\\.pages\\.dev[^\\s)\"<]*")] | first // ""')
117
+
118
+ printf " %-12s %s\n" "Copilot" "$([[ "$COPILOT_TOPLEVEL" -gt 0 || "$COPILOT_INLINE" -gt 0 ]] && echo "✅ overview×$COPILOT_TOPLEVEL, inline×$COPILOT_INLINE" || echo "— no posts yet")"
119
+ printf " %-12s %s\n" "qodo" "$([[ "$QODO_ISSUE" -gt 0 || "$QODO_INLINE" -gt 0 ]] && echo "✅ summary×$QODO_ISSUE, inline×$QODO_INLINE" || echo "— no posts yet")"
120
+ printf " %-12s %s\n" "Cloudflare" "$([[ -n "$CF_URL" ]] && echo "✅ $CF_URL" || ([[ "$CFPAGES_ISSUE" -gt 0 ]] && echo "✅ ($CFPAGES_ISSUE comments)" || echo "— no deploy preview"))"
121
+
122
+ # ── 4. SonarCloud quality gate + open issues ─────────────────────────────
123
+ SONAR_QG=$(curl -s "https://sonarcloud.io/api/qualitygates/project_status?projectKey=${SONAR_KEY}&pullRequest=${PR_NUMBER}")
124
+ SONAR_QG_STATUS=$(echo "$SONAR_QG" | jq -r '.projectStatus.status // "UNKNOWN"')
125
+ SONAR_OPEN=$(curl -s "https://sonarcloud.io/api/issues/search?componentKeys=${SONAR_KEY}&pullRequest=${PR_NUMBER}&statuses=OPEN,CONFIRMED&ps=1" \
126
+ | jq -r '.total // 0')
127
+ SONAR_HOTSPOTS=$(curl -s "https://sonarcloud.io/api/hotspots/search?projectKey=${SONAR_KEY}&pullRequest=${PR_NUMBER}&status=TO_REVIEW&ps=1" \
128
+ | jq -r '.paging.total // 0')
129
+
130
+ case "$SONAR_QG_STATUS" in
131
+ OK) SONAR_SYM="✅" ;;
132
+ ERROR) SONAR_SYM="❌" ;;
133
+ WARN) SONAR_SYM="⚠ " ;;
134
+ *) SONAR_SYM="?" ;;
135
+ esac
136
+ printf " %-12s %s Quality Gate %s, %d OPEN issue(s), %d hotspot(s)\n" \
137
+ "SonarCloud" "$SONAR_SYM" "$SONAR_QG_STATUS" "$SONAR_OPEN" "$SONAR_HOTSPOTS"
138
+
139
+ # When SonarCloud has OPEN issues, list them — saves a follow-up curl.
140
+ if [[ "$SONAR_OPEN" != "0" ]]; then
141
+ echo
142
+ echo " SonarCloud OPEN issues:"
143
+ curl -s "https://sonarcloud.io/api/issues/search?componentKeys=${SONAR_KEY}&pullRequest=${PR_NUMBER}&statuses=OPEN,CONFIRMED&ps=20" \
144
+ | jq -r '.issues[] | " • [\(.rule)] \(.component | sub("^[^:]+:"; ""))(:\(.line // "?")) (\(.severity)) — \(.message)"'
145
+ fi
146
+
147
+ # ── 5. Tally + summary ────────────────────────────────────────────────────
148
+ echo
149
+ echo "── Inline threads ────────────────────────────────────────────────────"
150
+ printf " Total: %d Resolved: %d Unresolved: %d\n" \
151
+ "$INLINE_TOTAL" "$INLINE_RESOLVED" "$INLINE_PENDING"
152
+
153
+ if [[ "$INLINE_PENDING" -gt 0 ]]; then
154
+ echo
155
+ echo " Unresolved threads:"
156
+ echo "$THREADS_JSON" | jq -r '
157
+ .[] | select(.isResolved == false) |
158
+ " • \(.comments.nodes[0].author.login): thread \(.id)"
159
+ '
160
+ fi
161
+
162
+ echo
163
+ echo "(For full comment bodies: agex pr read --agent claude-code $PR_NUMBER)"