Skip to content

Commit d7743c3

Browse files
committed
added create:
1 parent 43c76d6 commit d7743c3

14 files changed

Lines changed: 1152 additions & 64 deletions

File tree

build/lumo

51 KB
Binary file not shown.

cmd/lumo/main.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func main() {
8080
hasPrefix := false
8181
for _, prefix := range []string{"lumo:", "shell:", "ask:", "ai:", "auto:", "agent:",
8282
"health:", "syshealth:", "report:", "sysreport:", "chat:", "talk:", "config:",
83-
"speed:", "speedtest:", "speed-test:", "magic:", "clipboard", "connect"} {
83+
"speed:", "speedtest:", "speed-test:", "magic:", "clipboard", "connect", "create"} {
8484
if strings.HasPrefix(command, prefix) {
8585
hasPrefix = true
8686
break
@@ -243,6 +243,27 @@ func main() {
243243
os.Exit(1)
244244
}
245245
term.Display(result)
246+
} else if strings.HasPrefix(command, "create:") || command == "create" {
247+
// Handle create commands
248+
var intent string
249+
if strings.HasPrefix(command, "create:") {
250+
intent = strings.TrimSpace(command[7:])
251+
} else {
252+
// Just "create" shows help
253+
intent = ""
254+
}
255+
cmd := &nlp.Command{
256+
Type: nlp.CommandTypeCreate,
257+
Intent: intent,
258+
Parameters: make(map[string]string),
259+
RawInput: command,
260+
}
261+
result, err := exec.Execute(cmd)
262+
if err != nil {
263+
fmt.Fprintf(os.Stderr, "Error executing command: %v\n", err)
264+
os.Exit(1)
265+
}
266+
term.Display(result)
246267
} else {
247268
processCommand(command, parser, exec, term)
248269
}

docs/examples.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@ echo "This is some text" | lumo clipboard
194194
cat file.txt | lumo clipboard append
195195
```
196196

197+
## Project Creation
198+
199+
```bash
200+
# Create a Flutter project with BLoC architecture
201+
lumo create:"Flutter app with bloc architecture"
202+
203+
# Create a Flutter project with Provider state management
204+
lumo create:"Flutter app with provider state management"
205+
206+
# Create a Flutter project with Riverpod
207+
lumo create:"Flutter app with riverpod state management"
208+
209+
# Show help for the create command
210+
lumo create
211+
```
212+
197213
## Magic Commands
198214

199215
```bash

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/agnath18/lumo
22

3-
go 1.22.2
3+
go 1.23.0
4+
5+
toolchain go1.23.9
46

57
require github.com/shirou/gopsutil/v3 v3.24.5
68

@@ -14,5 +16,6 @@ require (
1416
github.com/tklauser/go-sysconf v0.3.13 // indirect
1517
github.com/tklauser/numcpus v0.7.0 // indirect
1618
github.com/yusufpapurcu/wmi v1.2.4 // indirect
19+
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
1720
golang.org/x/sys v0.20.0 // indirect
1821
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr
4444
github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY=
4545
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
4646
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
47+
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
48+
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
4749
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4850
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4951
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

lumo

643 KB
Binary file not shown.

pkg/create/create.go

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
package create
2+
3+
import (
4+
"fmt"
5+
"regexp"
6+
"strings"
7+
8+
"github.com/agnath18/lumo/pkg/ai"
9+
)
10+
11+
// Generator handles project creation
12+
type Generator struct {
13+
aiClient ai.Client
14+
}
15+
16+
// NewGenerator creates a new project generator
17+
func NewGenerator(aiClient ai.Client) *Generator {
18+
return &Generator{
19+
aiClient: aiClient,
20+
}
21+
}
22+
23+
// Execute processes a project creation command
24+
func (g *Generator) Execute(query string) (string, error) {
25+
// If no query is provided, show help
26+
if query == "" {
27+
return g.showHelp(), nil
28+
}
29+
30+
// Parse the query to determine project type
31+
projectType, framework, options, err := g.parseQuery(query)
32+
if err != nil {
33+
return "", err
34+
}
35+
36+
// Generate the project
37+
return g.generateProject(projectType, framework, options)
38+
}
39+
40+
// parseQuery analyzes the natural language query to determine project details
41+
func (g *Generator) parseQuery(query string) (string, string, map[string]string, error) {
42+
// Create a prompt for the AI to analyze the query
43+
prompt := fmt.Sprintf(`
44+
You are a project creation assistant. Analyze the following query and extract the following information:
45+
1. Project type/framework (e.g., Flutter, React, Next.js)
46+
2. State management approach (e.g., Bloc, Provider, Riverpod for Flutter)
47+
3. Any other specific requirements or options
48+
49+
Query: %s
50+
51+
Respond in the following JSON format:
52+
{
53+
"projectType": "flutter|react|nextjs|etc",
54+
"framework": "bloc|provider|riverpod|redux|etc",
55+
"options": {
56+
"name": "project_name",
57+
"additionalFeatures": ["feature1", "feature2"]
58+
}
59+
}
60+
61+
Only include fields that you can confidently determine from the query. Use snake_case for project names.
62+
`, query)
63+
64+
// Get response from AI
65+
response, err := g.aiClient.Query(prompt)
66+
if err != nil {
67+
return "", "", nil, fmt.Errorf("failed to analyze query: %w", err)
68+
}
69+
70+
// Extract JSON from response (this is a simplified approach)
71+
// In a real implementation, you would parse the JSON properly
72+
projectType := extractValue(response, "projectType")
73+
framework := extractValue(response, "framework")
74+
75+
// Extract options
76+
options := make(map[string]string)
77+
78+
// Extract project name
79+
name := extractValue(response, "name")
80+
if name != "" {
81+
options["name"] = name
82+
} else {
83+
// Default project name based on project type
84+
switch strings.ToLower(projectType) {
85+
case "flutter":
86+
options["name"] = "my_flutter_app"
87+
case "react":
88+
options["name"] = "my-react-app"
89+
case "nextjs":
90+
options["name"] = "my-nextjs-app"
91+
default:
92+
options["name"] = "my-app"
93+
}
94+
}
95+
96+
// If project type is not specified, default to Flutter
97+
if projectType == "" {
98+
projectType = "flutter"
99+
}
100+
101+
return projectType, framework, options, nil
102+
}
103+
104+
// generateProject creates a project based on the specified type and framework
105+
func (g *Generator) generateProject(projectType, framework string, options map[string]string) (string, error) {
106+
// Convert project type to lowercase for case-insensitive comparison
107+
projectType = strings.ToLower(projectType)
108+
109+
// Generate the project based on type
110+
switch projectType {
111+
case "flutter":
112+
return generateFlutterProject(framework, options)
113+
// Add more project types here as needed
114+
default:
115+
return "", fmt.Errorf("unsupported project type: %s", projectType)
116+
}
117+
}
118+
119+
// showHelp returns help information for the create command
120+
func (g *Generator) showHelp() string {
121+
return `
122+
╭─────────────────── Lumo Project Creator ───────────────────╮
123+
│ │
124+
│ Create new projects with natural language descriptions. │
125+
│ │
126+
│ Usage: │
127+
│ lumo create:"<project description>" │
128+
│ │
129+
│ Examples: │
130+
│ lumo create:"Flutter app with bloc architecture" │
131+
│ lumo create:"Flutter app with provider state management"│
132+
│ │
133+
│ Supported Frameworks: │
134+
│ • Flutter (with Bloc, Provider, Riverpod) │
135+
│ │
136+
╰────────────────────────────────────────────────────────────╯
137+
`
138+
}
139+
140+
// extractValue is a simple helper to extract values from the AI response
141+
// In a real implementation, you would use proper JSON parsing
142+
func extractValue(response, key string) string {
143+
// This is a very simplified approach - in production code, use proper JSON parsing
144+
pattern := fmt.Sprintf(`"%s":\s*"([^"]+)"`, key)
145+
matches := regexp.MustCompile(pattern).FindStringSubmatch(response)
146+
if len(matches) > 1 {
147+
return matches[1]
148+
}
149+
return ""
150+
}

0 commit comments

Comments
 (0)