codeep 1.2.25 → 1.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/commands.d.ts +10 -0
- package/dist/acp/commands.js +131 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CommandResult {
|
|
2
|
+
handled: boolean;
|
|
3
|
+
response: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Try to handle a slash command. Returns { handled: true, response } if the
|
|
7
|
+
* input was a command, or { handled: false, response: '' } to let it pass
|
|
8
|
+
* through to the agent loop.
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleCommand(input: string): CommandResult;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// src/acp/commands.ts
|
|
2
|
+
// Slash command handler for ACP sessions.
|
|
3
|
+
// Commands are intercepted before the agent loop and handled directly.
|
|
4
|
+
import { config, setProvider, getModelsForCurrentProvider, setApiKey, getMaskedApiKey } from '../config/index.js';
|
|
5
|
+
import { PROVIDERS } from '../config/providers.js';
|
|
6
|
+
/**
|
|
7
|
+
* Try to handle a slash command. Returns { handled: true, response } if the
|
|
8
|
+
* input was a command, or { handled: false, response: '' } to let it pass
|
|
9
|
+
* through to the agent loop.
|
|
10
|
+
*/
|
|
11
|
+
export function handleCommand(input) {
|
|
12
|
+
const trimmed = input.trim();
|
|
13
|
+
if (!trimmed.startsWith('/'))
|
|
14
|
+
return { handled: false, response: '' };
|
|
15
|
+
const [cmd, ...args] = trimmed.slice(1).split(/\s+/);
|
|
16
|
+
switch (cmd.toLowerCase()) {
|
|
17
|
+
case 'help':
|
|
18
|
+
return { handled: true, response: buildHelp() };
|
|
19
|
+
case 'settings':
|
|
20
|
+
return { handled: true, response: buildSettings() };
|
|
21
|
+
case 'provider': {
|
|
22
|
+
const id = args[0];
|
|
23
|
+
if (!id)
|
|
24
|
+
return { handled: true, response: buildProviderList() };
|
|
25
|
+
return { handled: true, response: setProviderCmd(id) };
|
|
26
|
+
}
|
|
27
|
+
case 'model': {
|
|
28
|
+
const id = args[0];
|
|
29
|
+
if (!id)
|
|
30
|
+
return { handled: true, response: buildModelList() };
|
|
31
|
+
return { handled: true, response: setModelCmd(id) };
|
|
32
|
+
}
|
|
33
|
+
case 'apikey': {
|
|
34
|
+
const key = args[0];
|
|
35
|
+
if (!key)
|
|
36
|
+
return { handled: true, response: showApiKey() };
|
|
37
|
+
return { handled: true, response: setApiKeyCmd(key) };
|
|
38
|
+
}
|
|
39
|
+
case 'status':
|
|
40
|
+
return { handled: true, response: buildSettings() };
|
|
41
|
+
default:
|
|
42
|
+
return {
|
|
43
|
+
handled: true,
|
|
44
|
+
response: `Unknown command: \`/${cmd}\`\n\nType \`/help\` to see available commands.`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// ─── renderers ────────────────────────────────────────────────────────────────
|
|
49
|
+
function buildHelp() {
|
|
50
|
+
return [
|
|
51
|
+
'## Codeep Commands',
|
|
52
|
+
'',
|
|
53
|
+
'| Command | Description |',
|
|
54
|
+
'|---------|-------------|',
|
|
55
|
+
'| `/help` | Show this help |',
|
|
56
|
+
'| `/settings` | Show current configuration |',
|
|
57
|
+
'| `/provider` | List available providers |',
|
|
58
|
+
'| `/provider <id>` | Switch to a provider (e.g. `/provider anthropic`) |',
|
|
59
|
+
'| `/model` | List models for current provider |',
|
|
60
|
+
'| `/model <id>` | Switch model (e.g. `/model claude-opus-4-5`) |',
|
|
61
|
+
'| `/apikey <key>` | Set API key for current provider |',
|
|
62
|
+
'| `/apikey` | Show masked API key |',
|
|
63
|
+
'| `/status` | Same as /settings |',
|
|
64
|
+
].join('\n');
|
|
65
|
+
}
|
|
66
|
+
function buildSettings() {
|
|
67
|
+
const provider = config.get('provider');
|
|
68
|
+
const model = config.get('model');
|
|
69
|
+
const protocol = config.get('protocol');
|
|
70
|
+
const maskedKey = getMaskedApiKey(provider);
|
|
71
|
+
const providerConfig = PROVIDERS[provider];
|
|
72
|
+
return [
|
|
73
|
+
'## Current Configuration',
|
|
74
|
+
'',
|
|
75
|
+
`- **Provider:** ${providerConfig?.name ?? provider} (\`${provider}\`)`,
|
|
76
|
+
`- **Model:** \`${model}\``,
|
|
77
|
+
`- **Protocol:** \`${protocol}\``,
|
|
78
|
+
`- **API Key:** ${maskedKey ? `\`${maskedKey}\`` : '_not set_'}`,
|
|
79
|
+
'',
|
|
80
|
+
'Use `/provider`, `/model`, or `/apikey` to change settings.',
|
|
81
|
+
].join('\n');
|
|
82
|
+
}
|
|
83
|
+
function buildProviderList() {
|
|
84
|
+
const current = config.get('provider');
|
|
85
|
+
const lines = ['## Available Providers', ''];
|
|
86
|
+
for (const [id, p] of Object.entries(PROVIDERS)) {
|
|
87
|
+
const marker = id === current ? ' ✓' : '';
|
|
88
|
+
lines.push(`- \`${id}\`${marker} — **${p.name}**: ${p.description}`);
|
|
89
|
+
}
|
|
90
|
+
lines.push('', 'Use `/provider <id>` to switch.');
|
|
91
|
+
return lines.join('\n');
|
|
92
|
+
}
|
|
93
|
+
function setProviderCmd(id) {
|
|
94
|
+
if (!PROVIDERS[id]) {
|
|
95
|
+
return `Provider \`${id}\` not found.\n\n${buildProviderList()}`;
|
|
96
|
+
}
|
|
97
|
+
setProvider(id);
|
|
98
|
+
const p = PROVIDERS[id];
|
|
99
|
+
return `Switched to **${p.name}** (\`${id}\`). Default model: \`${p.defaultModel}\`.`;
|
|
100
|
+
}
|
|
101
|
+
function buildModelList() {
|
|
102
|
+
const current = config.get('model');
|
|
103
|
+
const models = getModelsForCurrentProvider();
|
|
104
|
+
const lines = ['## Models for Current Provider', ''];
|
|
105
|
+
for (const [id, label] of Object.entries(models)) {
|
|
106
|
+
const marker = id === current ? ' ✓' : '';
|
|
107
|
+
lines.push(`- \`${id}\`${marker} — ${label}`);
|
|
108
|
+
}
|
|
109
|
+
lines.push('', 'Use `/model <id>` to switch.');
|
|
110
|
+
return lines.join('\n');
|
|
111
|
+
}
|
|
112
|
+
function setModelCmd(id) {
|
|
113
|
+
const models = getModelsForCurrentProvider();
|
|
114
|
+
if (!models[id]) {
|
|
115
|
+
return `Model \`${id}\` not available for current provider.\n\n${buildModelList()}`;
|
|
116
|
+
}
|
|
117
|
+
config.set('model', id);
|
|
118
|
+
return `Model set to \`${id}\`.`;
|
|
119
|
+
}
|
|
120
|
+
function showApiKey() {
|
|
121
|
+
const provider = config.get('provider');
|
|
122
|
+
const masked = getMaskedApiKey(provider);
|
|
123
|
+
return masked
|
|
124
|
+
? `API key for \`${provider}\`: \`${masked}\``
|
|
125
|
+
: `No API key set for \`${provider}\`. Use \`/apikey <key>\` to set one.`;
|
|
126
|
+
}
|
|
127
|
+
function setApiKeyCmd(key) {
|
|
128
|
+
const provider = config.get('provider');
|
|
129
|
+
setApiKey(key, provider);
|
|
130
|
+
return `API key for \`${provider}\` saved.`;
|
|
131
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeep",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.27",
|
|
4
4
|
"description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|