diff --git a/plugins/ultraplan-local/commands/ultraexecute-local.md b/plugins/ultraplan-local/commands/ultraexecute-local.md index c7bb0b7..ebfeff2 100644 --- a/plugins/ultraplan-local/commands/ultraexecute-local.md +++ b/plugins/ultraplan-local/commands/ultraexecute-local.md @@ -414,6 +414,11 @@ Verify with `node lib/validators/session-state-validator.mjs --json {project_dir}/.session-state.local.json`. On validator failure, emit a warning to stderr but do NOT block the stop; `progress.json` is still authoritative. +**Also write sibling `NEXT-SESSION-PROMPT.local.md`** with frontmatter +(`produced_by: ultraexecute-local`, `produced_at: `, +`status: stopped`) so the next-session producer-mismatch check has both +candidates available. Use the same combined ESM block pattern as Phase 8. + ### Check 2 — Plan file is tracked by git Run `git ls-files --error-unmatch {plan-path} 2>/dev/null`. If the plan file is @@ -898,6 +903,11 @@ the failed entry-condition session was supposed to consume. This lets write pattern + validator check as Phase 2.55. On validator failure, warn but do not block. +**Also write sibling `NEXT-SESSION-PROMPT.local.md`** with frontmatter +(`produced_by: ultraexecute-local`, `produced_at: `, +`status: stopped`) — same combined ESM pattern as Phase 8 — so Phase 1.5 +of `/ultracontinue` can compare project-dir and plugin-root candidates. + If the entry condition **passes**: ``` Entry condition: PASS @@ -1340,6 +1350,27 @@ Use `lib/util/atomic-write.mjs` (`atomicWriteJson`) — same crash-safety as --json {project_dir}/.session-state.local.json`. On validator failure, warn to stderr but do NOT block — Phase 8 must always reach the final report. +**Also write sibling `NEXT-SESSION-PROMPT.local.md`** (Bug 3 frontmatter +contract — see `docs/HANDOVER-CONTRACTS.md` § Handover 7 Lifecycle) in the +project directory. The frontmatter MUST contain `produced_by: ultraexecute-local` +and `produced_at: ` so `/ultracontinue` Phase 1.5 can detect +producer drift between project-dir and plugin-root candidates. Use a single +ESM inline block so state-file + prompt-file writes succeed or fail together: + +```bash +!`node --input-type=module -e " +import path from 'node:path'; +import { writeFileSync } from 'node:fs'; +import { atomicWriteJson } from './lib/util/atomic-write.mjs'; +const [, dir, briefPath, label, status] = process.argv; +const now = new Date().toISOString(); +const stateObj = { schema_version: 1, project: dir, next_session_brief_path: briefPath, next_session_label: label, status, updated_at: now }; +atomicWriteJson(path.join(dir, '.session-state.local.json'), stateObj); +const promptBody = '---\\nproduced_by: ultraexecute-local\\nproduced_at: ' + now + '\\nproject: ' + dir + '\\nstatus: ' + status + '\\n---\\n\\n# ' + label + '\\n\\nResume via /ultracontinue.\\n'; +writeFileSync(path.join(dir, 'NEXT-SESSION-PROMPT.local.md'), promptBody); +" '{project_dir}' '{next_session_brief_path}' '{next_session_label}' '{status}'` +``` + This single insertion covers every multi-session execution path that converges here (Path A: successful single session, Path B: `--session N` explicit, Path C: compaction-survival recovery, Path D: standard plan diff --git a/plugins/ultraplan-local/commands/ultraplan-end-session-local.md b/plugins/ultraplan-local/commands/ultraplan-end-session-local.md index 0e7c95e..c26406c 100644 --- a/plugins/ultraplan-local/commands/ultraplan-end-session-local.md +++ b/plugins/ultraplan-local/commands/ultraplan-end-session-local.md @@ -63,7 +63,7 @@ Resolve the nearest `.claude/projects/*/brief.md` from cwd (the current working directory). Use `node -e` enumeration (NOT shell glob — harness-mode safety): ```bash -!`node -e "const fs=require('fs'),path=require('path');const root='.claude/projects';if(!fs.existsSync(root)){process.exit(0)}const dirs=fs.readdirSync(root).filter(d=>fs.existsSync(path.join(root,d,'brief.md'))).map(d=>path.join(root,d));dirs.forEach(p=>process.stdout.write(p+'\\n'));"` +!`node --input-type=module -e "import {existsSync, readdirSync} from 'node:fs'; import {join} from 'node:path'; const root='.claude/projects'; if(!existsSync(root)) process.exit(0); readdirSync(root).filter(d=>existsSync(join(root,d,'brief.md'))).forEach(d=>process.stdout.write(join(root,d)+'\\n'));"` ``` Decision tree: @@ -89,7 +89,7 @@ Print to stderr and exit 1. **No interactive prompt** — this keeps the helper headless-safe (per brief NFR; addresses adversarial-review major #11). If you want an interactive flow, use `/ultracontinue --help` to see the full pipeline. -## Phase 3 — Atomically write `.session-state.local.json` +## Phase 3 — Atomically write `.session-state.local.json` + sibling NEXT-SESSION-PROMPT.local.md Write `/.session-state.local.json` with the schema-v1 object: @@ -105,21 +105,37 @@ Write `/.session-state.local.json` with the schema-v1 object: ``` Use the atomic-write util — write to `.tmp`, then `rename` into place — -to avoid partial-state on crash. Inline-call pattern: +to avoid partial-state on crash. The util is ESM, so invoke via +`node --input-type=module -e` with an `import` statement (a CommonJS shim +would throw `ERR_REQUIRE_ESM` on Node 18+ since `atomic-write.mjs` is ESM). + +Under `node --input-type=module -e "