Skip to content

Scaffold capability-targeted package starters - #332

Merged
unbraind merged 2 commits into
mainfrom
feat/package-init-capability-scaffold-pm-nhby
Jun 21, 2026
Merged

unbraind merged 2 commits into
mainfrom
feat/package-init-capability-scaffold-pm-nhby

Conversation

@unbraind

Copy link
Copy Markdown
Owner

Summary

  • add pm package init / pm extension init --capability <commands|hooks> with commands as the default
  • scaffold hook starters with commands + hooks, a starter command, an after_command lifecycle reactor, and package-mode SDK sample tests using assertRegisteredHook / runRegisteredHookForTest
  • update contracts, shell completions, concise help, SDK/package docs, PM tracker evidence, and package-owned CHANGELOG.md

Verification

  • node scripts/run-tests.mjs test -- tests/unit/extensions/extension-command.spec.ts tests/unit/commands/completion-command.spec.ts tests/unit/commands/contracts-command.spec.ts tests/unit/sdk/sdk-index.spec.ts tests/unit/cli/cli-main-errors.spec.ts
  • pnpm build && pnpm contracts:check
  • pnpm quality:static
  • pnpm security:scan
  • manual temp smoke: pm init, pm package init ./hook-package --capability hooks, local SDK npm install, npm test, pm install ./hook-package, pm package doctor --project --detail deep --trace, pm hook-package ping
  • node scripts/run-tests.mjs coverage -> 100/100/100/100 across 4,830 tests
  • pnpm changelog:pm && pnpm changelog:pm:check
  • node scripts/release/sentry-telemetry-gate.mjs --json --telemetry-mode best-effort --sentry-window-days 14 --max-critical 0 --max-high 0

PM

  • closes pm-nhby

Add package/extension init --capability support for commands and hooks starters. Hook scaffolds now declare commands+hooks, register an after_command lifecycle reactor, and include package-mode SDK sample tests using assertRegisteredHook and runRegisteredHookForTest.

Update help, shell completions, SDK contracts, docs, tests, and the package-owned changelog. Close pm-nhby with evidence including temp-project smoke, sentry/telemetry checks, changelog validation, and full 100/100/100/100 coverage.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @unbraind, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@unbraind

Copy link
Copy Markdown
Owner Author

@codex review
/gemini review
@gemini-code-assist
@coderabbitai full review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@unbraind, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 8 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1546d874-4881-4e2b-a34c-336b8a0f8fc2

📥 Commits

Reviewing files that changed from the base of the PR and between de1b7bd and 3e2fd95.

📒 Files selected for processing (16)
  • .agents/pm/features/pm-nhby.toon
  • .agents/pm/history/pm-nhby.jsonl
  • CHANGELOG.md
  • docs/EXTENSIONS.md
  • docs/SDK.md
  • src/cli/commands/completion.ts
  • src/cli/commands/extension.ts
  • src/cli/commands/extension/scaffold.ts
  • src/cli/help-content.ts
  • src/cli/register-setup.ts
  • src/sdk/cli-contracts.ts
  • tests/fixtures/contracts/full.json
  • tests/unit/commands/completion-command.spec.ts
  • tests/unit/commands/contracts-command.spec.ts
  • tests/unit/extensions/extension-command.spec.ts
  • tests/unit/sdk/sdk-index.spec.ts
📝 Walkthrough

Walkthrough

Adds a --capability <kind> option to pm package init / pm extension init, supporting commands (default) and hooks variants. The hooks variant scaffolds after_command lifecycle wiring in index.js, capability-conditional manifest.json, and a runnable index.test.js using SDK hook-testing helpers. CLI registration, contracts, completions, help text, and docs are updated accordingly.

Changes

--capability scaffold feature

Layer / File(s) Summary
Scaffold capability types and file generators
src/cli/commands/extension/scaffold.ts
Adds SCAFFOLD_CAPABILITIES/ExtensionScaffoldCapability, introduces buildActivateBodyLines and buildSampleTestSource helpers, and updates buildStarterExtensionScaffoldFiles and scaffoldExtensionProject to generate capability-conditional manifest, index.js, index.test.js, and README content.
CLI option registration and extension command integration
src/cli/register-setup.ts, src/cli/commands/extension.ts
Registers --capability <kind> on the lifecycle command and init subcommand, adds capability? to ExtensionCommandOptions, wires it through runExtension with an init-only guard, and passes it to scaffoldExtensionProject.
CLI contracts, completion scripts, and help text
src/sdk/cli-contracts.ts, src/cli/commands/completion.ts, src/cli/help-content.ts
Adds --capability to EXTENSION_FLAG_CONTRACTS and EXTENSION_INIT_FLAG_CONTRACTS via a new EXTENSION_SCOPE_FLAG_CONTRACTS; updates bash/zsh/fish completions with --capability choices; adds hooks capability examples and tips to package init / extension init help entries.
Unit tests, contract fixtures, and SDK assertions
tests/fixtures/contracts/full.json, tests/unit/extensions/extension-command.spec.ts, tests/unit/commands/completion-command.spec.ts, tests/unit/commands/contracts-command.spec.ts, tests/unit/sdk/sdk-index.spec.ts
Updates contract fixture with --capability entries for extension/package/packages commands; adds new tests for hooks scaffolding (package and extension modes), unknown capability rejection, and init-only guard; adjusts existing scaffold and completion expectations.
Documentation and changelog
CHANGELOG.md, docs/EXTENSIONS.md, docs/SDK.md, .agents/pm/...
Adds changelog entry, expands EXTENSIONS.md and SDK.md with --capability hooks examples and scaffold behavior descriptions, and records the feature in agent tracking files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • unbraind/pm-cli#321: This PR extends the same buildStarterExtensionScaffoldFiles and index.test.js generation added by PR #321, parameterizing it with --capability and varying the generated test and manifest content.
  • unbraind/pm-cli#327: Both PRs modify the lifecycle code generated inside scaffold.ts—PR #327 adds deactivate teardown stubs while this PR adds after_command hook wiring for the hooks capability.
  • unbraind/pm-cli#328: Both PRs extend the generated index.test.js template in scaffold.ts—PR #328 adds runRegisteredCommandForTest invocation, while this PR adds capability-conditional hook assertions using assertRegisteredHook and runRegisteredHookForTest.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Scaffold capability-targeted package starters' clearly and concisely summarizes the main change: adding capability-targeted scaffolding (commands vs hooks) to package initialization, which aligns with the core feature across all modified files.
