hole-nested-filled.ts 1.2 KB

1234567891011121314151617181920212223242526
  1. // Both holes filled: the outer fill wrote `<outer>/…`, the inner fill wrote `<inner>/…` (one
  2. // prefix level each: hole ids are name keys). The outer hole's phase claims the outer body's
  3. // first ask; the inner hole's phase claims nothing (its body opens with a marker) but keeps its
  4. // place and carries `fill=<outer>`, and the marker phase inside it carries `fill=<inner>`.
  5. // Neither hole is a step any more, and `holes` is absent from the display.
  6. interface Survey {
  7. slowest: string;
  8. }
  9. interface Plan {
  10. groups: string[][];
  11. }
  12. interface Order {
  13. first: string;
  14. }
  15. phase("摸底");
  16. const survey = await agent("勘察员").ask<Survey>("列出最慢的测试文件");
  17. const plan = await hole<Plan>("决定分组", `最慢的是 ${survey.slowest}`, async () => {
  18. const draft = await agent("分组员").ask<Plan>(`先按模块分组 ${survey.slowest}`);
  19. const order = await hole<Order>("决定顺序", `${draft.groups.length} 组,哪组先跑`, async () => {
  20. phase("排序");
  21. return await agent("排序员").ask<Order>(`给 ${draft.groups.length} 组排序`);
  22. });
  23. return { groups: [[order.first], ...draft.groups] };
  24. });
  25. phase("执行");
  26. return agent("执行者").ask<string>(`按 ${plan.groups.length} 组执行`);