@ryusenkei/conventions 0.1.0 → 0.1.2
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/dist/files.d.ts +2 -2
- package/dist/files.js +2 -2
- package/dist/hook.js +1 -1
- package/dist/policy.d.ts +2 -2
- package/dist/policy.js +2 -2
- package/dist/shell.d.ts +1 -1
- package/dist/shell.js +2 -2
- package/package.json +2 -2
package/dist/files.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** CLAUDE.md
|
|
1
|
+
/** CLAUDE.md で共通の規約を読み込む import */
|
|
2
2
|
export declare const IMPORT = "@node_modules/@ryusenkei/conventions/rules.md";
|
|
3
|
-
/**
|
|
3
|
+
/** 差分のあるファイル(`expected` が `undefined` = 自動で修正できない → `message` に対処) */
|
|
4
4
|
export type Drift = {
|
|
5
5
|
path: string;
|
|
6
6
|
expected?: string;
|
package/dist/files.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 利用側のリポにある共通ファイルの同期・検査
|
|
2
2
|
// - マスタ: パッケージの `files/`(npm は `.gitignore` を同梱しない → 先頭の `.` を除いた名前で格納)
|
|
3
3
|
// - 比較は改行コードを LF に正規化(Windows の作業ツリーは CRLF になりうる)
|
|
4
4
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
@@ -15,7 +15,7 @@ const FILES = [
|
|
|
15
15
|
];
|
|
16
16
|
const SETTINGS = '.claude/settings.json';
|
|
17
17
|
const WORKSPACE = 'pnpm-workspace.yaml';
|
|
18
|
-
/** CLAUDE.md
|
|
18
|
+
/** CLAUDE.md で共通の規約を読み込む import */
|
|
19
19
|
export const IMPORT = '@node_modules/@ryusenkei/conventions/rules.md';
|
|
20
20
|
// `.github/dependabot.yaml` の `cooldown` と同値
|
|
21
21
|
const RELEASE_AGE = [
|
package/dist/hook.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Claude Code の hook(`.claude/settings.json` から `node` で直接実行)
|
|
3
3
|
// - PreToolUse: 規約に反するツールの実行を拒否 → 終了コード2・理由は stderr
|
|
4
4
|
// - Stop: 変更があれば `pnpm lint`・`pnpm test` を実行し、失敗時は完了を差し戻し
|
|
5
|
-
// - hook 自体の失敗は終了コード1(拒否にしない →
|
|
5
|
+
// - hook 自体の失敗は終了コード1(拒否にしない → 作業を継続)
|
|
6
6
|
import { spawnSync } from 'node:child_process';
|
|
7
7
|
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
8
|
import { tmpdir } from 'node:os';
|
package/dist/policy.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export type ToolUse = {
|
|
|
8
8
|
export type Context = {
|
|
9
9
|
/** PR のタイトルの指摘(なければ空配列) */
|
|
10
10
|
titleIssues: (title: string) => string[];
|
|
11
|
-
/**
|
|
11
|
+
/** ファイルの内容(読み込みの失敗時は `undefined`) */
|
|
12
12
|
readFile: (path: string) => string | undefined;
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
14
|
+
/** 拒否の理由(許可する場合は `undefined`) */
|
|
15
15
|
export declare function denyReason(use: ToolUse, ctx: Context): string | undefined;
|
package/dist/policy.js
CHANGED
|
@@ -13,7 +13,7 @@ const AI_TRAILER = /^[\w-]+:.*\b(claude|anthropic|openai|chatgpt|gpt-\d|copilot|
|
|
|
13
13
|
const AI_NOTE = /generated (with|by) \[?(claude|chatgpt|copilot|gemini|codex|cursor)|🤖/i;
|
|
14
14
|
// `git branch` の作成以外の操作
|
|
15
15
|
const BRANCH_QUERY = ['-d', '-D', '--delete', '-l', '--list', '-a', '-r', '--all', '--remotes', '-v', '-vv', '--verbose', '--show-current', '--contains', '--no-contains', '--merged', '--no-merged', '-u', '--set-upstream-to', '--unset-upstream', '--edit-description'];
|
|
16
|
-
/**
|
|
16
|
+
/** 拒否の理由(許可する場合は `undefined`) */
|
|
17
17
|
export function denyReason(use, ctx) {
|
|
18
18
|
if (EDIT_TOOLS.includes(use.tool_name)) {
|
|
19
19
|
const path = String(use.tool_input.file_path ?? use.tool_input.notebook_path ?? '');
|
|
@@ -54,7 +54,7 @@ function gitReasons([sub, ...args]) {
|
|
|
54
54
|
return [`ブランチ名は \`<type>/<内容>\`(type = ${TYPES.join('・')}、内容 = 英小文字・数字・\`-\`): \`${name}\``];
|
|
55
55
|
return [];
|
|
56
56
|
}
|
|
57
|
-
//
|
|
57
|
+
// 作成・リネームするブランチの名前
|
|
58
58
|
function newBranch(sub, args) {
|
|
59
59
|
const positionals = args.filter((a) => !a.startsWith('-'));
|
|
60
60
|
switch (sub) {
|
package/dist/shell.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** コマンド文字列をコマンドごとの語の配列に分解 */
|
|
2
2
|
export declare function commands(line: string): string[][];
|
|
3
|
-
/** オプションの値(`--name value`・`--name=value`・`-n value
|
|
3
|
+
/** オプションの値(`--name value`・`--name=value`・`-n value`)→ 指定がなければ `undefined` */
|
|
4
4
|
export declare function option(words: string[], names: string[]): string | undefined;
|
package/dist/shell.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// シェルのコマンド文字列の簡易な分解(hook の判定用)
|
|
2
2
|
// - 区切り: `&&`・`||`・`;`・`|`・`&`・改行 → コマンドごとの語の配列
|
|
3
|
-
// - 解釈: 引用符(`'`・`"
|
|
3
|
+
// - 解釈: 引用符(`'`・`"`)とバックスラッシュ → 変数・コマンド置換は展開しない
|
|
4
4
|
// - 先頭の `NAME=value`(環境変数の指定)は除去
|
|
5
5
|
/** コマンド文字列をコマンドごとの語の配列に分解 */
|
|
6
6
|
export function commands(line) {
|
|
@@ -61,7 +61,7 @@ export function commands(line) {
|
|
|
61
61
|
endCommand();
|
|
62
62
|
return out;
|
|
63
63
|
}
|
|
64
|
-
/** オプションの値(`--name value`・`--name=value`・`-n value
|
|
64
|
+
/** オプションの値(`--name value`・`--name=value`・`-n value`)→ 指定がなければ `undefined` */
|
|
65
65
|
export function option(words, names) {
|
|
66
66
|
for (let i = 0; i < words.length; i++) {
|
|
67
67
|
const w = words[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryusenkei/conventions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "RYUSENKEI のモノリポの共通の規約(Claude Code の規約・hook、共通ファイルの同期)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "RYUSENKEI",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|
|
34
|
-
"provenance":
|
|
34
|
+
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ryusenkei/prose-lint": "^0.1.0"
|