Merge pull request #17 from jparkerweb/fix/loop-tests-and-sync-direction

Fix/loop tests and sync direction
This commit is contained in:
jparkerweb authored and GitHub committed 2026-11-08 20:01:37 -08:00
commit 4f172c63d3
6 files changed
+102 -83

No files matched your search

+6 -2
View File
@@ -1,6 +1,6 @@
---
name: sync-repo
description: "Run the encrypted, password-protected repository sync workflow for this project. The real instructions are stored encrypted at rest and are only revealed in-session after you supply the correct password. Invoke explicitly with /sync-repo."
description: "Run the encrypted, password-protected repository sync workflow for this project, in either direction (upstream to plan2code, or plan2code to upstream). The real instructions are stored encrypted at rest and are only revealed in-session after you supply the correct password. Invoke explicitly with /sync-repo."
disable-model-invocation: true
---
@@ -34,7 +34,11 @@ the workflow. Follow this launcher exactly.
3. **Handle the result.**
- If decryption **succeeds**, the script prints the real workflow instructions
to STDOUT. Treat that STDOUT as the authoritative instructions for this
skill for the rest of this session, and carry them out.
skill for the rest of this session, and carry them out. Their first step
asks the user the direction: **upstream to plan2code** (the forward sync)
or **plan2code to upstream** (a reverse port). Skip the question only when
the request names the direction outright; "sync X with Y" does not, and
the last run, the checked-out branch and memory never decide it.
- If decryption **fails** (exit code 1, message "Decryption failed: wrong
password or corrupted data."), the password was wrong or the file is
corrupt. Tell the user, ask them to re-enter the password, and retry. Do
+12 -7
View File
@@ -3,8 +3,9 @@
// Decrypts, replaces exactly one anchored line, re-encrypts, then decrypts again to verify.
// Plaintext never touches disk and never passes through a shell pipe (PowerShell pipes
// re-encode UTF-8 through the console code page, which is how the body got mojibake).
// Usage: SKILL_PASSWORD=... node set-synced.mjs <file.enc> "<new value>"
// Usage: SKILL_PASSWORD=... node set-synced.mjs [--reverse] <file.enc> "<new value>"
// e.g. node set-synced.mjs sync-repo.enc "v2.4.0 (main @ 1a2b3c4)"
// --reverse rewrites the "Last reverse-ported plan2code" line instead (a port from plan2code to upstream).
import { readFileSync, writeFileSync } from 'node:fs';
import { scryptSync, randomBytes, createCipheriv, createDecipheriv } from 'node:crypto';
@@ -14,12 +15,16 @@ const SCRYPT = { N: 1 << 17, r: 8, p: 1, maxmem: 256 * 1024 * 1024 };
const KEYLEN = 32, SALTLEN = 16, IVLEN = 12, TAGLEN = 16;
// Anchored to a whole line that starts with "**Last synced upstream:". Command text elsewhere in
// the body can mention the phrase without ever matching, because it never starts a line this way.
const LINE = /^\*\*Last synced upstream: .*\*\*$/gm;
const args = process.argv.slice(2);
const reverse = args[0] === '--reverse';
if (reverse) args.shift();
const LABEL = reverse ? 'Last reverse-ported plan2code' : 'Last synced upstream';
const LINE = new RegExp(`^\\*\\*${LABEL}: .*\\*\\*$`, 'gm');
const password = process.env.SKILL_PASSWORD;
const [encPath, value] = process.argv.slice(2);
const [encPath, value] = args;
if (!password) { console.error('ERROR: set SKILL_PASSWORD env var.'); process.exit(2); }
if (!encPath || !value) { console.error('Usage: node set-synced.mjs <file.enc> "<new value>"'); process.exit(2); }
if (!encPath || !value) { console.error('Usage: node set-synced.mjs [--reverse] <file.enc> "<new value>"'); process.exit(2); }
if (value.includes('*') || value.includes('\n')) { console.error('ERROR: value may not contain * or a newline.'); process.exit(2); }
function decrypt(b64) {
@@ -46,11 +51,11 @@ try { body = decrypt(readFileSync(encPath, 'utf8')); }
catch { console.error('Decryption failed: wrong password or corrupted data.'); process.exit(1); }
const hits = body.match(LINE) || [];
if (hits.length !== 1) { console.error(`ERROR: expected exactly one "Last synced" line, found ${hits.length}. Nothing written.`); process.exit(1); }
if (hits.length !== 1) { console.error(`ERROR: expected exactly one "${LABEL}" line, found ${hits.length}. Nothing written.`); process.exit(1); }
if (body.includes('�')) { console.error('ERROR: body contains U+FFFD (encoding damage). Nothing written.'); process.exit(1); }
const next = body.replace(LINE, `**Last synced upstream: ${value}**`);
const next = body.replace(LINE, `**${LABEL}: ${value}**`);
const out = encrypt(next);
if (decrypt(out) !== next) { console.error('ERROR: round-trip verification failed. Nothing written.'); process.exit(1); }
writeFileSync(encPath, out);
console.error(`Updated: ${hits[0]} -> **Last synced upstream: ${value}**`);
console.error(`Updated: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9S/k2DLw7ijuzd3y1yQ2vE+jcCde+AmAs0atvYQ9hH5xatN23OVCxYzZZ9YtBxyHrAos71Gdik52aZ+vi4LuYV2L0VL75anAMTxQF2T+Q1ZPNbY7aTZpl2HGHLOUFei+5ZNDThzofgwcqCzydK9KyvB47bRPYAq+dti/JRER3Eh2LLUxsBSR8/RI5yMioTPt/agJQoaPTt0Hznq+P1KcjKP53yVW5FquXn3RYHJOXOxNZlTYGYWUcL0ZVvpVa1lJ4nNWbvghX8dSfYoeuR7+s0UqSmzgjaPdHT+T2yBy5DAysZliefE+O6CGhNd/YK3JAVvLine truncated
+55 -49
View File
@@ -1678,24 +1678,40 @@ mod tests {
assert!(error.contains("project"), "{error}");
}
#[test]
fn the_setup_console_starts_on_the_setup_workflow() {
// Same setup as `real_console` below: the repo's own console source,
// a throwaway session home, no browser, no in-app variables.
/// Held by every test that starts a real console. The console's variables
/// are process-wide and tests run on parallel threads: when two tests set
/// `PLAN2CODE_CONSOLE_HOME` to different folders, one test's session was
/// looked for in the other's home, found gone, and replaced with a fresh
/// one (a Linux CI failure Windows timing hid).
static CONSOLE_ENV: std::sync::Mutex<()> = std::sync::Mutex::new(());
/// Take the lock, then point the console at the repo's own source and one
/// throwaway session home shared by these tests (sids keep them apart),
/// with no browser and no in-app variables. `None` (lock released) when
/// node or the console source is not here.
fn console_test_env() -> Option<std::sync::MutexGuard<'static, ()>> {
let guard = CONSOLE_ENV.lock().unwrap_or_else(|e| e.into_inner());
if !have_node() {
eprintln!("skipping: node is not on PATH");
return None;
}
let console_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../src/web-console");
if !have_node() || !console_dir.join("console.mjs").is_file() {
eprintln!("skipping: node or the console source is not here");
return;
if !console_dir.join("console.mjs").is_file() {
eprintln!(
"skipping: console source missing at {}",
console_dir.display()
);
return None;
}
let pid = std::process::id();
let project = std::env::temp_dir().join(format!("p2c-setup-test-project-{pid}"));
std::fs::create_dir_all(&project).unwrap();
std::env::set_var("PLAN2CODE_CONSOLE_DIR", &console_dir);
std::env::set_var(
"PLAN2CODE_CONSOLE_HOME",
std::env::temp_dir().join(format!("p2c-setup-test-home-{pid}")),
std::env::temp_dir().join(format!("p2c-main-test-home-{pid}")),
);
std::env::set_var("PLAN2CODE_NO_BROWSER", "1");
// Run inside the desktop app, the agent's in-app variables would have this
// console announce itself to the live window and take it over.
for name in [
"PLAN2CODE_IN_APP",
"PLAN2CODE_APP_ANNOUNCE",
@@ -1704,6 +1720,17 @@ mod tests {
] {
std::env::remove_var(name);
}
Some(guard)
}
#[test]
fn the_setup_console_starts_on_the_setup_workflow() {
let Some(_env) = console_test_env() else {
return;
};
let pid = std::process::id();
let project = std::env::temp_dir().join(format!("p2c-setup-test-project-{pid}"));
std::fs::create_dir_all(&project).unwrap();
let state = state_for("project-a");
state.project.lock().unwrap().as_mut().unwrap().dir = project.clone();
@@ -1753,47 +1780,22 @@ mod tests {
}
/// A real console, the same way `tests/console_supervisor.rs` sets one
/// up: `PLAN2CODE_CONSOLE_DIR` points at the repo's own console source,
/// `PLAN2CODE_CONSOLE_HOME` keeps its session files out of the real one.
fn real_console() -> Option<plan2code_app_lib::console_supervisor::ConsoleSupervisor> {
if !have_node() {
eprintln!("skipping: node is not on PATH");
return None;
}
let console_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../src/web-console");
if !console_dir.join("console.mjs").is_file() {
eprintln!(
"skipping: console source missing at {}",
console_dir.display()
);
return None;
}
/// up (see `console_test_env`). Keep the guard until the test ends: the
/// console's variables must not change while its session is in use.
fn real_console() -> Option<(
std::sync::MutexGuard<'static, ()>,
plan2code_app_lib::console_supervisor::ConsoleSupervisor,
)> {
let guard = console_test_env()?;
let pid = std::process::id();
let project = std::env::temp_dir().join(format!("p2c-main-test-project-{pid}"));
std::fs::create_dir_all(&project).unwrap();
std::env::set_var("PLAN2CODE_CONSOLE_DIR", &console_dir);
std::env::set_var(
"PLAN2CODE_CONSOLE_HOME",
std::env::temp_dir().join(format!("p2c-main-test-home-{pid}")),
);
std::env::set_var("PLAN2CODE_NO_BROWSER", "1");
// Run inside the desktop app, the agent's in-app variables would have this
// console announce itself to the live window and take it over.
for name in [
"PLAN2CODE_IN_APP",
"PLAN2CODE_APP_ANNOUNCE",
"PLAN2CODE_APP_TOKEN",
"PLAN2CODE_CONSOLE_SID",
] {
std::env::remove_var(name);
}
Some(
plan2code_app_lib::console_supervisor::ConsoleSupervisor::start(
project,
plan2code_app_lib::console_supervisor::app_origin().to_string(),
)
.expect("start a real console for the test"),
let sup = plan2code_app_lib::console_supervisor::ConsoleSupervisor::start(
project,
plan2code_app_lib::console_supervisor::app_origin().to_string(),
)
.expect("start a real console for the test");
Some((guard, sup))
}
fn state_with_loop(running: bool) -> AppState {
@@ -1838,7 +1840,9 @@ mod tests {
#[test]
fn a_start_after_a_stop_opens_the_same_session_again() {
let Some(sup) = real_console() else { return };
let Some((_env, sup)) = real_console() else {
return;
};
let state = state_for("project-a");
let sid = sup.session().sid.clone();
*state.console.lock().unwrap() = Some(sup);
@@ -1901,7 +1905,9 @@ mod tests {
#[test]
fn teardown_clears_the_console_so_console_start_refuses_not_reconnects() {
let Some(sup) = real_console() else { return };
let Some((_env, sup)) = real_console() else {
return;
};
let state = state_for("project-a");
*state.console.lock().unwrap() = Some(sup);
assert!(
+19 -11
View File
@@ -447,9 +447,17 @@ async function openStrengthSetup(t, launch = LAUNCH) {
const strengthRows = (s) =>
s.page.locator(".loop-strength-row").evaluateAll((rows) =>
rows.map((r) => ({ phase: r.querySelector(".loop-strength-phase").textContent, pick: r.querySelector("select").value, model: r.querySelector(".loop-strength-model").textContent }))
rows.map((r) => ({ phase: r.querySelector(".loop-strength-phase").textContent, pick: r.querySelector("input:checked")?.value ?? null, model: r.querySelector(".loop-strength-model").textContent }))
);
// Each row is a radio group, one radio per column: #loop-strength-<n>-<word>, "match" for Match my session.
// The cell is clicked, as a person does: its dot sits over the hidden radio.
const pickStrength = async (s, n, word) => {
const radio = s.page.locator(`#loop-strength-${n}-${word || "match"}`);
await radio.locator("..").click();
await s.page.locator(`#loop-strength-${n}-${word || "match"}:checked`).waitFor({ state: "attached" });
};
test("the strength section is first in the form and off by default", async (t) => {
const s = await openStrengthSetup(t);
const toggle = s.page.locator("#loop-phase-strength");
@@ -469,7 +477,7 @@ test("turning it on shows one row per phase left with the model each pick become
{ phase: "Phase 2: Two", pick: "", model: "opus, medium" },
], "untouched rows match the session and show the launch choice");
await s.page.locator("#loop-strength-1").selectOption("thrifty");
await pickStrength(s, 1, "thrifty");
assert.equal(await textOf(s.page.locator('[data-phase="1"] .loop-strength-model')), "sonnet, low");
assert.equal(await s.page.locator("#loop-strength-all").inputValue(), "-", "Set all to starts blank");
@@ -477,7 +485,7 @@ test("turning it on shows one row per phase left with the model each pick become
assert.deepEqual((await strengthRows(s)).map((r) => [r.pick, r.model]), [["best", "opus, medium"], ["best", "opus, medium"]]);
assert.equal(await s.page.locator("#loop-strength-all").inputValue(), "-", "and goes blank again: it is not a saved value");
await s.page.locator("#loop-strength-2").selectOption("balanced");
await pickStrength(s, 2, "balanced");
assert.deepEqual((await strengthRows(s)).map((r) => [r.pick, r.model]), [["best", "opus, medium"], ["balanced", "sonnet, medium"]], "a row can change after Set all");
await s.page.locator("#loop-strength-all").selectOption("match");
@@ -509,12 +517,12 @@ test("a saved pick that is not mapped holds Start with a line naming the row, an
const why = s.page.locator(".loop-why");
assert.equal(await textOf(why), "Pick a new strength for Phase 2: not mapped for this agent.");
assert.equal(await s.page.locator("#loop-start").isDisabled(), true);
const pick = s.page.locator("#loop-strength-2");
assert.equal(await pick.inputValue(), "thrifty", "the saved word stays in the row");
assert.equal(await pick.locator("option:checked").innerText(), "Thrifty (not mapped)");
assert.equal(await pick.locator("option:checked").evaluate((o) => o.disabled), true);
const held = s.page.locator("#loop-strength-2-thrifty");
assert.equal(await held.isChecked(), true, "the saved word stays in the row");
assert.equal(await held.isDisabled(), true);
assert.deepEqual(await s.page.locator(".loop-strength-head .loop-strength-chip.is-unmapped").allInnerTexts(), ["Thrifty (not mapped)", "Balanced (not mapped)"]);
await pick.selectOption("best");
await pickStrength(s, 2, "best");
assert.equal(await s.page.locator(".loop-why").count(), 0, "the hold is gone");
assert.equal(await s.page.locator("#loop-start").isDisabled(), false);
});
@@ -548,8 +556,8 @@ test("startBlock names every unmapped row, ignores the picks while the toggle is
test("the toggle and the picks survive reopening the screen, and the toggle off sends nothing for the loop", async (t) => {
const s = await openStrengthSetup(t);
await s.page.locator("#loop-phase-strength").check();
await s.page.locator("#loop-strength-1").selectOption("thrifty");
await s.page.locator("#loop-strength-2").selectOption("best");
await pickStrength(s, 1, "thrifty");
await pickStrength(s, 2, "best");
const save = () =>
s.page.evaluate(async () => {
@@ -573,7 +581,7 @@ test("the toggle and the picks survive reopening the screen, and the toggle off
await s.page.locator("#loop-start").waitFor();
};
await reopen();
await s.page.locator("#loop-strength-1").waitFor();
await s.page.locator(".loop-strength-row").first().waitFor();
assert.equal(await s.page.locator("#loop-phase-strength").isChecked(), true);
assert.deepEqual((await strengthRows(s)).map((r) => [r.pick, r.model]), [["thrifty", "sonnet, low"], ["best", "opus, medium"]]);
+9 -13
View File
@@ -1,8 +1,7 @@
# Loop Mode on the Web Console
Workflow notes for Implement and Implement + Review started by the desktop app's
Implementation Loop with `--loop`, part of the web console contract
(`console.md`). Read `building.md` and `notes/implement.md` first: this note says
Notes for Implement and Implement + Review run by the desktop app's
Implementation Loop (`--loop`), part of the `console.md` contract. Read `building.md` and `notes/implement.md` first: this note says
only where loop mode differs. The app judges the result, so you report and never
approve.
@@ -57,16 +56,14 @@ approve.
`passed`. Never list a failure the Notes do not name.
- A waiting `**Plan change:**` line in the phase's Notes: do not ask Revise
first or Resume; report `failed`, reason `other`, and say so in `summary`.
- Run only the tests the phase file names, as the Implement prompt's tests rule
says: a phase task or a task's `Test:` line (a `## Phase Testing` block counts
when it lists them as tasks). Never the full suite unless the phase file names it.
- Run only the tests the phase file names (a phase task, a task's `Test:` line,
or tasks under `## Phase Testing`), never the full suite unless it names it.
## Headline stages
Post `headline.stage` as each begins, using only these words: `Build`, `Review`,
`Fixes`, `Re-check`, `Reporting`. The app's strip reads them, and any other word
shows as Build, so do not invent new ones in loop mode. Keep `cleared` and
`total` as in any build.
`Fixes`, `Re-check`, `Reporting` (the app's strip shows any other word as
Build). Keep `cleared` and `total` as in any build.
## Choosing the phase
@@ -99,8 +96,8 @@ or `checkoff` post `result: "failed"`, `reason: "other"` and
`"handledBy": "loop"` and the answer filled in, so the page shows "The loop
handles this", for example
`{ "id": "fixes", "kind": "multi", "title": "Which to fix", "options": [ ... ], "status": "answered", "answer": { "ks": ["1", "2"] }, "handledBy": "loop" }`.
- Ask (chat) questions do not arrive while the loop drives. If one does, answer
it briefly as usual.
- Ask (chat) questions do not arrive while the loop drives; if one does, answer
it briefly.
## Review, one fix round and the re-check
@@ -130,8 +127,7 @@ say why. Post the triage's answers for the record as the settled `fixes` item (i
Then run the one fix round on the findings marked `fix`, and the fresh re-check
of only those fixes, as above. `left` counts the picked findings still open after
the re-check. Smart pick always reports `triage.ran: true` and `review.recheck: true`, even when no finding was raised or none was picked (an empty re-check). The triage runs under the `Review` stage; the stage words do not
change.
the re-check. Smart pick always reports `triage.ran: true` and `review.recheck: true`, even when no finding was raised or none was picked (an empty re-check). The triage runs under the `Review` stage.
## Reporting the outcome