@semalt-ai/code 1.0.1 → 1.2.0

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.
Files changed (3) hide show
  1. package/README.md +18 -0
  2. package/index.js +12 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -23,6 +23,13 @@ It provides an interactive chat interface, one-shot code generation, AI-assisted
23
23
 
24
24
  The default configuration expects a local API server at `http://127.0.0.1:8800`.
25
25
 
26
+ The CLI accepts `api_base` in either of these forms:
27
+
28
+ - `http://127.0.0.1:8800`
29
+ - `http://127.0.0.1:8800/v1`
30
+
31
+ Both formats are normalized automatically.
32
+
26
33
  ## Installation
27
34
 
28
35
  Install the package globally so the `semalt-code` command is available system-wide.
@@ -64,6 +71,8 @@ Example config:
64
71
  }
65
72
  ```
66
73
 
74
+ You can also set `"api_base"` to a URL that already ends with `/v1`.
75
+
67
76
  ## Usage
68
77
 
69
78
  ```bash
@@ -96,6 +105,9 @@ semalt-code [command] [options]
96
105
  - `-m, --model <name>`
97
106
  Override the model name.
98
107
 
108
+ - `-v, --version`
109
+ Print the current CLI version.
110
+
99
111
  - `-f, --file <path>`
100
112
  Load one or more files or directories into the prompt context for `code`.
101
113
 
@@ -193,6 +205,12 @@ semalt-code shell -a "npm test"
193
205
  semalt-code models
194
206
  ```
195
207
 
208
+ ### Show the current version
209
+
210
+ ```bash
211
+ semalt-code --version
212
+ ```
213
+
196
214
  ## How Responses Are Rendered
197
215
 
198
216
  The CLI formats streamed output for terminal readability:
package/index.js CHANGED
@@ -10,6 +10,8 @@ const http = require('http');
10
10
  const https = require('https');
11
11
  const { URL } = require('url');
12
12
 
13
+ const PACKAGE_JSON = require('./package.json');
14
+
13
15
  // ── Config ────────────────────────────────────────────────────────────────────
14
16
 
15
17
  const DEFAULT_CONFIG = {
@@ -416,7 +418,10 @@ class StreamRenderer {
416
418
  // ── API Client ────────────────────────────────────────────────────────────────
417
419
 
418
420
  function apiUrl(urlPath) {
419
- return `${config.api_base.replace(/\/$/, '')}${urlPath}`;
421
+ const base = (config.api_base || '').replace(/\/$/, '');
422
+ const normalizedBase = /\/v1$/i.test(base) ? base : `${base}/v1`;
423
+ const normalizedPath = urlPath.startsWith('/v1/') ? urlPath.slice(3) : urlPath;
424
+ return `${normalizedBase}${normalizedPath}`;
420
425
  }
421
426
 
422
427
  function estimateTokens(text) {
@@ -1081,12 +1086,18 @@ Options:
1081
1086
  --api-base <url> API base URL (init)
1082
1087
  --api-key <key> API key (init)
1083
1088
  --default-model <name> Default model (init)
1089
+ -v, --version Show CLI version
1084
1090
 
1085
1091
  Config: ${CONFIG_PATH}
1086
1092
  `);
1087
1093
  return;
1088
1094
  }
1089
1095
 
1096
+ if (command === '--version' || command === '-v') {
1097
+ console.log(PACKAGE_JSON.version);
1098
+ return;
1099
+ }
1100
+
1090
1101
  if (command === 'chat') {
1091
1102
  const { opts } = parseArgs(rawArgs.slice(1));
1092
1103
  await cmdChat(opts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semalt-ai/code",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Self-hosted AI Coding Assistant CLI",
5
5
  "main": "index.js",
6
6
  "bin": {