4.1 KiB
4.1 KiB
Development Guide
This document defines contributor workflow for Scriptorium.
Repository Layout
- root package
scriptorium: public Go facade, options, types, and error mapping. cmd/scriptorium: application entrypoint.internal/domain: core contracts.internal/usecase: runner orchestration.internal/adapter/cli: CLI adapter.internal/adapter/http: HTTP adapter.internal/config: application settings loading and precedence.internal/defaults: default constants.internal/promptdef: prompt-definition repository.internal/profile: execution-profile repository.internal/profile/builtin: embedded built-in execution profiles.internal/filecatalog: shared source discovery and path helpers.internal/artifact: artifact readers.internal/prompt: prompt rendering.internal/llm: LLM client interface and OpenAI-compatible implementation.internal/validate: validation interfaces and implementation.internal/format: prepared-run formatting.docs/: canonical documentation.examples/: copyable maintained examples and fixtures.
Common Commands
Build:
go build ./cmd/scriptorium
Test:
go test ./...
Targeted test runs commonly used during changes:
go test .
go test ./internal/adapter/cli ./internal/adapter/http ./internal/usecase
go test ./internal/...
Coding Conventions
- Prefer small interfaces at package boundaries.
- Keep adapter packages focused on translation and IO concerns.
- Keep domain/use-case logic outside adapters.
- Wrap errors with operation context.
- Use strict decoding for user-provided YAML/JSON where applicable.
- Avoid introducing dependencies unless they materially reduce risk/complexity.
Dependency Policy
- Prefer standard library unless an external library is clearly justified.
- Current non-stdlib dependencies are intentionally small:
gopkg.in/yaml.v3for YAML decoding.github.com/santhosh-tekuri/jsonschema/v6for JSON Schema validation.
- Do not leak dependency-specific types across unrelated package boundaries.
How To Add App Config Fields
- Add fields in
internal/config/config.go(Config,AppSettings, and/orCLIOverridesas needed). - Apply defaults in
BuiltInDefaults()when required. - Parse and validate in
applyConfig/ApplyCLIOverrides. - Wire the field through the consuming adapter(s).
- Add/update config tests in
internal/config/config_test.go. - Update canonical docs (
docs/config.md, and other affected docs).
How To Add CLI Flags
- Add flags in
internal/adapter/cli/run.gofor the relevant command. - Ensure precedence behavior remains consistent with app config rules.
- Keep
run,render, andserveflag surfaces intentionally scoped. - Add/update parser and command tests in
internal/adapter/cli/run_test.go. - Update
docs/cli.mdand any related docs/examples.
How To Add Adapters Or Adapter Capabilities
- Define or reuse the appropriate interface boundary in domain/use-case packages.
- Implement adapter code under
internal/adapter/<name>(or relevant boundary package). - Keep business decisions in
internal/usecase. - Add focused adapter tests for mapping, parse, and error behavior.
- Document the new/changed boundary in
docs/internal/adapters.md. - If source-loading behavior changes, update
docs/internal/sources.md. - If an external contract changes, update the canonical public or integration doc in the same change.
How To Update Prompt/Profile/Schema Assets
- Keep prompt/profile/schema files valid under strict loaders.
- Keep examples secret-free.
- Re-run tests that cover prompt/profile/validation behavior.
- Update
docs/config.mdand any docs that reference changed contracts.
Documentation Update Expectations
When behavior changes:
- Update canonical doc locations, not duplicate files.
- Keep non-roadmap docs limited to implemented behavior.
- Update links after file moves/renames.
- Re-run relevant tests and smoke commands.
- For internal boundary docs, check references with
rg "docs/internal|internal/sources" docs/policy docs/internal.
Docs work is complete only when code/tests/examples/docs agree.