@ryusenkei/conventions 0.2.0 → 0.2.1

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.
package/README.md CHANGED
@@ -53,7 +53,7 @@ The PreToolUse hook blocks the call and tells Claude why, so Claude can fix it a
53
53
  | PR title = squash commit message | Checks `gh pr create` / `gh pr edit` titles with prose-lint's commit rules |
54
54
  | No AI signature | `attribution` is empty, and the hook blocks PR bodies with an AI signature |
55
55
  | Squash merge only | Blocks `gh pr merge --merge` / `--rebase` |
56
- | Merge only after CI passes | Blocks `gh pr merge` unless every check of the PR has passed (`gh pr checks`). Pending, failed, missing, or unreadable checks are blocked, also with `--auto` |
56
+ | Merge only after CI passes | Blocks `gh pr merge` unless every check of the PR has passed (`gh pr checks`). Pending, failed, missing, or unreadable checks are blocked, also with `--auto` (with the epic flow, a PR into `dev/*` may have no checks) |
57
57
  | Epic flow (opt-in) | See [Epic flow](#epic-flow) |
58
58
  | Do not edit `node_modules` | Blocks Edit and Write under `node_modules` |
59
59
  | Secrets | `permissions.deny` blocks reading `.env` and `.dev.vars` with Claude's file tools (not Bash) |
@@ -74,6 +74,7 @@ Opt in per repository in the root `package.json`:
74
74
  - Each epic gets an integration branch `dev/<issue>-<name>` (e.g. `dev/12-search`). Sub-issue PRs target it, and only a `dev/*` branch is merged into `main` (on deploy).
75
75
  - `gh pr create` to `main` (`--base main`, or no `--base`) is blocked unless the head (`--head`, or the current branch) is `dev/*`.
76
76
  - A PR from any other branch must target a `dev/*` base. `gh pr edit` is checked only when it changes `--base`.
77
+ - A PR into `dev/*` runs no CI; the pre-push `pnpm check` is the gate. `gh pr merge` allows such a PR with no checks, but any checks it has must still pass.
77
78
  - Without the opt-in, none of this applies and `dev/*` branch names are rejected.
78
79
 
79
80
  ## Synced files
package/dist/hook.js CHANGED
@@ -14,7 +14,7 @@ const root = process.env.CLAUDE_PROJECT_DIR ?? input.cwd ?? process.cwd();
14
14
  // Windows の `pnpm` は `.cmd` → シェル経由でのみ起動可能
15
15
  const shell = process.platform === 'win32';
16
16
  if (input.hook_event_name === 'PreToolUse') {
17
- const reason = denyReason(input, { root, titleIssues, readFile, currentBranch, prHead, prChecks });
17
+ const reason = denyReason(input, { root, titleIssues, readFile, currentBranch, prHead, prBase, prChecks });
18
18
  if (reason) {
19
19
  process.stderr.write(`${reason}\n`);
20
20
  process.exit(2);
@@ -53,6 +53,10 @@ function prHead(pr, cwd) {
53
53
  const r = spawnSync('gh', ['pr', 'view', ...(pr ? [pr] : []), '--json', 'headRefName', '--jq', '.headRefName'], { cwd: cwd ?? root, encoding: 'utf8' });
54
54
  return (r.status === 0 && r.stdout.trim()) || undefined;
55
55
  }
56
+ function prBase(pr, cwd) {
57
+ const r = spawnSync('gh', ['pr', 'view', ...(pr ? [pr] : []), '--json', 'baseRefName', '--jq', '.baseRefName'], { cwd: cwd ?? root, encoding: 'utf8' });
58
+ return (r.status === 0 && r.stdout.trim()) || undefined;
59
+ }
56
60
  // `gh pr checks` は実行中・失敗で終了コードが0以外(8・1)→ 終了コードではなく出力で判定
57
61
  function prChecks(pr, cwd) {
58
62
  const r = spawnSync('gh', ['pr', 'checks', ...(pr ? [pr] : []), '--json', 'bucket'], { cwd: cwd ?? root, encoding: 'utf8' });
package/dist/policy.d.ts CHANGED
@@ -18,6 +18,8 @@ export type Context = {
18
18
  currentBranch: (cwd: string | undefined) => string | undefined;
19
19
  /** PR の head のブランチ(`pr` の省略時は現在のブランチの PR) */
20
20
  prHead: (pr: string | undefined, cwd: string | undefined) => string | undefined;
21
+ /** PR の base のブランチ(`pr` の省略時は現在のブランチの PR) */
22
+ prBase: (pr: string | undefined, cwd: string | undefined) => string | undefined;
21
23
  /** PR のチェックの集計(`pr` の省略時は現在のブランチの PR) */
22
24
  prChecks: (pr: string | undefined, cwd: string | undefined) => Checks;
23
25
  };
package/dist/policy.js CHANGED
@@ -195,11 +195,20 @@ function prReasons(sub, args, cwd, ctx) {
195
195
  return reasons;
196
196
  }
197
197
  // `--auto` も対象(必須のチェックがないリポでは即時にマージされる)
198
+ // - epic のフローの dev/* への PR: チェックなしを許可(CI を実行せず pre-push の `pnpm check` が関門)
198
199
  function mergeReasons(args, cwd, ctx) {
199
200
  if (args.some((a) => a === '--merge' || a === '--rebase' || a === '-m' || a === '-r'))
200
201
  return ['マージは squash のみ(`--squash`)'];
201
- const checks = ctx.prChecks(positionals(args, MERGE_VALUE)[0], cwd);
202
- return checks === 'pass' ? [] : [CHECKS_REASON[checks]];
202
+ const pr = positionals(args, MERGE_VALUE)[0];
203
+ const checks = ctx.prChecks(pr, cwd);
204
+ if (checks === 'pass')
205
+ return [];
206
+ if (checks === 'none' && epicFlow(ctx)) {
207
+ const base = ctx.prBase(pr, cwd);
208
+ if (base !== undefined && DEV_BRANCH.test(base))
209
+ return [];
210
+ }
211
+ return [CHECKS_REASON[checks]];
203
212
  }
204
213
  // epic のフロー: main への PR は dev/* から、それ以外のブランチの PR は dev/* へ
205
214
  // - `gh pr create` の base の省略 = main(既定のブランチ)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryusenkei/conventions",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "RYUSENKEI のモノリポの共通の規約(Claude Code の規約・hook、共通ファイルの同期)",
5
5
  "license": "MIT",
6
6
  "author": "RYUSENKEI",
package/rules.md CHANGED
@@ -39,6 +39,7 @@
39
39
  - マージ: CI の全チェックの成功を確認してから(フックで強制)
40
40
  - epic のフロー(有効にしたリポのみ)
41
41
  - epic ごとに `dev/<issue の番号>-<内容>` を作成し、sub-issue の PR は dev のブランチへ
42
+ - dev のブランチへのマージは CI なし、pre-push の `pnpm check` が関門(チェックがある場合は成功が必要)
42
43
  - `main` へのマージはデプロイのときだけ dev のブランチから
43
44
 
44
45
  ## 完了の条件