@@ -29,21 +29,19 @@ var (
2929 initializeUnattended bool
3030
3131 // Semantic provider configuration
32- initializeSemanticProvider string
33- initializeSemanticModel string
34- initializeSemanticAPIKey string
35- initializeSkipSemantic bool
36-
37- // Claude API configuration (legacy)
38- initializeAnthropicAPIKey string
39- initializeUseEnvAnthropicAPIKey bool
32+ initializeSemanticProvider string
33+ initializeSemanticModel string
34+ initializeSemanticAPIKey string
35+ initializeUseEnvSemanticAPIKey bool
36+ initializeSkipSemantic bool
4037
4138 // HTTP API configuration
4239 initializeHTTPPort int
4340
4441 // FalkorDB configuration
4542 initializeGraphHost string
4643 initializeGraphPort int
44+ initializeGraphDatabase string
4745 initializeGraphPassword string
4846 initializeStartFalkorDBDocker bool
4947 initializeStartFalkorDBPodman bool
5755
5856 // Integration configuration
5957 initializeIntegrations []string
60-
61- // Deprecated flags (kept for backward compatibility)
62- initializeSetupIntegrations bool
63- initializeSkipIntegrations bool
6458)
6559
6660var InitializeCmd = & cobra.Command {
@@ -78,25 +72,23 @@ var InitializeCmd = &cobra.Command{
7872 Example : ` # Interactive initialization (TUI wizard)
7973 memorizer initialize
8074
81- # Unattended initialization with Docker
75+ # Unattended initialization with environment variable
8276 memorizer initialize --unattended \
83- --use-env-anthropic -api-key \
77+ --use-env-semantic -api-key \
8478 --start-falkordb-docker \
8579 --integrations claude-code-hook,claude-code-mcp
8680
87- # Unattended initialization with Podman
81+ # Unattended with explicit API key and custom database
8882 memorizer initialize --unattended \
89- --use-env-anthropic- api-key \
90- --start-falkordb-podman \
83+ --semantic- api-key sk-... \
84+ --graph-database my-project \
9185 --integrations claude-code-hook
9286
93- # Unattended with explicit API keys
87+ # Using Gemini as semantic provider
9488 memorizer initialize --unattended \
95- --anthropic-api-key sk-ant-... \
96- --openai-api-key sk-... \
97- --enable-embeddings \
98- --graph-host localhost \
99- --graph-port 6379
89+ --semantic-provider gemini \
90+ --use-env-semantic-api-key \
91+ --start-falkordb-podman
10092
10193 # Force overwrite existing config
10294 memorizer initialize --force` ,
@@ -117,18 +109,16 @@ func init() {
117109 InitializeCmd .Flags ().StringVar (& initializeSemanticProvider , "semantic-provider" , "" , "Semantic analysis provider (claude, openai, gemini)" )
118110 InitializeCmd .Flags ().StringVar (& initializeSemanticModel , "semantic-model" , "" , "Model for semantic analysis (provider-specific)" )
119111 InitializeCmd .Flags ().StringVar (& initializeSemanticAPIKey , "semantic-api-key" , "" , "API key for semantic analysis" )
112+ InitializeCmd .Flags ().BoolVar (& initializeUseEnvSemanticAPIKey , "use-env-semantic-api-key" , false , "Use environment variable for semantic provider API key" )
120113 InitializeCmd .Flags ().BoolVar (& initializeSkipSemantic , "skip-semantic" , false , "Disable semantic analysis" )
121114
122- // Claude API configuration (legacy, still supported)
123- InitializeCmd .Flags ().StringVar (& initializeAnthropicAPIKey , "anthropic-api-key" , "" , "Anthropic API key value (legacy; use --semantic-api-key)" )
124- InitializeCmd .Flags ().BoolVar (& initializeUseEnvAnthropicAPIKey , "use-env-anthropic-api-key" , false , "Use ANTHROPIC_API_KEY from environment" )
125-
126115 // HTTP API configuration
127116 InitializeCmd .Flags ().IntVar (& initializeHTTPPort , "http-port" , - 1 , "HTTP API port (0 to disable, -1 for wizard default)" )
128117
129118 // FalkorDB configuration
130119 InitializeCmd .Flags ().StringVar (& initializeGraphHost , "graph-host" , config .DefaultConfig .Graph .Host , "FalkorDB host" )
131120 InitializeCmd .Flags ().IntVar (& initializeGraphPort , "graph-port" , config .DefaultConfig .Graph .Port , "FalkorDB port" )
121+ InitializeCmd .Flags ().StringVar (& initializeGraphDatabase , "graph-database" , config .DefaultConfig .Graph .Database , "FalkorDB database name" )
132122 InitializeCmd .Flags ().StringVar (& initializeGraphPassword , "graph-password" , "" , "FalkorDB password" )
133123 InitializeCmd .Flags ().BoolVar (& initializeStartFalkorDBDocker , "start-falkordb-docker" , false , "Start FalkorDB using Docker" )
134124 InitializeCmd .Flags ().BoolVar (& initializeStartFalkorDBPodman , "start-falkordb-podman" , false , "Start FalkorDB using Podman" )
@@ -143,12 +133,6 @@ func init() {
143133 // Integration configuration
144134 InitializeCmd .Flags ().StringSliceVar (& initializeIntegrations , "integrations" , []string {}, "Integrations to setup (comma-separated)" )
145135
146- // Deprecated flags (kept for backward compatibility)
147- InitializeCmd .Flags ().BoolVar (& initializeSetupIntegrations , "setup-integrations" , false , "Deprecated: use --integrations instead" )
148- InitializeCmd .Flags ().BoolVar (& initializeSkipIntegrations , "skip-integrations" , false , "Deprecated: omit --integrations instead" )
149- InitializeCmd .Flags ().MarkDeprecated ("setup-integrations" , "use --integrations flag instead" )
150- InitializeCmd .Flags ().MarkDeprecated ("skip-integrations" , "simply omit --integrations flag" )
151-
152136 InitializeCmd .Flags ().SortFlags = false
153137}
154138
@@ -163,8 +147,8 @@ func validateInit(cmd *cobra.Command, args []string) error {
163147 return fmt .Errorf ("--enable-embeddings and --disable-embeddings are mutually exclusive" )
164148 }
165149
166- if initializeAnthropicAPIKey != "" && initializeUseEnvAnthropicAPIKey {
167- return fmt .Errorf ("--anthropic -api-key and --use-env-anthropic -api-key are mutually exclusive" )
150+ if initializeSemanticAPIKey != "" && initializeUseEnvSemanticAPIKey {
151+ return fmt .Errorf ("--semantic -api-key and --use-env-semantic -api-key are mutually exclusive" )
168152 }
169153
170154 if initializeOpenAIAPIKey != "" && initializeUseEnvOpenAIAPIKey {
@@ -176,6 +160,11 @@ func validateInit(cmd *cobra.Command, args []string) error {
176160 return fmt .Errorf ("--http-port must be -1 (default), 0 (disabled), or 1-65535" )
177161 }
178162
163+ // Validate graph-port range
164+ if initializeGraphPort < 1 || initializeGraphPort > 65535 {
165+ return fmt .Errorf ("--graph-port must be between 1 and 65535" )
166+ }
167+
179168 // Validate semantic provider if specified
180169 if initializeSemanticProvider != "" && initializeSkipSemantic {
181170 return fmt .Errorf ("--semantic-provider and --skip-semantic are mutually exclusive" )
@@ -207,20 +196,14 @@ func validateInit(cmd *cobra.Command, args []string) error {
207196 // Check for API key based on provider
208197 hasKey := initializeSemanticAPIKey != ""
209198 if ! hasKey {
210- // Check legacy Anthropic flags for backward compatibility
211- if provider == "claude" && (initializeAnthropicAPIKey != "" || initializeUseEnvAnthropicAPIKey ) {
212- hasKey = true
213- }
214- // Check environment variable for provider
215- if ! hasKey {
216- switch provider {
217- case "claude" :
218- hasKey = os .Getenv (config .ClaudeAPIKeyEnv ) != ""
219- case "openai" :
220- hasKey = os .Getenv (config .OpenAIAPIKeyEnv ) != ""
221- case "gemini" :
222- hasKey = os .Getenv (config .GoogleAPIKeyEnv ) != ""
223- }
199+ // Check --use-env-semantic-api-key flag or implicit env var presence
200+ switch provider {
201+ case "claude" :
202+ hasKey = os .Getenv (config .ClaudeAPIKeyEnv ) != ""
203+ case "openai" :
204+ hasKey = os .Getenv (config .OpenAIAPIKeyEnv ) != ""
205+ case "gemini" :
206+ hasKey = os .Getenv (config .GoogleAPIKeyEnv ) != ""
224207 }
225208 }
226209
@@ -232,7 +215,7 @@ func validateInit(cmd *cobra.Command, args []string) error {
232215 case "gemini" :
233216 envVar = config .GoogleAPIKeyEnv
234217 }
235- return fmt .Errorf ("unattended mode requires --semantic-api-key or %s environment variable (or use --skip-semantic)" , envVar )
218+ return fmt .Errorf ("unattended mode requires --semantic-api-key, --use-env-semantic-api-key, or %s environment variable (or use --skip-semantic)" , envVar )
236219 }
237220 }
238221
@@ -389,17 +372,21 @@ func runUnattended(cmd *cobra.Command) error {
389372 }
390373 }
391374
392- // API key - check new flag, then legacy flags , then env vars
375+ // API key - check explicit flag, then use-env flag , then implicit env vars
393376 if initializeSemanticAPIKey != "" {
394377 cfg .Semantic .APIKey = initializeSemanticAPIKey
395- } else if cfg .Semantic .Provider == "claude" && initializeAnthropicAPIKey != "" {
396- // Legacy support
397- cfg .Semantic .APIKey = initializeAnthropicAPIKey
398- } else if cfg .Semantic .Provider == "claude" && initializeUseEnvAnthropicAPIKey {
399- // Legacy support
400- cfg .Semantic .APIKey = os .Getenv (config .ClaudeAPIKeyEnv )
378+ } else if initializeUseEnvSemanticAPIKey {
379+ // Unified env var flag - read from provider-appropriate env var
380+ switch cfg .Semantic .Provider {
381+ case "claude" :
382+ cfg .Semantic .APIKey = os .Getenv (config .ClaudeAPIKeyEnv )
383+ case "openai" :
384+ cfg .Semantic .APIKey = os .Getenv (config .OpenAIAPIKeyEnv )
385+ case "gemini" :
386+ cfg .Semantic .APIKey = os .Getenv (config .GoogleAPIKeyEnv )
387+ }
401388 } else {
402- // Try to get from environment based on provider
389+ // Try to get from environment based on provider (implicit)
403390 switch cfg .Semantic .Provider {
404391 case "claude" :
405392 cfg .Semantic .APIKey = os .Getenv (config .ClaudeAPIKeyEnv )
@@ -423,6 +410,7 @@ func runUnattended(cmd *cobra.Command) error {
423410 // FalkorDB
424411 cfg .Graph .Host = initializeGraphHost
425412 cfg .Graph .Port = initializeGraphPort
413+ cfg .Graph .Database = initializeGraphDatabase
426414 cfg .Graph .Password = initializeGraphPassword
427415
428416 // Start FalkorDB if requested
0 commit comments