Skip to content

Commit bfbb861

Browse files
committed
Add template validation, more teplates, animations feedback after clicking button and more
1 parent b089afd commit bfbb861

25 files changed

+645
-192
lines changed

actions/actions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ package actions
33
const AddPerson = "add-person"
44
const RemovePerson = "remove-person"
55
const ActionOpenTeamPresetsModal = "open-team-presets-modal"
6+
const ShareWorkspace = "share-workspace"

cmd/server/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package main
22

33
import (
4-
"github.com/marosiak/agent-prompt-builder/config"
5-
"github.com/marosiak/agent-prompt-builder/ui/views"
4+
"github.com/marosiak/agent-prompt-builder/ui/pages"
65
"log"
76
"net/http"
87

8+
"github.com/marosiak/agent-prompt-builder/config"
99
"github.com/maxence-charriere/go-app/v10/pkg/app"
1010
)
1111

@@ -15,10 +15,10 @@ import (
1515
func main() {
1616

1717
app.Route("/", func() app.Composer {
18-
return &views.MainView{}
18+
return &pages.MainPage{}
1919
})
2020
app.Route("/import", func() app.Composer {
21-
return &views.ImportView{}
21+
return &pages.ImportPage{}
2222
})
2323

2424
config.RegisterRoutes()

cmd/static/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package main
22

33
import (
4+
"log"
5+
46
"github.com/marosiak/agent-prompt-builder/config"
57
"github.com/marosiak/agent-prompt-builder/ui/views"
68
"github.com/maxence-charriere/go-app/v10/pkg/app"
7-
"log"
89
)
910

1011
func main() {
1112
// TODO fix DRY
1213
app.Route("/", func() app.Composer {
13-
return &views.MainView{}
14+
return &views.MainPage{}
1415
})
1516
app.Route("/import", func() app.Composer {
16-
return &views.ImportView{}
17+
return &views.ImportPage{}
1718
})
1819

1920
app.RunWhenOnBrowser()

config/app.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package config
22

33
import (
44
"github.com/google/uuid"
5-
"github.com/marosiak/agent-prompt-builder/ui/views"
5+
"github.com/marosiak/agent-prompt-builder/ui/pages"
66
"github.com/maxence-charriere/go-app/v10/pkg/app"
77
)
88

@@ -34,9 +34,9 @@ func GetAppHandler(isStatic bool) *app.Handler {
3434

3535
func RegisterRoutes() {
3636
app.Route("/", func() app.Composer {
37-
return &views.MainView{}
37+
return &pages.MainPage{}
3838
})
3939
app.Route("/import", func() app.Composer {
40-
return &views.ImportView{}
40+
return &pages.ImportPage{}
4141
})
4242
}

domain/master_prompt.go

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,39 @@ import (
1616
type MasterPromptTemplate string
1717

1818
func (m MasterPromptTemplate) SetStyle(style string) MasterPromptTemplate {
19-
return MasterPromptTemplate(strings.ReplaceAll(string(m), "[[$$style$$]]", style))
19+
return MasterPromptTemplate(strings.ReplaceAll(string(m), "$$style$$", style))
2020
}
2121

2222
func (m MasterPromptTemplate) SetTeam(team string) MasterPromptTemplate {
23-
return MasterPromptTemplate(strings.ReplaceAll(string(m), "[[$$team$$]]", team))
23+
return MasterPromptTemplate(strings.ReplaceAll(string(m), "$$team$$", team))
2424
}
2525

2626
func (m MasterPromptTemplate) SetRules(rules string) MasterPromptTemplate {
27-
return MasterPromptTemplate(strings.ReplaceAll(string(m), "[[$$rules$$]]", rules))
27+
return MasterPromptTemplate(strings.ReplaceAll(string(m), "$$rules$$", rules))
2828
}
2929

30-
func (m MasterPromptTemplate) IsValid() (bool, error) {
30+
type PromptTemplateValidation struct {
31+
StylePlaceholderMissing bool `json:"style_placeholder_missing"`
32+
TeamPlaceholderMissing bool `json:"team_placeholder_missing"`
33+
RulesPlaceholderMissing bool `json:"rules_placeholder_missing"`
34+
}
35+
36+
func (m MasterPromptTemplate) IsValid() (bool, *PromptTemplateValidation) {
3137
str := string(m)
3238

33-
if !strings.Contains(str, "[[$$style$$]]") {
34-
return false, fmt.Errorf("template is missing $$style$$ placeholder")
35-
}
36-
if !strings.Contains(str, "[[$$team$$]]") {
37-
return false, fmt.Errorf("template is missing $$team$$ placeholder")
38-
}
39-
if !strings.Contains(str, "[[$$rules$$]]") {
40-
return false, fmt.Errorf("template is missing $$rules$$ placeholder")
39+
validation := &PromptTemplateValidation{
40+
StylePlaceholderMissing: !strings.Contains(str, "$$style$$"),
41+
TeamPlaceholderMissing: !strings.Contains(str, "$$team$$"),
42+
RulesPlaceholderMissing: !strings.Contains(str, "$$rules$$"),
4143
}
4244

45+
if validation.StylePlaceholderMissing || validation.TeamPlaceholderMissing || validation.RulesPlaceholderMissing {
46+
slog.Error("Master prompt template is invalid",
47+
slog.Bool("style_placeholder_missing", validation.StylePlaceholderMissing),
48+
slog.Bool("team_placeholder_missing", validation.TeamPlaceholderMissing),
49+
slog.Bool("rules_placeholder_missing", validation.RulesPlaceholderMissing))
50+
return false, validation
51+
}
4352
return true, nil
4453
}
4554

@@ -57,7 +66,7 @@ func (f WeightedString) String() string {
5766
}
5867
}
5968
if f.Weight == 0 {
60-
return fmt.Sprintf("[WEIGHT: unspecified] %s", name)
69+
return fmt.Sprintf("[WEIGHT: ?] %s", name)
6170
}
6271

6372
return fmt.Sprintf("[WEIGHT: %d] %s", f.Weight, f.Name)
@@ -230,9 +239,9 @@ func (m *MasterPrompt) RemoveFeatureByID(featureID string) {
230239
func (m *MasterPrompt) String() (string, error) {
231240
masterPrompt := m.Template
232241

233-
isValid, err := masterPrompt.IsValid()
242+
isValid, _ := masterPrompt.IsValid()
234243
if !isValid {
235-
return "", fmt.Errorf("master prompt template is invalid: %w", err)
244+
return "", fmt.Errorf("master prompt template is invalid")
236245
}
237246

238247
styleString := ""

domain/templates_presets.go

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,48 @@ package domain
22

33
var MinimalisticTemplate = MasterPromptTemplate(`
44
### Apply such style
5-
[[$$style$$]]
5+
$$style$$
66
77
### Follow these rules:
8-
[[$$rules$$]]
8+
$$rules$$
99
1010
### Cooperate with this team:
11-
[[$$team$$]]
11+
$$team$$
1212
`)
1313

14-
var CodingInUnityTemplate = MasterPromptTemplate(`
15-
You are a senior programming assistant specialized in game development with Unity6 and C#.
14+
var CodingTemplate = MasterPromptTemplate(`
15+
You are a senior programming assistant working in a collaborative environment.
1616
17-
You work inside a virtual development team, where each member has a unique coding style, values, and review approach. The team always collaborates.
17+
You work inside a development team, where each member has a unique experience, coding style, values, and review approach. The team always collaborates.
1818
19-
The team:
20-
[[$$team$$]]
19+
# The team:
20+
<team>
21+
$$team$$
22+
</team>
2123
22-
23-
Your task follows a strict 3-phase development workflow:
24+
I want you to work in Phases, each with a specific goal.
2425
2526
---
2627
2728
🧠 PHASE 1: BRAINSTORM
28-
Before writing any code, initiate a brainstorming round. Each persona independently shares suggestions, concerns, or patterns they would apply to the provided input:
29+
Before writing any code, initiate a brainstorming round. Explain topic to the team, then they'll answer and shares suggestions, concerns, or patterns they would apply to the provided input:
2930
3031
Include design hints, edge cases, architectural suggestions, warnings or creative alternatives.
3132
This is not code – only ideas and reasoning. Each persona replies separately.
3233
34+
3335
---
3436
3537
💻 PHASE 2: CODE GENERATION
36-
Based on the brainstorm output, write a full Unity C# solution – a single, complete code file.
37-
Apply clean architecture, Unity6 conventions, and C# best practices.
38+
Based on the brainstorm output, write a full solution, including all necessary files, classes, and methods.
39+
You know your team very well, so try to write code that can satisfy all team members.
3840
39-
Always output the entire code, even if parts are unchanged. Do not include explanations unless asked.
41+
Always output the entire code, even if parts are unchanged.
4042
4143
---
4244
4345
🧪 PHASE 3: CODE REVIEW + RESOLUTION
44-
Now simulate a code review session. Each persona reviews the generated code and comments on what was good or problematic from their perspective.
46+
Simulate a code review session. Each persona reviews the generated code and comments on what was good or problematic from their perspective.
4547
4648
As assistant:
4749
- For each comment, mark resolution status using emoji:
@@ -57,17 +59,38 @@ As assistant:
5759
5860
---
5961
60-
Apply such style rules:
61-
[[$$style$$]]
62+
# Additional *STYLE* instructions:
63+
<style>
64+
$$style$$
65+
</style>
6266
63-
RULES:
64-
- Use markdown formatting if possible (e.g. triple backticks for code)
67+
# More *RULES*:
68+
<rules>
69+
$$rules$$
6570
- Do not hallucinate personas or skip any steps
66-
[[$$rules$$]]
67-
71+
</rules>
72+
`)
73+
var BrainstormingTemplate = MasterPromptTemplate(`
74+
You are a brainstorming assistant working in a collaborative environment.
75+
You work inside a development team, where each member has a unique experience, coding style, values, and review approach. The team always collaborates in order to get best and objective results.
76+
77+
# The team:
78+
<team>
79+
$$team$$
80+
</team>
81+
82+
# Rules:
83+
<rules>
84+
$$rules$$
85+
</rules>
86+
87+
# Style:
88+
<style>
89+
$$style$$
90+
</style>
6891
`)
69-
7092
var AllMasterTemplatesMap = map[string]MasterPromptTemplate{
71-
"Minimalistic": MinimalisticTemplate,
72-
"[Coding] Unity template": CodingInUnityTemplate,
93+
"🔸 Minimalistic": MinimalisticTemplate,
94+
"🧠 Brainstorming": BrainstormingTemplate,
95+
"🤖 Coding": CodingTemplate,
7396
}

state/prompt_state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func GetMasterPrompt(ctx app.Context) domain.MasterPrompt {
4444

4545
func getDefaultMasterPrompt() domain.MasterPrompt {
4646
return domain.MasterPrompt{
47-
Template: domain.CodingInUnityTemplate,
47+
Template: domain.CodingTemplate,
4848
StylePreset: domain.StylePresetShortAndLazy,
4949
RulePreset: domain.RulePresetPerformanceOptimization,
5050
TeamPreset: domain.ExampleTeamPreset,

tailwind/config.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
prefersdark: false;
1313
color-scheme: "light";
1414
--color-base-100: oklch(97.788% 0.004 56.375);
15-
--color-base-200: oklch(93.982% 0.007 61.449);
16-
--color-base-300: oklch(91.586% 0.006 53.44);
15+
--color-base-200: oklch(96% 0.001 286.375);
16+
--color-base-300: oklch(87% 0.006 286.286);
1717
--color-base-content: oklch(23.574% 0.066 313.189);
1818
--color-primary: oklch(80% 0.105 251.813);
1919
--color-primary-content: oklch(43% 0.078 188.216);
@@ -24,13 +24,13 @@
2424
--color-neutral: oklch(27% 0.006 286.033);
2525
--color-neutral-content: oklch(92% 0.004 286.32);
2626
--color-info: oklch(68% 0.169 237.323);
27-
--color-info-content: oklch(29% 0.066 243.157);
28-
--color-success: oklch(69% 0.17 162.48);
29-
--color-success-content: oklch(26% 0.051 172.552);
27+
--color-info-content: oklch(39% 0.09 240.876);
28+
--color-success: oklch(62% 0.194 149.214);
29+
--color-success-content: oklch(98% 0.003 247.858);
3030
--color-warning: oklch(79% 0.184 86.047);
31-
--color-warning-content: oklch(28% 0.066 53.813);
32-
--color-error: oklch(64% 0.246 16.439);
33-
--color-error-content: oklch(27% 0.105 12.094);
31+
--color-warning-content: oklch(47% 0.114 61.907);
32+
--color-error: oklch(71% 0.194 13.428);
33+
--color-error-content: oklch(39% 0.141 25.723);
3434
--radius-selector: 0.5rem;
3535
--radius-field: 0.5rem;
3636
--radius-box: 1rem;

ui/components/breadcrumbs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type BreadcrumbsComponent struct {
1818
}
1919

2020
func (b *BreadcrumbsComponent) Render() app.UI {
21-
ul := app.Ul().Class("breadcrumbs text-xl")
21+
ul := app.Ul().Class("breadcrumbs text-md lg:text-xl")
2222
var liList []app.UI
2323
for _, breadcrumb := range b.Breadcrumbs {
2424
li := app.Li()

0 commit comments

Comments
 (0)