mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Let helpers run at a strength matched to their job, chosen in the Subagents dialog
AI Assisted
This commit is contained in:
1 parent
5f91fb665f
commit
1d146cce6f
23 files changed
+482
-73
No files matched your search
@@ -2086,6 +2086,31 @@
|
||||
</li>
|
||||
<li>The button only appears on skills that use helpers, and only when Plan2Code can pass the setting on.</li>
|
||||
</ul>
|
||||
<h4>Helper strength</h4>
|
||||
<p>
|
||||
Under Helpers, the dialog also asks how strong the helpers should be.
|
||||
Like the rest of the dialog it is saved for this project and this
|
||||
skill, and it does nothing under <strong>Work alone</strong>.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<strong>Balanced</strong> (the default): each helper gets the
|
||||
strength its job needs: light for lookups, stronger for reviews and
|
||||
design work.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Thrifty</strong>: one step lighter everywhere to save cost;
|
||||
reviews stay at standard or above.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Best</strong>: the strongest model and high effort for
|
||||
everything except lookups.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Match my session</strong>: helpers run on whatever your
|
||||
session uses; nothing is set for them.
|
||||
</li>
|
||||
</ul>
|
||||
<h4>The Subagents tab</h4>
|
||||
<ul>
|
||||
<li>
|
||||
@@ -2099,6 +2124,12 @@
|
||||
check-ins, not live. The page cannot stop a helper; ask Plan2Code
|
||||
on the Ask tab if one should stop.
|
||||
</li>
|
||||
<li>
|
||||
Under each helper, a line such as "Standard, medium effort" shows
|
||||
what that helper actually ran with. "Session model" means the agent
|
||||
could not set a strength for it, so it ran on the session's own
|
||||
model. A helper that reported neither shows no line.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Working alone</strong> means your agent reported it has no
|
||||
way to start helpers here. If it starts one after all, the note
|
||||
@@ -2639,6 +2670,14 @@
|
||||
<label><input type="radio" name="subagents-on" value="on" /> <span>Use helpers</span></label>
|
||||
<label><input type="radio" name="subagents-on" value="off" checked /> <span>Work alone</span></label>
|
||||
</fieldset>
|
||||
<fieldset class="modal-ranges looks-row" id="subagents-strength-row">
|
||||
<legend>Helper strength</legend>
|
||||
<label><input type="radio" name="subagents-strength" value="balanced" checked /> <span>Balanced</span></label>
|
||||
<label><input type="radio" name="subagents-strength" value="thrifty" /> <span>Thrifty</span></label>
|
||||
<label><input type="radio" name="subagents-strength" value="best" /> <span>Best</span></label>
|
||||
<label><input type="radio" name="subagents-strength" value="session" /> <span>Match my session</span></label>
|
||||
<p class="help" id="subagents-strength-help"></p>
|
||||
</fieldset>
|
||||
<fieldset class="modal-ranges">
|
||||
<legend>Instruction</legend>
|
||||
<textarea id="subagents-instruction" rows="4" maxlength="2000" aria-label="Instruction"></textarea>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { thumbs, uploadUrl, docChip, attachTray, CHAT_IMAGES, attachFiles, incom
|
||||
import { attachMentions } from "../mention-box.js";
|
||||
import { pickerAccept, attachmentKind, noteAwaiting, threadWho, threadText } from "../answers.js";
|
||||
import { postJson } from "../net.js";
|
||||
import { CHECKIN_LINE, helperRows, showSwitch, switchLabel, defaultInstruction, PATHFINDER_RESEARCH_LINE } from "../subagents.js";
|
||||
import { CHECKIN_LINE, helperRows, showSwitch, switchLabel, defaultInstruction, PATHFINDER_RESEARCH_LINE, STRENGTHS, DEFAULT_STRENGTH, STRENGTH_HELP } from "../subagents.js";
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
@@ -724,6 +724,7 @@ export function renderSubagents(main) {
|
||||
head.appendChild(pill);
|
||||
item.appendChild(head);
|
||||
item.appendChild(el("p", "sa-ask", row.ask));
|
||||
if (row.strengthLine) item.appendChild(el("p", "sa-strength", row.strengthLine));
|
||||
if (row.result) item.appendChild(el("p", "sa-result", row.result));
|
||||
list.appendChild(item);
|
||||
}
|
||||
@@ -755,6 +756,9 @@ export function openSubagents() {
|
||||
}
|
||||
$("subagents-instruction").value = page.subagentsFrame.instruction ?? defaultInstruction(page.S.workflow);
|
||||
$("subagents-max").value = String(page.subagentsFrame.max);
|
||||
const strength = STRENGTHS.includes(page.subagentsFrame.strength) ? page.subagentsFrame.strength : DEFAULT_STRENGTH;
|
||||
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.checked = radio.value === strength;
|
||||
syncStrengthHelp();
|
||||
$("subagents-checkin").textContent = CHECKIN_LINE;
|
||||
const research = $("subagents-research");
|
||||
research.textContent = PATHFINDER_RESEARCH_LINE;
|
||||
@@ -767,17 +771,25 @@ export function openSubagents() {
|
||||
if (checked) checked.focus();
|
||||
}
|
||||
|
||||
// Instruction and "at most" only mean anything with helpers on, so they are
|
||||
// inert under Work alone (kept as typed, for when helpers go back on).
|
||||
// Instruction, "at most" and strength only mean anything with helpers on, so
|
||||
// they are inert under Work alone (kept as picked, for when helpers go back on).
|
||||
export function syncSubagentsFields() {
|
||||
const picked = document.querySelector('input[name="subagents-on"]:checked');
|
||||
const off = !picked || picked.value !== "on";
|
||||
for (const id of ["subagents-instruction", "subagents-max", "subagents-default"]) $(id).disabled = off;
|
||||
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.disabled = off;
|
||||
}
|
||||
|
||||
// The line under the strength radios explains the picked one.
|
||||
function syncStrengthHelp() {
|
||||
const picked = document.querySelector('input[name="subagents-strength"]:checked');
|
||||
$("subagents-strength-help").textContent = STRENGTH_HELP[picked ? picked.value : DEFAULT_STRENGTH];
|
||||
}
|
||||
|
||||
const SUBAGENTS_ERRORS = {
|
||||
max: "Pick a number from 1 to 20.",
|
||||
"too-long": "The instruction is over 2,000 characters.",
|
||||
strength: "That strength isn't one of the four choices.",
|
||||
"not-offered": "This skill doesn't use helpers.",
|
||||
bad: "That didn't save. Try again.",
|
||||
};
|
||||
@@ -792,7 +804,13 @@ export async function saveSubagents() {
|
||||
// The shipped default is stored as null, so a later release's wording
|
||||
// reaches everyone who never changed it.
|
||||
const instruction = text === defaultInstruction(page.S.workflow) ? null : text;
|
||||
const body = { on: Boolean(picked && picked.value === "on"), instruction, max: Number($("subagents-max").value) };
|
||||
const strength = document.querySelector('input[name="subagents-strength"]:checked');
|
||||
const body = {
|
||||
on: Boolean(picked && picked.value === "on"),
|
||||
instruction,
|
||||
max: Number($("subagents-max").value),
|
||||
strength: strength ? strength.value : DEFAULT_STRENGTH,
|
||||
};
|
||||
save.disabled = true;
|
||||
status.textContent = "";
|
||||
const res = await postJson("/subagents", body);
|
||||
@@ -811,6 +829,7 @@ export const askOfflineFlipped = () => (askState().send.state === "offline") !==
|
||||
// The Subagents dialog's buttons, and dropping files onto the notes panel.
|
||||
export function wireAsk() {
|
||||
for (const radio of document.querySelectorAll('input[name="subagents-on"]')) radio.addEventListener("change", syncSubagentsFields);
|
||||
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.addEventListener("change", syncStrengthHelp);
|
||||
lightDismiss($("subagents-modal"));
|
||||
$("btn-subagents").addEventListener("click", openSubagents);
|
||||
$("subagents-default").addEventListener("click", () => {
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
// Shared by Implement and Implement + Review.
|
||||
const BUILD_HELPERS =
|
||||
"Hand independent tasks in a phase to helpers: tasks that touch different files and do not depend on each other. Keep tasks that share files, the phase's tests and the sign-off with you.";
|
||||
"Hand independent tasks in a phase to helpers: tasks that touch different files and do not depend on each other. Keep tasks that share files, the phase's tests and the sign-off with you. Pick each helper's strength and effort from helper-strength.md's table: light for a 1-2 file task the task file spells out, standard for multi-file or debugging work.";
|
||||
|
||||
// Pathfinder's and Plan's reason on a finished spec (a fixed bug).
|
||||
export const FIXED_REASON = "This bug is fixed. Delete it with the Delete button on its chip, or move it to specs--completed/.";
|
||||
@@ -110,7 +110,7 @@ export const SKILLS = Object.freeze([
|
||||
pose: "pathfinder",
|
||||
builds: false, phased: false, metered: false, templates: true,
|
||||
weight: null, started: null, ran: null, resume: "folder",
|
||||
subagents: "Use helpers for codebase recon, sketches and lookups beside the conversation. Keep every question for the person with you.",
|
||||
subagents: "Use helpers for codebase recon, sketches and lookups beside the conversation. Keep every question for the person with you. Recon and lookups at light strength, research questions at standard.",
|
||||
states: ["none", "unrecognized", "exploring"], marksNext: true,
|
||||
greyed: {
|
||||
default: "This spec is already past the questions",
|
||||
@@ -264,7 +264,7 @@ export const SKILLS = Object.freeze([
|
||||
pose: "quick-task",
|
||||
builds: true, phased: false, metered: true, templates: true,
|
||||
weight: 1, started: "Quick task started", ran: "Quick task built", resume: null,
|
||||
subagents: "Use helpers for side lookups, such as reading unfamiliar code or checking documentation, while you make the change yourself.",
|
||||
subagents: "Use helpers for side lookups, such as reading unfamiliar code or checking documentation, while you make the change yourself. Side lookups at light strength, low effort.",
|
||||
states: "any",
|
||||
greyed: null,
|
||||
card: {
|
||||
@@ -284,7 +284,7 @@ export const SKILLS = Object.freeze([
|
||||
pose: "review",
|
||||
builds: false, phased: false, metered: true, templates: false,
|
||||
weight: 2, started: "Review started", ran: "Code review run", resume: null,
|
||||
subagents: "Run the review's analysis in one fresh helper briefed only with the spec and the change set (references/reviewer-brief.md); verify every finding yourself before you report.",
|
||||
subagents: "Run the review's analysis in one fresh helper briefed only with the spec and the change set (references/reviewer-brief.md); verify every finding yourself before you report. At standard strength or above (strongest for branch or full scope), high effort.",
|
||||
states: "any",
|
||||
greyed: null,
|
||||
card: {
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px;
|
||||
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
|
||||
}
|
||||
.sa-strength { margin: 4px 0 0; color: var(--ink-3); font-size: 12.5px; }
|
||||
.sa-result { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--rule); font-size: 13.5px; }
|
||||
.sa-pill { display: inline-flex; align-items: center; gap: 6px; flex: none; }
|
||||
.sa-pill.is-running { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
|
||||
|
||||
@@ -31,6 +31,20 @@ export const HELPER_TITLE_MAX = 80;
|
||||
export const HELPER_ASK_MAX = 400;
|
||||
export const HELPER_RESULT_MAX = 200;
|
||||
export const HELPER_STATES = Object.freeze(["running", "done", "failed"]);
|
||||
// The person's Helper strength profile, applied on top of helper-strength.md's table.
|
||||
export const STRENGTHS = Object.freeze(["balanced", "thrifty", "best", "session"]);
|
||||
export const DEFAULT_STRENGTH = "balanced";
|
||||
// What the dialog's strength radios say, and the line under them for the picked one.
|
||||
export const STRENGTH_LABELS = Object.freeze({ balanced: "Balanced", thrifty: "Thrifty", best: "Best", session: "Match my session" });
|
||||
export const STRENGTH_HELP = Object.freeze({
|
||||
balanced: "Each helper gets the strength its job needs: light for lookups, stronger for reviews and design work.",
|
||||
thrifty: "One step lighter everywhere to save cost; reviews stay at standard or above.",
|
||||
best: "The strongest model and high effort for everything except lookups.",
|
||||
session: "Helpers run on whatever your session uses; nothing is set for them.",
|
||||
});
|
||||
// What a reported helper may say it actually ran with.
|
||||
export const HELPER_STRENGTHS = Object.freeze(["light", "standard", "strongest", "inherit"]);
|
||||
export const HELPER_EFFORTS = Object.freeze(["low", "medium", "high"]);
|
||||
|
||||
/* ------------------------------------------------------------- settings */
|
||||
|
||||
@@ -46,12 +60,13 @@ export function effectiveInstruction(setting) {
|
||||
|
||||
export function defaultSetting(workflow) {
|
||||
// On until the person turns it off, for the workflows that offer the switch.
|
||||
return { workflow, on: offered(workflow), instruction: null, max: DEFAULT_MAX };
|
||||
return { workflow, on: offered(workflow), instruction: null, max: DEFAULT_MAX, strength: DEFAULT_STRENGTH };
|
||||
}
|
||||
|
||||
/**
|
||||
* `{ on, instruction, max }` from untrusted input, or `{ error }` naming the
|
||||
* field that failed: "bad" (wrong type), "too-long" (instruction) or "max".
|
||||
* `{ on, instruction, max, strength }` from untrusted input, or `{ error }`
|
||||
* naming the field that failed: "bad" (wrong type), "too-long" (instruction),
|
||||
* "max" or "strength". A missing strength is the default, balanced.
|
||||
* Returns an error object rather than throwing, so the route and the store
|
||||
* reader share one validator. An empty instruction means the default: null.
|
||||
*/
|
||||
@@ -67,7 +82,9 @@ export function cleanSetting(input) {
|
||||
}
|
||||
const max = input.max;
|
||||
if (!Number.isInteger(max) || max < MAX_MIN || max > MAX_MAX) return { error: "max" };
|
||||
return { on: input.on, instruction, max };
|
||||
const strength = input.strength === undefined || input.strength === null ? DEFAULT_STRENGTH : input.strength;
|
||||
if (!STRENGTHS.includes(strength)) return { error: "strength" };
|
||||
return { on: input.on, instruction, max, strength };
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ the lines */
|
||||
@@ -77,13 +94,22 @@ export const FRAME_LINES = Object.freeze([
|
||||
"Hand independent work to helpers if your tools allow it; otherwise carry on alone.",
|
||||
"Report each helper on the page (console-subagents.md); questions for the person stay with you.",
|
||||
'If your tools cannot start helpers at all, report one "working alone" entry for this skill run instead; a real helper report removes it.',
|
||||
"Match each helper's strength and effort to its job, as helper-strength.md says; when your tools cannot set them, start the helper without them.",
|
||||
]);
|
||||
|
||||
export const PATHFINDER_RESEARCH_LINE = "Research questions always use helpers, whatever this switch says.";
|
||||
|
||||
// The profile line each strength adds to an "on" block.
|
||||
export const STRENGTH_LINES = Object.freeze({
|
||||
balanced: "Helper strength: balanced (the table in helper-strength.md as written).",
|
||||
thrifty: "Helper strength: thrifty (one step lighter in strength and effort than the table; reviews never below standard).",
|
||||
best: "Helper strength: best (strongest and high effort for every helper except lookups, which stay light).",
|
||||
session: "Helper strength: match the session (set no model or effort on any helper, whatever the skill files say).",
|
||||
});
|
||||
|
||||
// Only the first line of a block starts at column 0, so no line inside it can
|
||||
// be read as an entry of its own (NFR-5).
|
||||
export function onLines({ revision, replaces, max, instruction }) {
|
||||
export function onLines({ revision, replaces, max, instruction, strength }) {
|
||||
const label = replaces ? `revision ${revision}, replaces revision ${replaces}` : `revision ${revision}`;
|
||||
const own = String(instruction || "")
|
||||
.split("\n")
|
||||
@@ -91,7 +117,7 @@ export function onLines({ revision, replaces, max, instruction }) {
|
||||
.filter((line) => line.trim());
|
||||
return [
|
||||
`Subagents: on (${label}) — a console setting, not typed by the person.`,
|
||||
...[...FRAME_LINES, ...own, `At most ${max} helpers at once.`].map((line) => " " + line),
|
||||
...[...FRAME_LINES, ...own, STRENGTH_LINES[strength] || STRENGTH_LINES[DEFAULT_STRENGTH], `At most ${max} helpers at once.`].map((line) => " " + line),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -110,17 +136,18 @@ export function blockFor(setting, told) {
|
||||
if (!setting || !offered(setting.workflow) || !(setting.revision > last.revision)) return null;
|
||||
const { revision, max } = setting;
|
||||
const instruction = effectiveInstruction(setting);
|
||||
const strength = STRENGTHS.includes(setting.strength) ? setting.strength : DEFAULT_STRENGTH;
|
||||
if (setting.on) {
|
||||
const replaces = last.state === "on" ? last.revision : undefined;
|
||||
return {
|
||||
field: { state: "on", revision, max, instruction },
|
||||
lines: onLines({ revision, replaces, max, instruction }),
|
||||
field: { state: "on", revision, max, instruction, strength },
|
||||
lines: onLines({ revision, replaces, max, instruction, strength }),
|
||||
cursor: { revision, state: "on" },
|
||||
};
|
||||
}
|
||||
if (last.state !== "on") return null;
|
||||
return {
|
||||
field: { state: "off", revision, max, instruction },
|
||||
field: { state: "off", revision, max, instruction, strength },
|
||||
lines: [offLine(revision)],
|
||||
cursor: { revision, state: "off" },
|
||||
};
|
||||
@@ -147,6 +174,8 @@ export function checkHelper(entry) {
|
||||
if (typeof entry.result !== "string") problems.push(`${who}: result must be a string`);
|
||||
else if (entry.result.length > HELPER_RESULT_MAX) problems.push(`${who}: result must be at most ${HELPER_RESULT_MAX} characters`);
|
||||
}
|
||||
if (entry.strength !== undefined && !HELPER_STRENGTHS.includes(entry.strength)) problems.push(`${who}: strength must be light, standard, strongest or inherit`);
|
||||
if (entry.effort !== undefined && !HELPER_EFFORTS.includes(entry.effort)) problems.push(`${who}: effort must be low, medium or high`);
|
||||
return problems;
|
||||
}
|
||||
|
||||
@@ -191,22 +220,43 @@ export function switchLabel(frame) {
|
||||
// What the Subagents tab draws: the working-alone note, or one row per helper
|
||||
// in the order the agent reported them. A real helper supersedes the
|
||||
// working-alone marker, so the note only draws when no helper was ever
|
||||
// reported. A result shows once the helper ended.
|
||||
// reported. A result shows once the helper ended, and a reported strength or
|
||||
// effort as one line ("Standard, medium effort").
|
||||
export function helperRows(helpers) {
|
||||
const list = Array.isArray(helpers) ? helpers.filter(isPlainObject) : [];
|
||||
const real = list.filter((h) => h.alone !== true);
|
||||
if (!real.length) return { alone: list.some((h) => h.alone === true), rows: [] };
|
||||
const rows = real.map(({ id, title, ask, state, result }) => ({
|
||||
id,
|
||||
title,
|
||||
ask,
|
||||
state,
|
||||
stateLabel: STATE_LABELS[state] || STATE_LABELS.running,
|
||||
...((state === "done" || state === "failed") && typeof result === "string" && result ? { result } : {}),
|
||||
}));
|
||||
const rows = real.map(({ id, title, ask, state, result, strength, effort }) => {
|
||||
const ran = {
|
||||
...(HELPER_STRENGTHS.includes(strength) ? { strength } : {}),
|
||||
...(HELPER_EFFORTS.includes(effort) ? { effort } : {}),
|
||||
};
|
||||
const line = strengthLine(ran.strength, ran.effort);
|
||||
return {
|
||||
id,
|
||||
title,
|
||||
ask,
|
||||
state,
|
||||
stateLabel: STATE_LABELS[state] || STATE_LABELS.running,
|
||||
...((state === "done" || state === "failed") && typeof result === "string" && result ? { result } : {}),
|
||||
...ran,
|
||||
...(line ? { strengthLine: line } : {}),
|
||||
};
|
||||
});
|
||||
return { alone: false, rows };
|
||||
}
|
||||
|
||||
const HELPER_STRENGTH_WORDS = Object.freeze({ light: "Light", standard: "Standard", strongest: "Strongest", inherit: "Session model" });
|
||||
|
||||
// "Standard, medium effort", "Light", "Medium effort", or "" when neither was reported.
|
||||
function strengthLine(strength, effort) {
|
||||
const parts = [];
|
||||
if (strength) parts.push(HELPER_STRENGTH_WORDS[strength]);
|
||||
if (effort) parts.push(`${effort} effort`);
|
||||
const line = parts.join(", ");
|
||||
return line && line[0].toUpperCase() + line.slice(1);
|
||||
}
|
||||
|
||||
// Never an empty tab. Independent of on / off, so Pathfinder's research
|
||||
// helpers show even with the switch off (FR-11, FR-12).
|
||||
export function showTab(frame, helpers) {
|
||||
|
||||
Reference in new issue
Block a user