mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Add the git-commit skill and dashboard card, and the No changes button, as v2.6.0
AI Assisted
This commit is contained in:
1 parent
1877ca1fa7
commit
50a78a6917
37 files changed
+1001
-141
No files matched your search
@@ -16,7 +16,7 @@ The FIRST thing you do, before anything else in this file — before reading a s
|
||||
|
||||
- `node "<S>/specs.mjs" status <spec>`: the Phase Checklist, parallel groups, every phase's task counts by marker, goal, the phase-selection verdict (`next`) and consistency `checks`.
|
||||
- `node "<S>/specs.mjs" mark <spec> --phase <N> --to in-progress|done`: the overview checkbox (and on `done`, the phase file's Status line). It refuses to reset `[/]` to `[ ]`.
|
||||
- `node "<S>/commit-msg.mjs" --subject "<subject>" --add-all`: the commit command, ticket taken from the branch.
|
||||
- `node "<S>/commit-msg.mjs" --subject "<subject>" --add-all`: the commit command (`<subject>`, then `AI Assisted`).
|
||||
|
||||
## Rules
|
||||
|
||||
@@ -208,7 +208,7 @@ On user "approved":
|
||||
| Phase X: [Name] | Y | [One-sentence goal] |
|
||||
| Phase X+1: [Name] | Z | [One-sentence goal] |
|
||||
|
||||
5. Write a one-line subject for the phase, then give the user the `command` from `commit-msg.mjs --subject "<subject>" --add-all`. It enforces the format: subject ≤100 chars and EXACTLY THREE -m flags (subject, ticket, `AI Assisted`), no body. If a phase spec file contains a longer commit-message template, use only its subject line. The diff is the body; the PR is the explanation. On Windows PowerShell 5.1 (no `&&`), give `add` and `commit` as two commands instead. Exit 4 `no-ticket`: ask the user for the ticket and rerun with `--ticket`, or show the command with `<JIRA-Ticket-ID>` for them to fill in.
|
||||
5. Write a one-line subject for the phase, then give the user the `command` from `commit-msg.mjs --subject "<subject>" --add-all`. It enforces the format: subject ≤100 chars and EXACTLY TWO -m flags (subject, `AI Assisted`), no body. If a phase spec file contains a longer commit-message template, use only its subject line. The diff is the body; the PR is the explanation. On Windows PowerShell 5.1 (no `&&`), give `add` and `commit` as two commands instead.
|
||||
6. **If more phases:** "NEXT STEP: Start NEW conversation and run: `/plan2code-3-implement --web`"
|
||||
7. **If final phase:** "NEXT STEP: Start NEW conversation and run: `/plan2code-4-finalize --web`"
|
||||
8. Mention `/plan2code-1b-revise-plan --web` option
|
||||
|
||||
@@ -18,7 +18,7 @@ The FIRST thing you do, before anything else in this file — before the Require
|
||||
- `node "<S>/specs.mjs" archive <spec> [--dry-run]`: the Step 6 move, verified.
|
||||
- `node "<S>/specs.mjs" metrics <spec> --step finalize --set ...`: Step 7's METRICS_JSON line.
|
||||
- `node "<S>/feedback-payload.mjs"`: Step 6.5 (see its reference).
|
||||
- `node "<S>/commit-msg.mjs" --subject "<subject>"`: the commit command, ticket from the branch.
|
||||
- `node "<S>/commit-msg.mjs" --subject "<subject>"`: the commit command.
|
||||
|
||||
## Rules
|
||||
|
||||
@@ -343,7 +343,7 @@ If you discovered undocumented commands, dependency quirks, gotchas (>5min cost)
|
||||
|
||||
(Step 7 already delivered the completion summary — don't repeat it.)
|
||||
|
||||
Suggested commit (only if README, CHANGELOG, or other tracked docs were updated): the `command` from `commit-msg.mjs --subject "chore: finalize and archive <feature-name>"` (exit 4 `no-ticket`: show it with `<JIRA-Ticket-ID>` for the user to fill in).
|
||||
Suggested commit (only if README, CHANGELOG, or other tracked docs were updated): the `command` from `commit-msg.mjs --subject "chore: finalize and archive <feature-name>"`.
|
||||
|
||||
Returning context: Feature complete. Specs archived to `specs--completed/<feature-name>/`.
|
||||
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
#!/usr/bin/env node
|
||||
// git-state.mjs: what the Git commit skill needs to know about the repository.
|
||||
//
|
||||
// The skill's questions about git have one correct answer each: which branch is
|
||||
// the default, what is staged, which files are risky, what a push would be. They
|
||||
// live here so no prompt works them out by eye or per shell. This script only
|
||||
// reads: it never changes the repository, the index or the working tree. The
|
||||
// agent runs git init, switch, add, commit and push itself, each behind a yes.
|
||||
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { EXIT, fail, out, parseArgs, run } from "./common.mjs";
|
||||
|
||||
const USAGE = `
|
||||
git-state.mjs: read-only facts about the git repository. JSON on stdout. It never
|
||||
changes the repository.
|
||||
|
||||
node git-state.mjs state
|
||||
node git-state.mjs branch-check --name <branch>
|
||||
node git-state.mjs init-check
|
||||
|
||||
state Run from inside a repository. Prints { ok, root, branch, detached,
|
||||
hasCommits, defaultBranch, defaultFrom, onDefault, inProgress,
|
||||
conflicted, staged, unstaged, untracked, nothingToCommit,
|
||||
sensitive, large, remotes, upstream, ahead, behind, unpublished,
|
||||
push }.
|
||||
branch null when HEAD is detached.
|
||||
defaultBranch origin/HEAD, else local main, else master, else
|
||||
(no commits yet, on main or master) that branch,
|
||||
else null. defaultFrom says which: origin/HEAD,
|
||||
local-main, local-master, unborn, null.
|
||||
inProgress merge, rebase, cherry-pick, revert or null.
|
||||
staged, unstaged, untracked, conflicted
|
||||
[{ path, status }]; a conflicted file is listed
|
||||
only under conflicted.
|
||||
sensitive paths that look like secrets (.env, keys,
|
||||
credentials); left out unless the person insists.
|
||||
large [{ path, bytes }] for files over 5 MB.
|
||||
ahead, behind commits against the upstream; null without one.
|
||||
unpublished commits exist and the branch has no upstream.
|
||||
push null when there is nothing to push, no remote, no
|
||||
commits or HEAD is detached; otherwise
|
||||
{ command, setsUpstream, remote, needsRemoteChoice }.
|
||||
branch-check Is --name a usable new branch name here? Prints { ok, name, valid,
|
||||
exists }. Exit 4 when the name is invalid or already taken.
|
||||
init-check Run anywhere. Can git init be offered in this folder? Prints { ok,
|
||||
path, safe, reason?, insideRepo, repoRoot?, hasGitignore,
|
||||
suggestedIgnore }. safe is false (reason: inside-repo, home or
|
||||
root) for a folder that is already in a repository, the home
|
||||
folder and a drive root. suggestedIgnore lists .gitignore lines
|
||||
for what is in the folder (node_modules/, .env, build output).
|
||||
|
||||
Exit: 0 ok · 1 crash · 2 bad arguments · 3 not a git repository · 4 invalid or
|
||||
taken branch name.
|
||||
`;
|
||||
|
||||
const LARGE_BYTES = 5 * 1024 * 1024;
|
||||
// An untracked folder is one entry in the status; its files are listed
|
||||
// separately so a .env inside a new folder is still caught. Every name is
|
||||
// checked, but only the first STAT_LIMIT files are sized, so a forgotten
|
||||
// node_modules cannot make this slow.
|
||||
const STAT_LIMIT = 2000;
|
||||
const CONFLICT = new Set(["DD", "AU", "UD", "UA", "DU", "AA", "UU"]);
|
||||
|
||||
function git(args, cwd, { raw = false } = {}) {
|
||||
try {
|
||||
const stdout = execFileSync("git", args, {
|
||||
cwd,
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
maxBuffer: 64 * 1024 * 1024,
|
||||
// Without this, git status refreshes the index on disk: a write.
|
||||
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" },
|
||||
});
|
||||
return { ok: true, out: raw ? stdout : stdout.trim() };
|
||||
} catch {
|
||||
return { ok: false, out: "" };
|
||||
}
|
||||
}
|
||||
|
||||
function requireRepo() {
|
||||
const top = git(["rev-parse", "--show-toplevel"], process.cwd());
|
||||
if (!top.ok || !top.out) {
|
||||
fail(EXIT.NOT_FOUND, "not-a-repo", "This directory is not inside a git repository.", "Run git-state.mjs init-check to see whether this folder can start one.");
|
||||
}
|
||||
return top.out;
|
||||
}
|
||||
|
||||
// Basename tests for files that probably hold secrets.
|
||||
const ENV_OK = new Set([".env.example", ".env.sample", ".env.template"]);
|
||||
function isSensitive(file) {
|
||||
const b = file.split("/").pop();
|
||||
if (b === ".env" || (b.startsWith(".env.") && !ENV_OK.has(b))) return true;
|
||||
if (/\.(pem|key|p12|pfx|keystore|jks)$/.test(b)) return true;
|
||||
if (/^id_(rsa|dsa|ecdsa|ed25519)/.test(b)) return true;
|
||||
if (/^credentials.*\.json$/.test(b) || b.endsWith(".credentials")) return true;
|
||||
if (b === ".npmrc" || b === ".pypirc" || b === ".netrc") return true;
|
||||
return b.startsWith("secrets.");
|
||||
}
|
||||
|
||||
function inProgress(root) {
|
||||
const dir = git(["rev-parse", "--absolute-git-dir"], root).out;
|
||||
if (!dir) return null;
|
||||
const has = (n) => fs.existsSync(path.join(dir, n));
|
||||
if (has("MERGE_HEAD")) return "merge";
|
||||
if (has("rebase-merge") || has("rebase-apply")) return "rebase";
|
||||
if (has("CHERRY_PICK_HEAD")) return "cherry-pick";
|
||||
if (has("REVERT_HEAD")) return "revert";
|
||||
return null;
|
||||
}
|
||||
|
||||
function defaultBranch(root, branch, hasCommits) {
|
||||
const head = git(["symbolic-ref", "-q", "--short", "refs/remotes/origin/HEAD"], root);
|
||||
if (head.ok && head.out) return { name: head.out.replace(/^origin\//, ""), from: "origin/HEAD" };
|
||||
if (git(["show-ref", "--verify", "-q", "refs/heads/main"], root).ok) return { name: "main", from: "local-main" };
|
||||
if (git(["show-ref", "--verify", "-q", "refs/heads/master"], root).ok) return { name: "master", from: "local-master" };
|
||||
if (!hasCommits && (branch === "main" || branch === "master")) return { name: branch, from: "unborn" };
|
||||
return { name: null, from: null };
|
||||
}
|
||||
|
||||
// git status --porcelain=v1 -z: "XY path" entries; a rename or copy is followed
|
||||
// by one more field holding the original path.
|
||||
function parseStatus(root) {
|
||||
const res = git(["status", "--porcelain=v1", "-z", "--untracked-files=normal"], root, { raw: true });
|
||||
const files = { staged: [], unstaged: [], untracked: [], conflicted: [] };
|
||||
const fields = res.out.split("\0");
|
||||
for (let i = 0; i < fields.length; i++) {
|
||||
const f = fields[i];
|
||||
if (f.length < 4) continue;
|
||||
const x = f[0];
|
||||
const y = f[1];
|
||||
const p = f.slice(3);
|
||||
if (x === "R" || x === "C" || y === "R" || y === "C") i++;
|
||||
if (x === "?" && y === "?") files.untracked.push({ path: p, status: "?" });
|
||||
else if (CONFLICT.has(x + y)) files.conflicted.push({ path: p, status: x + y });
|
||||
else {
|
||||
if (x !== " " && x !== "?") files.staged.push({ path: p, status: x });
|
||||
if (y !== " " && y !== "?") files.unstaged.push({ path: p, status: y });
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
function riskyFiles(root, files) {
|
||||
const names = new Set();
|
||||
for (const list of [files.staged, files.unstaged, files.untracked, files.conflicted]) {
|
||||
for (const f of list) if (!f.path.endsWith("/")) names.add(f.path);
|
||||
}
|
||||
if (files.untracked.some((f) => f.path.endsWith("/"))) {
|
||||
const all = git(["ls-files", "-o", "--exclude-standard", "-z"], root, { raw: true });
|
||||
for (const n of all.out.split("\0")) if (n) names.add(n);
|
||||
}
|
||||
const sensitive = [];
|
||||
const large = [];
|
||||
let statted = 0;
|
||||
for (const p of names) {
|
||||
if (isSensitive(p)) sensitive.push(p);
|
||||
if (statted >= STAT_LIMIT) continue;
|
||||
statted++;
|
||||
try {
|
||||
const st = fs.statSync(path.join(root, p));
|
||||
if (st.isFile() && st.size > LARGE_BYTES) large.push({ path: p, bytes: st.size });
|
||||
} catch {
|
||||
// a deletion, or a file that vanished
|
||||
}
|
||||
}
|
||||
return { sensitive: sensitive.sort(), large: large.sort((a, b) => a.path.localeCompare(b.path)) };
|
||||
}
|
||||
|
||||
function pushPlan(root, { branch, hasCommits, remotes, upstream, ahead }) {
|
||||
if (!branch || !hasCommits || !remotes.length) return null;
|
||||
if (upstream) {
|
||||
const configured = git(["config", "--get", `branch.${branch}.remote`], root).out;
|
||||
const remote = configured || upstream.split("/")[0];
|
||||
if (remote === "." || !ahead) return null;
|
||||
return { command: "git push", setsUpstream: false, remote, needsRemoteChoice: false };
|
||||
}
|
||||
const remote = remotes.length === 1 ? remotes[0] : remotes.includes("origin") ? "origin" : remotes[0];
|
||||
return { command: `git push -u ${remote} ${branch}`, setsUpstream: true, remote, needsRemoteChoice: remotes.length > 1 };
|
||||
}
|
||||
|
||||
function state() {
|
||||
const root = requireRepo();
|
||||
const branchRef = git(["symbolic-ref", "--short", "-q", "HEAD"], root);
|
||||
const branch = branchRef.ok && branchRef.out ? branchRef.out : null;
|
||||
const hasCommits = git(["rev-parse", "-q", "--verify", "HEAD"], root).ok;
|
||||
const def = defaultBranch(root, branch, hasCommits);
|
||||
const files = parseStatus(root);
|
||||
const { sensitive, large } = riskyFiles(root, files);
|
||||
const remotes = git(["remote"], root).out.split(/\r?\n/).filter(Boolean);
|
||||
|
||||
const up = branch ? git(["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], root) : { ok: false };
|
||||
const upstream = up.ok && up.out ? up.out : null;
|
||||
let ahead = null;
|
||||
let behind = null;
|
||||
if (upstream) {
|
||||
const counts = git(["rev-list", "--left-right", "--count", "@{u}...HEAD"], root).out.split(/\s+/).map(Number);
|
||||
if (counts.length === 2 && counts.every(Number.isFinite)) [behind, ahead] = counts;
|
||||
}
|
||||
const unpublished = hasCommits && !!branch && !upstream;
|
||||
|
||||
out({
|
||||
ok: true,
|
||||
root,
|
||||
branch,
|
||||
detached: branch === null,
|
||||
hasCommits,
|
||||
defaultBranch: def.name,
|
||||
defaultFrom: def.from,
|
||||
onDefault: !!branch && !!def.name && branch === def.name,
|
||||
inProgress: inProgress(root),
|
||||
conflicted: files.conflicted,
|
||||
staged: files.staged,
|
||||
unstaged: files.unstaged,
|
||||
untracked: files.untracked,
|
||||
nothingToCommit: !files.staged.length && !files.unstaged.length && !files.untracked.length && !files.conflicted.length,
|
||||
sensitive,
|
||||
large,
|
||||
remotes,
|
||||
upstream,
|
||||
ahead,
|
||||
behind,
|
||||
unpublished,
|
||||
push: pushPlan(root, { branch, hasCommits, remotes, upstream, ahead }),
|
||||
});
|
||||
}
|
||||
|
||||
function branchCheck(args) {
|
||||
const name = (args.name || "").trim();
|
||||
if (!name) fail(EXIT.USAGE, "missing-name", "--name is required.", "Example: branch-check --name feature/export-csv");
|
||||
const root = requireRepo();
|
||||
const suggestion = "Use lowercase words joined by '-' under a prefix such as feature/, fix/, chore/ or docs/ (feature/export-csv).";
|
||||
// check-ref-format --branch also expands @{-1}; a changed name is not a name.
|
||||
const checked = name.startsWith("-") ? { ok: false } : git(["check-ref-format", "--branch", name], root);
|
||||
if (!checked.ok || checked.out !== name) {
|
||||
fail(EXIT.INVALID, "invalid-name", `"${name}" is not a valid git branch name.`, suggestion);
|
||||
}
|
||||
const exists = git(["show-ref", "--verify", "-q", `refs/heads/${name}`], root).ok;
|
||||
if (exists) fail(EXIT.INVALID, "branch-exists", `A branch named "${name}" already exists.`, `Pick another name, for example "${name}-2".`);
|
||||
// git cannot hold both feature and feature/x: a branch is a file in refs/heads.
|
||||
const heads = git(["for-each-ref", "--format=%(refname:short)", "refs/heads"], root).out.split(/\r?\n/).filter(Boolean);
|
||||
const clash = heads.find((h) => name.startsWith(`${h}/`) || h.startsWith(`${name}/`));
|
||||
if (clash) fail(EXIT.INVALID, "branch-conflict", `"${name}" clashes with the existing branch "${clash}" (one is a folder of the other).`, "Pick a name that is not nested under an existing branch.");
|
||||
out({ ok: true, name, valid: true, exists: false });
|
||||
}
|
||||
|
||||
// Top-level names that should not go into a first commit.
|
||||
const IGNORE_DIRS = ["node_modules", "dist", "build", "out", ".next", "coverage", "target", "__pycache__", ".venv", "venv"];
|
||||
|
||||
function suggestedIgnore(dir) {
|
||||
let names = [];
|
||||
try {
|
||||
names = fs.readdirSync(dir);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
const lines = [];
|
||||
for (const d of IGNORE_DIRS) if (names.includes(d)) lines.push(`${d}/`);
|
||||
const envs = names.filter((n) => n === ".env" || (n.startsWith(".env.") && !ENV_OK.has(n)));
|
||||
if (envs.length) {
|
||||
lines.push(".env", ".env.*");
|
||||
if (names.includes(".env.example")) lines.push("!.env.example");
|
||||
}
|
||||
if (names.includes(".DS_Store")) lines.push(".DS_Store");
|
||||
if (names.includes("Thumbs.db")) lines.push("Thumbs.db");
|
||||
if (names.some((n) => n.endsWith(".log"))) lines.push("*.log");
|
||||
return lines;
|
||||
}
|
||||
|
||||
const sameFolder = (a, b) => (process.platform === "win32" || process.platform === "darwin" ? a.toLowerCase() === b.toLowerCase() : a === b);
|
||||
|
||||
function initCheck() {
|
||||
const cwd = fs.realpathSync.native(process.cwd());
|
||||
const top = git(["rev-parse", "--show-toplevel"], cwd);
|
||||
const insideRepo = top.ok && !!top.out;
|
||||
let home = os.homedir();
|
||||
try {
|
||||
home = fs.realpathSync.native(home);
|
||||
} catch {
|
||||
// a home folder that no longer exists cannot be the current folder
|
||||
}
|
||||
let safe = true;
|
||||
let reason;
|
||||
if (insideRepo) [safe, reason] = [false, "inside-repo"];
|
||||
else if (sameFolder(cwd, home)) [safe, reason] = [false, "home"];
|
||||
else if (cwd === path.parse(cwd).root) [safe, reason] = [false, "root"];
|
||||
const result = { ok: true, path: cwd, safe };
|
||||
if (reason) result.reason = reason;
|
||||
result.insideRepo = insideRepo;
|
||||
if (insideRepo) result.repoRoot = top.out;
|
||||
result.hasGitignore = fs.existsSync(path.join(cwd, ".gitignore"));
|
||||
result.suggestedIgnore = suggestedIgnore(cwd);
|
||||
out(result);
|
||||
}
|
||||
|
||||
run(USAGE, async (argv) => {
|
||||
const args = parseArgs(argv, { values: ["name"] });
|
||||
const [cmd, ...extra] = args._;
|
||||
if (!cmd) fail(EXIT.USAGE, "missing-command", "A subcommand is required: state, branch-check or init-check.", "Run with --help for usage.");
|
||||
if (extra.length) fail(EXIT.USAGE, "stray-argument", `Unexpected argument(s): ${extra.join(" ")}.`, "Run with --help for usage.");
|
||||
if (cmd === "state") return state();
|
||||
if (cmd === "branch-check") return branchCheck(args);
|
||||
if (cmd === "init-check") return initCheck();
|
||||
fail(EXIT.USAGE, "unknown-command", `Unknown subcommand "${cmd}".`, "Use state, branch-check or init-check.");
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
# 🔀 GIT COMMIT MODE
|
||||
|
||||
Start all GIT COMMIT MODE responses with '🔀'
|
||||
|
||||
## Role
|
||||
|
||||
Careful committer. Read what changed, write a clear message, suggest a split when the work is really two jobs, and push only when asked. Nothing leaves the machine without a yes.
|
||||
|
||||
## Interface
|
||||
|
||||
The FIRST thing you do, before anything else in this file, before reading the repository: ask **web console** (browser page, suggested) or **terminal**? Console → run `node "<D>/console.mjs" open --workflow git-commit` before reading (<D>: references/web-console/ beside this SKILL.md, ~/.agents/skills/plan2code-git-commit/references/web-console/ globally, or the dir in ~/.plan2code/console/console-dir), then read <D>/console.md → Git commit. Every question goes through it. Switchable anytime. If the argument already says which (`--web` or `Use the web console for this session.`) take it and do not ask; drop the flag. Launched by the dashboard? Its session is already open: resume it (console.md → Launches), then Step 1. On the console, a `__stop` action is the person ending the session (console.md → Stop requests); at every session end post `finish` BEFORE `stop`.
|
||||
|
||||
## Scripts
|
||||
|
||||
`<S>` is `scripts/` beside this SKILL.md (`~/.agents/skills/plan2code-git-commit/scripts/` globally). Run them from the project folder. Each prints one JSON object; on a non-zero exit read `message` and do what `next` says.
|
||||
|
||||
- `node "<S>/git-state.mjs" state`: read-only snapshot. `branch`, `detached`, `defaultBranch`, `onDefault`, `inProgress`, `conflicted`, `staged`, `unstaged`, `untracked`, `nothingToCommit`, `sensitive`, `large`, `remotes`, `ahead`, `behind`, `push`. Exit 3 `not-a-repo`.
|
||||
- `node "<S>/git-state.mjs" branch-check --name <name>`: is the name usable? Exit 4 means invalid or taken.
|
||||
- `node "<S>/git-state.mjs" init-check`: can `git init` be offered here? `safe`, `reason`, `hasGitignore`, `suggestedIgnore`.
|
||||
- `node "<S>/commit-msg.mjs" --subject "<subject>" --files <path> [--files <path> ...]`: the commit command (one `--files` per path). Exit 4 means the subject or a path breaks a rule: rephrase it.
|
||||
|
||||
## Project context
|
||||
|
||||
Read `./AGENTS.md` when it exists, for commit conventions (subject style, branch names). Never block on it.
|
||||
|
||||
## Argument
|
||||
|
||||
An optional commit subject, for example `/plan2code-git-commit fix timeout on report export`. `--web` is the console flag, not part of the subject.
|
||||
|
||||
## Rules
|
||||
|
||||
- `git status` never with `-uall`.
|
||||
- Stage named files only. Never `git add -A` or `git add .`.
|
||||
- Never amend unless asked. Never `--no-verify`. Never force-push.
|
||||
- A failed hook: diagnose it, fix the cause, re-stage the group's files, make a NEW commit. A hook that fails on a problem unrelated to the staged changes is reported to the person, not worked around.
|
||||
- Never push, create a branch or run `git init` without an explicit yes. The commit itself needs a yes unless the subject came as the argument.
|
||||
- `sensitive` and `large` files are left out and named. Include one only if the person insists after a warning.
|
||||
- The message is exactly what `commit-msg.mjs` builds: `<subject>`, a blank line, `AI Assisted`. Subject at most 100 characters, about why. No other AI attribution.
|
||||
- Run no tests and no review before committing (Implement and Review do that).
|
||||
- On Windows PowerShell 5.1 (no `&&`), run `add` and `commit` as two commands.
|
||||
|
||||
## Steps
|
||||
|
||||
1. **State.** Run `state`. Exit 3 → Step 1b. `inProgress` or `conflicted` → say what is in progress (a merge, a rebase, files with conflicts) and stop: finish it first.
|
||||
1b. **Not a repository.** Run `init-check`. `safe: false` → explain (the home folder or a drive root) and stop. `safe` → ask before `git init`, naming the folder. On yes run it. If `hasGitignore` is false and `suggestedIgnore` is not empty, propose that `.gitignore` for approval, write it, then continue at Step 3 (the first commit; no push offer later because there is no remote; say it can be added with `git remote add origin <url>`).
|
||||
2. **Nothing to commit.** If `push` is not null, go to Step 7. Otherwise say the tree is clean and everything is pushed (or that there is no remote), and finish.
|
||||
3. **Branch.** When `onDefault` (or `detached`) and `hasCommits`, offer a new branch named `<type>/<short-description>` (types: feature, fix, chore, docs, refactor, test) from the changes. Run any name the person types through `branch-check`. On yes: `git switch -c <name>`. Skipping is always fine (on a detached HEAD, warn that commits there are easy to lose). When `defaultBranch` is null say why there is no offer.
|
||||
4. **Read the changes.** `git diff`, `git diff --cached` and the untracked files (an `untracked` path ending in `/` is a folder: list its files with `git ls-files -o --exclude-standard -- <folder>` and stage them by name). If the person staged some files, work from that staged set and leave the rest alone (say what was left). Decide whether the work is one concern or several.
|
||||
5. **Message.** One concern: draft a subject, or use the argument and skip approval; ask Yes / Edit / No. Several: always suggest whole-file groups, each with a subject, naming any file that mixes concerns and which group took it; ask Approve / Change it / One commit instead (asked even when the subject came as the argument). Mention `sensitive` and `large` files you are leaving out.
|
||||
6. **Commit.** For each group in order: when there is more than one group, run `git reset -q` first so only that group is staged; then run `commit-msg.mjs --subject "<s>" --files ...` and its `command` (or `add`, then `commit`). Finish with `git log --oneline -<n>`.
|
||||
7. **Push.** Run `state` again. When `push` is not null, offer it: show the commits that would go (`git log --oneline HEAD --not --remotes`) and `push.command`. `setsUpstream` → say the branch will be created on the remote. `needsRemoteChoice` → ask which of `remotes`. Run only `git push` or `git push -u <remote> <branch>`. If `behind` is above 0, say a push will likely be rejected. A rejected push: report it, suggest `git pull --rebase`, run nothing more.
|
||||
8. **Finish.** What was committed (hashes and subjects) and whether it was pushed.
|
||||
|
||||
## Session End
|
||||
|
||||
Terminal: the summary from Step 8. Web console: post `finish` (headline, a body listing the commits and the push result, no `command`, `"dashboard": true`) BEFORE `stop`, then keep waiting for the dashboard press (console.md → Finishing). A `__stop` posts a finish whose headline starts "Paused" with `"command": "/plan2code-git-commit"`.
|
||||
|
||||
Returning context: run `/plan2code-git-commit` again for the next commit.
|
||||
@@ -271,6 +271,6 @@ Agent: Updated CLAUDE.md. AGENTS.md is your single source of truth now!
|
||||
|
||||
Work summary — tell user: sections updated, entries added/changed, files modified (`AGENTS.md` or `.agents-docs/` files).
|
||||
|
||||
Suggested commit: the `command` from `commit-msg.mjs --subject "docs: update AGENTS.md with new learnings"` (exit 4 `no-ticket`: show it with `<JIRA-Ticket-ID>` for the user to fill in).
|
||||
Suggested commit: the `command` from `commit-msg.mjs --subject "docs: update AGENTS.md with new learnings"`.
|
||||
|
||||
Returning context: Run `/plan2code-init-update` again to make additional updates.
|
||||
@@ -178,7 +178,7 @@ Read references/session-end.md
|
||||
|
||||
> Fallback: route plan2code artifacts (plan/spec docs/phases) on the reviewed feature's own `specs/<feature>/` state to the earliest unmet pipeline stage whose input exists — `PLAN-*` or `overview.md` without `phase-*.md` → `/plan2code-2-document`; unchecked `- [ ]` phase tasks → `/plan2code-3-implement`; all checked → `/plan2code-4-finalize`; archived → complete, summary only. Read the state with `specs.mjs status <spec>` (gitignored `specs/` defeats search tools). Non-pipeline artifacts (code/PRs/docs/logs) → summary only. Unresolved Criticals → fixing them (H/A/S) is the next step. Ambiguous or multiple candidate specs → ask one targeted question. Output: "Next (NEW conversation): `/plan2code-<step>` — [why + how you know]", appending ` --web` when the routed step offers the web console; else "Review complete -- [summary]."
|
||||
|
||||
- **Commit** (code changes): the `command` from `commit-msg.mjs --subject "fix: [desc]" --files <file>` repeated once per fixed file (ticket from the branch; exit 4 `no-ticket`: show it with `<JIRA>` for the user to fill in). On Windows PowerShell 5.1 (no `&&`), give `add` and `commit` as two commands.
|
||||
- **Commit** (code changes): the `command` from `commit-msg.mjs --subject "fix: [desc]" --files <file>` repeated once per fixed file. On Windows PowerShell 5.1 (no `&&`), give `add` and `commit` as two commands.
|
||||
|
||||
```
|
||||
⋅
|
||||
|
||||
+3
-1
@@ -19,7 +19,7 @@ If `open` fails outright, fall back without drama: list the skills in the termin
|
||||
|
||||
## The menu
|
||||
|
||||
The page draws the cards itself — you never send the list. It also knows the repo already: `open` scans `AGENTS.md` and `specs/` into `state.scan` (`{ hasAgents, specs: [{ dir, name, state, detail, touched }] }`), and the picker at the top enables or greys every card from it — the spec the person picks there is the target their launch carries. What you post is your judgment on top of that:
|
||||
The page draws the cards itself — you never send the list. It also knows the repo already: `open` scans `AGENTS.md` and `specs/` into `state.scan` (`{ hasAgents, isGit, specs: [{ dir, name, state, detail, touched }] }`), and the picker at the top enables or greys every card from it — the spec the person picks there is the target their launch carries. What you post is your judgment on top of that:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
@@ -58,6 +58,7 @@ Ground truth for menu notes and Ask-tab answers. For anything beyond this table,
|
||||
| review | spec, diff | the fixes picked; no spec writes |
|
||||
| 4-finalize | spec + code | summary in `overview.md`; moves the spec to `specs--completed/` |
|
||||
| handoff | conversation, spec, git | `<timestamp>-handoff.md` (OS temp or `handoffs/`) |
|
||||
| git-commit | git status, diffs, `AGENTS.md` | commits; optional branch, `.gitignore`, push; no spec writes |
|
||||
|
||||
## A pick arrives
|
||||
|
||||
@@ -99,6 +100,7 @@ If `skill` is not in the table below, say so on the page and stay the dashboard.
|
||||
| plan2code-1-plan | plan | | plan2code-review | review |
|
||||
| plan2code-1b-revise-plan | revise-plan | | plan2code-4-finalize | finalize |
|
||||
| plan2code-quick-task | quick-task | | plan2code-handoff | handoff |
|
||||
| plan2code-git-commit | git-commit | | | |
|
||||
|
||||
## Coming back from another skill
|
||||
|
||||
|
||||
@@ -1,73 +1,37 @@
|
||||
#!/usr/bin/env node
|
||||
// commit-msg.mjs: the team's commit message, built from the branch name.
|
||||
// commit-msg.mjs: the commit command every Plan2Code skill suggests.
|
||||
//
|
||||
// Every Plan2Code skill that suggests a commit uses one format:
|
||||
// Every skill that suggests a commit uses one format:
|
||||
//
|
||||
// <subject>
|
||||
//
|
||||
// <JIRA-Ticket-ID>
|
||||
// AI Assisted
|
||||
//
|
||||
// and derives the ticket from a branch named <prefix>/<TICKET-ID>-description,
|
||||
// where the ticket is an uppercase project key, a hyphen and an integer
|
||||
// (ABC-10968). This script reads the branch, extracts the ticket and prints
|
||||
// the exact command, so no prompt re-implements the rule by eye.
|
||||
// This script checks the subject and prints the exact command, so no prompt
|
||||
// re-implements the rule by eye. It reads no git state and needs no repository.
|
||||
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { EXIT, fail, out, parseArgs, run } from "./common.mjs";
|
||||
|
||||
const USAGE = `
|
||||
commit-msg.mjs: build the team's commit command from the current branch. JSON on stdout.
|
||||
commit-msg.mjs: build the commit command from a subject. JSON on stdout.
|
||||
|
||||
node commit-msg.mjs --subject "<subject>" [--add-all | --files <path> ...] [--ticket <ID>]
|
||||
node commit-msg.mjs --subject "<subject>" [--add-all | --files <path> ...]
|
||||
|
||||
--subject the one-line description (at most 100 characters). No double
|
||||
quotes (straight or curly), backticks, $, backslashes or ! in it,
|
||||
so the command pastes unchanged into bash, zsh and PowerShell.
|
||||
--add-all prefix the command with "git add -A &&".
|
||||
--files prefix it with "git add -- <files> &&" (repeat --files per path).
|
||||
--ticket use this ticket ID instead of reading the branch.
|
||||
|
||||
Prints { ok, branch, ticket, subject, message, command, add, commit }. The
|
||||
commit is three -m flags, exactly: subject, ticket, "AI Assisted". command is
|
||||
add && commit, one line for bash, zsh and PowerShell 7+. Windows PowerShell 5.1
|
||||
has no &&: run add (null when nothing is staged) and then commit as two
|
||||
commands. Nothing is run.
|
||||
Prints { ok, subject, message, command, add, commit }. The commit is two -m
|
||||
flags, exactly: subject, "AI Assisted". command is add && commit, one line for
|
||||
bash, zsh and PowerShell 7+. Windows PowerShell 5.1 has no &&: run add (null
|
||||
when nothing is staged) and then commit as two commands. Nothing is run.
|
||||
|
||||
Exit: 0 ok · 2 bad arguments (including a stray argument: one --files per
|
||||
path) · 3 not a git repository / no branch (detached HEAD) · 4 the branch
|
||||
carries no ticket ID, --ticket is not KEY-123, the subject breaks a rule, or a
|
||||
path cannot be quoted safely.
|
||||
Exit: 0 ok · 2 bad arguments (a stray argument, or an unknown flag such as
|
||||
--ticket) · 4 the subject breaks a rule, or a path cannot be quoted safely.
|
||||
`;
|
||||
|
||||
// The ticket is the first <KEY>-<number> path segment start after a "/" (or the
|
||||
// branch start), ended by "-", "_", "/" or the end of the name.
|
||||
const TICKET_RE = /(?:^|\/)([A-Z][A-Z0-9]*-\d+)(?=[-_/]|$)/;
|
||||
|
||||
function ticketFromBranch(branch) {
|
||||
const m = String(branch || "").match(TICKET_RE);
|
||||
return m ? m[1] : null;
|
||||
}
|
||||
|
||||
function git(args) {
|
||||
try {
|
||||
return { ok: true, out: execFileSync("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim() };
|
||||
} catch {
|
||||
return { ok: false };
|
||||
}
|
||||
}
|
||||
|
||||
function currentBranch() {
|
||||
if (!git(["rev-parse", "--git-dir"]).ok) {
|
||||
fail(EXIT.NOT_FOUND, "not-a-repo", "This directory is not inside a git repository.", "Run from the project root, or skip the commit suggestion.");
|
||||
}
|
||||
// symbolic-ref names the branch even before the first commit, where
|
||||
// rev-parse --abbrev-ref HEAD fails; it fails only on a detached HEAD.
|
||||
const ref = git(["symbolic-ref", "--short", "-q", "HEAD"]);
|
||||
if (!ref.ok || !ref.out) fail(EXIT.NOT_FOUND, "detached-head", "HEAD is detached, so there is no branch name to read a ticket from.", "Ask the user for the ticket ID and pass --ticket <ID>.");
|
||||
return ref.out;
|
||||
}
|
||||
|
||||
// A path goes into the command as-is when it is plainly safe, in single quotes
|
||||
// otherwise (literal in bash, zsh and PowerShell alike). Backslashes become
|
||||
// forward slashes, which git accepts on every platform. A leading @ or - is
|
||||
@@ -82,7 +46,7 @@ function quoteFile(f) {
|
||||
}
|
||||
|
||||
run(USAGE, async (argv) => {
|
||||
const args = parseArgs(argv, { booleans: ["add-all"], values: ["subject", "ticket"], lists: ["files"] });
|
||||
const args = parseArgs(argv, { booleans: ["add-all"], values: ["subject"], lists: ["files"] });
|
||||
if (args._.length) fail(EXIT.USAGE, "stray-argument", `Unexpected argument(s): ${args._.join(" ")}.`, "Each path needs its own --files (e.g. --files a.js --files b.js); quote a subject with spaces.");
|
||||
const subject = (args.subject || "").trim();
|
||||
if (!subject) fail(EXIT.USAGE, "missing-subject", "--subject is required.", 'Example: --subject "Add the export endpoint"');
|
||||
@@ -94,25 +58,12 @@ run(USAGE, async (argv) => {
|
||||
if (/["`$\\!\u201C-\u201F]/.test(subject)) fail(EXIT.INVALID, "unsafe-subject", "The subject contains a double quote (straight or curly), backtick, $, backslash or !, which bash, zsh and PowerShell read differently inside double quotes.", "Rephrase without those characters (single quotes are fine).");
|
||||
if (args["add-all"] && args.files) fail(EXIT.USAGE, "add-conflict", "Use --add-all or --files, not both.", "Pick one.");
|
||||
|
||||
let branch = null;
|
||||
let ticket = args.ticket ? args.ticket.trim() : null;
|
||||
if (ticket && !/^[A-Z][A-Z0-9]*-\d+$/.test(ticket)) fail(EXIT.INVALID, "bad-ticket", `"${ticket}" is not an uppercase KEY-123 ticket ID.`, "Pass a ticket like ABC-10968.");
|
||||
if (!ticket) {
|
||||
branch = currentBranch();
|
||||
ticket = ticketFromBranch(branch);
|
||||
if (!ticket) {
|
||||
fail(EXIT.INVALID, "no-ticket", `The branch "${branch}" has no <prefix>/<TICKET-ID>-description ticket in it.`, "Ask the user for the ticket ID, then rerun with --ticket <ID>; or show the command with <JIRA-Ticket-ID> for them to fill in.");
|
||||
}
|
||||
}
|
||||
|
||||
const add = args["add-all"] ? "git add -A" : args.files ? `git add -- ${args.files.map(quoteFile).join(" ")}` : null;
|
||||
const commit = `git commit -m "${subject}" -m "${ticket}" -m "AI Assisted"`;
|
||||
const commit = `git commit -m "${subject}" -m "AI Assisted"`;
|
||||
out({
|
||||
ok: true,
|
||||
branch,
|
||||
ticket,
|
||||
subject,
|
||||
message: `${subject}\n\n${ticket}\nAI Assisted`,
|
||||
message: `${subject}\n\nAI Assisted`,
|
||||
command: add ? `${add} && ${commit}` : commit,
|
||||
add,
|
||||
commit,
|
||||
|
||||
@@ -96,8 +96,8 @@ files under `specs/` are the only source of truth, and neither channel owns them
|
||||
```
|
||||
`--workflow` is whichever you are running: `dashboard`, `init`,
|
||||
`init-update`, `pathfinder`, `quick-task`, `plan`, `revise-plan`,
|
||||
`document`, `implement`, `implement-review`, `review`, `finalize` or
|
||||
`handoff`. Get it
|
||||
`document`, `implement`, `implement-review`, `review`, `finalize`,
|
||||
`handoff` or `git-commit`. Get it
|
||||
right: the page decides from it whether to offer a brief, what stopping
|
||||
early costs, and which command resumes the session if you cannot say.
|
||||
`dashboard` is the special one: the page draws the skill menu itself, and
|
||||
@@ -776,7 +776,7 @@ where its real work starts.
|
||||
|
||||
The menu itself is the page's own list — you never send it. The page knows
|
||||
the repo too: `open` scans `AGENTS.md` and `specs/` into `state.scan`
|
||||
(`{ hasAgents, specs: [{ dir, name, state, detail, touched }] }`), and the
|
||||
(`{ hasAgents, isGit, specs: [{ dir, name, state, detail, touched }] }`), and the
|
||||
picker at the top of the menu greys the cards that do not fit the selected
|
||||
spec's pipeline stage — or hides them outright while the **Hide unavailable
|
||||
workflows** switch under the picker is on (the default; kept in `looks.json`
|
||||
@@ -873,6 +873,25 @@ that is what the person is there to download. The finish carries no
|
||||
`command`: the doc download is the point, and the dashboard button and the
|
||||
"All done" line cover what comes next.
|
||||
|
||||
### Git commit (`git-commit`)
|
||||
|
||||
Open with `--workflow git-commit` (launched from the dashboard: resume the
|
||||
session instead). Post `activity` while you read diffs and untracked files. One
|
||||
card per step, each asked only when the step needs it:
|
||||
|
||||
| Step | On the page |
|
||||
| --- | --- |
|
||||
| Branch offer | A `choice`, "Which branch?": the suggested `<type>/<name>` (recommended), "Another name" (`allowOther` with a `pattern` for a branch name's shape; run what they type through `branch-check`) and "Stay on the current branch". |
|
||||
| One commit | A `text` card whose `placeholder` is the drafted subject and whose `pattern` caps it at 100 characters, then a `confirm` "Commit this?" with the files in `consequences`. With the subject given as the argument there is no card. |
|
||||
| A split | The groups as a doc (`id: "commits"`: each group's subject and files, and any file that mixes concerns) plus a `review` card with verdicts `approve`, `change` and `single` ("One commit instead"). Asked even when the subject came as the argument. |
|
||||
| Push | A `confirm` with `push.command` and the commit list in `consequences`. |
|
||||
| `git init` | A `confirm` naming the folder (`danger: false`). |
|
||||
| `.gitignore` | The proposed file as a doc plus a `review` card. |
|
||||
|
||||
Risky files (`sensitive`, `large`) are named in the card's `body`. Finish: no
|
||||
`command`, `"dashboard": true`, the commits and the push result in `body`.
|
||||
A stop's finish is the bare `/plan2code-git-commit`.
|
||||
|
||||
### Pathfinder
|
||||
|
||||
- Every probe, recap and menu goes through the page.
|
||||
@@ -994,7 +1013,7 @@ The page's top bar shows a meter of how much work this console session has
|
||||
done (green, yellow, red), so the person knows when a fresh session would be
|
||||
sharper. It is advice only and never blocks anything. The console counts
|
||||
launches itself: Plan, Revise plan, Document, Review, Quick task, Init, Init
|
||||
update and Finalize score when their session opens, and there is nothing to
|
||||
update, Finalize and Git commit score when their session opens, and there is nothing to
|
||||
post for them.
|
||||
|
||||
It counts answers itself too: every card the person answers in a send adds to
|
||||
@@ -1011,7 +1030,8 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
- `event` is one of `pathfinder-chart`, `pathfinder-question` (scores
|
||||
nothing now: answers count instead), `pathfinder-research`, `plan`,
|
||||
`revise-plan`, `document`, `implement-phase`, `implement-review-phase`,
|
||||
`review`, `quick-task`, `init`, `init-update`, `finalize`, `handoff`.
|
||||
`review`, `quick-task`, `init`, `init-update`, `finalize`, `handoff`,
|
||||
`git-commit` (counted when its session opens, so never post it).
|
||||
An unknown event is exit `3`.
|
||||
- `id` names the unit: a question's file slug, `phase-N`, `map`. The same id
|
||||
posted again in the same skill run is ignored, so a repeated post never
|
||||
|
||||
@@ -1108,7 +1108,7 @@ port, and the filesystem as transport; this CLI is the whole agent surface.
|
||||
|
||||
workflows: dashboard · init · init-update · pathfinder · quick-task · plan ·
|
||||
revise-plan · document · implement · implement-review · review ·
|
||||
finalize · handoff
|
||||
finalize · handoff · git-commit
|
||||
|
||||
A session handed to you by the dashboard (a --session id): resume it with
|
||||
"open --resume <sid> --no-open --workflow <yours> --title <t>" -- never a
|
||||
|
||||
@@ -344,6 +344,20 @@ function gitDirAt(dir) {
|
||||
return fs.existsSync(path.join(git, "HEAD")) ? git : null;
|
||||
}
|
||||
|
||||
// Whether `dir` is inside a git repository, found without a git process: the
|
||||
// same walk findRoots() does. A set GIT_DIR / GIT_WORK_TREE / GIT_COMMON_DIR
|
||||
// means git decides, so it counts as a repository. A `gitdir:` file (a linked
|
||||
// worktree or a submodule) counts like a `.git` folder.
|
||||
export function insideGitRepo(dir) {
|
||||
if (process.env.GIT_DIR || process.env.GIT_WORK_TREE || process.env.GIT_COMMON_DIR) return true;
|
||||
for (let d = path.resolve(dir); ; ) {
|
||||
if (gitDirAt(d)) return true;
|
||||
const up = path.dirname(d);
|
||||
if (up === d) return false;
|
||||
d = up;
|
||||
}
|
||||
}
|
||||
|
||||
export function projectRoot(cwd = process.cwd()) {
|
||||
return repoRoots(cwd).project;
|
||||
}
|
||||
@@ -857,6 +871,7 @@ function isDir(p) {
|
||||
* Scan <root>/specs into picker entries, most recently touched first.
|
||||
* `touched` is the newest file mtime inside the folder — last write wins,
|
||||
* which is the honest reading of "the one you were working on".
|
||||
* `isGit` says whether `root` sits inside a git repository (no git process).
|
||||
*/
|
||||
export function scanProject(root) {
|
||||
const specsDir = path.join(root, "specs");
|
||||
@@ -888,6 +903,7 @@ export function scanProject(root) {
|
||||
return {
|
||||
at: nowIso(),
|
||||
hasAgents: fs.existsSync(path.join(root, "AGENTS.md")),
|
||||
isGit: insideGitRepo(root),
|
||||
specs,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -247,6 +247,7 @@ export const WORKFLOW_LABEL = {
|
||||
"quick-task": "Quick task",
|
||||
finalize: "Wrapping up",
|
||||
handoff: "Handoff",
|
||||
"git-commit": "Git commit",
|
||||
};
|
||||
|
||||
export function workflowLabel(workflow) {
|
||||
@@ -271,6 +272,7 @@ export const CONSOLE_WORKFLOWS = [
|
||||
"/plan2code-review",
|
||||
"/plan2code-4-finalize",
|
||||
"/plan2code-handoff",
|
||||
"/plan2code-git-commit",
|
||||
];
|
||||
|
||||
// Rides on the end of the command as part of the skill's argument. Every
|
||||
@@ -434,6 +436,8 @@ export function resumeCommand({ workflow, specDir } = {}) {
|
||||
return withOverview("/plan2code-4-finalize");
|
||||
case "handoff":
|
||||
return "/plan2code-handoff";
|
||||
case "git-commit":
|
||||
return "/plan2code-git-commit";
|
||||
default:
|
||||
return dir ? `/plan2code-0-pathfinder ${dir}/pathfinder` : "/plan2code-0-pathfinder";
|
||||
}
|
||||
@@ -638,6 +642,17 @@ export const SKILL_CATALOG = [
|
||||
about:
|
||||
"Writes down everything a new session would need, as a single document: what was decided, what is done, what is left. Use it when a conversation got long, a machine changed, or tomorrow-you deserves the context today-you has.",
|
||||
},
|
||||
{
|
||||
skill: "plan2code-git-commit",
|
||||
command: "/plan2code-git-commit",
|
||||
workflow: "git-commit",
|
||||
group: "extra",
|
||||
chip: "Utility",
|
||||
title: "Git commit",
|
||||
blurb: "Commits your changes with a clear message, suggests a split when it is really two jobs, and offers to push.",
|
||||
about:
|
||||
"Reads what changed and drafts the commit message for you to approve. On the main branch it offers a new one first, and when the work is really two jobs it suggests splitting it into separate commits. It asks before every commit and every push, and never force-pushes.",
|
||||
},
|
||||
];
|
||||
|
||||
// A workflow by the name its dashboard card gives it ("Implement"), for the
|
||||
@@ -660,6 +675,7 @@ export const START_POSES = [
|
||||
"quick-task",
|
||||
"review",
|
||||
"handoff",
|
||||
"git-commit",
|
||||
];
|
||||
|
||||
const POSE_ALIASES = { "init-update": "init", "revise-plan": "plan", "implement-review": "implement" };
|
||||
@@ -699,19 +715,21 @@ const NEXT_FOR_STATE = {
|
||||
};
|
||||
|
||||
const ON = { on: true };
|
||||
export const GIT_INIT_NOTE = "Not a git repository yet: it offers to start one";
|
||||
const off = (reason) => ({ on: false, reason });
|
||||
|
||||
/**
|
||||
* Whether a catalog card is clickable for the current picker selection.
|
||||
*
|
||||
* `scan` is the server's project scan ({ hasAgents, specs }); `sel` is the
|
||||
* `scan` is the server's project scan ({ hasAgents, isGit, specs }); `sel` is the
|
||||
* picked spec object or null for "start from scratch". A spec whose files
|
||||
* match no pipeline shape ("unrecognized") behaves like no spec at all for
|
||||
* availability — but its folder still goes along on a Pathfinder or Plan
|
||||
* launch, since the files may be reference docs.
|
||||
*
|
||||
* Returns { on, reason?, next? } — `reason` is the one line a greyed card
|
||||
* shows, `next` marks the state's natural step.
|
||||
* Returns { on, reason?, note?, next? } — `reason` is the one line a greyed card
|
||||
* shows, `note` the one line a clickable card shows when there is something to
|
||||
* know before launching it, `next` marks the state's natural step.
|
||||
*/
|
||||
export function cardAvailability(entry, scan, sel) {
|
||||
const hasAgents = Boolean(scan && scan.hasAgents);
|
||||
@@ -727,6 +745,8 @@ export function cardAvailability(entry, scan, sel) {
|
||||
case "plan2code-review":
|
||||
case "plan2code-handoff":
|
||||
return ON;
|
||||
case "plan2code-git-commit":
|
||||
return scan && scan.isGit === false ? { on: true, note: GIT_INIT_NOTE } : ON;
|
||||
case "plan2code-0-pathfinder":
|
||||
if (!state || state === "exploring") return { ...ON, next };
|
||||
return off("This spec is already past the questions");
|
||||
@@ -763,7 +783,14 @@ export function cardPresentation(entry, scan, sel, menu = {}) {
|
||||
const recommendation = requested && cardAvailability(requested, scan, sel).on ? requested.skill : null;
|
||||
const recommended = availability.on && (recommendation ? entry.skill === recommendation : availability.next);
|
||||
const supplied = initial && menu.details && typeof menu.details[entry.skill] === "string" ? menu.details[entry.skill] : "";
|
||||
const detail = availability.on && supplied ? supplied : !initial && availability.next && sel && sel.detail ? sel.detail : "";
|
||||
const detail =
|
||||
availability.on && supplied
|
||||
? supplied
|
||||
: availability.on && availability.note
|
||||
? availability.note
|
||||
: !initial && availability.next && sel && sel.detail
|
||||
? sel.detail
|
||||
: "";
|
||||
return { ...availability, recommended, detail };
|
||||
}
|
||||
|
||||
|
||||
@@ -3419,6 +3419,20 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
|
||||
100% { transform: translateX(8px); opacity: 0; }
|
||||
}
|
||||
|
||||
/* Git commit -- the arm reaches out and a new commit settles onto the branch
|
||||
line in step with it. */
|
||||
.pose .gc-reach { transform-origin: 0% 50%; animation: gc-reach 2.4s ease-in-out infinite; }
|
||||
@keyframes gc-reach {
|
||||
0%, 100% { transform: scaleX(0.9); }
|
||||
50% { transform: scaleX(1); }
|
||||
}
|
||||
.pose .gc-dot { animation: gc-dot 2.4s ease-in-out infinite; }
|
||||
@keyframes gc-dot {
|
||||
0%, 15% { opacity: 0; transform: translateY(-8px); }
|
||||
50%, 85% { opacity: 1; transform: translateY(0); }
|
||||
100% { opacity: 0; transform: translateY(0); }
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.dash { padding-top: 0; }
|
||||
.launch-stage { height: 140px; }
|
||||
|
||||
@@ -4712,15 +4712,22 @@ function buildList(card, item, staged) {
|
||||
}
|
||||
card.appendChild(row);
|
||||
card.appendChild(el("p", "help", "Drag to reorder, click a name to rename it."));
|
||||
commentField(card, item, "Anything else about this breakdown? (type 'no changes' if none)");
|
||||
commentField(card, item, "Anything else about this breakdown?", false, "no changes");
|
||||
}
|
||||
|
||||
function commentField(card, item, labelText, required) {
|
||||
function commentField(card, item, labelText, required, quickText) {
|
||||
const wrap = el("div", "field");
|
||||
const id = "note-" + item.id;
|
||||
const label = el("label", null, labelText);
|
||||
label.htmlFor = id;
|
||||
wrap.appendChild(label);
|
||||
let quick = null;
|
||||
if (quickText) {
|
||||
quick = el("button", "btn tiny", quickText.charAt(0).toUpperCase() + quickText.slice(1));
|
||||
quick.type = "button";
|
||||
quick.title = "Fill in \"" + quickText + "\"";
|
||||
wrap.appendChild(quick);
|
||||
}
|
||||
const ta = el("textarea");
|
||||
ta.id = id;
|
||||
ta.placeholder = required ? "Tell Plan2Code what to change." : "Optional.";
|
||||
@@ -4741,6 +4748,12 @@ function commentField(card, item, labelText, required) {
|
||||
stagedChanged();
|
||||
});
|
||||
wrap.appendChild(ta);
|
||||
if (quick)
|
||||
quick.addEventListener("click", () => {
|
||||
ta.value = quickText;
|
||||
ta.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
ta.focus();
|
||||
});
|
||||
card.appendChild(wrap);
|
||||
}
|
||||
|
||||
|
||||
@@ -538,6 +538,32 @@
|
||||
</g>
|
||||
<g class="ho-arrow"><path class="as" d="M178 64 L214 64 M204 54 L216 64 L204 74" /></g>
|
||||
</svg>
|
||||
|
||||
<!-- Git commit: saving a step. Beside a branch line with two commits on
|
||||
it, one arm reaches to set a third commit onto the line. -->
|
||||
<svg class="pose pose-git-commit" data-pose="git-commit" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
|
||||
<ellipse class="shadow" cx="126" cy="198" rx="44" ry="5" />
|
||||
<g class="prop">
|
||||
<line class="lt gc-line" x1="204" y1="62" x2="204" y2="172" />
|
||||
<circle class="ac" cx="204" cy="82" r="7" />
|
||||
<circle class="ac" cx="204" cy="112" r="7" />
|
||||
<circle class="ac gc-dot" cx="204" cy="142" r="7" />
|
||||
</g>
|
||||
<g class="bob">
|
||||
<g transform="translate(-14 0)">
|
||||
<rect class="fl foot f1" x="94" y="179" width="20" height="10" rx="5" />
|
||||
<rect class="fl foot f2" x="126" y="179" width="20" height="10" rx="5" />
|
||||
<rect class="sh" x="80" y="72" width="80" height="108" rx="16" />
|
||||
<path class="ln" d="M80 126 L66 150" /><circle class="fl" cx="66" cy="150" r="5.5" />
|
||||
<path class="ey blink" d="M126 86 L129.64 94.98 L139.31 95.67 L131.9 101.92 L134.23 111.33 L126 106.2 L117.77 111.33 L120.1 101.92 L112.69 95.67 L122.36 94.98 Z" />
|
||||
<path class="es" d="M110 120 Q122 129 134 120" />
|
||||
<g class="gc-reach">
|
||||
<line class="ln" x1="160" y1="126" x2="212" y2="142" />
|
||||
<circle class="fl" cx="212" cy="142" r="5.5" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<!-- The Help dialog's content, cloned into #help-modal the first time ? is
|
||||
@@ -1341,6 +1367,7 @@
|
||||
<li><strong>Quick task.</strong> Too small for the full process? A quick plan, then it just builds it.</li>
|
||||
<li><strong>Review.</strong> A second opinion on the changes. Problems ranked, and you pick what gets fixed.</li>
|
||||
<li><strong>Handoff.</strong> Pack this conversation into a document a fresh session can pick up cold.</li>
|
||||
<li><strong>Git commit.</strong> Commits your changes with a clear message, suggests a split when it is really two jobs, and offers to push.</li>
|
||||
</ul>
|
||||
<h4>Picking a spec</h4>
|
||||
<p>
|
||||
|
||||
@@ -25,13 +25,14 @@ export const WEIGHTS = Object.freeze({
|
||||
"init-update": 2,
|
||||
finalize: 1,
|
||||
handoff: 0,
|
||||
"git-commit": 1,
|
||||
});
|
||||
|
||||
// Workflows whose launch itself scores WEIGHTS[workflow]. Pathfinder,
|
||||
// implement and implement-review score only through the agent's `run`
|
||||
// reports; dashboard and handoff never score.
|
||||
// reports; dashboard and handoff never score; git-commit scores 1 on launch.
|
||||
export const LAUNCH_COUNTED = Object.freeze(
|
||||
new Set(["plan", "revise-plan", "document", "review", "quick-task", "init", "init-update", "finalize"])
|
||||
new Set(["plan", "revise-plan", "document", "review", "quick-task", "init", "init-update", "finalize", "git-commit"])
|
||||
);
|
||||
|
||||
const weightOf = (key) => (Object.prototype.hasOwnProperty.call(WEIGHTS, key) ? WEIGHTS[key] : 0);
|
||||
@@ -126,6 +127,7 @@ const WORKFLOW_NAMES = Object.freeze({
|
||||
"init-update": "Init update",
|
||||
finalize: "Finalize",
|
||||
handoff: "Handoff",
|
||||
"git-commit": "Git commit",
|
||||
});
|
||||
|
||||
// The skill run an entry belongs to, from its ledger id ("L3:..." -> "L3").
|
||||
@@ -141,6 +143,7 @@ const LAUNCH_LABELS = Object.freeze({
|
||||
init: "Init started",
|
||||
"init-update": "Init update started",
|
||||
finalize: "Finalize started",
|
||||
"git-commit": "Git commit started",
|
||||
});
|
||||
const RUN_LABELS = Object.freeze({
|
||||
"pathfinder-chart": "Pathfinder map written",
|
||||
@@ -157,6 +160,7 @@ const RUN_LABELS = Object.freeze({
|
||||
"init-update": "Init update run",
|
||||
finalize: "Finalize run",
|
||||
handoff: "Handoff written",
|
||||
"git-commit": "Git commit run",
|
||||
});
|
||||
|
||||
// The unit a run names, from its ledger id ("L3:phase-2" -> "phase-2").
|
||||
|
||||
@@ -185,7 +185,7 @@ export function checkHelpers(list) {
|
||||
// are tested without a browser. `frame` is the state frame's `subagents`
|
||||
// block; app.js only renders what these say.
|
||||
|
||||
export const CHECKIN_LINE = "Helpers report through Plan2Code, so their progress shows here at its check-ins, not live.";
|
||||
export const CHECKIN_LINE = "Helpers report through Plan2Code, so their progress is shown as it checks-in, not live.";
|
||||
|
||||
const STATE_LABELS = Object.freeze({ running: "Running", done: "Done", failed: "Failed" });
|
||||
|
||||
|
||||
Reference in new issue
Block a user