dsh-context-domains 0.3.1 → 0.3.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/lib/http.js +2 -1
- package/lib/version.js +16 -0
- package/package.json +1 -1
package/lib/http.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { randomUUID } from 'node:crypto'
|
|
4
4
|
import { domainCounts, requestedMembers, selectionFor, unassigned } from './resolve.js'
|
|
5
5
|
import { estimateTokens } from './config.js'
|
|
6
|
+
import { VERSION } from './version.js'
|
|
6
7
|
import { readCatalogAll, readSkills, readTools, suggestDomains } from './catalog.js'
|
|
7
8
|
|
|
8
9
|
const PREFIX = '/context-domains/api'
|
|
@@ -180,7 +181,7 @@ export function registerHttp(ctx, deps) {
|
|
|
180
181
|
async 'GET /health'(_req, res) {
|
|
181
182
|
ok(res, {
|
|
182
183
|
plugin: 'context-domains',
|
|
183
|
-
version:
|
|
184
|
+
version: VERSION,
|
|
184
185
|
stateFile: store.file,
|
|
185
186
|
config,
|
|
186
187
|
domains: store.document().domains.length,
|
package/lib/version.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// 插件自报版本:只从 package.json 读,绝不手写常量。
|
|
2
|
+
// 之前 /health 里写死 '0.1.0',发到 0.3.x 之后它仍报 0.1.0,排障时先被骗一次。
|
|
3
|
+
import { readFileSync } from 'node:fs'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
function readVersion() {
|
|
7
|
+
try {
|
|
8
|
+
const file = fileURLToPath(new URL('../package.json', import.meta.url))
|
|
9
|
+
const parsed = JSON.parse(readFileSync(file, 'utf8'))
|
|
10
|
+
return typeof parsed.version === 'string' ? parsed.version : '0.0.0'
|
|
11
|
+
} catch {
|
|
12
|
+
return '0.0.0'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const VERSION = readVersion()
|