Skip to content

Comments

Refactor: consolidate types, add shared utils, tests, and CI#25

Open
TOFFster96 wants to merge 3 commits intoJIGGAI:mainfrom
TOFFster96:main
Open

Refactor: consolidate types, add shared utils, tests, and CI#25
TOFFster96 wants to merge 3 commits intoJIGGAI:mainfrom
TOFFster96:main

Conversation

@TOFFster96
Copy link

Summary

This PR improves maintainability and reliability by: (1) centralizing repeated patterns into shared utilities, (2) adding 301 tests with Vitest to catch regressions, and (3) adding pre-commit hook + GitHub Actions CI. All changes are non-breaking; behavior stays the same.


Benefits of Merging

Benefit Impact
Regression safety 301 automated tests cover libs, API routes, and edge cases.
Faster future changes Shared helpers mean fewer edits to fix bugs or add features.
CI guardrail Lint + tests run on every push/PR to prevent broken merges.
Pre-commit checks Lint and tests run before commits, catching issues locally.
Type clarity Shared types for AgentListItem, GoalFrontmatter, RecipeDetail, CronJob reduce drift and confusion.

What Changed

New shared utilities (in src/lib/):

  • errorMessage(e) — replaces 30+ copies of e instanceof Error ? e.message : String(e)
  • listRecipes() / findRecipeById() — centralizes recipe lookup instead of duplicating runOpenClaw + JSON.parse
  • slugifyId() — shared slugification used by goals, CloneTeamModal, and goal-promote
  • cronJobId() / cronJobLabel() / fmtCronSchedule() — consistent handling of cron job objects
  • forceFrontmatterId() — moved from team-editor into lib/recipes
  • safeJsonParse() — extracted from channels into lib/json

Type consolidation:

  • AgentListItem — exported from lib/agents, used across 5 call sites
  • GoalFrontmatter — used instead of duplicated Goal type in goals clients
  • RecipeDetail — used in RecipeEditor instead of local Recipe
  • CronJob — exported from lib/cron for cron UIs

Testing & CI:

  • Vitest + Testing Library for unit and API route tests
  • Coverage thresholds for src/lib/** (80%)
  • Pre-commit hook (husky) runs lint + tests before commits
  • GitHub Actions workflow runs lint + coverage on push and PRs

Testing

  • npm run lint — passes
  • npm run test:run — 301 tests pass
  • npm run coverage — meets configured thresholds

Breaking Changes

None. All changes are refactors and additions; public behavior is unchanged.

Made with Cursor

- Add errorMessage() util, replace 30+ duplicate catch patterns
- Add listRecipes/findRecipeById in lib/recipes
- Add CronJob type and cronJobId/cronJobLabel/fmtCronSchedule in lib/cron
- Add slugifyId in lib/slugify, use in goals, CloneTeamModal, goal-promote
- Consolidate AgentListItem (lib/agents), GoalFrontmatter (lib/goals)
- Move forceFrontmatterId to lib/recipes
- Add safeJsonParse to lib/json
- Use Pick<AgentListItem> for team agents in team-editor
- Add Vitest, 300+ tests, pre-commit hook, CI workflow

Co-authored-by: Cursor <cursoragent@cursor.com>
TOFFster96 and others added 2 commits February 18, 2026 19:12
- Add jscpd copy-paste detection + .jscpd.json config
- Add scripts/refactor-report.mjs (coverage gaps, patterns; Node fallback when rg missing)
- Add dup:check and refactor:report npm scripts
- Add report/jscpd to CI, upload artifact
- ESLint: add report/** to ignores, SonarJS duplicate rules, no-os-command override for refactor script
- Extract api-route-helpers (getTeamContext, listWorkspaceFiles) for teams/agents API
- Extract ConfirmationModal, WorkspaceFileListSidebar, GoalFormFields
- Refactor CloneTeamModal, DeleteTeamModal, DeleteRecipeModal, agent delete to use ConfirmationModal
- Extract updateTeamAgents in team-editor; use WorkspaceFileListSidebar in team/agent editors
- Extract parseCommaList, parseGoalResponse, loadGoal in goals flow
- Add .husky/pre-push for dup:check
- Improve promote route coverage (EEXIST, error handling tests)
- Ignore refactor-report.md output

Co-authored-by: Cursor <cursoragent@cursor.com>
- Extract tab panels into sub-components in team-editor and agent-editor
  to reduce cognitive complexity below limit (22 -> ≤15)
- Deduplicate IdentityTabProps type in agent-editor (fixes jscpd)
- Harden slugify against ReDoS (avoid slow regex)
- Fix react-hooks/exhaustive-deps in channels-client
- Remove CI continue-on-error for jscpd (0 clones)

Co-authored-by: Cursor <cursoragent@cursor.com>
@rjdjohnston
Copy link
Collaborator

Appreciate the work! Kitchen was released tonight. No more major changes coming for a few

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