diff --git a/.issues/.counter b/.issues/.counter index 60d3b2f..3c03207 100644 --- a/.issues/.counter +++ b/.issues/.counter @@ -1 +1 @@ -15 +18 diff --git a/.issues/closed/015-make-template-work.md b/.issues/closed/015-make-template-work.md new file mode 100644 index 0000000..221348a --- /dev/null +++ b/.issues/closed/015-make-template-work.md @@ -0,0 +1,46 @@ +--- +id: "015" +assignee: "" +labels: [] +created: 2025-11-24T11:30:27.643813+09:00 +updated: 2025-11-24T12:14:28.9905+09:00 +--- + +# Make template work + +## Description + +The `gi create` command is not using the `.issues/template.md` file when creating new issues. New issues are created with minimal content instead of the structured template that includes Description, Requirements, and Success Criteria sections. + +## Current Behavior + +When running `gi create`, new issues are created with only: +- YAML frontmatter (id, assignee, labels, created, updated) +- A simple title heading +- Empty content + +## Expected Behavior + +New issues should be created based on `.issues/template.md`, which includes: +- YAML frontmatter (with appropriate fields populated) +- Title heading +- Description section with placeholder text +- Requirements section with example bullet points +- Success Criteria section with checkboxes + +## Steps to Reproduce + +1. Run `gi create` and enter an issue title +2. Open the newly created issue file +3. Observe that the file does not contain the template sections + +## Impact + +Users must manually add common sections (Description, Requirements, Success Criteria) to each new issue, reducing productivity and consistency across issues. + +## Success Criteria + +- [ ] `gi create` command reads `.issues/template.md` when creating new issues +- [ ] Template sections (Description, Requirements, Success Criteria) appear in new issues +- [ ] YAML frontmatter fields are properly populated (id, timestamps, etc.) +- [ ] Title from user input replaces "Issue Title" placeholder in template diff --git a/.issues/closed/016-test-template-functionality.md b/.issues/closed/016-test-template-functionality.md new file mode 100644 index 0000000..74bf8b5 --- /dev/null +++ b/.issues/closed/016-test-template-functionality.md @@ -0,0 +1,23 @@ +--- +id: "016" +assignee: "" +labels: [] +created: 2025-11-24T11:40:26.980336+09:00 +updated: 2025-11-24T11:40:41.888813+09:00 +--- + +# Test template functionality + +## Description + +Describe the issue here... + +## Requirements + +- Requirement 1 +- Requirement 2 + +## Success Criteria + +- [ ] Criterion 1 +- [ ] Criterion 2 diff --git a/.issues/closed/017-sample-issue-to-show-template.md b/.issues/closed/017-sample-issue-to-show-template.md new file mode 100644 index 0000000..1be9516 --- /dev/null +++ b/.issues/closed/017-sample-issue-to-show-template.md @@ -0,0 +1,24 @@ +--- +id: "017" +assignee: user1 +labels: + - feature +created: 2025-11-24T12:14:42.020428+09:00 +updated: 2025-11-24T12:14:51.635438+09:00 +--- + +# Sample issue to show template + +## Description + +Describe the issue here... + +## Requirements + +- Requirement 1 +- Requirement 2 + +## Success Criteria + +- [ ] Criterion 1 +- [ ] Criterion 2 diff --git a/pkg/storage.go b/pkg/storage.go index 2fdcde7..b881a3c 100644 --- a/pkg/storage.go +++ b/pkg/storage.go @@ -326,9 +326,52 @@ func GetClosedPath() string { return filepath.Join(IssuesDir, ClosedDir) } +// LoadTemplateBody reads the template file and extracts the body content (after title heading) +func LoadTemplateBody() string { + templatePath := filepath.Join(IssuesDir, TemplateFile) + + // Read template file + data, err := os.ReadFile(templatePath) + if err != nil { + // If template doesn't exist, return empty body + return "" + } + + // Parse the template to extract body + content := string(data) + parts := strings.SplitN(content, "---", 3) + if len(parts) < 3 { + // Invalid template format, return empty + return "" + } + + // Get everything after frontmatter + body := strings.TrimSpace(parts[2]) + + // Skip the title line (first # heading) and get everything after + lines := strings.Split(body, "\n") + for i, line := range lines { + line = strings.TrimSpace(line) + if strings.HasPrefix(line, "# ") { + // Return everything after the title line + if i+1 < len(lines) { + return strings.TrimSpace(strings.Join(lines[i+1:], "\n")) + } + return "" + } + } + + // If no title found, return the whole body + return body +} + // NewIssue creates a new Issue with default values func NewIssue(id int, title, assignee string, labels []string) *Issue { now := time.Now() + + // Load template body + templateBody := LoadTemplateBody() + return &Issue{ ID: FormatID(id), Assignee: assignee, @@ -336,6 +379,6 @@ func NewIssue(id int, title, assignee string, labels []string) *Issue { Created: now, Updated: now, Title: title, - Body: "", + Body: templateBody, } }