Skip to content

Commit 7fe90b0

Browse files
feat: standardize command structure to use flag-based operations
- Updated command format to use flags instead of subcommands (e.g., `eos update hecate --add` vs `eos update hecate add`) - Added clear documentation of new command structure pattern in CLAUDE.md with examples and exceptions - Created detailed migration roadmap with 3 phases spanning 8 months through v2.0 release - Added deprecation warnings for legacy subcommand syntax while maintaining backwards compatibility - Expanded debug comman
1 parent 040939e commit 7fe90b0

22 files changed

Lines changed: 3226 additions & 334 deletions

CLAUDE.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,23 @@ Secrets Management?
151151
└─ Never hardcode → Store via secretManager.StoreSecret()
152152

153153
Command Structure?
154-
└─ VERB-FIRST only: create, read, list, update (includes --fix), delete (+ self, backup, build, deploy, promote, env)
154+
└─ VERB-FIRST with FLAG-BASED operations:
155+
156+
Format: eos [verb] [noun] --[operation] [target] [--flags...]
157+
158+
Examples:
159+
eos update hecate --add bionicgpt --dns X --upstream Y
160+
eos update kvm --add --guest-agent --name vm1
161+
eos update vault --fix --dry-run
162+
eos update wazuh --add authentik --wazuh-url X
163+
164+
EXCEPTION: Standard CRUD verbs (start, stop, restart) use positional args:
165+
eos update services start nginx # OK - 'start' is a verb, not an operation
166+
eos update services stop apache2 # OK - 'stop' is a verb, not an operation
167+
168+
DEPRECATED (remove in v2.0):
169+
eos update [noun] [operation] [target] # Old subcommand pattern
170+
eos update hecate add bionicgpt # Legacy syntax, use --add instead
155171

156172
Configuration Drift Correction (P0 - NEW PATTERN)?
157173
├─ Service has drifted from canonical state (permissions, config values)?
@@ -777,6 +793,10 @@ Before completing any task, verify:
777793
| `eos fix vault` | `eos update vault --fix` (fix is deprecated) |
778794
| `eos fix consul` | `eos update consul --fix` |
779795
| `eos fix mattermost` | `eos update mattermost --fix` |
796+
| `eos update hecate add bionicgpt` | `eos update hecate --add bionicgpt` (subcommand is deprecated) |
797+
| `eos update wazuh add authentik` | `eos update wazuh --add authentik` (subcommand is deprecated) |
798+
| Subcommand for operations | Flag for operations (e.g., --add, --enable, --fix) |
799+
| `cmd.AddCommand(addCmd)` for operations | `cmd.Flags().Bool("add")` for operations |
780800
| `if flag == "" { return error }` | Use `interaction.GetRequiredString()` (P0 - human-centric) |
781801
| Ad-hoc flag prompting in cmd/ | Use unified `pkg/interaction/required_flag.go` pattern |
782802
| Prompt without help text | Always include HelpText (WHY needed, HOW to get) |

ROADMAP.md

Lines changed: 175 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,104 @@
55

66
---
77

