@guardsmith/cli 0.5.0 → 0.6.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.
Files changed (3) hide show
  1. package/README.ja.md +51 -17
  2. package/README.md +50 -14
  3. package/package.json +2 -2
package/README.ja.md CHANGED
@@ -42,23 +42,47 @@ npx @guardsmith/cli init
42
42
  # 契約見出しの破壊、資格情報の混入、drift など)
43
43
  npx @guardsmith/cli lint
44
44
 
45
- # 標準マスターからの乖離(drift)を表示し、復元する
46
- npx @guardsmith/cli sync # dry-run
47
- npx @guardsmith/cli sync --write # 復元(PJ 固有セクションは保全)
45
+ # 標準更新で何が変わるかを表示し、取り込む
46
+ npx @guardsmith/cli bump v0.7.1 --dry-run # 新タグでの dry-run(衝突があれば exit 1)
47
+ npx @guardsmith/cli bump v0.7.1 # 適用 + extends タグと vars ファイルの更新
48
+
49
+ # 現在固定しているタグでの未適用分の確認(bump の予見にはならない)
50
+ npx @guardsmith/cli sync
51
+
52
+ # guardsmith.vars.yaml がまだ無い既存 PJ は先に生成する
53
+ npx @guardsmith/cli sync --init-vars
48
54
 
49
55
  # ルールの説明 / バージョン表示
50
56
  npx @guardsmith/cli explain claude-md/thin-diff
51
57
  npx @guardsmith/cli version
52
58
  ```
53
59
 
54
- | コマンド | 主なフラグ |
55
- | ------------------------- | ---------------------------------------------------------------------------------------------- |
56
- | `guard new <dir>` | — |
57
- | `guard init` | — |
58
- | `guard lint` | `--root`、`--policy`、`--format console\|sarif\|json`、`--out`、`--no-cache`、`--no-gitignore` |
59
- | `guard sync` | `--root`、`--policy`、`--write`、`--no-cache`、`--no-gitignore` |
60
- | `guard explain <rule-id>` | — |
61
- | `guard version` | — |
60
+ | コマンド | 主なフラグ |
61
+ | ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
62
+ | `guard new <dir>` | — |
63
+ | `guard init` | — |
64
+ | `guard lint` | `--root`、`--policy`、`--format console\|sarif\|json`、`--out`、`--no-cache`、`--no-gitignore` |
65
+ | `guard sync` | `--root`、`--policy`、`--write`、`--no-cache`、`--no-gitignore`、`--conflict-markers`、`--init-vars` |
66
+ | `guard bump <tag>` | `--root`、`--policy`、`--repo <owner>/<repo>`、`--dry-run`、`--no-cache`、`--no-gitignore`、`--conflict-markers` |
67
+ | `guard explain <rule-id>` | — |
68
+ | `guard version` | — |
69
+
70
+ `guard sync` / `guard bump` は標準リリースを **3-way マージ**で取り込みます。PJ が乗っている
71
+ タグのマスターが base、新タグのマスターが theirs、PJ リポジトリが ours なので、PJ 固有の記述は
72
+ そのまま残ります。PJ の編集と標準の変更が重なったファイルは**衝突**として報告され、無変更のまま
73
+ 残ります(`--conflict-markers` を付けると `<<<<<<<` / `|||||||` / `=======` / `>>>>>>>` マーカー
74
+ 入りで書き出します)。どちらも終了コードは、衝突なしで `0`、1 ファイルでも衝突すれば `1`
75
+ (このとき `guard bump` は policy を含め何も書きません)、実行エラーは `2` です。
76
+
77
+ `guard bump <tag> --dry-run` は同じ計画・衝突予測・policy の書き換え予定行を表示し、
78
+ 1 バイトも書かずに本番と同じ終了コードを返します。**新しい**タグでの差分を事前に見られるのは
79
+ この dry-run だけです(`--write` なしの `guard sync` は policy が **現在** 固定しているタグを
80
+ 基準にした dry-run です)。`--dry-run` と `--conflict-markers` は併用できません。
81
+
82
+ マージが読む PJ のプレースホルダ置換値は `guardsmith.vars.yaml`(PJ ルート・コミット対象・
83
+ 秘密情報は書かない)にあります。`guard new` が雛形を生成し、既存 PJ は
84
+ `guard sync --init-vars` で生成します。`drift3` ルールを持たないポリシーでは、従来どおり
85
+ `guard sync --write` が節単位で復元します。
62
86
 
63
87
  各 check は「**コミットされうるファイル**」を対象にします。既定で `.gitignore`(入れ子も)に
64
88
  追従し、`.git/` は常に除外するため、`secret-scan` は `.claude/settings.local.json` の中身を
@@ -66,6 +90,16 @@ npx @guardsmith/cli version
66
90
  `ignore`(glob)を除外し、除外対象は結果フィルタではなく走査の時点で枝刈りします。
67
91
  `--no-gitignore` で全走査に戻せます。
68
92
 
93
+ `guard lint` は `CLAUDE.md` の常駐量も測ります。`import-budget` は起点ファイルと `@path`
94
+ インポートで到達する全ファイルを合算し、必ず `info` を1件出します
95
+ (`resident context: N files, X chars (≈Y tokens, rough estimate)` + ファイル別内訳。
96
+ トークン数は `chars / 4` の粗い目安)。走査ルートの外は読みません。パッケージ名は
97
+ `` `@scope/pkg` `` と書いてください — `@` はファイル中のどこでも有効なので、裸で書くと
98
+ インポートとみなされ `unresolved import` として報告されます。
99
+
100
+ ポリシースキーマは厳格です。`with` の未知キーとルール直下の未知キーは、黙って捨てられる
101
+ のではなく該当パス付きの **parse エラー**になります。
102
+
69
103
  `guard new` の後は Claude Code でプロジェクトを開いてください — 同梱の `init-project`
70
104
  スキルがインタビューを行い、テンプレートを具体化します。初期化が本当に完了すると
71
105
  `guard lint` が PASS します。
@@ -77,12 +111,12 @@ npx @guardsmith/cli version
77
111
  version: 1
78
112
  target: claude-code
79
113
  extends:
80
- - github:novexar/guardsmith//presets/baseline.yaml@v0.6.0 # tag pinning is mandatory
81
- # Projects with a frontend also add:
82
- # - github:novexar/guardsmith//presets/frontend.yaml@v0.6.0
114
+ - github:novexar/guardsmith//presets/baseline.yaml@v0.7.1 # タグ固定は必須
115
+ # フロントエンドを持つプロジェクトはさらに:
116
+ # - github:novexar/guardsmith//presets/frontend.yaml@v0.7.1
83
117
  ignore: [] # 全走査から除外する glob(extends 間で連結される)
84
- rules: [] # add or override (redefining an id overrides it)
85
- exemptions: [] # time-boxed waivers: reason + approved_by + expires required
118
+ rules: [] # 追加・上書き(同じ id の再定義=上書き)
119
+ exemptions: [] # 期限付き例外(reason + approved_by + expires 必須)
86
120
  ```
87
121
 
88
122
  `extends` は OSS baseline → private 組織 overlay → PJ ごとのポリシー、と合成されます。
@@ -96,7 +130,7 @@ GitHub の外に出ることはありません。期限切れの例外(exemption
96
130
  workflow に 1 行追加:
97
131
 
98
132
  ```yaml
99
- - uses: novexar/Guardsmith@v0.6.0
133
+ - uses: novexar/Guardsmith@v0.7.1
100
134
  ```
101
135
 
102
136
  違反した PR はサマリコメントと SARIF レポート付きで失敗します。閉域網などの環境では
package/README.md CHANGED
@@ -42,23 +42,49 @@ npx @guardsmith/cli init
42
42
  # broken contract headings, leaked credentials, drift, ...)
43
43
  npx @guardsmith/cli lint
44
44
 
45
- # Show drift against the standards master, then repair it
46
- npx @guardsmith/cli sync # dry-run
47
- npx @guardsmith/cli sync --write # restore (project-owned sections are preserved)
45
+ # Show what a standards update would change, then take it in
46
+ npx @guardsmith/cli bump v0.7.1 --dry-run # dry-run for the new tag (exit 1 = something conflicts)
47
+ npx @guardsmith/cli bump v0.7.1 # apply + move the extends tags and the vars file
48
+
49
+ # Dry-run at the tag the policy currently pins (does not predict a bump)
50
+ npx @guardsmith/cli sync
51
+
52
+ # Existing project with no guardsmith.vars.yaml yet — generate it first
53
+ npx @guardsmith/cli sync --init-vars
48
54
 
49
55
  # Explain a rule / show versions
50
56
  npx @guardsmith/cli explain claude-md/thin-diff
51
57
  npx @guardsmith/cli version
52
58
  ```
53
59
 
54
- | Command | Key flags |
55
- | ------------------------- | ---------------------------------------------------------------------------------------------- |
56
- | `guard new <dir>` | — |
57
- | `guard init` | — |
58
- | `guard lint` | `--root`, `--policy`, `--format console\|sarif\|json`, `--out`, `--no-cache`, `--no-gitignore` |
59
- | `guard sync` | `--root`, `--policy`, `--write`, `--no-cache`, `--no-gitignore` |
60
- | `guard explain <rule-id>` | — |
61
- | `guard version` | — |
60
+ | Command | Key flags |
61
+ | ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
62
+ | `guard new <dir>` | — |
63
+ | `guard init` | — |
64
+ | `guard lint` | `--root`, `--policy`, `--format console\|sarif\|json`, `--out`, `--no-cache`, `--no-gitignore` |
65
+ | `guard sync` | `--root`, `--policy`, `--write`, `--no-cache`, `--no-gitignore`, `--conflict-markers`, `--init-vars` |
66
+ | `guard bump <tag>` | `--root`, `--policy`, `--repo <owner>/<repo>`, `--dry-run`, `--no-cache`, `--no-gitignore`, `--conflict-markers` |
67
+ | `guard explain <rule-id>` | — |
68
+ | `guard version` | — |
69
+
70
+ `guard sync` and `guard bump` take a standards release in as a **three-way merge**: the
71
+ master at the tag the project sits on is the base, the master at the new tag is theirs, and
72
+ your repository is ours, so project-specific wording survives. A file where your edits and
73
+ the standards change overlap is reported as a **conflict** and left untouched
74
+ (`--conflict-markers` writes it out with `<<<<<<<` / `|||||||` / `=======` / `>>>>>>>`
75
+ markers instead). Both exit `0` with no conflicts, `1` when anything conflicts — `guard bump`
76
+ then writes nothing at all, not even the policy — and `2` on a run-time error.
77
+
78
+ `guard bump <tag> --dry-run` prints the same plan, the predicted conflicts and the policy
79
+ lines it would rewrite, writes nothing, and returns the exit code the real run would. It is
80
+ the only way to see a **new** tag's diff up front: `guard sync` without `--write` is a
81
+ dry-run against the tag the policy **currently** pins. `--dry-run` cannot be combined with
82
+ `--conflict-markers`.
83
+
84
+ The merge reads the project's placeholder substitutions from `guardsmith.vars.yaml`
85
+ (project root, committed, no secrets). `guard new` writes the skeleton; an existing project
86
+ generates one with `guard sync --init-vars`. A policy with no `drift3` rule keeps the old
87
+ section-level `guard sync --write` behaviour.
62
88
 
63
89
  Checks operate on **files that could be committed**: `.gitignore` (nested files included)
64
90
  is honoured by default and `.git/` is always excluded, so `secret-scan` never reports a
@@ -67,6 +93,16 @@ as missing. The policy's `ignore` globs are excluded on top of that, and exclude
67
93
  pruned during traversal rather than filtered afterwards. `--no-gitignore` restores the full
68
94
  scan when you want to audit ignored files.
69
95
 
96
+ `guard lint` also measures how much context a `CLAUDE.md` keeps resident: `import-budget`
97
+ adds up the entry file plus every file reached through its `@path` imports and always
98
+ reports one `info` (`resident context: N files, X chars (≈Y tokens, rough estimate)` plus a
99
+ per-file breakdown; the token figure is a rough `chars / 4` estimate). Nothing outside the
100
+ scan root is read. Write package names as `` `@scope/pkg` `` — `@` is an import anywhere in
101
+ the file, so a bare `@scope/pkg` is read as one and reported as `unresolved import`.
102
+
103
+ The policy schema is strict: unknown keys under `with` or on a rule are **parse errors**
104
+ naming the offending path, not silently dropped fields.
105
+
70
106
  After `guard new`, open the project with Claude Code — the bundled `init-project` skill
71
107
  interviews you and concretizes the templates. `guard lint` passes once initialization
72
108
  is genuinely complete.
@@ -78,9 +114,9 @@ is genuinely complete.
78
114
  version: 1
79
115
  target: claude-code
80
116
  extends:
81
- - github:novexar/guardsmith//presets/baseline.yaml@v0.6.0 # tag pinning is mandatory
117
+ - github:novexar/guardsmith//presets/baseline.yaml@v0.7.1 # tag pinning is mandatory
82
118
  # Projects with a frontend also add:
83
- # - github:novexar/guardsmith//presets/frontend.yaml@v0.6.0
119
+ # - github:novexar/guardsmith//presets/frontend.yaml@v0.7.1
84
120
  ignore: [] # globs excluded from every scan (concatenated across extends layers)
85
121
  rules: [] # add or override (redefining an id overrides it)
86
122
  exemptions: [] # time-boxed waivers: reason + approved_by + expires required
@@ -97,7 +133,7 @@ Add one line to your workflow using the
97
133
  [GuardSmith Lint Action](https://github.com/marketplace/actions/guardsmith-lint):
98
134
 
99
135
  ```yaml
100
- - uses: novexar/Guardsmith@v0.6.0
136
+ - uses: novexar/Guardsmith@v0.7.1
101
137
  ```
102
138
 
103
139
  Violating PRs fail with a summary comment and a SARIF report. Air-gapped environments can
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardsmith/cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "GuardSmith CLI — the guard binary (init / lint / sync / new / explain)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -19,6 +19,6 @@
19
19
  "bin"
20
20
  ],
21
21
  "dependencies": {
22
- "@guardsmith/core": "^0.5.0"
22
+ "@guardsmith/core": "^0.6.1"
23
23
  }
24
24
  }