Skip to content

Commit 8eaa243

Browse files
committed
Retask
1 parent ff48a5e commit 8eaa243

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+6912
-758
lines changed

.kiro/specs/sai-cli-application/design.md

Lines changed: 400 additions & 1 deletion
Large diffs are not rendered by default.

.kiro/specs/sai-cli-application/requirements.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,87 @@ The SAI CLI application is a lightweight command-line tool for executing softwar
126126
2. WHEN multiple providers are used THEN the system SHALL display the provider name with a configurable background color
127127
3. WHEN a command is executed THEN the system SHALL show the output in normal text followed by highlighted exit status (Green for success, Red for failure)
128128
4. WHEN any executed command fails THEN the sai command exit code SHALL be 1 AND WHEN all commands succeed THEN the exit code SHALL be 0
129-
5. WHEN validating commands THEN the system SHALL only show and execute commands that can be executed AND SHALL NOT attempt to run commands with unavailable providers or on non-existent software
129+
5. WHEN validating commands THEN the system SHALL only show and execute commands that can be executed AND SHALL NOT attempt to run commands with unavailable providers or on non-existent software
130+
131+
### Requirement 11
132+
133+
**User Story:** As a system administrator, I want automatic saidata repository management, so that I can use SAI without manual setup and always have up-to-date software definitions.
134+
135+
#### Acceptance Criteria
136+
137+
1. WHEN SAI is executed for the first time THEN the system SHALL display a relevant message about downloading saidata repository
138+
2. WHEN running as a normal user THEN the system SHALL download saidata to $HOME/.sai/saidata directory
139+
3. WHEN running as root THEN the system SHALL download saidata to /etc/sai/saidata directory (or Windows equivalent)
140+
4. WHEN downloading saidata THEN the system SHALL use Git clone as the primary method with zip download as fallback
141+
5. WHEN the `sai saidata` command is executed THEN the system SHALL provide saidata management operations including update, status, and synchronization
142+
143+
### Requirement 12
144+
145+
**User Story:** As a developer, I want detailed debug information when troubleshooting SAI issues, so that I can diagnose problems effectively.
146+
147+
#### Acceptance Criteria
148+
149+
1. WHEN the `--debug` flag is provided THEN the system SHALL display detailed debug information including provider detection, template resolution, and command execution details
150+
2. WHEN debug mode is enabled THEN the system SHALL show internal state information, configuration loading, and decision-making processes
151+
3. WHEN debug mode is enabled THEN the system SHALL log all template variable resolutions and provider selection logic
152+
4. WHEN debug mode is enabled THEN the system SHALL display timing information for operations and performance metrics
153+
154+
### Requirement 13
155+
156+
**User Story:** As a system administrator, I want accurate provider detection and system statistics, so that I can understand which providers are actually available on my system.
157+
158+
#### Acceptance Criteria
159+
160+
1. WHEN `sai stats` is executed THEN the system SHALL only show providers that are actually available based on executable detection
161+
2. WHEN a provider defines an `executable` field THEN the system SHALL use that executable to determine provider availability
162+
3. WHEN provider detection fails THEN the system SHALL not list that provider as available in stats output
163+
4. WHEN multiple providers are available THEN the system SHALL show accurate availability status for each provider
164+
165+
### Requirement 14
166+
167+
**User Story:** As a system administrator, I want to check software versions using SAI's version command, so that I can see installed software versions across different providers.
168+
169+
#### Acceptance Criteria
170+
171+
1. WHEN `sai version <software>` is executed THEN the system SHALL show the version of the software if installed for all available providers
172+
2. WHEN a provider has a version action defined THEN the system SHALL use that action's command to retrieve version information
173+
3. WHEN `sai --version` is executed THEN the system SHALL show SAI's own version information
174+
4. WHEN software is not installed THEN the system SHALL indicate that the software is not installed for that provider
175+
5. WHEN version information cannot be retrieved THEN the system SHALL show an appropriate error message
176+
177+
### Requirement 15
178+
179+
**User Story:** As a system administrator, I want compact and informative output when multiple providers are available, so that I can quickly understand my options and make informed decisions.
180+
181+
#### Acceptance Criteria
182+
183+
1. WHEN multiple providers are available for an action THEN the system SHALL display provider name and the full command that will be executed
184+
2. WHEN showing provider options THEN the system SHALL display "Command: (The full command executed/to execute to get the output)" instead of package/version/description
185+
3. WHEN an action only displays information and doesn't modify the system THEN the system SHALL execute the command for each available provider without asking for selection
186+
4. WHEN an action modifies the system THEN the system SHALL still prompt for provider selection
187+
5. WHEN displaying provider options THEN the system SHALL show availability status for each provider
188+
189+
### Requirement 16
190+
191+
**User Story:** As a system administrator, I want all SAI actions to work correctly, so that I can actually manage software using the tool.
192+
193+
#### Acceptance Criteria
194+
195+
1. WHEN any SAI command is executed THEN the system SHALL successfully complete the requested action without errors
196+
2. WHEN template resolution occurs THEN all saidata template functions SHALL resolve correctly to actual values
197+
3. WHEN provider actions are executed THEN the commands SHALL be properly constructed and executed
198+
4. WHEN saidata is loaded THEN the system SHALL correctly parse and use the software definitions
199+
5. WHEN providers are loaded THEN the system SHALL correctly parse and execute provider actions
200+
6. WHEN any action fails THEN the system SHALL provide clear error messages indicating what went wrong and how to fix it
201+
202+
### Requirement 17
203+
204+
**User Story:** As a system administrator, I want consistent naming for packages and services in saidata and providers, so that template functions work predictably across all configurations.
205+
206+
#### Acceptance Criteria
207+
208+
1. WHEN defining packages in saidata THEN the system SHALL use `package_name` parameter instead of `name` for package identification
209+
2. WHEN using template functions THEN `sai_package()` SHALL reference the `package_name` field consistently
210+
3. WHEN using template functions THEN `sai_service()` SHALL continue to reference the `service_name` field as before
211+
4. WHEN updating providers THEN all existing provider templates SHALL be updated to use `package_name` instead of `name`
212+
5. WHEN updating schemas THEN the saidata schema SHALL be updated to require `package_name` field for packages

.kiro/specs/sai-cli-application/tasks.md

Lines changed: 105 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,110 @@
11
# Implementation Plan
22

3-
- [x] 1. Set up Go project structure and core dependencies
4-
- Initialize Go module with proper project structure (cmd/, internal/, pkg/)
5-
- Add Cobra CLI framework, YAML parsing (gopkg.in/yaml.v3), and logging dependencies
6-
- Create main.go entry point and basic CLI structure
7-
- Set up build configuration (Makefile) for cross-platform compilation
8-
- _Requirements: 7.1, 7.2, 8.1_
3+
## Phase 1: Fix Core Functionality (Critical)
4+
5+
- [x] 1. Diagnose and fix template resolution system
6+
- Analyze current template engine implementation and identify why sai_package(), sai_service() functions fail
7+
- Fix template function registration and context passing to ensure saidata is available
8+
- Update template functions to properly access package_name field instead of name field
9+
- Add comprehensive error handling for template resolution failures with clear error messages
10+
- Create unit tests that verify template functions work with existing saidata samples
11+
- _Requirements: 16.2, 16.3, 17.2, 17.3_
12+
13+
- [x] 2. Fix provider loading and validation system
14+
- Debug current provider YAML loading to identify parsing failures
15+
- Fix YAML unmarshaling for all existing provider files (apt.yaml, brew.yaml, docker.yaml, etc.)
16+
- Implement proper schema validation against providerdata-0.1-schema.json
17+
- Add error handling for malformed provider files with specific error messages
18+
- Verify all existing providers load correctly and actions are accessible
19+
- _Requirements: 16.4, 16.5_
20+
21+
- [x] 3. Fix saidata loading and parsing system
22+
- Debug current saidata loading from docs/saidata_samples/ directory
23+
- Fix hierarchical loading (software/{prefix}/{software}/default.yaml pattern)
24+
- Implement proper OS-specific override loading and merging
25+
- Add schema validation against saidata-0.2-schema.json with clear error messages
26+
- Verify existing saidata samples (apache, elasticsearch, etc.) load correctly
27+
- _Requirements: 16.4, 16.5_
28+
29+
- [x] 4. Fix command execution and provider action system
30+
- Debug why provider actions fail to execute properly
31+
- Fix command template rendering with proper saidata context
32+
- Implement proper command execution with error handling and output capture
33+
- Add validation to ensure commands are executable before attempting to run them
34+
- Create comprehensive logging for command execution failures
35+
- _Requirements: 16.1, 16.3, 16.6_
36+
37+
## Phase 2: Implement Missing Core Features
38+
39+
- [x] 5. Implement automatic saidata management
40+
- Create saidata bootstrap system that detects first-time usage
41+
- Implement automatic download to $HOME/.sai/saidata (user) or /etc/sai/saidata (root)
42+
- Add Git clone functionality with zip download fallback
43+
- Create welcome message display for first-time users
44+
- Implement `sai saidata` command for repository management (update, status, sync)
45+
- _Requirements: 11.1, 11.2, 11.3, 11.4, 11.5_
46+
47+
- [x] 6. Fix provider detection system
48+
- Implement proper executable-based provider detection using provider.executable field
49+
- Fix provider availability checking to prevent showing unavailable providers (like apt on macOS)
50+
- Update `sai stats` command to only show actually available providers
51+
- Add provider detection caching for performance
52+
- Create comprehensive provider detection logging for debugging
53+
- _Requirements: 13.1, 13.2, 13.3, 13.4_
54+
55+
- [x] 7. Implement debug system
56+
- Add --debug flag to root command with comprehensive debug logging
57+
- Implement debug logging for provider detection, template resolution, command execution
58+
- Add performance timing and metrics collection in debug mode
59+
- Create debug output for configuration loading and decision-making processes
60+
- Add internal state logging for troubleshooting complex issues
61+
- _Requirements: 12.1, 12.2, 12.3, 12.4_
62+
63+
## Phase 3: Improve User Experience
64+
65+
- [x] 8. Fix and improve version command functionality
66+
- Separate `sai --version` (SAI version) from `sai version <software>` (software version)
67+
- Implement proper software version checking using provider version actions
68+
- Add support for showing version across all available providers
69+
- Display installation status alongside version information
70+
- Add proper error handling when version information cannot be retrieved
71+
- _Requirements: 14.1, 14.2, 14.3, 14.4, 14.5_
72+
73+
- [x] 9. Improve output formatting and provider selection
74+
- Update provider selection UI to show actual commands instead of package details
75+
- Implement automatic execution for information-only commands (search, info, status, etc.)
76+
- Add compact output format showing "Command: (full command)" for each provider
77+
- Maintain provider selection prompts only for system-changing operations
78+
- Update output formatting to be more concise and informative
79+
- _Requirements: 15.1, 15.2, 15.3, 15.4, 15.5_
80+
81+
## Phase 4: Data Structure Consistency
82+
83+
- [ ] 10. Standardize package naming across all components
84+
- Update saidata-0.2-schema.json to require package_name field for packages
85+
- Update all existing saidata samples to use package_name instead of name
86+
- Update all provider templates to reference package_name consistently
87+
- Update template functions to use package_name field for package resolution
88+
- Verify all existing providers work with updated package_name structure
89+
- _Requirements: 17.1, 17.2, 17.4, 17.5_
90+
91+
## Phase 5: Testing and Validation
92+
93+
- [ ] 11. Create comprehensive test suite for fixed functionality
94+
- Write integration tests that verify all basic SAI commands work (install, status, version, etc.)
95+
- Create tests using existing provider files and saidata samples
96+
- Add tests for template resolution with real saidata
97+
- Implement tests for provider detection across different platforms
98+
- Create end-to-end tests that verify complete workflows work correctly
99+
- _Requirements: 16.1, 16.2, 16.3, 16.4, 16.5, 16.6_
100+
101+
- [ ] 12. Add error handling and recovery systems
102+
- Implement comprehensive error handling with clear, actionable error messages
103+
- Add error context and suggestions for common failure scenarios
104+
- Create recovery mechanisms for transient failures
105+
- Add validation systems that prevent execution when resources don't exist
106+
- Implement graceful degradation when providers or saidata are unavailable
107+
- _Requirements: 16.6_
9108

