Skip to content

Commit 7f959f4

Browse files
committed
chore(commands)!: remove legacy commands support
BREAKING CHANGE: Legacy commands have been removed You can you the `Opencode` which contains all commands
1 parent 03b9c69 commit 7f959f4

5 files changed

Lines changed: 4 additions & 115 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,6 @@ There's 3 main ways on how to change the snacks picker layout
587587

588588
The plugin provides the following actions that can be triggered via keymaps, commands, slash commands (typed in the input window), or the Lua API:
589589

590-
> **Note:** Commands have been restructured into a single `:Opencode` command with subcommands. Legacy `Opencode*` commands (e.g., `:OpencodeOpenInput`) are still available by default but will be removed in a future version. Update your scripts and workflows to use the new nested syntax.
591-
592590
| Action | Default keymap | Command | API Function |
593591
| ----------------------------------------------------------- | ------------------------------------- | ------------------------------------------- | ---------------------------------------------------------------------- |
594592
| Open opencode. Close if opened | `<leader>og` | `:Opencode` | `require('opencode.api').toggle()` |

lua/opencode/api.lua

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,53 +1487,6 @@ M.slash_commands_map = {
14871487
},
14881488
}
14891489

1490-
M.legacy_command_map = {
1491-
OpencodeSwapPosition = 'swap',
1492-
OpencodeToggleFocus = 'toggle_focus',
1493-
OpencodeOpenInput = 'open input',
1494-
OpencodeOpenInputNewSession = 'session new',
1495-
OpencodeOpenOutput = 'open output',
1496-
OpencodeCreateNewSession = 'session new',
1497-
OpencodeClose = 'close',
1498-
OpencodeStop = 'cancel',
1499-
OpencodeSelectSession = 'session select',
1500-
OpencodeSelectChildSession = 'session child',
1501-
OpencodeTogglePane = 'toggle_pane',
1502-
OpencodeConfigureProvider = 'models',
1503-
OpencodeConfigureVariant = 'variant',
1504-
OpencodeRun = 'run',
1505-
OpencodeRunNewSession = 'run_new',
1506-
OpencodeDiff = 'diff open',
1507-
OpencodeDiffNext = 'diff next',
1508-
OpencodeDiffPrev = 'diff prev',
1509-
OpencodeDiffClose = 'diff close',
1510-
OpencodeRevertAllLastPrompt = 'revert all prompt',
1511-
OpencodeRevertThisLastPrompt = 'revert this prompt',
1512-
OpencodeRevertAllSession = 'revert all session',
1513-
OpencodeRevertThisSession = 'revert this session',
1514-
OpencodeRevertAllToSnapshot = 'revert all',
1515-
OpencodeRevertThisToSnapshot = 'revert this',
1516-
OpencodeRestoreSnapshotFile = 'restore file',
1517-
OpencodeRestoreSnapshotAll = 'restore all',
1518-
OpencodeSetReviewBreakpoint = 'breakpoint',
1519-
OpencodeInit = 'session agents_init',
1520-
OpencodeHelp = 'help',
1521-
OpencodeMCP = 'mcp',
1522-
OpencodeAgentPlan = 'agent plan',
1523-
OpencodeAgentBuild = 'agent build',
1524-
OpencodeAgentSelect = 'agent select',
1525-
OpencodeRunUserCommand = 'command',
1526-
OpencodeCompactSession = 'session compact',
1527-
OpencodeShareSession = 'session share',
1528-
OpencodeUnshareSession = 'session unshare',
1529-
OpencodeUndo = 'undo',
1530-
OpencodeRedo = 'redo',
1531-
OpencodePermissionAccept = 'permission accept',
1532-
OpencodePermissionAcceptAll = 'permission accept_all',
1533-
OpencodePermissionDeny = 'permission deny',
1534-
OpencodePasteImage = 'paste_image',
1535-
}
1536-
15371490
function M.route_command(opts)
15381491
local args = vim.split(opts.args or '', '%s+', { trimempty = true })
15391492
---@type OpencodeSelectionRange|nil
@@ -1599,25 +1552,6 @@ function M.complete_command(arg_lead, cmd_line, cursor_pos)
15991552
return {}
16001553
end
16011554

1602-
function M.setup_legacy_commands()
1603-
if not config.legacy_commands then
1604-
return
1605-
end
1606-
1607-
for legacy_name, new_route in pairs(M.legacy_command_map) do
1608-
vim.api.nvim_create_user_command(legacy_name, function(opts)
1609-
vim.notify(
1610-
string.format(':%s is deprecated. Use `:Opencode %s` instead', legacy_name, new_route),
1611-
vim.log.levels.WARN
1612-
)
1613-
vim.cmd('Opencode ' .. new_route)
1614-
end, {
1615-
desc = 'deprecated',
1616-
nargs = '*',
1617-
})
1618-
end
1619-
end
1620-
16211555
M.get_slash_commands = Promise.async(function()
16221556
local result = {}
16231557
for slash_cmd, def in pairs(M.slash_commands_map) do
@@ -1653,8 +1587,6 @@ function M.setup()
16531587
range = true, -- Enable range support
16541588
complete = M.complete_command,
16551589
})
1656-
1657-
M.setup_legacy_commands()
16581590
end
16591591

16601592
return M

lua/opencode/config.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ M.defaults = {
1111
default_global_keymaps = true,
1212
default_mode = 'build',
1313
default_system_prompt = nil,
14-
legacy_commands = true,
1514
keymap_prefix = '<leader>o',
1615
opencode_executable = 'opencode',
1716
server = {

lua/opencode/types.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@
230230
---@field debug OpencodeDebugConfig
231231
---@field prompt_guard? fun(mentioned_files: string[]): boolean
232232
---@field hooks OpencodeHooks
233-
---@field legacy_commands boolean
234233
---@field quick_chat OpencodeQuickChatConfig
235234

236235
---@class MessagePartState

tests/unit/api_spec.lua

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -68,51 +68,12 @@ describe('opencode.api', function()
6868
end)
6969

7070
describe('setup', function()
71-
it('registers the main Opencode command and legacy commands', function()
71+
it('registers the main Opencode command', function()
7272
api.setup()
7373

74-
local main_cmd_found = false
75-
local legacy_cmd_count = 0
76-
77-
for i, cmd in ipairs(created_commands) do
78-
if cmd.name == 'Opencode' then
79-
main_cmd_found = true
80-
assert.equal('Opencode.nvim main command with nested subcommands', cmd.opts.desc)
81-
else
82-
legacy_cmd_count = legacy_cmd_count + 1
83-
assert.truthy(string.match(cmd.opts.desc, 'deprecated'), 'Legacy command should be marked as deprecated')
84-
end
85-
end
86-
87-
assert.truthy(main_cmd_found, 'Main Opencode command should be registered')
88-
assert.truthy(legacy_cmd_count > 0, 'Legacy commands should be registered')
89-
end)
90-
91-
it('sets up legacy command functions that route to main command', function()
92-
local stored_fns = {}
93-
local cmd_stub
94-
95-
vim.api.nvim_create_user_command = function(name, fn, _)
96-
stored_fns[name] = fn
97-
end
98-
99-
cmd_stub = stub(vim, 'cmd')
100-
101-
api.setup()
102-
103-
stored_fns['OpencodeOpenInput']()
104-
assert.stub(cmd_stub).was_called()
105-
assert.stub(cmd_stub).was_called_with('Opencode open input')
106-
107-
cmd_stub:clear()
108-
stored_fns['OpencodeStop']()
109-
assert.stub(cmd_stub).was_called_with('Opencode cancel')
110-
111-
cmd_stub:clear()
112-
stored_fns['OpencodeClose']()
113-
assert.stub(cmd_stub).was_called_with('Opencode close')
114-
115-
cmd_stub:revert()
74+
assert.equal(1, #created_commands)
75+
assert.equal('Opencode', created_commands[1].name)
76+
assert.equal('Opencode.nvim main command with nested subcommands', created_commands[1].opts.desc)
11677
end)
11778
end)
11879

0 commit comments

Comments
 (0)