Skip to content

refactor(core): rename Context to CommandContext#104

Merged
zrosenbauer merged 2 commits intomainfrom
refactor/context-rename
Mar 24, 2026
Merged

refactor(core): rename Context to CommandContext#104
zrosenbauer merged 2 commits intomainfrom
refactor/context-rename

Conversation

@zrosenbauer
Copy link
Member

Summary

  • Renames Context interface to CommandContext for clearer delineation between command handlers and screen components
  • Renames useCommandContext hook to useScreenContext to match the ScreenContext type it returns
  • Updates all references across core, cli, middleware, module augmentations, docs, and tests
  • No backwards-compatible aliases — clean break

Test plan

  • pnpm check passes (typecheck + lint + format)
  • pnpm test passes (744 tests)
  • All module augmentations updated (auth, report, icons)

…t to useScreenContext

Clearer delineation between command handler context (CommandContext)
and screen component context (ScreenContext). Updates all references
across core, cli, middleware, docs, and tests.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
oss-kidd Ignored Ignored Preview Mar 24, 2026 10:04pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: 9157536

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@kidd-cli/core Minor
@kidd-cli/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

This pull request systematically renames the exported context type from Context to CommandContext across documentation, core modules, CLI commands, middleware implementations, runtime logic, and test utilities. Additionally, the UI hook is renamed from useCommandContext to useScreenContext. The changes are primarily type-level annotations and import modifications; no runtime behavior or control flow logic is altered. Module augmentation examples in documentation are updated to target CommandContext instead of Context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The refactoring spans ~70 files with a consistent, repetitive pattern (Context → CommandContext, useCommandContext → useScreenContext), making individual change verification straightforward. However, the breadth requires systematic verification of import consistency, completeness of the rename across all affected files, alignment of documentation examples with code, and consistency of module augmentation targets.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the primary change: renaming Context to CommandContext across the codebase.
Description check ✅ Passed The description accurately outlines the PR's intent, including the two main renames, scope of changes, test coverage, and breaking change notice.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/context-rename

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

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 24, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing refactor/context-rename (9157536) with main (6998ac8)

Open in CodSpeed

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/middleware/http/README.md (1)

54-60: ⚠️ Potential issue | 🟡 Minor

Update the prose to CommandContext to avoid conflicting augmentation guidance.

Line 54 still instructs users to augment Context, while Line 60 correctly augments CommandContext. Keep both aligned so consumers don’t augment the wrong interface.

Suggested fix
-Augment the `Context` interface so TypeScript knows about the namespace property:
+Augment the `CommandContext` interface so TypeScript knows about the namespace property:

As per coding guidelines: “When renaming types in docs … update names precisely … and keep references … accurate and consistent across files.” (contributing/standards/documentation/writing.md)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/middleware/http/README.md` around lines 54 - 60, The docs
incorrectly refer to augmenting `Context` on line 54 while the example augments
`CommandContext`; update the prose so it consistently instructs consumers to
augment `CommandContext` (not `Context`) and scan the surrounding text for any
other mentions of `Context` to replace with `CommandContext`, ensuring the
example import and the `declare module` augmentation (including `HttpClient` and
the namespace property) remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/core/src/context/index.ts`:
- Line 6: Re-add a compatibility type export for the removed public Context by
exporting CommandContext under the old name; update the context entrypoint to
re-export or alias CommandContext as Context (e.g., export the type
CommandContext as Context or declare type Context = CommandContext) so consumers
importing Context continue to work — target the export in the same module where
CommandContext is currently exported.

In `@packages/core/src/ui/index.ts`:
- Line 67: Restore the legacy export by reintroducing a compatibility re-export
for useCommandContext that points to the new hook; locate the export block in
packages/core/src/ui/index.ts where useScreenContext is exported and add a
re-export/alias so useCommandContext is exported (e.g., export {
useScreenContext as useCommandContext }) to maintain backward compatibility
while keeping the canonical symbol useScreenContext.

---

Outside diff comments:
In `@packages/core/src/middleware/http/README.md`:
- Around line 54-60: The docs incorrectly refer to augmenting `Context` on line
54 while the example augments `CommandContext`; update the prose so it
consistently instructs consumers to augment `CommandContext` (not `Context`) and
scan the surrounding text for any other mentions of `Context` to replace with
`CommandContext`, ensuring the example import and the `declare module`
augmentation (including `HttpClient` and the namespace property) remain
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: df8ccab4-7830-4ca3-b046-eb42d73efe33

📥 Commits

Reviewing files that changed from the base of the PR and between 6998ac8 and 9157536.

⛔ Files ignored due to path filters (1)
  • .changeset/context-rename.md is excluded by !.changeset/**
📒 Files selected for processing (58)
  • README.md
  • docs/concepts/context.md
  • docs/concepts/icons.md
  • docs/concepts/reporting.md
  • docs/guides/add-authentication.md
  • docs/reference/command.md
  • docs/reference/middleware.md
  • docs/reference/report.md
  • packages/cli/src/commands/add/command.test.ts
  • packages/cli/src/commands/add/command.ts
  • packages/cli/src/commands/add/config.ts
  • packages/cli/src/commands/add/middleware.test.ts
  • packages/cli/src/commands/add/middleware.ts
  • packages/cli/src/commands/build.test.ts
  • packages/cli/src/commands/build.ts
  • packages/cli/src/commands/commands.test.ts
  • packages/cli/src/commands/commands.ts
  • packages/cli/src/commands/dev.test.ts
  • packages/cli/src/commands/dev.ts
  • packages/cli/src/commands/doctor.test.ts
  • packages/cli/src/commands/doctor.ts
  • packages/cli/src/commands/init.test.ts
  • packages/cli/src/commands/init.ts
  • packages/core/src/cli.test.ts
  • packages/core/src/context/create-context.ts
  • packages/core/src/context/decorate.ts
  • packages/core/src/context/index.ts
  • packages/core/src/context/types.ts
  • packages/core/src/index.ts
  • packages/core/src/middleware/auth/README.md
  • packages/core/src/middleware/auth/auth.ts
  • packages/core/src/middleware/auth/headers.test.ts
  • packages/core/src/middleware/auth/headers.ts
  • packages/core/src/middleware/auth/require.ts
  • packages/core/src/middleware/auth/types.ts
  • packages/core/src/middleware/http/README.md
  • packages/core/src/middleware/http/http.ts
  • packages/core/src/middleware/http/types.ts
  • packages/core/src/middleware/icons/context.ts
  • packages/core/src/middleware/icons/types.ts
  • packages/core/src/middleware/report/types.ts
  • packages/core/src/middleware/typed-middleware.test.ts
  • packages/core/src/runtime/args.test.ts
  • packages/core/src/runtime/register.ts
  • packages/core/src/runtime/runner.test.ts
  • packages/core/src/runtime/runner.ts
  • packages/core/src/runtime/runtime.test.ts
  • packages/core/src/runtime/runtime.ts
  • packages/core/src/runtime/types.ts
  • packages/core/src/test/context.ts
  • packages/core/src/test/middleware.test.ts
  • packages/core/src/test/types.ts
  • packages/core/src/types/command.ts
  • packages/core/src/types/middleware.ts
  • packages/core/src/ui/index.ts
  • packages/core/src/ui/provider.tsx
  • packages/core/src/ui/screen.test.ts
  • packages/core/src/ui/screen.tsx

@zrosenbauer zrosenbauer merged commit 008efc0 into main Mar 24, 2026
7 checks passed
@zrosenbauer zrosenbauer deleted the refactor/context-rename branch March 24, 2026 22:17
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