feat(factory): manage Droid settings from dotfiles - #2258
Conversation
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds generated Factory Droid settings with a local Gemma model and tool hooks. Home Manager merges these settings into existing Factory configuration. Shared hooks now document and recognize Factory Droid operations. ChangesFactory Droid settings
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant HomeManager
participant FactoryActivation
participant ActivateSettings
participant jq
participant FactorySettings
HomeManager->>FactoryActivation: run activation after writeBoundary
FactoryActivation->>ActivateSettings: pass managed settings and jq
ActivateSettings->>jq: merge settings and filter managed hooks
jq-->>ActivateSettings: return staged JSON
ActivateSettings->>FactorySettings: atomically replace settings.json
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@config/factory/activate-settings.sh`:
- Line 10: Update the temporary-file creation in activate-settings.sh to place
TEMP_SETTINGS inside FACTORY_DIR rather than relying on mktemp’s default
directory. Ensure the temporary path used by the subsequent activation and mv
operations is within the same filesystem as settings.json, preserving atomic
replacement.
- Around line 21-30: Update is_managed_droid_command and clean_hook_group to
remove only exact managed matcher-and-command pairs, rather than every command
under config/shared/hooks/. Preserve unrelated Factory hook groups, including
entries sharing a command path but using different matchers or arguments, while
retaining cleanup of the two managed matcher groups.
- Around line 73-75: Update the settings-file permission in the activation flow
after moving "$TEMP_SETTINGS" to "$SETTINGS" so ~/.factory/settings.json is set
to mode 600 instead of 644, keeping API keys unreadable by other local users.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 913205f7-b23e-48e3-b2c5-4627ebd9f9a6
📒 Files selected for processing (11)
config/factory/activate-settings.shconfig/factory/default.nixconfig/factory/settings.jsonconfig/factory/settings.tpl.jsonconfig/shared/hooks/README.mdconfig/shared/hooks/block-gh-settings.shconfig/shared/hooks/block-git-push.shconfig/shared/hooks/secret-guard.shconfig/shared/hooks/security.shmodels.jsonscripts/llm-update.sh
|
Addressed in the follow-up commit
Validated with Bash syntax, ShellCheck, jq checks, fresh/legacy activation tests, and |
|
Follow-up commit
Added expanded-path and non-array-hook regression checks; prior mode, atomic-temp, legacy-cleanup, ShellCheck, jq, and syntax checks remain green. |
Summary
models.jsonhydrationValidation
jqJSON validationgit diff --checkmake buildSummary by cubic
Manage Factory Droid model and guardrail hooks from dotfiles, merging them into Factory settings without overwriting user preferences. Adds a local Gemma preset, sets it as default, and makes activation idempotent while cleaning legacy entries and writing atomically.
~/.factory/settings.jsonwithjq, preserving other settings and removing legacy Droid hooks, duplicate managed hooks, and staleimportedClaudeHooksrefs.models.jsonviaconfig/factory/settings.tpl.jsonand hydrated byscripts/llm-update.sh.git-aicheckpoints on PreToolUse/PostToolUse for write/edit with correct Execute/Edit matchers.config/factory/default.nixusingactivate-settings.sh; idempotent, uses a temp file, and setschmod 600for safer writes.Written for commit c55ea57. Summary will update on new commits.