stk-codegen 1.2.0 → 1.2.2
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/README.md +39 -0
- package/dist/327.index.js +117 -0
- package/dist/i18n/en_US.yaml +30 -0
- package/dist/index.js +27 -28
- package/package.json +18 -4
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
CLI interativa (TUI com Ink/React) para se conectar a um agente CodeGen via HTTP/WebSocket.
|
|
4
4
|
|
|
5
5
|
- [Execução da CLI](#execução-da-cli)
|
|
6
|
+
- [Configurações e Permissões (User Settings)](#configurações-e-permissões-user-settings)
|
|
6
7
|
- [Configuração do backend](#configuração-do-backend)
|
|
7
8
|
- [Endpoints esperados](#endpoints-esperados)
|
|
8
9
|
- [Rodando a CLI em modo de desenvolvimento](#rodando-a-cli-em-modo-desenvolvimento)
|
|
@@ -14,6 +15,33 @@ CLI interativa (TUI com Ink/React) para se conectar a um agente CodeGen via HTTP
|
|
|
14
15
|
|
|
15
16
|
## Execução da CLI
|
|
16
17
|
|
|
18
|
+
### Autenticação
|
|
19
|
+
|
|
20
|
+
A CLI suporta dois modos de autenticação:
|
|
21
|
+
|
|
22
|
+
1. **Interativo (device flow)**: solicitado quando não há sessão autenticada e as variáveis de client-credentials não estão configuradas.
|
|
23
|
+
2. **Não-interativo (client credentials via env vars)**: quando as variáveis abaixo estiverem configuradas, a CLI autentica automaticamente sem prompt.
|
|
24
|
+
|
|
25
|
+
Variáveis de ambiente (client credentials):
|
|
26
|
+
|
|
27
|
+
- `STK_CODEGEN_IAM_REALM` (ex.: `stackspot`)
|
|
28
|
+
- `STK_CODEGEN_IAM_CLIENT_ID`
|
|
29
|
+
- `STK_CODEGEN_IAM_CLIENT_SECRET`
|
|
30
|
+
|
|
31
|
+
Opcional:
|
|
32
|
+
|
|
33
|
+
- `AUTH_DEVICE_URL` (default: `https://auth.stackspot.com`)
|
|
34
|
+
|
|
35
|
+
Exemplo:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
export STK_CODEGEN_IAM_REALM=stackspot
|
|
39
|
+
export STK_CODEGEN_IAM_CLIENT_ID=your-client-id
|
|
40
|
+
export STK_CODEGEN_IAM_CLIENT_SECRET=your-client-secret
|
|
41
|
+
|
|
42
|
+
stk-codegen
|
|
43
|
+
```
|
|
44
|
+
|
|
17
45
|
**Pré‑requisitos**
|
|
18
46
|
|
|
19
47
|
- [Node.js](https://nodejs.org/) (versão LTS recomendada > 22.x)
|
|
@@ -62,6 +90,17 @@ pnpm dev
|
|
|
62
90
|
|
|
63
91
|
---
|
|
64
92
|
|
|
93
|
+
## Configurações e Permissões (User Settings)
|
|
94
|
+
|
|
95
|
+
O CodeGen CLI possui um sistema de permissões baseado em arquivos YAML que permite controlar quais ferramentas o agente pode executar.
|
|
96
|
+
|
|
97
|
+
Para saber mais, consulte:
|
|
98
|
+
|
|
99
|
+
- [Guia do Usuário](./docs/USER_SETTINGS.md): Como configurar o `settings.yaml` e gerenciar permissões.
|
|
100
|
+
- [Documentação Técnica](./docs/TECHNICAL_USER_SETTINGS.md): Detalhes sobre a arquitetura do sistema de permissões.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
65
104
|
**Passos para executar localmente (apontando para backend local)**
|
|
66
105
|
|
|
67
106
|
## Configuração do backend
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export const id = 327;
|
|
2
|
+
export const ids = [327];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 5327:
|
|
6
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// EXPORTS
|
|
10
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
runHeadless: () => (/* binding */ runHeadless)
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// EXTERNAL MODULE: ./src/services/websocketClient.ts
|
|
15
|
+
var websocketClient = __webpack_require__(2435);
|
|
16
|
+
;// CONCATENATED MODULE: ./src/core/agent/approvalStrategy.ts
|
|
17
|
+
class AutoApprovalStrategy {
|
|
18
|
+
async approveShell(_pending) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
async approveDiff(_review) {
|
|
22
|
+
return ['accepted', undefined];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// EXTERNAL MODULE: ./src/core/agent/toolExecutor.ts
|
|
27
|
+
var agent_toolExecutor = __webpack_require__(7035);
|
|
28
|
+
;// CONCATENATED MODULE: ./src/headless/HeadlessRunner.ts
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
async function runHeadless(prompt, effort) {
|
|
33
|
+
const approvalStrategy = new AutoApprovalStrategy();
|
|
34
|
+
const toolExecutor = new agent_toolExecutor/* ToolExecutor */.K(approvalStrategy, {
|
|
35
|
+
onStateEvent: (eventType, data) => {
|
|
36
|
+
if (process.env['STK_DEBUG_AGENT_STREAM'] === '1') {
|
|
37
|
+
process.stderr.write(`[headless] ${eventType} ${JSON.stringify(data ?? {})}\n`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const currentToolIds = new Set();
|
|
42
|
+
let resolved = false;
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
const finalize = (err) => {
|
|
45
|
+
if (resolved)
|
|
46
|
+
return;
|
|
47
|
+
resolved = true;
|
|
48
|
+
if (err)
|
|
49
|
+
reject(err);
|
|
50
|
+
else
|
|
51
|
+
resolve();
|
|
52
|
+
};
|
|
53
|
+
const handleMessage = (data) => {
|
|
54
|
+
if (data.type === 'agent_error') {
|
|
55
|
+
const message = data.payload?.message || 'Agent error';
|
|
56
|
+
process.stderr.write(`Error: ${message}\n`);
|
|
57
|
+
finalize(new Error(message));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (data.type === 'agent_message') {
|
|
61
|
+
const content = data.payload?.content || '';
|
|
62
|
+
process.stdout.write(content);
|
|
63
|
+
if (!content.endsWith('\n'))
|
|
64
|
+
process.stdout.write('\n');
|
|
65
|
+
finalize();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (data.type === 'agent_message_delta') {
|
|
69
|
+
const content = data.payload?.content || '';
|
|
70
|
+
process.stdout.write(content);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (data.type === 'agent_thought') {
|
|
74
|
+
if (process.env['STK_DEBUG_AGENT_STREAM'] === '1') {
|
|
75
|
+
process.stderr.write(`[thought] ${data.payload?.content || ''}\n`);
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (data.type === 'agent_finished') {
|
|
80
|
+
process.stdout.write('\n');
|
|
81
|
+
finalize();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (data.type === 'run_tool') {
|
|
85
|
+
const { tool_id } = data.payload;
|
|
86
|
+
if (currentToolIds.has(tool_id))
|
|
87
|
+
return;
|
|
88
|
+
currentToolIds.add(tool_id);
|
|
89
|
+
Promise.resolve().then(() => toolExecutor.execute(data.payload));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (data.type === 'agent_generation_cancelled') {
|
|
93
|
+
process.stderr.write('Agent generation was cancelled.\n');
|
|
94
|
+
finalize();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
websocketClient/* websocketClient */.V
|
|
98
|
+
.connect(handleMessage, (status) => {
|
|
99
|
+
if (process.env['STK_DEBUG_WS'] === '1') {
|
|
100
|
+
process.stderr.write(`[ws] status: ${status}\n`);
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
.then(() => {
|
|
104
|
+
websocketClient/* websocketClient */.V.send({
|
|
105
|
+
type: 'user_message',
|
|
106
|
+
payload: { prompt },
|
|
107
|
+
effort: effort
|
|
108
|
+
});
|
|
109
|
+
})
|
|
110
|
+
.catch(finalize);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
/***/ })
|
|
116
|
+
|
|
117
|
+
};
|
package/dist/i18n/en_US.yaml
CHANGED
|
@@ -16,6 +16,19 @@ STK_MESSAGE_OUTPUT_ERROR_INVALID_COMMAND: '`{command}` is not a valid command.'
|
|
|
16
16
|
STK_MESSAGE_OUTPUT_INFO_USE_HELP_TO_SEE_AVAILABLE_COMMANDS: Use --help to see available commands.
|
|
17
17
|
STK_MESSAGE_OUTPUT_SUCCESS_LOGIN_PERFORMED_SUCCESSFULLY_WITH_EMAIL: Login performed successfully using e-mail {email}!
|
|
18
18
|
STK_MESSAGE_OUTPUT_SUCCESS_LOGOUT_PERFORMED_SUCCESSFULLY: Logout performed successfully.
|
|
19
|
+
|
|
20
|
+
# Shortcuts table (/help, /?)
|
|
21
|
+
STK_MESSAGE_UI_SHORTCUTS_TITLE: Shortcuts
|
|
22
|
+
STK_MESSAGE_UI_SHORTCUTS_COLUMN_KEYS: Keys
|
|
23
|
+
STK_MESSAGE_UI_SHORTCUTS_COLUMN_ACTION: Action
|
|
24
|
+
STK_MESSAGE_UI_SHORTCUTS_ROW_CTRL_T: toggle AUTO / APPROVAL mode
|
|
25
|
+
STK_MESSAGE_UI_SHORTCUTS_ROW_ESC: cancel agent response (when thinking/streaming)
|
|
26
|
+
STK_MESSAGE_UI_SHORTCUTS_ROW_ESC_ESC: clear current input
|
|
27
|
+
STK_MESSAGE_UI_SHORTCUTS_ROW_CTRL_C: exit (press Ctrl+C again to confirm)
|
|
28
|
+
STK_MESSAGE_UI_SHORTCUTS_ROW_CTRL_V: paste image from clipboard (attaches as [IMG#n])
|
|
29
|
+
STK_MESSAGE_UI_SHORTCUTS_ROW_CTRL_S: view full diff in static mode (when applicable)
|
|
30
|
+
STK_MESSAGE_UI_SHORTCUTS_ROW_ARROWS: prompt history (or move between lines in multiline)
|
|
31
|
+
|
|
19
32
|
STK_MESSAGE_UI_LOGIN_TITLE: Authentication
|
|
20
33
|
STK_MESSAGE_UI_LOGIN_EMAIL_LABEL: 'Login e-mail:'
|
|
21
34
|
STK_MESSAGE_UI_LOGIN_HINT_ENTER_TO_START: Type your e-mail and press Enter to start.
|
|
@@ -25,8 +38,25 @@ STK_MESSAGE_BUSINESS_EXCEPTION_LOGIN_MAX_RETRIES: Couldn't possible confirm the
|
|
|
25
38
|
STK_MESSAGE_BUSINESS_EXCEPTION_AUTH_CREATE_SESSION_FILE: Couldn't create session file at {sessionFile}
|
|
26
39
|
STK_MESSAGE_BUSINESS_EXCEPTION_AUTH_GET_SESSION_FILE: Couldn't read session file at {sessionFile}. Please login again.
|
|
27
40
|
STK_MESSAGE_BUSINESS_EXCEPTION_AUTH_GET_URLS_AND_DEVICE: An error occurred while retrieving URLS and device model. Check the logs for more details.
|
|
41
|
+
STK_MESSAGE_BUSINESS_EXCEPTION_AUTH_CLIENT_CREDENTIALS: An error occurred while authenticating using client credentials. Check your realm/client id/client secret and try again.
|
|
42
|
+
STK_MESSAGE_OUTPUT_ERROR_AUTH_CLIENT_CREDENTIALS_ENV_INCOMPLETE: 'Client-credentials auth is partially configured. Missing environment variables: {missing}'
|
|
28
43
|
STK_MESSAGE_BUSINESS_EXCEPTION_FETCH_WELL_KNOWN_DATA_ERROR: An error occurred while fetching for login urls.
|
|
29
44
|
STK_MESSAGE_BUSINESS_EXCEPTION_RENEW_SESSION_TOKEN_ERROR: 'An error occurred while renewing the session token. Check the logs for more details.'
|
|
30
45
|
STK_MESSAGE_BUSINESS_EXCEPTION_REVOKE_SESSION_TOKEN_ERROR: 'An error occurred while revoking the current session token. Check the logs for more details.'
|
|
31
46
|
STK_MESSAGE_OUTPUT_ERROR_BROWSER_OPEN_FAILED: Could not open your default browser automatically. Please open the URL manually
|
|
32
47
|
STK_MESSAGE_OUTPUT_ERROR_AUTH_VERIFICATION_URL_NOT_AVAILABLE: Could not start authentication because the verification URL was not provided by the identity provider.
|
|
48
|
+
STK_MESSAGE_OUTPUT_ERROR_UNEXPECTED_ERROR: 'Unexpected error during authentication: {message}'
|
|
49
|
+
STK_MESSAGE_OUTPUT_ERROR_TOOL_NOT_FOUND: "Error: Tool '{toolName}' not found."
|
|
50
|
+
STK_MESSAGE_OUTPUT_ERROR_USER_REJECTED_COMMAND_EXECUTION: User rejected command execution.
|
|
51
|
+
STK_MESSAGE_OUTPUT_ERROR_USER_REJECTED_CHANGES: User rejected changes.
|
|
52
|
+
STK_MESSAGE_OUTPUT_ERROR_HEADLESS_SESSION_ERROR: 'Headless session error: {message}'
|
|
53
|
+
STK_MESSAGE_OUTPUT_INFO_SHELL_REJECTED_BY_USER: '· Shell: {command} (rejected by user)'
|
|
54
|
+
STK_MESSAGE_OUTPUT_ERROR_SHELL_SIGINT_FAILED: 'Failed to send SIGINT to shell process: {error}'
|
|
55
|
+
STK_MESSAGE_OUTPUT_ERROR_INVALID_EFFORT: 'Invalid value for flag effort: {effort}.'
|
|
56
|
+
|
|
57
|
+
# User Settings
|
|
58
|
+
STK_MESSAGE_OUTPUT_ERROR_USER_SETTINGS_INVALID_FORMAT: 'Invalid {filePath} format:'
|
|
59
|
+
STK_MESSAGE_OUTPUT_ERROR_USER_SETTINGS_READ_ERROR: 'Error reading {filePath}: {error}'
|
|
60
|
+
STK_MESSAGE_OUTPUT_ERROR_USER_SETTINGS_INVALID_RULE: "Invalid rule format. Expected 'ToolName' or 'ToolName(argument)'"
|
|
61
|
+
STK_MESSAGE_OUTPUT_ERROR_USER_SETTINGS_DENIED_BY_LOCAL_SETTINGS: "Error: Tool '{toolName}' denied by local user settings (Rule: {rule})."
|
|
62
|
+
STK_MESSAGE_OUTPUT_ERROR_USER_SETTINGS_DENIED_BY_LOCAL_SETTINGS_NO_RULE: "Error: Tool '{toolName}' denied by local user settings."
|