Skip to content

1.3 Implement the command registry #4

Description

@goofmint

Part of Phase 1 — Core skeleton (tasks.md Task 1.3).

Summary

Implement core/commands/registry.ts: the command bus every behavior in tecode goes through.

Details

  • register(id, handler, meta?) returns a Disposable; re-registering an existing ID replaces the handler (last-wins) and logs a warning.
  • execute(id, ...args) is async and never throws: unknown ID and handler exceptions become HostErrors routed to a status sink (stub interface for now; the statusbar extension consumes it later). Returns undefined on failure, the handler's return value on success.
  • list() returns { id, title, category, when }[] for the palette; no when-filtering here (callers filter).
  • Command IDs follow namespace.verb; meta supports title, category, when.

Completion requirements

  • Unknown-ID execute surfaces Command not found: <id> via the status sink and does not throw
  • A throwing handler is caught, logged to the host log, surfaced via the sink; execute resolves undefined
  • Disposing a registration removes the command; double-dispose is a no-op
  • Re-registration replaces last-wins with a logged warning
  • Unit tests cover: unknown ID, throwing handler, dispose semantics, list() metadata
  • bun test and lint pass

References

  • requirements.md: Req 3.1–3.5
  • design.md: §5

Dependencies

Blocked by: 1.2 (#3). Parallelizable with 1.4–1.10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions