mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-04-28 06:59:37 +00:00
chore: hoist Pi model sort + cover bash-utils edge cases
- Move modelDisplayEntries sort to module scope so it runs once instead of on every modelDisplayName call. - Add bash-utils tests for the env var prefix and true/false skip behaviors that came in with the Pi commit. Verified Pi token semantics against real session data: input + cacheRead + cacheWrite + output equals totalTokens exactly, confirming Anthropic-style accounting (cached tokens disjoint from input). No double-counting.
This commit is contained in:
parent
d92d5b3f26
commit
97c0869763
2 changed files with 19 additions and 2 deletions
|
|
@ -28,6 +28,9 @@ const toolNameMap: Record<string, string> = {
|
|||
patch: 'Patch',
|
||||
}
|
||||
|
||||
// Pre-sorted by key length descending so longer/more-specific keys match first
|
||||
const modelDisplayEntries = Object.entries(modelDisplayNames).sort((a, b) => b[0].length - a[0].length)
|
||||
|
||||
type PiEntry = {
|
||||
type: string
|
||||
id?: string
|
||||
|
|
@ -200,8 +203,7 @@ export function createPiProvider(sessionsDir?: string): Provider {
|
|||
displayName: 'Pi',
|
||||
|
||||
modelDisplayName(model: string): string {
|
||||
const entries = Object.entries(modelDisplayNames).sort((a, b) => b[0].length - a[0].length)
|
||||
for (const [key, name] of entries) {
|
||||
for (const [key, name] of modelDisplayEntries) {
|
||||
if (model.startsWith(key)) return name
|
||||
}
|
||||
return model
|
||||
|
|
|
|||
|
|
@ -58,6 +58,21 @@ describe('extractBashCommands', () => {
|
|||
it('handles single-quoted separators', () => {
|
||||
expect(extractBashCommands("echo 'hello && world'")).toEqual(['echo'])
|
||||
})
|
||||
|
||||
it('skips leading env var assignments', () => {
|
||||
expect(extractBashCommands('NODE_ENV=prod npm test')).toEqual(['npm'])
|
||||
expect(extractBashCommands('FOO=bar BAZ=qux ls -la')).toEqual(['ls'])
|
||||
})
|
||||
|
||||
it('skips standalone true/false', () => {
|
||||
expect(extractBashCommands('true && git status')).toEqual(['git'])
|
||||
expect(extractBashCommands('false || echo done')).toEqual(['echo'])
|
||||
expect(extractBashCommands('true')).toEqual([])
|
||||
})
|
||||
|
||||
it('handles env vars combined with chained commands', () => {
|
||||
expect(extractBashCommands('NODE_ENV=test npm test && git push')).toEqual(['npm', 'git'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('BASH_TOOLS', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue