Implements deterministic feature lifecycle management for agent-driven
development. Agents use the CLI in pods; operators control via REST API.
Library (internal/sdlc/):
- Feature lifecycle with 10 phases (draft → released)
- Classifier engine with priority-ordered rules
- Artifact tracking with approval workflow
- Task management within features
- YAML-based state persistence
CLI (cmd/sdlc/):
- init, state, next, feature, artifact, task, query commands
- --json flag for machine-readable output
- Runs inside project pods
API (21 endpoints under /projects/{id}/sdlc/):
- State: GET /state, GET /next
- Features: CRUD + transition/block/unblock
- Artifacts: approve/reject per type
- Tasks: add/start/complete/block
- Queries: blocked/ready/needs-approval
Architecture:
- Port: SDLCExecutor interface (internal/port/)
- Adapter: kubectl exec into pods (internal/adapter/kubernetes/)
- Service: pod resolution + logging (internal/service/)
- Handlers: 5 files under 500-line limit (internal/handlers/)
Also includes template upgrades (chassis framework, UI components,
OpenAPI helpers, backend/frontend guides) and component improvements.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
196 lines
4.1 KiB
Go
196 lines
4.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/orchard9/rdev/internal/sdlc"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var artifactCmd = &cobra.Command{
|
|
Use: "artifact",
|
|
Short: "Manage feature artifacts",
|
|
}
|
|
|
|
var artifactCreateCmd = &cobra.Command{
|
|
Use: "create <feature> <type>",
|
|
Short: "Create an artifact file (sets status to draft)",
|
|
Args: cobra.ExactArgs(2),
|
|
RunE: func(_ *cobra.Command, args []string) error {
|
|
root := mustResolveRoot()
|
|
slug, artTypeStr := args[0], args[1]
|
|
|
|
artType := sdlc.ArtifactType(artTypeStr)
|
|
if !sdlc.IsValidArtifactType(artType) {
|
|
return fmt.Errorf("invalid artifact type: %s (valid: spec, design, tasks, qa_plan, review, audit, qa_results)", artTypeStr)
|
|
}
|
|
|
|
f, err := sdlc.LoadFeature(root, slug)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Create the artifact file if it doesn't exist
|
|
path := sdlc.ArtifactPath(root, slug, artType)
|
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
|
if err := os.WriteFile(path, fmt.Appendf(nil, "# %s: %s\n\n", artType, f.Title), 0o644); err != nil {
|
|
return fmt.Errorf("create artifact file: %w", err)
|
|
}
|
|
}
|
|
|
|
// Update manifest
|
|
art := f.GetArtifact(artType)
|
|
if art == nil {
|
|
art = sdlc.NewArtifact(artType)
|
|
f.SetArtifact(artType, art)
|
|
}
|
|
art.MarkDraft()
|
|
|
|
if err := f.Save(root); err != nil {
|
|
return err
|
|
}
|
|
|
|
if jsonOutput {
|
|
printJSON(map[string]string{
|
|
"feature": slug,
|
|
"artifact": string(artType),
|
|
"status": string(art.Status),
|
|
"path": path,
|
|
})
|
|
return nil
|
|
}
|
|
|
|
fmt.Printf("Created artifact: %s/%s\n", slug, artType)
|
|
fmt.Printf(" Status: %s\n", art.Status)
|
|
fmt.Printf(" Path: %s\n", path)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
var artifactApproveCmd = &cobra.Command{
|
|
Use: "approve <feature> <type>",
|
|
Short: "Approve an artifact",
|
|
Args: cobra.ExactArgs(2),
|
|
RunE: func(_ *cobra.Command, args []string) error {
|
|
root := mustResolveRoot()
|
|
slug, artTypeStr := args[0], args[1]
|
|
artType := sdlc.ArtifactType(artTypeStr)
|
|
|
|
f, err := sdlc.LoadFeature(root, slug)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
art := f.GetArtifact(artType)
|
|
if art == nil {
|
|
return sdlc.ErrArtifactNotFound
|
|
}
|
|
|
|
art.Approve("user")
|
|
if err := f.Save(root); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Record in state
|
|
state, err := sdlc.LoadState(root)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
state.RecordAction("APPROVE_ARTIFACT", slug, "user")
|
|
if err := state.Save(root); err != nil {
|
|
return err
|
|
}
|
|
|
|
if jsonOutput {
|
|
printJSON(map[string]string{
|
|
"feature": slug,
|
|
"artifact": string(artType),
|
|
"status": "approved",
|
|
})
|
|
return nil
|
|
}
|
|
|
|
fmt.Printf("Approved: %s/%s\n", slug, artType)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
var artifactRejectCmd = &cobra.Command{
|
|
Use: "reject <feature> <type>",
|
|
Short: "Reject an artifact",
|
|
Args: cobra.ExactArgs(2),
|
|
RunE: func(_ *cobra.Command, args []string) error {
|
|
root := mustResolveRoot()
|
|
slug, artTypeStr := args[0], args[1]
|
|
artType := sdlc.ArtifactType(artTypeStr)
|
|
|
|
f, err := sdlc.LoadFeature(root, slug)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
art := f.GetArtifact(artType)
|
|
if art == nil {
|
|
return sdlc.ErrArtifactNotFound
|
|
}
|
|
|
|
art.Reject("user")
|
|
if err := f.Save(root); err != nil {
|
|
return err
|
|
}
|
|
|
|
if jsonOutput {
|
|
printJSON(map[string]string{
|
|
"feature": slug,
|
|
"artifact": string(artType),
|
|
"status": "rejected",
|
|
})
|
|
return nil
|
|
}
|
|
|
|
fmt.Printf("Rejected: %s/%s\n", slug, artType)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
var artifactStatusCmd = &cobra.Command{
|
|
Use: "status <feature>",
|
|
Short: "Show all artifact statuses for a feature",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(_ *cobra.Command, args []string) error {
|
|
root := mustResolveRoot()
|
|
|
|
f, err := sdlc.LoadFeature(root, args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if jsonOutput {
|
|
printJSON(f.Artifacts)
|
|
return nil
|
|
}
|
|
|
|
fmt.Printf("Artifacts for %s:\n", f.Slug)
|
|
for _, at := range sdlc.ValidArtifactTypes {
|
|
art := f.GetArtifact(at)
|
|
if art == nil {
|
|
fmt.Printf(" %-12s -\n", at)
|
|
continue
|
|
}
|
|
fmt.Printf(" %-12s %s\n", at, art.Status)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
artifactCmd.AddCommand(
|
|
artifactCreateCmd,
|
|
artifactApproveCmd,
|
|
artifactRejectCmd,
|
|
artifactStatusCmd,
|
|
)
|
|
rootCmd.AddCommand(artifactCmd)
|
|
}
|