mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-30 23:59:20 -08:00
Remember the terminal or web console choice, refresh the launcher model menus (v3.2.2)
AI Assisted
This commit is contained in:
1 parent
f1d087ba47
commit
ccf82c4eb7
60 files changed
+477
-317
No files matched your search
@@ -351,7 +351,7 @@ test("the session sweep removes only month-old session dirs, never the one being
|
||||
}
|
||||
});
|
||||
|
||||
test("the scratch sweep removes old patches and helpers, never looks, the pointer, the update cache or a directory", async () => {
|
||||
test("the scratch sweep removes old patches and helpers, never looks, the interface, the pointer, the update cache or a directory", async () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-scratch-"));
|
||||
try {
|
||||
const file = (name, stale = true) => {
|
||||
@@ -363,6 +363,7 @@ test("the scratch sweep removes old patches and helpers, never looks, the pointe
|
||||
const removable = [file("p2.json"), file("helper.mjs")];
|
||||
const kept = [
|
||||
file("looks.json"),
|
||||
file("interface.json"),
|
||||
file("workspaces.json"),
|
||||
file("loop-setup.json"),
|
||||
file("review-loop-setup.json"),
|
||||
@@ -383,13 +384,14 @@ test("the scratch sweep removes old patches and helpers, never looks, the pointe
|
||||
const stale = staleScratch(dir, Date.now(), SESSION_MAX_AGE_MS).sort();
|
||||
assert.deepEqual(stale, ["helper.mjs", "p2.json"]);
|
||||
assert.deepEqual(
|
||||
(await removeScratch(dir, [...stale, "looks.json", "workspaces.json", "loop-setup.json", "review-loop-setup.json", "loop-reports.json", "subagents.json", "spec-carry.json", "pr-hosts.json", "../p.json", "console-dir", "update-check.json"])).sort(),
|
||||
(await removeScratch(dir, [...stale, "looks.json", "interface.json", "workspaces.json", "loop-setup.json", "review-loop-setup.json", "loop-reports.json", "subagents.json", "spec-carry.json", "pr-hosts.json", "../p.json", "console-dir", "update-check.json"])).sort(),
|
||||
["helper.mjs", "p2.json"]
|
||||
);
|
||||
for (const p of removable) assert.equal(fs.existsSync(p), false, p);
|
||||
for (const p of kept) assert.ok(fs.existsSync(p), p);
|
||||
assert.deepEqual([...PROTECTED_CONSOLE_FILES].sort(), [
|
||||
"console-dir",
|
||||
"interface.json",
|
||||
"looks.json",
|
||||
"loop-reports.json",
|
||||
"loop-setup.json",
|
||||
@@ -435,7 +437,7 @@ test("cleanup finds old sessions and strays in both folders, and keeps every pro
|
||||
const drafted = session("20250801-101010-dddddd", true);
|
||||
put(path.join(drafted, "draft.json"));
|
||||
const kept = [
|
||||
...["looks.json", "workspaces.json", "subagents.json", "console-dir", "update-check.json"].map((n) =>
|
||||
...["looks.json", "interface.json", "workspaces.json", "subagents.json", "console-dir", "update-check.json"].map((n) =>
|
||||
put(path.join(consoleDir, n))
|
||||
),
|
||||
put(path.join(plan2code, "launcher.json")),
|
||||
@@ -1666,3 +1668,76 @@ test("a setup console without the app signal never calls a leftover announce URL
|
||||
stub.close();
|
||||
}
|
||||
});
|
||||
|
||||
/* ------------------------------------------------- terminal or web console */
|
||||
|
||||
// Its own console home, so a default saved here never reaches another test.
|
||||
function interfaceCli(home, args) {
|
||||
return cli(["interface", ...args], { expectFail: true, env: { PLAN2CODE_CONSOLE_HOME: home } });
|
||||
}
|
||||
|
||||
test("interface reports no default on a fresh home, and its rule says to ask and save nothing", () => {
|
||||
const home = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-interface-"));
|
||||
try {
|
||||
const res = interfaceCli(home, []);
|
||||
assert.equal(res.status, 0);
|
||||
assert.equal(res.json.interface, null);
|
||||
assert.match(res.json.rule, /Save nothing from the answer/);
|
||||
assert.match(res.json.rule, /make the terminal \(or web console\) my default/);
|
||||
assert.equal(fs.existsSync(path.join(home, "interface.json")), false);
|
||||
assert.match(res.json.rule, /interface --set web\|terminal/);
|
||||
assert.match(res.json.rule, /--web/);
|
||||
assert.match(res.json.rule, /--terminal/);
|
||||
} finally {
|
||||
fs.rmSync(home, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("interface --set saves one default that every later call reads back, and ask clears it", () => {
|
||||
const home = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-interface-"));
|
||||
try {
|
||||
for (const choice of ["terminal", "web"]) {
|
||||
assert.deepEqual(interfaceCli(home, ["--set", choice]).json, { ok: true, interface: choice });
|
||||
const res = interfaceCli(home, []);
|
||||
assert.equal(res.json.interface, choice);
|
||||
assert.match(res.json.rule, /saved default, so do not ask/);
|
||||
assert.doesNotMatch(res.json.rule, /Save nothing/);
|
||||
}
|
||||
assert.deepEqual(interfaceCli(home, ["--set", "ask"]).json, { ok: true, interface: null });
|
||||
assert.equal(fs.existsSync(path.join(home, "interface.json")), false);
|
||||
assert.equal(interfaceCli(home, []).json.interface, null);
|
||||
} finally {
|
||||
fs.rmSync(home, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("interface refuses an unknown or missing value, and reads a damaged file as no default", () => {
|
||||
const home = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-interface-"));
|
||||
try {
|
||||
for (const bad of [["--set", "browser"], ["--set"]]) {
|
||||
const res = interfaceCli(home, bad);
|
||||
assert.equal(res.status, 2, bad.join(" "));
|
||||
assert.equal(fs.existsSync(path.join(home, "interface.json")), false);
|
||||
}
|
||||
for (const body of ["{not json", JSON.stringify({ interface: "browser" }), "[]"]) {
|
||||
fs.writeFileSync(path.join(home, "interface.json"), body);
|
||||
assert.equal(interfaceCli(home, []).json.interface, null, body);
|
||||
}
|
||||
} finally {
|
||||
fs.rmSync(home, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// The rule lives in the interface command, so no skill may go back to asking
|
||||
// up front or spell out its own version of the rule.
|
||||
test("every skill but the dashboard picks its interface through the interface command", () => {
|
||||
const skills = fs.readdirSync(path.join(ROOT, "src")).filter((f) => /^plan2code-.*\.md$/.test(f));
|
||||
assert.equal(skills.length, 21);
|
||||
for (const f of skills) {
|
||||
const text = fs.readFileSync(path.join(ROOT, "src", f), "utf8");
|
||||
const iface = text.indexOf('console.mjs" interface`');
|
||||
assert.ok(iface > -1, `${f} runs the interface command`);
|
||||
assert.ok(iface < text.search(/console\.mjs" open(?! --resume)/), `${f} runs it before open`);
|
||||
assert.doesNotMatch(text, /ask \*\*web console\*\*/, `${f} no longer asks up front`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user