diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3683014b3..22a3b4623 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,7 +97,7 @@ below describes the current layout as the migration proceeds. - `internal/testutil/console/` contains shared synthetic Windows console records and observer fixtures used only by native feature tests. - `internal/app/` owns invocation, request-environment scope, completion setup, - output policy, and exit-status selection. Command assembly still uses the + output policy, help assembly, and exit-status selection. Command assembly still uses the existing generated tree during the layout migration. - `api_reference/openapi.transformed.yml` contains the OpenAPI specification used by the mock server. diff --git a/cmd/openai/error_coverage_test.go b/cmd/openai/error_coverage_test.go index b8acc92cd..6fc4edc96 100644 --- a/cmd/openai/error_coverage_test.go +++ b/cmd/openai/error_coverage_test.go @@ -21,6 +21,7 @@ import ( "time" "github.com/openai/openai-cli/generated/commands" + "github.com/openai/openai-cli/internal/app" "github.com/openai/openai-cli/internal/requestflag" "github.com/openai/openai-cli/pkg/custom" "github.com/urfave/cli/v3" @@ -310,7 +311,7 @@ func TestMainErrorCoverageManifestProcess(t *testing.T) { } root := commands.Command root.Flags = append(root.Flags, custom.NewRequestHeaderFlag()) - if _, _, err := custom.ConfigureHelp(root, []string{"openai", "--help"}); err != nil { + if _, _, err := app.ConfigureHelp(root, []string{"openai", "--help"}); err != nil { t.Fatal(err) } custom.ConfigureCommandErrors(root) diff --git a/docs/architecture/repository-layout.md b/docs/architecture/repository-layout.md index ffbba0233..62acf7ec8 100644 --- a/docs/architecture/repository-layout.md +++ b/docs/architecture/repository-layout.md @@ -351,3 +351,7 @@ entrypoint contracts, check platform compilation, and verify that generated file and dependency manifests are untouched. For generator changes, additionally verify regenerated snapshots and a repeat generation with no unexplained drift. Keep release, signing, CODEOWNER, merge-queue, and trusted-main controls intact. + +Help assembly and its contracts live in `internal/app/`: root flag descriptions, +feature help content, flag groups, and admin setup guidance are configured there +in the existing order. Rendering remains in `internal/clihelp/`. diff --git a/pkg/custom/admin_setup_test.go b/internal/app/admin_setup_test.go similarity index 99% rename from pkg/custom/admin_setup_test.go rename to internal/app/admin_setup_test.go index 1ec2afb4e..6434da788 100644 --- a/pkg/custom/admin_setup_test.go +++ b/internal/app/admin_setup_test.go @@ -1,4 +1,4 @@ -package custom +package app import ( "bytes" diff --git a/pkg/custom/help.go b/internal/app/help.go similarity index 99% rename from pkg/custom/help.go rename to internal/app/help.go index 022ba7f4e..8fc3451f3 100644 --- a/pkg/custom/help.go +++ b/internal/app/help.go @@ -1,4 +1,4 @@ -package custom +package app import ( "strings" diff --git a/pkg/custom/help_test.go b/internal/app/help_test.go similarity index 97% rename from pkg/custom/help_test.go rename to internal/app/help_test.go index bfffc8599..9ac8f6d09 100644 --- a/pkg/custom/help_test.go +++ b/internal/app/help_test.go @@ -1,4 +1,4 @@ -package custom +package app import ( "bytes" @@ -11,6 +11,7 @@ import ( imagecommands "github.com/openai/openai-cli/internal/commands/images" requestconfig "github.com/openai/openai-cli/internal/request" "github.com/openai/openai-cli/internal/requestflag" + "github.com/openai/openai-cli/pkg/custom" "github.com/urfave/cli/v3" ) @@ -156,9 +157,9 @@ func TestConfigureHelpPreservesImageGuidance(t *testing.T) { {Name: "unrelated", Description: "Keep this description", CustomHelpTemplate: "Keep this template"}, }} root := &cli.Command{Name: "openai", Commands: []*cli.Command{images}} - imagecommands.ConfigureSaving(root, ImageSavingOptions()) - imagecommands.RegisterPreview(root, ImagePreviewOptions()) - imagecommands.RegisterModels(root, ImageModelOptions()) + imagecommands.ConfigureSaving(root, custom.ImageSavingOptions()) + imagecommands.RegisterPreview(root, custom.ImagePreviewOptions()) + imagecommands.RegisterModels(root, custom.ImageModelOptions()) wantGuidance := map[string][]string{ "generate": {"interactive terminal", "picker reopens", "Ctrl+C exits", "~/Downloads/gpt-images/", "--format json", "without --name or --output-dir", "depend on the model"}, "edit": {"Replace photo.png", "Keeps your original", "~/Downloads/gpt-images/", "existing folder", "--format json", "depend on the model"}, diff --git a/internal/app/run.go b/internal/app/run.go index bf8e7f85d..cbfb19725 100644 --- a/internal/app/run.go +++ b/internal/app/run.go @@ -47,7 +47,7 @@ func Run(ctx context.Context, argv []string) int { prepareForAutocomplete(app) } - args, _, err := custom.ConfigureHelp(app, argv) + args, _, err := ConfigureHelp(app, argv) custom.ConfigureCommandErrors(app) if err == nil { diff --git a/internal/clihelp/request_inputs_test.go b/internal/clihelp/request_inputs_test.go index a2974256e..90fdc9ac2 100644 --- a/internal/clihelp/request_inputs_test.go +++ b/internal/clihelp/request_inputs_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" + "github.com/openai/openai-cli/internal/app" "github.com/openai/openai-cli/internal/clihelp" localcommands "github.com/openai/openai-cli/internal/commands" "github.com/openai/openai-cli/internal/requestflag" - "github.com/openai/openai-cli/pkg/custom" "github.com/urfave/cli/v3" ) @@ -55,7 +55,7 @@ func TestDescribeRequestInputsSurvivesResourceCloning(t *testing.T) { clihelp.DescribeRequestInputs(root) localcommands.ConfigureSubgroups(root) args := append(append([]string{"openai"}, path...), "--help") - args, _, err := custom.ConfigureHelp(root, args) + args, _, err := app.ConfigureHelp(root, args) if err != nil { t.Fatal(err) }