Description check ✅ Passed The description is well-organized and directly related to the changeset, covering the feature summary, scaffolding differences, updated components, comprehensive verification steps, and PM tracker closure.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

@unbraind Sure, I'll kick off a full review of this PR now.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a --capability <kind> option to the pm package init and pm extension init commands, allowing developers to scaffold starter packages targeted at specific capabilities, specifically commands (default) or hooks. When the hooks capability is selected, the scaffolded package includes an after_command lifecycle reactor along with corresponding SDK-based tests. The changes also update shell completions, CLI contracts, help content, and documentation. A review comment suggests simplifying and strengthening the validation of the --capability option on non-init actions to prevent bypassing the check with empty strings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/cli/commands/extension.ts Outdated
Comment on lines +1146 to +1148
if (typeof options.capability === "string" && options.capability.trim().length > 0 && action !== "init") {
throw new PmCliError("--capability is only valid with --init/--scaffold.", EXIT_CODE.USAGE);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check for --capability on non-init actions can be simplified and made more robust. Checking options.capability.trim().length > 0 allows users to bypass this validation by passing an empty or whitespace-only string (e.g., --capability ""), which should still be rejected on non-init actions. We can simply check if options.capability is a string.

Suggested change
if (typeof options.capability === "string" && options.capability.trim().length > 0 && action !== "init") {
throw new PmCliError("--capability is only valid with --init/--scaffold.", EXIT_CODE.USAGE);
}
if (typeof options.capability === "string" && action !== "init") {
throw new PmCliError("--capability is only valid with --init/--scaffold.", EXIT_CODE.USAGE);
}

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a --capability <kind> option (supporting commands and hooks) to the pm package init and pm extension init commands, allowing authors to scaffold targeted starter packages. Selecting hooks scaffolds an after_command lifecycle reactor along with corresponding SDK testing coverage, documentation, and shell completions. The feedback suggests improving the robustness of the --capability validation on non-init actions by checking for any presence of the flag (options.capability !== undefined) rather than just non-empty strings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/cli/commands/extension.ts Outdated
Comment on lines +1146 to +1148
if (typeof options.capability === "string" && options.capability.trim().length > 0 && action !== "init") {
throw new PmCliError("--capability is only valid with --init/--scaffold.", EXIT_CODE.USAGE);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check for --capability on non-init actions can be simplified and made more robust. Currently, it only throws if the capability is a non-empty string. If a user passes --capability "" or --capability (which might be parsed as a boolean or empty string depending on the environment) to a non-init action, it will not be rejected. Checking for options.capability !== undefined is simpler and correctly rejects any presence of the flag on non-init actions.

Suggested change
if (typeof options.capability === "string" && options.capability.trim().length > 0 && action !== "init") {
throw new PmCliError("--capability is only valid with --init/--scaffold.", EXIT_CODE.USAGE);
}
if (options.capability !== undefined && action !== "init") {
throw new PmCliError("--capability is only valid with --init/--scaffold.", EXIT_CODE.USAGE);
}

Address Gemini review feedback by treating any present --capability value as invalid on non-init package/extension actions, including an empty string value.

Add regression coverage and record the reviewer follow-up on pm-nhby.
@unbraind

Copy link
Copy Markdown
Owner Author

Review follow-up pushed in 3e2fd95 for Gemini feedback. Please review the current head again.

@codex review
/gemini review
@gemini-code-assist
@coderabbitai full review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

@unbraind Sure! I'll kick off a full review of the current head now.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the "--capability " option for the "pm package init" and "pm extension init" commands, allowing developers to scaffold capability-targeted starter packages. Specifically, it supports the default "commands" capability and a new "hooks" capability, which scaffolds an "after_command" lifecycle reactor along with corresponding SDK testing coverage. The changes span CLI command registration, shell completions, CLI contracts, documentation, and comprehensive unit tests. As there are no review comments provided, I have no additional feedback on this pull request.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant