@yandy-r/ycc-opencode 6.4.0 → 6.6.0

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 (85) hide show
  1. package/README.md +11 -4
  2. package/agents/code-finder.md +1 -1
  3. package/agents/planner.md +1 -2
  4. package/agents/pr-evidence-collector.md +99 -0
  5. package/agents/root-cause-analyzer.md +1 -1
  6. package/index.js +9 -0
  7. package/package.json +1 -1
  8. package/registration.json +67 -0
  9. package/shared/references/branching-model.md +2 -1
  10. package/shared/references/standalone-dispatch.md +4 -1
  11. package/shared/references/target-capability-matrix.md +170 -30
  12. package/shared/references/worktree-strategy.md +9 -31
  13. package/shared/scripts/lib/ci-classify.sh +2 -2
  14. package/shared/scripts/release-feature-sets.sh +18 -0
  15. package/shared/scripts/release_feature_sets.py +232 -0
  16. package/shared/scripts/setup-worktree.sh +2 -69
  17. package/skills/bundle-author/references/surface-map.md +1 -1
  18. package/skills/bundle-author/references/when-not-to-scaffold.md +1 -1
  19. package/skills/bundle-author/scripts/scaffold-skill.sh +9 -0
  20. package/skills/bundle-release/SKILL.md +22 -5
  21. package/skills/bundle-release/references/release-checklist.md +9 -1
  22. package/skills/bundle-release/references/version-policy.md +11 -4
  23. package/skills/bundle-release/scripts/release_versions.py +19 -1
  24. package/skills/code-report/SKILL.md +0 -2
  25. package/skills/code-report/templates/report-structure.md +0 -2
  26. package/skills/compatibility-audit/SKILL.md +8 -4
  27. package/skills/compatibility-audit/scripts/audit-install-assumptions.sh +75 -5
  28. package/skills/compatibility-audit/scripts/audit-target-features.sh +15 -9
  29. package/skills/feature-research/SKILL.md +1 -1
  30. package/skills/feature-research/scripts/validate-spec.sh +0 -4
  31. package/skills/formatters/SKILL.md +2 -1
  32. package/skills/formatters/references/flag-reference.md +8 -4
  33. package/skills/formatters/references/templates/lint-autofix.yml.tmpl +189 -23
  34. package/skills/formatters/references/templates/lint.yml.tmpl +11 -11
  35. package/skills/formatters/references/templates/readme-section.md.tmpl +1 -1
  36. package/skills/formatters/scripts/bundle/go-tools.sh +73 -41
  37. package/skills/formatters/scripts/bundle/init-formatters.sh +1 -1
  38. package/skills/formatters/scripts/bundle/lib/modified-files.sh +0 -5
  39. package/skills/formatters/scripts/bundle/style.sh +2 -2
  40. package/skills/git-cleanup/SKILL.md +4 -5
  41. package/skills/git-workflow/SKILL.md +1 -0
  42. package/skills/git-workflow/templates/agent-prompts.md +5 -6
  43. package/skills/git-workflow/templates/documentation-decision.md +1 -3
  44. package/skills/git-workflow/templates/pr-template.md +1 -3
  45. package/skills/go-patterns/references/design-and-tooling.md +16 -13
  46. package/skills/go-testing/references/advanced-testing.md +2 -2
  47. package/skills/implement-plan/references/agent-task-prompt.md +18 -20
  48. package/skills/implement-plan/scripts/parse-dependencies.sh +3 -9
  49. package/skills/init/references/conventional-commits.md +8 -1
  50. package/skills/init/references/template-library.md +1 -1
  51. package/skills/init/templates/git/gitignore.tmpl +2 -0
  52. package/skills/init/templates/git/gitmessage.tmpl +2 -1
  53. package/skills/init/templates/github/workflows/pr-title.yml.tmpl +1 -1
  54. package/skills/orchestrate/SKILL.md +1 -1
  55. package/skills/orchestrate/references/dispatch-playbook.md +1 -1
  56. package/skills/parallel-plan/SKILL.md +6 -10
  57. package/skills/plan-workflow/SKILL.md +3 -3
  58. package/skills/plan-workflow/references/plan-structure.md +1 -3
  59. package/skills/plan-workflow/scripts/validate-workflow-plan.sh +2 -8
  60. package/skills/pr-evidence/SKILL.md +138 -0
  61. package/skills/pr-evidence/references/perf-evidence.md +119 -0
  62. package/skills/pr-evidence/references/pr-body-and-hosting.md +112 -0
  63. package/skills/pr-evidence/references/ui-evidence.md +152 -0
  64. package/skills/pr-evidence/scripts/bench_report.py +331 -0
  65. package/skills/pr-evidence/scripts/capture-ui.mjs +311 -0
  66. package/skills/pr-evidence/scripts/classify-change.sh +135 -0
  67. package/skills/prp-plan/SKILL.md +4 -5
  68. package/skills/prp-plan/scripts/validate-prp-plan.sh +1 -11
  69. package/skills/prp-pr/SKILL.md +4 -0
  70. package/skills/release-model/templates/RELEASING.md.tmpl +2 -1
  71. package/skills/releaser/SKILL.md +5 -1
  72. package/skills/releaser/references/ci-optimization-checklist.md +1 -1
  73. package/skills/releaser/references/ci-templates/docker-release.yml +8 -8
  74. package/skills/releaser/references/ci-templates/generic-release.yml +5 -5
  75. package/skills/releaser/references/ci-templates/go-release.yml +4 -4
  76. package/skills/releaser/references/ci-templates/node-release.yml +8 -8
  77. package/skills/releaser/references/ci-templates/python-release.yml +8 -8
  78. package/skills/releaser/references/ci-templates/rust-release.yml +10 -10
  79. package/skills/releaser/references/release-preparation.md +34 -15
  80. package/skills/rust-testing/references/advanced-testing.md +1 -1
  81. package/skills/shared-context/SKILL.md +6 -10
  82. package/skills/ts-testing/references/advanced-testing.md +4 -4
  83. package/skills/visual-recap/SKILL.md +3 -4
  84. package/shared/scripts/merge-children.sh +0 -82
  85. package/skills/write-docs/templates/docs-readme.md +0 -34
