Files
pi-goals/src/plan-view.ts
T
wassnameandPi/OpenAI c175096ddb Restore automatic plan proposals and make goal commands explicit
Reduce unchanged upkeep and identity-only review noise; retain user README structure and screenshot with abridged terminal example. 174 tests pass; actual Herdr automatic proposal captured.

Co-Authored-By: Pi/OpenAI <288921227+claudypoo@users.noreply.github.com>
2026-09-10 18:12:38 +08:00

29 lines
1.3 KiB
TypeScript

// Pi/OpenAI: Preserve plan wording; omit history and, in the short view, task/evidence details.
export function planViews(plan: string): { short: string; long: string } {
const long = plan.split(/^#{1,6}\s+(?:Log|Appendix|Appendices|Appendixes|Interview|Learnings|Papercuts)\b.*$/mi)[0].trim();
const kept: string[] = [];
let omittedIndent: number | null = null;
let omittedHeading: number | null = null;
for (const line of long.split("\n")) {
// Pi/OpenAI: Worker identity bookkeeping is not a change to agreed requirements.
if (/^-\s*(?:active worker|worker session|worker intercom session):/i.test(line)) continue;
const heading = /^(#{1,6})\s+(.+)$/.exec(line);
if (heading) {
if (omittedHeading !== null && heading[1].length <= omittedHeading) omittedHeading = null;
if (/^(?:Tasks?|Task list|Subtasks?|Evidence)\b/i.test(heading[2])) omittedHeading = heading[1].length;
}
if (omittedHeading !== null) continue;
const indent = line.match(/^\s*/)?.[0].length ?? 0;
if (omittedIndent !== null) {
if (!line.trim() || indent > omittedIndent) continue;
omittedIndent = null;
}
if (/^\s*[-*]\s+(?:tasks?|subtasks?|evidence):/i.test(line) || /^\s*(?:\d+[.)]|[-*])\s+\[[ x/~-]\]\s+(?!goal:)/i.test(line)) {
omittedIndent = indent;
continue;
}
kept.push(line);
}
return { short: kept.join("\n").trim(), long };
}