Problem
When agent-gen or agent-gen-all.sh runs from a target project (e.g., ~/af/myproject/), it writes all artifacts — including Go role templates (.md.tmpl) — relative to the factory root. Templates need to be in the af source tree's internal/templates/roles/ directory for Go's //go:embed to compile them into the binary. Users must manually mv/cp files before running make build. This is too many steps for newcomers.
Goal
After running agent-gen, the only step a user needs is quickstart.sh — no manual file moves.
Design
Full design document and PR: #3
Design artifacts in .designs/af-5836e28c/:
- [design-doc.md] — Synthesized design with implementation plan
- [api.md] — API & interface design
- [data.md] — Data model analysis
- [ux.md] — User experience analysis
- [security.md] — Security analysis
- [integration.md] — Integration analysis
- [scale.md] — Scalability analysis
- [constraints.md] — Constraint definitions
- [constraint-audit.md] — Constraint verification
- [conflicts.md] — Conflict matrix
- [dependencies.md] — Dependency graph
- [problem-summary.md] — Problem analysis
Implementation Plan (from design-doc.md)
Phase 1: Source Root Resolution (Small)
- New file
internal/config/source_root.go with ResolveSourceRoot(), isAgentFactorySourceTree(), SetBuildSourceRoot()
- Unit tests in
internal/config/source_root_test.go
- One-line addition to
cmd/af/main.go
Phase 2: Formula.go Integration (Small)
- Update
runFormulaAgentGen() to route templates to source root
- Update
runFormulaAgentGenDelete() for cleanup
- Update output messages and existing tests
Phase 3: Script Updates (Trivial)
- Add
export AF_SOURCE_ROOT="$AF_SRC" to agent-gen-all.sh
- Verify
quickstart.sh already handles it (it does)
Acceptance Criteria
References
Problem
When
agent-genoragent-gen-all.shruns from a target project (e.g.,~/af/myproject/), it writes all artifacts — including Go role templates (.md.tmpl) — relative to the factory root. Templates need to be in the af source tree'sinternal/templates/roles/directory for Go's//go:embedto compile them into the binary. Users must manuallymv/cpfiles before runningmake build. This is too many steps for newcomers.Goal
After running
agent-gen, the only step a user needs isquickstart.sh— no manual file moves.Design
Full design document and PR: #3
Design artifacts in
.designs/af-5836e28c/:Implementation Plan (from design-doc.md)
Phase 1: Source Root Resolution (Small)
internal/config/source_root.gowithResolveSourceRoot(),isAgentFactorySourceTree(),SetBuildSourceRoot()internal/config/source_root_test.gocmd/af/main.goPhase 2: Formula.go Integration (Small)
runFormulaAgentGen()to route templates to source rootrunFormulaAgentGenDelete()for cleanupPhase 3: Script Updates (Trivial)
export AF_SOURCE_ROOT="$AF_SRC"toagent-gen-all.shquickstart.shalready handles it (it does)Acceptance Criteria
ResolveSourceRoot()returns factory root when it contains agentfactory go.modResolveSourceRoot()returnsAF_SOURCE_ROOTwhen factory root is not source treeResolveSourceRoot()returns error when neither is availableinternal/templates/roles/.agentfactory/agents/-oearly return--deleteremoves template from source rootagent-gen-all.shsetsAF_SOURCE_ROOTbefore calling agent-genquickstart.shcontinues to work unchangedmake testpassesReferences