2.8 KiB
2.8 KiB
id, title, status, wave, depends_on, plan, spec, adr
| id | title | status | wave | depends_on | plan | spec | adr | |
|---|---|---|---|---|---|---|---|---|
| 03-sdk-data-accessors | SDK Go-native data DTOs, Host interface, and author accessors | done | 2 |
|
plan.md | ../../../specs/plugins/requirements/plugins.md | ../../../decisions/0043-plugin-host-data-api.md |
Task 03: SDK Go-native data DTOs, Host interface, and author accessors
Extend pkg/pluginsdk so authors read kandev data through Go-native typed structs
— proto types never leak past the package boundary, matching the existing
state/secrets pattern in host.go/types.go.
Scope
- Go-native DTOs in
types.gomirroring the proto:Task,TaskRepository,Session,SessionCodeStats,Workspace,Workflow,WorkflowStep,AgentProfile,Repository, plusPage/PageInfo/filter structs, each withtoProto/fromProtohelpers alongside the existing ones. - Host interface extension (
host.go): add data read methods. Prefer grouping behind sub-accessors exposed from theHostinterface —host.Tasks(),host.Sessions(),host.Workspaces(),host.Workflows(),host.AgentProfiles(),host.Repositories()— each returning a small typed accessor (e.g.TasksAPI.List(ctx, filter, page),TasksAPI.Get(ctx, id),SessionsAPI.List(...),SessionsAPI.CodeStats(...)). The task and message accessors also expose the implemented write methods, includingTasks().Create,Tasks().Update,Tasks().Move, andMessages().Send. - Client + server conversions:
grpcHostClient(plugin side) calls the generated data RPCs and converts responses to Go-native;grpcHostServer(kandev side) dispatches to the Go-native interface. Follow the existingGetState/ListStateconversion shape exactly. - Keep the existing
Hoststate/secrets/emit methods intact.
Acceptance
- Author can call
host.Sessions().List(ctx, filter, page)andhost.Sessions().CodeStats(ctx, filter, page)(etc.) receiving Go-native structs; proto types are not exposed. grpcHostServersatisfies the generated server interface for the new RPCs;grpcHostClientsatisfies the extendedHostinterface.- Round-trip conversion unit tests pass.
Verification
cd apps/backend && go test ./pkg/pluginsdk/...cd apps/backend && go build ./...
Files likely touched
apps/backend/pkg/pluginsdk/types.goapps/backend/pkg/pluginsdk/host.goapps/backend/pkg/pluginsdk/*_test.go
Inputs
- Generated stubs from task-01.
- Existing pattern:
pkg/pluginsdk/host.go(grpcHostClient/grpcHostServer),types.go(toProto/fromProto,mapToStruct/structToMap). - Spec: "Host data API" resource/capability table.
Dependencies
Task 01 (needs regenerated proto stubs).
Output contract
Summary, the accessor shape chosen (sub-accessors vs flat methods), files changed,
test result, and status update here + in plan.md.