Remember the terminal or web console choice, refresh the launcher model menus (v3.2.2)

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-30 20:08:23 -08:00
1 parent f1d087ba47
commit ccf82c4eb7
60 files changed
+477 -317

No files matched your search

+6
View File
@@ -143,6 +143,11 @@ port, and the filesystem as transport; this CLI is the whole agent surface.
finish to post). --force stops a dead page or an abandoned session
anyway (the desktop app passes it on its own shutdowns); --all
never asks.
interface [--set web|terminal|ask]
Every skill's first step. Prints { interface, rule }: the person's
saved default ("web", "terminal" or null) and the rule for picking
this session's interface. Follow the rule. --set saves the default
for every skill in every project; ask clears it.
${workflowLines()}
@@ -174,6 +179,7 @@ export const HELP_TOPICS = {
dashboard: "console-launches.md",
meter: "console-meter.md",
trouble: "console-trouble.md",
interface: "console-interface.md",
};
for (const f of fs.existsSync(path.join(HERE, "notes")) ? fs.readdirSync(path.join(HERE, "notes")) : []) {
if (f.endsWith(".md")) HELP_TOPICS[f.slice(0, -3)] ??= `notes/${f}`;
+53 -2
View File
@@ -1,9 +1,9 @@
// Plan2Code Web Console - the small commands: keep, forget, delete-spec, handoff, delete-handoff, status and stop.
// Plan2Code Web Console - the small commands: keep, forget, delete-spec, handoff, delete-handoff, status, stop and interface.
import fs from "node:fs";
import path from "node:path";
import { SESSIONS_DIR, appendEvent, readJson } from "./files.mjs";
import { HERE, HOME_DIR, INTERFACE_FILE, INTERFACES, SESSIONS_DIR, appendEvent, ensureDir, nowIso, readJson, savedInterface, writeJsonAtomic } from "./files.mjs";
import { SERVER_MAX_LIFE_MS, attachmentName, healthOk, listHandles, pidAlive, projectRoot, repoRoots, resultWaiting, sessionDir } from "./sessions.mjs";
import { removeSpec } from "./scan.mjs";
import { isOpen, rule } from "./patches.mjs";
@@ -304,3 +304,54 @@ export async function cmdStop() {
}
print({ ok: true, stopped, ...(skipped ? { skippedStaleHandles: skipped } : {}) });
}
/* ------------------------------------------------------------ interface */
// Every skill's first step: terminal or web console? The answer comes from the
// person's request, else their one saved default, and only when neither says
// does a skill ask. An answer is never saved on its own: the person opts in to
// a default by asking for one. The rule is printed here rather than written
// into every skill prompt: those sit at their size limit, and one copy
// cannot drift.
const INTERFACE_NAMES = { web: "web console", terminal: "terminal" };
const INTERFACE_CUES =
"Cues for the web console: --web, `Use the web console for this session.`, or words such as " +
"web console, Plan2Code UI, browser page, interactive HTML session. Cues for the terminal: " +
"--terminal, or asking for the terminal. A task that is merely about web code is not a cue. " +
"Drop a flag from the argument.";
function interfaceRule(saved) {
const set = `node "${path.join(HERE, "console.mjs")}" interface --set web|terminal`;
const switching =
'Mid-session, "web console" or "terminal" from the person switches (console-interface.md → Switching mid-session) and leaves the default alone.';
if (saved) {
return (
`Use the ${INTERFACE_NAMES[saved]}: it is the person's saved default, so do not ask. ` +
`Only a cue in their request for this skill overrides it, for this session only. ${INTERFACE_CUES} ` +
`${switching} Asked to change the default: ${set}; --set ask clears it, so the next skill asks again.`
);
}
return (
`No default saved. A cue in the person's request decides. ${INTERFACE_CUES} ` +
"Without one, ask: web console (suggested: a browser page, easier for sign-offs) or terminal. " +
"Save nothing from the answer. After asking, add one line: say \"make the terminal (or web console) my default\" " +
`and no skill asks again. Asked for a default: ${set}. ${switching}`
);
}
export function cmdInterface() {
if (args.set === undefined) {
const saved = savedInterface();
print({ interface: saved, rule: interfaceRule(saved) });
return;
}
if (args.set === "ask") {
fs.rmSync(INTERFACE_FILE, { force: true });
print({ ok: true, interface: null });
return;
}
if (!INTERFACES.includes(args.set)) die("--set takes web, terminal or ask", 2);
ensureDir(HOME_DIR);
writeJsonAtomic(INTERFACE_FILE, { interface: args.set, at: nowIso() });
print({ ok: true, interface: args.set });
}
+55
View File
@@ -0,0 +1,55 @@
# The Interface Pick: Terminal or Web Console
Part of the web console contract (`console.md`). Read when the `interface`
command's rule tells you to ask, or when the person asks to switch a running
session between the terminal and this page.
## Which one: the request, the saved default, or ask
Every skill's first step is `node "<CONSOLE>" interface`. It prints
`{ interface, rule }`: the person's saved default (`"web"`, `"terminal"` or
`null`) and the rule to follow. In short: a cue in their request wins for this
session (`--web`, `--terminal`, or plain words asking for one), then the saved
default, and only with neither do you ask. The answer is for this session only:
nothing is saved until the person asks for a default, so someone who has not
chosen one keeps being offered both.
The default is one file for the person, `interface.json` in the console folder
(`~/.plan2code/console/`), shared by every skill in every project. A cue, an
answer to the question or a mid-session switch never changes it. "Make the
terminal my default" does: `interface --set terminal`. `interface --set ask`
clears it, so the next skill asks again.
When the rule says to ask, use the structured question tool if you have one.
If you have none, ask it as an ordinary numbered question in prose. Either way
it is one question with two answers:
> **How would you like to work through this?**
>
> - **In your browser** (suggested) — a page opens with the questions laid out,
> what we have agreed so far, and everything saved as you go. Easier to follow,
> and far easier if you are walking through this with someone else.
> - **Here in the terminal** — one question at a time, right where you are.
If it lands on the terminal, ignore the rest of the console's files until they
ask to switch. If the console fails to start for any reason, say so in one line
and carry on in the terminal: never let this block the session.
## Switching mid-session
The person can move a running session either way whenever they say so ("web
console", "terminal", "switch to the browser"). The files under `specs/` are the
only source of truth and neither channel owns them, so nothing is lost. A switch
is for this session only and leaves the saved default alone.
- **Terminal → web console:** `open --workflow <yours>` (with `--spec` if you
know it), read `console.md` (and `building.md` for a build), then post where
the session stands: what is already settled as answered items, and the
question that is open now. Never re-ask something they answered in the
terminal.
- **Web console → terminal:** in one patch, post a `finish` with a headline
such as "Carrying on in the terminal", a body saying their answers are
saved, and `"console": false`, and clear any `"stopWarning"` with `""` (a
`finish` is refused while one is set). Then `stop`, and carry on in the
terminal from the same point, re-asking there whatever was still open on
the page.
+1 -1
View File
@@ -6,7 +6,7 @@
| `wait` returns 20 | `open --resume <sid>`, give the new link; nothing they typed is lost |
| They close the tab | Nothing: drafts are saved and the link restores everything |
| Your session ends mid-flight | Their answers stay on disk; a fresh session runs `status` (or `open --resume`, which reports `pendingResult:true`) and `wait` returns them |
| They ask to go back to the terminal | `finish`, then `stop`, and continue; files under `specs/` are unchanged |
| They ask to go back to the terminal | Post the "Carrying on in the terminal" `finish`, then `stop`, and continue (`console-interface.md` → Switching mid-session); files under `specs/` are unchanged |
| The page is dead, the server will not answer, or the session is abandoned with no finish | `stop --session <sid> --force` (a plain `stop` with no finish is refused, exit 3) |
| Picking up a paused session | `open --resume <sid>` clears the paused `finish` and its open questions; re-ask what you need (`console-stop.md`) |
| The same result arrives twice | Your harness killed `wait` after the hand-over. Handle it once; most of a repeated patch is harmless since items merge by id, but `thread` appends: leave out entries you already sent |
+6 -2
View File
@@ -8,6 +8,8 @@
// keep copy a cited note attachment into specs/<idea>/attachments/
// status list sessions, or show one
// stop shut a session's server down
// interface the person's saved terminal / web console default, and the rule
// every skill follows to pick one; --set changes it
//
// This file is the command table and what every command shares (the parsed
// flags, print, die and the session lookups). The commands live beside it:
@@ -39,6 +41,7 @@ import {
cmdDeleteSpec,
cmdForget,
cmdHandoff,
cmdInterface,
cmdKeep,
cmdStatus,
cmdStop,
@@ -90,6 +93,7 @@ const COMMANDS = {
"delete-handoff": cmdDeleteHandoff,
status: cmdStatus,
stop: cmdStop,
interface: cmdInterface,
help: cmdHelp,
};
@@ -107,7 +111,7 @@ if (Number.isFinite(nodeMajor) && nodeMajor < 18) {
if (!cmd || !Object.hasOwn(COMMANDS, cmd)) {
process.stderr.write(
"console: usage: console.mjs <open|post|wait|chat|keep|forget|delete-spec|handoff|delete-handoff|status|stop|help> [--session <id>] [--file <patch.json>] [--seconds N]\n"
"console: usage: console.mjs <open|post|wait|chat|keep|forget|delete-spec|handoff|delete-handoff|status|stop|interface|help> [--session <id>] [--file <patch.json>] [--seconds N]\n"
);
process.exit(2);
}
@@ -115,7 +119,7 @@ if (!cmd || !Object.hasOwn(COMMANDS, cmd)) {
// A flag given with no value parses as `true`, and a boolean handed on as a
// path or a name crashes somewhere deep (path.basename(true) throws). Every
// flag that takes a value is checked once, here, and refused as bad usage.
const VALUE_FLAGS = ["session", "sid", "resume", "file", "spec", "title", "workflow", "skill", "handoff", "upload", "name", "from", "seconds", "limit", "idle-ms", "for-cli", "round", "role", "scope-file"];
const VALUE_FLAGS = ["session", "sid", "resume", "file", "spec", "title", "workflow", "skill", "handoff", "upload", "name", "from", "seconds", "limit", "idle-ms", "for-cli", "round", "role", "scope-file", "set"];
for (const flag of VALUE_FLAGS) {
if (flag in args && typeof args[flag] !== "string") die(`--${flag} needs a value`, 2);
}
+13
View File
@@ -53,6 +53,19 @@ export const LOOKS_FILE = path.join(HOME_DIR, "looks.json");
// so every session within the hour reuses one lookup.
export const UPDATE_CHECK_FILE = path.join(HOME_DIR, "update-check.json");
// Where the person likes skills to run: "web" (this console) or "terminal".
// One file for the user, read by every skill in every project, and kept apart
// from looks.json because the page rewrites that one from its own copy and
// would put back a stale value. Written only by `console.mjs interface --set`.
export const INTERFACE_FILE = path.join(HOME_DIR, "interface.json");
export const INTERFACES = Object.freeze(["web", "terminal"]);
// The saved interface, or null when there is none or the file is unreadable.
export function savedInterface() {
const saved = readJson(INTERFACE_FILE, null);
return saved && INTERFACES.includes(saved.interface) ? saved.interface : null;
}
// The runtime dir has to follow PLAN2CODE_CONSOLE_HOME too. Without that, a
// test run (or a second sandboxed instance) shares one handle directory with
// the real thing, and `stop --all` reaches outside its own world and kills a
+1
View File
@@ -22,6 +22,7 @@ export const POINTER_FILES = {
workspace: "console-workspace.md",
subagents: "console-subagents.md",
review: "building-review.md",
interface: "console-interface.md",
learning: "console-launches.md",
};
+3 -3
View File
@@ -451,8 +451,8 @@ export function workflowLabel(workflow) {
export const CONSOLE_WORKFLOWS = FLOW_SKILLS.map((s) => s.command).filter(Boolean);
// Rides on the end of the command as part of the skill's argument. Every
// console skill takes it as the answer to "web console or terminal?" instead
// of asking again. It must stay clear of "brief", "recap" and "minutes":
// console skill takes it as a one-session cue for the web console, ahead of
// the person's saved default. It must stay clear of "brief", "recap" and "minutes":
// pathfinder reads any of those in its argument as a request for a brief.
export const CONTINUE_IN_CONSOLE = "--web";
@@ -464,7 +464,7 @@ const CONSOLE_SENTENCE = /\s*Use the web console for this session\.?/gi;
* What the Copy button on the finished screen puts on the clipboard.
*
* Someone who worked the whole session in the browser should land back in the
* browser, not be asked the interface question as though they were new. The
* browser, even when their saved default is the terminal. The
* `--web` flag goes on the same line as the command, because what follows a
* slash command is its argument, and a pasted second line is not reliably that.
* A command written with the long sentence is copied with the flag instead.
+7
View File
@@ -3908,6 +3908,13 @@
Your choices are remembered on this machine and carry over to every
session you open here.
</p>
<h4>Terminal or this page</h4>
<p>
Until you save a default, Plan2Code asks whether to start in the
terminal or on this page. Say "make the terminal my default" (or "make
the web console my default") and it stops asking. To move just the
session you are in, say "web console" or "terminal" at any point.
</p>
<h4>Less motion</h4>
<p>
The page has no motion switch of its own. It follows your computer's
+2 -1
View File
@@ -297,12 +297,13 @@ export async function removeSessions(sessionsDir, sids) {
}
// The console folder's own files that no sweep may ever remove: the person's
// looks, the folders remembered per project and spec, the Implementation
// looks, their saved interface, the folders remembered per project and spec, the Implementation
// Loop's setup per project and its report while a build is under way, the Subagents switch
// saved per project and workflow, what each unknown git host is, the pointer
// to this console's directory, and the cached release check.
export const PROTECTED_CONSOLE_FILES = new Set([
"looks.json",
"interface.json",
"workspaces.json",
"loop-setup.json",
"loop-reports.json",