Commit e40ffed
Build user story generator from brief descriptions (#91)
* Add User Story built-in template
- Add 'user-story' template with title, description, tasks, acceptance criteria, and time estimate
- Include template metadata in picker with description
- Add User Stories category with 📝 icon for organization
- Support auto-categorization with 'user-story' and 'story' keywords
- Template includes placeholders for {filename}, {date}, and {user}
* Add AI-enhanced user story creation command
- Add 'noted.createUserStoryWithAI' command to create user stories from brief descriptions
- Uses VS Code LLM API (GitHub Copilot) to analyze description and populate:
- Story title
- User story format (As a... I want... So that...)
- 3-5 actionable tasks as checklist
- 3-5 testable acceptance criteria
- Realistic time estimate
- Creates note in User Stories folder with YAML frontmatter
- Supports fallback when AI is unavailable
- Register command in extension.ts and package.json
- Icon: $(notebook) for command palette
* Fix user story creation and add to templates picker
Issue 1 - Fix workspace folder error:
- Use getNotesPath() from configService instead of workspace folders
- Support absolute path configurations for notes folder
- Add getNotesPath import to templateCommands.ts
- Provide clearer error message when notes folder not configured
Issue 2 - Add AI User Story to templates picker:
- Add "$(sparkle) User Story with AI" option at top of template picker
- Shows as "AI-Enhanced" category in picker UI
- Accessible via Cmd+K Cmd+N template selection flow
- Special value '__ai_user_story__' triggers handleCreateUserStoryWithAI()
- Also added regular "User Story" template to built-in list
* Default AI model selection to latest Claude Sonnet
Update model selection priority in both TemplateGenerator and user story creation:
Priority hierarchy:
1. Claude Sonnet (latest version) - best for structured JSON output
2. Claude Opus - most capable
3. Other Claude models
4. Direct Anthropic vendor
5. GPT-4 models
6. Other GPT models
7. Gemini models
8. First available model
Key improvements:
- Filters for all Sonnet models and sorts by ID to get latest (e.g., sonnet-4-5)
- Case-insensitive matching for model family/ID
- Checks both 'copilot' and 'anthropic' vendors for Claude models
- Maintains user preference override at top of hierarchy
- Provides clear fallback chain for reliability
Applies to:
- User story AI generation (templateCommands.ts)
- Template creation with AI (TemplateGenerator.ts)
* Add User Story templates to Templates panel
Add both manual and AI-enhanced User Story options to the Standard Templates section:
Standard Templates section now includes:
- Problem/Solution
- Meeting
- Research
- User Story (manual template)
- ✨ User Story with AI (AI-powered generation)
- Quick Note
Changes:
- Add 'user-story' to STANDARD_TEMPLATES array
- Insert AI-enhanced option after regular User Story template
- AI option uses sparkle icon (✨) to distinguish it visually
- Both options now appear in the collapsible "Standard Templates" section of the Templates panel
User can now access user story creation from three places:
1. Templates panel > Standard Templates
2. Command Palette (Cmd+K Cmd+N)
3. Direct command palette search for "Create User Story with AI"
* Fix CI/CD and implement code review improvements
CI/CD Fix:
- Fix TypeScript compilation error in templatesTreeProvider.ts
- Explicitly type items array as TreeItem[] to allow mixing TemplateActionItem and ActionButtonItem
- Resolves: error TS2345 "Property 'templateType' is missing in type 'ActionButtonItem'"
Code Review Improvements:
1. Cancellation Support:
- Add cancellable: true to withProgress in handleCreateUserStoryWithAI
- Use token from progress callback instead of creating new CancellationTokenSource
- Check token.isCancellationRequested during response streaming
- Add early return if cancelled to prevent partial operations
2. ES6 Import Refactoring:
- Replace require('os') with top-level import * as os from 'os'
- Change require('os').userInfo().username to os.userInfo().username
- Improves code readability and enables static analysis
3. DRY Principle - Shared AI Model Service:
- Create new src/services/aiModelService.ts with shared selectAIModel()
- Remove duplicate selectModel() from TemplateGenerator.ts (84 lines)
- Remove duplicate selectAIModel() from templateCommands.ts (75 lines)
- Both files now import and use shared selectAIModel()
- Single source of truth for AI model selection logic
- Prioritizes Claude Sonnet (latest) > Opus > other Claude > GPT-4 > GPT > Gemini
Benefits:
- Easier to maintain model selection logic in one place
- Consistent behavior across all AI features
- Reduced code duplication by ~160 lines
- Future AI features can reuse the same selection logic
---------
Co-authored-by: Claude <[email protected]>1 parent d0a5d68 commit e40ffed
File tree
7 files changed
+458
-59
lines changed- src
- commands
- providers
- services
- templates
7 files changed
+458
-59
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
740 | 742 | | |
741 | 743 | | |
742 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
51 | 81 | | |
52 | 82 | | |
53 | 83 | | |
| |||
57 | 87 | | |
58 | 88 | | |
59 | 89 | | |
| 90 | + | |
60 | 91 | | |
61 | 92 | | |
62 | 93 | | |
| |||
131 | 162 | | |
132 | 163 | | |
133 | 164 | | |
134 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
135 | 168 | | |
136 | 169 | | |
137 | 170 | | |
| |||
206 | 239 | | |
207 | 240 | | |
208 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
209 | 248 | | |
210 | 249 | | |
211 | 250 | | |
| |||
0 commit comments