[PR #951] [MERGED] Added sharing config with auto/disabled options #9755

Closed
opened 2026-02-16 18:14:07 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/951
Author: @opencode-agent[bot]
Created: 7/13/2025
Status: Merged
Merged: 7/13/2025
Merged by: @thdxr

Base: devHead: opencode/issue938-20250713_203633


📝 Commits (3)

  • 98dae79 Added sharing config with auto/disabled options
  • db3b165 Removed isSharingEnabled, renamed sharing→share, updated logic
  • deeccb0 Centralized sharing disabled check in share function

📊 Changes

3 files changed (+28 additions, -5 deletions)

View changed files

📝 packages/opencode/src/cli/cmd/run.ts (+11 -3)
📝 packages/opencode/src/config/config.ts (+9 -1)
📝 packages/opencode/src/session/index.ts (+8 -1)

📄 Description

Perfect! I've successfully implemented the requested changes to add a sharing config option that can be set to "auto" or "disabled" while maintaining backward compatibility with the deprecated autoshare field.

Summary of Changes

  1. Updated config schema (src/config/config.ts):

    • Added new sharing field with enum values "auto" | "disabled"
    • Marked autoshare field as deprecated with @deprecated comment
    • Added isSharingEnabled() helper function that respects both new and old config fields
  2. Updated sharing logic in multiple files:

    • Session creation (src/session/index.ts): Now uses Config.isSharingEnabled() instead of directly checking cfg.autoshare
    • CLI run command (src/cli/cmd/run.ts): Updated to use the new helper function and added error message when sharing is disabled but --share flag is used
  3. Backward compatibility:

    • The autoshare field is still respected for existing configurations
    • If sharing is explicitly set, it takes precedence over autoshare
    • If sharing is not set, falls back to autoshare behavior

Usage Examples

New configuration (recommended):

{
  "sharing": "disabled"
}

Legacy configuration (still works):

{
  "autoshare": false
}

Mixed configuration (sharing takes precedence):

{
  "sharing": "disabled",
  "autoshare": true
}

This implementation allows enterprise users to disable sharing entirely by setting "sharing": "disabled" in their configuration files, addressing the security concerns raised in the GitHub issue while maintaining full backward compatibility with existing configurations.

Closes #938

view session | view log


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/951 **Author:** [@opencode-agent[bot]](https://github.com/apps/opencode-agent) **Created:** 7/13/2025 **Status:** ✅ Merged **Merged:** 7/13/2025 **Merged by:** [@thdxr](https://github.com/thdxr) **Base:** `dev` ← **Head:** `opencode/issue938-20250713_203633` --- ### 📝 Commits (3) - [`98dae79`](https://github.com/anomalyco/opencode/commit/98dae7974fe778a50eabcb38c0b5166db6d7989b) Added sharing config with auto/disabled options - [`db3b165`](https://github.com/anomalyco/opencode/commit/db3b16515fdc827b4f180fbc1f141ff98486152a) Removed isSharingEnabled, renamed sharing→share, updated logic - [`deeccb0`](https://github.com/anomalyco/opencode/commit/deeccb0bd6487904b601735e3dcf8c4383412c21) Centralized sharing disabled check in share function ### 📊 Changes **3 files changed** (+28 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/cli/cmd/run.ts` (+11 -3) 📝 `packages/opencode/src/config/config.ts` (+9 -1) 📝 `packages/opencode/src/session/index.ts` (+8 -1) </details> ### 📄 Description Perfect! I've successfully implemented the requested changes to add a `sharing` config option that can be set to `"auto"` or `"disabled"` while maintaining backward compatibility with the deprecated `autoshare` field. ## Summary of Changes 1. **Updated config schema** (`src/config/config.ts`): - Added new `sharing` field with enum values `"auto"` | `"disabled"` - Marked `autoshare` field as deprecated with `@deprecated` comment - Added `isSharingEnabled()` helper function that respects both new and old config fields 2. **Updated sharing logic** in multiple files: - **Session creation** (`src/session/index.ts`): Now uses `Config.isSharingEnabled()` instead of directly checking `cfg.autoshare` - **CLI run command** (`src/cli/cmd/run.ts`): Updated to use the new helper function and added error message when sharing is disabled but `--share` flag is used 3. **Backward compatibility**: - The `autoshare` field is still respected for existing configurations - If `sharing` is explicitly set, it takes precedence over `autoshare` - If `sharing` is not set, falls back to `autoshare` behavior ## Usage Examples **New configuration (recommended):** ```json { "sharing": "disabled" } ``` **Legacy configuration (still works):** ```json { "autoshare": false } ``` **Mixed configuration (sharing takes precedence):** ```json { "sharing": "disabled", "autoshare": true } ``` This implementation allows enterprise users to disable sharing entirely by setting `"sharing": "disabled"` in their configuration files, addressing the security concerns raised in the GitHub issue while maintaining full backward compatibility with existing configurations. Closes #938 [view session](https://opencode.ai/s/2jA4FBlk) | [view log](/sst/opencode/actions/runs/16253176476) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:07 -05:00
yindo closed this issue 2026-02-16 18:14:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9755