@abdullahsahmad/work-kit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +147 -0
  2. package/cli/bin/work-kit.mjs +18 -0
  3. package/cli/src/commands/complete.ts +123 -0
  4. package/cli/src/commands/completions.ts +137 -0
  5. package/cli/src/commands/context.ts +41 -0
  6. package/cli/src/commands/doctor.ts +79 -0
  7. package/cli/src/commands/init.test.ts +116 -0
  8. package/cli/src/commands/init.ts +184 -0
  9. package/cli/src/commands/loopback.ts +64 -0
  10. package/cli/src/commands/next.ts +172 -0
  11. package/cli/src/commands/observe.ts +144 -0
  12. package/cli/src/commands/setup.ts +159 -0
  13. package/cli/src/commands/status.ts +50 -0
  14. package/cli/src/commands/uninstall.ts +89 -0
  15. package/cli/src/commands/upgrade.ts +12 -0
  16. package/cli/src/commands/validate.ts +34 -0
  17. package/cli/src/commands/workflow.ts +125 -0
  18. package/cli/src/config/agent-map.ts +62 -0
  19. package/cli/src/config/loopback-routes.ts +45 -0
  20. package/cli/src/config/phases.ts +119 -0
  21. package/cli/src/context/extractor.test.ts +77 -0
  22. package/cli/src/context/extractor.ts +73 -0
  23. package/cli/src/context/prompt-builder.ts +70 -0
  24. package/cli/src/engine/loopbacks.test.ts +33 -0
  25. package/cli/src/engine/loopbacks.ts +32 -0
  26. package/cli/src/engine/parallel.ts +60 -0
  27. package/cli/src/engine/phases.ts +23 -0
  28. package/cli/src/engine/transitions.test.ts +117 -0
  29. package/cli/src/engine/transitions.ts +97 -0
  30. package/cli/src/index.ts +248 -0
  31. package/cli/src/observer/data.ts +237 -0
  32. package/cli/src/observer/renderer.ts +316 -0
  33. package/cli/src/observer/watcher.ts +99 -0
  34. package/cli/src/state/helpers.test.ts +91 -0
  35. package/cli/src/state/helpers.ts +65 -0
  36. package/cli/src/state/schema.ts +113 -0
  37. package/cli/src/state/store.ts +82 -0
  38. package/cli/src/state/validators.test.ts +105 -0
  39. package/cli/src/state/validators.ts +81 -0
  40. package/cli/src/utils/colors.ts +12 -0
  41. package/package.json +49 -0
  42. package/skills/auto-kit/SKILL.md +214 -0
  43. package/skills/build/SKILL.md +88 -0
  44. package/skills/build/stages/commit.md +43 -0
  45. package/skills/build/stages/core.md +48 -0
  46. package/skills/build/stages/integration.md +44 -0
  47. package/skills/build/stages/migration.md +41 -0
  48. package/skills/build/stages/red.md +44 -0
  49. package/skills/build/stages/refactor.md +48 -0
  50. package/skills/build/stages/setup.md +42 -0
  51. package/skills/build/stages/ui.md +51 -0
  52. package/skills/deploy/SKILL.md +62 -0
  53. package/skills/deploy/stages/merge.md +47 -0
  54. package/skills/deploy/stages/monitor.md +39 -0
  55. package/skills/deploy/stages/remediate.md +54 -0
  56. package/skills/full-kit/SKILL.md +195 -0
  57. package/skills/plan/SKILL.md +77 -0
  58. package/skills/plan/stages/architecture.md +53 -0
  59. package/skills/plan/stages/audit.md +58 -0
  60. package/skills/plan/stages/blueprint.md +60 -0
  61. package/skills/plan/stages/clarify.md +61 -0
  62. package/skills/plan/stages/investigate.md +47 -0
  63. package/skills/plan/stages/scope.md +46 -0
  64. package/skills/plan/stages/sketch.md +44 -0
  65. package/skills/plan/stages/ux-flow.md +49 -0
  66. package/skills/review/SKILL.md +104 -0
  67. package/skills/review/stages/compliance.md +48 -0
  68. package/skills/review/stages/handoff.md +59 -0
  69. package/skills/review/stages/performance.md +45 -0
  70. package/skills/review/stages/security.md +49 -0
  71. package/skills/review/stages/self-review.md +41 -0
  72. package/skills/test/SKILL.md +83 -0
  73. package/skills/test/stages/e2e.md +44 -0
  74. package/skills/test/stages/validate.md +51 -0
  75. package/skills/test/stages/verify.md +41 -0
  76. package/skills/wrap-up/SKILL.md +107 -0
