phase-merge-fallback.ts 979 B

123456789101112131415161718192021222324
  1. // Two things at once: the same name at two call sites is ONE phase — the name is the key,
  2. // unlike an actor's name, which is only a display label — and the steps issued before the
  3. // script's first marker fall into the synthetic `unphased` phase, which sorts first.
  4. const reviewer = agent("reviewer");
  5. // No marker is current yet, so this read is `unphased` — the fallback exists for exactly
  6. // this shape (a script whose author marked the interesting middle and not the setup).
  7. const paths = await files.glob("src/**/*.ts");
  8. if (paths.length > 1) {
  9. phase("gate");
  10. const body = await files.read(paths[0] ?? "src/index.ts");
  11. const verdict = await reviewer.ask<string>(`Review:\n${body}`);
  12. report({ verdict });
  13. } else {
  14. // Second call site, same word: one phase#1, not a phase#2.
  15. phase("gate");
  16. const readme = await files.read("README.md");
  17. const verdict = await reviewer.ask<string>(`Review:\n${readme}`);
  18. report({ verdict });
  19. }
  20. return paths.length;