feat: --scopes オプションのヘルプに有効なスコープ一覧を追加#73
Conversation
help.ts に addNotes() 機能を追加し、--scopes を持つコマンド (me oauth-clients create, me api-keys create, admin api-keys create/update) の NOTES セクションに全16リソーススコープと包含関係を表示。
📝 WalkthroughWalkthroughコマンドヘルプにNOTESセクションを追加する機能を導入し、 Changes
(テストファイル群の例: Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/helpers.ts (1)
10-19: スコープ定義を構造化すると将来の更新差分を減らせます(任意)。現状でも動作は正しいですが、文字列を直接列挙する形だと更新時に漏れや整形差分が入りやすいです。
RESOURCE_SCOPESのような配列を元に NOTES 文面を組み立てる形にすると保守しやすくなります。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/helpers.ts` around lines 10 - 19, Replace the hard-coded multi-line string array SCOPES_HELP_NOTES with a derived construction from a structured RESOURCE_SCOPES array: define RESOURCE_SCOPES (e.g., list of resources like entities, subscriptions, registrations, rules, custom-data-models, users, tenants, policies, oauth-clients, api-keys, metrics) with allowed verbs (read, write, admin) or mapped scope variants, then programmatically generate SCOPES_HELP_NOTES by iterating RESOURCE_SCOPES to produce the formatted lines (including grouping admin and write implications and the header/footer lines). Update any usages of SCOPES_HELP_NOTES to reference the generated constant so future scope additions only require editing RESOURCE_SCOPES.tests/me-oauth-clients.test.ts (1)
27-30: NOTES 配線の回帰防止としてaddNotes呼び出し検証を1件追加するのがおすすめです。モック追加はできているので、コマンド登録時に
addNotesが実際に呼ばれることまで確認できると、この機能の退行をより早く検知できます。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/me-oauth-clients.test.ts` around lines 27 - 30, The test currently mocks addNotes (and addExamples) but doesn't assert it was invoked; after the code path that registers the command(s) in this test, add an assertion that the mocked addNotes was called (e.g., expect(addNotes).toHaveBeenCalledTimes(1) or toHaveBeenCalled()), referencing the existing vi.mock stub for addNotes so the assertion verifies the command registration triggers addNotes; place this assertion immediately after the command-registration invocation in the me-oauth-clients test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/helpers.ts`:
- Around line 10-19: Replace the hard-coded multi-line string array
SCOPES_HELP_NOTES with a derived construction from a structured RESOURCE_SCOPES
array: define RESOURCE_SCOPES (e.g., list of resources like entities,
subscriptions, registrations, rules, custom-data-models, users, tenants,
policies, oauth-clients, api-keys, metrics) with allowed verbs (read, write,
admin) or mapped scope variants, then programmatically generate
SCOPES_HELP_NOTES by iterating RESOURCE_SCOPES to produce the formatted lines
(including grouping admin and write implications and the header/footer lines).
Update any usages of SCOPES_HELP_NOTES to reference the generated constant so
future scope additions only require editing RESOURCE_SCOPES.
In `@tests/me-oauth-clients.test.ts`:
- Around line 27-30: The test currently mocks addNotes (and addExamples) but
doesn't assert it was invoked; after the code path that registers the command(s)
in this test, add an assertion that the mocked addNotes was called (e.g.,
expect(addNotes).toHaveBeenCalledTimes(1) or toHaveBeenCalled()), referencing
the existing vi.mock stub for addNotes so the assertion verifies the command
registration triggers addNotes; place this assertion immediately after the
command-registration invocation in the me-oauth-clients test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 81e4946b-8a85-4606-8c4e-dbe8555195ff
📒 Files selected for processing (23)
CHANGELOG.mdREADME.mdsrc/commands/admin/api-keys.tssrc/commands/help.tssrc/commands/me-api-keys.tssrc/commands/me-oauth-clients.tssrc/helpers.tstests/admin-api-keys.test.tstests/admin-oauth-clients.test.tstests/admin-policies.test.tstests/admin-tenants.test.tstests/admin-users.test.tstests/auth.test.tstests/commands-config.test.tstests/commands-profile.test.tstests/entities.test.tstests/health.test.tstests/me-api-keys.test.tstests/me-oauth-clients.test.tstests/setup-command-mocks.tstests/snapshots.test.tstests/temporal.test.tstests/types.test.ts
writeConfig() に v1→v2 自動ラップを追加し、CLI プロセスでの auto-migration(ファイル再書き込み)を不要にした。 これにより別プロセス間のファイル I/O タイミング問題を解消。
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/step_definitions/token.steps.ts (1)
8-12:profiles[active]が存在しない場合の潜在的な問題
profiles[active]がundefinedの場合、.token = "invalidated"でランタイムエラーが発生する可能性があります。writeConfigが常にdefaultプロファイルを作成するため、performLogin後であれば問題ありませんが、防御的にチェックを追加することを検討してください。🛡️ 防御的なコードの提案
const full = this.readFullConfig(); const profiles = full.profiles as Record<string, Record<string, unknown>>; const active = (full.currentProfile as string) ?? "default"; +if (!profiles[active]) { + throw new Error(`Profile "${active}" not found in config`); +} profiles[active].token = "invalidated"; this.writeConfig(full);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/e2e/step_definitions/token.steps.ts` around lines 8 - 12, profiles[active] を直接参照して token を上書きすると、profiles[active] が undefined の場合にクラッシュするので、readFullConfig() で取得した full.profiles と active を使う箇所(変数 names: full, profiles, active)で profiles[active] が存在しない場合は防御的に新しいプロファイルオブジェクトを作成してから token を設定し、最後に writeConfig(full) を呼ぶように修正してください(存在チェックと代替作成ロジックを追加)。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/e2e/step_definitions/token.steps.ts`:
- Around line 8-12: profiles[active] を直接参照して token を上書きすると、profiles[active] が
undefined の場合にクラッシュするので、readFullConfig() で取得した full.profiles と active を使う箇所(変数
names: full, profiles, active)で profiles[active]
が存在しない場合は防御的に新しいプロファイルオブジェクトを作成してから token を設定し、最後に writeConfig(full)
を呼ぶように修正してください(存在チェックと代替作成ロジックを追加)。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 19260a42-0669-49ef-8db5-0cf5dd582e72
📒 Files selected for processing (4)
CHANGELOG.mdtests/e2e/step_definitions/auth.steps.tstests/e2e/step_definitions/token.steps.tstests/e2e/support/world.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- CHANGELOG.md
Summary
help.tsにaddNotes()機能を追加(addExamplesと同パターン)し、コマンドヘルプに NOTES セクションを表示可能に--scopesを持つ4コマンド (me oauth-clients create,me api-keys create,admin api-keys create,admin api-keys update) に全16リソーススコープの一覧と包含関係 (write:Ximpliesread:X,admin:Ximplies both) を表示permanent,jwt) の説明を追加admin api-keys createの例で誤ったスコープ形式 (entities:read) をread:entitiesに修正Test plan
npm run lint— passnpm run typecheck— passnpm test— 624 tests passgeonic help me oauth-clients createで NOTES セクションにスコープ一覧が表示されることを確認geonic help me api-keys createで同様に確認geonic help admin api-keys createで同様に確認geonic help admin api-keys updateで同様に確認Summary by CodeRabbit
リリースノート
新機能
ドキュメンテーション
バグ修正