mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 06:50:46 +08:00
Parse packaging-generated paths and load each local_skills/*/SKILL.md with the same hasSkills toggles and provider as shared packs. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
/**
|
|
* KB runtime env mirroring.
|
|
*/
|
|
|
|
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
|
|
import { resolveKbRoot } from '../src/netx/kb-manifest.ts'
|
|
import { applyKbEnv, getKbContext, publishKbContext, resetKbContext } from '../src/netx/kb-runtime.ts'
|
|
|
|
test('applyKbEnv clears identity when unconfigured', () => {
|
|
process.env.KB_ROOT = '/tmp/x'
|
|
process.env.KB_OPERATOR = 'IOH'
|
|
applyKbEnv(resolveKbRoot(''))
|
|
assert.equal(process.env.KB_STATUS, 'unconfigured')
|
|
assert.equal(process.env.KB_ROOT, undefined)
|
|
assert.equal(process.env.KB_OPERATOR, undefined)
|
|
resetKbContext()
|
|
})
|
|
|
|
test('publishKbContext updates store', () => {
|
|
publishKbContext({
|
|
status: 'configured',
|
|
realRoot: '/kb',
|
|
operatorName: 'IOH',
|
|
country: 'ID',
|
|
version: '1',
|
|
content: {
|
|
hasRegions: true,
|
|
hasTheory: false,
|
|
hasPacket: false,
|
|
hasCommon: false,
|
|
hasSkills: false,
|
|
},
|
|
paths: { skills: '_skills', localSkills: 'regions/ID/IOH/_local/local_skills' },
|
|
errorMessage: '',
|
|
})
|
|
const snap = getKbContext()
|
|
assert.equal(snap.status, 'configured')
|
|
assert.equal(snap.operatorName, 'IOH')
|
|
assert.equal(snap.paths.skills, '_skills')
|
|
assert.equal(snap.paths.localSkills, 'regions/ID/IOH/_local/local_skills')
|
|
applyKbEnv(snap)
|
|
assert.equal(process.env.KB_OPERATOR, 'IOH')
|
|
assert.equal(process.env.KB_COUNTRY, 'ID')
|
|
assert.ok(process.env.KB_CONTENT?.includes('"hasRegions":true'))
|
|
assert.equal(process.env.KB_CONTENT?.includes('"regions"'), false)
|
|
resetKbContext()
|
|
})
|