@jeancodogno/specforce-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.geminiignore +15 -0
- package/.github/workflows/ci.yml +100 -0
- package/.github/workflows/release.yml +51 -0
- package/.golangci.yml +21 -0
- package/.goreleaser.yaml +43 -0
- package/.rgignore +13 -0
- package/.specforce/config.yaml +32 -0
- package/.specforce/docs/.gitkeep +0 -0
- package/.specforce/docs/architecture.md +98 -0
- package/.specforce/docs/engineering.md +80 -0
- package/.specforce/docs/governance.md +30 -0
- package/.specforce/docs/memorial.md +44 -0
- package/.specforce/docs/principles.md +31 -0
- package/.specforce/docs/security.md +31 -0
- package/.specforce/docs/ui-ux.md +129 -0
- package/.specforce/specs/.gitkeep +0 -0
- package/AGENTS.md +36 -0
- package/CONTRIBUTING.md +81 -0
- package/LICENSE +21 -0
- package/Makefile +49 -0
- package/README.md +144 -0
- package/assets/logo-header.png +0 -0
- package/assets/logo.png +0 -0
- package/docs/artifacts.md +41 -0
- package/docs/cli.md +73 -0
- package/docs/configuration.md +50 -0
- package/docs/getting-started.md +110 -0
- package/docs/supported-tools.md +14 -0
- package/go.mod +35 -0
- package/go.sum +61 -0
- package/index.js +0 -0
- package/package.json +26 -0
- package/src/cmd/specforce/main.go +23 -0
- package/src/cmd/specforce/main_test.go +7 -0
- package/src/internal/agent/artifacts/constitution/architecture.yaml +70 -0
- package/src/internal/agent/artifacts/constitution/engineering.yaml +52 -0
- package/src/internal/agent/artifacts/constitution/governance.yaml +41 -0
- package/src/internal/agent/artifacts/constitution/memorial.yaml +55 -0
- package/src/internal/agent/artifacts/constitution/principles.yaml +54 -0
- package/src/internal/agent/artifacts/constitution/security.yaml +47 -0
- package/src/internal/agent/artifacts/constitution/ui-ux.yaml +158 -0
- package/src/internal/agent/artifacts/spec/design.yaml +50 -0
- package/src/internal/agent/artifacts/spec/requirements.yaml +48 -0
- package/src/internal/agent/artifacts/spec/tasks.yaml +55 -0
- package/src/internal/agent/compatibility_test.go +120 -0
- package/src/internal/agent/cwd_test.go +9 -0
- package/src/internal/agent/embed.go +19 -0
- package/src/internal/agent/integration_test.go +138 -0
- package/src/internal/agent/kit/agents/product-analyst.yaml +31 -0
- package/src/internal/agent/kit/agents/technical-developer.yaml +28 -0
- package/src/internal/agent/kit/agents/technical-project-planner.yaml +30 -0
- package/src/internal/agent/kit/agents/technical-qa-engineer.yaml +36 -0
- package/src/internal/agent/kit/agents/technical-solution-architect.yaml +32 -0
- package/src/internal/agent/kit/commands/archive.yaml +25 -0
- package/src/internal/agent/kit/commands/constitution.yaml +132 -0
- package/src/internal/agent/kit/commands/implement.yaml +96 -0
- package/src/internal/agent/kit/commands/spec.yaml +94 -0
- package/src/internal/agent/kit/instructions/archive.md +68 -0
- package/src/internal/agent/kit/kit.yaml +111 -0
- package/src/internal/agent/kit/skills/opportunity-framing/SKILL.yaml +56 -0
- package/src/internal/agent/kit/skills/pragmatic-product-owner/SKILL.yaml +58 -0
- package/src/internal/agent/kit/skills/pragmatic-product-owner/references/spec-artifacts.yaml +38 -0
- package/src/internal/agent/kit/skills/spec-clarification-interview/SKILL.yaml +52 -0
- package/src/internal/agent/kit/skills/task-atomic-decomposition/SKILL.yaml +137 -0
- package/src/internal/agent/kit/skills/task-atomic-decomposition/references/roadmap-patterns.yaml +103 -0
- package/src/internal/agent/kit_manifests_test.go +58 -0
- package/src/internal/agent/manifest.go +15 -0
- package/src/internal/agent/registry.go +69 -0
- package/src/internal/agent/registry_test.go +51 -0
- package/src/internal/agent/translator.go +334 -0
- package/src/internal/agent/translator_test.go +734 -0
- package/src/internal/cli/archive.go +91 -0
- package/src/internal/cli/archive_test.go +67 -0
- package/src/internal/cli/cli.go +259 -0
- package/src/internal/cli/cli_test.go +130 -0
- package/src/internal/cli/cobra/archive.go +26 -0
- package/src/internal/cli/cobra/console.go +21 -0
- package/src/internal/cli/cobra/constitution.go +44 -0
- package/src/internal/cli/cobra/dummy_test.go +7 -0
- package/src/internal/cli/cobra/implementation.go +50 -0
- package/src/internal/cli/cobra/init.go +23 -0
- package/src/internal/cli/cobra/install.go +21 -0
- package/src/internal/cli/cobra/root.go +47 -0
- package/src/internal/cli/cobra/spec.go +91 -0
- package/src/internal/cli/console.go +48 -0
- package/src/internal/cli/constitution.go +190 -0
- package/src/internal/cli/constitution_test.go +50 -0
- package/src/internal/cli/implementation.go +153 -0
- package/src/internal/cli/implementation_test.go +165 -0
- package/src/internal/cli/spec.go +369 -0
- package/src/internal/cli/spec_test.go +85 -0
- package/src/internal/constitution/registry.go +139 -0
- package/src/internal/constitution/registry_test.go +97 -0
- package/src/internal/constitution/status.go +70 -0
- package/src/internal/constitution/status_test.go +160 -0
- package/src/internal/core/blueprint.go +49 -0
- package/src/internal/core/blueprint_test.go +58 -0
- package/src/internal/core/config.go +124 -0
- package/src/internal/core/config_test.go +145 -0
- package/src/internal/core/constants.go +13 -0
- package/src/internal/core/errors.go +31 -0
- package/src/internal/core/errors_test.go +48 -0
- package/src/internal/core/hooks.go +89 -0
- package/src/internal/core/hooks_test.go +51 -0
- package/src/internal/core/kit.go +15 -0
- package/src/internal/core/kit_test.go +65 -0
- package/src/internal/core/path.go +115 -0
- package/src/internal/core/path_test.go +101 -0
- package/src/internal/core/ui.go +19 -0
- package/src/internal/installer/dependencies.go +23 -0
- package/src/internal/installer/install.go +89 -0
- package/src/internal/installer/installer.go +45 -0
- package/src/internal/installer/installer_test.go +96 -0
- package/src/internal/project/agents_md.go +108 -0
- package/src/internal/project/agents_md_test.go +101 -0
- package/src/internal/project/bootstrapper.go +64 -0
- package/src/internal/project/bootstrapper_test.go +89 -0
- package/src/internal/project/detector.go +35 -0
- package/src/internal/project/detector_test.go +96 -0
- package/src/internal/project/refresh_integration_test.go +86 -0
- package/src/internal/project/service.go +93 -0
- package/src/internal/project/service_test.go +135 -0
- package/src/internal/spec/archive.go +49 -0
- package/src/internal/spec/archive_test.go +55 -0
- package/src/internal/spec/discovery.go +53 -0
- package/src/internal/spec/discovery_test.go +60 -0
- package/src/internal/spec/implementation.go +296 -0
- package/src/internal/spec/implementation_test.go +253 -0
- package/src/internal/spec/registry.go +142 -0
- package/src/internal/spec/registry_test.go +105 -0
- package/src/internal/spec/scanner.go +219 -0
- package/src/internal/spec/scanner_test.go +243 -0
- package/src/internal/spec/service.go +157 -0
- package/src/internal/spec/service_test.go +238 -0
- package/src/internal/spec/status.go +94 -0
- package/src/internal/spec/status_test.go +146 -0
- package/src/internal/spec/tasks.go +103 -0
- package/src/internal/spec/tasks_test.go +137 -0
- package/src/internal/tui/components.go +132 -0
- package/src/internal/tui/console.go +247 -0
- package/src/internal/tui/console_test.go +19 -0
- package/src/internal/tui/constitution.go +36 -0
- package/src/internal/tui/constitution_test.go +32 -0
- package/src/internal/tui/implementation.go +151 -0
- package/src/internal/tui/logo.go +89 -0
- package/src/internal/tui/multiselect.go +199 -0
- package/src/internal/tui/progressbar.go +37 -0
- package/src/internal/tui/progressbar_test.go +30 -0
- package/src/internal/tui/spec.go +35 -0
- package/src/internal/tui/spinner.go +66 -0
- package/src/internal/tui/terminal.go +18 -0
- package/src/internal/tui/theme.go +125 -0
- package/src/internal/tui/ui.go +52 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"strings"
|
|
6
|
+
|
|
7
|
+
"github.com/jeancodogno/specforce-kit/src/internal/spec"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// RenderImplementationStatus renders the implementation status report.
|
|
11
|
+
func RenderImplementationStatus(report *spec.ImplementationReport) error {
|
|
12
|
+
if IsTTY() {
|
|
13
|
+
PrintBranding()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
renderStatusHeader(report)
|
|
17
|
+
renderArtifactsCheck(report)
|
|
18
|
+
renderImplementationContext(report)
|
|
19
|
+
renderExecutionStrategy(report)
|
|
20
|
+
renderAtomicTasks(report)
|
|
21
|
+
renderProjectInstructions(report)
|
|
22
|
+
renderPreemptiveMitigations(report)
|
|
23
|
+
|
|
24
|
+
return nil
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func renderStatusHeader(report *spec.ImplementationReport) {
|
|
28
|
+
fmt.Println("\n" + HeaderStyle.Render("IMPLEMENTATION READINESS: "+strings.ToUpper(report.Name)))
|
|
29
|
+
|
|
30
|
+
var statusBadge string
|
|
31
|
+
switch strings.ToLower(report.Status) {
|
|
32
|
+
case "ready":
|
|
33
|
+
statusBadge = SuccessBadgeStyle.Render(" READY ")
|
|
34
|
+
case "blocked":
|
|
35
|
+
statusBadge = ErrorBadgeStyle.Render(" BLOCKED ")
|
|
36
|
+
case "in-progress":
|
|
37
|
+
statusBadge = WarningBadgeStyle.Render(" IN-PROGRESS ")
|
|
38
|
+
case "finished":
|
|
39
|
+
statusBadge = SuccessBadgeStyle.Render(" FINISHED ")
|
|
40
|
+
default:
|
|
41
|
+
statusBadge = SubtitleStyle.Render(strings.ToUpper(report.Status))
|
|
42
|
+
}
|
|
43
|
+
fmt.Printf("%s\n\n", statusBadge)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func renderArtifactsCheck(report *spec.ImplementationReport) {
|
|
47
|
+
fmt.Println(HeaderStyle.Render("ARTIFACTS CHECK"))
|
|
48
|
+
if len(report.MissingArtifacts) == 0 {
|
|
49
|
+
fmt.Println(SuccessStyle.Render(" [v] All triad artifacts present (requirements, design, tasks)"))
|
|
50
|
+
} else {
|
|
51
|
+
for _, art := range report.MissingArtifacts {
|
|
52
|
+
fmt.Println(ErrorStyle.Render(" [x] Missing: " + art))
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
fmt.Println()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func renderImplementationContext(report *spec.ImplementationReport) {
|
|
59
|
+
fmt.Println(HeaderStyle.Render("IMPLEMENTATION CONTEXT"))
|
|
60
|
+
if len(report.ContextFiles) == 0 {
|
|
61
|
+
fmt.Println(SubtitleStyle.Render(" No context files found."))
|
|
62
|
+
} else {
|
|
63
|
+
for _, file := range report.ContextFiles {
|
|
64
|
+
fmt.Println(SubtitleStyle.Render(" - " + file))
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
fmt.Println()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
func renderExecutionStrategy(report *spec.ImplementationReport) {
|
|
71
|
+
if report.ExecutionStrategy != "" {
|
|
72
|
+
fmt.Println(HeaderStyle.Render("EXECUTION STRATEGY"))
|
|
73
|
+
fmt.Println(BodyStyle.Render(" " + report.ExecutionStrategy))
|
|
74
|
+
fmt.Println()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func renderAtomicTasks(report *spec.ImplementationReport) {
|
|
79
|
+
fmt.Println(HeaderStyle.Render("ATOMIC TASKS"))
|
|
80
|
+
if len(report.Phases) == 0 || (len(report.Phases) == 1 && len(report.Phases[0].Tasks) == 0) {
|
|
81
|
+
fmt.Println(SubtitleStyle.Render(" No tasks found in tasks.md."))
|
|
82
|
+
} else {
|
|
83
|
+
for _, phase := range report.Phases {
|
|
84
|
+
renderPhase(phase, len(report.Phases))
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
fmt.Println()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func renderPhase(phase spec.Phase, totalPhases int) {
|
|
91
|
+
allFinished := len(phase.Tasks) > 0
|
|
92
|
+
for _, t := range phase.Tasks {
|
|
93
|
+
if strings.ToUpper(t.State) != "FINISHED" {
|
|
94
|
+
allFinished = false
|
|
95
|
+
break
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
phaseTitle := phase.Title
|
|
100
|
+
if allFinished {
|
|
101
|
+
phaseTitle = "✓ " + phaseTitle
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if totalPhases > 1 || (phase.ID != "0" && phase.ID != "") {
|
|
105
|
+
phaseStyle := HeaderStyle
|
|
106
|
+
if allFinished {
|
|
107
|
+
phaseStyle = SuccessStyle
|
|
108
|
+
}
|
|
109
|
+
fmt.Printf("\n %s\n", phaseStyle.Render(strings.ToUpper(phaseTitle)))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
for _, task := range phase.Tasks {
|
|
113
|
+
renderTask(task)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
func renderTask(task spec.ImplementationTask) {
|
|
118
|
+
stateIcon := "○"
|
|
119
|
+
stateStyle := BodyStyle
|
|
120
|
+
switch strings.ToUpper(task.State) {
|
|
121
|
+
case "FINISHED":
|
|
122
|
+
stateIcon = "◉"
|
|
123
|
+
stateStyle = SuccessStyle
|
|
124
|
+
case "IN-PROGRESS":
|
|
125
|
+
stateStyle = WarningStyle
|
|
126
|
+
case "FAILED":
|
|
127
|
+
stateStyle = ErrorStyle
|
|
128
|
+
}
|
|
129
|
+
fmt.Printf(" %s %s: %s\n", stateStyle.Render(stateIcon), HeaderStyle.Render(task.ID), BodyStyle.Render(task.Title))
|
|
130
|
+
if task.Target != "" {
|
|
131
|
+
fmt.Printf(" %s %s\n", SubtitleStyle.Render("Target:"), BodyStyle.Render(task.Target))
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
func renderProjectInstructions(report *spec.ImplementationReport) {
|
|
136
|
+
if len(report.Instructions) > 0 {
|
|
137
|
+
fmt.Println(HeaderStyle.Render("PROJECT SPECIFIC INSTRUCTIONS"))
|
|
138
|
+
for _, inst := range report.Instructions {
|
|
139
|
+
fmt.Println(BodyStyle.Render(" - " + inst))
|
|
140
|
+
}
|
|
141
|
+
fmt.Println()
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
func renderPreemptiveMitigations(report *spec.ImplementationReport) {
|
|
146
|
+
if report.PreemptiveMitigations != "" {
|
|
147
|
+
fmt.Println(HeaderStyle.Render("PRE-EMPTIVE MITIGATIONS"))
|
|
148
|
+
fmt.Println(BodyStyle.Render(" " + report.PreemptiveMitigations))
|
|
149
|
+
fmt.Println()
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"strings"
|
|
6
|
+
|
|
7
|
+
"github.com/charmbracelet/lipgloss"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
var AppVersion = "v0.1.0"
|
|
11
|
+
|
|
12
|
+
var brailleLines = []string{
|
|
13
|
+
` ⢠⣶⣶⡄ `,
|
|
14
|
+
` ⢠⣿⣿⣿⣿⡄ `,
|
|
15
|
+
` ⢠⣿⣿⣿⣿⣿⣿⡄ `,
|
|
16
|
+
` ⠻⣿⣿⣿⣿⣿⣿⠟ `,
|
|
17
|
+
` ⠻⣿⣿⣿⠟ `,
|
|
18
|
+
` ⠻⠟ `,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var gradientColors = []lipgloss.Color{
|
|
22
|
+
lipgloss.Color("#00FA9A"),
|
|
23
|
+
lipgloss.Color("#00FCBB"),
|
|
24
|
+
lipgloss.Color("#00FDEE"),
|
|
25
|
+
lipgloss.Color("#00FFFF"),
|
|
26
|
+
lipgloss.Color("#70FFFF"),
|
|
27
|
+
lipgloss.Color("#E0FFFF"),
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var (
|
|
31
|
+
cachedLogo string
|
|
32
|
+
cachedBranding string
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
// GenerateLogo returns the styled lipgloss string for the new Ghost in the Machine logo.
|
|
36
|
+
func GenerateLogo(withSubtitle bool) string {
|
|
37
|
+
if withSubtitle && cachedBranding != "" {
|
|
38
|
+
return cachedBranding
|
|
39
|
+
}
|
|
40
|
+
if !withSubtitle && cachedLogo != "" {
|
|
41
|
+
return cachedLogo
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var renderedBraille []string
|
|
45
|
+
for i, line := range brailleLines {
|
|
46
|
+
style := lipgloss.NewStyle().Foreground(gradientColors[i]).Bold(true)
|
|
47
|
+
renderedBraille = append(renderedBraille, style.Render(line))
|
|
48
|
+
}
|
|
49
|
+
brailleBlock := lipgloss.JoinVertical(lipgloss.Left, renderedBraille...)
|
|
50
|
+
|
|
51
|
+
var textLines []string
|
|
52
|
+
textLines = append(textLines, "") // Alignment for Line 0
|
|
53
|
+
|
|
54
|
+
specforceText := lipgloss.NewStyle().Foreground(lipgloss.Color("#FFFFFF")).Bold(true).Render("SPECFORCE ")
|
|
55
|
+
versionStr := AppVersion
|
|
56
|
+
if !strings.HasPrefix(versionStr, "v") {
|
|
57
|
+
versionStr = "v" + versionStr
|
|
58
|
+
}
|
|
59
|
+
versionText := DimmedStyle.Render(versionStr)
|
|
60
|
+
textLines = append(textLines, specforceText+versionText)
|
|
61
|
+
|
|
62
|
+
if withSubtitle {
|
|
63
|
+
textLines = append(textLines, DimmedStyle.Render("Spec-Driven Development (SDD)"))
|
|
64
|
+
textLines = append(textLines, DimmedStyle.Render("Ecosystem for AI-assisted development"))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
textBlock := lipgloss.JoinVertical(lipgloss.Left, textLines...)
|
|
68
|
+
|
|
69
|
+
finalStr := lipgloss.JoinHorizontal(lipgloss.Top, brailleBlock, textBlock)
|
|
70
|
+
finalStr = lipgloss.NewStyle().Padding(1, 0, 0, 0).Render(finalStr)
|
|
71
|
+
|
|
72
|
+
if withSubtitle {
|
|
73
|
+
cachedBranding = finalStr
|
|
74
|
+
} else {
|
|
75
|
+
cachedLogo = finalStr
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return finalStr
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// PrintLogo renders the Specforce logo.
|
|
82
|
+
func PrintLogo() {
|
|
83
|
+
fmt.Println(GenerateLogo(false))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// PrintBranding renders both the logo and the subtitle.
|
|
87
|
+
func PrintBranding() {
|
|
88
|
+
fmt.Println(GenerateLogo(true))
|
|
89
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
|
|
6
|
+
tea "github.com/charmbracelet/bubbletea"
|
|
7
|
+
"github.com/jeancodogno/specforce-kit/src/internal/agent"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
type AgentOption struct {
|
|
11
|
+
ID string
|
|
12
|
+
Name string
|
|
13
|
+
Selected bool
|
|
14
|
+
Exists bool
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type model struct {
|
|
18
|
+
choices []AgentOption
|
|
19
|
+
cursor int
|
|
20
|
+
selected map[int]struct{}
|
|
21
|
+
toRemove map[int]struct{}
|
|
22
|
+
confirming bool
|
|
23
|
+
quitting bool
|
|
24
|
+
aborted bool
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func initialModel(available []agent.AgentMetadata, existing []string) model {
|
|
28
|
+
choices := make([]AgentOption, len(available))
|
|
29
|
+
for i, a := range available {
|
|
30
|
+
choices[i] = AgentOption{
|
|
31
|
+
ID: a.ID,
|
|
32
|
+
Name: a.Name,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
selected := make(map[int]struct{})
|
|
37
|
+
for i, choice := range choices {
|
|
38
|
+
for _, e := range existing {
|
|
39
|
+
if choice.ID == e {
|
|
40
|
+
choices[i].Exists = true
|
|
41
|
+
selected[i] = struct{}{}
|
|
42
|
+
break
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return model{
|
|
48
|
+
choices: choices,
|
|
49
|
+
selected: selected,
|
|
50
|
+
toRemove: make(map[int]struct{}),
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
func (m model) Init() tea.Cmd {
|
|
55
|
+
return nil
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
59
|
+
keyMsg, ok := msg.(tea.KeyMsg)
|
|
60
|
+
if !ok {
|
|
61
|
+
return m, nil
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if m.confirming {
|
|
65
|
+
return m.handleConfirmation(keyMsg)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return m.handleNavigation(keyMsg)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
func (m model) handleConfirmation(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|
72
|
+
switch msg.String() {
|
|
73
|
+
case "y", "Y":
|
|
74
|
+
m.quitting = true
|
|
75
|
+
return m, tea.Quit
|
|
76
|
+
case "n", "N", "esc":
|
|
77
|
+
m.confirming = false
|
|
78
|
+
return m, nil
|
|
79
|
+
}
|
|
80
|
+
return m, nil
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func (m model) handleNavigation(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|
84
|
+
switch msg.String() {
|
|
85
|
+
case "ctrl+c", "q":
|
|
86
|
+
m.quitting = true
|
|
87
|
+
m.aborted = true
|
|
88
|
+
return m, tea.Quit
|
|
89
|
+
case "up", "k":
|
|
90
|
+
if m.cursor > 0 {
|
|
91
|
+
m.cursor--
|
|
92
|
+
}
|
|
93
|
+
case "down", "j":
|
|
94
|
+
if m.cursor < len(m.choices)-1 {
|
|
95
|
+
m.cursor++
|
|
96
|
+
}
|
|
97
|
+
case "enter", " ":
|
|
98
|
+
m.toggleSelection()
|
|
99
|
+
case "y":
|
|
100
|
+
if len(m.toRemove) > 0 {
|
|
101
|
+
m.confirming = true
|
|
102
|
+
} else {
|
|
103
|
+
m.quitting = true
|
|
104
|
+
return m, tea.Quit
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return m, nil
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
func (m *model) toggleSelection() {
|
|
111
|
+
_, ok := m.selected[m.cursor]
|
|
112
|
+
if ok {
|
|
113
|
+
delete(m.selected, m.cursor)
|
|
114
|
+
if m.choices[m.cursor].Exists {
|
|
115
|
+
m.toRemove[m.cursor] = struct{}{}
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
m.selected[m.cursor] = struct{}{}
|
|
119
|
+
delete(m.toRemove, m.cursor)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
func (m model) View() string {
|
|
124
|
+
if m.quitting {
|
|
125
|
+
return ""
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if m.confirming {
|
|
129
|
+
return m.viewConfirmation()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return m.viewSelection()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
func (m model) viewConfirmation() string {
|
|
136
|
+
var agents []string
|
|
137
|
+
for i := range m.toRemove {
|
|
138
|
+
agents = append(agents, m.choices[i].Name)
|
|
139
|
+
}
|
|
140
|
+
s := WarningStyle.Render("⚠️ WARNING: You have unselected existing agents.\n")
|
|
141
|
+
s += BodyStyle.Render(fmt.Sprintf("The following agent directories will be decommissioned: %v\n\n", agents))
|
|
142
|
+
s += BodyStyle.Render("Are you sure you want to proceed? (y/n)")
|
|
143
|
+
return s
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
func (m model) viewSelection() string {
|
|
147
|
+
s := HeaderStyle.Render("Select AI agents to initialize in this project:") + "\n\n"
|
|
148
|
+
|
|
149
|
+
for i, choice := range m.choices {
|
|
150
|
+
cursor := " "
|
|
151
|
+
if m.cursor == i {
|
|
152
|
+
cursor = ActiveArrowStyle.Render(ArrowGlyph)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
checked := UnselectedBulletStyle.Render(EmptyBulletGlyph)
|
|
156
|
+
if _, ok := m.selected[i]; ok {
|
|
157
|
+
checked = SelectedBulletStyle.Render(BulletGlyph)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
existsInfo := ""
|
|
161
|
+
if choice.Exists {
|
|
162
|
+
existsInfo = DimmedStyle.Render(" (already exists)")
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
s += fmt.Sprintf("%s %s %s%s\n", cursor, checked, BodyStyle.Render(choice.Name), existsInfo)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
s += m.viewFooter()
|
|
169
|
+
return s
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
func (m model) viewFooter() string {
|
|
173
|
+
footer := "\n" + DimmedStyle.Render("Press space/enter to toggle, 'y' to confirm, 'q' to quit.") + "\n"
|
|
174
|
+
if len(m.toRemove) > 0 {
|
|
175
|
+
footer += "\n" + WarningStyle.Render("⚠️ Some existing agents will be removed upon confirmation.") + "\n"
|
|
176
|
+
}
|
|
177
|
+
return footer
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// SelectAgents launches the TUI and returns the selected agent IDs.
|
|
181
|
+
func SelectAgents(available []agent.AgentMetadata, existing []string) ([]string, error) {
|
|
182
|
+
p := tea.NewProgram(initialModel(available, existing))
|
|
183
|
+
m, err := p.Run()
|
|
184
|
+
if err != nil {
|
|
185
|
+
return nil, err
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
finalModel := m.(model)
|
|
189
|
+
if finalModel.aborted {
|
|
190
|
+
return nil, fmt.Errorf("aborted")
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var selected []string
|
|
194
|
+
for i := range finalModel.selected {
|
|
195
|
+
selected = append(selected, finalModel.choices[i].ID)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return selected, nil
|
|
199
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"strings"
|
|
6
|
+
|
|
7
|
+
"github.com/charmbracelet/lipgloss"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// RenderProgressBar returns a stylized progress bar string.
|
|
11
|
+
func RenderProgressBar(percent int, width int) string {
|
|
12
|
+
if percent < 0 {
|
|
13
|
+
percent = 0
|
|
14
|
+
}
|
|
15
|
+
if percent > 100 {
|
|
16
|
+
percent = 100
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Calculate filled width
|
|
20
|
+
filledWidth := (percent * width) / 100
|
|
21
|
+
emptyWidth := width - filledWidth
|
|
22
|
+
|
|
23
|
+
// Styles
|
|
24
|
+
barColor := brandCyan
|
|
25
|
+
if percent == 100 {
|
|
26
|
+
barColor = successGreen
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
filledStyle := lipgloss.NewStyle().Foreground(barColor)
|
|
30
|
+
emptyStyle := lipgloss.NewStyle().Foreground(mutedGrey)
|
|
31
|
+
|
|
32
|
+
// Use solid blocks for the neon look
|
|
33
|
+
filled := filledStyle.Render(strings.Repeat("█", filledWidth))
|
|
34
|
+
empty := emptyStyle.Render(strings.Repeat("░", emptyWidth))
|
|
35
|
+
|
|
36
|
+
return fmt.Sprintf("%s%s %d%%", filled, empty, percent)
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"strings"
|
|
5
|
+
"testing"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
func TestRenderProgressBar(t *testing.T) {
|
|
9
|
+
tests := []struct {
|
|
10
|
+
name string
|
|
11
|
+
percent int
|
|
12
|
+
width int
|
|
13
|
+
contains string
|
|
14
|
+
}{
|
|
15
|
+
{"0 percent", 0, 10, "0%"},
|
|
16
|
+
{"50 percent", 50, 10, "50%"},
|
|
17
|
+
{"100 percent", 100, 10, "100%"},
|
|
18
|
+
{"Underflow", -10, 10, "0%"},
|
|
19
|
+
{"Overflow", 110, 10, "100%"},
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
for _, tt := range tests {
|
|
23
|
+
t.Run(tt.name, func(t *testing.T) {
|
|
24
|
+
got := RenderProgressBar(tt.percent, tt.width)
|
|
25
|
+
if !strings.Contains(got, tt.contains) {
|
|
26
|
+
t.Errorf("RenderProgressBar() = %q, want it to contain %q", got, tt.contains)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"strings"
|
|
6
|
+
|
|
7
|
+
"github.com/charmbracelet/lipgloss"
|
|
8
|
+
"github.com/jeancodogno/specforce-kit/src/internal/spec"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// RenderSpecStatus renders a checklist of the spec artifacts for a given slug.
|
|
12
|
+
func RenderSpecStatus(status spec.SpecStatus) string {
|
|
13
|
+
var builder strings.Builder
|
|
14
|
+
|
|
15
|
+
// Styles
|
|
16
|
+
successStyle := lipgloss.NewStyle().Foreground(successGreen)
|
|
17
|
+
errorStyle := lipgloss.NewStyle().Foreground(errorRed)
|
|
18
|
+
descStyle := lipgloss.NewStyle().Foreground(textGrey)
|
|
19
|
+
nameStyle := lipgloss.NewStyle().Foreground(textWhite).Bold(true)
|
|
20
|
+
|
|
21
|
+
for _, artifact := range status.Artifacts {
|
|
22
|
+
glyph := errorStyle.Render(EmptyBulletGlyph)
|
|
23
|
+
if artifact.Exists {
|
|
24
|
+
glyph = successStyle.Render(BulletGlyph)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Align columns: Glyph [Name] Description
|
|
28
|
+
name := nameStyle.Render(fmt.Sprintf("%-16s", artifact.Name))
|
|
29
|
+
description := descStyle.Render(artifact.Description)
|
|
30
|
+
|
|
31
|
+
fmt.Fprintf(&builder, " %s %s %s\n", glyph, name, description)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return builder.String()
|
|
35
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
|
|
6
|
+
"github.com/charmbracelet/bubbles/spinner"
|
|
7
|
+
tea "github.com/charmbracelet/bubbletea"
|
|
8
|
+
"github.com/charmbracelet/lipgloss"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// NeonSpinner represents a styled progress indicator with a mandatory label.
|
|
12
|
+
type NeonSpinner struct {
|
|
13
|
+
spinner spinner.Model
|
|
14
|
+
label string
|
|
15
|
+
done bool
|
|
16
|
+
err error
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// NewNeonSpinner creates a new spinner with the specified label.
|
|
20
|
+
func NewNeonSpinner(label string) NeonSpinner {
|
|
21
|
+
s := spinner.New()
|
|
22
|
+
s.Spinner = spinner.Dot
|
|
23
|
+
s.Style = lipgloss.NewStyle().Foreground(brandCyan)
|
|
24
|
+
return NeonSpinner{
|
|
25
|
+
spinner: s,
|
|
26
|
+
label: label,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Init initializes the spinner animation.
|
|
31
|
+
func (m NeonSpinner) Init() tea.Cmd {
|
|
32
|
+
return m.spinner.Tick
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Update handles spinner animation ticks.
|
|
36
|
+
func (m NeonSpinner) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
37
|
+
switch msg := msg.(type) {
|
|
38
|
+
case spinner.TickMsg:
|
|
39
|
+
var cmd tea.Cmd
|
|
40
|
+
m.spinner, cmd = m.spinner.Update(msg)
|
|
41
|
+
return m, cmd
|
|
42
|
+
default:
|
|
43
|
+
return m, nil
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// View renders the spinner and its label.
|
|
48
|
+
func (m NeonSpinner) View() string {
|
|
49
|
+
if m.done {
|
|
50
|
+
return fmt.Sprintf(" %s %s\n", SuccessStyle.Render("✓"), m.label)
|
|
51
|
+
}
|
|
52
|
+
if m.err != nil {
|
|
53
|
+
return fmt.Sprintf(" %s %s\n", ErrorStyle.Render("✖"), m.label)
|
|
54
|
+
}
|
|
55
|
+
return fmt.Sprintf(" %s %s\n", m.spinner.View(), m.label)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// SetDone marks the operation as successfully completed.
|
|
59
|
+
func (m *NeonSpinner) SetDone() {
|
|
60
|
+
m.done = true
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// SetError marks the operation as failed with an error.
|
|
64
|
+
func (m *NeonSpinner) SetError(err error) {
|
|
65
|
+
m.err = err
|
|
66
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package tui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
|
|
6
|
+
"github.com/mattn/go-isatty"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// IsTTY returns true if the standard output is a terminal.
|
|
10
|
+
func IsTTY() bool {
|
|
11
|
+
return isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// GetTerminalWidth returns the current width of the terminal.
|
|
15
|
+
func GetTerminalWidth() int {
|
|
16
|
+
// Simplified implementation, could use golang.org/x/term
|
|
17
|
+
return 80 // Default fallback
|
|
18
|
+
}
|