@@ -0,0 +1,48 @@
1
+ ---
2
+ description: "Build sub-stage: Make failing tests pass — service layer, API, business logic (TDD green phase)."
3
+ ---
4
+
5
+ # Core — Make Tests Pass
6
+
7
+ **Role:** Core Developer
8
+ **Goal:** Implement the minimum code to make all failing tests pass.
9
+
10
+ ## Instructions
11
+
12
+ 1. Read the failing tests from the Red phase
13
+ 2. Implement the code needed to make them pass:
14
+ - Service layer functions
15
+ - API route handlers
16
+ - Validation schemas
17
+ - Business logic
18
+ 3. Follow the Blueprint's Architecture section for structure
19
+ 4. Match existing codebase patterns found during Investigate
20
+ 5. Run tests after each major piece — watch them go green one by one
21
+
22
+ ## Output (append to state.md)
23
+
24
+ ```markdown
25
+ ### Build: Core
26
+
27
+ **Files Changed:**
28
+ - `<path>` — <what was implemented>
29
+
30
+ **Functions Implemented:**
31
+ - `<name>` in `<file>` — <purpose>
32
+
33
+ **Test Status:**
34
+ - Previously failing: <N>
35
+ - Now passing: <M>
36
+ - Still failing: <K> (explain why if > 0)
37
+
38
+ **Notes:**
39
+ - <any deviations from Blueprint — also record in the `## Deviations` section of state.md>
40
+ ```
41
+
42
+ ## Rules
43
+
44
+ - Write the **minimum** code to pass tests — no gold-plating
45
+ - Don't refactor yet — that's the Refactor sub-stage
46
+ - Don't build UI yet — that's the UI sub-stage
47
+ - If a test expectation seems wrong, fix the test only if the Blueprint supports it
48
+ - Match existing code patterns exactly — naming, file structure, error handling
@@ -0,0 +1,44 @@
1
+ ---
2
+ description: "Build sub-stage: Wire everything together, verify full data flow end-to-end."
3
+ ---
4
+
5
+ # Integration
6
+
7
+ **Role:** Integration Engineer
8
+ **Goal:** Verify the full data flow works end-to-end: UI → API → Service → DB → Response → UI.
9
+
10
+ ## Instructions
11
+
12
+ 1. Trace every code path from user action to database and back
13
+ 2. Verify data flows correctly at each boundary:
14
+ - UI sends correct request to API
15
+ - API validates and calls correct service function
16
+ - Service performs correct DB operations
17
+ - Response flows back through each layer correctly
18
+ 3. Fix any wiring issues (wrong imports, missing props, incorrect types)
19
+ 4. Run the full test suite to confirm nothing broke
20
+ 5. Manually test key flows if possible (dev server)
21
+
22
+ ## Output (append to state.md)
23
+
24
+ ```markdown
25
+ ### Build: Integration
26
+
27
+ **Integration Points Verified:**
28
+ - <flow description>: working | fixed (<what was wrong>)
29
+
30
+ **Issues Fixed:**
31
+ - <issue and fix — or "None">
32
+
33
+ **Full Test Suite:** passing | failing (<details>)
34
+
35
+ **Notes:**
36
+ - <anything discovered during integration>
37
+ ```
38
+
39
+ ## Rules
40
+
41
+ - This is verification, not new development — if you're writing significant new code, something was missed earlier
42
+ - Check TypeScript types across boundaries — mismatches here cause runtime bugs
43
+ - If the dev server is available, actually navigate the flow
44
+ - Document any issues found — they indicate gaps in the Blueprint for future reference
@@ -0,0 +1,41 @@
1
+ ---
2
+ description: "Build sub-stage: Generate and verify database schema changes."
3
+ ---
4
+
5
+ # Migration
6
+
7
+ **Role:** Database Engineer
8
+ **Goal:** Apply schema changes from the Architecture plan.
9
+
10
+ ## Instructions
11
+
12
+ 1. Check the Blueprint/Architecture for data model changes
13
+ 2. If no DB changes needed, output `has_migration: false` and move on
14
+ 3. Otherwise:
15
+ - Update the schema definition files per your project's ORM
16
+ - Generate the migration
17
+ - Run the migration
18
+ - **Verify** the migration actually applied by checking the database directly
19
+ 4. Verify the application still connects to the DB and existing features work
20
+
21
+ ## Output (append to state.md)
22
+
23
+ ```markdown
24
+ ### Build: Migration
25
+
26
+ **Has Migration:** true/false
27
+ **Migration File:** <path>
28
+ **Changes:**
29
+ - <table.column: type — added/modified/removed>
30
+
31
+ **Verification:**
32
+ - Schema check: <pass/fail>
33
+ - App connection: <pass/fail>
34
+ ```
35
+
36
+ ## Rules
37
+
38
+ - Always verify migrations applied — don't trust "success" output alone
39
+ - Use `IF NOT EXISTS` / `IF EXISTS` guards where appropriate
40
+ - If the project uses Drizzle: run `pnpm db:generate` then `pnpm db:migrate`, then verify with psql
41
+ - If migration fails, diagnose and fix before proceeding — don't skip
@@ -0,0 +1,44 @@
1
+ ---
2
+ description: "Build sub-stage: Write failing tests BEFORE implementation (TDD red phase)."
3
+ ---
4
+
5
+ # Red — Write Failing Tests
6
+
7
+ **Role:** Test Author
8
+ **Goal:** Define expected behavior through tests that don't pass yet.
9
+
10
+ ## Instructions
11
+
12
+ 1. Read the Blueprint's test expectations for each layer
13
+ 2. Write tests that describe the expected behavior:
14
+ - Service/business logic tests
15
+ - API endpoint tests (request → expected response)
16
+ - Component tests (render → expected output/behavior)
17
+ 3. Run the tests — **all new tests must fail** (that's the point)
18
+ 4. If any test accidentally passes, you're testing something that already exists — remove or adjust it
19
+
20
+ ## Output (append to state.md)
21
+
22
+ ```markdown
23
+ ### Build: Red (Failing Tests)
24
+
25
+ **Tests Written:**
26
+ - `<test file>`: <what it tests>
27
+ - <test case 1> — FAIL (expected)
28
+ - <test case 2> — FAIL (expected)
29
+
30
+ **Test Output:**
31
+ <summary of test run — X tests, Y failing, Z passing (pre-existing)>
32
+
33
+ **Criteria Coverage:**
34
+ - "<criterion>" → tested by <test name>
35
+ ```
36
+
37
+ ## Rules
38
+
39
+ - Write tests FIRST — this is the "Red" in Red-Green-Refactor
40
+ - Tests should be specific to acceptance criteria
41
+ - Don't test implementation details — test behavior
42
+ - Existing tests must still pass — only NEW tests should fail
43
+ - Match the project's existing test patterns and frameworks
44
+ - If the project has no test framework set up, set one up as part of this step
@@ -0,0 +1,48 @@
1
+ ---
2
+ description: "Build sub-stage: Improve code quality while keeping all tests green (TDD refactor phase)."
3
+ ---
4
+
5
+ # Refactor
6
+
7
+ **Role:** Code Quality Engineer
8
+ **Goal:** Clean up implementation code while maintaining all passing tests.
9
+
10
+ ## Instructions
11
+
12
+ 1. Run full test suite — confirm everything passes before starting
13
+ 2. Review code for:
14
+ - Duplication that should be extracted
15
+ - Unclear naming
16
+ - Functions that are too long
17
+ - Missing error handling at system boundaries
18
+ - Dead code or unused imports
19
+ 3. Refactor incrementally — run tests after each change
20
+ 4. If tests break: **stop immediately**, revert the breaking change
21
+
22
+ ## Output (append to state.md)
23
+
24
+ ```markdown
25
+ ### Build: Refactor
26
+
27
+ **Refactoring Summary:**
28
+ - <what was improved and why>
29
+
30
+ **Test Status:** passing | broken
31
+
32
+ **If broken:**
33
+ - What broke: <description>
34
+ - Reverted: yes/no
35
+ ```
36
+
37
+ ## Outcome Routing
38
+
39
+ - **passing** → All tests green, proceed to Integration
40
+ - **broken** → Tests broke and couldn't recover. Loop back to Core to fix.
41
+
42
+ ## Rules
43
+
44
+ - Tests MUST be green before AND after refactoring
45
+ - Don't add new features during refactor — only improve existing code
46
+ - Don't refactor code you didn't write/modify in this feature
47
+ - If code is already clean, say so and move on — don't refactor for its own sake
48
+ - Small, incremental changes — not a big-bang rewrite
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: "Build sub-stage: Branch creation, dependency installation, scaffolding."
3
+ ---
4
+
5
+ # Setup
6
+
7
+ **Role:** Project Scaffolder
8
+ **Goal:** Prepare the workspace for implementation. No feature code yet.
9
+
10
+ ## Instructions
11
+
12
+ 1. Verify you're in the correct worktree on the feature branch
13
+ 2. Install any new dependencies specified in the Blueprint
14
+ 3. Create new files/directories that the Blueprint calls for (empty scaffolds)
15
+ 4. Update config files if the Blueprint requires it
16
+ 5. Verify the project still builds/compiles cleanly after setup
17
+
18
+ ## Output (append to state.md)
19
+
20
+ ```markdown
21
+ ### Build: Setup
22
+
23
+ **Branch:** feature/<slug> (confirmed)
24
+ **Dependencies Added:**
25
+ - <package> — <why>
26
+
27
+ **Files Created:**
28
+ - `<path>` — <scaffold for what>
29
+
30
+ **Config Changes:**
31
+ - `<file>` — <what changed>
32
+
33
+ **Build Status:** clean | issues (detail)
34
+ ```
35
+
36
+ ## Rules
37
+
38
+ - Do NOT write implementation code — just scaffolding (empty files, directory structure)
39
+ - Do NOT write tests yet — that's Red
40
+ - If the worktree already has setup from a previous loop-back, verify state and skip what's done
41
+ - If dependency installation fails, diagnose the issue — don't proceed with broken dependencies
42
+ - Run the build/compile check to ensure nothing is broken before proceeding
@@ -0,0 +1,51 @@
1
+ ---
2
+ description: "Build sub-stage: Implement UI components, pages, and interactions."
3
+ ---
4
+
5
+ # UI
6
+
7
+ **Role:** Frontend Developer
8
+ **Goal:** Build the user-facing interface per the UX Flow and Blueprint.
9
+
10
+ ## Instructions
11
+
12
+ 1. If no UI changes are needed (from UX Flow: `has_ui_changes: false`), skip this step
13
+ 2. Otherwise, implement:
14
+ - New components per Blueprint/Architecture
15
+ - Page modifications
16
+ - Forms, interactions, navigation
17
+ - Loading, error, and empty states (from UX Flow)
18
+ 3. Follow existing UI patterns from Investigate findings
19
+ 4. Wire components to the API/service layer built in Core
20
+ 5. Run any UI/component tests
21
+
22
+ ## Output (append to state.md)
23
+
24
+ ```markdown
25
+ ### Build: UI
26
+
27
+ **Components Created:**
28
+ - `<ComponentName>` in `<path>` — <purpose>
29
+
30
+ **Components Modified:**
31
+ - `<ComponentName>` in `<path>` — <what changed>
32
+
33
+ **Pages Affected:**
34
+ - `<route/path>` — <what changed>
35
+
36
+ **States Handled:**
37
+ - Loading: yes/no
38
+ - Error: yes/no
39
+ - Empty: yes/no
40
+
41
+ **Notes:**
42
+ - <deviations from UX Flow and why>
43
+ ```
44
+
45
+ ## Rules
46
+
47
+ - Match the project's existing design system / component patterns
48
+ - Every interactive element must have `cursor: pointer`
49
+ - Handle all states from UX Flow — don't skip empty/error states
50
+ - Don't introduce new UI libraries unless the Blueprint calls for it
51
+ - Accessibility basics: labels, keyboard nav, ARIA where needed
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: deploy
3
+ description: "Run the Deploy phase (optional) — 3 sub-stages: Merge, Monitor, Remediate."
4
+ user-invocable: false
5
+ allowed-tools: Bash, Read, Write, Edit, Glob, Grep
6
+ ---
7
+
8
+ You are the **Release Engineer**. Get this PR merged and deployed safely.
9
+
10
+ ## Sub-stages (in order)
11
+
12
+ 1. **Merge** — Get the PR merged safely
13
+ 2. **Monitor** — Watch for deployment issues
14
+ 3. **Remediate** — Handle deployment outcome
15
+
16
+ ## Execution
17
+
18
+ For each sub-stage:
19
+ 1. Read the sub-stage file (e.g., `.claude/skills/deploy/stages/merge.md`)
20
+ 2. Follow its instructions
21
+ 3. Update `.work-kit/state.md` with outputs
22
+ 4. Proceed to next sub-stage
23
+
24
+ ## Key Principle
25
+
26
+ **Verify before acting, monitor after acting.** Never merge without checking CI. Never walk away after merge without checking deployment.
27
+
28
+ ## Recording
29
+
30
+ Update the shared state.md sections:
31
+
32
+ - **`## Decisions`** — Record merge method choice, any rollback decisions.
33
+
34
+ ## This phase is optional
35
+
36
+ If the user says "skip deploy" or the project doesn't have CI/CD, skip this phase entirely. The feature is considered complete after Review/Handoff approval.
37
+
38
+ ## Context Input
39
+
40
+ This phase runs as a **fresh agent**. Read only these sections from `.work-kit/state.md`:
41
+ - `### Review: Final` — ship decision, concerns
42
+ - `### Build: Final` — PR URL, branch
43
+ - `## Criteria` — for final confirmation
44
+
45
+ ## Final Output
46
+
47
+ After all sub-stages are done, append a `### Deploy: Final` section to state.md. This is what **Wrap-up reads**.
48
+
49
+ ```markdown
50
+ ### Deploy: Final
51
+
52
+ **PR:** #<number>
53
+ **Merge status:** merged | fix_needed | abort
54
+ **Deploy status:** deployed | failed | not_applicable
55
+ **Final status:** success | fix_and_redeploy | rolled_back
56
+
57
+ **Summary:** <what happened>
58
+ ```
59
+
60
+ Then:
61
+ - Update state: `**Phase:** deploy (complete)`
62
+ - Commit state: `git add .work-kit/ && git commit -m "work-kit: complete deploy"`
@@ -0,0 +1,47 @@
1
+ ---
2
+ description: "Deploy sub-stage: Get the PR merged safely."
3
+ ---
4
+
5
+ # Merge
6
+
7
+ **Role:** Merge Manager
8
+ **Goal:** Get the PR merged with confidence.
9
+
10
+ ## Instructions
11
+
12
+ 1. Check CI status on the PR — all checks must pass
13
+ 2. Check for merge conflicts — resolve if any
14
+ 3. Rebase on main if the branch is behind
15
+ 4. Post a readiness summary as a PR comment:
16
+ - Tests: pass/fail
17
+ - Review: approved
18
+ - Conflicts: none/resolved
19
+ - Risk: low/medium/high
20
+ 5. **Prepare a merge readiness summary** and return it to the orchestrator for user approval — don't auto-merge
21
+ 6. Once the orchestrator confirms user approval, merge using the project's preferred method (check CONTRIBUTING.md or README for merge preferences; default to squash if unspecified)
22
+
23
+ ## Output (append to state.md)
24
+
25
+ ```markdown
26
+ ### Deploy: Merge
27
+
28
+ **PR:** #<number>
29
+ **CI Status:** passing | failing
30
+ **Conflicts:** none | resolved
31
+ **Merge Method:** squash | merge | rebase
32
+ **Result:** merged | fix_needed | abort
33
+ ```
34
+
35
+ ## Outcome Routing
36
+
37
+ - **merged** → Proceed to Monitor
38
+ - **fix_needed** → Loop back to Build/Core with the specific issue
39
+ - **abort** → Stop work. Report to user.
40
+
41
+ ## Rules
42
+
43
+ - NEVER force push to main
44
+ - NEVER merge with failing CI
45
+ - ALWAYS return to the orchestrator for user approval before merging
46
+ - If CI fails, diagnose the issue — don't just retry
47
+ - If conflicts are non-trivial, explain them to the user before resolving
@@ -0,0 +1,39 @@
1
+ ---
2
+ description: "Deploy sub-stage: Monitor deployment after merge."
3
+ ---
4
+
5
+ # Monitor
6
+
7
+ **Role:** Deployment Monitor
8
+ **Goal:** Verify the deployment succeeds and the feature works in production.
9
+
10
+ ## Instructions
11
+
12
+ 1. Check CI/CD pipeline status after merge
13
+ 2. Wait for deployment to complete (if applicable)
14
+ 3. Verify health checks pass
15
+ 4. Check for errors in logs (if accessible)
16
+ 5. Verify the feature works as expected in the deployed environment
17
+
18
+ ## Output (append to state.md)
19
+
20
+ ```markdown
21
+ ### Deploy: Monitor
22
+
23
+ **Deploy Status:** deployed | pending | failed | not_applicable
24
+ **Pipeline:** <url or "no CI/CD">
25
+ **Health Checks:** passing | failing | not_applicable
26
+ **Notes:**
27
+ - <observations>
28
+ ```
29
+
30
+ ## Outcome Routing
31
+
32
+ - **deployed** → Proceed to Remediate (success path)
33
+ - **failed** → Proceed to Remediate (failure path)
34
+
35
+ ## Rules
36
+
37
+ - If the project has no CI/CD, mark as `not_applicable` and move on
38
+ - Don't wait indefinitely — if deployment takes more than a few minutes, note it and move on
39
+ - If you can't access production logs/monitoring, say so
@@ -0,0 +1,54 @@
1
+ ---
2
+ description: "Deploy sub-stage: Handle deployment outcome — confirm success or manage failure."
3
+ ---
4
+
5
+ # Remediate
6
+
7
+ **Role:** Incident Responder
8
+ **Goal:** Confirm successful deployment or manage failure.
9
+
10
+ ## Instructions
11
+
12
+ ### If deployment succeeded:
13
+ 1. Confirm the feature is healthy
14
+ 2. Output `final_status: success`
15
+ 3. Done — the feature is shipped
16
+
17
+ ### If deployment failed:
18
+ 1. Analyze the failure:
19
+ - Build failure? Test failure? Runtime error? Config issue?
20
+ 2. Recommend action:
21
+ - **fix_and_redeploy**: Issue is small and fixable → loop back to Build/Core
22
+ - **rolled_back**: Issue is serious → revert the merge, explain to user
23
+
24
+ ## Output (append to state.md)
25
+
26
+ ```markdown
27
+ ### Deploy: Remediate
28
+
29
+ **Final Status:** success | fix_and_redeploy | rolled_back
30
+ **Failure Category:** build | test | deploy | runtime | config | none
31
+ **Summary:**
32
+ - <what happened>
33
+
34
+ **If fix_and_redeploy:**
35
+ - Issue: <what needs to be fixed>
36
+ - Plan: <how to fix>
37
+
38
+ **If rolled_back:**
39
+ - Reason: <why rollback was necessary>
40
+ - Revert: <commit hash or PR>
41
+ ```
42
+
43
+ ## Outcome Routing
44
+
45
+ - **success** → Work is complete. Orchestrator writes work-kit log.
46
+ - **fix_and_redeploy** → Loop back to Build/Core with the fix context
47
+ - **rolled_back** → Work is stopped. Report to user.
48
+
49
+ ## Rules
50
+
51
+ - Don't panic on failure — diagnose first
52
+ - Prefer fix-forward over rollback for small issues
53
+ - Rollback is the right call for data corruption, security issues, or widespread breakage
54
+ - Always explain to the user what happened and why