Skip to content

refactor: extract KapiService authored artifact metadata helpers #136

@devkade

Description

@devkade

Summary

Child slice of #128. Keep KapiService.buildWorkflowPrompt as the shared renderer wrapper, then extract the remaining service-local authored artifact metadata/header sync helpers if they are still orchestration noise.

Evidence

Current PR branch evidence:

  • src/application/kapi-service.ts is still 1357 lines with 106 methods/helpers and 52 lines over 180 chars.
  • buildWorkflowPrompt correctly delegates to renderRunContractPrompt; no prompt rewrite is needed after refactor: consolidate Track A RunContract formatting #132.
  • The authored artifact metadata/header helpers remain at service top level:
    • AUTHORED_METADATA_ARTIFACTS
    • authoredArtifactMetadataHeader
    • syncAuthoredArtifactMetadata
    • normalizeDecisionReportOrder
  • These helpers are formatting/sync policy, not core service orchestration.

Scope

  • Extract authored artifact metadata/header sync into a small application helper module.
  • Keep KapiService as workflow orchestration, not artifact text-format owner.
  • Add or preserve tests for context/interview/decision-report header synchronization and decision-report ordering.

Non-goals

  • Do not split all of KapiService in this slice.
  • Do not change artifact names, storage layout, or .kapi compatibility.
  • Do not change Deep Interview or Autoresearch behavior except through preserved helper movement.

Acceptance criteria

  • KapiService delegates authored artifact header generation/sync to an extracted helper.
  • Existing artifact sync behavior remains backward-compatible.
  • Tests cover metadata header sync and decision-report ordering after extraction.
  • npm run check, npm run check:unused, and relevant service tests pass.

Suggested verification

npm test -- test/workflow-service.test.ts test/artifact-*.test.ts
npm run check
npm run check:unused
npm run quality:budgets

Part of #128.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions