mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-14 04:02:26 +00:00
fix(tui): address rollback guard and parity registry review
Load slash command names from the Python registry instead of regex-parsing source, and guard native rollback when no TUI session is active.
This commit is contained in:
parent
4f59510dd4
commit
8a33ed6136
3 changed files with 36 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { readFileSync } from 'node:fs'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
|
|
@ -38,8 +38,17 @@ const MUTATING_COMMANDS = [
|
|||
|
||||
const loadCommandRegistryNames = (): string[] => {
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const source = readFileSync(resolve(here, '../../../hermes_cli/commands.py'), 'utf8')
|
||||
const names = [...source.matchAll(/CommandDef\("([^"]+)"/g)].map(match => match[1]!)
|
||||
|
||||
const names = JSON.parse(
|
||||
execFileSync(
|
||||
process.env.PYTHON ?? 'python3',
|
||||
[
|
||||
'-c',
|
||||
'import json; from hermes_cli.commands import COMMAND_REGISTRY; print(json.dumps([c.name for c in COMMAND_REGISTRY]))'
|
||||
],
|
||||
{ cwd: resolve(here, '../../..'), encoding: 'utf8' }
|
||||
)
|
||||
) as string[]
|
||||
|
||||
return [...new Set(names)]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue