teken 0.8.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 (120) hide show
  1. teken-0.8.0/.agex/data/pr/events.jsonl +5 -0
  2. teken-0.8.0/.claude/skills/cicd/SKILL.md +168 -0
  3. teken-0.8.0/.claude/skills/cicd/scripts/_resolve-nick.sh +43 -0
  4. teken-0.8.0/.claude/skills/cicd/scripts/portability-lint.sh +57 -0
  5. teken-0.8.0/.claude/skills/cicd/scripts/pr-reply.sh +77 -0
  6. teken-0.8.0/.claude/skills/cicd/scripts/pr-status.sh +163 -0
  7. teken-0.8.0/.claude/skills/cicd/scripts/workflow.sh +157 -0
  8. teken-0.8.0/.claude/skills/communicate/SKILL.md +325 -0
  9. teken-0.8.0/.claude/skills/communicate/scripts/fetch-issues.sh +59 -0
  10. teken-0.8.0/.claude/skills/communicate/scripts/mesh-message.sh +74 -0
  11. teken-0.8.0/.claude/skills/communicate/scripts/post-comment.sh +65 -0
  12. teken-0.8.0/.claude/skills/communicate/scripts/post-issue.sh +71 -0
  13. teken-0.8.0/.claude/skills/communicate/scripts/templates/skill-update-brief.md +101 -0
  14. teken-0.8.0/.claude/skills/lint-markdown/SKILL.md +29 -0
  15. teken-0.8.0/.claude/skills/version-bump/SKILL.md +84 -0
  16. teken-0.8.0/.claude/skills/version-bump/scripts/bump.py +193 -0
  17. teken-0.8.0/.flake8 +20 -0
  18. teken-0.8.0/.github/workflows/docs.yml +154 -0
  19. teken-0.8.0/.github/workflows/publish.yml +101 -0
  20. teken-0.8.0/.github/workflows/security-checks.yml +41 -0
  21. teken-0.8.0/.github/workflows/tests.yml +113 -0
  22. teken-0.8.0/.gitignore +211 -0
  23. teken-0.8.0/.markdownlint-cli2.yaml +19 -0
  24. teken-0.8.0/.pre-commit-config.yaml +37 -0
  25. teken-0.8.0/CHANGELOG.md +178 -0
  26. teken-0.8.0/CLAUDE.md +61 -0
  27. teken-0.8.0/LICENSE +21 -0
  28. teken-0.8.0/PKG-INFO +93 -0
  29. teken-0.8.0/README.md +76 -0
  30. teken-0.8.0/culture.yaml +3 -0
  31. teken-0.8.0/docs/.gitignore +5 -0
  32. teken-0.8.0/docs/Gemfile +8 -0
  33. teken-0.8.0/docs/_config.yml +64 -0
  34. teken-0.8.0/docs/_includes/head_custom.html +5 -0
  35. teken-0.8.0/docs/_sass/color_schemes/dark-terminal.scss +40 -0
  36. teken-0.8.0/docs/_sass/custom/custom.scss +348 -0
  37. teken-0.8.0/docs/agent-first.md +107 -0
  38. teken-0.8.0/docs/agentculture.md +55 -0
  39. teken-0.8.0/docs/index.md +75 -0
  40. teken-0.8.0/docs/rubric.md +120 -0
  41. teken-0.8.0/docs/skill-sources.md +44 -0
  42. teken-0.8.0/packaging/afi-cli/README.md +14 -0
  43. teken-0.8.0/packaging/afi-cli/pyproject.toml +36 -0
  44. teken-0.8.0/pyproject.toml +84 -0
  45. teken-0.8.0/scripts/lint-md.sh +24 -0
  46. teken-0.8.0/sonar-project.properties +18 -0
  47. teken-0.8.0/teken/__init__.py +13 -0
  48. teken-0.8.0/teken/__main__.py +8 -0
  49. teken-0.8.0/teken/_brand.py +27 -0
  50. teken-0.8.0/teken/cite/__init__.py +19 -0
  51. teken-0.8.0/teken/cite/_engine.py +181 -0
  52. teken-0.8.0/teken/cite/references/python-cli/AGENT.md +98 -0
  53. teken-0.8.0/teken/cite/references/python-cli/MANIFEST.json +65 -0
  54. teken-0.8.0/teken/cite/references/python-cli/tests/test_cli.py +46 -0
  55. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/__init__.py +12 -0
  56. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/__main__.py +10 -0
  57. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/cli/__init__.py +84 -0
  58. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/cli/_commands/__init__.py +0 -0
  59. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/cli/_commands/explain.py +38 -0
  60. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/cli/_commands/learn.py +81 -0
  61. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/cli/_errors.py +41 -0
  62. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/cli/_output.py +53 -0
  63. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/explain/__init__.py +24 -0
  64. teken-0.8.0/teken/cite/references/python-cli/{{slug}}/explain/catalog.py +66 -0
  65. teken-0.8.0/teken/cli/__init__.py +160 -0
  66. teken-0.8.0/teken/cli/_commands/__init__.py +0 -0
  67. teken-0.8.0/teken/cli/_commands/cli.py +198 -0
  68. teken-0.8.0/teken/cli/_commands/doctor.py +564 -0
  69. teken-0.8.0/teken/cli/_commands/explain.py +38 -0
  70. teken-0.8.0/teken/cli/_commands/learn.py +130 -0
  71. teken-0.8.0/teken/cli/_commands/overview.py +51 -0
  72. teken-0.8.0/teken/cli/_errors.py +42 -0
  73. teken-0.8.0/teken/cli/_output.py +58 -0
  74. teken-0.8.0/teken/doctor/__init__.py +66 -0
  75. teken-0.8.0/teken/doctor/_self_checks.py +347 -0
  76. teken-0.8.0/teken/doctor/fixes.py +73 -0
  77. teken-0.8.0/teken/explain/__init__.py +28 -0
  78. teken-0.8.0/teken/explain/catalog.py +390 -0
  79. teken-0.8.0/teken/overview/__init__.py +136 -0
  80. teken-0.8.0/teken/overview/cli_surface.py +455 -0
  81. teken-0.8.0/teken/rubric/__init__.py +53 -0
  82. teken-0.8.0/teken/rubric/_runner.py +102 -0
  83. teken-0.8.0/teken/rubric/_types.py +70 -0
  84. teken-0.8.0/teken/rubric/checks/__init__.py +0 -0
  85. teken-0.8.0/teken/rubric/checks/doctor.py +270 -0
  86. teken-0.8.0/teken/rubric/checks/errors.py +107 -0
  87. teken-0.8.0/teken/rubric/checks/explain_cmd.py +87 -0
  88. teken-0.8.0/teken/rubric/checks/json_output.py +97 -0
  89. teken-0.8.0/teken/rubric/checks/learnability.py +74 -0
  90. teken-0.8.0/teken/rubric/checks/overview_cmd.py +181 -0
  91. teken-0.8.0/teken/rubric/checks/structure.py +297 -0
  92. teken-0.8.0/tests/__init__.py +0 -0
  93. teken-0.8.0/tests/integration/__init__.py +0 -0
  94. teken-0.8.0/tests/integration/test_cite_no_collateral.py +80 -0
  95. teken-0.8.0/tests/integration/test_cli_commands.py +185 -0
  96. teken-0.8.0/tests/integration/test_cli_doctor.py +225 -0
  97. teken-0.8.0/tests/test_cli.py +62 -0
  98. teken-0.8.0/tests/test_self_doctor.py +79 -0
  99. teken-0.8.0/tests/unit/__init__.py +0 -0
  100. teken-0.8.0/tests/unit/_fake_runner.py +24 -0
  101. teken-0.8.0/tests/unit/test_cite_engine.py +187 -0
  102. teken-0.8.0/tests/unit/test_cli_overview_cmd.py +79 -0
  103. teken-0.8.0/tests/unit/test_doctor_cmd_inprocess.py +121 -0
  104. teken-0.8.0/tests/unit/test_doctor_self.py +199 -0
  105. teken-0.8.0/tests/unit/test_doctor_target_resolution.py +153 -0
  106. teken-0.8.0/tests/unit/test_errors.py +43 -0
  107. teken-0.8.0/tests/unit/test_explain.py +90 -0
  108. teken-0.8.0/tests/unit/test_learn.py +47 -0
  109. teken-0.8.0/tests/unit/test_main_error_handling.py +72 -0
  110. teken-0.8.0/tests/unit/test_output.py +56 -0
  111. teken-0.8.0/tests/unit/test_overview_cli_surface.py +142 -0
  112. teken-0.8.0/tests/unit/test_rubric_bundle_doctor.py +168 -0
  113. teken-0.8.0/tests/unit/test_rubric_errors.py +66 -0
  114. teken-0.8.0/tests/unit/test_rubric_explain_cmd.py +65 -0
  115. teken-0.8.0/tests/unit/test_rubric_json_output.py +80 -0
  116. teken-0.8.0/tests/unit/test_rubric_learnability.py +53 -0
  117. teken-0.8.0/tests/unit/test_rubric_overview_cmd.py +141 -0
  118. teken-0.8.0/tests/unit/test_rubric_structure.py +202 -0
  119. teken-0.8.0/tests/unit/test_rubric_types.py +56 -0
  120. teken-0.8.0/uv.lock +646 -0
@@ -0,0 +1,5 @@
1
+ {"ts":"2026-05-12T05:07:51.790191+00:00","type":"pr_read","pr":19,"comment_count":7,"threads_unresolved":3,"ci_state":"ok"}
2
+ {"ts":"2026-05-12T05:21:58.781816+00:00","type":"pr_reply","pr":19,"thread_id":"PRRT_kwDOSGEynM6BTAaJ","in_reply_to":null}
3
+ {"ts":"2026-05-12T05:22:00.768056+00:00","type":"pr_reply","pr":19,"thread_id":"PRRT_kwDOSGEynM6BTAaK","in_reply_to":null}
4
+ {"ts":"2026-05-12T05:22:02.526061+00:00","type":"pr_reply","pr":19,"thread_id":"PRRT_kwDOSGEynM6BTAaN","in_reply_to":null}
5
+ {"ts":"2026-05-12T05:22:03.040672+00:00","type":"pr_batch_replied","pr":19,"count":3,"resolved":3}
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: cicd
3
+ description: >
4
+ afi-cli's CI/CD lane (vendored from steward), layered on `agex pr`.
5
+ Delegates lint / open / read / reply / delta to agex; adds two
6
+ steward-derived extensions — `status` (SonarCloud quality gate +
7
+ hotspots + unresolved-thread tally) and `await` (read --wait +
8
+ status with non-zero exit on Sonar ERROR or unresolved threads).
9
+ Use when: creating PRs in afi-cli, handling review feedback,
10
+ polling CI status, or the user says "create PR", "review comments",
11
+ "address feedback", "resolve threads". Renamed from `pr-review` in
12
+ steward 0.7.0; rebased on agex in 0.12.0.
13
+ ---
14
+
15
+ # CI/CD — afi-cli edition (vendored from steward)
16
+
17
+ `agex pr` (in `agentculture/agex-cli`) is the upstream for the
18
+ five core PR-lifecycle verbs — `lint`, `open`, `read`, `reply`,
19
+ `delta`. Steward used to vendor parallel scripts for each; in 0.12.0
20
+ those vendored copies were dropped in favor of delegating to `agex`.
21
+ What's left in this skill is the steward-derived gating layer (vendored here from upstream):
22
+
23
+ - `status` — SonarCloud quality gate, OPEN issues, hotspots, deploy
24
+ preview URL, unresolved-inline-thread tally.
25
+ - `await` — composes `agex pr read --wait` with `status` and gates on
26
+ Sonar `ERROR` / unresolved threads. The single command to run after
27
+ pushing a fix when you want "wake me when this PR is triage-able."
28
+
29
+ Those two are the steward-unique surface today (carried into this vendored copy). They're filed as a
30
+ feature ask upstream
31
+ ([agex-cli#41](https://github.com/agentculture/agex-cli/issues/41));
32
+ once they land they migrate out of this skill.
33
+
34
+ The workflow is encapsulated in `scripts/workflow.sh` — follow that
35
+ (or call `agex pr` directly).
36
+
37
+ ## Prerequisites
38
+
39
+ Hard requirements: `agex` (>=0.1), `gh` (GitHub CLI), `jq`, `bash`,
40
+ `python3` (stdlib only), `curl` (used by `pr-status.sh`).
41
+
42
+ Install agex once:
43
+
44
+ ```bash
45
+ uv tool install agex-cli # or: pip install --user agex-cli
46
+ ```
47
+
48
+ Soft requirement: `PyYAML` is needed **only for suffix mode** of the
49
+ sibling `agent-config` skill, where it parses Culture's server
50
+ manifest. Every `cicd` script works without it; suffix mode prints a
51
+ clear install hint when invoked without it.
52
+
53
+ Per-machine paths (sibling-project layout) live in
54
+ `.claude/skills.local.yaml`; see the committed `.example` for the
55
+ schema. `agex pr delta` reads the same file.
56
+
57
+ ## How to run
58
+
59
+ `scripts/workflow.sh` is the entry point. Subcommands:
60
+
61
+ | Command | What it does |
62
+ |---------|--------------|
63
+ | `workflow.sh lint` | `agex pr lint --exit-on-violation` — portability + alignment-trigger check. |
64
+ | `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. |
65
+ | `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. |
66
+ | `workflow.sh reply <PR>` | `agex pr reply <PR>` — batch JSONL replies (stdin) + thread resolve. agex auto-signs from `culture.yaml`. |
67
+ | `workflow.sh delta` | `agex pr delta` — sibling alignment dump. |
68
+ | `workflow.sh status <PR>` | **Steward extension.** `pr-status.sh` — Sonar gate, OPEN issues, hotspots, unresolved-thread breakdown, deploy preview URL. Authoritative gate for `await`. |
69
+ | `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). |
70
+ | `workflow.sh help` | Print the list. |
71
+
72
+ You can also call `agex pr <verb>` directly — `workflow.sh` is a
73
+ typing-saver around the same verbs. The `status` and `await`
74
+ extensions (carried from steward) only have shell entry points.
75
+
76
+ The vendored single-comment helper `pr-reply.sh` (plus its
77
+ `_resolve-nick.sh` dependency) is still shipped — pinned by
78
+ `tests/test_pr_reply_signature.py` and `tests/test_resolve_nick.py`,
79
+ and useful when a one-off reply doesn't merit batch JSONL. It is not
80
+ called by `workflow.sh` anymore. The vendored `portability-lint.sh`
81
+ is also still shipped — upstream `steward doctor`'s portability check
82
+ runs it directly; in afi-cli it's available as a standalone helper.
83
+ Both are scheduled for follow-up migration to agex.
84
+
85
+ ## Long waits (background polling)
86
+
87
+ `agex pr read --wait N` polls in-session for up to N seconds. The
88
+ Anthropic prompt cache has a 5-minute TTL; sleeping past it burns
89
+ context every cache miss. Two ways to drive the wait:
90
+
91
+ - **Synchronous** — `workflow.sh await <PR>` after `gh pr create` /
92
+ `workflow.sh open`. Fine when readiness is expected within ~5
93
+ minutes.
94
+ - **Asynchronous** — for longer waits, run `agex pr read --wait NNN`
95
+ inside a background subagent (Agent tool, `run_in_background: true`)
96
+ so the main session only pays the cache cost when readiness fires.
97
+ The subagent's only job is to invoke `agex pr read --wait` and echo
98
+ its headline back. The parent triages with `workflow.sh await`
99
+ when the notification arrives. The user can interrupt with
100
+ TaskStop.
101
+
102
+ This pattern was originally borrowed from sibling repo
103
+ [`agentculture/cfafi`](https://github.com/agentculture/cfafi)'s `poll`
104
+ skill. The async guidance is also filed upstream
105
+ ([agex-cli#41](https://github.com/agentculture/agex-cli/issues/41)).
106
+
107
+ ## Conventions
108
+
109
+ `agex pr` emits a **"Next step:"** footer at the end of every command
110
+ that names the right next verb (the same chain `agex learn cicd`
111
+ documents) — follow that rather than memorizing an order. `workflow.sh
112
+ help` mirrors the verb table when you need the steward-derived
113
+ extensions (`status`, `await`) on top.
114
+
115
+ Branch naming: `fix/<desc>`, `feat/<desc>`, `docs/<desc>`,
116
+ `skill/<name>`. PR / comment signature: `- <nick> (Claude)`, where
117
+ `<nick>` is resolved by `agex` from the agent's own `culture.yaml`
118
+ (first agent's `suffix`), falling back to the git-repo basename. agex
119
+ auto-appends the signature on `pr open` and `pr reply` only when the
120
+ body isn't already signed.
121
+
122
+ ## Triage rules
123
+
124
+ For every comment, decide **FIX** or **PUSHBACK** with reasoning.
125
+
126
+ Default to **FIX** for: portability complaints (always valid —
127
+ recurring bug class across AgentCulture repos), test or doc requests,
128
+ style nits aligned with workspace conventions.
129
+
130
+ Default to **PUSHBACK** for: architecture opinions that conflict with
131
+ workspace `CLAUDE.md` or the all-backends rule; greenfield
132
+ false-positives (e.g. "add tests" before there's any source — defer
133
+ to a later PR, don't refuse).
134
+
135
+ ### Alignment-delta rule
136
+
137
+ If the PR touches `CLAUDE.md`, `culture.yaml`, or anything under
138
+ `.claude/skills/`, run `workflow.sh delta` **before** declaring FIX or
139
+ PUSHBACK on each comment. Note any sibling that needs a follow-up PR
140
+ and mention it in your reply.
141
+
142
+ ## Greenfield-aware steps
143
+
144
+ The lint and the workflow script are always-on. Stack-specific steps
145
+ are conditional and currently no-op (greenfield repo):
146
+
147
+ ```bash
148
+ [ -d tests ] && [ -f pyproject.toml ] && uv run pytest tests/ -x -q
149
+ [ -f pyproject.toml ] && bump_version_per_project_convention # see project README
150
+ [ -f .markdownlint-cli2.yaml ] && markdownlint-cli2 "$(git diff --name-only --cached '*.md')"
151
+ ```
152
+
153
+ Revisit each line as the corresponding stack element actually lands.
154
+ A `pr lint --extra=tests,version,markdown` ask is filed upstream
155
+ ([agex-cli#41](https://github.com/agentculture/agex-cli/issues/41)).
156
+
157
+ ## Reply etiquette
158
+
159
+ Every comment must get a reply — no silent fixes. `agex pr reply`
160
+ includes thread-resolve by default. Reference the review-comment IDs
161
+ in the fix-up commit message.
162
+
163
+ The `status` extension queries SonarCloud directly (it predates the
164
+ upstream Sonar integration in `agex pr read`). Both surfaces are
165
+ trustworthy — `agex pr read` for display in the briefing, `status` for
166
+ the gate. afi-cli isn't yet a registered mesh agent, so the
167
+ post-merge IRC ping that Culture's `pr-review` includes is still
168
+ skipped — that returns when afi-cli 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,57 @@
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
+ hits1=$(echo "$files" | xargs -r grep -nE '/home/[a-z][a-z0-9_-]+/' 2>/dev/null || true)
25
+
26
+ # ----- Check 2: per-user dotfile *config* refs in committed docs/configs -----
27
+ # Carve-outs (allowed, NOT flagged):
28
+ # - ~/.claude/skills/<x>/scripts/ vendored tool calls
29
+ # - ~/.culture/ Culture mesh data this skill is supposed to read
30
+ md_yaml=$(echo "$files" | grep -E '\.(md|ya?ml|toml|json|jsonc)$' || true)
31
+ if [ -n "$md_yaml" ]; then
32
+ hits2=$(echo "$md_yaml" | xargs -r grep -nE '~/\.[A-Za-z]' 2>/dev/null \
33
+ | grep -vE '~/\.claude/skills/[^[:space:]"]+/scripts/' \
34
+ | grep -vE '~/\.culture/' \
35
+ || true)
36
+ else
37
+ hits2=""
38
+ fi
39
+
40
+ fail=0
41
+ if [ -n "$hits1" ]; then
42
+ echo "❌ Hard-coded /home/<user>/ paths:"
43
+ echo "$hits1" | sed 's/^/ /'
44
+ echo " Fix: use ../sibling, repo URL, or \$WORKSPACE/sibling instead."
45
+ fail=1
46
+ fi
47
+ if [ -n "$hits2" ]; then
48
+ [ "$fail" -eq 1 ] && echo
49
+ echo "❌ Per-user ~/.<dotfile> config refs in committed doc/config:"
50
+ echo "$hits2" | sed 's/^/ /'
51
+ echo " Allowed carve-outs: ~/.claude/skills/.../scripts/ (tool calls), ~/.culture/ (mesh data)."
52
+ echo " Otherwise: commit a repo-local config or document a portable lookup."
53
+ fail=1
54
+ fi
55
+
56
+ [ "$fail" -eq 0 ] && echo "✓ portability lint clean ($(echo "$files" | wc -l | tr -d ' ') files checked)"
57
+ 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)"