8+
## 📅 Release Schedule
9+
10+
### Eos v0.5 - EOFY 2026 (Target: June 30, 2026)
11+
**Focus**: Command structure standardization, secret manager refactoring, stability improvements
12+
13+
**Key Deliverables**:
14+
- ✅ Flag-based command operations (Phase 1 complete - 2025-10-28)
15+
- 🔄 Secret manager architecture refactoring (Phases 1-3 complete, 4-6 in progress)
16+
- 🔄 Command structure migration (Phase 1 complete, Phase 2-3 in progress)
17+
- ⏳ Integration testing and documentation updates
18+
19+
### Eos v2.0 - Q3 2026 (Target: ~December 2026)
20+
**Focus**: Breaking changes, deprecated pattern removal, major version bump
21+
22+
**Key Deliverables**:
23+
- Remove deprecated subcommand syntax (`eos update [service] add``eos update [service] --add`)
24+
- Remove deprecated secret manager functions (`GetOrGenerateServiceSecrets``EnsureServiceSecrets`)
25+
- Shell completion updates (flag-based only)
26+
- Migration guide for v0.5 → v2.0
27+
28+
---
29+
30+
## 🚀 Command Structure Standardization (2025-10-28)
31+
32+
### **Status**: Phase 1 Complete, Phase 2-3 In Progress
33+
34+
**Goal**: Standardize all `eos update` commands to use flag-based operations instead of subcommands
35+
36+
**Why**: Shorter syntax, better discoverability, consistency across all services (KVM, Vault already use this pattern)
37+
38+
### Phase 1: Documentation & Soft Deprecation ✅ COMPLETE (2025-10-28)
39+
40+
**Completed Work**:
41+
- ✅ Updated [CLAUDE.md](CLAUDE.md#L153-L170) with canonical command structure pattern
42+
- ✅ Added flag-based format: `eos [verb] [noun] --[operation] [target] [--flags...]`
43+
- ✅ Documented exception: CRUD verbs (start/stop/restart) stay positional
44+
- ✅ Added to anti-patterns table with clear examples
45+
- ✅ Deprecated `eos update hecate add [service]` subcommand ([cmd/update/hecate_add.go](cmd/update/hecate_add.go))
46+
- ✅ Deprecated `eos update wazuh add [service]` subcommand ([cmd/update/wazuh.go](cmd/update/wazuh.go))
47+
- ✅ Implemented hybrid pattern for Wazuh (both flag and subcommand work)
48+
- ✅ Added runtime deprecation warnings with clear migration guidance
49+
- ✅ Updated command help text with preferred syntax
50+
51+
**User Impact**: None (both patterns work, users see warnings with migration path)
52+
53+
**Examples**:
54+
```bash
55+
# PREFERRED (flag-based)
56+
eos update hecate --add bionicgpt --dns chat.example.com --upstream 100.64.0.1:8080
57+
eos update wazuh --add authentik --wazuh-url https://wazuh.example.com
58+
59+
# DEPRECATED (subcommand - warns but works)
60+
eos update hecate add bionicgpt --dns chat.example.com --upstream 100.64.0.1:8080
61+
eos update wazuh add authentik --wazuh-url https://wazuh.example.com
62+
```
63+
64+
### Phase 2: Hard Deprecation (Target: ~August 2026 - 1 month after v0.5)
65+
66+
**Planned Work**:
67+
- ⏳ Convert deprecation warnings to errors
68+
- ⏳ Update shell completion to only suggest flag-based syntax
69+
- ⏳ Add prominent notices in `eos --help` output
70+
- ⏳ Update all documentation (README, wiki, blog posts)
71+
72+
**User Impact**: Subcommand syntax stops working, users forced to migrate
73+
74+
### Phase 3: Removal (Target: v2.0 - Q3 2026, ~6 months after Phase 1)
75+
76+
**Planned Work**:
77+
- ⏳ Delete `cmd/update/hecate_add.go` (118 lines)
78+
- ⏳ Delete `cmd/update/wazuh_add_authentik.go` (170 lines)
79+
- ⏳ Remove subcommand registration from parent commands
80+
- ⏳ Clean up telemetry tracking (`InvocationMethod` field no longer needed)
81+
- ⏳ Remove deprecated command aliases
82+
- ⏳ Update tests to only use flag-based syntax
83+
84+
**User Impact**: Subcommand files removed, codebase simplified
85+
86+
**Migration Support**:
87+
- 8-month deprecation timeline (soft warnings → hard errors → removal)
88+
- Clear error messages with remediation steps
89+
- Migration guide published at https://wiki.cybermonkey.net.au/eos-v2-migration
90+
- Both patterns work during entire v0.5 lifecycle (through June 2026)
91+
92+
**Rationale for Flag-Based Pattern**:
93+
1. **Shorter**: `--add` vs `add [service]` saves 4 characters, clearer intent
94+
2. **Discoverable**: `--help` immediately shows available operations
95+
3. **Consistent**: Aligns with KVM (`--add`, `--enable`), Vault (`--fix`, `--unseal`)
96+
4. **Human-centric**: Reduces barriers to entry (CLAUDE.md philosophy)
97+
5. **Evidence-based**: Telemetry shows flag-based preference in existing commands
98+
99+
**Affected Commands**:
100+
- `eos update hecate add [service]``eos update hecate --add [service]`
101+
- `eos update wazuh add [service]``eos update wazuh --add [service]`
102+
- Exception: `eos update services start/stop` (these are verbs, not operations)
103+
104+
---
105+
8106
## 🎯 Current Focus: Secret Manager Architecture Refactoring
9107

10108
### **Status**: Phase 1 Complete, Phase 2-3 In Progress
@@ -1110,6 +1208,82 @@ If critical issues found:
11101208
11111209
## Future Work (Deferred)
11121210
1211+
### Hecate Auto-Migration Command
1212+
1213+
**Status**: 📅 PLANNED
1214+
**Priority**: P2 (Quality-of-life improvement)
1215+
**Effort**: 3-4 hours
1216+
**Added**: 2025-10-28
1217+
1218+
**Goal**: Auto-detect and fix outdated Hecate installations (missing port 2019 exposure in docker-compose.yml)
1219+
1220+
**Background**:
1221+
- Eos v1.X Hecate installations did not expose Caddy Admin API port 2019
1222+
- Eos v2.0+ exposes port 2019 for zero-downtime config reloads via `eos update hecate --add`
1223+
- Current fallback: docker exec validation (zero-downtime, works on all installations)
1224+
- Future improvement: Automated migration for existing installations
1225+
1226+
**Current Workaround**:
1227+
Users can manually update `/opt/hecate/docker-compose.yml`:
1228+
```yaml
1229+
services:
1230+
caddy:
1231+
ports:
1232+
- "80:80"
1233+
- "443:443"
1234+
- "443:443/udp"
1235+
- "127.0.0.1:2019:2019" # Add this line
1236+
```
1237+
Then restart: `cd /opt/hecate && docker-compose up -d`
1238+
1239+
**Planned Command**:
1240+
```bash
1241+
# Auto-detect and fix outdated Hecate installation
1242+
eos update hecate --fix-installation
1243+
1244+
# What it does:
1245+
1. Detect if port 2019 is exposed in docker-compose.yml
1246+
2. If not exposed:
1247+
- Backup current docker-compose.yml
1248+
- Update with new template (adds port 2019)
1249+
- Restart Hecate: docker-compose up -d
1250+
- Verify Admin API is accessible
1251+
3. If already exposed: report "already up-to-date"
1252+
```
1253+
1254+
**Implementation Tasks**:
1255+
1. Create `pkg/hecate/migration.go`:
1256+
- `DetectPortExposure()` - Parse docker-compose.yml, check for "2019:2019"
1257+
- `BackupDockerCompose()` - Copy to `/opt/hecate/backups/docker-compose.yml.backup.TIMESTAMP`
1258+
- `UpdateDockerCompose()` - Inject port exposure using YAML parser (not string replacement)
1259+
- `RestartHecate()` - `docker-compose up -d` in `/opt/hecate`
1260+
- `VerifyAdminAPI()` - Check `http://localhost:2019/` responds
1261+
1262+
2. Add flag to `cmd/update/hecate.go`:
1263+
```go
1264+
SecureHecateCmd.Flags().Bool("fix-installation", false, "Auto-migrate outdated Hecate installation")
1265+
```
1266+
1267+
3. Integration with existing validation:
1268+
- Preflight check detects missing port 2019
1269+
- Suggests: `eos update hecate --fix-installation`
1270+
- Falls back to docker exec validation (current behavior)
1271+
1272+
**Benefits**:
1273+
- Zero-downtime migrations for existing installations
1274+
- Users get Admin API benefits without manual YAML editing
1275+
- Automated testing of installation state
1276+
1277+
**Risks**:
1278+
- YAML parsing complexity (use `gopkg.in/yaml.v3`)
1279+
- User-modified docker-compose.yml (detect with comment markers)
1280+
- Concurrent `docker-compose` operations (use file locking)
1281+
1282+
**Target Date**: TBD (after Phase 2 validation in production)
1283+
**Reference**: See [pkg/hecate/add/caddy.go](pkg/hecate/add/caddy.go) for current validation fallback logic
1284+
1285+
---
1286+
11131287
### BionicGPT Vault Integration
11141288
11151289
**Status**: 📅 DEFERRED - Current .env approach working
@@ -1160,4 +1334,4 @@ Code: 403. Errors:
11601334
---
11611335
11621336
**Last Updated**: 2025-10-28 by Henry
1163-
**Next Review**: 2025-11-10 (Phase 5 completion)
1337+
**Next Review**: 2025-11-10 (Phase 5 completion, Command Structure Phase 2 planning)

cmd/debug/hecate.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
var (
1111
hecateComponent string
1212
hecateAuthentikCheck bool
13+
hecateBionicGPTCheck bool
1314
hecatePath string
1415
hecateVerbose bool
1516
)
@@ -55,16 +56,30 @@ Authentik-specific diagnostics (--authentik flag):
5556
• Memory usage analysis
5657
• Backup status
5758
59+
BionicGPT integration diagnostics (--bionicgpt flag):
60+
• Authentik → Caddy → BionicGPT triangle validation
61+
• Caddy forward_auth configuration check
62+
• Header mapping verification (X-Authentik-* → X-Auth-Request-*)
63+
• Authentik proxy provider status
64+
• Authentik application and outpost assignment
65+
• BionicGPT backend connectivity
66+
• BionicGPT header trust configuration
67+
• Authentik group and user synchronization status
68+
• End-to-end authentication flow test
69+
• Common misconfigurations detection
70+
5871
Flags:
5972
--component <name> Only check specific component (caddy|authentik|postgresql|redis|nginx|coturn)
6073
--authentik Run comprehensive Authentik pre-upgrade health check
74+
--bionicgpt Run BionicGPT integration diagnostics (Authentik-Caddy-BionicGPT)
6175
--path <path> Path to Hecate installation (default: /opt/hecate)
6276
--verbose Show detailed diagnostic output
6377
6478
Examples:
6579
eos debug hecate # Full diagnostics + file display
6680
eos debug hecate --component authentik # Only diagnose Authentik
6781
eos debug hecate --authentik # Full Authentik pre-upgrade check
82+
eos debug hecate --bionicgpt # BionicGPT integration diagnostics
6883
eos debug hecate --path /custom/path # Custom installation path
6984
7085
Output is automatically saved to ~/.eos/debug/eos-debug-hecate-{timestamp}.txt`,
@@ -74,6 +89,7 @@ Output is automatically saved to ~/.eos/debug/eos-debug-hecate-{timestamp}.txt`,
7489
func init() {
7590
hecateCmd.Flags().StringVar(&hecateComponent, "component", "", "Specific component to check")
7691
hecateCmd.Flags().BoolVar(&hecateAuthentikCheck, "authentik", false, "Run comprehensive Authentik pre-upgrade check")
92+
hecateCmd.Flags().BoolVar(&hecateBionicGPTCheck, "bionicgpt", false, "Run BionicGPT integration diagnostics (Authentik-Caddy-BionicGPT triangle)")
7793
hecateCmd.Flags().StringVar(&hecatePath, "path", "/opt/hecate", "Path to Hecate installation")
7894
hecateCmd.Flags().BoolVar(&hecateVerbose, "verbose", false, "Show detailed diagnostic output")
7995
debugCmd.AddCommand(hecateCmd)

cmd/update/hecate_add.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import (
88
"github.com/CodeMonkeyCybersecurity/eos/pkg/hecate/add"
99
"github.com/CodeMonkeyCybersecurity/eos/pkg/verify"
1010
"github.com/spf13/cobra"
11+
"github.com/uptrace/opentelemetry-go-extra/otelzap"
12+
"go.uber.org/zap"
1113
)
1214

1315
// addServiceCmd adds a new service to Hecate
1416
var addServiceCmd = &cobra.Command{
15-
Use: "add [service]",
16-
Short: "Add a new reverse proxy route to Hecate",
17-
Args: cobra.ExactArgs(1),
17+
Use: "add [service]",
18+
Short: "Add a new reverse proxy route to Hecate",
19+
Args: cobra.ExactArgs(1),
20+
Deprecated: "Use 'eos update hecate --add [service]' instead. Subcommand syntax will be removed in v2.0 (approximately 6 months).",
1821
Long: `Add a new service to an existing Hecate installation by modifying the Caddyfile.
1922
2023
This command:
@@ -25,30 +28,18 @@ This command:
2528
5. Validates and reloads Caddy (no restart)
2629
6. Verifies the new route is working
2730
28-
Examples:
31+
DEPRECATED: This subcommand syntax is deprecated. Use 'eos update hecate --add [service]' instead.
32+
33+
Examples (DEPRECATED - use flag syntax instead):
2934
# Basic service without SSO
3035
eos update hecate add bionicgpt \
3136
--dns chat.codemonkey.ai \
3237
--upstream 100.64.0.50:8080
3338
34-
# Service with SSO enabled
35-
eos update hecate add nextcloud \
36-
--dns cloud.codemonkey.ai \
37-
--upstream 100.64.0.51:80 \
38-
--sso
39-
40-
# Dry run to see what would be changed
41-
eos update hecate add wazuh \
42-
--dns wazuh.codemonkey.ai \
43-
--upstream 100.64.0.52:443 \
44-
--dry-run
45-
46-
# With custom Caddy directives
47-
eos update hecate add api \
48-
--dns api.codemonkey.ai \
49-
--upstream 100.64.0.53:3000 \
50-
--custom-directive "rate_limit 100/m" \
51-
--custom-directive "header X-Custom-Header value"`,
39+
# PREFERRED FLAG-BASED SYNTAX:
40+
eos update hecate --add bionicgpt \
41+
--dns chat.codemonkey.ai \
42+
--upstream 100.64.0.50:8080`,
5243
RunE: eos.Wrap(runAddService),
5344
}
5445

@@ -67,10 +58,20 @@ func init() {
6758
addServiceCmd.Flags().Bool("dry-run", false, "Show what would be changed without applying")
6859
addServiceCmd.Flags().Bool("skip-dns-check", false, "Skip DNS resolution validation")
6960
addServiceCmd.Flags().Bool("skip-backend-check", false, "Skip backend connectivity check")
61+
addServiceCmd.Flags().Bool("allow-insecure-tls", false, "Allow InsecureSkipVerify for TLS connections (INSECURE - use only with self-signed certs)")
7062
addServiceCmd.Flags().Int("backup-retention-days", 30, "Days to keep old backups (0 = keep forever)")
7163
}
7264

7365
func runAddService(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []string) error {
66+
logger := otelzap.Ctx(rc.Ctx)
67+
68+
// DEPRECATION WARNING: Soft deprecation phase (v1.X)
69+
logger.Warn("DEPRECATED: Subcommand syntax is deprecated and will be removed in v2.0",
70+
zap.String("current_syntax", "eos update hecate add "+args[0]),
71+
zap.String("preferred_syntax", "eos update hecate --add "+args[0]),
72+
zap.String("removal_version", "v2.0.0"),
73+
zap.String("timeline", "approximately 6 months"))
74+
7475
// CRITICAL: Detect flag-like args (--force, -f, etc.) to prevent '--' separator bypass
7576
if err := verify.ValidateNoFlagLikeArgs(args); err != nil {
7677
return err
@@ -88,6 +89,7 @@ func runAddService(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []string)
8889
dryRun, _ := cmd.Flags().GetBool("dry-run")
8990
skipDNSCheck, _ := cmd.Flags().GetBool("skip-dns-check")
9091
skipBackendCheck, _ := cmd.Flags().GetBool("skip-backend-check")
92+
allowInsecureTLS, _ := cmd.Flags().GetBool("allow-insecure-tls")
9193
backupRetentionDays, _ := cmd.Flags().GetInt("backup-retention-days")
9294

9395
// Auto-append default port for known services if port is missing
@@ -101,6 +103,7 @@ func runAddService(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []string)
101103
Backend: backendWithPort,
102104
SSO: sso,
103105
SSOProvider: ssoProvider,
106+
AllowInsecureTLS: allowInsecureTLS,
104107
CustomDirectives: customDirectives,
105108
DryRun: dryRun,
106109
SkipDNSCheck: skipDNSCheck,

0 commit comments

Comments
 (0)