Execution Rules メタデータを追加(git commit 禁止)

buildInstruction で自動付与される実行ルールを追加。
エージェントがコミットすると git diff が空になりレビューできなくなる問題を防ぐ。
This commit is contained in:
nrslib 2026-01-29 01:30:37 +09:00
parent 82193e6db4
commit 48e055ac8a
2 changed files with 13 additions and 6 deletions

View File

@ -192,13 +192,13 @@ describe('instruction-builder', () => {
}); });
describe('renderExecutionMetadata', () => { describe('renderExecutionMetadata', () => {
it('should render Working Directory only', () => { it('should render Working Directory and Execution Rules', () => {
const rendered = renderExecutionMetadata({ workingDirectory: '/project', language: 'en' }); const rendered = renderExecutionMetadata({ workingDirectory: '/project', language: 'en' });
expect(rendered).toContain('## Execution Context'); expect(rendered).toContain('## Execution Context');
expect(rendered).toContain('- Working Directory: /project'); expect(rendered).toContain('- Working Directory: /project');
expect(rendered).not.toContain('Project Root'); expect(rendered).toContain('## Execution Rules');
expect(rendered).not.toContain('Mode:'); expect(rendered).toContain('Do NOT run git commit');
}); });
it('should end with a trailing empty line', () => { it('should end with a trailing empty line', () => {
@ -212,8 +212,8 @@ describe('instruction-builder', () => {
expect(rendered).toContain('## 実行コンテキスト'); expect(rendered).toContain('## 実行コンテキスト');
expect(rendered).toContain('- 作業ディレクトリ: /project'); expect(rendered).toContain('- 作業ディレクトリ: /project');
expect(rendered).not.toContain('Execution Context'); expect(rendered).toContain('## 実行ルール');
expect(rendered).not.toContain('Working Directory'); expect(rendered).toContain('git commit を実行しないでください');
}); });
it('should include English note only for en, not for ja', () => { it('should include English note only for en, not for ja', () => {

View File

@ -60,11 +60,15 @@ const METADATA_STRINGS = {
en: { en: {
heading: '## Execution Context', heading: '## Execution Context',
workingDirectory: 'Working Directory', workingDirectory: 'Working Directory',
rulesHeading: '## Execution Rules',
noCommit: '**Do NOT run git commit.** Commits are handled automatically by the system after workflow completion.',
note: 'Note: This section is metadata. Follow the language used in the rest of the prompt.', note: 'Note: This section is metadata. Follow the language used in the rest of the prompt.',
}, },
ja: { ja: {
heading: '## 実行コンテキスト', heading: '## 実行コンテキスト',
workingDirectory: '作業ディレクトリ', workingDirectory: '作業ディレクトリ',
rulesHeading: '## 実行ルール',
noCommit: '**git commit を実行しないでください。** コミットはワークフロー完了後にシステムが自動で行います。',
note: '', note: '',
}, },
} as const; } as const;
@ -73,7 +77,7 @@ const METADATA_STRINGS = {
* Render execution metadata as a markdown string. * Render execution metadata as a markdown string.
* *
* Pure function: ExecutionMetadata string. * Pure function: ExecutionMetadata string.
* Always includes heading + Working Directory. * Always includes heading + Working Directory + Execution Rules.
* Language determines the output language; 'en' includes a note about language consistency. * Language determines the output language; 'en' includes a note about language consistency.
*/ */
export function renderExecutionMetadata(metadata: ExecutionMetadata): string { export function renderExecutionMetadata(metadata: ExecutionMetadata): string {
@ -81,6 +85,9 @@ export function renderExecutionMetadata(metadata: ExecutionMetadata): string {
const lines = [ const lines = [
strings.heading, strings.heading,
`- ${strings.workingDirectory}: ${metadata.workingDirectory}`, `- ${strings.workingDirectory}: ${metadata.workingDirectory}`,
'',
strings.rulesHeading,
`- ${strings.noCommit}`,
]; ];
if (strings.note) { if (strings.note) {
lines.push(''); lines.push('');