mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04: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
@@ -5,7 +5,7 @@
|
||||
|
||||
```
|
||||
plan2code/
|
||||
├── src/ # Source workflow prompts (13 markdown files)
|
||||
├── src/ # Source workflow prompts (14 markdown files)
|
||||
│ ├── plan2code-0-pathfinder-references/ # Reference files for pathfinder skill
|
||||
│ │ ├── brief.md # Dated plain-English decision briefs
|
||||
│ │ ├── chart.md # MODE A: destination + frontier grills, templates
|
||||
@@ -53,7 +53,7 @@ plan2code/
|
||||
│ ├── test-web-console.mjs, test-launcher.mjs # node --test suites
|
||||
│ ├── test-skill-scripts.mjs, test-script-<skill>.mjs, skill-script-helpers.mjs # Skill script suites and fixtures
|
||||
│ └── validate-char-count.js # Pre-commit character count validator
|
||||
├── skills/ # Committed build artifact — one Agent Skill per src/ prompt
|
||||
├── skills/ # Generated, gitignored build output — one Agent Skill per src/ prompt
|
||||
│ └── plan2code-<name>/ # SKILL.md plus references/ and scripts/ where present
|
||||
│ # Generated by npm run build:skills; consumed by skills add
|
||||
├── .husky/ # Git hooks (husky)
|
||||
@@ -80,7 +80,7 @@ plan2code/
|
||||
|------|---------|
|
||||
| `install.js` | Interactive installer — builds `skills/` from `src/`, then delegates installation to the skills CLI |
|
||||
| `src/plan2code-*.md` | Source workflow prompts (the "source of truth") |
|
||||
| `skills/` | Generated Agent Skills committed for installation and drift verification |
|
||||
| `skills/` | Generated Agent Skills, gitignored build output regenerated by the installer (and `npm run build:skills`) before every `skills add` |
|
||||
| `scripts/validate-char-count.js` | Pre-commit validator ensuring all source prompts ≤ 20,000 chars |
|
||||
| `version.json` | Version metadata (name, version, description) |
|
||||
| `QUICK-REFERENCE.md` | User quick-reference card |
|
||||
@@ -104,6 +104,7 @@ plan2code/
|
||||
| `plan2code-review.md` | review | Post-implementation comprehensive review |
|
||||
| `plan2code-4-finalize.md` | 4 | Validate, summarize, feedback, archive (steps 1–7, +optional 6.5) |
|
||||
| `plan2code-handoff.md` | handoff | Compact the conversation into a self-contained handoff document for a fresh session |
|
||||
| `plan2code-git-commit.md` | git-commit | Commit with a clear message, suggested splits, a branch offer on the default branch, and an optional push |
|
||||
|
||||
## Naming Convention
|
||||
|
||||
@@ -141,13 +142,14 @@ Anything a workflow step decides with one correct answer (parsing a spec's check
|
||||
| Script | Skills | Does |
|
||||
|---|---|---|
|
||||
| `specs.mjs` | plan, revise-plan, document, implement, implement-review, review, quick-task, finalize, handoff | `list` / `status` (Phase Checklist, groups, task markers, numbering, the implement selection verdict, consistency checks) / `metrics` / `mark` / `archive`. Imports `scanProject()` from the bundled `web-console/lib.mjs`, so the dashboard and the skills share one spec classifier |
|
||||
| `commit-msg.mjs` | implement(-review), review, quick-task, finalize, init-update | The `<subject>` / ticket / `AI Assisted` command from the branch name |
|
||||
| `commit-msg.mjs` | implement(-review), review, quick-task, finalize, init-update | The `<subject>` / `AI Assisted` commit command (two `-m` flags), with optional `git add` |
|
||||
| `review-scope.mjs` | review, implement(-review), quick-task | Review Mode's git fallback: files, lines, doc share, base branch |
|
||||
| `agents-md.mjs` | init, init-update | AGENTS.md structure, budget, orphans, broken links, always-inline sections |
|
||||
| `agent-files.mjs` | init, init-update | Detect and replace other agents' config files with AGENTS.md pointers |
|
||||
| `pathfinder.mjs` (own) | 0-pathfinder | `reconcile`, `frontier`, `claim`, `resolve`, `rule-out`, `trail`, `gate`, `lint`, `brief-data` |
|
||||
| `feedback-payload.mjs` (own) | 4-finalize | STEP 6.5's payload (real sha256 prompt hashes) and the gh / browser / print submission tiers |
|
||||
| `handoff-path.mjs` (own) | handoff | Timestamped path, OS temp dir, git ignore check |
|
||||
| `git-state.mjs` (own) | git-commit | `state`, `branch-check`, `init-check`: the repo snapshot, branch-name check and git init safety check, read-only |
|
||||
|
||||
**Conventions** (`common.mjs`): Node 18+ built-ins only; one JSON object on stdout (`ok: false` plus `error`, `message`, `next` on a handled failure, the same line on stderr); exit 0 ok, 1 crash, 2 bad arguments, 3 not found, 4 invalid or check failed, 5 refused; `--help` documents commands and exit codes; writes take `--dry-run`; `PLAN2CODE_NOW` pins the clock for tests. A SKILL.md names a script as `node "<S>/<name>.mjs"`, where `<S>` is `scripts/` beside it.
|
||||
|
||||
@@ -204,6 +206,7 @@ Key design points:
|
||||
- **Month-old sessions are deleted whole.** `open` lists `staleSessions()` (directories matching the session-id pattern whose `state.json` mtime is older than 30 days, never the sid being opened — no exceptions for paused sessions or unread sends) and `staleScratch()` (top-level regular `.json` / `.mjs` files in the console folder older than 30 days, never `looks.json` or `console-dir` — `PROTECTED_CONSOLE_FILES` — never a directory or symlink) before it prints, and removes them after; `removeSessions()` / `removeScratch()` re-check every name against the session-id pattern / the scratch-name rule before deleting — not the age, the skipped sid or the file type, which the `stale*` listing already decided, so never hand them names that did not come from it. `console.md` tells agents to write temporary payload files into the session's own folder so they go with it.
|
||||
- **User Preferences → Cleanup deletes on demand, from a list the server makes.** `POST /cleanup` (origin-checked) with `{ scan: true }` returns `cleanupFindings()`: `{ items: [{ id, where, name, kind, bytes }], bytes }`, ids `session:<sid>` (the `staleSessions()` rule, and every file in the folder that old too, never the serving sid), `console:<name>` (anything at the top of the console home but `PROTECTED_CONSOLE_FILES`, `sessions` and `runtime`, directories too) and `root:<name>` (anything at the top of `~/.plan2code` but `KEPT_PLAN2CODE_ENTRIES`: `console`, `bin`, `launcher.json`, `models.json`). Both stray kinds must be untouched for `STRAY_GRACE_MS` (an hour, by the newest `lstat` mtime anywhere inside, since rewriting a file never moves its folder's mtime; unreadable reads as fresh): the same folders hold `workspaces.json.lock` and `writeJsonAtomic()`'s `<file>.<pid>.tmp`, which live for milliseconds. `root:` is only scanned when the console home is `<PLAN2CODE_MODELS_DIR or ~/.plan2code>/console`, so a test or dev home never reaches the real folder. Paths never go to the page. `{ delete: [id] }` runs `removeCleanup()`, which re-scans and removes only ids still on the fresh list (symlinks unlinked, never followed), returning `{ removed, bytes, failed }`. The page always shows the list before **Delete these**.
|
||||
- **The console's path is stated, not searched for.** Each Interface line names `references/web-console/` beside the SKILL.md and the `~/.plan2code/console/console-dir` fallback; the prompts with room (all but pathfinder, plan, document and finalize, which sit near the char limit) also name the canonical global install path `~/.agents/skills/<skill>/references/web-console/` (the skills CLI's real store; every agent dir links into it), and every `console.mjs open` writes `HERE` to `~/.plan2code/console/console-dir` (only `open`, so a `help` or dev run from `src/` never repoints it) so a later session can read the path from a fixed place. Without these the agent hunts the skill install dirs on every session.
|
||||
- **The dashboard scan knows whether the folder is a git repository.** `scanProject()` returns `{ hasAgents, isGit, specs }`; `isGit` comes from `insideGitRepo()`, the same filesystem walk `findRoots()` does (no `git` process, linked worktrees and submodules count, a set `GIT_DIR` / `GIT_WORK_TREE` / `GIT_COMMON_DIR` counts as a repo). When it is `false` the Git commit card stays clickable and shows `GIT_INIT_NOTE` ("Not a git repository yet: it offers to start one") as its detail line; a scan with no `isGit` counts as a repo.
|
||||
- **`open` needs no payload, and runs first.** `--file` and `--title` are optional (the title defaults to the folder name). Every skill's Interface line puts `node "<D>/console.mjs" open --workflow <w>` BEFORE reading console.md or the project, and a test (`every skill opens the console before it reads anything`) keeps it that way; a blank session renders a starting screen ("Starting Pathfinder", Planny in flight) until the first post. Every skill replaces the flight with its own animated pose (init — init-update borrows it — pathfinder, plan — revise-plan borrows it — document, implement — implement-review borrows it — finalize, quick-task, review, handoff; only the dashboard keeps the flight), cloned by `startStage()` in `app.js` from `<template id="start-poses">` in `index.html` and animated under `.pose` in `app.css`; `START_POSES`/`startPose()` in `answers.js` is the list, and a test keeps the template in sync with it and every catalog workflow mapped to a pose. The same pose stands above the waiting pane (`.waiting-pane`, agent working with an `activity` and nothing to ask). `posePane()` keeps the pane on screen across renders when the pose is unchanged — `renderMain()` holds any `:scope > [data-pose]` child back from the clear — so the SVG never leaves the DOM, its animations never restart on a state frame, and Planny carries unbroken from launching → starting → waiting. The dashboard's launch hand-off resumes first and reads the launched skill's file after.
|
||||
- **The start path is timed, and `open` is built around it.** Measure with `node scripts/bench-web-console.mjs` (`--browser-delay 900` for a real Chrome launch, `--roundtrip` for Send→agent and post→page, `PLAN2CODE_CONSOLE_TRACE=1` on `open` for a step timeline). Four things make it fast, and each is load-bearing:
|
||||
- **No git process.** `repoRoots()` in `lib.mjs` finds the common dir and worktree top by walking to `.git` (following `gitdir:` and `commondir` files) — each `git rev-parse` cost 150ms+ on Windows. It asks git only when `GIT_DIR`/`GIT_WORK_TREE`/`GIT_COMMON_DIR` relocate the repo, and uses the native realpath so an 8.3 short name keys the same project git would.
|
||||
@@ -242,7 +245,7 @@ Key design points:
|
||||
- **Help is in the page, built on first open.** The **?** button (`#btn-about`) opens `<dialog id="help-modal">`, which replaced the old "What this page is" About dialog. Its 17 panels and their icon sheet are hand-written HTML and SVG in `<template id="help-content">` in `index.html` (after `#start-poses`), cloned into `#help-panels` the first time **?** is pressed, so first load builds nothing and Help still reads fully once the server is gone. `help.js` supplies the tab list and rules, `app.js` the wiring (tab buttons, roving focus, `renderAbout()` for the live connection line on tab 1, `lightDismiss()`, and a Ctrl/⌘+Enter guard scoped to this dialog). SVG is styled by class and CSS variables only — a `style=` attribute is dropped by the CSP, and a test fails on one — and every number the prose quotes sits in a `data-fact` span a test checks against the constant it comes from.
|
||||
- **Markdown is rendered to DOM nodes, never to an HTML string** (`public/render.js`), so agent-authored text that quotes a hostile source cannot execute. Only `marked.lexer()` is used.
|
||||
|
||||
Tests: `npm test` runs, in order, `validate-char-count.js`, `install.js --verify-skills`, `parse-check.mjs`, `check-skill-table.mjs`, then `node --test scripts/test-web-console.mjs scripts/test-launcher.mjs scripts/test-skill-scripts.mjs scripts/test-script-pathfinder.mjs scripts/test-script-finalize.mjs scripts/test-script-handoff.mjs`. The parse check exists because `node --check` parses a `.js` file as a CommonJS script and has already let a browser-fatal string literal through; it imports each shipped module as a real ES module instead. They live in `scripts/`, not `src/web-console/`, because everything under the latter ships into every skill.
|
||||
Tests: `npm test` runs, in order, `validate-char-count.js`, `install.js --build-skills`, `parse-check.mjs`, `check-skill-table.mjs`, then `node --test scripts/test-web-console.mjs scripts/test-launcher.mjs scripts/test-skill-scripts.mjs scripts/test-script-pathfinder.mjs scripts/test-script-finalize.mjs scripts/test-script-handoff.mjs scripts/test-script-git-commit.mjs`. The parse check exists because `node --check` parses a `.js` file as a CommonJS script and has already let a browser-fatal string literal through; it imports each shipped module as a real ES module instead. They live in `scripts/`, not `src/web-console/`, because everything under the latter ships into every skill.
|
||||
|
||||
**Adding a file under `public/` needs three edits, not one:** the file itself, the `SERVABLE` allow-list in `server.mjs`, and (for a module the page imports) a `<link rel="modulepreload">` in `index.html`. The set is hardcoded rather than a directory lookup so there is nothing to traverse; a new module missing from it 404s and the page dies at import with no useful error (a test fetches every import and fails naming the file). A module missing its preload still works, but loads serially after `app.js` and slows the first paint.
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
- **Workflow file character limit:** All `src/plan2code-*.md` files (and the dashboard prompt `src/plan2code.md`) must be ≤ 20,000 characters (about 5k tokens, the usual Agent Skills guidance for a SKILL.md body). A husky pre-commit hook enforces this, and `plan2code-metrics` (`improver.ts`, `applier.ts`) applies the same number to proposed prompt edits, so change them together. History: 11,000 originally (headroom under Windsurf's old 12,000-char limit for platform-specific files, gone since 2.1.0's single-format build), 11,500 in 2.4.0, 20,000 in 2.4.1. The limit is now a prompt-size discipline only: the whole SKILL.md loads on every invocation while references load on demand, so situational detail still belongs in a reference file, and anything with one correct answer belongs in a script (see Skill scripts in the architecture doc).
|
||||
- **Keep LF line endings:** `.gitattributes` pins `eol=lf` because `validate-char-count.js` counts the characters on disk, and a CRLF checkout adds about one per line to every prompt. Measure with `node scripts/validate-char-count.js` before trusting a near-limit prompt.
|
||||
- **The pre-commit hook runs only the char-count check:** `.husky/pre-commit` is `node scripts/validate-char-count.js` alone. `skills/` drift, parse errors and test failures are caught only by `npm test`, so run it before committing. Sub-package tests are separate; see [Development Commands](./AGENTS-development-commands.md).
|
||||
- **`skills/` is a committed build artifact:** edit `src/`, run `npm run build:skills`, and commit the regenerated skills in the same change. `npm test` runs `install.js --verify-skills` and fails on missing, unexpected, or stale files. Never edit `skills/` by hand.
|
||||
- **`skills/` is generated build output (gitignored):** edit `src/` only. The installer rebuilds `skills/` on every run, so it is always up to date at install time. `npm test` runs `install.js --build-skills` so a broken `SOURCE_PROMPTS` entry or unreadable source fails CI. Never hand-edit `skills/`; `install.js --verify-skills` can diff a stale tree against `src/` when diagnosing.
|
||||
- **Metrics internal prompts have no char limit:** Files in `plan2code-metrics/src/prompts/` are NOT subject to the 20,000 char limit — only `src/plan2code-*.md` consumer-facing prompts are.
|
||||
- **User Feedback table format:** The `## User Feedback` markdown table in `overview.md` has a strict format the collector regex depends on. Field names must be exactly `Rating`, `Reason`, `Went Well`, `Went Poorly`. Pipe characters in values must be escaped as `\|`.
|
||||
- **PLAN-DRAFT confidence numbers are scraped by regex:** `collector.ts` scrapes the latest `specs/<feature>/PLAN-DRAFT-*.md` prose. Overall confidence falls back to prose only when `<!-- METRICS_JSON ... -->` lacks `confidence` (`collector.ts:186-196`): `Confidence: 95%`, or a table row `| Confidence | 95` with no `%`. The four *breakdown* patterns (`collector.ts:200-203`) run on every draft, METRICS_JSON or not: `/[Rr]equirements?[:\s|]+(\d{1,2})/` and its siblings match a bare dimension word followed by whitespace, a colon, or a pipe and then digits. So a PLAN-DRAFT written by anything other than `/plan2code-1-plan` Phase 7 must keep `Confidence` followed by a number (with `%`, or as a table row) **and** bare `Requirements` / `Feasibility` / `Integration` / `Risk` followed by a number off the page — including innocent table rows like `| Requirements | 11 |`. Otherwise the metrics pipeline records a planning-step confidence that no planning step produced. `/plan2code-0-pathfinder` works around this by hyphenating the labels (`Requirements-clarity 22/25`), which breaks the character class.
|
||||
|
||||
@@ -14,7 +14,7 @@ node install.js
|
||||
# Regenerate skills/ from src/ (non-interactive)
|
||||
npm run build:skills
|
||||
|
||||
# Full check (about 70s): char limits, skills/ drift, browser-module parse check,
|
||||
# Full check (about 70s): char limits, skills/ build, browser-module parse check,
|
||||
# dashboard skill-table check, web console + launcher node:test suites
|
||||
npm test
|
||||
|
||||
@@ -29,7 +29,7 @@ node scripts/bench-web-console.mjs [--runs 7] [--workflow dashboard]
|
||||
# before committing: right screen, both themes, no username or home path in frame.
|
||||
npm i --no-save puppeteer-core # once; never added to package.json
|
||||
node scripts/capture-screenshots.mjs # every screen
|
||||
node scripts/capture-screenshots.mjs --only dashboard # one screen
|
||||
node scripts/capture-screenshots.mjs --only dashboard # one screen (dashboard-utilities scrolls to the utility cards)
|
||||
|
||||
# Plan2Code Loop
|
||||
cd plan2code-loop && npm install # First time setup
|
||||
@@ -89,7 +89,7 @@ The root `npm test` does not run the metrics or bot vitest suites; run them in t
|
||||
| Flag | Action |
|
||||
|------|--------|
|
||||
| `--build-skills` | Regenerate `skills/` from `src/`, pruning stale skills and reference files |
|
||||
| `--verify-skills` | Compare committed `skills/` with `src/`; exits 1 on drift and is run by `npm test` |
|
||||
| `--verify-skills` | Diff local `skills/` against `src/`; exits 1 on drift. Diagnostic only, the installer rebuilds anyway |
|
||||
|
||||
## How the Installer Works
|
||||
|
||||
@@ -128,7 +128,7 @@ See the `skills/` build-artifact gotcha in [Code Style & Gotchas](./AGENTS-code-
|
||||
1. Edit the source file under `src/`.
|
||||
2. Run `npm run build:skills`.
|
||||
3. Test the workflow in an AI tool.
|
||||
4. Commit regenerated `skills/` beside the source change; `npm test` fails on drift.
|
||||
4. `skills/` is gitignored, so only the `src/` change is committed.
|
||||
5. Never edit `skills/` by hand because the next build overwrites it.
|
||||
|
||||
## Adding a New Workflow Prompt / Skill
|
||||
|
||||
@@ -16,6 +16,11 @@ node_modules/
|
||||
package-lock.json
|
||||
SYNC.md
|
||||
|
||||
# Generated by install.js/`npm run build:skills` from src/, regenerated on
|
||||
# every install, so it never needs committing. Anchored: .claude/skills/ and
|
||||
# per-skill references must stay tracked.
|
||||
/skills/
|
||||
|
||||
# Throwaway design prototypes (ai-assist-prototype). The decision they
|
||||
# recorded lives in the code and the CHANGELOG; the files stay local.
|
||||
prototypes/
|
||||
+10
-1
@@ -50,6 +50,13 @@ it opens on the page without asking.
|
||||
<img src="../docs/screenshots/dashboard-light.webp" alt="The Plan2Code dashboard: a Set up card, then the steps in order as cards, one of them marked Suggested.">
|
||||
</picture>
|
||||
|
||||
Scroll down for the utilities. Outside a git repository the **Git commit** card says so and still offers to start one:
|
||||
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="../docs/screenshots/dashboard-utilities-dark.webp">
|
||||
<img src="../docs/screenshots/dashboard-utilities-light.webp" alt="The utility cards: Quick task, Review, Handoff and Git commit, which notes that the folder is not a git repository yet and offers to start one.">
|
||||
</picture>
|
||||
|
||||
---
|
||||
|
||||
## What you get
|
||||
@@ -186,7 +193,9 @@ The easy way in is the dashboard:
|
||||
A page opens with every skill laid out as cards — the setup pair, the pipeline
|
||||
in order, and the utilities alongside — with a note about what it made of your
|
||||
project (no AGENTS.md yet, a spec waiting on Phase 2) and a *Suggested* flag on
|
||||
the card it would pick. Click one and Planny flies while it gets ready; a few
|
||||
the card it would pick. **Git commit** is among the utilities, always available; in a
|
||||
folder that is not a git repository its card says *Not a git repository yet: it offers to
|
||||
start one*, and clicking it still works. Click one and Planny flies while it gets ready; a few
|
||||
seconds later the same page is that skill's console, already running. No
|
||||
command names to remember.
|
||||
|
||||
|
||||
@@ -93,3 +93,5 @@ When you make a mistake, get corrected, or discover something about this codebas
|
||||
- After a sync merge, run `npm test` before trusting a "clean" file: when upstream and plan2code fixed the same bug, `git merge-file` keeps both copies without a conflict (a sync once left `let pattern` declared twice in `app.js`, caught only by `parse-check`).
|
||||
- When extracting upstream files in Git Bash, run `git show <ref>:<path>` with `MSYS_NO_PATHCONV=1` and `C:/` style paths (never `/c/`): path conversion rewrites `origin/main:.readme/x.md` into `origin\main;.readme\x.md`, the show fails, and the merge silently runs against an empty "theirs". Check every extracted file is non-empty before merging.
|
||||
- After a sync, grep the result for the upstream owner slug and company name in any case (the `/sync-repo` body lists them): the rebrand map only rewrites URLs, so a bare owner slug once slipped through into `feedback-payload.mjs` (and its test) until it was fixed by hand to `jparkerweb/plan2code`. No upstream name may appear in plain text anywhere in this repo.
|
||||
- Keep plan2code's ticket-free `commit-msg.mjs` (`<subject>`, `AI Assisted`) in every `/sync-repo`: upstream's ticket-from-branch rule was ported by mistake once and removed in v2.6.0.
|
||||
- When a new first-run dialog is added to the web console, set its seen flag in `scripts/capture-screenshots.mjs`'s `looks.json` too: the Welcome dialog once covered the regenerated dashboard screenshots until `welcomeSeen: true` was added.
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
All notable changes to Plan2Code will be documented in this file.
|
||||
|
||||
## v2.6.0
|
||||
|
||||
### ✨ Added
|
||||
|
||||
- **web-console**: the breakdown question's "Anything else about this breakdown?" field has a **No changes** button. One click fills the box with "no changes", so you no longer type it. The old "(type 'no changes' if none)" hint is gone from the label.
|
||||
- **git-commit**: a new `/plan2code-git-commit` skill and dashboard card. It reads what changed, drafts the commit message for your approval, offers a new branch first on the default branch, suggests splitting work that is really two jobs, and asks before every commit and push (never a force-push). Outside a git repository it offers to start one.
|
||||
- **web-console**: the dashboard scan reports `isGit`, found from the filesystem without spawning git (linked worktrees count). The Git commit card stays clickable outside a repository and says "Not a git repository yet: it offers to start one". The skill has its own Planny pose and a Help entry.
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **commits**: every commit Plan2Code suggests is now `<subject>`, a blank line, then `AI Assisted`. `commit-msg.mjs` no longer reads a ticket from the branch name and rejects `--ticket`.
|
||||
- **build**: `skills/` is no longer tracked. It is gitignored build output, rebuilt by the installer and `npm run build:skills`, as upstream does. `npm test` now runs `install.js --build-skills` instead of `--verify-skills`, so it fails on a broken source entry rather than on drift. `--verify-skills` stays as a diagnostic.
|
||||
|
||||
## v2.5.1
|
||||
|
||||
### ✨ Added
|
||||
|
||||
+16
-15
@@ -17,21 +17,22 @@ Pick a skill on the dashboard and the same page becomes that session. Details: [
|
||||
|
||||
Every command below is what a dashboard card runs. Typed on its own, each one asks "web console or terminal?" first.
|
||||
|
||||
| Step | Command | Input | Output |
|
||||
| -------- | ------------------------------- | --------------- | --------------------------------------------------------------------------------------- |
|
||||
| — | /plan2code | None | Web console dashboard — a menu of every skill below, launched on the page |
|
||||
| Init | /plan2code-init | None | AGENTS.md file |
|
||||
| Update | /plan2code-init-update | AGENTS.md | Updated AGENTS.md |
|
||||
| 0 | /plan2code-0-pathfinder | A foggy idea | pathfinder/map.md *or* GitHub Issues + PLAN-DRAFT-<date>.md |
|
||||
| quick | /plan2code-quick-task | Requirements | A short plan, then the change built (standalone, not a pipeline step) |
|
||||
| review | /plan2code-review | Scope guidance | Review findings + fixes |
|
||||
| 1 | /plan2code-1-plan | Requirements | PLAN-CONVERSATION-<date>.md + PLAN-DRAFT-<date>.md |
|
||||
| 1b | /plan2code-1b-revise-plan | Specs + changes | Updated specs |
|
||||
| 2 | /plan2code-2-document | PLAN-DRAFT.md | overview.md + Phase files |
|
||||
| 3 | /plan2code-3-implement | overview.md | Implemented code |
|
||||
| 3+review | /plan2code-3-implement-review | overview.md | Reviewed implementation ready for approval (alternative to `/plan2code-3-implement`) |
|
||||
| 4 | /plan2code-4-finalize | overview.md | Archived specs |
|
||||
| handoff | /plan2code-handoff | Conversation | Self-contained handoff doc (OS temp dir by default, or a folder you pick such as `handoffs/`) |
|
||||
| Step | Command | Input | Output |
|
||||
| ---------- | ----------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------- |
|
||||
| — | /plan2code | None | Web console dashboard — a menu of every skill below, launched on the page |
|
||||
| Init | /plan2code-init | None | AGENTS.md file |
|
||||
| Update | /plan2code-init-update | AGENTS.md | Updated AGENTS.md |
|
||||
| 0 | /plan2code-0-pathfinder | A foggy idea | pathfinder/map.md *or* GitHub Issues + PLAN-DRAFT-<date>.md |
|
||||
| quick | /plan2code-quick-task | Requirements | A short plan, then the change built (standalone, not a pipeline step) |
|
||||
| review | /plan2code-review | Scope guidance | Review findings + fixes |
|
||||
| 1 | /plan2code-1-plan | Requirements | PLAN-CONVERSATION-<date>.md + PLAN-DRAFT-<date>.md |
|
||||
| 1b | /plan2code-1b-revise-plan | Specs + changes | Updated specs |
|
||||
| 2 | /plan2code-2-document | PLAN-DRAFT.md | overview.md + Phase files |
|
||||
| 3 | /plan2code-3-implement | overview.md | Implemented code |
|
||||
| 3+review | /plan2code-3-implement-review | overview.md | Reviewed implementation ready for approval (alternative to `/plan2code-3-implement`) |
|
||||
| 4 | /plan2code-4-finalize | overview.md | Archived specs |
|
||||
| handoff | /plan2code-handoff | Conversation | Self-contained handoff doc (OS temp dir by default, or a folder you pick such as `handoffs/`) |
|
||||
| git-commit | /plan2code-git-commit | Your changes | A commit (`<subject>` / `AI Assisted`): suggested splits, a branch offer on the default branch, optional push |
|
||||
|
||||
**Terminal instead:** run any command without `--web` and answer the interface question with **terminal**. Nothing is lost: same questions, same gates, same files under `specs/`. You can switch between the two mid-feature.
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ the next engineer all start from the same specs.
|
||||
|
||||
One command opens it, every step is a card, and the terminal is always there if you prefer it.
|
||||
|
||||
Version 2.5.1 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
Version 2.6.0 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
|
||||
---
|
||||
|
||||
@@ -183,6 +183,7 @@ The dashboard's cards, and when each one lights up for the spec you pick:
|
||||
| Quick task | Too small for the full process? A quick plan, then it just builds it. | Always |
|
||||
| Review | A second opinion on the changes. Problems ranked, and you pick what gets fixed. | Always |
|
||||
| Handoff | Pack this conversation into a document a fresh session can pick up cold. | Always |
|
||||
| Git commit | Commits your changes with a clear message, suggests a split when it is really two jobs, and offers to push. | Always (offers to start a repository outside one) |
|
||||
|
||||
---
|
||||
|
||||
@@ -349,6 +350,7 @@ console or the terminal; add `--web` to skip the question and go straight to the
|
||||
| `/plan2code-quick-task` | A small change that doesn't warrant the full sequence |
|
||||
| `/plan2code-1b-revise-plan` | Requirements moved mid-build. Revise the specs, not the code |
|
||||
| `/plan2code-handoff` | Compact this conversation into a doc the next one resumes from |
|
||||
| `/plan2code-git-commit` | Commit with a clear message, suggested splits, a branch offer on the default branch, and an optional push |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 81 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 87 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
+16
-5
@@ -12,7 +12,7 @@
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* Install Plan2Code skills globally or into the current project via skills.sh.
|
||||
* Builds the committed skills/ artifact from source prompts in src/.
|
||||
* Builds the (gitignored) skills/ artifact from source prompts in src/.
|
||||
* Supports non-interactive --build-skills and --verify-skills maintenance hooks.
|
||||
*/
|
||||
|
||||
@@ -103,8 +103,8 @@ const MASCOT = {
|
||||
],
|
||||
};
|
||||
|
||||
// Generated skills directory: the committed, canonical Agent Skills build of src/.
|
||||
// `npm run build:skills` regenerates it and `npm test` (`--verify-skills`) fails on drift.
|
||||
// Generated skills directory: the gitignored Agent Skills build of src/.
|
||||
// The installer and `npm run build:skills` regenerate it; `--verify-skills` diffs a stale tree.
|
||||
// `skills add` consumes this directory; nothing else is platform-specific any more.
|
||||
const SKILLS_DIR_NAME = 'skills';
|
||||
const SKILLS_DIR = path.join(__dirname, SKILLS_DIR_NAME);
|
||||
@@ -262,6 +262,16 @@ const SOURCE_PROMPTS = [
|
||||
isUtility: true,
|
||||
scripts: ['specs.mjs'],
|
||||
additionalReferences: [{ source: 'web-console', target: 'web-console' }]
|
||||
},
|
||||
{
|
||||
source: 'plan2code-git-commit.md',
|
||||
stepNumber: 'git-commit',
|
||||
name: 'git-commit',
|
||||
displayName: 'Git Commit Mode',
|
||||
description: 'Commit changes with a clear message, suggest splits, offer a branch and a push',
|
||||
isUtility: true,
|
||||
scripts: ['commit-msg.mjs'],
|
||||
additionalReferences: [{ source: 'web-console', target: 'web-console' }]
|
||||
}
|
||||
];
|
||||
|
||||
@@ -288,6 +298,7 @@ function generateStepLabel(prompt) {
|
||||
if (prompt.stepNumber === 'update') return 'Update';
|
||||
if (prompt.stepNumber === 'review') return 'Review';
|
||||
if (prompt.stepNumber === 'handoff') return 'Handoff';
|
||||
if (prompt.stepNumber === 'git-commit') return 'Git Commit';
|
||||
if (prompt.stepNumber === 'quick') return 'Quick Task';
|
||||
return `Step ${prompt.stepNumber}`;
|
||||
}
|
||||
@@ -728,7 +739,7 @@ function verifySkillsSync() {
|
||||
if (problems.length > 0) {
|
||||
console.error(`${SKILLS_DIR_NAME}/ is out of sync with src/:\n`);
|
||||
for (const problem of problems) console.error(` ${problem}`);
|
||||
console.error(`\n${problems.length} problem(s). Run 'npm run build:skills' and commit the result.`);
|
||||
console.error(`\n${problems.length} problem(s). Run 'npm run build:skills' to regenerate it.`);
|
||||
return false;
|
||||
}
|
||||
console.log(`${SKILLS_DIR_NAME}/ matches src/ — ${expected.size} file(s) across ${SOURCE_PROMPTS.length} skill(s) ✓`);
|
||||
@@ -2593,7 +2604,7 @@ function uninstallLauncher() {
|
||||
// MAIN
|
||||
// ============================================================================
|
||||
|
||||
// Non-interactive build hooks for the committed skills/ artifact.
|
||||
// Non-interactive build hooks for the generated skills/ artifact.
|
||||
const argv = process.argv.slice(2);
|
||||
|
||||
if (argv.includes('--build-skills')) {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code",
|
||||
"version": "2.5.1",
|
||||
"version": "2.6.0",
|
||||
"private": true,
|
||||
"bin": {
|
||||
"plan2code-install": "./install.js"
|
||||
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"prepare": "husky",
|
||||
"build:skills": "node install.js --build-skills",
|
||||
"test": "node scripts/validate-char-count.js && node install.js --verify-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node --test scripts/test-web-console.mjs scripts/test-launcher.mjs scripts/test-skill-scripts.mjs scripts/test-script-pathfinder.mjs scripts/test-script-finalize.mjs scripts/test-script-handoff.mjs"
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node --test scripts/test-web-console.mjs scripts/test-launcher.mjs scripts/test-skill-scripts.mjs scripts/test-script-pathfinder.mjs scripts/test-script-finalize.mjs scripts/test-script-handoff.mjs scripts/test-script-git-commit.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"husky": "^9.0.0"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// The shots use the console's Ocean highlight rather than its default orange:
|
||||
// it is the console's nearest to the Plan2Code blue the site and README use.
|
||||
//
|
||||
// Shots: dashboard, question, doc, build, signoff, finish, ask.
|
||||
// Shots: dashboard, dashboard-utilities, question, doc, build, signoff, finish, ask.
|
||||
//
|
||||
// Needs puppeteer-core (`npm i --no-save puppeteer-core`, never added to
|
||||
// package.json) and a local Chrome or Edge. Writes nothing outside its temp
|
||||
@@ -53,6 +53,14 @@ const SHOTS = {
|
||||
scrollTo: ".dash-toggle",
|
||||
mustShow: ".dash-card:has(.pill.suggested)",
|
||||
},
|
||||
// The utility cards sit even lower: scroll until the Git commit card is the
|
||||
// last row in frame ("cmd:" picks a card by its command).
|
||||
"dashboard-utilities": {
|
||||
workflow: "dashboard",
|
||||
posts: ["dashboard"],
|
||||
scrollTo: "cmd:/plan2code-git-commit",
|
||||
mustShow: "cmd:/plan2code-git-commit",
|
||||
},
|
||||
question: { workflow: "plan", posts: ["question"] },
|
||||
doc: { workflow: "plan", posts: ["doc"], tab: "What we've agreed" },
|
||||
build: { workflow: "implement", posts: ["build"], tab: "Phase 3 tasks" },
|
||||
@@ -201,11 +209,15 @@ async function openTab(page, label) {
|
||||
async function scrollTo(page, { scrollTo: top, mustShow }) {
|
||||
const problem = await page.evaluate(
|
||||
(topSel, showSel) => {
|
||||
const node = document.querySelector(topSel);
|
||||
const find = (sel) =>
|
||||
sel.startsWith("cmd:")
|
||||
? [...document.querySelectorAll(".dash-card")].find((c) => c.querySelector(".dash-card-cmd")?.textContent.trim() === sel.slice(4))
|
||||
: document.querySelector(sel);
|
||||
const node = find(topSel);
|
||||
if (!node) return `nothing matched ${topSel}, captured from the top`;
|
||||
node.scrollIntoView({ block: "start", behavior: "instant" });
|
||||
node.scrollIntoView({ block: topSel.startsWith("cmd:") ? "end" : "start", behavior: "instant" });
|
||||
if (!showSel) return null;
|
||||
const show = document.querySelector(showSel);
|
||||
const show = find(showSel);
|
||||
if (!show) return `nothing matched ${showSel}`;
|
||||
const r = show.getBoundingClientRect();
|
||||
return r.top >= 0 && r.bottom <= window.innerHeight ? null : `${showSel} is not wholly in view`;
|
||||
@@ -329,7 +341,7 @@ async function main() {
|
||||
// A saved role keeps the dashboard's "pick your role" banner out of shot,
|
||||
// and the Ocean highlight is the console's nearest to the Plan2Code blue
|
||||
// the landing page uses.
|
||||
fs.writeFileSync(path.join(HOME, "looks.json"), JSON.stringify({ looks: { role: "engineer", accent: "ocean" } }));
|
||||
fs.writeFileSync(path.join(HOME, "looks.json"), JSON.stringify({ looks: { role: "engineer", accent: "ocean", welcomeSeen: true } }));
|
||||
browser = await puppeteer.launch({
|
||||
executablePath: browserPath,
|
||||
headless: true,
|
||||
|
||||
@@ -0,0 +1,299 @@
|
||||
// Tests for plan2code-git-commit's scripts/git-state.mjs.
|
||||
//
|
||||
// See skill-script-helpers.mjs for how these run.
|
||||
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { runScript, tmp, write, gitInit } from "./skill-script-helpers.mjs";
|
||||
|
||||
const S = (cwd, ...a) => runScript("plan2code-git-commit", "git-state.mjs", a, { cwd });
|
||||
|
||||
// A repo with one commit on `branch`, and its git runner.
|
||||
function repoWithCommit(name, branch = "main") {
|
||||
const repo = tmp(name);
|
||||
const g = gitInit(repo, branch);
|
||||
write(repo, "a.txt", "a\n");
|
||||
g("add", "-A");
|
||||
g("commit", "-q", "-m", "init");
|
||||
return { repo, g };
|
||||
}
|
||||
|
||||
function bareRemote() {
|
||||
const bare = tmp("origin");
|
||||
execFileSync("git", ["init", "-q", "--bare", "-b", "main", bare], { stdio: "pipe" });
|
||||
return bare;
|
||||
}
|
||||
|
||||
/* ============================================================ git-state.mjs state */
|
||||
|
||||
test("git-state state: a clean repo with one commit and no remote", () => {
|
||||
const { repo } = repoWithCommit("gs-clean");
|
||||
const r = S(repo, "state");
|
||||
assert.equal(r.code, 0, r.stderr);
|
||||
assert.equal(r.json.branch, "main");
|
||||
assert.equal(r.json.detached, false);
|
||||
assert.equal(r.json.hasCommits, true);
|
||||
assert.equal(r.json.nothingToCommit, true);
|
||||
assert.deepEqual([r.json.staged, r.json.unstaged, r.json.untracked, r.json.conflicted], [[], [], [], []]);
|
||||
assert.deepEqual(r.json.remotes, []);
|
||||
assert.equal(r.json.upstream, null);
|
||||
assert.equal(r.json.push, null, "no remote, nothing to push");
|
||||
assert.equal(r.json.inProgress, null);
|
||||
});
|
||||
|
||||
test("git-state state: staged, unstaged, untracked and renamed files land in the right lists", () => {
|
||||
const { repo, g } = repoWithCommit("gs-files");
|
||||
write(repo, "b.txt", "b\n");
|
||||
write(repo, "c.txt", "c\n");
|
||||
g("add", "-A");
|
||||
g("commit", "-q", "-m", "more");
|
||||
write(repo, "a.txt", "changed\n"); // unstaged
|
||||
write(repo, "b.txt", "changed\n"); // staged...
|
||||
g("add", "b.txt");
|
||||
write(repo, "b.txt", "changed again\n"); // ...and unstaged too
|
||||
g("mv", "c.txt", "d.txt"); // staged rename
|
||||
write(repo, "u.txt", "new\n"); // untracked
|
||||
const r = S(repo, "state");
|
||||
assert.equal(r.code, 0, r.stderr);
|
||||
assert.deepEqual(r.json.staged, [
|
||||
{ path: "b.txt", status: "M" },
|
||||
{ path: "d.txt", status: "R" },
|
||||
]);
|
||||
assert.deepEqual(r.json.unstaged, [
|
||||
{ path: "a.txt", status: "M" },
|
||||
{ path: "b.txt", status: "M" },
|
||||
]);
|
||||
assert.deepEqual(r.json.untracked, [{ path: "u.txt", status: "?" }]);
|
||||
assert.ok(![...r.json.staged, ...r.json.unstaged].some((f) => f.path === "c.txt"), "a rename's old path is skipped");
|
||||
assert.equal(r.json.nothingToCommit, false);
|
||||
});
|
||||
|
||||
test("git-state state: the default branch from origin/HEAD, local main, local master, unborn, or none", () => {
|
||||
// origin/HEAD
|
||||
const bare = bareRemote();
|
||||
const { repo, g } = repoWithCommit("gs-def-origin");
|
||||
g("remote", "add", "origin", bare);
|
||||
g("push", "-q", "-u", "origin", "main");
|
||||
g("remote", "set-head", "origin", "-a");
|
||||
const fromOrigin = S(repo, "state").json;
|
||||
assert.equal(fromOrigin.defaultFrom, "origin/HEAD");
|
||||
assert.equal(fromOrigin.defaultBranch, "main");
|
||||
assert.equal(fromOrigin.onDefault, true);
|
||||
|
||||
// local main, and off the default
|
||||
const main = repoWithCommit("gs-def-main");
|
||||
assert.equal(S(main.repo, "state").json.defaultFrom, "local-main");
|
||||
main.g("checkout", "-q", "-b", "feature/x");
|
||||
const off = S(main.repo, "state").json;
|
||||
assert.equal(off.defaultBranch, "main");
|
||||
assert.equal(off.onDefault, false);
|
||||
|
||||
// local master
|
||||
const master = S(repoWithCommit("gs-def-master", "master").repo, "state").json;
|
||||
assert.equal(master.defaultFrom, "local-master");
|
||||
assert.equal(master.defaultBranch, "master");
|
||||
assert.equal(master.onDefault, true);
|
||||
|
||||
// no commits yet, on main
|
||||
const fresh = tmp("gs-def-unborn");
|
||||
gitInit(fresh, "main");
|
||||
const unborn = S(fresh, "state").json;
|
||||
assert.equal(unborn.hasCommits, false);
|
||||
assert.equal(unborn.branch, "main");
|
||||
assert.equal(unborn.defaultFrom, "unborn");
|
||||
assert.equal(unborn.defaultBranch, "main");
|
||||
assert.equal(unborn.onDefault, true);
|
||||
assert.equal(unborn.push, null, "no commits, nothing to push");
|
||||
|
||||
// neither main nor master: no default, so no branch offer
|
||||
const dev = S(repoWithCommit("gs-def-none", "develop").repo, "state").json;
|
||||
assert.equal(dev.defaultBranch, null);
|
||||
assert.equal(dev.defaultFrom, null);
|
||||
assert.equal(dev.onDefault, false);
|
||||
const devFresh = tmp("gs-def-none2");
|
||||
gitInit(devFresh, "develop");
|
||||
assert.equal(S(devFresh, "state").json.defaultBranch, null);
|
||||
});
|
||||
|
||||
test("git-state state: a detached HEAD has no branch and nothing to push", () => {
|
||||
const { repo, g } = repoWithCommit("gs-detached");
|
||||
g("remote", "add", "origin", bareRemote());
|
||||
g("checkout", "-q", "--detach");
|
||||
const r = S(repo, "state").json;
|
||||
assert.equal(r.detached, true);
|
||||
assert.equal(r.branch, null);
|
||||
assert.equal(r.onDefault, false);
|
||||
assert.equal(r.unpublished, false);
|
||||
assert.equal(r.push, null);
|
||||
});
|
||||
|
||||
test("git-state state: the push command for an unpublished branch, one remote or several", () => {
|
||||
const { repo, g } = repoWithCommit("gs-unpub", "feature/x");
|
||||
g("remote", "add", "origin", bareRemote());
|
||||
const one = S(repo, "state").json;
|
||||
assert.equal(one.unpublished, true);
|
||||
assert.equal(one.upstream, null);
|
||||
assert.equal(one.ahead, null);
|
||||
assert.deepEqual(one.push, { command: "git push -u origin feature/x", setsUpstream: true, remote: "origin", needsRemoteChoice: false });
|
||||
|
||||
g("remote", "add", "backup", bareRemote());
|
||||
const two = S(repo, "state").json;
|
||||
assert.equal(two.push.remote, "origin", "origin wins when there are several");
|
||||
assert.equal(two.push.needsRemoteChoice, true);
|
||||
assert.equal(two.push.command, "git push -u origin feature/x");
|
||||
|
||||
g("remote", "remove", "origin");
|
||||
g("remote", "add", "zeta", bareRemote());
|
||||
const noOrigin = S(repo, "state").json;
|
||||
assert.equal(noOrigin.push.remote, "backup", "no origin: the first remote");
|
||||
assert.equal(noOrigin.push.needsRemoteChoice, true);
|
||||
});
|
||||
|
||||
test("git-state state: ahead of an upstream is a plain git push, pushed is null", () => {
|
||||
const { repo, g } = repoWithCommit("gs-ahead");
|
||||
g("remote", "add", "origin", bareRemote());
|
||||
g("push", "-q", "-u", "origin", "main");
|
||||
const synced = S(repo, "state").json;
|
||||
assert.equal(synced.upstream, "origin/main");
|
||||
assert.equal(synced.ahead, 0);
|
||||
assert.equal(synced.behind, 0);
|
||||
assert.equal(synced.unpublished, false);
|
||||
assert.equal(synced.push, null);
|
||||
|
||||
write(repo, "n.txt", "n\n");
|
||||
g("add", "-A");
|
||||
g("commit", "-q", "-m", "next");
|
||||
const ahead = S(repo, "state").json;
|
||||
assert.equal(ahead.ahead, 1);
|
||||
assert.equal(ahead.behind, 0);
|
||||
assert.deepEqual(ahead.push, { command: "git push", setsUpstream: false, remote: "origin", needsRemoteChoice: false });
|
||||
});
|
||||
|
||||
test("git-state state: a merge in progress and its conflicted files", () => {
|
||||
const repo = tmp("gs-merge");
|
||||
const g = gitInit(repo, "main");
|
||||
write(repo, "f.txt", "a\n");
|
||||
g("add", "-A");
|
||||
g("commit", "-q", "-m", "base");
|
||||
g("checkout", "-q", "-b", "x");
|
||||
write(repo, "f.txt", "b\n");
|
||||
g("commit", "-q", "-am", "x side");
|
||||
g("checkout", "-q", "main");
|
||||
write(repo, "f.txt", "c\n");
|
||||
g("commit", "-q", "-am", "main side");
|
||||
assert.throws(() => g("merge", "x"));
|
||||
const r = S(repo, "state").json;
|
||||
assert.equal(r.inProgress, "merge");
|
||||
assert.deepEqual(r.conflicted, [{ path: "f.txt", status: "UU" }]);
|
||||
assert.ok(!r.staged.some((f) => f.path === "f.txt") && !r.unstaged.some((f) => f.path === "f.txt"), "listed only under conflicted");
|
||||
assert.equal(r.nothingToCommit, false);
|
||||
});
|
||||
|
||||
test("git-state state: secrets are flagged, examples are not, and large files are listed", () => {
|
||||
const { repo } = repoWithCommit("gs-risky");
|
||||
for (const f of [".env", ".env.local", "id_rsa", "id_ed25519.pub", "server.pem", "secrets.json", "credentials.json", ".npmrc", "config/.env"]) write(repo, f, "x\n");
|
||||
for (const f of [".env.example", ".env.sample", "key.txt", "notes.md"]) write(repo, f, "x\n");
|
||||
write(repo, "video.bin", Buffer.alloc(6 * 1024 * 1024, 1));
|
||||
write(repo, "small.bin", Buffer.alloc(1024 * 1024, 1));
|
||||
const r = S(repo, "state").json;
|
||||
assert.deepEqual(r.sensitive, [".env", ".env.local", ".npmrc", "config/.env", "credentials.json", "id_ed25519.pub", "id_rsa", "secrets.json", "server.pem"]);
|
||||
assert.deepEqual(r.large, [{ path: "video.bin", bytes: 6 * 1024 * 1024 }]);
|
||||
});
|
||||
|
||||
test("git-state state: reading leaves the index untouched", () => {
|
||||
const { repo } = repoWithCommit("gs-readonly");
|
||||
const index = path.join(repo, ".git", "index");
|
||||
// Same content, new mtime: a plain git status would refresh and rewrite the index.
|
||||
const later = new Date(Date.now() + 5000);
|
||||
fs.utimesSync(path.join(repo, "a.txt"), later, later);
|
||||
const before = fs.readFileSync(index);
|
||||
assert.equal(S(repo, "state").code, 0);
|
||||
assert.ok(before.equals(fs.readFileSync(index)), "the index file is byte-for-byte the same");
|
||||
});
|
||||
|
||||
test("git-state: outside a repository, and a bad subcommand", () => {
|
||||
const plain = tmp("gs-norepo");
|
||||
const r = S(plain, "state");
|
||||
assert.equal(r.code, 3);
|
||||
assert.equal(r.json.error, "not-a-repo");
|
||||
assert.match(r.json.next, /init-check/);
|
||||
assert.equal(S(plain, "branch-check", "--name", "x").code, 3);
|
||||
assert.equal(S(plain).code, 2);
|
||||
assert.equal(S(plain, "commit").code, 2);
|
||||
assert.equal(S(plain, "state", "extra").code, 2);
|
||||
});
|
||||
|
||||
/* ======================================================= git-state.mjs branch-check */
|
||||
|
||||
test("git-state branch-check: valid, invalid, taken and clashing names", () => {
|
||||
const { repo, g } = repoWithCommit("gs-branch");
|
||||
g("branch", "feat");
|
||||
const ok = S(repo, "branch-check", "--name", "feature/export-csv");
|
||||
assert.equal(ok.code, 0, ok.stderr);
|
||||
assert.deepEqual(ok.json, { ok: true, name: "feature/export-csv", valid: true, exists: false });
|
||||
for (const bad of ["bad..name", "has space", "-leading", "@{-1}", "ends/"]) {
|
||||
const r = S(repo, "branch-check", "--name", bad);
|
||||
assert.equal(r.code, 4, bad);
|
||||
assert.equal(r.json.error, "invalid-name", bad);
|
||||
}
|
||||
assert.match(S(repo, "branch-check", "--name", "bad..name").json.next, /feature\//);
|
||||
const taken = S(repo, "branch-check", "--name", "main");
|
||||
assert.equal(taken.code, 4);
|
||||
assert.equal(taken.json.error, "branch-exists");
|
||||
assert.match(taken.json.next, /main-2/);
|
||||
const clash = S(repo, "branch-check", "--name", "feat/x");
|
||||
assert.equal(clash.code, 4);
|
||||
assert.equal(clash.json.error, "branch-conflict");
|
||||
assert.equal(S(repo, "branch-check").code, 2);
|
||||
});
|
||||
|
||||
/* ========================================================= git-state.mjs init-check */
|
||||
|
||||
test("git-state init-check: a plain folder is safe and suggests what to ignore", () => {
|
||||
const dir = tmp("gs-init");
|
||||
for (const f of ["node_modules/x/index.js", "dist/out.js", ".env", ".env.example", "app.log", "src/a.js"]) write(dir, f, "x\n");
|
||||
const r = S(dir, "init-check");
|
||||
assert.equal(r.code, 0, r.stderr);
|
||||
assert.equal(r.json.safe, true);
|
||||
assert.equal(r.json.reason, undefined);
|
||||
assert.equal(r.json.insideRepo, false);
|
||||
assert.equal(r.json.hasGitignore, false);
|
||||
assert.deepEqual(r.json.suggestedIgnore, ["node_modules/", "dist/", ".env", ".env.*", "!.env.example", "*.log"]);
|
||||
write(dir, ".gitignore", "x\n");
|
||||
assert.equal(S(dir, "init-check").json.hasGitignore, true);
|
||||
const empty = tmp("gs-init-empty");
|
||||
assert.deepEqual(S(empty, "init-check").json.suggestedIgnore, []);
|
||||
});
|
||||
|
||||
test("git-state init-check: inside a repository, the home folder, and a drive root are not safe", () => {
|
||||
const { repo } = repoWithCommit("gs-init-repo");
|
||||
write(repo, "sub/x.txt", "x\n");
|
||||
const inside = S(path.join(repo, "sub"), "init-check").json;
|
||||
assert.equal(inside.safe, false);
|
||||
assert.equal(inside.reason, "inside-repo");
|
||||
assert.equal(inside.insideRepo, true);
|
||||
assert.equal(path.resolve(inside.repoRoot).toLowerCase(), repo.toLowerCase());
|
||||
|
||||
const home = tmp("gs-init-home");
|
||||
const asHome = runScript("plan2code-git-commit", "git-state.mjs", ["init-check"], { cwd: home, env: { HOME: home, USERPROFILE: home } });
|
||||
assert.equal(asHome.json.safe, false);
|
||||
assert.equal(asHome.json.reason, "home");
|
||||
|
||||
const root = path.parse(process.cwd()).root;
|
||||
const atRoot = S(root, "init-check").json;
|
||||
if (!atRoot.insideRepo) {
|
||||
assert.equal(atRoot.safe, false);
|
||||
assert.equal(atRoot.reason, "root");
|
||||
}
|
||||
});
|
||||
|
||||
/* ============================================================ the skill's other script */
|
||||
|
||||
test("plan2code-git-commit ships commit-msg.mjs with the two -m flags", () => {
|
||||
const r = runScript("plan2code-git-commit", "commit-msg.mjs", ["--subject", "Add the export", "--files", "src/a.js"]);
|
||||
assert.equal(r.code, 0, r.stderr);
|
||||
assert.equal(r.json.command, 'git add -- src/a.js && git commit -m "Add the export" -m "AI Assisted"');
|
||||
});
|
||||
@@ -228,7 +228,7 @@ test("specs archive: dry-run, move, refuse to clobber", () => {
|
||||
|
||||
/* ============================================================ commit-msg.mjs */
|
||||
|
||||
test("commit-msg: ticket from the branch, the three -m flags, subject rules", () => {
|
||||
test("commit-msg: the two -m flags on any branch, subject rules", () => {
|
||||
const repo = tmp("commit");
|
||||
const g = gitInit(repo, "feature/ABC-10968-export-csv");
|
||||
write(repo, "a.txt", "a");
|
||||
@@ -237,24 +237,29 @@ test("commit-msg: ticket from the branch, the three -m flags, subject rules", ()
|
||||
const C = (...a) => runScript("plan2code-review", "commit-msg.mjs", a, { cwd: repo });
|
||||
const ok = C("--subject", "Add the export endpoint", "--add-all");
|
||||
assert.equal(ok.code, 0, ok.stderr);
|
||||
assert.equal(ok.json.ticket, "ABC-10968");
|
||||
assert.equal(ok.json.command, 'git add -A && git commit -m "Add the export endpoint" -m "ABC-10968" -m "AI Assisted"');
|
||||
assert.equal(ok.json.message, "Add the export endpoint\n\nABC-10968\nAI Assisted");
|
||||
assert.equal(ok.json.ticket, undefined);
|
||||
assert.equal(ok.json.branch, undefined);
|
||||
assert.equal(ok.json.command, 'git add -A && git commit -m "Add the export endpoint" -m "AI Assisted"');
|
||||
assert.equal(ok.json.message, "Add the export endpoint\n\nAI Assisted");
|
||||
assert.equal(C("--subject", "x".repeat(101)).code, 4);
|
||||
assert.equal(C("--subject", 'say "hi"').code, 4);
|
||||
assert.equal(C("--subject", "costs $5").code, 4);
|
||||
assert.equal(C().code, 2);
|
||||
assert.match(C("--subject", "Fix it", "--files", "src/a.ts", "--files", "my file.md").json.command, /^git add -- src\/a\.ts 'my file\.md' && git commit/);
|
||||
g("checkout", "-q", "-b", "chore/no-ticket-here");
|
||||
const none = C("--subject", "Fix it");
|
||||
assert.equal(none.code, 4);
|
||||
assert.equal(none.json.error, "no-ticket");
|
||||
assert.equal(C("--subject", "Fix it", "--ticket", "ABC-1").json.ticket, "ABC-1");
|
||||
assert.equal(C("--subject", "Fix it", "--ticket", "abc-1").code, 4);
|
||||
g("checkout", "-q", "-b", "PROJ2-7_underscore");
|
||||
assert.equal(C("--subject", "Fix it").json.ticket, "PROJ2-7");
|
||||
const fix = 'git commit -m "Fix it" -m "AI Assisted"';
|
||||
assert.equal(C("--subject", "Fix it").json.commit, fix, "ticket branch");
|
||||
g("checkout", "-q", "-b", "main");
|
||||
const onMain = C("--subject", "Fix it");
|
||||
assert.equal(onMain.json.commit, fix, "main");
|
||||
assert.equal(onMain.json.message, "Fix it\n\nAI Assisted");
|
||||
assert.equal(onMain.json.ticket, undefined);
|
||||
assert.equal(onMain.json.branch, undefined);
|
||||
const flag = C("--subject", "Fix it", "--ticket", "ABC-1");
|
||||
assert.equal(flag.code, 2, "--ticket is an unknown flag");
|
||||
assert.equal(flag.json.error, "unknown-flag");
|
||||
const notRepo = runScript("plan2code-review", "commit-msg.mjs", ["--subject", "x"], { cwd: tmp("norepo") });
|
||||
assert.equal(notRepo.code, 3);
|
||||
assert.equal(notRepo.code, 0, "no repository needed");
|
||||
assert.equal(notRepo.json.commit, 'git commit -m "x" -m "AI Assisted"');
|
||||
});
|
||||
|
||||
/* ============================================================ agent-files.mjs */
|
||||
@@ -427,7 +432,7 @@ test("commit-msg: a repo with no commits, stray arguments, and paths quoted for
|
||||
const repo = tmp("commit2");
|
||||
gitInit(repo, "feature/ABC-12-x");
|
||||
const C = (...a) => runScript("plan2code-review", "commit-msg.mjs", a, { cwd: repo });
|
||||
assert.equal(C("--subject", "Add x").json.ticket, "ABC-12", "no commits yet");
|
||||
assert.equal(C("--subject", "Add x").json.commit, 'git commit -m "Add x" -m "AI Assisted"', "no commits yet");
|
||||
const stray = C("--subject", "Fix", "--files", "a.js", "b.js");
|
||||
assert.equal(stray.code, 2);
|
||||
assert.equal(stray.json.error, "stray-argument");
|
||||
@@ -577,7 +582,7 @@ test("commit-msg: @ and - paths are quoted, git add ends its options, risky subj
|
||||
const files = C("--subject", "Fix", "--files", "@types/x.d.ts", "--files", "-weird.md", "--files", "src/a@b.js");
|
||||
assert.equal(files.code, 0, files.stderr);
|
||||
assert.equal(files.json.add, "git add -- '@types/x.d.ts' '-weird.md' src/a@b.js");
|
||||
assert.equal(files.json.commit, 'git commit -m "Fix" -m "ABC-12" -m "AI Assisted"');
|
||||
assert.equal(files.json.commit, 'git commit -m "Fix" -m "AI Assisted"');
|
||||
assert.equal(files.json.command, `${files.json.add} && ${files.json.commit}`);
|
||||
assert.equal(C("--subject", "Fix", "--add-all").json.add, "git add -A");
|
||||
const bare = C("--subject", "Fix").json;
|
||||
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
DONE_REPLY,
|
||||
finishPaused,
|
||||
fitWithin,
|
||||
GIT_INIT_NOTE,
|
||||
handoffShape,
|
||||
handoffText,
|
||||
HOME_REPLY,
|
||||
@@ -185,6 +186,7 @@ import {
|
||||
cwdHash,
|
||||
handOff,
|
||||
initialWorkspace,
|
||||
insideGitRepo,
|
||||
latestOpenCaps,
|
||||
parseArgs,
|
||||
pendingWorkspaceChanges,
|
||||
@@ -3030,6 +3032,63 @@ test("the project scan reads each spec's pipeline stage off its files", () => {
|
||||
}
|
||||
});
|
||||
|
||||
// The dashboard's Git commit card offers to start a repository when the folder
|
||||
// is not one. The scan answers that from the filesystem, never from a git
|
||||
// process, and a linked worktree (a .git file, not a folder) must count.
|
||||
test("scanProject reports isGit for a repo, a subfolder, a linked worktree and a plain folder", () => {
|
||||
const saved = {};
|
||||
for (const k of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR"]) {
|
||||
saved[k] = process.env[k];
|
||||
delete process.env[k];
|
||||
}
|
||||
const base = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-isgit-"));
|
||||
try {
|
||||
const repo = path.join(base, "repo");
|
||||
fs.mkdirSync(path.join(repo, "sub"), { recursive: true });
|
||||
const git = (cwd, ...a) => execFileSync("git", a, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
||||
git(repo, "init", "-q");
|
||||
git(repo, "-c", "user.email=t@t", "-c", "user.name=t", "commit", "-q", "--allow-empty", "-m", "x");
|
||||
git(repo, "worktree", "add", "-q", path.join(base, "wt"));
|
||||
const plain = path.join(base, "plain");
|
||||
fs.mkdirSync(plain);
|
||||
|
||||
assert.equal(scanProject(repo).isGit, true);
|
||||
assert.equal(scanProject(path.join(repo, "sub")).isGit, true);
|
||||
assert.equal(fs.statSync(path.join(base, "wt", ".git")).isFile(), true, "a linked worktree's .git is a file");
|
||||
assert.equal(scanProject(path.join(base, "wt")).isGit, true);
|
||||
assert.equal(scanProject(plain).isGit, false);
|
||||
assert.equal(insideGitRepo(plain), false);
|
||||
|
||||
// When git is steered by the environment, git decides: count it as a repo.
|
||||
process.env.GIT_DIR = path.join(plain, "nowhere");
|
||||
assert.equal(insideGitRepo(plain), true);
|
||||
} finally {
|
||||
for (const [k, v] of Object.entries(saved)) {
|
||||
if (v === undefined) delete process.env[k];
|
||||
else process.env[k] = v;
|
||||
}
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("the Git commit card stays clickable outside a repository and says what happens", () => {
|
||||
const entry = SKILL_CATALOG.find((e) => e.skill === "plan2code-git-commit");
|
||||
const outside = cardAvailability(entry, { hasAgents: true, isGit: false }, null);
|
||||
assert.equal(outside.on, true);
|
||||
assert.equal(outside.note, GIT_INIT_NOTE);
|
||||
for (const scan of [{ hasAgents: true, isGit: true }, { hasAgents: true }, null]) {
|
||||
const a = cardAvailability(entry, scan, null);
|
||||
assert.equal(a.on, true);
|
||||
assert.equal(a.note, undefined);
|
||||
}
|
||||
const scan = { hasAgents: true, isGit: false, specs: [] };
|
||||
assert.equal(cardPresentation(entry, scan, null).detail, GIT_INIT_NOTE);
|
||||
// The agent's own detail line still wins over the note.
|
||||
const withSpec = { hasAgents: true, isGit: false, specs: [{ dir: "specs/x", name: "x", state: "building" }] };
|
||||
const menu = { details: { "plan2code-git-commit": "Two changes ready" } };
|
||||
assert.equal(cardPresentation(entry, withSpec, withSpec.specs[0], menu).detail, "Two changes ready");
|
||||
});
|
||||
|
||||
test("a verdict's button text never renders blank", () => {
|
||||
assert.equal(verdictText({ id: "approve", label: "Approve it" }), "Approve it");
|
||||
assert.equal(verdictText({ id: "approve", text: "Approve it" }), "Approve it");
|
||||
|
||||
@@ -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" });
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Plan2Code",
|
||||
"version": "2.5.1",
|
||||
"version": "2.6.0",
|
||||
"description": "A structured 4-step workflow methodology for AI-assisted software development",
|
||||
"keywords": [
|
||||
"ai",
|
||||
|
||||
Reference in new issue
Block a user