10109
- [x] 2. Implement core data structures and YAML parsing
11110
- [x] 2.1 Create provider data structures matching existing YAML files

docs/saidata_samples/ap/apache/centos/8.yaml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ version: "0.2"
33
# CentOS 8-specific overrides for Apache HTTP Server
44
# This file demonstrates OS-specific configuration that gets deep-merged with default.yaml
55

6+
metadata:
7+
name: "apache"
8+
69
packages:
710
- name: "httpd" # CentOS uses 'httpd' instead of 'apache2'
811
version: "2.4.37-43.module_el8.5.0+1022+b541f3b1"
@@ -95,39 +98,28 @@ providers:
9598
"ca-certificates",
9699
"centos-release" # CentOS-specific release package
97100
]
98-
post_install_commands: [
99-
"systemctl enable httpd",
100-
"systemctl start httpd",
101-
"firewall-cmd --permanent --add-service=http", # CentOS firewall
102-
"firewall-cmd --permanent --add-service=https",
103-
"firewall-cmd --reload"
104-
]
101+
105102
services:
106103
- name: "apache"
107104
service_name: "httpd"
108105
type: "systemd"
109106
enabled: true
110-
centos_selinux: true # CentOS-specific SELinux consideration
107+
111108
repositories:
112109
- name: "appstream"
113110
url: "http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/"
114111
key: "RPM-GPG-KEY-centosofficial"
115112
type: "os-default"
116113
components: ["appstream"]
117-
centos_stream: true
118114

119115
# CentOS 8-specific compatibility
120116
compatibility:
121117
matrix:
122118
- provider: "dnf"
123119
platform: ["linux"]
124-
os: ["centos"]
125120
architecture: ["x86_64", "aarch64"]
126121
os_version: ["8"]
127122
supported: true
128123
notes: "Native CentOS 8 package with SELinux integration"
129124
tested: true
130-
recommended: true
131-
centos_stream: true
132-
selinux_support: true
133-
package_version: "2.4.37-43.module_el8.5.0+1022+b541f3b1"
125+
recommended: true

docs/saidata_samples/ap/apache/macos/13.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ version: "0.2"
33
# macOS 13-specific overrides for Apache HTTP Server
44
# This file demonstrates OS-specific configuration that gets deep-merged with default.yaml
55

6+
metadata:
7+
name: "apache"
8+
69
packages:
710
- name: "httpd" # macOS uses 'httpd' instead of 'apache2'
811
version: "2.4.58"
@@ -79,12 +82,12 @@ providers:
7982
service_name: "httpd"
8083
type: "launchd"
8184
enabled: false # Don't auto-start on macOS
82-
plist_path: "/opt/homebrew/etc/httpd/org.apache.httpd.plist"
85+
8386
files:
8487
- name: "config"
8588
path: "/opt/homebrew/etc/httpd/httpd.conf"
8689
type: "config"
87-
template: "macos-httpd.conf.j2" # macOS-specific template
90+
8891
directories:
8992
- name: "config"
9093
path: "/opt/homebrew/etc/httpd"
@@ -93,18 +96,16 @@ providers:
9396
commands:
9497
- name: "httpd"
9598
path: "/opt/homebrew/bin/httpd"
96-
shell_integration: "zsh" # macOS default shell
99+
97100

98101
# macOS 13-specific compatibility matrix
99102
compatibility:
100103
matrix:
101104
- provider: "brew"
102-
os: "macos" # Changed from 'platform' to 'os'
105+
platform: "macos"
103106
architecture: ["x86_64", "arm64"]
104107
os_version: ["13.0"]
105108
supported: true
106109
notes: "Recommended installation method for macOS 13"
107110
tested: true
108111
recommended: true
109-
homebrew_formula: "httpd"
110-
minimum_macos: "13.0"

0 commit comments

Comments
 (0)