Skip to content

feat(lib): add NonEmptyArray helper, tighten preferredRunner#125

Merged
wyattjoh merged 1 commit intomainfrom
feat/lib-non-empty-array
Apr 15, 2026
Merged

feat(lib): add NonEmptyArray helper, tighten preferredRunner#125
wyattjoh merged 1 commit intomainfrom
feat/lib-non-empty-array

Conversation

@wyattjoh
Copy link
Copy Markdown
Contributor

@wyattjoh wyattjoh commented Apr 7, 2026

Summary

  • Adds lib/helpers/arrays.ts with a NonEmptyArray<T> type alias and an isNonEmpty<T> type-guard predicate.
  • Tightens preferredRunner to require a NonEmptyArray<Runner> input and return Runner (no longer | undefined).
  • Updates the two call sites (init/skills.ts, init/format.ts) to use isNonEmpty for the non-empty check, and drops the now-provably-unreachable defensive if (!preferred) branch in skills.ts. The type system enforces the invariant that runtime code previously checked.

Stacked on #124.

Test plan

  • bun run test passes (60 passed)
  • bun test packages/cli-core/src/lib/helpers/arrays.test.ts covers the type guard

@wyattjoh
Copy link
Copy Markdown
Contributor Author

wyattjoh commented Apr 7, 2026

@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch from 47dc327 to 21072f9 Compare April 7, 2026 19:40
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from 26405f7 to 1e94859 Compare April 7, 2026 19:40
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch from 21072f9 to d52abd4 Compare April 7, 2026 20:23
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch 2 times, most recently from 670617f to 10da1db Compare April 7, 2026 21:58
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch 2 times, most recently from 133bd4a to ecae3c7 Compare April 8, 2026 21:39
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch 2 times, most recently from a4185bb to a45b262 Compare April 9, 2026 20:23
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch from ecae3c7 to 3f687c8 Compare April 9, 2026 20:23
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from a45b262 to c95a429 Compare April 9, 2026 22:54
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch 2 times, most recently from 207adbd to dcb4afa Compare April 11, 2026 06:48
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from c95a429 to 79d474f Compare April 11, 2026 06:48
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch from dcb4afa to d700db1 Compare April 11, 2026 06:54
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch 2 times, most recently from 08653a1 to a8903e7 Compare April 13, 2026 20:01
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch 2 times, most recently from 0262797 to 523c58a Compare April 13, 2026 22:49
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from a8903e7 to 190c5d5 Compare April 13, 2026 22:49
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch from 523c58a to 3a3375e Compare April 13, 2026 23:20
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from 190c5d5 to 09c9f9b Compare April 13, 2026 23:20
@wyattjoh wyattjoh force-pushed the refactor/format-uses-runners branch from 3a3375e to f7ab840 Compare April 14, 2026 18:56
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from 09c9f9b to 59ca3db Compare April 14, 2026 18:56
Base automatically changed from refactor/format-uses-runners to main April 14, 2026 19:13
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from 59ca3db to 5f34cb8 Compare April 14, 2026 20:09
@wyattjoh wyattjoh marked this pull request as ready for review April 14, 2026 20:10
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from 5f34cb8 to b30a809 Compare April 14, 2026 20:12
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8293af40-5596-4c25-b0d2-d6af154d8da7

📥 Commits

Reviewing files that changed from the base of the PR and between 5ae8ed6 and f9c2e28.

📒 Files selected for processing (7)
  • .changeset/fiery-comics-shave.md
  • packages/cli-core/src/commands/init/format.ts
  • packages/cli-core/src/commands/init/skills.ts
  • packages/cli-core/src/lib/helpers/arrays.test.ts
  • packages/cli-core/src/lib/helpers/arrays.ts
  • packages/cli-core/src/lib/runners.test.ts
  • packages/cli-core/src/lib/runners.ts
✅ Files skipped from review due to trivial changes (2)
  • .changeset/fiery-comics-shave.md
  • packages/cli-core/src/lib/helpers/arrays.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/cli-core/src/commands/init/format.ts
  • packages/cli-core/src/lib/runners.ts
  • packages/cli-core/src/lib/helpers/arrays.ts
  • packages/cli-core/src/lib/runners.test.ts

📝 Walkthrough

Walkthrough

Adds a NonEmptyArray<T> type and an isNonEmpty() type guard with tests. preferredRunner() signature changed to require available: NonEmptyArray<Runner> and to always return a Runner (removed empty-array handling). Call sites in init/format and init/skills now gate with isNonEmpty(available) and no longer treat preferredRunner() as possibly undefined. Runner tests were updated to use non-empty inputs and removed empty-list assertions. A new empty changeset file was added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% 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 accurately describes the main changes: adding a NonEmptyArray helper utility and tightening the preferredRunner function signature.
Description check ✅ Passed The description is directly related to the changeset, providing a clear summary of the new utilities added and the function signature changes made.

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


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

@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from b30a809 to 6e469c7 Compare April 14, 2026 21:35
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch 2 times, most recently from c7f94fa to 78613e5 Compare April 15, 2026 20:06
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: f9c2e28

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from 78613e5 to 5ae8ed6 Compare April 15, 2026 21:13
@wyattjoh wyattjoh requested a review from rafa-thayto April 15, 2026 21:47
Adds `lib/helpers/arrays.ts` with a NonEmptyArray<T> type alias and an
isNonEmpty<T> type-guard predicate. Tightens preferredRunner to require
a NonEmptyArray<Runner> input and return Runner (no longer | undefined).

Updates the two call sites (init/skills.ts, init/format.ts) to use
isNonEmpty for the non-empty check, and drops the now-provably-unreachable
defensive `if (!preferred)` branch in skills.ts. The type system enforces
the invariant that runtime code previously checked.
@wyattjoh wyattjoh force-pushed the feat/lib-non-empty-array branch from 5ae8ed6 to f9c2e28 Compare April 15, 2026 22:23
@wyattjoh wyattjoh merged commit 3b840b8 into main Apr 15, 2026
10 checks passed
@wyattjoh wyattjoh deleted the feat/lib-non-empty-array branch April 15, 2026 22:38
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.

2 participants