@@ -84,8 +84,6 @@ Include important information that would be valuable for maintainers:
84
84
  - Security considerations
85
85
  - Known limitations
86
86
 
87
- Be thorough but concise. Only include information that's important for someone maintaining this code.
88
-
89
87
  Example:
90
88
 
91
89
  ```markdown
@@ -36,14 +36,18 @@ modifies any file.
36
36
  Parse `$ARGUMENTS` for:
37
37
 
38
38
  - **--target** (optional, default `all`) — restrict the audit to a single
39
- target. Accepted values: `claude`, `cursor`, `codex`, `opencode`, `omp`, `pi`, `all`. When `all`
40
- is specified, phases 2–5 run once per target in the set
41
- `{claude, cursor, codex, opencode, omp, pi}`.
39
+ target. Accepted values: `claude`, `cursor`, `codex`, `opencode`, `omp`, `pi`, `antigravity`, `muse`, `all`.
40
+ When `all` is specified, phases 2–5 run once per target in the set
41
+ `{claude, cursor, codex, opencode, omp, pi, antigravity, muse}`.
42
42
  `omp` has no generated tree or generator yet: skip Phases 2 and 3 for it and
43
43
  report them as `not generated yet` rather than failures.
44
44
  `pi` is modeled but has no generated `packages/pi/` tree or generator yet (ADR 0003,
45
45
  YAN-1188): skip Phases 2 and 3 for it and report them as `not generated yet`. Phase 4
46
46
  still runs its `PI1` check.
47
+ `antigravity` has no `report-bundle-drift.sh` entry: skip Phase 2 for it and report
48
+ `drift covered by Phase 3` (`validate.sh --only antigravity` runs the generator `--check`).
49
+ `muse` likewise has no `report-bundle-drift.sh` entry: skip Phase 2 for it and report
50
+ `drift covered by Phase 3` (`validate.sh --only muse` runs the generator `--check`).
47
51
  - **--json** (flag, default off) — emit the final triage report as a
48
52
  machine-readable JSON envelope instead of Markdown. Per-target sections are
49
53
  preserved inside the envelope as structured objects.
@@ -70,7 +74,7 @@ required for Phase 5.
70
74
 
71
75
  Parse `$ARGUMENTS` as described above. Resolve `--target` to a concrete list:
72
76
 
73
- - `all` → `[claude, cursor, codex, opencode, omp, pi]`
77
+ - `all` → `[claude, cursor, codex, opencode, omp, pi, antigravity, muse]`
74
78
  - any single value → a one-element list
75
79
 
76
80
  If `--dry-run` was passed, print the resolved target list, the scripts that
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # audit-install-assumptions.sh — validate install-path assumptions for each
3
- # generated compatibility target (Claude, Cursor, Codex, opencode, omp, pi).
3
+ # generated compatibility target (Claude, Cursor, Codex, opencode, omp, pi, antigravity, muse).
4
4
  #
5
5
  # Flags:
6
- # --target=<claude|cursor|codex|opencode|omp|pi|all> (default: all)
6
+ # --target=<claude|cursor|codex|opencode|omp|pi|antigravity|muse|all> (default: all)
7
7
  # --format=<human|json> (default: human)
8
8
  # --help, -h print usage and exit 0
9
9
  #
@@ -12,7 +12,7 @@
12
12
  set -euo pipefail
13
13
 
14
14
  usage() { cat <<'EOF'
15
- Usage: audit-install-assumptions.sh [--target=<claude|cursor|codex|opencode|omp|pi|all>]
15
+ Usage: audit-install-assumptions.sh [--target=<claude|cursor|codex|opencode|omp|pi|antigravity|muse|all>]
16
16
  [--format=<human|json>] [--help|-h]
17
17
  [repo-root]
18
18
 
@@ -42,7 +42,7 @@ for arg in "$@"; do
42
42
  ;;
43
43
  esac
44
44
  done
45
- case "$TARGET" in all|claude|cursor|codex|opencode|omp|pi) ;;
45
+ case "$TARGET" in all|claude|cursor|codex|opencode|omp|pi|antigravity|muse) ;;
46
46
  *) echo "audit-install-assumptions.sh: unknown --target: $TARGET" >&2; usage >&2; exit 2 ;; esac
47
47
  case "$FORMAT" in human|json) ;;
48
48
  *) echo "audit-install-assumptions.sh: unknown --format: $FORMAT" >&2; usage >&2; exit 2 ;; esac
@@ -412,6 +412,74 @@ PY
412
412
  fi
413
413
  }
414
414
 
415
+ # ---------------------------------------------------------------------------
416
+ # Antigravity checks
417
+ # ---------------------------------------------------------------------------
418
+ run_antigravity_checks() {
419
+ local adir="${REPO_ROOT}/packages/antigravity" pkg manifest
420
+ # AG1: every generated plugin has a valid root plugin.json naming its folder.
421
+ if [[ ! -d "$adir" ]]; then
422
+ record "antigravity" "AG1" "FAIL" "${adir} does not exist (run ./scripts/sync.sh --only antigravity)"; return
423
+ fi
424
+ for pkg in ycc ycc-mcp ycc-rules; do
425
+ manifest="${adir}/${pkg}/plugin.json"
426
+ if ! json_ok "$manifest"; then
427
+ record "antigravity" "AG1" "FAIL" "${manifest} is missing or not valid JSON"; continue
428
+ fi
429
+ if [[ "$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1])).get("name",""))' "$manifest")" != "$pkg" ]]; then
430
+ record "antigravity" "AG1" "FAIL" "${manifest} name must be ${pkg}"; continue
431
+ fi
432
+ record "antigravity" "AG1" "PASS" "${pkg}"
433
+ done
434
+ # AG2: skills and agents carry no Claude plugin-root variable (Antigravity has none).
435
+ local hits
436
+ hits="$(grep -rl --include=SKILL.md --include='*.md' 'CLAUDE_PLUGIN_ROOT' "${adir}/ycc/skills"/*/SKILL.md "${adir}/ycc/agents" 2>/dev/null || true)"
437
+ if [[ -n "$hits" ]]; then
438
+ record "antigravity" "AG2" "FAIL" "CLAUDE_PLUGIN_ROOT left in: $(tr '\n' ' ' <<<"$hits")"
439
+ else
440
+ record "antigravity" "AG2" "PASS" ""
441
+ fi
442
+ }
443
+
444
+ # ---------------------------------------------------------------------------
445
+ # Muse checks
446
+ # ---------------------------------------------------------------------------
447
+ run_muse_checks() {
448
+ local mdir="${REPO_ROOT}/packages/muse" pkg manifest hits
449
+ # MU1: ycc carries the claude-compatible manifest (the only family that imports
450
+ # agents) and no native one (which would win and hide them); ycc-mcp the native one.
451
+ if [[ ! -d "$mdir" ]]; then
452
+ record "muse" "MU1" "FAIL" "${mdir} does not exist (run ./scripts/sync.sh --only muse)"; return
453
+ fi
454
+ for pkg in ycc:.claude-plugin ycc-mcp:.muse-plugin ycc-rules:.muse-plugin; do
455
+ manifest="${mdir}/${pkg%%:*}/${pkg#*:}/plugin.json"
456
+ if ! json_ok "$manifest"; then
457
+ record "muse" "MU1" "FAIL" "${manifest} is missing or not valid JSON"; continue
458
+ fi
459
+ if [[ "$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1])).get("name",""))' "$manifest")" != "${pkg%%:*}" ]]; then
460
+ record "muse" "MU1" "FAIL" "${manifest} name must be ${pkg%%:*}"; continue
461
+ fi
462
+ record "muse" "MU1" "PASS" "${pkg%%:*}"
463
+ done
464
+ if [[ -e "${mdir}/ycc/.muse-plugin/plugin.json" ]]; then
465
+ record "muse" "MU1" "FAIL" "${mdir}/ycc/.muse-plugin/plugin.json would hide the ycc agents"
466
+ fi
467
+ # MU2: skills and agents carry no Claude plugin-root variable (Muse caches by digest).
468
+ hits="$(grep -rl --include=SKILL.md --include='*.md' 'CLAUDE_PLUGIN_ROOT' "${mdir}/ycc/skills"/*/SKILL.md "${mdir}/ycc/agents" 2>/dev/null || true)"
469
+ if [[ -n "$hits" ]]; then
470
+ record "muse" "MU2" "FAIL" "CLAUDE_PLUGIN_ROOT left in: $(tr '\n' ' ' <<<"$hits")"
471
+ else
472
+ record "muse" "MU2" "PASS" ""
473
+ fi
474
+ # MU3: agent frontmatter avoids what Muse refuses (an off-palette color) or cannot project (Glob).
475
+ hits="$(grep -lE '^(color:| - Glob$)' "${mdir}/ycc/agents"/*.md 2>/dev/null || true)"
476
+ if [[ -n "$hits" ]]; then
477
+ record "muse" "MU3" "FAIL" "color or Glob in: $(tr '\n' ' ' <<<"$hits")"
478
+ else
479
+ record "muse" "MU3" "PASS" ""
480
+ fi
481
+ }
482
+
415
483
  # ---------------------------------------------------------------------------
416
484
  # Dispatch
417
485
  # ---------------------------------------------------------------------------
@@ -422,7 +490,9 @@ case "$TARGET" in
422
490
  opencode) run_opencode_checks ;;
423
491
  omp) run_omp_checks ;;
424
492
  pi) run_pi_checks ;;
425
- all) run_claude_checks; run_cursor_checks; run_codex_checks; run_opencode_checks; run_omp_checks; run_pi_checks ;;
493
+ antigravity) run_antigravity_checks ;;
494
+ muse) run_muse_checks ;;
495
+ all) run_claude_checks; run_cursor_checks; run_codex_checks; run_opencode_checks; run_omp_checks; run_pi_checks; run_antigravity_checks; run_muse_checks ;;
426
496
  esac
427
497
 
428
498
  OVERALL_RC=0
@@ -7,7 +7,7 @@
7
7
  #
8
8
  # Flags:
9
9
  # --target=<t>|all Restrict findings to one target: claude, cursor, codex,
10
- # opencode, omp, pi, or all (default: all). `--target <t>` also works.
10
+ # opencode, omp, pi, antigravity, muse, or all (default: all). `--target <t>` also works.
11
11
  # --format=human|json Output format (default: human)
12
12
  # --strict Exit 1 if any verdict is "unsupported"
13
13
  # --help Show this help and exit 0
@@ -22,7 +22,7 @@
22
22
  #
23
23
  # The parser reads ONE markdown table from the matrix file. Rules:
24
24
  # - The header row must be exactly (after per-cell whitespace trim):
25
- # capability | claude | cursor | codex | opencode | omp | pi
25
+ # capability | claude | cursor | codex | opencode | omp | pi | antigravity | muse
26
26
  # - Separator rows (cells of dashes) are skipped.
27
27
  # - Each data cell must be one of: supported | partial | unsupported
28
28
  # - The "As of <date>" line is expected anywhere in the file as:
@@ -47,7 +47,7 @@ verdict lines.
47
47
 
48
48
  Flags:
49
49
  --target=<t>|all Restrict findings to one target: claude, cursor, codex,
50
- opencode, omp, pi, or all (default: all). `--target <t>` also works.
50
+ opencode, omp, pi, antigravity, muse, or all (default: all). `--target <t>` also works.
51
51
  --format=human|json Output format (default: human)
52
52
  --strict Exit 1 if any verdict is "unsupported"
53
53
  --help Show this help and exit 0
@@ -64,7 +64,7 @@ EOF
64
64
  # ---------------------------------------------------------------------------
65
65
 
66
66
  # Canonical target order; must match the matrix header after `capability`.
67
- ALL_TARGETS=("claude" "cursor" "codex" "opencode" "omp" "pi")
67
+ ALL_TARGETS=("claude" "cursor" "codex" "opencode" "omp" "pi" "antigravity" "muse")
68
68
 
69
69
  FORMAT="human"
70
70
  STRICT=0
@@ -114,7 +114,7 @@ case "$FORMAT" in
114
114
  esac
115
115
 
116
116
  case "$TARGET" in
117
- all|claude|cursor|codex|opencode|omp|pi) ;;
117
+ all|claude|cursor|codex|opencode|omp|pi|antigravity|muse) ;;
118
118
  *)
119
119
  echo "audit-target-features.sh: unknown --target value: $TARGET" >&2
120
120
  usage >&2
@@ -182,7 +182,7 @@ fi
182
182
  # ---------------------------------------------------------------------------
183
183
  # Parse the capability matrix via Python
184
184
  # Outputs: one line per capability row in the form:
185
- # <capability>|<claude>|<cursor>|<codex>|<opencode>|<omp>|<pi>
185
+ # <capability>|<claude>|<cursor>|<codex>|<opencode>|<omp>|<pi>|<antigravity>|<muse>
186
186
  # First line is the "As of ..." date (prefixed with "AS_OF:").
187
187
  # ---------------------------------------------------------------------------
188
188
 
@@ -193,7 +193,7 @@ matrix_path = sys.argv[1]
193
193
  matrix_rel = sys.argv[2]
194
194
 
195
195
  VOCABULARY = {"supported", "partial", "unsupported"}
196
- EXPECTED_HEADER = ["capability", "claude", "cursor", "codex", "opencode", "omp", "pi"]
196
+ EXPECTED_HEADER = ["capability", "claude", "cursor", "codex", "opencode", "omp", "pi", "antigravity", "muse"]
197
197
 
198
198
  lines = open(matrix_path).read().splitlines()
199
199
 
@@ -281,7 +281,7 @@ fi
281
281
  AS_OF_LINE="$(echo "$PARSE_RESULT" | grep "^AS_OF:" | sed 's/^AS_OF://')"
282
282
 
283
283
  # Build parallel arrays: CAPS, VERDICTS_CLAUDE, VERDICTS_CURSOR, VERDICTS_CODEX,
284
- # VERDICTS_OPENCODE, VERDICTS_OMP, VERDICTS_PI
284
+ # VERDICTS_OPENCODE, VERDICTS_OMP, VERDICTS_PI, VERDICTS_ANTIGRAVITY, VERDICTS_MUSE
285
285
  declare -a CAPS=()
286
286
  declare -a VERDICTS_CLAUDE=()
287
287
  declare -a VERDICTS_CURSOR=()
@@ -289,8 +289,10 @@ declare -a VERDICTS_CODEX=()
289
289
  declare -a VERDICTS_OPENCODE=()
290
290
  declare -a VERDICTS_OMP=()
291
291
  declare -a VERDICTS_PI=()
292
+ declare -a VERDICTS_ANTIGRAVITY=()
293
+ declare -a VERDICTS_MUSE=()
292
294
 
293
- while IFS='|' read -r cap cl cu co oc om pi; do
295
+ while IFS='|' read -r cap cl cu co oc om pi ag mu; do
294
296
  [[ "$cap" == AS_OF:* ]] && continue
295
297
  [[ -z "$cap" ]] && continue
296
298
  CAPS+=("$cap")
@@ -300,6 +302,8 @@ while IFS='|' read -r cap cl cu co oc om pi; do
300
302
  VERDICTS_OPENCODE+=("$oc")
301
303
  VERDICTS_OMP+=("$om")
302
304
  VERDICTS_PI+=("$pi")
305
+ VERDICTS_ANTIGRAVITY+=("$ag")
306
+ VERDICTS_MUSE+=("$mu")
303
307
  done < <(echo "$PARSE_RESULT" | grep -v "^AS_OF:")
304
308
 
305
309
  # ---------------------------------------------------------------------------
@@ -414,6 +418,8 @@ lookup_verdict() {
414
418
  opencode) echo "${VERDICTS_OPENCODE[$i]}"; return ;;
415
419
  omp) echo "${VERDICTS_OMP[$i]}"; return ;;
416
420
  pi) echo "${VERDICTS_PI[$i]}"; return ;;
421
+ antigravity) echo "${VERDICTS_ANTIGRAVITY[$i]}"; return ;;
422
+ muse) echo "${VERDICTS_MUSE[$i]}"; return ;;
417
423
  *)
418
424
  echo "audit-target-features.sh: lookup_verdict: unknown target '$target'" >&2
419
425
  exit 2
@@ -312,6 +312,6 @@ Each research file should: focus on its specific domain, include concrete exampl
312
312
  - **Single-owner research files** — each researcher writes only its assigned artifact
313
313
  - **Gate synthesis with validation** — do not generate `feature-spec.md` before validator pass
314
314
  - **Use web search** — external APIs require current documentation
315
- - **Be thorough but focused** — quality over quantity
315
+ - Cover each research lens with findings that inform the feature specification
316
316
  - **Enable plan-workflow** — this spec is the foundation for implementation planning
317
317
  - **Preserve uncertainty** — mark areas needing clarification rather than guessing
@@ -67,10 +67,6 @@ log_success() {
67
67
  echo -e "${GREEN}OK:${NC} $1"
68
68
  }
69
69
 
70
- log_info() {
71
- echo -e "INFO: $1"
72
- }
73
-
74
70
  # Check if file exists
75
71
  SPEC_FILE=""
76
72
  store_flag=""
@@ -150,7 +150,7 @@ Unless suppressed, run each applier. Each writes to a distinct file so they can
150
150
  {{package-root}}/skills/formatters/scripts/apply-ci.sh --target "$TARGET" --profile-file "$PROFILE_FILE" [--force] [--no-autofix]
151
151
  ```
152
152
 
153
- Pass `--no-autofix` when `NO_AUTOFIX=true` to install only the check workflow. The check workflow runs on every PR and on pushes to the default branch and `release/**`. The autofix workflow runs on same-repo PRs to the default branch (`origin/HEAD`, falling back to `main`), applies `./scripts/style.sh format` + `lint --fix`, and pushes fixes back as `github-actions[bot]`; fork PRs are skipped because `GITHUB_TOKEN` cannot push to them.
153
+ Pass `--no-autofix` when `NO_AUTOFIX=true` to install only the check workflow. The check workflow runs on every PR and on pushes to the default branch and `release/**`. The autofix workflow runs on same-repo PRs to the default branch (`origin/HEAD`, falling back to `main`) as two jobs. The `format` job checks out the PR head without persisted credentials, runs `./scripts/style.sh format` + `lint --fix` with a read-only `GITHUB_TOKEN` and no secrets, and uploads any fixes as a patch artifact. The `push` job never checks out or runs PR code: it validates the patch (in-place text edits to existing files only; anything else, including any path under `.github/` such as `.github/workflows/`, fails the job without pushing), mints a GitHub App installation token with Contents write only (`actions/create-github-app-token`), applies the patch in a fresh repository with hooks disabled, and pushes. It uses an App token because a push made with `GITHUB_TOKEN` leaves every check on the fix commit waiting for approval. It reads the App's client ID from the `AUTOFIX_APP_CLIENT_ID` variable and its private key from the `AUTOFIX_APP_PRIVATE_KEY` secret; without them, or if minting fails, it reports the fixes in a warning and the job summary instead of pushing. Fork PRs are skipped by both jobs because the workflow cannot push to them.
154
154
 
155
155
  4. **Hooks** (run when `HOOKS=true`, OR when the target already has a `lefthook.yml` / `.husky/pre-commit` — i.e., `has_lefthook=true` or `has_husky=true` in the profile):
156
156
 
@@ -177,6 +177,7 @@ Produce a summary with these sections:
177
177
  - `lefthook install` (if `--hooks` + lefthook chosen)
178
178
  - Review `scripts/` bundle in the first commit that adds it
179
179
  - Re-run with `formatters --sync` after upstream bundle changes
180
+ - If `lint-autofix.yml` was written: create a GitHub App with repository permission Contents read and write (no Workflows permission: autofix never pushes changes under `.github/`, so format those locally), install it on the repository, and set the `AUTOFIX_APP_CLIENT_ID` variable and `AUTOFIX_APP_PRIVATE_KEY` secret; until then the workflow reports fixes instead of pushing. Anyone who can write to a repository holding the private key can mint tokens for every repository the App is installed on, so reuse one App only across repositories with the same trusted writers. Organization-level variables and secrets are not available to private repositories on GitHub Free; set them on the repository there
180
181
  - Bypass a single hook run: `git commit --no-verify`
181
182
 
182
183
  ## Important Notes
@@ -90,9 +90,13 @@ The check workflow runs on every pull request and on pushes to the default branc
90
90
  The autofix workflow:
91
91
 
92
92
  - Triggers on pull requests to the target repo's default branch (detected via `git symbolic-ref refs/remotes/origin/HEAD`, falling back to `main`).
93
- - Skips fork PRs via `github.event.pull_request.head.repo.full_name == github.repository` — `GITHUB_TOKEN` cannot push to fork branches.
94
- - Commits as `github-actions[bot]`; the check workflow (`lint.yml`) still runs authoritatively on the resulting push.
95
- - Carries a commented `git add -u -- . ':(exclude)...'` placeholder — customize after install if the project has generated files that should not be auto-fixed.
93
+ - Skips fork PRs in both jobs via `github.event.pull_request.head.repo.full_name == github.repository`; the workflow cannot push to fork branches.
94
+ - Runs two jobs. The `format` job checks out the PR head (`persist-credentials: false`), runs the language setup and `./scripts/style.sh format` + `lint --fix` with `GITHUB_TOKEN` at `contents: read` and no secrets, and uploads any fixes as a `git diff` patch artifact. With no fixes it succeeds and the `push` job is skipped.
95
+ - The `push` job holds the App key and token, so it never checks out or runs PR code: no `./scripts/style.sh`, package installs, or hooks. It treats the patch as untrusted, accepts only in-place text edits to existing regular files, and fails without pushing on anything else, including any path under `.github/` (workflows, local actions, and repository settings). It applies the patch to the PR head commit's index in a fresh repository (the PR tree is never written to disk, hooks are disabled), re-checks the result, and pushes. Keep it on GitHub-hosted or ephemeral runners so nothing started by the `format` job can outlive it. The split keeps the App key away from code that the formatters and package installs run; it does not protect against someone who can push a changed workflow file to a branch, so limit branch write access to trusted writers and review autofix commits like any other commit on the PR.
96
+ - Pushes with a GitHub App installation token minted by `actions/create-github-app-token` with Contents write only. A push made with `GITHUB_TOKEN` creates the `pull_request` runs for the fix commit in an approval-required state, so every check on it would wait for a maintainer.
97
+ - Needs the `AUTOFIX_APP_CLIENT_ID` variable and `AUTOFIX_APP_PRIVATE_KEY` secret and an App with repository permission Contents read and write, installed on the repo. The App needs no Workflows permission: the `format` job leaves `.github/` out of the patch (format those files locally; `lint.yml` still reports them) and the `push` job refuses them. Organization-level variables and secrets are not available to private repositories on GitHub Free, so set them on the repository there. Anyone who can write to a repository holding the private key can mint tokens for every repository the App is installed on, so reuse one App only across repositories with the same trusted writers. Without them, or if minting fails, the job prints a warning, lists the fixes in the job summary, and exits successfully without pushing.
98
+ - Commits as `github-actions[bot]`; the check workflow (`lint.yml`) still runs authoritatively on the resulting push. A loop guard stops a second push when the PR head is already the autofix commit and the fixers still change files.
99
+ - Carries a commented `git add -u -- . ':(exclude)...'` placeholder in the `format` job — customize after install if the project has generated files that should not be auto-fixed.
96
100
 
97
101
  ```
98
102
  formatters --ci # installs both workflows
@@ -102,7 +106,7 @@ formatters --ci --no-autofix # install only lint.yml (check-only)
102
106
 
103
107
  ### `--no-autofix`
104
108
 
105
- Only meaningful when `--ci` is set. Skips installing `lint-autofix.yml`. The existing check workflow (`lint.yml`) is still installed. Use when a repo has branch-protection rules that forbid bot pushes, or when the team prefers to run formatters exclusively via pre-commit hooks.
109
+ Only meaningful when `--ci` is set. Skips installing `lint-autofix.yml`. The existing check workflow (`lint.yml`) is still installed. Use when a repo has branch-protection rules that forbid bot pushes, when no GitHub App can be set up for the push, or when the team prefers to run formatters exclusively via pre-commit hooks.
106
110
 
107
111
  ```
108
112
  formatters --ci --no-autofix
@@ -5,25 +5,33 @@ on:
5
5
  branches: [{{DEFAULT_BRANCH}}]
6
6
 
7
7
  permissions:
8
- contents: write
8
+ contents: read
9
9
 
10
10
  concurrency:
11
11
  group: lint-autofix-${{ github.event.pull_request.number || github.ref }}
12
12
  cancel-in-progress: true
13
13
 
14
14
  jobs:
15
- format-and-push:
16
- name: Format and push fixes
15
+ # The work is split so PR code never shares a job with the App key or token:
16
+ # format: checks out and runs the PR branch (formatters, package installs) with a
17
+ # read-only GITHUB_TOKEN and no secrets, then uploads the fixes as a patch.
18
+ # push: never checks out or runs PR code. It treats the patch as untrusted input,
19
+ # validates it, mints the App token, applies the patch and pushes.
20
+ format:
21
+ name: Format (read-only)
17
22
  # Fork PRs cannot be pushed back to; the check workflow (lint.yml) still runs authoritatively.
18
23
  if: github.event.pull_request.head.repo.full_name == github.repository
19
24
  runs-on: ubuntu-latest
25
+ permissions:
26
+ contents: read
27
+ outputs:
28
+ has_patch: ${{ steps.patch.outputs.has_patch }}
20
29
  steps:
21
- - name: Checkout PR head branch
22
- uses: actions/checkout@v4
30
+ - name: Checkout PR head
31
+ uses: actions/checkout@v7
23
32
  with:
24
- ref: ${{ github.head_ref }}
25
- fetch-depth: 0
26
- token: ${{ secrets.GITHUB_TOKEN }}
33
+ ref: ${{ github.event.pull_request.head.sha }}
34
+ persist-credentials: false
27
35
 
28
36
  {{#IF_RUST}}
29
37
  - uses: dtolnay/rust-toolchain@stable
@@ -33,14 +41,14 @@ jobs:
33
41
  {{/IF_RUST}}
34
42
 
35
43
  {{#IF_GO}}
36
- - uses: actions/setup-go@v5
44
+ - uses: actions/setup-go@v7
37
45
  with:
38
46
  go-version: stable
39
47
  cache: true
40
48
  {{/IF_GO}}
41
49
 
42
50
  {{#IF_TS}}
43
- - uses: actions/setup-node@v4
51
+ - uses: actions/setup-node@v7
44
52
  with:
45
53
  node-version: lts/*
46
54
  cache: npm
@@ -48,7 +56,7 @@ jobs:
48
56
  {{/IF_TS}}
49
57
 
50
58
  {{#IF_PYTHON}}
51
- - uses: actions/setup-python@v5
59
+ - uses: actions/setup-python@v7
52
60
  with:
53
61
  python-version: "3.12"
54
62
  - run: pip install --no-cache-dir ruff black
@@ -60,7 +68,7 @@ jobs:
60
68
  {{/IF_SHELL}}
61
69
 
62
70
  {{#IF_DOCS}}
63
- - uses: actions/setup-node@v4
71
+ - uses: actions/setup-node@v7
64
72
  with:
65
73
  node-version: lts/*
66
74
  {{/IF_DOCS}}
@@ -69,26 +77,184 @@ jobs:
69
77
  run: ./scripts/style.sh format
70
78
 
71
79
  - name: Apply auto-fixable lint
72
- # Unfixable violations are reported by the check workflow (lint.yml); do not block the push-back here.
80
+ # Unfixable violations are reported by the check workflow (lint.yml); do not block the autofix here.
73
81
  run: ./scripts/style.sh lint --fix
74
82
  continue-on-error: true
75
83
 
76
- - name: Commit and push if changed
84
+ - name: Export autofix patch
85
+ id: patch
86
+ run: |
87
+ # The push job refuses changes under .github/ (workflows, local actions and repo
88
+ # settings; its App token has no Workflows permission), so leave them out here.
89
+ # lint.yml still reports them. Customize exclusions here, e.g.:
90
+ # git add -u -- . ':(exclude).github' ':(exclude)CHANGELOG.md' ':(exclude)docs/internal/**'
91
+ git add -u -- . ':(exclude).github'
92
+ if ! git diff --quiet -- .github; then
93
+ echo "::notice title=Lint autofix skipped .github/ files::Format .github/ locally; autofix does not push files under .github/."
94
+ fi
95
+ if git diff --cached --quiet; then
96
+ echo "No autofix changes."
97
+ echo "has_patch=false" >> "$GITHUB_OUTPUT"
98
+ exit 0
99
+ fi
100
+ git diff --cached --stat
101
+ git diff --cached --no-color --no-ext-diff --no-textconv --no-renames --full-index > "$RUNNER_TEMP/autofix.patch"
102
+ echo "has_patch=true" >> "$GITHUB_OUTPUT"
103
+
104
+ - name: Upload autofix patch
105
+ if: steps.patch.outputs.has_patch == 'true'
106
+ uses: actions/upload-artifact@v7
107
+ with:
108
+ name: lint-autofix-patch
109
+ path: ${{ runner.temp }}/autofix.patch
110
+ if-no-files-found: error
111
+ retention-days: 1
112
+ overwrite: true
113
+
114
+ push:
115
+ name: Push autofix commit
116
+ needs: format
117
+ if: github.event.pull_request.head.repo.full_name == github.repository && needs.format.outputs.has_patch == 'true'
118
+ # This job holds the App key and token. It never checks out or runs PR code: no
119
+ # ./scripts/style.sh, no package installs, no hooks, and no PR files written to disk.
120
+ # Keep it on GitHub-hosted (or ephemeral self-hosted) runners so nothing the format
121
+ # job started on a runner can outlive that job and reach this one.
122
+ runs-on: ubuntu-latest
123
+ permissions:
124
+ contents: read
125
+ env:
126
+ # 'true' once the autofix App is configured for this repository (see the mint step).
127
+ AUTOFIX_APP_CONFIGURED: ${{ vars.AUTOFIX_APP_CLIENT_ID != '' && secrets.AUTOFIX_APP_PRIVATE_KEY != '' }}
128
+ steps:
129
+ - name: Download autofix patch
130
+ uses: actions/download-artifact@v8
131
+ with:
132
+ name: lint-autofix-patch
133
+ path: ${{ runner.temp }}/autofix-artifact
134
+
135
+ - name: Validate autofix patch
136
+ # The patch comes from a job that ran PR code, so it is untrusted: copy only the
137
+ # patch file out of the artifact, run git from an empty directory, and accept only
138
+ # in-place text edits to existing files outside .github/. Anything else fails
139
+ # without pushing. The push step re-checks the applied result.
140
+ run: |
141
+ refuse() {
142
+ echo "::error title=Lint autofix refused::$1"
143
+ exit 1
144
+ }
145
+ artifact="$RUNNER_TEMP/autofix-artifact/autofix.patch"
146
+ patch="$RUNNER_TEMP/autofix.patch"
147
+ [[ -f "$artifact" && ! -L "$artifact" ]] || refuse "The autofix patch is missing."
148
+ cp -- "$artifact" "$patch"
149
+ rm -rf -- "$RUNNER_TEMP/autofix-artifact"
150
+ [[ -s "$patch" ]] || refuse "The autofix patch is empty."
151
+ scratch="$(mktemp -d)"
152
+ cd "$scratch"
153
+ export GIT_CEILING_DIRECTORIES="${scratch%/*}"
154
+ summary="$(git apply --summary "$patch")" || refuse "The autofix patch could not be parsed."
155
+ if [[ -n "$summary" ]]; then
156
+ refuse "The autofix patch creates, deletes, renames, or changes the mode of a file."
157
+ fi
158
+ git apply --numstat -z "$patch" > "$scratch/numstat" || refuse "The autofix patch could not be parsed."
159
+ files=0
160
+ while IFS= read -r -d '' record; do
161
+ added="${record%%$'\t'*}"
162
+ path="${record#*$'\t'*$'\t'}"
163
+ [[ -n "$path" && "$path" != "$record" ]] || refuse "The autofix patch has an unexpected file entry."
164
+ [[ "$path" != *[[:cntrl:]]* ]] || refuse "The autofix patch has a file name with control characters."
165
+ [[ "$added" != "-" ]] || refuse "The autofix patch changes a binary file: $path"
166
+ case "/${path,,}/" in
167
+ /.github/*) refuse "The autofix patch changes a file under .github/: $path" ;;
168
+ //* | */../* | */./*) refuse "The autofix patch has an unsafe path: $path" ;;
169
+ esac
170
+ files=$((files + 1))
171
+ done < "$scratch/numstat"
172
+ (( files > 0 )) || refuse "The autofix patch changes no files."
173
+ echo "Autofix patch accepted: $files file(s)."
174
+
175
+ - name: Mint autofix App token
176
+ id: app-token
177
+ # A push made with GITHUB_TOKEN leaves every check on the autofix commit waiting for
178
+ # approval, so the push uses a GitHub App token with Contents write only.
179
+ # Without the App variable and secret (or if minting fails) the job reports, not pushes.
180
+ if: env.AUTOFIX_APP_CONFIGURED == 'true'
181
+ continue-on-error: true
182
+ uses: actions/create-github-app-token@v3
183
+ with:
184
+ client-id: ${{ vars.AUTOFIX_APP_CLIENT_ID }}
185
+ private-key: ${{ secrets.AUTOFIX_APP_PRIVATE_KEY }}
186
+ permission-contents: write
187
+
188
+ - name: Report fixes without pushing
189
+ if: steps.app-token.outputs.token == ''
190
+ run: |
191
+ patch="$RUNNER_TEMP/autofix.patch"
192
+ echo "::warning title=Lint autofix not pushed::Fixes found but not pushed: set the AUTOFIX_APP_CLIENT_ID variable and AUTOFIX_APP_PRIVATE_KEY secret (or check the App installation)."
193
+ {
194
+ echo "### Lint autofix: fixes found, not pushed"
195
+ echo
196
+ echo "This workflow pushes with a GitHub App token. Set the \`AUTOFIX_APP_CLIENT_ID\` variable and \`AUTOFIX_APP_PRIVATE_KEY\` secret, or run the formatters locally."
197
+ echo
198
+ echo '```'
199
+ (cd "$(mktemp -d)" && git apply --stat "$patch")
200
+ echo '```'
201
+ } >> "$GITHUB_STEP_SUMMARY"
202
+
203
+ - name: Commit and push autofix patch
204
+ if: steps.app-token.outputs.token != ''
77
205
  env:
78
206
  PR_HEAD_REF: ${{ github.head_ref }}
207
+ PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
208
+ AUTOFIX_SUBJECT: "chore: apply format + lint --fix (autofix workflow)"
209
+ AUTOFIX_TOKEN: ${{ steps.app-token.outputs.token }}
79
210
  run: |
211
+ patch="$RUNNER_TEMP/autofix.patch"
212
+ remote="https://x-access-token:${AUTOFIX_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
213
+ # Work in a fresh repository with only the PR head commit in its object store and
214
+ # index: the PR tree is never written to disk, and hooks are disabled, so nothing
215
+ # from the PR runs. Only git fetch, apply, commit, and push run here.
216
+ repo="$RUNNER_TEMP/autofix-repo"
217
+ git -c core.hooksPath=/dev/null init -q --template= "$repo"
218
+ cd "$repo"
219
+ git config core.hooksPath /dev/null
80
220
  git config user.name "github-actions[bot]"
81
221
  git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
82
- if git diff --quiet && git diff --cached --quiet; then
83
- echo "No autofix changes."
222
+ git fetch -q --depth=1 --no-tags "$remote" "$PR_HEAD_SHA"
223
+ git update-ref HEAD "$PR_HEAD_SHA"
224
+ git read-tree HEAD
225
+ # Loop guard: the App push starts a new run on the autofix commit. If HEAD is already
226
+ # that commit and the fixers still change files, they are not idempotent; stop here.
227
+ if [[ "$(git log -1 --format=%s HEAD)" == "$AUTOFIX_SUBJECT" ]]; then
228
+ echo "::warning title=Lint autofix stopped::HEAD is already an autofix commit and the fixers still change files; not pushing again."
229
+ git apply --stat "$patch"
84
230
  exit 0
85
231
  fi
86
- # Customize exclusions here, e.g.:
87
- # git add -u -- . ':(exclude)CHANGELOG.md' ':(exclude)docs/internal/**'
88
- git add -u -- .
89
- if git diff --cached --quiet; then
90
- echo "No autofix changes remain after exclusions."
232
+ git apply --cached "$patch"
233
+ # Re-check what actually landed in the index: in-place edits to regular text files
234
+ # only (a forced-text diff can hide binary content from the validate step), nothing
235
+ # under .github/.
236
+ git diff --cached --raw -z --no-renames HEAD > "$RUNNER_TEMP/autofix.raw"
237
+ while IFS= read -r -d '' meta && IFS= read -r -d '' path; do
238
+ read -r old_mode new_mode old_blob new_blob status <<< "${meta#:}"
239
+ case "$old_mode:$new_mode:$status" in
240
+ 100644:100644:M | 100755:100755:M) ;;
241
+ *) echo "::error title=Lint autofix refused::The autofix patch changes something other than a regular file's contents."; exit 1 ;;
242
+ esac
243
+ case "${path,,}" in
244
+ .github/*) echo "::error title=Lint autofix refused::The autofix patch changes a file under .github/."; exit 1 ;;
245
+ esac
246
+ for blob in "$old_blob" "$new_blob"; do
247
+ nul_bytes="$(git cat-file blob "$blob" | tr -dc '\000' | wc -c)"
248
+ if (( nul_bytes > 0 )); then
249
+ echo "::error title=Lint autofix refused::The autofix patch changes a binary file."
250
+ exit 1
251
+ fi
252
+ done
253
+ done < "$RUNNER_TEMP/autofix.raw"
254
+ if git diff --cached --quiet HEAD; then
255
+ echo "No autofix changes after applying the patch."
91
256
  exit 0
92
257
  fi
93
- git commit -m "chore: apply format + lint --fix (autofix workflow)"
94
- git push origin "HEAD:${PR_HEAD_REF}"
258
+ git commit -q --no-verify -m "$AUTOFIX_SUBJECT"
259
+ git show --stat --format='%h %s' HEAD
260
+ git push -q --no-verify "$remote" "HEAD:refs/heads/${PR_HEAD_REF}"