คู่มือปฏิบัติ
ให้ agent เขียนการทดสอบ
ใช้ขอบเขตที่อนุญาตให้เพิ่มเฉพาะไฟล์ทดสอบ การตรวจทีละจุด และการตรวจแบบ mutation เพื่อให้ agent เพิ่มชุดทดสอบที่เชื่อถือได้
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Create a project in the Antigravity app and review artifacts IDE extensions: Review agent changes in your editor
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
อธิบายอย่างง่าย: A test-writing agent can also change the code under test
หัวข้อที่มีชื่อว่า “อธิบายอย่างง่าย: A test-writing agent can also change the code under test”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Add tests for an existing function
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ตัวอย่างขั้นต่ำ
หัวข้อที่มีชื่อว่า “ตัวอย่างขั้นต่ำ”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
Write a complete test suite for lateFeeCents. If the implementation is wrong, fix it too, and finish with passing tests.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
First, analyze the current behavior of lateFeeCents without writing anything. Produce a test table and wait for my approval.
Persistent change scope: you may only add test/late-fee.test.js.Do not change src/, package.json, lockfiles, existing tests, configuration, or dependencies.Do not delete, skip, or weaken assertions. If current behavior looks defective, record it as an open question; do not fix it.
Run the existing tests first and preserve the baseline. After adding the test file, run the same command and report the command,exit status, and output. Then stop. I will perform a one-line mutation manually; you may only analyze whether the failurematches the target behavior. Finally, report git status --short, git diff for tracked files, andgit diff --no-index -- /dev/null test/late-fee.test.js for the new file. The last command exits with 1 when it finds the expected difference.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ตัวอย่างฉบับเต็ม: Add tests for a late-fee function
หัวข้อที่มีชื่อว่า “ตัวอย่างฉบับเต็ม: Add tests for a late-fee function”วัสดุตั้งต้น
หัวข้อที่มีชื่อว่า “วัสดุตั้งต้น”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
demo-fees/|-- package.json|-- src/| `-- late-fee.js`-- test/ `-- smoke.test.js{ "type": "module", "scripts": { "test": "node --test" }}export function lateFeeCents(daysLate) { if (!Number.isInteger(daysLate) || daysLate <= 0) return 0; return Math.min(daysLate * 25, 500);}ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Add tests for an existing function
หัวข้อ: Set the scope and permissions first
หัวข้อที่มีชื่อว่า “หัวข้อ: Set the scope and permissions first”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Permissions and sandbox: what presets, rules, and the sandbox each control
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
{ "permissions": { "allow": [ "command(node --test)", "command(git status --short)", "command(git diff)", "command(git diff --no-index -- /dev/null test/late-fee.test.js)" ], "deny": [ "write_file(src/)", "write_file(test/smoke.test.js)", "write_file(package.json)", "write_file(package-lock.json)", "command(git commit)", "command(git push)" ] }}ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Before enabling auto or Turbo: risks, acceptable cases, and reversal
หัวข้อ: Mode, inspection, and output at each step
หัวข้อที่มีชื่อว่า “หัวข้อ: Mode, inspection, and output at each step”| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
|---|---|---|---|
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Your first agent task: Use execution modes and permissions as guardrails
หัวข้อ: Step one: Read-only plan and baseline
หัวข้อที่มีชื่อว่า “หัวข้อ: Step one: Read-only plan and baseline”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
Goal: add current-behavior tests for lateFeeCents in src/late-fee.js.
This turn is read-only. Do not modify files or run commands. Please:1. List the files you actually read.2. Derive inputs, outputs, and boundaries from the source.3. Propose the smallest test set and explain which incorrect implementation each case would distinguish.4. Name test/late-fee.test.js as the only path that may be added.5. State that you will not change src/, existing tests, dependencies, configuration, or lockfiles.6. List the existing test command to run later, but do not claim that it ran.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
git status --shortnode --testข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
command: node --testresult: tests 1, pass 1, fail 0exit status: 0ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Step two: Add only the test file
หัวข้อที่มีชื่อว่า “หัวข้อ: Step two: Add only the test file”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
I ran the baseline: git status --short produced no output; node --test reported tests 1, pass 1, fail 0; exit status 0.
Now add only test/late-fee.test.js. Do not modify any other file, especiallysrc/late-fee.js, test/smoke.test.js, package.json, lockfiles, or configuration.
Requirements:- Use node:test and node:assert/strict.- Cover non-positive or non-integer input, below the cap, exactly at the cap, and above the cap.- Name tests after observable current behavior.- Add no dependency, skip no test, and do not change test discovery.- Show the diff before saving; after saving, request permission to run node --test.- If any test fails, stop and report the actual value. Do not change implementation to satisfy the assertion.- Finally report git status --short, git diff for tracked files, and git diff --no-index -- /dev/null test/late-fee.test.js for the new file. The last command exits with 1 when it finds a difference. Do not commit or push.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
import test from 'node:test';import assert from 'node:assert/strict';import { lateFeeCents } from '../src/late-fee.js';
test('returns zero for non-positive or non-integer days', () => { assert.equal(lateFeeCents(0), 0); assert.equal(lateFeeCents(-2), 0); assert.equal(lateFeeCents(1.5), 0);});
test('charges 25 cents per late day below the cap', () => { assert.equal(lateFeeCents(1), 25); assert.equal(lateFeeCents(19), 475);});
test('reaches the 500-cent cap on day 20', () => { assert.equal(lateFeeCents(20), 500);});
test('does not exceed the cap after day 20', () => { assert.equal(lateFeeCents(21), 500); assert.equal(lateFeeCents(100), 500);});ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Step three: Run and review independently
หัวข้อที่มีชื่อว่า “หัวข้อ: Step three: Run and review independently”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
command: node --testresult: tests 5, pass 5, fail 0exit status: 0ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Review agent changes before you accept them
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
git status --shortgit diffgit diff --no-index -- /dev/null test/late-fee.test.jsnode --testข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Step four: Perform one temporary mutation by hand
หัวข้อที่มีชื่อว่า “หัวข้อ: Step four: Perform one temporary mutation by hand”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
return Math.min(daysLate * 25, 500);return daysLate * 25;ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
command: node --testresult: tests 5, pass 4, fail 1failing test: does not exceed the cap after day 20first mismatch: actual 525, expected 500exit status: 1ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Add tests for an existing function
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ตัวอย่างที่ไม่ควรทำและการเขียนใหม่
หัวข้อที่มีชื่อว่า “ตัวอย่างที่ไม่ควรทำและการเขียนใหม่”หัวข้อ: Counterexample one: Use auto and finish in one pass
หัวข้อที่มีชื่อว่า “หัวข้อ: Counterexample one: Use auto and finish in one pass”Use auto. Analyze the function, add tests, and fix everything until the suite is green without interrupting me.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Before enabling auto or Turbo: risks, acceptable cases, and reversal
หัวข้อ: Counterexample two: Delegate the meaning of a failure
หัวข้อที่มีชื่อว่า “หัวข้อ: Counterexample two: Delegate the meaning of a failure”If a new test fails, decide whether the test or the implementation is wrong and handle it directly.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Counterexample three: Read only the completion summary
หัวข้อที่มีชื่อว่า “หัวข้อ: Counterexample three: Read only the completion summary”The agent says it added four tests and all of them pass, so the change is ready to commit.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Review agent changes before you accept them
รายการตรวจสอบการยืนยันผล
หัวข้อที่มีชื่อว่า “รายการตรวจสอบการยืนยันผล”- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
การกู้คืนและขอบเขตความปลอดภัย
หัวข้อที่มีชื่อว่า “การกู้คืนและขอบเขตความปลอดภัย”- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Your first agent task: Use execution modes and permissions as guardrails
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Add tests for an existing function Locate and fix a bug Review agent changes before you accept them