Skip to content

Thread TStateName through platform + rewrite consumer CLI#10

Merged
NTCoding merged 4 commits into
mainfrom
worktree-linked-wondering-ritchie
Mar 7, 2026
Merged

Thread TStateName through platform + rewrite consumer CLI#10
NTCoding merged 4 commits into
mainfrom
worktree-linked-wondering-ritchie

Conversation

@NTCoding
Copy link
Copy Markdown
Owner

@NTCoding NTCoding commented Mar 7, 2026

Summary

  • Platform: BaseWorkflowState<TStateName> generic threads strong state name types through WorkflowFactory, WorkflowEngine, and recording-ops — eliminating string from the core
  • Platform CLI module: New defineCommands/createWorkflowRunner with discriminated union CommandDefinition (handler only required on transaction type, not transition/session-start)
  • Consumer: CLI entry point rewritten from 371 → 249 lines — 16 hand-written handler functions replaced with declarative command definitions
  • Consumer types: WorkflowState.currentStateMachineState narrowed from string to StateName, event schemas validate at Zod boundary

49 files changed, +2237 −703. 100% test coverage, all 1283 tests pass.

Test plan

  • pnpm typecheck — no string where TStateName should be
  • pnpm test — 1283 tests pass, 100% coverage (statements, branches, functions, lines)
  • pnpm lint — clean
  • pnpm deps — no dependency rule violations
  • pnpm knip — no unused exports

🤖 Generated with Claude Code

NTCoding and others added 4 commits March 7, 2026 10:47
…neCommands

Platform changes:
- BaseWorkflowState<TStateName> generic replaces string state names in core
- WorkflowFactory/WorkflowEngine thread TStateName + TOperation generics
- New CLI module: defineCommands, createWorkflowRunner, arg helpers, hook schemas
- CommandDefinition is a discriminated union — handler only on transaction type
- New recording-ops module for gate-checked workflow operations
- parseStateName on factory for edge-to-core string narrowing

Consumer changes:
- WorkflowState.currentStateMachineState narrowed to StateName
- WorkflowAdapter implements full generic factory interface
- CLI entry point rewritten from 371 to 249 lines using platform runner
- 16 handler functions replaced with declarative command definitions
- Event schemas validate StateName at Zod boundary
- All test fixtures updated with strong StateName types

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…te fixtures

Decompose the 240-line entry point into focused modules:
- Rename autonomous-claude-agent-team-workflow.ts → entrypoint.ts
- Extract hook handling → src/hook-routes.ts (uses platform Zod schemas)
- Extract analytics/view-report → src/analytics/cli-routes.ts
- Remove consumer parse functions from hook-io.ts (replaced by platform schemas)
- Consolidate duplicated test fixtures across 3 spec files into shared imports
- Entry point now ~80 lines with 4 clear routing paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…th defineCommands

Platform changes:
- Add preToolUseHandler to WorkflowRunnerConfig for engine-level PreToolUse hooks
- Add RunnerOptions with getSessionId injection (removes session-id from route args)
- Move formatDenyDecision/formatContextInjection to platform hook-output module
- Add PlatformContext type for createWorkflowCli dep assembly

Consumer changes:
- Extract PreToolUse logic into pre-tool-use-handler.ts
- Replace 5 hand-written recording methods with defineRecordingOps + executeRecording
- Replace ad-hoc narrowing with Zod-based parseNumber/parseString/parseStringArray
- Delete hook-routes.ts, composition-root.ts, hook-io.ts (replaced by platform)
- Relocate all entrypoint files to src/workflow-definition/entrypoint/
- Shorten verbose spec/fixture filenames

Net -1382 lines. All 1326 tests pass, 100% coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move git, github, linter, arg-parsing, workflow-error to workflow-definition/infra/
- Move analytics CLI routes to workflow-analysis/entrypoint/
- Create src/shell.ts as process boundary and top-level router
- Delete src/infra/ entirely (environment + stdin absorbed into shell, state-store deleted as dead code)
- Decouple workflow-definition from workflow-analysis (shell.ts routes between them)
- Export WorkflowError from workflow-definition barrel for cross-module use
- Update depcruiser rules for new module structure
- hooks.json now points to src/shell.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@NTCoding NTCoding merged commit 44c38cf into main Mar 7, 2026
3 checks passed
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