Files
fission-ai__openspec/openspec/changes/archive/2025-12-21-add-config-command/tasks.md
Tabish Bidiwale 971f8ca4a3 feat(cli): add openspec config command for global configuration management (#382)
* feat(cli): add openspec config command for global configuration management

Implements the `openspec config` command with subcommands:
- `path`: Show config file location
- `list [--json]`: Show all current settings
- `get <key>`: Get a specific value (raw output for scripting)
- `set <key> <value> [--string]`: Set a value with auto type coercion
- `unset <key>`: Remove a key (revert to default)
- `reset --all [-y]`: Reset configuration to defaults
- `edit`: Open config in $EDITOR/$VISUAL

Key features:
- Dot notation for nested key access (e.g., featureFlags.someFlag)
- Auto type coercion (true/false → boolean, numbers → number)
- --string flag to force string storage
- Zod schema validation with unknown field passthrough
- Reserved --scope flag for future project-local config
- Windows-compatible editor spawning with proper path quoting
- Shell completion registry integration

* test(config): add additional unit tests for validation and coercion

- Add tests for unknown fields with various types
- Add test to verify error message path for featureFlags
- Add test for number values rejection in featureFlags
- Add config set simulation tests to verify full coerce → set → validate flow

* fix(config): avoid shell parsing in config edit to handle paths with spaces

Use spawn with shell: false and pass configPath as an argument instead
of building a shell command string. This correctly handles spaces in
both the EDITOR path and config file path on all platforms.

* chore(openspec): archive add-config-command and create cli-config spec

Move completed change to archive and apply spec deltas to create
the cli-config specification documenting the config command interface.

* Validate config keys on set
2025-12-22 18:29:25 +11:00

1.2 KiB

1. Core Infrastructure

  • 1.1 Create zod schema for global config in src/core/config-schema.ts
  • 1.2 Add utility functions for dot-notation key access (get/set nested values)
  • 1.3 Add type coercion logic (auto-detect boolean/number/string)

2. Config Command Implementation

  • 2.1 Create src/commands/config.ts with Commander.js subcommands
  • 2.2 Implement config path subcommand
  • 2.3 Implement config list subcommand with --json flag
  • 2.4 Implement config get <key> subcommand (raw output)
  • 2.5 Implement config set <key> <value> with --string flag
  • 2.6 Implement config unset <key> subcommand
  • 2.7 Implement config reset --all with -y confirmation flag
  • 2.8 Implement config edit subcommand (spawn $EDITOR)

3. Integration

  • 3.1 Register config command in CLI entry point
  • 3.2 Update shell completion registry to include config subcommands

4. Testing

  • 4.1 Manual testing of all subcommands
  • 4.2 Verify zod validation rejects invalid keys/values
  • 4.3 Test nested key access with dot notation
  • 4.4 Test type coercion edge cases (true/false, numbers, strings)