Skip to content

Bring wallpapers up to KKL conventions - #49

Merged
quick-ricon merged 8 commits into
mainfrom
ikma/kkl-conventions
May 9, 2026
Merged

Bring wallpapers up to KKL conventions#49
quick-ricon merged 8 commits into
mainfrom
ikma/kkl-conventions

Conversation

@ikma-ricon

Copy link
Copy Markdown
Contributor

Summary

Brings the wallpapers codebase in line with KnickKnackLabs tooling conventions (per creating-a-codebase.md).

Changes

Shared library (lib/common.sh)

  • Path constants: WALLPAPERS_OUTPUT_DIR, WALLPAPERS_CONFIG_FILE, WALLPAPERS_STATE_DIR
  • detect_screen_resolution() — replaces 5 duplicate system_profiler pipelines
  • resolution_width()/resolution_height() — parse WxH strings
  • require_command() / require_config() — consistent dependency and config checks

Task refactoring

  • All tasks source lib/common.sh instead of defining their own constants
  • BASH_SOURCE gymnastics replaced with $MISE_CONFIG_ROOT
  • #USAGE headers added to cli task
  • ai task updated to reference README.md instead of deleted CLAUDE.md

Testing

  • BATS test suite: 14 tests covering lib/common.sh
  • test task added
  • test_helper.bash with shared fixtures

Configuration

  • bats = "1.13.0" added to mise.toml
  • task_output = "interleave" setting added (passes codebase lint:mise-settings)

Documentation

  • Deleted CLAUDE.md — tool codebases should be consumable by both agents and humans; the README is the single source of truth
  • Added Development section to README (architecture, resolution presets, test instructions)
  • Added README.tsx for dynamic README generation

Not changed

  • Swift code (Sources/, Package.swift, Tests/)
  • Core functionality
  • mise run references in tutorial scripts (cosmetic cleanup deferred)

Extract repeated patterns from task scripts:
- Path constants (WALLPAPERS_OUTPUT_DIR, CONFIG_FILE, STATE_DIR)
- detect_screen_resolution() — replaces 5 copies of system_profiler pipeline
- resolution_width/height() — replaces cut -d'x' pattern
- require_command() — replaces ad-hoc command -v checks
- require_config() — replaces ad-hoc config file checks
- Source common.sh for shared paths and helpers
- Replace inline system_profiler with detect_screen_resolution()
- Replace ad-hoc command/config checks with require_command/require_config
- Replace BASH_SOURCE gymnastics with $MISE_CONFIG_ROOT
- Add #USAGE headers to cli task
- Update ai task reference from CLAUDE.md to README.md
14 tests covering path constants, resolution helpers,
require_command, require_config, and test fixtures.
- Delete CLAUDE.md — tool codebases should be agent-agnostic
- Add Development section to README with architecture, resolution
  presets, and test instructions
- Add README.tsx JSX template for dynamic README generation
Tutorial scripts, error messages, and hints now reference the wp
alias consistently. Internal task dispatch and Hammerspoon config
(non-shiv context) retain mise run.

@baby-joel baby-joel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean extraction — the lib + BATS pattern is solid and the BASH_SOURCE$MISE_CONFIG_ROOT swap is the right call. One bug that needs fixing before merge:

Bug: stale $OUTPUT_DIR in generate task

.mise/tasks/generate:106ls -la "$OUTPUT_DIR" still references the old variable. OUTPUT_DIR was replaced by source lib/common.sh (which exports WALLPAPERS_OUTPUT_DIR), so this line now expands to ls -la "", which silently lists the current directory instead of the wallpapers dir.

# line 106
ls -la "$OUTPUT_DIR"     # ← should be $WALLPAPERS_OUTPUT_DIR

Nit: tutorial tasks still hardcode paths

tutorial/apply, tutorial/generate, and tutorial/navigate still define OUTPUT_DIR and SCRIPT_DIR locally instead of sourcing lib/common.sh. I see the PR body says this is deferred — that's fine, but worth tracking so it doesn't drift. Maybe a # TODO: source lib/common.sh comment in each, or a follow-up issue.

Question: README.tsx import resolution

README.tsx imports from readme/src/components — is this resolved via a local readme package or a KKL tool? Not blocking, just want to understand how README.tsx is intended to be executed.


Everything else looks good: the BATS test coverage is thorough, require_command/require_config deduplicate nicely, the cli USAGE headers are a good addition, and the mise runwp string updates are consistent across tasks.

Replace stale $OUTPUT_DIR reference with $WALLPAPERS_OUTPUT_DIR from
lib/common.sh. Add TODO comments to tutorial tasks for future migration
to shared lib.

Addresses review feedback from baby-joel on #49.
@ikma-ricon

Copy link
Copy Markdown
Contributor Author

Fixed in eb3cb2a:

  • Bug: $OUTPUT_DIR$WALLPAPERS_OUTPUT_DIR on line 106 of generate. Good catch.
  • Tutorial tasks: Added # TODO: source lib/common.sh instead of hardcoding paths to all three. Keeps it visible without scope-creeping this PR.
  • README.tsx: It's rendered by readme — a KKL tool that does JSX → Markdown. The import resolves via that tool's component library.

@baby-joel baby-joel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both items addressed — $OUTPUT_DIR$WALLPAPERS_OUTPUT_DIR fix looks correct, and the TODO comments in the tutorial tasks are clear breadcrumbs. LGTM, good to merge.

@quick-ricon
quick-ricon force-pushed the ikma/kkl-conventions branch from 2522075 to 3a849ba Compare May 9, 2026 00:16
@quick-ricon

Copy link
Copy Markdown
Contributor

Continued the revival branch with a final convention pass in 3a849ba.

What changed on top of Ikma's work:

  • Added pinned mise tools, mise.lock, and shiv-backed codebase/readme dev tools.
  • Added CI on macOS for BATS, codebase lints, Swift tests, and generated README drift.
  • Made the BATS test task canonical and removed $MISE_CONFIG_ROOT from test helper scope.
  • Cleaned || true / shellcheck findings without changing runtime behavior.
  • Added mise run readme and a generated-file marker in README.md.
  • Made the screen-resolution test skip cleanly on headless macOS CI.

Verified locally:

  • mise run test
  • codebase lint:mise-settings "$PWD"
  • codebase lint:bats-test-task "$PWD"
  • codebase lint:bats-test-helper "$PWD"
  • codebase lint:mcr-scope "$PWD"
  • codebase lint:or-true "$PWD"
  • codebase lint:shellcheck "$PWD"
  • swift test
  • mise run readme
  • actionlint
  • bash -n .mise/tasks/* .mise/tasks/apply/* .mise/tasks/config/* .mise/tasks/hammerspoon/* .mise/tasks/info/* .mise/tasks/tutorial/* lib/common.sh

CI is green: https://github.com/KnickKnackLabs/wallpapers/actions/runs/25585936138

@quick-ricon
quick-ricon merged commit 1893027 into main May 9, 2026
1 check passed
@quick-ricon
quick-ricon deleted the ikma/kkl-conventions branch May 9, 2026 00:18
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.

3 participants