mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-20 15:13:47 +01:00
Every skill's voice directive now tells the agent to reply in the language of the user's latest message unless asked otherwise, so long English skill text no longer drags a Chinese (or any non-English) session into English. Mixed-language sessions follow the latest message. Code, commands, paths, identifiers and quoted output stay verbatim, and at tier 2+ so do the machine-read question markers (D<N>, option letters, (recommended)). The rule costs 205 bytes per tier-2+ skill and 144 per tier-1 skill. A further 25-byte cut to the bounded closer's exemption list leaves the net for this wave at +17 bytes per tier-2+ skill and +158 per tier-1 skill. review, qa and browse caps rise with measured notes; the ship goldens are refreshed. Co-authored-by: Xianying Tan <shrektan@126.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
40 lines
2.2 KiB
TypeScript
40 lines
2.2 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { execFileSync } from 'node:child_process';
|
|
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { generateVoiceDirective } from '../scripts/resolvers/preamble/generate-voice-directive';
|
|
import { HOST_PATHS, type TemplateContext } from '../scripts/resolvers/types';
|
|
import { between, expectMentions } from './helpers/prompt-structure';
|
|
|
|
const ctx: TemplateContext = { skillName: 'review', tmplPath: 'review/SKILL.md.tmpl', host: 'claude', paths: HOST_PATHS.claude };
|
|
const tiers: number[] = [1, 3];
|
|
|
|
describe('shared voice directive', () => {
|
|
test.each(tiers)('tier %i bans the load-bearing stock phrase on the AI-vocabulary line', tier => {
|
|
const banLine = generateVoiceDirective(ctx, tier).split('\n').find(line => line.includes('No AI vocabulary:'));
|
|
expect(banLine).toBeDefined();
|
|
expect(banLine!).toContain('load-bearing');
|
|
});
|
|
|
|
test.each(tiers)('tier %i replies in the language of the latest message and keeps technical text verbatim', tier => {
|
|
const voice = generateVoiceDirective(ctx, tier);
|
|
expectMentions(voice, [
|
|
['reply', 'language', "user's latest message", 'unless'],
|
|
['code', 'commands', 'paths', 'identifiers', 'quoted output', 'verbatim'],
|
|
], `tier ${tier} voice`);
|
|
if (tier >= 2) expectMentions(voice, [['question markers', '`D<N>`', 'option letters', '`(recommended)`', 'verbatim']], 'tier 3 voice');
|
|
});
|
|
|
|
test('every generated skill with a Voice section carries the reply-language rule', () => {
|
|
const root = join(import.meta.dir, '..');
|
|
const skills = execFileSync('git', ['ls-files', 'SKILL.md', '*/SKILL.md'], { cwd: root, encoding: 'utf8', timeout: 10_000 }).split('\n').filter(Boolean);
|
|
const voiced = skills.filter(file => readFileSync(join(root, file), 'utf8').includes('\n## Voice\n'));
|
|
expect(voiced.length).toBeGreaterThan(40);
|
|
const missing = voiced.filter(file => {
|
|
const voice = between(readFileSync(join(root, file), 'utf8'), '\n## Voice\n', /\n## /).toLowerCase();
|
|
return !(voice.includes('language') && voice.includes('latest message') && voice.includes('verbatim'));
|
|
});
|
|
expect(missing).toEqual([]);
|
|
});
|
|
});
|