refactor(cli): restructure cmd packages into subdirectories
- Move CLI commands into subdirectories matching command hierarchy:
dev/, go/, php/, build/, ci/, sdk/, pkg/, vm/, docs/, setup/, doctor/, test/, ai/
- Create shared/ package for common styles and utilities
- Add new `core ai` root command with claude subcommand
- Update package declarations and imports across all files
- Create commands.go entry points for each package
- Remove GUI-related files (moved to core-gui repo)
This makes the filesystem structure match the CLI command structure,
improving context capture and code organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:02:43 +00:00
|
|
|
package php
|
2026-01-28 19:14:06 +00:00
|
|
|
|
|
|
|
|
import (
|
2026-02-01 02:07:26 +00:00
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
|
2026-01-30 10:32:05 +00:00
|
|
|
"github.com/host-uk/core/pkg/cli"
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
"github.com/host-uk/core/pkg/i18n"
|
2026-02-01 02:07:26 +00:00
|
|
|
"github.com/host-uk/core/pkg/workspace"
|
2026-01-30 00:47:54 +00:00
|
|
|
"github.com/spf13/cobra"
|
2026-01-28 19:14:06 +00:00
|
|
|
)
|
|
|
|
|
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
func init() {
|
|
|
|
|
cli.RegisterCommands(AddPHPCommands)
|
|
|
|
|
}
|
|
|
|
|
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
// Style aliases from shared
|
refactor(cli): restructure cmd packages into subdirectories
- Move CLI commands into subdirectories matching command hierarchy:
dev/, go/, php/, build/, ci/, sdk/, pkg/, vm/, docs/, setup/, doctor/, test/, ai/
- Create shared/ package for common styles and utilities
- Add new `core ai` root command with claude subcommand
- Update package declarations and imports across all files
- Create commands.go entry points for each package
- Remove GUI-related files (moved to core-gui repo)
This makes the filesystem structure match the CLI command structure,
improving context capture and code organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:02:43 +00:00
|
|
|
var (
|
2026-01-30 10:32:05 +00:00
|
|
|
successStyle = cli.SuccessStyle
|
|
|
|
|
errorStyle = cli.ErrorStyle
|
|
|
|
|
dimStyle = cli.DimStyle
|
|
|
|
|
linkStyle = cli.LinkStyle
|
refactor(cli): restructure cmd packages into subdirectories
- Move CLI commands into subdirectories matching command hierarchy:
dev/, go/, php/, build/, ci/, sdk/, pkg/, vm/, docs/, setup/, doctor/, test/, ai/
- Create shared/ package for common styles and utilities
- Add new `core ai` root command with claude subcommand
- Update package declarations and imports across all files
- Create commands.go entry points for each package
- Remove GUI-related files (moved to core-gui repo)
This makes the filesystem structure match the CLI command structure,
improving context capture and code organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:02:43 +00:00
|
|
|
)
|
|
|
|
|
|
2026-01-30 01:04:29 +00:00
|
|
|
// Service colors for log output (domain-specific, keep local)
|
2026-01-28 19:14:06 +00:00
|
|
|
var (
|
2026-01-31 23:01:21 +00:00
|
|
|
phpFrankenPHPStyle = cli.NewStyle().Foreground(cli.ColourIndigo500)
|
|
|
|
|
phpViteStyle = cli.NewStyle().Foreground(cli.ColourYellow500)
|
|
|
|
|
phpHorizonStyle = cli.NewStyle().Foreground(cli.ColourOrange500)
|
|
|
|
|
phpReverbStyle = cli.NewStyle().Foreground(cli.ColourViolet500)
|
|
|
|
|
phpRedisStyle = cli.NewStyle().Foreground(cli.ColourRed500)
|
2026-01-28 19:14:06 +00:00
|
|
|
)
|
|
|
|
|
|
2026-01-30 01:04:29 +00:00
|
|
|
// Status styles (from shared)
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
var (
|
2026-01-30 10:32:05 +00:00
|
|
|
phpStatusRunning = cli.SuccessStyle
|
2026-01-31 23:01:21 +00:00
|
|
|
phpStatusStopped = cli.DimStyle
|
2026-01-30 10:32:05 +00:00
|
|
|
phpStatusError = cli.ErrorStyle
|
2026-01-30 01:04:29 +00:00
|
|
|
)
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
|
2026-01-30 01:04:29 +00:00
|
|
|
// QA command styles (from shared)
|
|
|
|
|
var (
|
2026-01-30 10:32:05 +00:00
|
|
|
phpQAPassedStyle = cli.SuccessStyle
|
|
|
|
|
phpQAFailedStyle = cli.ErrorStyle
|
|
|
|
|
phpQAWarningStyle = cli.WarningStyle
|
2026-01-31 23:01:21 +00:00
|
|
|
phpQAStageStyle = cli.HeaderStyle
|
2026-01-30 01:04:29 +00:00
|
|
|
)
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
|
2026-01-30 01:04:29 +00:00
|
|
|
// Security severity styles (from shared)
|
|
|
|
|
var (
|
2026-01-31 23:01:21 +00:00
|
|
|
phpSecurityCriticalStyle = cli.NewStyle().Bold().Foreground(cli.ColourRed500)
|
|
|
|
|
phpSecurityHighStyle = cli.NewStyle().Bold().Foreground(cli.ColourOrange500)
|
|
|
|
|
phpSecurityMediumStyle = cli.NewStyle().Foreground(cli.ColourAmber500)
|
|
|
|
|
phpSecurityLowStyle = cli.NewStyle().Foreground(cli.ColourGray500)
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
)
|
|
|
|
|
|
2026-01-28 19:14:06 +00:00
|
|
|
// AddPHPCommands adds PHP/Laravel development commands.
|
2026-01-30 00:47:54 +00:00
|
|
|
func AddPHPCommands(root *cobra.Command) {
|
|
|
|
|
phpCmd := &cobra.Command{
|
|
|
|
|
Use: "php",
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
Short: i18n.T("cmd.php.short"),
|
|
|
|
|
Long: i18n.T("cmd.php.long"),
|
2026-02-01 02:07:26 +00:00
|
|
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
// Check if we are in a workspace root
|
|
|
|
|
wsRoot, err := workspace.FindWorkspaceRoot()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil // Not in a workspace, regular behavior
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load workspace config
|
|
|
|
|
config, err := workspace.LoadConfig(wsRoot)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil // Failed to load, ignore
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if config.Active == "" {
|
|
|
|
|
return nil // No active package
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate package path
|
|
|
|
|
pkgDir := config.PackagesDir
|
|
|
|
|
if pkgDir == "" {
|
|
|
|
|
pkgDir = "./packages"
|
|
|
|
|
}
|
|
|
|
|
if !filepath.IsAbs(pkgDir) {
|
|
|
|
|
pkgDir = filepath.Join(wsRoot, pkgDir)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
targetDir := filepath.Join(pkgDir, config.Active)
|
|
|
|
|
|
|
|
|
|
// Check if target directory exists
|
|
|
|
|
if _, err := os.Stat(targetDir); err != nil {
|
|
|
|
|
cli.Warnf("Active package directory not found: %s", targetDir)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Change working directory
|
|
|
|
|
if err := os.Chdir(targetDir); err != nil {
|
|
|
|
|
return cli.Err("failed to change directory to active package: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cli.Print("%s %s\n", dimStyle.Render("Workspace:"), config.Active)
|
|
|
|
|
return nil
|
|
|
|
|
},
|
2026-01-30 00:47:54 +00:00
|
|
|
}
|
|
|
|
|
root.AddCommand(phpCmd)
|
2026-01-28 19:14:06 +00:00
|
|
|
|
2026-02-01 02:07:26 +00:00
|
|
|
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
// Development
|
2026-01-28 19:14:06 +00:00
|
|
|
addPHPDevCommand(phpCmd)
|
|
|
|
|
addPHPLogsCommand(phpCmd)
|
|
|
|
|
addPHPStopCommand(phpCmd)
|
|
|
|
|
addPHPStatusCommand(phpCmd)
|
|
|
|
|
addPHPSSLCommand(phpCmd)
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
|
|
|
|
|
// Build & Deploy
|
2026-01-28 19:24:11 +00:00
|
|
|
addPHPBuildCommand(phpCmd)
|
|
|
|
|
addPHPServeCommand(phpCmd)
|
|
|
|
|
addPHPShellCommand(phpCmd)
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
|
|
|
|
|
// Quality (existing)
|
2026-01-28 19:26:57 +00:00
|
|
|
addPHPTestCommand(phpCmd)
|
|
|
|
|
addPHPFmtCommand(phpCmd)
|
2026-01-30 20:06:51 +00:00
|
|
|
addPHPStanCommand(phpCmd)
|
2026-01-28 19:24:11 +00:00
|
|
|
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
// Quality (new)
|
|
|
|
|
addPHPPsalmCommand(phpCmd)
|
|
|
|
|
addPHPAuditCommand(phpCmd)
|
|
|
|
|
addPHPSecurityCommand(phpCmd)
|
|
|
|
|
addPHPQACommand(phpCmd)
|
|
|
|
|
addPHPRectorCommand(phpCmd)
|
|
|
|
|
addPHPInfectionCommand(phpCmd)
|
2026-01-28 19:24:11 +00:00
|
|
|
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
// Package Management
|
|
|
|
|
addPHPPackagesCommands(phpCmd)
|
2026-01-28 19:39:04 +00:00
|
|
|
|
feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing
Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands
QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00
|
|
|
// Deployment
|
|
|
|
|
addPHPDeployCommands(phpCmd)
|
2026-01-31 23:01:21 +00:00
|
|
|
}
|