feat: add docs checker for ADRs and implementation plans (#1)
Add cmd/docs, the first corestack component: `docs new adr|plan "Title"` writes records from embedded templates, and `docs check` validates them against the public format spec in docs/docs-format.md (timestamp IDs, frontmatter keys and enums, separate decision and implementation status, supersession symmetry, MADR 4 layout with required Consequences, plan sections, and repo-root/durable references), reporting path:line errors. Also adds the module skeleton (go.auvem.com/corestack, BSD-3-Clause, README, AGENTS.md, CLAUDE.md), Gitea CI running tests and docs check, a tag-triggered goreleaser release for darwin/linux binaries, and the accepted ADR adopting the format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit was merged in pull request #1.
This commit is contained in:
1 parent
37b0516fd2
commit
cc482d9a9b
27 files changed
+2464
No files matched your search
@@ -0,0 +1,66 @@
|
||||
// Command docs creates and checks ADR and plan records. See docs/docs-format.md.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"go.auvem.com/corestack/internal/docs"
|
||||
)
|
||||
|
||||
const usage = `usage:
|
||||
docs new adr|plan "Title"
|
||||
docs check [--root DIR]
|
||||
`
|
||||
|
||||
func main() { os.Exit(run(os.Args[1:], os.Stdout, os.Stderr, time.Now())) }
|
||||
|
||||
// run returns the exit status: 0 success, 1 problems or failure, 2 usage error.
|
||||
func run(args []string, stdout, stderr io.Writer, now time.Time) int {
|
||||
if len(args) == 0 {
|
||||
fmt.Fprint(stderr, usage)
|
||||
return 2
|
||||
}
|
||||
switch args[0] {
|
||||
case "new":
|
||||
if len(args) != 3 || (args[1] != "adr" && args[1] != "plan") {
|
||||
fmt.Fprint(stderr, usage)
|
||||
return 2
|
||||
}
|
||||
path, err := docs.New(".", args[1], args[2], now)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "docs: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintln(stdout, path)
|
||||
return 0
|
||||
case "check":
|
||||
fs := flag.NewFlagSet("docs check", flag.ContinueOnError)
|
||||
fs.SetOutput(stderr)
|
||||
root := fs.String("root", ".", "repository root")
|
||||
if err := fs.Parse(args[1:]); err != nil || fs.NArg() != 0 {
|
||||
if fs.NArg() != 0 {
|
||||
fmt.Fprint(stderr, usage)
|
||||
}
|
||||
return 2
|
||||
}
|
||||
res, err := docs.Check(*root)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "docs: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
for _, p := range res.Problems {
|
||||
fmt.Fprintln(stdout, p)
|
||||
}
|
||||
if len(res.Problems) > 0 {
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintf(stdout, "ok: %d records checked\n", res.Records)
|
||||
return 0
|
||||
}
|
||||
fmt.Fprint(stderr, usage)
|
||||
return 2
|
||||
}
|
||||
Reference in new issue
Block a user