-
Notifications
You must be signed in to change notification settings - Fork 1
Plan 52: user-supplied archetype templates with CLI #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e77a3b7
plan 52: mark in-progress
claude a9dbec7
plan 52: add archetype template library
claude 484f199
plan 52: raise patch coverage on archetype paths
claude 5fd7d3b
plan 52: address Copilot review
claude 808350a
plan 52: rework scope to user-supplied archetypes + CLI
claude cc8b3c8
plan 52: replace embedded archetypes with user-supplied + CLI
claude 1d01cce
plan 52: raise patch coverage on archetypes paths
claude 8b5298a
plan 52: broaden e2e coverage of archetypes CLI
claude f956950
plan 52: address Copilot review
claude eef4693
plan 52: review fixes — reserved names, unified errors, fixtures
claude cf7e767
plan 52: cover loadArchetype raw-os fallback path
claude fb2f316
plan 52: reject escaping archetype-roots + doc accuracy
claude 6802276
plan 52: constrain CLI resolver to project root
claude c9afab8
fix: handle empty archetype roots and dot-root schema detection
Copilot 1efcf8c
test(cmd/mdsmith): add unit tests for all functions in main package
Copilot 8d535cc
test: clarify parallel-unsafe comment on capture helpers
Copilot 02cae35
docs(cli): add --no-follow-symlinks to check/fix table, document metr…
Copilot 39493bb
plan 52: address review — rename e2e test, add defaults to CLI flag t…
claude d6ec7ff
plan 52: tighten schema-source matching to one level deep
claude 5905a99
plan 52: reuse archetypes.DefaultRoot + surface List errors
claude 5c00f8b
plan 52: reject path-injection archetype names
claude 9efb0dc
plan 52: validate init dir, drop stale comment, close pipe read ends
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| name: 'string & != ""' | ||
| description: 'string & != ""' | ||
| "tools?": '[...string]' | ||
| --- | ||
| # ? | ||
|
|
||
| ## Purpose | ||
|
|
||
| ## Inputs | ||
|
|
||
| ## Outputs | ||
|
|
||
| ## ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Package archetypes ships built-in required-structure schemas | ||
| // for common agentic Markdown document types. | ||
| package archetypes | ||
|
|
||
| import ( | ||
| "embed" | ||
| "errors" | ||
| "fmt" | ||
| "io/fs" | ||
| "sort" | ||
| "strings" | ||
| ) | ||
|
|
||
| //go:embed *.md | ||
| var files embed.FS | ||
|
|
||
| // Lookup returns the bytes of the built-in archetype schema with the | ||
| // given name (for example "story-file"). The name is the basename | ||
| // without extension. An unknown name returns an error whose message | ||
| // lists the available archetypes; other read errors are wrapped and | ||
| // returned as-is. | ||
| func Lookup(name string) ([]byte, error) { | ||
| if name == "" { | ||
| return nil, fmt.Errorf("archetype name must not be empty") | ||
| } | ||
| data, err := files.ReadFile(name + ".md") | ||
| if err != nil { | ||
| return nil, classifyLookupError(name, err, List()) | ||
| } | ||
| return data, nil | ||
| } | ||
|
|
||
| // classifyLookupError turns a ReadFile error into a user-facing | ||
| // error. Missing entries surface as "unknown archetype" with the | ||
| // available list; other errors are wrapped verbatim. | ||
| func classifyLookupError(name string, err error, available []string) error { | ||
| if errors.Is(err, fs.ErrNotExist) { | ||
| return fmt.Errorf( | ||
| "unknown archetype %q: available: %s", | ||
| name, strings.Join(available, ", ")) | ||
| } | ||
| return fmt.Errorf("reading archetype %q: %w", name, err) | ||
| } | ||
|
|
||
| // List returns the names of all built-in archetypes, sorted. | ||
| func List() []string { | ||
| entries, _ := files.ReadDir(".") | ||
| names := make([]string, 0, len(entries)) | ||
| for _, e := range entries { | ||
| names = append(names, strings.TrimSuffix(e.Name(), ".md")) | ||
| } | ||
| sort.Strings(names) | ||
| return names | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package archetypes | ||
|
|
||
| import ( | ||
| "errors" | ||
| "io/fs" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestList_ContainsBuiltins(t *testing.T) { | ||
| names := List() | ||
| assert.Contains(t, names, "story-file") | ||
| assert.Contains(t, names, "prd") | ||
| assert.Contains(t, names, "agent-definition") | ||
| assert.Contains(t, names, "claude-md") | ||
| } | ||
|
|
||
| func TestList_Sorted(t *testing.T) { | ||
| names := List() | ||
| for i := 1; i < len(names); i++ { | ||
| assert.Less(t, names[i-1], names[i]) | ||
| } | ||
| } | ||
|
|
||
| func TestLookup_ReturnsSchemaBytes(t *testing.T) { | ||
| data, err := Lookup("story-file") | ||
| require.NoError(t, err) | ||
| assert.Contains(t, string(data), "## Background") | ||
| assert.Contains(t, string(data), "## Acceptance Criteria") | ||
| } | ||
|
|
||
| func TestLookup_EmptyName(t *testing.T) { | ||
| _, err := Lookup("") | ||
| require.Error(t, err) | ||
| } | ||
|
|
||
| func TestLookup_UnknownNameListsAvailable(t *testing.T) { | ||
| _, err := Lookup("not-real") | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "story-file") | ||
| assert.Contains(t, err.Error(), "unknown archetype") | ||
| } | ||
|
|
||
| func TestClassifyLookupError_MissingEntry(t *testing.T) { | ||
| err := classifyLookupError("foo", fs.ErrNotExist, []string{"a", "b"}) | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "unknown archetype") | ||
| assert.Contains(t, err.Error(), "a, b") | ||
| } | ||
|
|
||
| func TestClassifyLookupError_UnexpectedError(t *testing.T) { | ||
| boom := errors.New("io failure") | ||
| err := classifyLookupError("foo", boom, nil) | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "reading archetype") | ||
| assert.True(t, errors.Is(err, boom)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # ? | ||
|
|
||
| ## Project | ||
|
|
||
| ## ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| title: 'string & != ""' | ||
| "status?": '"draft" | "review" | "approved"' | ||
| "owner?": 'string & != ""' | ||
| --- | ||
| # ? | ||
|
|
||
| ## Problem | ||
|
|
||
| ## Goals | ||
|
|
||
| ## Non-Goals | ||
|
|
||
| ## Requirements | ||
|
|
||
| ## ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| as: 'string & != ""' | ||
| i-want: 'string & != ""' | ||
| so-that: 'string & != ""' | ||
| "status?": '"draft" | "in-progress" | "done"' | ||
| --- | ||
| # ? | ||
|
|
||
| ## Background | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| ## ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.