Files
accounted/lib/agent/intents/__tests__/shared-rules.test.ts
T
Jakob Wennberg ec27228a8e style: remove em/en dashes repo-wide, add CLAUDE.md rule against them (#890)
Em dashes (—) and en dashes (–) had spread across comments, docs, tests,
and a few UI strings, reading as AI-generated boilerplate rather than
house style. Replaced each with punctuation matching its context: colon
for explanatory clauses, comma for asides, plain hyphen for numeric/legal
ranges (e.g. "21-23§"), "to"/"till" for date ranges, parentheses for
paired-dash asides. messages/en.json and messages/sv.json were fixed by
hand together to keep sv/en in sync.

Left untouched where the dash is the functional subject rather than
decorative punctuation: date-range-parser.ts's separator regex,
charset-repair.ts's CP1252 byte-mapping table (and its test), the SIE
encoding mojibake docs, generic-csv.ts's minus-sign normalizer, the
agent system-prompt files that already instruct against em dashes, and
a golden iXBRL test fixture compared byte-for-byte.

Also fixes two bugs surfaced along the way: an off-by-one in
ApiKeysPanel's scope-label split (a leftover from an earlier partial
pass), and a charset-repair test that had lost the literal en-dash it
exists to verify.

Regenerated the agent atom seed migration (skills:generate) since 27
SKILL.md files changed. Added a CLAUDE.md rule against em/en dashes,
with an explicit carve-out for the functional-dash cases above.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 15:58:06 +02:00

43 lines
2.0 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { renderAgentGroundRules, AGENT_GROUND_RULES } from '../shared-rules'
// AGENT_GROUND_RULES is rendered into the first user message of the bookkeeping
// intents that inject it (general.help, vat-review, invoice-draft,
// supplier_invoice.review, bokslut.step, verifikation.draft). It owns the
// bookkeeping-specific HEURISTICS: underlag-first, no BAS numbers in chat,
// counterparty history, representation, known-counterparty defaults.
//
// The cross-cutting EPISTEMICS rules (load before quoting a rate; don't infer
// the business from an SNI code) deliberately do NOT live here anymore. They
// live exactly once, in the always-on system prompt (buildIdentityBlock: see
// system-prompt.test.ts), which is re-sent every turn in the high-salience
// system position. This file guards both: that the heuristics stay, and that
// the epistemics are not re-duplicated back into the first user message.
const text = renderAgentGroundRules()
describe('agent ground rules: bookkeeping heuristics it owns', () => {
it('keeps underlag-first, no-BAS-in-chat, history, representation, known counterparties', () => {
expect(text).toContain('UNDERLAG FÖRST')
expect(text).toContain('INGA BAS-KONTONUMMER')
expect(text).toContain('KOLLA HISTORIK FÖRST')
expect(text).toContain('REPRESENTATION')
expect(text).toContain('KÄNDA MOTPARTER')
})
it('still renders as a non-trivial joined block', () => {
expect(AGENT_GROUND_RULES.length).toBeGreaterThan(10)
expect(text.split('\n').length).toBeGreaterThan(10)
})
})
describe('agent ground rules: epistemics live in the system prompt, not here', () => {
it('does not re-duplicate the always-on epistemics / anti-speculation rules', () => {
// These moved to buildIdentityBlock (always-on Block 2). Re-adding them here
// restores the triplication this cleanup removed.
expect(text).not.toContain('12 %→6 %')
expect(text).not.toContain('GISSA INTE BOLAGETS VERKSAMHET')
expect(text).not.toContain('är du säker?')
})
})