@ryusenkei/conventions 0.5.2 → 0.7.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.
package/README.md CHANGED
@@ -5,6 +5,7 @@ Shared conventions for RYUSENKEI monorepos created from monorepo-template. Rules
5
5
  | Part | What it does |
6
6
  | --- | --- |
7
7
  | [`rules.md`](rules.md) | Rules for Claude Code, imported from each repository's `CLAUDE.md` (Japanese) |
8
+ | [`rules-ts.md`](rules-ts.md), [`rules-go.md`](rules-go.md), [`rules-rust.md`](rules-rust.md), [`rules-ui.md`](rules-ui.md) | Rules for one language or for UI code, imported only where they apply |
8
9
  | `dist/hook.js` | Claude Code hook: blocks tool calls that break the rules, and optionally runs lint and tests before Claude finishes |
9
10
  | `files/` | Master copies of the shared files, synced into each repository |
10
11
  | `ryusenkei-conventions` | CLI: `sync` writes the shared files, `check` reports drift |
@@ -31,6 +32,7 @@ Requires Node.js 24 or later.
31
32
  - Repository-specific rules
32
33
 
33
34
  @node_modules/@ryusenkei/conventions/rules.md
35
+ @node_modules/@ryusenkei/conventions/rules-ts.md
34
36
  ```
35
37
 
36
38
  2. Write the shared files: `npx ryusenkei-conventions sync` (add `--stop` to run lint and tests before Claude finishes).
@@ -52,13 +54,15 @@ The PreToolUse hook blocks the call and tells Claude why, so Claude can fix it a
52
54
  | No force push to `main` / `master` | Blocks `git push --force` / `-f` / `--force-with-lease` and `+<refspec>` targeting `main` or `master` (also the current branch when no refspec is given) |
53
55
  | PR title = squash commit message | Checks `gh pr create` / `gh pr edit` titles with prose-lint's commit rules |
54
56
  | No AI signature | `attribution` is empty, and the hook blocks PR bodies with an AI signature |
55
- | Squash merge only | Blocks `gh pr merge --merge` / `--rebase` |
57
+ | Squash merge | Blocks `gh pr merge --rebase`, and `--merge` except for a `dev/*` → `main` PR with the epic flow, which must use `--merge` |
56
58
  | 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
59
  | Epic flow (opt-in) | See [Epic flow](#epic-flow) |
58
60
  | Do not edit `node_modules` | Blocks Edit and Write under `node_modules` |
59
61
  | Secrets | `permissions.deny` blocks reading `.env` and `.dev.vars` with Claude's file tools (not Bash) |
60
62
  | Definition of done (`--stop`) | The Stop hook runs `pnpm lint` and `pnpm test` when the working tree has changes, and sends Claude back once on failure |
61
63
 
64
+ The hook works out the target from the command itself. After `cd` or `git -C`, it checks against that repository (including its epic opt-in and `prose-lint.json`). After `git switch` or `git checkout`, it uses the new branch. Heredoc bodies are not parsed as commands.
65
+
62
66
  Commit messages are checked by `.githooks/commit-msg`, and edited files by prose-lint's PostToolUse hook. `.githooks/pre-push` runs `pnpm run --if-present check`, so a repository that defines a `check` script cannot push until it passes. It applies to people as well as Claude. When [Hostslot](https://github.com/ryusenkei-inc/hostslot) (`hostslot`) is on the `PATH` and the repository has a `check` script, the check runs through `hostslot run`, so pushes from parallel agents and repositories wait for free memory instead of exhausting it.
63
67
 
64
68
  ### Epic flow
@@ -74,6 +78,7 @@ Opt in per repository in the root `package.json`:
74
78
  - 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
79
  - `gh pr create` to `main` (`--base main`, or no `--base`) is blocked unless the head (`--head`, or the current branch) is `dev/*`.
76
80
  - A PR from any other branch must target a `dev/*` base. `gh pr edit` is checked only when it changes `--base`.
81
+ - A `dev/*` → `main` PR is merged with a merge commit (`gh pr merge --merge`), not squashed. This keeps one commit per sub-issue on `main`, and keeps `dev/*` and `main` from diverging when work continues on the epic after a deploy. Turn on "Allow merge commits" in the repository settings.
77
82
  - 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.
78
83
  - Without the opt-in, none of this applies and `dev/*` branch names are rejected.
79
84
 
@@ -84,10 +89,20 @@ Opt in per repository in the root `package.json`:
84
89
  - `.editorconfig`, `.gitattributes`, `.gitignore`, `.gitleaks.toml`, `mise.toml`, `.github/dependabot.yaml`, `.githooks/commit-msg`, `.githooks/pre-push`
85
90
  - `.github/dependabot.yaml` updates npm and GitHub Actions. When the repository has a `go.mod` at the root, a `gomod` entry is appended (same schedule, rebase strategy and cooldown, minor and patch grouped). Without one it is left out, because Dependabot fails on a missing `go.mod`
86
91
  - When the repository has a `Cargo.toml` at the root, a `cargo` entry is appended to `.github/dependabot.yaml` after any `gomod` entry (same settings as `gomod`, covering workspace members), and `target/` is appended to `.gitignore`. `Cargo.lock` stays tracked
87
- - `.claude/settings.json`: only the hooks, `attribution`, and `permissions.deny` are managed. Other settings and hooks are kept
92
+ - `.claude/settings.json`: only the hooks, `attribution`, `permissions.deny`, and the writing plugins are managed. Other settings, hooks, and plugins are kept
93
+ - The writing plugins are [yomiyasu](https://github.com/nanaism/yomiyasu) (Japanese) and [humanizer](https://github.com/blader/humanizer) (English). `extraKnownMarketplaces` registers their marketplaces and `enabledPlugins` turns them on. They load after you trust the folder, with no separate install. They are not bundled, and they do not auto-update; run `/plugin` to update them. To turn one off in a repository, set it to `false` in `enabledPlugins`
88
94
  - `pnpm-workspace.yaml`: `minimumReleaseAge` and `minimumReleaseAgeExclude`, matching the Dependabot `cooldown`
89
95
 
90
- `check` also reports a missing `rules.md` import in `CLAUDE.md`.
96
+ `check` also reports a missing `rules.md` import in `CLAUDE.md`, and the imports of the language and UI rules a repository needs:
97
+
98
+ | Rules | Required when |
99
+ | --- | --- |
100
+ | `rules-ts.md` | `tsconfig.json` at the root |
101
+ | `rules-go.md` | `go.mod` at the root |
102
+ | `rules-rust.md` | `Cargo.toml` at the root |
103
+ | `rules-ui.md` | `"ryusenkei": { "ui": true }` in the root `package.json` |
104
+
105
+ When the `rules.md` import is present, `sync` adds the missing ones right after it.
91
106
 
92
107
  Dependabot runs monthly with `rebase-strategy: disabled` to save GitHub Actions minutes, so rebase a Dependabot PR (`@dependabot rebase`) before merging it. The `cooldown` excludes `@ryusenkei/*`. To pick up a new version sooner, run `pnpm update "@ryusenkei/*"`. After an update, `check` fails until `sync` is run.
93
108
 
package/dist/files.js CHANGED
@@ -26,6 +26,21 @@ const SETTINGS = '.claude/settings.json';
26
26
  const WORKSPACE = 'pnpm-workspace.yaml';
27
27
  /** CLAUDE.md で共通の規約を読み込む import */
