Skip to content

feat: Add allow-read-config command for GSD external directory permission#84

Merged
rokicool merged 66 commits intomainfrom
dev
Mar 5, 2026
Merged

feat: Add allow-read-config command for GSD external directory permission#84
rokicool merged 66 commits intomainfrom
dev

Conversation

@rokicool
Copy link
Owner

@rokicool rokicool commented Mar 5, 2026

Summary

  • Added allow-read-config command to gsd-oc-tools.cjs for managing external_directory permissions in opencode.json
  • Implemented comprehensive test suite with 5 tests covering permission creation, idempotency, dry-run mode, and backup creation
  • Integrated GSD config read permission step into oc-set-profile workflow for automated access configuration
  • Updated 6 files with 551 insertions and 5 deletions across 65 commits on dev branch

Additional important details

  • Files changed: 6 files (CHANGELOG.md, allow-read-config.cjs, gsd-oc-tools.cjs, allow-read-config.test.cjs, oc-set-profile.md, opencode.json)
  • New command: node gsd-oc-tools.cjs allow-read-config with --dry-run and --verbose flags
  • Permission pattern: ~/.config/opencode/get-shit-done/** allows gsd-opencode to read workflow files, templates, and configuration
  • Safety features: Includes atomic backup creation, rollback support, and idempotency checks
  • Version: Release v1.20.4 ready for merge to main

…dels.cjs)

- oc-core.cjs: output/json envelope, error handling, safeReadFile, createBackup
- oc-models.cjs: getModelCatalog from opencode models, validateModelIds against catalog
- Follows gsd-tools.cjs architecture pattern with CommonJS modules
- Synchronous file ops appropriate for CLI utilities
- Validates model IDs in opencode.json against opencode models catalog
- Outputs JSON envelope format with validation results
- Supports --verbose flag for detailed logging
- Exit code 0 for valid, 1 for invalid/error
- Error codes: CONFIG_NOT_FOUND, INVALID_JSON, FETCH_FAILED, INVALID_MODEL_ID
- Validates profile configuration in .planning/config.json
- Checks profile_type and profile names against whitelist (simple|smart|genius)
- Outputs JSON envelope format with validation results
- Exit code 0 for valid, 1 for invalid/error
- Error codes: CONFIG_NOT_FOUND, INVALID_JSON, INVALID_PROFILE
- Main CLI router with command routing via switch statement
- Routes check-opencode-json, check-config-json, and help commands
- Parses --verbose and --raw flags from command line
- Shows help message with available commands and examples
- Error handling with standardized JSON envelope format
- Follows gsd-tools.cjs architecture pattern
- Add loadProfileConfig function to load .planning/config.json
- Add applyProfileToOpencode function to update agent model assignments
- Define VALID_PROFILES constant (simple|smart|genius)
- Define PROFILE_AGENT_MAPPING for planning/execution/verification agents
- Profile to agent mapping follows context specifications
- Add command to update opencode.json agent models from profile config
- Support --dry-run flag to preview changes without modifying
- Support --verbose flag for detailed output
- Create timestamped backup before modifications using createBackup()
- Validate profile_type against whitelist (simple|smart|genius)
- Output JSON envelope with backup path and updated agents list
- Proper error codes: CONFIG_NOT_FOUND, INVALID_PROFILE, BACKUP_FAILED, UPDATE_FAILED
- Add update-opencode-json case to command switch
- Update help text with new command description
- Add --dry-run option to help examples
- Keep existing check-opencode-json and check-config-json commands
- Update oc-config.cjs to handle profiles.models.{planning|execution|verification}
- Update update-opencode-json.cjs dry-run mode with same fix
- Fallback to profiles.{type} structure for backward compatibility
- Tested: update-opencode-json creates backup and updates all 11 agents
- Tested: INVALID_PROFILE error with exit code 1
- Create 14-02-SUMMARY.md with execution details
- Update STATE.md with plan completion and session info
- Update ROADMAP.md: Phase 14 now 2/2 plans complete
- All 3 tasks + 1 auto-fix committed
- Verified: update-opencode-json creates backups, updates 11 agents
- Rename bin/commands → bin/gsd-oc-commands (3 command files)
- Create bin/gsd-oc-lib with oc-* libraries (oc-core, oc-config, oc-models)
- Update all require paths in gsd-oc-tools.cjs and command files
- Extend check-config-json to validate model IDs against opencode models catalog
- Add --verbose flag to check-config-json for detailed validation output
- Change updatedAgents array to contain { agent, model } objects
- Maintains backward compatibility (updated field still exists)
- Provides model ID details for each updated agent
- Dry-run mode: include modelId in changes array
- Actual mode: add details field with { agent, model } objects
- Maintain backward compatibility: updated array contains agent names
- SUMMARY.md created with full execution details
- STATE.md updated with Quick Task 4 completion
- Added task 4 to Quick Tasks Completed table
- Updated session timestamp and focus
- Workflow checks both opencode.json and .planning/config.json
- Uses gsd-oc-tools.cjs check-opencode-json and check-config-json commands
- Fast success path when both checks pass
- Detailed error display with /gsd-set-profile recommendation when issues found
- Supports --verbose flag for debugging
- Created 5-SUMMARY.md with workflow documentation
- Updated STATE.md with quick task 5 completion
- Workflow validates opencode.json and .planning/config.json
- Provides /gsd-set-profile remediation guidance
Add 4 new commands to optimize oc-set-profile workflow:
- validate-models: Validate model IDs against opencode catalog
- analyze-reuse: Analyze model reuse opportunities for profile switching
- migrate-config: Migrate legacy config to current profile format
- set-profile: Switch profile with interactive model selection

Update oc-set-profile.md workflow to use new tools instead of
manual bash operations, providing:
- Automatic backups before file modifications
- Consistent JSON envelope output format
- Dry-run support for previewing changes
- Centralized error handling
Change relative paths (gsd-opencode/...) to absolute paths
(~/.config/opencode/...) in:
- oc-set-profile.md
- oc-check-profile.md

This ensures workflows work correctly in user environments
where gsd-opencode/ directory structure may not exist.
Per up.md requirements:

check-config-json updates:
- Validate current_oc_profile field (required, must be simple|smart|genius)
- Validate profiles.profile_type (must be simple|smart|genius)
- Validate profiles.models has required stages for current profile
- Validate all model IDs against opencode catalog
- Fail if current_oc_profile missing or invalid

Removed commands:
- analyze-reuse.cjs (deleted)
- migrate-config.cjs (deleted)

Updated:
- gsd-oc-tools.cjs: Remove deleted commands from router and help
- set-profile.cjs: Remove --reuse flag handling
- oc-set-profile.md: Remove --reuse workflow step
- Remove LEGACY_PROFILE_MAP constant
- Remove auto-migration block for legacy model_profile
- Add profile validation against VALID_PROFILES whitelist
- Add current_os_profile tracking in config.json
- Keep applyProfileToOpencode for agent config sync
- Create SUMMARY.md with task completion details
- Document removed legacy migration code
- Document added profile validation
- Track verification results
- Add Quick Task 6 to completed tasks table
- Update Current Focus to reflect task 6 complete
…if missing

- Replace error-return with creation logic when opencode.json doesn't exist
- Create initial structure with $schema and empty agent object
- Load and update existing opencode.json when present
- Ensure agent object exists in both cases
- Always call applyProfileToOpencode unconditionally
- Function now handles both creation and update scenarios
- Update comment to reflect create/update behavior
- SUMMARY.md documents changes to oc-config.cjs and set-profile.cjs
- STATE.md updated with Quick Task 7 completion
- Added key decision about create-or-update pattern
- Update Quick Task 7 record with correct commit hash (f80ec5a)
- Remove migration mention from oc-set-profile workflow
- Update session continuity with task 7 focus
When a profile name is passed as argument, the command now applies the
profile changes using current models instead of just outputting a prompt
and exiting.
Always use object format for agent configurations instead of plain strings.
rokicool added 28 commits March 2, 2026 20:09
- Mode 1 (no params): Returns current profile from oc_config.json
- Mode 2 (profile name): Returns specified profile from oc_config.json
- JSON output format with --raw and --verbose flags
- Structured JSON errors for MISSING_CURRENT_PROFILE, PROFILE_NOT_FOUND, CONFIG_NOT_FOUND
- Read-only operation, no file modifications
- Mode 1 tests: current profile retrieval, error handling
- Mode 2 tests: specific profile retrieval, works without current_oc_profile
- --raw flag tests: output without JSON envelope
- --verbose flag tests: diagnostic output to stderr
- Error format tests: structured JSON errors
- 100% pass rate (16/16 tests)

fix(16-02): correct raw output handling in oc-core.cjs output function

- Bug: raw mode was double-stringifying JSON output
- Fix: use rawValue directly when raw=true instead of stringify again
- Add get-profile to help text with description
- Add command case in switch statement
- Add usage examples with and without profile name
- Add --raw flag example
- Created 16-02-SUMMARY.md with execution details
- Updated STATE.md: Plan 02 complete, added metrics and decisions
- Updated ROADMAP.md: Phase 16 now 2/3 plans executed
- All requirements satisfied: CONTEXT-01, CONTEXT-02, CONTEXT-08, CONTEXT-09
- 16/16 tests passing
- Mode 1: validates and applies current profile from oc_config.json
- Mode 2: switches to specified profile with validation
- Mode 3: creates new profile from inline JSON definition
- Pre-flight validation before any file modifications
- Atomic transaction with rollback on failure
- Dry-run mode for previewing changes
- Structured JSON output with error codes
- Test Mode 1: validates current profile
- Test Mode 2: switches to specified profile
- Test Mode 3: creates new profile from inline JSON
- Test dry-run mode for all three modes
- Test atomic transaction with rollback
- Test error handling and validation order
- 30+ test cases covering all scenarios
- Thin wrapper calling setProfilePhase16(cwd, args)
- Alternative command name for user preference
- No duplicate code or separate tests needed
- Add command routing for set-profile-phase16
- Add command routing for pivot-profile alias
- Update help text with new commands and examples
- Document three operation modes in help
- Tests verify pivotProfile function is exported correctly
- Tests verify delegation to setProfilePhase16 with all 3 modes
- Tests verify --dry-run flag handling
- Tests verify error handling for invalid profiles
- All 11 tests pass (100% pass rate)
- Test file: 276 lines (target: 30+ lines)
- Follows same pattern as get-profile.test.cjs
- Mocks console.log, console.error, and process.exit
- Uses isolated temp directories for test isolation
- Created 16-04-SUMMARY.md with execution results
- Updated STATE.md: Phase 16 Plan 04 complete
- Updated ROADMAP.md: Phase 16 now 4/4 plans complete (100%)
- Closed verification gap: pivot-profile.test.cjs now exists with 11 passing tests
- All CONTEXT-09 requirements satisfied
…e documentation

- Renamed set-profile-phase16.cjs to set-profile.cjs as the main profile command
- Removed obsolete pivot-profile.cjs and set-profile-phase16.cjs files
- Removed set-profile-phase16 and pivot-profile command references from gsd-oc-tools.cjs
- Updated all inline filename references to match new naming scheme
- Restored proper test file named set-profile.test.cjs from phase16 version
- Updated workflow to reflect changes in set-profile command usage
- Modified command examples to use new get-profile and inline JSON profile syntax
- Updated step-by-step instructions for profile handling to match new implementation
- Removed outdated validation steps and update steps that are now handled differently
- Corrected terminology and documentation to reflect current code structure
…ig.json

- Modify update-opencode-json.cjs to load from .planning/oc_config.json instead of .planning/config.json
- Update all references to use the new config structure with current_oc_profile and profiles.presets
- Modify main entry documentation to reflect new config source in gsd-oc-tools.cjs
- Renamed check-config-json.cjs to check-oc-config-json.cjs
- Updated implementation to support oc_config.json instead of config.json
- Updated config schema validation to support profiles.presets structure
- Updated main router to support check-oc-config-json command
- Updated help text to reflect new file structure and migration information
- Updated the oc-set-profile workflow to correspond with new command structure
- Removed obsolete backup files that were no longer needed
- Kept the workflow documentation in sync with the codebase changes
- Fix step numbering (was 5→7)
- Update file reference to .planning/oc_config.json
- Fix broken JSON command (missing closing brace)
- Remove verbose agent listing examples
- Define reusable Output Format template
- Clarify flow branching for positional vs interactive paths
- Streamline from 287 to 158 lines (45% reduction)
Root cause: PROFILE_EXISTS check at lines 196-198 prevented updating
existing profiles when using inline JSON syntax (profileName:JSON).
This check was appropriate for preventing accidental duplicates but
blocked legitimate use case of updating profile definitions.

Fix: Removed the unconditional PROFILE_EXISTS check. Users can now
update existing profiles by running set-profile with inline JSON syntax.
- Planning & Execution: qwen3-coder-plus
- Verification: MiniMax-M2.5
- Restructure from purpose/process to role/context/behavior/notes format
- Add explicit read-only constraint: never modify files or fix issues
- Update file references from config.json to oc_config.json
- Document JSON response shapes for both validation commands
- Remove manual editing option, recommend only /gsd-set-profile
- Add CONFIG_NOT_FOUND handling with friendly messaging
- Remove verbose step (handled internally by CLI tools)
- oc-set-profile.md: Add note about restarting opencode after changes
- Cleanup: Remove oc-set-profile-by-qwen.md
…ttings

- Update oc-check-profile.md with severity levels (OK/WARNING/ERROR)
- Change model profile option from 'Custom' to 'Genius'
- Add set-profile workflow reference in settings.md
- Add new exclude patterns and translation pattern in config.json
- Fix comment capitalization in CJS library files
Document v1.20.3 release with gsd-oc-tools.cjs CLI, profile management
system, validation commands, and vitest testing infrastructure.

Add README section explaining new simple/smart/genius profile system
and migration from original GSD model profile approach.
- New command: allow-read-config adds external_directory permission to opencode.json
- Permission pattern: ~/.config/opencode/get-shit-done/** for recursive access
- Supports --dry-run and --verbose flags
- Automatic backup creation before modifying existing files
- Idempotent operation detects existing permissions
- Integrated into oc-set-profile workflow as Step 0
- Test suite with 5 passing tests
- Updated CLI help and documentation
- Document allow-read-config command in CHANGELOG.md
- Add external_directory permission to opencode.json for GSD config access
@rokicool rokicool merged commit 4527186 into main Mar 5, 2026
5 checks passed
@rokicool rokicool deleted the dev branch March 5, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant