Files
pi-goals/src/plan-view.ts
T
wassnameandPi/OpenAI c834237970 Notify on goal, task and evidence plan edits; stay silent on identity bookkeeping
Field calibration from three supervisor reports: the useful plan-change catch was a worker-ticked task the short-view hash no longer surfaced, while identity-line edits caused duplicate empty reviews. The notify digest keeps goals, tasks and evidence above the Log and drops worker identity lines. Reopening a signed goal still clears its sign-off.

Co-Authored-By: Pi/OpenAI <288921227+claudypoo@users.noreply.github.com>
2026-09-11 06:33:59 +08:00

34 lines
1.8 KiB
TypeScript

// Pi/OpenAI: Preserve plan wording; omit history and, in the short view, task/evidence details.
// The notify view governs plan-change events: goals, tasks, evidence and inferences are
// content worth a supervisor review; worker identity bookkeeping is not (field report,
// LUCID3 supervisor 2026-09-10: two identical review events for a session-path edit).
export function planViews(plan: string): { short: string; notify: string; long: string } {
const long = plan.split(/^#{1,6}\s+(?:Log|Appendix|Appendices|Appendixes|Interview|Learnings|Papercuts)\b.*$/mi)[0].trim();
const identity = /^-\s*(?:active worker|worker session|worker intercom session):/i;
const notify = long.split("\n").filter((line) => !identity.test(line)).join("\n").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(), notify, long };
}