28
28
  export const IMPORT = '@node_modules/@ryusenkei/conventions/rules.md';
29
+ // 言語・UI の規約: 条件に合うリポだけ import を求める(UI は `package.json` の `"ryusenkei": { "ui": true }` で opt-in)
30
+ const LANG_RULES = [
31
+ { file: 'rules-ts.md', if: (root) => existsSync(join(root, 'tsconfig.json')) },
32
+ { file: 'rules-go.md', if: (root) => existsSync(join(root, 'go.mod')) },
33
+ { file: 'rules-rust.md', if: (root) => existsSync(join(root, 'Cargo.toml')) },
34
+ { file: 'rules-ui.md', if: (root) => uiOptIn(root) },
35
+ ];
36
+ function uiOptIn(root) {
37
+ try {
38
+ return JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).ryusenkei?.ui === true;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
29
44
  // `.github/dependabot.yaml` の `cooldown` と同値
30
45
  const RELEASE_AGE = [
31
46
  '# 公開から2日未満のバージョンは解決しない(`.github/dependabot.yaml` の `cooldown` と同値)',
@@ -49,7 +64,7 @@ export function drifts(root, options = {}) {
49
64
  const current = raw === undefined ? {} : JSON.parse(raw);
50
65
  const settings = `${JSON.stringify(managedSettings(current, { stop: options.stop ?? hasStop(current) }), null, 2)}\n`;
51
66
  if (raw !== settings)
52
- out.push({ path: SETTINGS, expected: settings, message: 'hook・`attribution`・`permissions.deny` が不一致' });
67
+ out.push({ path: SETTINGS, expected: settings, message: 'hook・`attribution`・`permissions.deny`・プラグインが不一致' });
53
68
  const workspace = read(join(root, WORKSPACE)) ?? '';
54
69
  if (!workspace.includes(RELEASE_AGE.slice(1).join('\n'))) {
55
70
  if (/^minimumReleaseAge/m.test(workspace))
@@ -58,8 +73,13 @@ export function drifts(root, options = {}) {
58
73
  out.push({ path: WORKSPACE, expected: `${workspace.trimEnd()}\n\n${RELEASE_AGE.join('\n')}\n`, message: '`minimumReleaseAge` が未設定' });
59
74
  }
60
75
  const claude = read(join(root, 'CLAUDE.md')) ?? '';
61
- if (!claude.split('\n').some((l) => l.trim() === IMPORT))
62
- out.push({ path: 'CLAUDE.md', message: `共通の規約の import(\`${IMPORT}\`)を追加` });
76
+ const lines = claude.split('\n');
77
+ const at = lines.findIndex((l) => l.trim() === IMPORT);
78
+ const missing = LANG_RULES.filter((r) => r.if(root)).map((r) => IMPORT.replace('rules.md', r.file)).filter((line) => !lines.some((l) => l.trim() === line));
79
+ if (at === -1)
80
+ out.push({ path: 'CLAUDE.md', message: `共通の規約の import(\`${[IMPORT, ...missing].join('`・`')}\`)を追加` });
81
+ else if (missing.length)
82
+ out.push({ path: 'CLAUDE.md', expected: [...lines.slice(0, at + 1), ...missing, ...lines.slice(at + 1)].join('\n'), message: `規約の import(\`${missing.join('`・`')}\`)が不足` });
63
83
  return out;
64
84
  }
65
85
  /** 自動で修正できる差分を書き込み、残りの差分を返却 */
package/dist/hook.js CHANGED
@@ -5,8 +5,8 @@
5
5
  // - hook 自体の失敗は終了コード1(拒否にしない → 作業を継続)
6
6
  import { spawnSync } from 'node:child_process';
7
7
  import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
8
- import { tmpdir } from 'node:os';
9
- import { join } from 'node:path';
8
+ import { homedir, tmpdir } from 'node:os';
9
+ import { isAbsolute, join, resolve } from 'node:path';
10
10
  import { fileURLToPath } from 'node:url';
11
11
  import { denyReason } from "./policy.js";
12
12
  const input = JSON.parse(readFileSync(0, 'utf8'));
@@ -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, prBase, prChecks });
17
+ const reason = denyReason(input, { root, repoRoot, resolveDir, titleIssues, readFile, currentBranch, prHead, prBase, prChecks });
18
18
  if (reason) {
19
19
  process.stderr.write(`${reason}\n`);
20
20
  process.exit(2);
@@ -23,14 +23,14 @@ if (input.hook_event_name === 'PreToolUse') {
23
23
  else if (input.hook_event_name === 'Stop') {
24
24
  stop();
25
25
  }
26
- // PR のタイトル = squash のコミットのメッセージ → prose-lint のコミットの規則で検査(リポの `prose-lint.json` を反映)
27
- function titleIssues(title) {
26
+ // PR のタイトル = squash のコミットのメッセージ → prose-lint のコミットの規則で検査(対象のリポの `prose-lint.json` を反映)
27
+ function titleIssues(title, cwd) {
28
28
  const dir = mkdtempSync(join(tmpdir(), 'conventions-'));
29
29
  try {
30
30
  const file = join(dir, 'title');
31
31
  writeFileSync(file, `${title}\n`);
32
32
  const cli = fileURLToPath(new URL('./cli.js', import.meta.resolve('@ryusenkei/prose-lint')));
33
- const r = spawnSync(process.execPath, [cli, '--commit-msg', file], { cwd: root, encoding: 'utf8' });
33
+ const r = spawnSync(process.execPath, [cli, '--commit-msg', file], { cwd: repoRoot(cwd) ?? root, encoding: 'utf8' });
34
34
  return r.status === 0 ? [] : [`${r.stdout}${r.stderr}`.trim()];
35
35
  }
36
36
  finally {
@@ -45,6 +45,19 @@ function readFile(path) {
45
45
  return undefined;
46
46
  }
47
47
  }
48
+ function repoRoot(cwd) {
49
+ const r = spawnSync('git', ['rev-parse', '--show-toplevel'], { cwd: cwd ?? root, encoding: 'utf8' });
50
+ return (r.status === 0 && r.stdout.trim()) || undefined;
51
+ }
52
+ // 変数・コマンド置換・`cd -` は解決しない
53
+ // Git Bash の `/c/...` は Windows のパス `C:/...` に変換
54
+ function resolveDir(base, dir) {
55
+ if (dir === '-' || /[$`]/.test(dir))
56
+ return undefined;
57
+ const home = dir === '~' || dir.startsWith('~/') ? join(homedir(), dir.slice(1)) : dir;
58
+ const native = process.platform === 'win32' ? home.replace(/^\/([a-zA-Z])(?=\/|$)/, '$1:') : home;
59
+ return isAbsolute(native) ? resolve(native) : resolve(base ?? root, native);
60
+ }
48
61
  function currentBranch(cwd) {
49
62
  const r = spawnSync('git', ['branch', '--show-current'], { cwd: cwd ?? root, encoding: 'utf8' });
50
63
  return (r.status === 0 && r.stdout.trim()) || undefined;
package/dist/policy.d.ts CHANGED
@@ -8,10 +8,14 @@ export type ToolUse = {
8
8
  export type Checks = 'pass' | 'pending' | 'fail' | 'none' | 'unknown';
9
9
  /** 判定に必要な外部の処理 */
10
10
  export type Context = {
11
- /** リポのルート(`package.json` の opt-in の読み込み元) */
11
+ /** セッションのリポのルート(作業ディレクトリの git のルートが不明なときの判定の対象) */
12
12
  root: string;
13
+ /** 作業ディレクトリの git のルート(git の外・取得の失敗時は `undefined`) */
14
+ repoRoot: (cwd: string | undefined) => string | undefined;
15
+ /** `cd` の移動先(`base` からの相対・`~` などを解決。解決できなければ `undefined`) */
16
+ resolveDir: (base: string | undefined, dir: string) => string | undefined;
13
17
  /** PR のタイトルの指摘(なければ空配列) */
14
- titleIssues: (title: string) => string[];
18
+ titleIssues: (title: string, cwd: string | undefined) => string[];
15
19
  /** ファイルの内容(読み込みの失敗時は `undefined`) */
16
20
  readFile: (path: string) => string | undefined;
17
21
  /** 現在のブランチ(detached HEAD・取得の失敗時は `undefined`) */
package/dist/policy.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // PreToolUse で拒否するツールの実行
2
2
  // - 判定は純粋な関数 → 外部の処理(タイトルの検査・ファイルの読み込み・git・gh)は `Context` で注入
3
3
  // - 拒否の理由は Claude に返却 → Claude が修正して再実行
4
+ // - 対象のリポ・ブランチはコマンドから解決: `cd`・`git -C` の後はその git のルート、ブランチの切り替えの後はその先のブランチ
4
5
  import { isAbsolute, join } from 'node:path';
5
6
  import { commands, option } from "./shell.js";
6
7
  const TYPES = ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test'];
@@ -43,22 +44,40 @@ export function denyReason(use, ctx) {
43
44
  }
44
45
  if (use.tool_name !== 'Bash')
45
46
  return undefined;
46
- const reasons = commands(String(use.tool_input.command ?? '')).flatMap((words) => commandReasons(words, use.cwd, ctx));
47
+ const st = { cwd: use.cwd };
48
+ const reasons = commands(String(use.tool_input.command ?? '')).flatMap((words) => commandReasons(words, st, ctx));
47
49
  return reasons.length ? reasons.join('\n') : undefined;
48
50
  }
49
- function commandReasons(words, cwd, ctx) {
51
+ // 判定の後に、`cd`・ブランチの切り替えを状態に反映
52
+ function commandReasons(words, st, ctx) {
50
53
  const [cmd, ...args] = words;
54
+ if (cmd === 'cd' || cmd === 'pushd') {
55
+ const dir = args.find((a) => !a.startsWith('-'));
56
+ const next = dir === undefined ? undefined : ctx.resolveDir(st.cwd, dir);
57
+ if (next !== undefined && next !== st.cwd)
58
+ Object.assign(st, { cwd: next, branch: undefined });
59
+ return [];
60
+ }
51
61
  if (cmd === 'yarn' || (cmd === 'npm' && NPM_CHANGES.includes(args[0] ?? '')))
52
62
  return ['パッケージ管理は pnpm のみ(`pnpm add`・`pnpm install` など)'];
53
- if (cmd === 'git')
54
- return gitReasons(gitArgs(args), cwd, ctx);
63
+ if (cmd === 'git') {
64
+ const { dir, rest } = gitArgs(args);
65
+ // `git -C <path>` はその場所の git で判定し、切り替えは状態に反映しない
66
+ const target = dir === undefined ? st : { cwd: ctx.resolveDir(st.cwd, dir) ?? st.cwd };
67
+ const reasons = gitReasons(rest, target, ctx);
68
+ const branch = dir === undefined ? switchedBranch(rest[0], rest.slice(1)) : undefined;
69
+ if (branch !== undefined)
70
+ st.branch = branch;
71
+ return reasons;
72
+ }
55
73
  if (cmd === 'gh' && args[0] === 'pr')
56
- return prReasons(args[1], args.slice(2), cwd, ctx);
74
+ return prReasons(args[1], args.slice(2), st, ctx);
57
75
  return [];
58
76
  }
59
- // epic のフローの opt-in: ルートの `package.json` の `"ryusenkei": { "flow": "epic" }`
60
- function epicFlow(ctx) {
61
- const raw = ctx.readFile(join(ctx.root, 'package.json'));
77
+ const branchOf = (st, ctx) => st.branch ?? ctx.currentBranch(st.cwd);
78
+ // epic のフローの opt-in: 対象のリポのルートの `package.json` の `"ryusenkei": { "flow": "epic" }`
79
+ function epicFlow(st, ctx) {
80
+ const raw = ctx.readFile(join(ctx.repoRoot(st.cwd) ?? ctx.root, 'package.json'));
62
81
  if (raw === undefined)
63
82
  return false;
64
83
  try {
@@ -69,11 +88,30 @@ function epicFlow(ctx) {
69
88
  }
70
89
  }
71
90
  // git の全体のオプション(`-C <path>`・`-c <name=value>` など)を除去
91
+ // - `dir`: `-C` の場所(複数あれば git と同じく前から順に連結)
72
92
  function gitArgs(args) {
73
93
  let i = 0;
74
- while (i < args.length && args[i].startsWith('-'))
94
+ let dir;
95
+ while (i < args.length && args[i].startsWith('-')) {
96
+ const value = args[i + 1];
97
+ if (args[i] === '-C' && value !== undefined)
98
+ dir = dir === undefined || isAbsolute(value) ? value : join(dir, value);
75
99
  i += args[i] === '-C' || args[i] === '-c' ? 2 : 1;
76
- return args.slice(i);
100
+ }
101
+ return { dir, rest: args.slice(i) };
102
+ }
103
+ // 切り替え先のブランチ(`git switch`・`git checkout`)
104
+ // - `git checkout <path>` と区別できない形(`--` を含む・位置引数が2つ以上)は対象外
105
+ function switchedBranch(sub, args) {
106
+ if (sub !== 'switch' && sub !== 'checkout')
107
+ return undefined;
108
+ const created = sub === 'switch' ? option(args, ['-c', '-C', '--create', '--force-create']) : option(args, ['-b', '-B']);
109
+ if (created !== undefined)
110
+ return created;
111
+ if (args.includes('--') || args.includes('--detach') || args.includes('-d'))
112
+ return undefined;
113
+ const names = args.filter((a) => !a.startsWith('-'));
114
+ return names.length === 1 && names[0] !== '-' ? names[0] : undefined;
77
115
  }
78
116
  // 位置引数(`--` 以降はすべて位置引数)
79
117
  function positionals(args, valued) {
@@ -110,7 +148,7 @@ function hasShort(args, flag, valued = '') {
110
148
  }
111
149
  return false;
112
150
  }
113
- function gitReasons([sub, ...args], cwd, ctx) {
151
+ function gitReasons([sub, ...args], st, ctx) {
114
152
  if ((sub === 'commit' || sub === 'push') && args.includes('--no-verify'))
115
153
  return ['フックの省略(`--no-verify`)は禁止'];
116
154
  // `git commit -n` = `--no-verify`(`git push -n` は dry run)
@@ -121,11 +159,11 @@ function gitReasons([sub, ...args], cwd, ctx) {
121
159
  if (sub === 'add' && bulkAdd(args))
122
160
  return [BULK_STAGING];
123
161
  if (sub === 'push')
124
- return pushReasons(args, cwd, ctx);
162
+ return pushReasons(args, st, ctx);
125
163
  const name = newBranch(sub, args);
126
164
  if (name === undefined || BRANCH.test(name))
127
165
  return [];
128
- if (!epicFlow(ctx))
166
+ if (!epicFlow(st, ctx))
129
167
  return [`ブランチ名は ${BRANCH_RULE}: \`${name}\``];
130
168
  if (DEV_BRANCH.test(name))
131
169
  return [];
@@ -139,21 +177,21 @@ function bulkAdd(args) {
139
177
  return positionals(args, ADD_VALUE).some((p) => ALL_PATHS.includes(p));
140
178
  }
141
179
  // main・master への force push を拒否
142
- function pushReasons(args, cwd, ctx) {
180
+ function pushReasons(args, st, ctx) {
143
181
  const forceAll = args.some((a) => a === '--force' || a.startsWith('--force-with-lease')) || hasShort(args, 'f', 'o');
144
182
  if (args.includes('--all') || args.includes('--mirror'))
145
183
  return forceAll ? [`\`--all\`・\`--mirror\` の force push は禁止(${PROTECTED.join('・')} を含む)。${ASK_USER}`] : [];
146
184
  const [, ...refspecs] = positionals(args, PUSH_VALUE);
147
185
  const targets = refspecs.length
148
- ? refspecs.map((r) => ({ force: forceAll || r.startsWith('+'), branch: pushTarget(r.replace(/^\+/, ''), cwd, ctx) }))
149
- : [{ force: forceAll, branch: ctx.currentBranch(cwd) }];
186
+ ? refspecs.map((r) => ({ force: forceAll || r.startsWith('+'), branch: pushTarget(r.replace(/^\+/, ''), st, ctx) }))
187
+ : [{ force: forceAll, branch: branchOf(st, ctx) }];
150
188
  const hit = targets.find((t) => t.force && t.branch !== undefined && PROTECTED.includes(t.branch));
151
189
  return hit ? [`\`${hit.branch}\` への force push は禁止。${ASK_USER}`] : [];
152
190
  }
153
- function pushTarget(refspec, cwd, ctx) {
191
+ function pushTarget(refspec, st, ctx) {
154
192
  const dst = refspec.includes(':') ? refspec.slice(refspec.indexOf(':') + 1) : refspec;
155
193
  const name = dst.replace(/^refs\/heads\//, '');
156
- return name === 'HEAD' ? ctx.currentBranch(cwd) : name;
194
+ return name === 'HEAD' ? branchOf(st, ctx) : name;
157
195
  }
158
196
  // 作成・リネームするブランチの名前
159
197
  function newBranch(sub, args) {
@@ -175,9 +213,10 @@ function newBranch(sub, args) {
175
213
  return undefined;
176
214
  }
177
215
  }
178
- function prReasons(sub, args, cwd, ctx) {
216
+ function prReasons(sub, args, st, ctx) {
217
+ const { cwd } = st;
179
218
  if (sub === 'merge')
180
- return mergeReasons(args, cwd, ctx);
219
+ return mergeReasons(args, st, ctx);
181
220
  if (sub !== 'create' && sub !== 'edit')
182
221
  return [];
183
222
  const reasons = [];
@@ -185,25 +224,34 @@ function prReasons(sub, args, cwd, ctx) {
185
224
  if (title === undefined && sub === 'create')
186
225
  reasons.push('PR のタイトルを `--title` で指定(`main` のコミットのメッセージになるため検査)');
187
226
  if (title !== undefined)
188
- reasons.push(...ctx.titleIssues(title).map((i) => `PR のタイトル: ${i}`));
227
+ reasons.push(...ctx.titleIssues(title, cwd).map((i) => `PR のタイトル: ${i}`));
189
228
  const file = option(args, ['--body-file', '-F']);
190
229
  const body = [option(args, ['--body', '-b']), file && file !== '-' ? ctx.readFile(isAbsolute(file) || !cwd ? file : join(cwd, file)) : undefined].join('\n');
191
230
  if (AI_TRAILER.test(body) || AI_NOTE.test(body))
192
231
  reasons.push('PR の本文に AI の署名を付けない');
193
- if (epicFlow(ctx))
194
- reasons.push(...epicReasons(sub, args, cwd, ctx));
232
+ if (epicFlow(st, ctx))
233
+ reasons.push(...epicReasons(sub, args, st, ctx));
195
234
  return reasons;
196
235
  }
197
236
  // `--auto` も対象(必須のチェックがないリポでは即時にマージされる)
198
237
  // - epic のフローの dev/* への PR: チェックなしを許可(CI を実行せず pre-push の `pnpm check` が関門)
199
- function mergeReasons(args, cwd, ctx) {
200
- if (args.some((a) => a === '--merge' || a === '--rebase' || a === '-m' || a === '-r'))
201
- return ['マージは squash のみ(`--squash`)'];
238
+ // - epic のフローの dev/* から main への PR: merge commit
239
+ // squash すると sub-issue ごとのコミットが1つにまとまり、dev と main の履歴もずれる
240
+ function mergeReasons(args, st, ctx) {
241
+ const { cwd } = st;
242
+ if (args.some((a) => a === '--rebase' || a === '-r'))
243
+ return ['rebase でのマージは禁止(`--squash`、dev のブランチから main へは `--merge`)'];
202
244
  const pr = positionals(args, MERGE_VALUE)[0];
245
+ const merge = args.some((a) => a === '--merge' || a === '-m');
246
+ const devToMain = epicFlow(st, ctx) && DEV_BRANCH.test(ctx.prHead(pr, cwd) ?? '') && PROTECTED.includes(ctx.prBase(pr, cwd) ?? '');
247
+ if (devToMain && !merge)
248
+ return ['dev のブランチから main へのマージは merge commit(`--merge`)。sub-issue ごとのコミットを残すため'];
249
+ if (!devToMain && merge)
250
+ return ['マージは squash(`--squash`)。merge commit は epic のフローで dev のブランチから main への PR だけ'];
203
251
  const checks = ctx.prChecks(pr, cwd);
204
252
  if (checks === 'pass')
205
253
  return [];
206
- if (checks === 'none' && epicFlow(ctx)) {
254
+ if (checks === 'none' && epicFlow(st, ctx)) {
207
255
  const base = ctx.prBase(pr, cwd);
208
256
  if (base !== undefined && DEV_BRANCH.test(base))
209
257
  return [];
@@ -213,12 +261,12 @@ function mergeReasons(args, cwd, ctx) {
213
261
  // epic のフロー: main への PR は dev/* から、それ以外のブランチの PR は dev/* へ
214
262
  // - `gh pr create` の base の省略 = main(既定のブランチ)
215
263
  // - `gh pr edit` は base を変更する場合のみ
216
- function epicReasons(sub, args, cwd, ctx) {
264
+ function epicReasons(sub, args, st, ctx) {
217
265
  const explicit = option(args, ['--base', '-B']);
218
266
  if (sub === 'edit' && explicit === undefined)
219
267
  return [];
220
268
  const base = explicit ?? 'main';
221
- const head = sub === 'create' ? (option(args, ['--head', '-H'])?.replace(/^.*:/, '') ?? ctx.currentBranch(cwd)) : ctx.prHead(positionals(args, EDIT_VALUE)[0], cwd);
269
+ const head = sub === 'create' ? (option(args, ['--head', '-H'])?.replace(/^.*:/, '') ?? branchOf(st, ctx)) : ctx.prHead(positionals(args, EDIT_VALUE)[0], st.cwd);
222
270
  if (head !== undefined && DEV_BRANCH.test(head))
223
271
  return [];
224
272
  if (PROTECTED.includes(base))
package/dist/settings.js CHANGED
@@ -1,12 +1,19 @@
1
1
  // `.claude/settings.json` の管理する項目
2
- // - hook の登録・`attribution`・`permissions.deny`
3
- // - リポ独自の設定・hook は維持
2
+ // - hook の登録・`attribution`・`permissions.deny`・文章の見直しのプラグイン(yomiyasu・humanizer)
3
+ // - リポ独自の設定・hook は維持。プラグインはリポで `false` にすれば無効のまま
4
4
  /** hook の本体のパス(`node` で直接実行 → Windows でもシェルを経由しない) */
5
5
  export const HOOK_PATH = '${CLAUDE_PROJECT_DIR}/node_modules/@ryusenkei/conventions/dist/hook.js';
6
6
  const HOOK = { type: 'command', command: 'node', args: [HOOK_PATH] };
7
7
  const PROSE_LINT = { type: 'command', command: 'npx --no -- prose-lint --hook' };
8
8
  // 秘密値のファイル(`.env.example` は対象外 → `.env.*` の指定は不可)
9
9
  const DENY = ['Read(./**/.env)', 'Read(./**/.dev.vars)'];
10
+ // 同梱せずマーケットプレイスから読み込む(ライセンスの表示に個人名を含むため)
11
+ // `autoUpdate` は既定の `false`(第三者のマーケットプレイス)→ 上流の変更は各自の更新の操作まで入らない
12
+ const MARKETPLACES = {
13
+ yomiyasu: { source: { source: 'github', repo: 'nanaism/yomiyasu' } },
14
+ humanizer: { source: { source: 'github', repo: 'blader/humanizer' } },
15
+ };
16
+ const PLUGINS = { 'yomiyasu@yomiyasu': true, 'humanizer@humanizer': true };
10
17
  const owned = (h) => (h.command === 'node' && h.args?.[0] === HOOK_PATH) || h.command.includes('prose-lint --hook');
11
18
  /** Stop の hook(完了前の lint・test)が登録済みか */
12
19
  export const hasStop = (s) => (s.hooks?.Stop ?? []).some((g) => g.hooks.some(owned));
@@ -27,6 +34,8 @@ export function managedSettings(current, options) {
27
34
  ...current,
28
35
  attribution: { commit: '', pr: '', sessionUrl: false },
29
36
  permissions: { ...current.permissions, deny },
37
+ extraKnownMarketplaces: { ...current.extraKnownMarketplaces, ...MARKETPLACES },
38
+ enabledPlugins: { ...PLUGINS, ...current.enabledPlugins },
30
39
  hooks,
31
40
  };
32
41
  }
package/dist/shell.js CHANGED
@@ -2,6 +2,8 @@
2
2
  // - 区切り: `&&`・`||`・`;`・`|`・`&`・改行 → コマンドごとの語の配列
3
3
  // - 解釈: 引用符(`'`・`"`)とバックスラッシュ → 変数・コマンド置換は展開しない
4
4
  // - 先頭の `NAME=value`(環境変数の指定)は除去
5
+ // - heredoc の本文はコマンドとして分割しない。`"$(cat <<'EOF' ... EOF)"` のように引用符の中なら語の一部、外なら除去
6
+ const HEREDOC = /^<<(-?)[ \t]*(['"]?)([A-Za-z0-9_]+)\2/;
5
7
  /** コマンド文字列をコマンドごとの語の配列に分解 */
6
8
  export function commands(line) {
7
9
  const out = [];
@@ -10,6 +12,30 @@ export function commands(line) {
10
12
  // 空の引用符(`""`)も1語
11
13
  let has = false;
12
14
  let quote;
15
+ // 次の改行の後に本文を読む heredoc の終端の語(`<<-` は行頭のタブを除いて照合)
16
+ let heredocs = [];
17
+ // 本文を読み、終端の行の後の改行の位置を返す
18
+ const readHeredocs = (from) => {
19
+ let at = from;
20
+ const bodies = [];
21
+ for (const { end, tabs } of heredocs) {
22
+ const body = [];
23
+ while (at < line.length) {
24
+ const next = line.indexOf('\n', at);
25
+ const stop = next === -1 ? line.length : next;
26
+ const text = line.slice(at, stop);
27
+ at = stop + 1;
28
+ if ((tabs ? text.replace(/^\t+/, '') : text) === end)
29
+ break;
30
+ body.push(text);
31
+ }
32
+ bodies.push(body.join('\n'));
33
+ }
34
+ if (quote)
35
+ word += bodies.join('\n');
36
+ heredocs = [];
37
+ return at - 1;
38
+ };
13
39
  const endWord = () => {
14
40
  if (has)
15
41
  words.push(word);
@@ -25,6 +51,25 @@ export function commands(line) {
25
51
  };
26
52
  for (let i = 0; i < line.length; i++) {
27
53
  const c = line[i];
54
+ const heredoc = quote !== "'" && line.startsWith('<<', i) && line[i - 1] !== '<' && line[i + 2] !== '<' ? line.slice(i).match(HEREDOC) : null;
55
+ if (heredoc) {
56
+ heredocs.push({ end: heredoc[3], tabs: heredoc[1] === '-' });
57
+ if (quote)
58
+ word += heredoc[0];
59
+ else
60
+ endWord();
61
+ i += heredoc[0].length - 1;
62
+ continue;
63
+ }
64
+ if (c === '\n' && heredocs.length) {
65
+ if (quote)
66
+ word += c;
67
+ else
68
+ endCommand();
69
+ // 終端の行の後の改行は通常の区切りとして次の周回で処理
70
+ i = readHeredocs(i + 1) - 1;
71
+ continue;
72
+ }
28
73
  if (quote) {
29
74
  if (c === quote)
30
75
  quote = undefined;
package/files/commit-msg CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
- # コミットメッセージの文体の検査(規則 = @ryusenkei/prose-lint)
2
+ # コミットメッセージの書式の検査(規則 = @ryusenkei/prose-lint)
3
3
  exec npx --no -- prose-lint --commit-msg "$1"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryusenkei/conventions",
3
- "version": "0.5.2",
3
+ "version": "0.7.0",
4
4
  "description": "RYUSENKEI のモノリポの共通の規約(Claude Code の規約・hook、共通ファイルの同期)",
5
5
  "license": "MIT",
6
6
  "author": "RYUSENKEI",
@@ -24,7 +24,7 @@
24
24
  "files": [
25
25
  "dist",
26
26
  "files",
27
- "rules.md"
27
+ "rules*.md"
28
28
  ],
29
29
  "engines": {
30
30
  "node": ">=24"
@@ -34,7 +34,7 @@
34
34
  "provenance": true
35
35
  },
36
36
  "dependencies": {
37
- "@ryusenkei/prose-lint": "^0.1.0"
37
+ "@ryusenkei/prose-lint": "^0.2.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^26.6.1",
package/rules-go.md ADDED
@@ -0,0 +1,6 @@
1
+ ## Go
2
+
3
+ - テストは `testing` で書き、対象と同じディレクトリに `*_test.go` を置く
4
+ - インターフェースは使う側のパッケージで定義する
5
+ - OS ごとの実装はビルドタグのファイルに分け、中心のパッケージは OS に依存させない
6
+ - `pnpm lint` に `go vet ./...`、`pnpm test` に `go test ./...` を含める
package/rules-rust.md ADDED
@@ -0,0 +1,6 @@
1
+ ## Rust
2
+
3
+ - ライブラリのエントリポイントは `src/lib.rs`。`pub` にするのは外部で使うものだけ
4
+ - 単体テストは対象と同じファイルの `#[cfg(test)] mod tests` に書く
5
+ - `unsafe` は OS の API の呼び出しだけに使い、箇所ごとに `#[allow(unsafe_code)]` と `SAFETY` のコメントを付ける
6
+ - `pnpm lint` に `cargo fmt --all --check` と `cargo clippy --workspace --all-targets -- -D warnings`、`pnpm test` に `cargo test --workspace` を含める
package/rules-ts.md ADDED
@@ -0,0 +1,13 @@
1
+ ## TypeScript
2
+
3
+ - エントリポイントはパッケージごとの `src/index.ts`
4
+ - TypeScript はビルドせず、Node で直接実行する(`node scripts/x.ts`)
5
+ - テストは Vitest で書き、対象と同じディレクトリに `*.test.ts` を置く
6
+ - 子プロセスは `scripts/lib/exec.ts` の `exec` で起動する。Windows の `.cmd` に対応するため
7
+
8
+ ## 定数
9
+
10
+ - export するモジュールの定数は UPPER_SNAKE で書き、`as const satisfies T` を付ける。フィールドは camelCase
11
+ - 数値は単位を接尾辞で表す(`Ms`、`Sec`、`Px`、`Rem`、`Pct`、`MB` など)
12
+ - enum は使わない。`const X = [...] as const` と `type X = (typeof X)[number]` で表す
13
+ - 条件、数値、識別子は config に置き、表示の文言は辞書に置く。複数の言語から使う値は JSON のマスタを1つ置く
package/rules-ui.md ADDED
@@ -0,0 +1,7 @@
1
+ ## UI
2
+
3
+ - 色、影、書体、余白はトークンのマスタから引き、スタイルに値を直書きしない。ブレークポイントも1か所で持つ
4
+ - 部品は使う範囲で置き場所を分ける(全ページ共通、サイト共通、ページ専用)。下層のページはレイアウトと共通の部品で組む
5
+ - 表示の文言は辞書に定義し、画面に直書きしない
6
+ - 文言には事実だけを書く。未実装の機能や誇大な表現は書かない
7
+ - フォームは、入力欄と説明・エラーを `aria-describedby` で結び、エラーは入力欄の近くに出す
package/rules.md CHANGED
@@ -1,58 +1,79 @@
1
1
  ## コード
2
2
 
3
- - 構成: パッケージの責務・依存は README の構成の表に準拠
4
- - 共有: リポ内は `packages/*`、リポ間は toolkit(npm の `@ryusenkei/*`)。`@ryusenkei/*` の変更は toolkit で実施
5
- - エントリポイント: パッケージごとに `src/index.ts`。export は外部で使用するものだけ・他パッケージの再 export なし
6
- - TypeScript: ビルドせず Node で直接実行(`node scripts/x.ts`)
7
- - テスト: Vitest。対象と同じディレクトリに `*.test.ts`
8
- - 子プロセス: `scripts/lib/exec.ts` の `exec`(Windows の `.cmd` に対応)
9
- - 依存の更新: Dependabot の PR で実施(月1回・自動の rebase なし → マージの前に手で rebase)
10
-
11
- ## 設定・秘密値
12
-
13
- - 秘密値: ルート `.env` に集約。配信は `pnpm env:push` に一本化
14
- - `*.tfvars`・Terraform の state: コミット禁止
15
- - `.env.example`: 変数の追加時は `scripts/env.ts` の `TARGETS` にも定義
16
- - 環境変数を付けた実行: `node scripts/env.ts run NAME=value <cmd>`(`NAME=value cmd` は Windows で不可)
17
- - YAML の拡張子: `.yaml`(pnpm のファイルと統一)
18
- - 共通ファイル(`.editorconfig`・`.github/dependabot.yaml`・`.claude/settings.json` など): `@ryusenkei/conventions` のマスタから同期。直接編集しない
19
- - 変更は toolkit で実施し、`ryusenkei-conventions sync` で反映
20
-
21
- ## 記述内容(コード・コメント・ドキュメント共通)
22
-
23
- - コメント: 非自明な理由・制約のみ。処理の内容はコードの名前で表現
24
- - 変更の経緯: コメントに書かず PR に記載
25
- - `export` する関数・型・定数: JSDoc
26
- - 個人名: 記載禁止(コード・コメント・ドキュメント・設定値すべて)
27
-
28
- ## 文体(Markdown・コメント共通)
29
-
30
- - 散文より構造化(表・箇条書き・キー: 値)
31
- - ドメインの概念・説明・表示文字列は日本語
32
- - 文体の指摘(`prose-lint`)がドメインの用語に該当する場合: `prose-lint.json` の `allow`・`vocabulary` に追加
33
-
34
- ## Git・PR
35
-
36
- - コミット: 変更・追加したファイルをパスで指定して add(一括の add は禁止、フックで強制)
37
- - push の前: `pnpm check`(`check` を持つリポは pre-push で強制)
38
- - PR の本文: 背景・変更・検証
39
- - マージ: CI の全チェックの成功を確認してから(フックで強制)
40
- - epic のフロー(有効にしたリポのみ)
41
- - epic ごとに `dev/<issue の番号>-<内容>` を作成し、sub-issue の PR は dev のブランチへ
42
- - dev のブランチへのマージは CI なし、pre-push の `pnpm check` が関門(チェックがある場合は成功が必要)
43
- - `main` へのマージはデプロイのときだけ dev のブランチから
3
+ - パッケージ・クレートの責務と依存は、README の構成の表に従う
4
+ - リポ内で共有するコードは `packages/*` に置く。リポをまたぐものは toolkit(npm の `@ryusenkei/*`)に置き、変更も toolkit で行う
5
+ - エントリポイントでは外部で使うものだけを公開し、他パッケージのものを公開し直さない
6
+ - テストは対象の近くに置く。言語ごとの置き方は `rules-ts.md`・`rules-go.md`・`rules-rust.md`
7
+ - 依存の更新は Dependabot の PR で行う。月1回で自動の rebase はしないので、マージの前に手で rebase する
8
+
9
+ ## 設定と秘密値
10
+
11
+ - 秘密値はルートの `.env` にまとめ、配信は `pnpm env:push` だけで行う
12
+ - `*.tfvars` と Terraform の state はコミットしない
13
+ - `.env.example` に変数を足したら、`scripts/env.ts` の `TARGETS` にも定義する
14
+ - 環境変数を付けて実行するときは `node scripts/env.ts run NAME=value <cmd>` を使う。`NAME=value cmd` は Windows で動かない
15
+ - YAML の拡張子は `.yaml` にする(pnpm のファイルに合わせる)
16
+ - 共通ファイル(`.editorconfig`、`.github/dependabot.yaml`、`.claude/settings.json` など)は `@ryusenkei/conventions` から同期するので、直接編集しない。変えるときは toolkit で直し、`ryusenkei-conventions sync` で反映する
17
+
18
+ ## 文章を書く場所
19
+
20
+ | 場所 | 性格 | 書くこと |
21
+ | --- | --- | --- |
22
+ | コード | 常に最新 | 意図は名前、型、関数の分け方で表す。コメントはその場所に欠かせない制約だけ |
23
+ | README | 変更と一緒に直す | 今の構成と設計の方針 |
24
+ | PR、issue | その時点の記録 | 経緯、検証、判断、採用しなかった案 |
25
+
26
+ - 決定の記録のファイル(ADR など)は置かない
27
+ - 個人名は書かない。コード、コメント、ドキュメント、設定値のすべてが対象
28
+
29
+ ## 書く量
30
+
31
+ | 種類 | 書く | 書かない |
32
+ | --- | --- | --- |
33
+ | コードのコメント | 既定は書かない。書くのは、読み手が直そうとしてしまう一見おかしなコードの理由、コードから読み取れない外部の事実(仕様、プラットフォームの癖)、型で表せない単位や形式だけ | コードがしていることの説明、経緯、採用しなかった案、issue に結びつかない TODO |
34
+ | export の JSDoc | 名前と型以上の情報があるときだけ(単位、副作用、エラーコード、前提条件) | 名前を言い換えるだけの JSDoc |
35
+ | README | 何のリポか、動かし方、構成、今の設計の方針 | 経緯、判断の理由の長文、機能の宣伝 |
36
+ | PR | 背景(1〜3行)、レビューに要る粒度での変更、実際に行った検証 | 差分をなぞる説明、ファイルごとの実況 |
37
+ | issue | 問題、決めた範囲、未決の点。決まったら決定を書き足す | 調査の過程の全文 |
38
+ | コミットメッセージ | 1行で変更を言い切る | 本文での経緯の説明 |
39
+
40
+ 説明が要ると感じたら、先にコードや構成を直せないか考える
41
+
42
+ ## 書き方
43
+
44
+ - 語彙は慣例に合わせる。公式の文書の日本語訳や、業界でよく使う言い方を基準にし、安易に平易化や漢語化をしない
45
+ - 例: データの操作は「作成」「取得」「更新」「削除」(UI と API の慣例)。ソフトウェアの版は「バージョン」
46
+ - 常体の短い文で書く。体言止めや、記号(`→`、`・`)で語をつなぐ略記にしない
47
+ - 表は比較や対応表のように、中身が表の形のものに使う。飾りとして表や、太字の見出しを付けた箇条書きにしない
48
+ - エラー、ログ、標準出力はコード(識別子)で表す。人が読む文言は表示のマスタ(辞書)から引き、その場に日本語を書かない
49
+ - コード上の値と環境変数はバッククォートで囲む。ドメインの概念、説明、表示の文言は日本語で書く
50
+ - 文章を見直すときは、日本語の文書・issue・PR に yomiyasu、英語の README に humanizer のスキルを使う(`.claude/settings.json` のプラグインで有効)。出てくるのは見直しの候補で、点数を合格の基準にしない
51
+ - prose-lint が止めるのは機械的な誤り(空白、句読点、表記の揺れ)だけ。ドメインの用語が表記の規則に当たるときは、`prose-lint.json` の `allow` に足す
52
+
53
+ ## Git と PR
54
+
55
+ - add は変更・追加したファイルをパスで指定する。一括の add はフックで止まる
56
+ - push の前に `pnpm check` を通す。`check` を持つリポでは pre-push で強制される
57
+ - PR の本文は背景、変更、検証の順に書く
58
+ - マージは squash で、CI の全チェックの成功を確かめてから行う(フックで強制)
59
+ - epic のフロー(有効にしたリポだけ)
60
+ - epic ごとに `dev/<issue の番号>-<内容>` を作り、sub-issue の PR は dev のブランチに向ける
61
+ - dev のブランチへのマージに CI は使わず、pre-push の `pnpm check` を関門にする。チェックがある場合は成功が必要
62
+ - `main` へのマージは、デプロイのときに dev のブランチからだけ行う。方法は merge commit(`gh pr merge --merge`)で、sub-issue ごとのコミットを残し、dev と main の履歴をずらさない
63
+ - リポの設定で merge commit を許可する(Settings → General → Allow merge commits)
44
64
 
45
65
  ## CI(GitHub Actions)
46
66
 
47
- - 非公開のリポ: GitHub Free の時間を節約(組織の合計で月2,000分、ジョブごとに分単位の切り上げ)
48
- - 実行: `main` 行きの PR だけ。`main` への push では実行しない(マージの結果の ref を PR で検査済み)
49
- - ジョブ: 1つに検査を順に並べる(並列の分割は切り上げと準備の時間を増加)
50
- - 同じ PR の新しい実行で古い実行を中止(`concurrency` の `cancel-in-progress`)
51
- - PR のタイトルの変更 `edited`: タイトルだけを検査する別のワークフロー(依存の導入なし)
52
- - キャッシュ: キーにコミットの ID `github.sha` を含めない(保存が毎回走り、復元が効かない)
53
- - Windows・macOS のランナー: 公開のリポだけ(非公開では2倍・10倍で計上)
67
+ 非公開のリポでは GitHub Free の時間を節約する(上限は組織の合計で月2,000分、ジョブごとに分単位で切り上げて計上)
68
+
69
+ - 実行するのは `main` 行きの PR だけ。マージの結果の ref は PR で検査済みなので、`main` への push では実行しない
70
+ - 検査は1つのジョブに順に並べる。並列に分けると、切り上げと準備の時間が増える
71
+ - 同じ PR で新しい実行が始まったら、古い実行を中止する(`concurrency` の `cancel-in-progress`)
72
+ - PR のタイトルの変更(`edited`)は、タイトルだけを検査する別のワークフローで扱う。依存は入れない
73
+ - キャッシュのキーにコミットの ID(`github.sha`)を含めない。毎回保存が走り、復元が効かなくなる
74
+ - Windows と macOS のランナーは公開のリポだけで使う。非公開では2倍と10倍で計上される
54
75
 
55
76
  ## 完了の条件
56
77
 
57
- - `pnpm lint`(型検査・prose-lint・共通ファイルの検査)と `pnpm test` が通過
58
- - README の構成・コマンドの記述が変更と一致
78
+ - `pnpm lint`(型検査、prose-lint、共通ファイルの検査)と `pnpm test` が通る
79
+ - README の構成とコマンドの記述が変更と合っている