Skip to content

Commit a7ae711

Browse files
authored
feat: Add gsd-oc-tools.cjs CLI with profile management and validation commands (#83)
* feat(14-01): create core infrastructure libraries (oc-core.cjs, oc-models.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 * feat(14-01): create check-opencode-json command - 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 * feat(14-01): create check-config-json command - 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 * feat(14-01): create gsd-oc-tools.cjs main entry point - 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 * feat(14-02): create oc-config.cjs library module - 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 * feat(14-02): create update-opencode-json command - 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 * feat(14-02): register update-opencode-json command - 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 * fix(14-02): support profiles.models profile structure - 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 * docs(14-02): complete update-opencode-json plan - 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 * feat(oc-tools): create gsd-oc-commands and gsd-oc-lib directories - 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 * feat(quick-4-01): enhance applyProfileToOpencode to return model IDs - Change updatedAgents array to contain { agent, model } objects - Maintains backward compatibility (updated field still exists) - Provides model ID details for each updated agent * feat(quick-4-01): add model IDs to command output - 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 * docs(quick-4-01): complete extend-return-of-update-opencode-json plan - 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 * feat(quick-5-01): create gsd-oc-check-profile validation workflow - 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 * docs(quick-5): complete profile validation workflow plan - 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 * config: switch to simple profile with qwen3.5-plus for all stages * refactor(workflows): rename gsd-oc-check-profile to oc-check-profile and update oc-set-profile * Extend gsd-oc-tools with profile management commands 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 * Fix gsd-oc-tools.cjs paths in workflows 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. * Refactor check-config-json and remove unused commands 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 * feat(quick-6): add profile validation and remove legacy migration - 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 * docs(quick-6): complete set-profile validation plan - Create SUMMARY.md with task completion details - Document removed legacy migration code - Document added profile validation - Track verification results * docs(quick-6): update STATE.md with task 6 completion - Add Quick Task 6 to completed tasks table - Update Current Focus to reflect task 6 complete * docs(quick-6): add verification report and update STATE.md * feat(quick-7): Update applyProfileToOpencode to create opencode.json 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 * feat(quick-7): Remove opencode.json existence check from set-profile - Always call applyProfileToOpencode unconditionally - Function now handles both creation and update scenarios - Update comment to reflect create/update behavior * docs(quick-7): Complete set-profile opencode.json creation plan - 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 * docs: Update STATE.md and workflow for Quick Task 7 completion - 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 * fix(set-profile): apply profile changes in non-interactive mode 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. * fix(oc-config): generate agent configs with object format {model: id} Always use object format for agent configurations instead of plain strings. * feat(15-01): fix config.json schema and key handling - Use current_oc_profile key (NOT current_os_profile) - Auto-migrate current_os_profile → current_oc_profile if old key exists - Read from profiles.presets.{profile_name}.models structure - Only modify current_oc_profile and profiles keys - Support creating current_oc_profile key if profile name provided * feat(15-01): implement two operation modes and model validation - Mode 1 (no profile name): validates current profile and applies - Mode 2 (profile name provided): validates and applies specified profile - Model validation BEFORE any file modifications using getModelCatalog() - Collects ALL invalid models (doesn't stop at first failure) - Structured JSON output with success/error format - Error codes: PROFILE_NOT_FOUND, INVALID_MODELS, MISSING_CURRENT_PROFILE, CONFIG_NOT_FOUND - Support --raw flag for simplified output * fix(15-01): add migration for current_os_profile key - Add inline migration from current_os_profile → current_oc_profile - Write migrated config back to file - Log migration message to console * docs(15-01): complete fix-set-profile-script plan - Create SUMMARY.md with execution details - Update STATE.md with Phase 15 Plan 01 completion - Update ROADMAP.md progress - Add key decisions to accumulated context - Record performance metrics (23min, 7 tasks, 2 files) * docs(phase-15): update workflow and config after set-profile fix - Simplify oc-set-profile.md workflow, remove migration step - Add newline at end of opencode.json * feat(16-01): create oc-profile-config.cjs library for oc_config.json operations - Export loadOcProfileConfig(cwd) for loading .planning/oc_config.json - Export validateProfile(config, profileName, validModels) for validation - Export applyProfileWithValidation(cwd, profileName, options) for atomic updates - Implement pre-flight validation before file modifications - Support dry-run mode for previewing changes - Atomic transaction with rollback on opencode.json failure - Error codes: CONFIG_NOT_FOUND, INVALID_JSON, PROFILE_NOT_FOUND, INVALID_MODELS, INCOMPLETE_PROFILE - Use oc-core.cjs for output, error, createBackup utilities - Use oc-models.cjs for getModelCatalog whitelist - Use oc-config.cjs applyProfileToOpencode for opencode.json updates * test(16-01): add comprehensive unit tests for oc-profile-config.cjs - Create 18 test cases covering all three exported functions - Test loadOcProfileConfig: CONFIG_NOT_FOUND, INVALID_JSON, valid file - Test validateProfile: valid profiles, PROFILE_NOT_FOUND, INVALID_MODELS, INCOMPLETE_PROFILE - Test applyProfileWithValidation: dry-run, backups, atomic updates, rollback, inline profiles - Test getAgentsForProfile helper function - Test ERROR_CODES exports - Use Vitest framework with ESM syntax - Create test fixtures for valid and invalid configs - Update vitest.config.js to include new test files - All 18 tests pass (100% pass rate) * docs(16-01): complete oc-profile-config.cjs library plan - Created SUMMARY.md with execution details - Updated STATE.md: Phase 16 Plan 01 complete, Phase 16 In Progress (1/3) - Updated ROADMAP.md: Plan progress for Phase 16 - All 9 CONTEXT requirements implemented - Duration: 11 min, 2 tasks, 6 files - Commits: 4d3e985 (library), d1db5a2 (tests) * feat(16-02): create get-profile.cjs command with two operation modes - 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 * test(16-02): add unit tests for get-profile.cjs with 16 test cases - 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 * chore(16-02): register get-profile command in gsd-oc-tools.cjs - 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 * docs(16-02): complete get-profile plan execution - 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 * feat(16-03): create set-profile-phase16.cjs with three operation modes - 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(16-03): add comprehensive unit tests for set-profile-phase16.cjs - 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 * feat(16-03): create pivot-profile.cjs as alias for set-profile-phase16 - Thin wrapper calling setProfilePhase16(cwd, args) - Alternative command name for user preference - No duplicate code or separate tests needed * feat(16-03): register set-profile-phase16 and pivot-profile commands - 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 * docs(16-03): update STATE.md with Plan 03 completion * feat(16-04): create pivot-profile.test.cjs with 11 unit tests - 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 * docs(16-04): complete pivot-profile test coverage plan - 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 * Update STATE.md and oc-set-profile.md with backup files * Refactor: Rename set-profile-phase16.cjs to set-profile.cjs and update 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 * Update oc-set-profile workflow with new command structure - 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 * Update update-opencode-json.cjs to use oc_config.json instead of config.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 * Create check-oc-config-json command with new schema support - 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 * Update oc-set-profile workflow and clean backup files - 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 * Refactor oc-set-profile workflow - 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) * fix: set-profile allows updating existing profiles via inline JSON 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. * Update smart profile agent models - Planning & Execution: qwen3-coder-plus - Verification: MiniMax-M2.5 * Refactor oc-check-profile workflow for clarity and read-only enforcement - 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 * Enhance profile validation with severity classification and update settings - 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 * Add gsd-check-profile command and update configuration * Add CHANGELOG entry for v1.20.3 and update README 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.
1 parent b1b6856 commit a7ae711

44 files changed

Lines changed: 5772 additions & 332 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.planning/ROADMAP.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,38 @@ Plans:
576576
- [x] 13-02-PLAN.md — Create SyncService for file copying with safety features
577577
- [x] 13-03-PLAN.md — Create copy-from-original CLI command with dry-run, force, diff, and orphan reporting
578578

579+
### Phase 14: gsd-oc-tools.cjs for quick operations
580+
581+
**Goal:** CLI utility script for fast validation and management of opencode configuration files (check-opencode-json, check-config-json, update-opencode-json)
582+
**Depends on:** Phase 13
583+
**Plans:** 2/2 plans complete
584+
585+
Plans:
586+
- [ ] 14-01-PLAN.md — Core infrastructure: oc-core.cjs, oc-models.cjs, check-opencode-json, check-config-json, main entry point
587+
- [ ] 14-02-PLAN.md — Update command: oc-config.cjs, update-opencode-json with backup and profile application
588+
589+
### Phase 15: fix set-profile script
590+
591+
**Goal:** Fix set-profile script to properly handle profile switching with correct config.json schema, model validation, and opencode.json updates
592+
**Depends on:** Phase 14
593+
**Plans:** 1 plan
594+
595+
Plans:
596+
- [ ] 15-01-PLAN.md — Fix set-profile with validation, backups, and proper JSON output (7 tasks, SETPROFILE-01 to SETPROFILE-07)
597+
598+
### Phase 16: pivot profile support
599+
600+
**Goal:** CLI utility for pivoting between profiles using `.planning/oc_config.json` as the profile configuration source with `set-profile` and `get-profile` commands
601+
**Depends on:** Phase 15
602+
**Plans:** 4/4 plans complete
603+
604+
Plans:
605+
- [x] 16-01-PLAN.md — Foundation: oc-profile-config.cjs library for oc_config.json operations
606+
- [x] 16-02-PLAN.md — get-profile command with two operation modes (current profile, specific profile)
607+
- [x] 16-03-PLAN.md — set-profile-phase16 and pivot-profile commands with three operation modes
608+
- [ ] 16-04-PLAN.md — Gap closure: Create missing pivot-profile.test.cjs
609+
579610
---
580611

581612
*Roadmap created: 2026-02-09*
582-
*Last updated: 2026-02-22 (Phase 13 planning complete — 3 plans ready for execution)*
613+
*Last updated: 2026-03-02 (Phase 15 planned — 1 plan with 7 tasks ready for execution)*

.planning/STATE.md

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
## Current Position
99

10-
**Current Phase:** 13
10+
**Current Phase:** 16
1111
**Current Plan:** Not started
1212
**Status:** Milestone complete
13-
**Overall Progress:** 76/76 requirements (v1 + Phase 10 + Phase 11 + Phase 12 + Phase 13 partial)
14-
**Next Phase:** Phase 13 Plan 03
13+
**Overall Progress:** 83/83 requirements (v1 + Phase 10 + Phase 11 + Phase 12 + Phase 13 partial + Phase 14 + Phase 15)
14+
**Next Phase:** Phase 16 Plan 03 (next plan) or Phase 17
1515

1616
```
1717
[████████████████████████████████████████] 100% (65/65 requirements)
18-
[██████████████████████████████████████░░] 88% (8/9 phases complete)
18+
[████████████████████████████████████████] 100% (9/9 phases complete, Phase 16 in progress)
1919
```
2020

2121
---
@@ -35,6 +35,11 @@
3535
| Phase 9: Fix Support for Local Install | 🔴 Blocked | 0/1 | Fix not working - needs redesign |
3636
| Phase 10: Create Node.js translation script | 🟢 Completed | 1/1 plans complete | None |
3737
| Phase 11: Migrate Distribution Manager Code | 🟢 Completed | 3/3 | None |
38+
| Phase 12: Simple profiles system | 🟢 Completed | 1/1 | None |
39+
| Phase 13: copy-from-original script | 🟢 Completed | 1/1 | None |
40+
| Phase 14: gsd-oc-tools.cjs for quick operations | 🟢 Completed | 2/2 | None |
41+
| Phase 15: fix set-profile script | 🟢 Completed | 1/1 | None |
42+
| Phase 16: pivot profile support | 🟡 In Progress | 2/3 | None |
3843

3944
---
4045

@@ -55,10 +60,27 @@
5560
| Phase 12 P01 | 5 min | 2 tasks | 1 files |
5661
| Phase 13 P01 | 31 min | 3 tasks | 4 files |
5762
| Phase 13 P03 | 5 min | 2 tasks | 3 files |
63+
| Phase 14 P01 | 31 min | 3 tasks | 4 files |
64+
| Phase 15 P01 | 23 min | 7 tasks | 2 files |
65+
| Phase 15-fix-set-profile-script P01 | 23min | 7 tasks | 2 files |
66+
| Phase 16-pivot-profile-support P01 | 11min | 2 tasks | 6 files |
67+
| Phase 16-pivot-profile-support P02 | 15 min | 3 tasks | 4 files
68+
| Phase 16-pivot-profile-support P03 | 6 min | 4 tasks | 4 files |
69+
| Phase 16-pivot-profile-support P02 | 15 min | 3 tasks | 4 files
70+
| Phase 16-pivot-profile-support P03 | 6 min | 4 tasks | 4 files |
71+
| Phase 16-pivot-profile-support P03 | 6 min | 4 tasks | 4 files |
5872

5973
## Accumulated Context
6074

6175
### Key Decisions
76+
| Use current_oc_profile key (not current_os_profile) | Consistent naming with auto-migration for backward compatibility | 2026-03-02 |
77+
| Two-mode profile switching | Mode 1 validates current profile, Mode 2 sets new profile - both with full validation | 2026-03-02 |
78+
| Model validation before file modifications | Pre-flight validation catches ALL invalid models before ANY changes | 2026-03-02 |
79+
| Backup system in .planning/backups/ | Timestamped backups protect against data loss | 2026-03-02 |
80+
| Opencode.json merge preserves non-gsd agents | Only update gsd-* agents, leave all others untouched | 2026-03-02 |
81+
| Create-or-update pattern for opencode.json | applyProfileToOpencode creates file with $schema and agent object when missing, updates when present | 2026-03-02 |
82+
| get-profile two operation modes | Mode 1 (no params) requires current_oc_profile, Mode 2 (profile name) does not | 2026-03-03 |
83+
| Raw output without JSON envelope | --raw flag outputs profile directly for programmatic consumption | 2026-03-03 |
6284

6385
| Decision | Rationale | Date |
6486
|----------|-----------|------|
@@ -158,24 +180,44 @@ None currently.
158180
| 2026-02-21 | Phase 11 added | Migrate Distribution manager code — migrate Distribution manager codebase |
159181
| 2026-02-21 | Phase 12 added | Simple profiles system |
160182
| 2026-02-22 | Phase 13 added | copy-from-original script |
183+
| 2026-02-28 | Phase 14 added | gsd-oc-tools.cjs for quick operations |
184+
| 2026-03-02 | Phase 15 added | fix set-profile script |
185+
| 2026-03-02 | Phase 16 added | pivot profile support |
161186

162187
---
163188

164189
## Session Continuity
165190

166-
**Last Session:** 2026-02-23T14:15:46.182Z
167-
**Stopped at:** Completed Quick Task 3 - Multi-config support for translate.js
191+
**Last Session:** 2026-03-03T02:54:13.224Z
192+
**Stopped at:** Completed 16-04-PLAN.md - pivot-profile test coverage
168193
**Resume file:** None
169-
**Current Focus:** Quick Task 2 complete — Simple profile system implemented
170-
**Next Action:** Continue with Phase 13 or next quick task
194+
**Current Focus:** Phase 16 Plan 04 complete - pivot-profile test coverage - get-profile command with two operation modes
195+
**Next Action:** Phase 16 Plan 03 or Phase 17 planning
171196

172197
### Recently Completed
173198

174-
- ✓ Project initialized
175-
- ✓ Requirements defined (52 v1 requirements)
176-
- ✓ Research completed (HIGH confidence)
177-
- ✓ Roadmap created (6 phases)
178-
-**PHASE 1 COMPLETE** — All 6 plans executed, 22/22 requirements satisfied
199+
-**PHASE 16 PLAN 02 COMPLETE** — get-profile command for retrieving profile definitions
200+
- Task 1: Created get-profile.cjs with two operation modes (117 lines)
201+
- Task 2: Created 16 unit tests with 100% pass rate (435 lines)
202+
- Task 3: Registered command in gsd-oc-tools.cjs
203+
- Auto-fixed: Rule 1 bug in oc-core.cjs output() double-stringification
204+
- All CONTEXT requirements satisfied (CONTEXT-01, CONTEXT-02, CONTEXT-08, CONTEXT-09)
205+
- Commits: 7516b11, 4799fd8, a630614
206+
-**PHASE 16 ADDED** — pivot profile support
207+
- Phase directory created: `.planning/phases/16-pivot-profile-support/`
208+
- Roadmap updated with Phase 16 entry
209+
- Status: Not planned yet
210+
- Next: `/gsd-plan-phase 16` to create execution plan
211+
-**PHASE 15 PLAN 01 COMPLETE** — Fix set-profile script with comprehensive validation
212+
- Task 1: Fixed config.json schema to use current_oc_profile key with auto-migration
213+
- Task 2: Implemented two operation modes (with/without profile name)
214+
- Task 3: Model validation BEFORE any file modifications
215+
- Task 4: Opencode.json merge preserves non-gsd agents
216+
- Task 5: Backup system in .planning/backups/ with date stamps
217+
- Task 6: Structured JSON output with success/error format
218+
- Task 7: Local scope only (no --global flag)
219+
- All 7 SETPROFILE requirements satisfied
220+
- Commits: c4ad78d, 93c6c50, 9afe34d
179221
- ✓ Plan 01-01: Foundation utilities — logger, path-resolver, constants
180222
- ✓ Plan 01-02: Interactive prompt utilities
181223
- ✓ Plan 01-03: Service layer — ScopeManager and ConfigManager
@@ -338,13 +380,25 @@ v1 is successful when:
338380

339381
### Quick Tasks Completed
340382

341-
| # | Description | Date | Commit | Directory |
342-
|---|-------------|------|--------|-----------|
343-
| 1 | Add include option to translate.js config | 2026-02-19 | 6830b95 | [1-add-include-option-to-translate-js-confi](./quick/1-add-include-option-to-translate-js-confi/) |
344-
| 2 | Implement Simple Profile system for model assignment | 2026-02-22 | 322472f | [2-implement-simple-profile-system-for-mode](./quick/2-implement-simple-profile-system-for-mode/) |
345-
| 3 | Support multiple JSON config files in translate.js | 2026-02-23 | fa02a30 | [3-support-multiple-json-config-files-in-tr](./quick/3-support-multiple-json-config-files-in-tr/) |
383+
| # | Description | Date | Commit | Status | Directory |
384+
|---|-------------|------|--------|--------|-----------|
385+
| 1 | Add include option to translate.js config | 2026-02-19 | 6830b95 | | [1-add-include-option-to-translate-js-confi](./quick/1-add-include-option-to-translate-js-confi/) |
386+
| 2 | Implement Simple Profile system for model assignment | 2026-02-22 | 322472f | | [2-implement-simple-profile-system-for-mode](./quick/2-implement-simple-profile-system-for-mode/) |
387+
| 3 | Support multiple JSON config files in translate.js | 2026-02-23 | fa02a30 | | [3-support-multiple-json-config-files-in-tr](./quick/3-support-multiple-json-config-files-in-tr/) |
388+
| 4 | Extend update-opencode-json output with model IDs | 2026-03-01 | c2beb2f | | [4-extend-return-of-update-opencode-json-wi](./quick/4-extend-return-of-update-opencode-json-wi/) |
389+
| 5 | Create profile validation workflow | 2026-03-01 | c736845 | | [5-create-a-workflow-in-gsd-opencode-get-sh](./quick/5-create-a-workflow-in-gsd-opencode-get-sh/) |
390+
| 6 | Add set-profile validation and remove legacy migration | 2026-03-02 | daf2e11 | Verified | [6-gsd-oc-tools-cjs-set-profile-should-not-](./quick/6-gsd-oc-tools-cjs-set-profile-should-not-/) |
391+
| 7 | Fix set-profile to create opencode.json when missing | 2026-03-02 | f80ec5a | | [7-fix-set-profile-to-not-migrate-and-creat](./quick/7-fix-set-profile-to-not-migrate-and-creat/) |
392+
393+
-**PHASE 14 PLAN 02 COMPLETE** — update-opencode-json command with profile-driven model updates
394+
- oc-config.cjs library with loadProfileConfig and applyProfileToOpencode
395+
- update-opencode-json command with --dry-run, --verbose, backup creation
396+
- Support for profiles.models and profiles.{type} config structures
397+
- Profile validation against whitelist (simple|smart|genius)
398+
- All 11 gsd-* agents updated from profile configuration
399+
- Auto-fixed: Rule 1 bug fix for profile structure mismatch (a9ca34e)
346400

347401
---
348402

349403
*State initialized: 2026-02-09*
350-
*Last updated: 2026-02-23 (Quick Task 3 Complete — Multi-config support)*
404+
*Last updated: 2026-03-02 (Quick Task 6 Complete — set-profile validation and legacy cleanup)*

.planning/config.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,28 @@
55
"commit_docs": false,
66
"model_profile": "quality",
77
"profiles": {
8-
"profile_type": "custom",
9-
"models": {
10-
"planning": "inherit",
11-
"execution": "inherit",
12-
"verification": "sonnet"
8+
"presets": {
9+
"quality": {
10+
"planning": "bailian-coding-plan/qwen3.5-plus",
11+
"execution": "bailian-coding-plan/qwen3.5-plus",
12+
"verification": "bailian-coding-plan/qwen3.5-plus"
13+
},
14+
"balanced": {
15+
"planning": "bailian-coding-plan/qwen3.5-plus",
16+
"execution": "bailian-coding-plan/qwen3.5-plus",
17+
"verification": "bailian-coding-plan/qwen3.5-plus"
18+
},
19+
"budget": {
20+
"planning": "bailian-coding-plan/qwen3.5-plus",
21+
"execution": "bailian-coding-plan/qwen3.5-plus",
22+
"verification": "bailian-coding-plan/qwen3.5-plus"
23+
}
1324
}
1425
},
1526
"workflow": {
1627
"research": true,
1728
"plan_check": true,
1829
"verifier": true
19-
}
20-
}
30+
},
31+
"current_oc_profile": "quality"
32+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
phase: 14-gsd-oc-tools-cjs-for-quick-operations
3+
plan: 02
4+
subsystem: infra
5+
tags: cli, validation, opencode, nodejs, commonjs, profile
6+
7+
# Dependency graph
8+
requires:
9+
- phase: 14-gsd-oc-tools-cjs-for-quick-operations
10+
provides: gsd-oc-tools.cjs CLI framework, oc-core.cjs utilities, oc-models.cjs model validation
11+
provides:
12+
- update-opencode-json command for updating agent models from profile
13+
- oc-config.cjs library for profile loading and application
14+
affects:
15+
- Future phases using profile-based model assignment automation
16+
- Workflow automation requiring profile-driven config updates
17+
18+
# Tech tracking
19+
tech-stack:
20+
added:
21+
- oc-config.cjs (profile configuration library)
22+
- update-opencode-json.cjs (command module)
23+
patterns:
24+
- Profile-driven configuration updates
25+
- Backup-before-modify pattern
26+
- Dry-run preview mode
27+
- JSON envelope output format
28+
29+
key-files:
30+
created:
31+
- gsd-opencode/get-shit-done/bin/lib/oc-config.cjs
32+
- gsd-opencode/get-shit-done/bin/commands/update-opencode-json.cjs
33+
modified:
34+
- gsd-opencode/get-shit-done/bin/gsd-oc-tools.cjs
35+
36+
key-decisions:
37+
- "Support both profiles.models and profiles.{type} structures for backward compatibility"
38+
- "Profile to agent mapping: planning→7 agents, execution→2 agents, verification→2 agents"
39+
40+
patterns-established:
41+
- "Profile configuration loaded from .planning/config.json"
42+
- "VALID_PROFILES whitelist: simple|smart|genius"
43+
- "Backup creation before any modifications using createBackup()"
44+
45+
requirements-completed: []
46+
47+
# Metrics
48+
duration: 4 min
49+
completed: 2026-03-01
50+
---
51+
52+
# Phase 14 Plan 02: update-opencode-json Command Summary
53+
54+
**Created update-opencode-json command with profile-driven model assignment updates and backup creation**
55+
56+
## Performance
57+
58+
- **Duration:** 4 min
59+
- **Started:** 2026-03-01T03:27:39Z
60+
- **Completed:** 2026-03-01T03:32:02Z
61+
- **Tasks:** 3
62+
- **Files modified:** 3
63+
64+
## Accomplishments
65+
66+
- oc-config.cjs library module with loadProfileConfig and applyProfileToOpencode functions
67+
- update-opencode-json command with --dry-run preview and --verbose modes
68+
- Timestamped backup creation before modifications (.opencode-backups/)
69+
- Profile validation against whitelist (simple|smart|genius)
70+
- Support for both profiles.models and profiles.{type} config structures
71+
- All 11 gsd-* agents updated from profile configuration
72+
73+
## Task Commits
74+
75+
Each task was committed atomically:
76+
77+
1. **Task 1: Create oc-config.cjs library module** - `7124aa8` (feat)
78+
2. **Task 2: Create update-opencode-json command** - `6db03b3` (feat)
79+
3. **Task 3: Register update-opencode-json in main entry point** - `4462595` (feat)
80+
4. **Fix: Support profiles.models structure** - `a9ca34e` (fix)
81+
82+
## Files Created/Modified
83+
84+
- `gsd-opencode/get-shit-done/bin/lib/oc-config.cjs` - Profile configuration library with VALID_PROFILES and PROFILE_AGENT_MAPPING
85+
- `gsd-opencode/get-shit-done/bin/commands/update-opencode-json.cjs` - Update command with dry-run, verbose, backup
86+
- `gsd-opencode/get-shit-done/bin/gsd-oc-tools.cjs` - Updated with update-opencode-json command routing and help
87+
88+
## Decisions Made
89+
90+
- Support both `profiles.models.{category}` and `profiles.{type}` structures for backward compatibility
91+
- Profile to agent mapping hardcoded in PROFILE_AGENT_MAPPING constant (planning→7 agents, execution→2, verification→2)
92+
- Backup directory: `.opencode-backups/` with ISO timestamp format (YYYYMMDD-HHmmss-SSS)
93+
94+
## Deviations from Plan
95+
96+
### Auto-fixed Issues
97+
98+
**1. [Rule 1 - Bug] Fixed profile structure mismatch**
99+
- **Found during:** Task 2 (update-opencode-json testing)
100+
- **Issue:** Config uses `profiles.models.{planning|execution|verification}` but code expected `profiles.{profileType}`
101+
- **Fix:** Updated both oc-config.cjs and update-opencode-json.cjs to support both structures with fallback
102+
- **Files modified:** gsd-opencode/get-shit-done/bin/lib/oc-config.cjs, gsd-opencode/get-shit-done/bin/commands/update-opencode-json.cjs
103+
- **Verification:** update-opencode-json --verbose successfully updates 11 agents, creates backup
104+
- **Committed in:** a9ca34e (fix commit)
105+
106+
---
107+
108+
**Total deviations:** 1 auto-fixed (1 bug fix)
109+
**Impact on plan:** Fix essential for profile loading to work with actual config structure. No scope creep.
110+
111+
## Issues Encountered
112+
113+
- Profile structure in .planning/config.json uses nested `profiles.models` format instead of direct `profiles.{type}` - discovered during testing and fixed via Rule 1
114+
115+
## User Setup Required
116+
117+
None - no external service configuration required.
118+
119+
## Next Phase Readiness
120+
121+
- update-opencode-json command ready for production use
122+
- Can be extended with additional profile categories or agent mappings
123+
- Backup system provides safety for automated config updates
124+
125+
---
126+
127+
*Phase: 14-gsd-oc-tools-cjs-for-quick-operations*
128+
*Completed: 2026-03-01*
129+
130+
## Self-Check: PASSED
131+
132+
- All 3 created/modified files verified on disk
133+
- All 4 commits verified in git history
134+
- Commands tested: check-opencode-json, check-config-json, update-opencode-json (--dry-run, --verbose, actual update)
135+
- Backup creation verified: .opencode-backups/ contains timestamped backups
136+
- Error handling verified: INVALID_PROFILE returns exit code 1

0 commit comments

Comments
 (0)