mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 12:45:33 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9226b82c37 | ||
|
|
76e0c44e0b |
No files matched your search
@@ -5,7 +5,7 @@ description: "Publish a GitHub Release for jparkerweb/plan2code whenever CHANGEL
|
||||
|
||||
# Plan2Code Release Publisher
|
||||
|
||||
Publish a GitHub Release for `jparkerweb/plan2code` whenever `CHANGELOG.md`'s top version is ahead of the latest published release on GitHub. This turns the merged CHANGELOG entry on `main` into an actual GitHub Release (which also creates the `vX.Y.Z` git tag).
|
||||
Publish a GitHub Release for `jparkerweb/plan2code` whenever `CHANGELOG.md`'s top version is ahead of the latest published release on GitHub. This turns the merged CHANGELOG entry on `main` into an actual GitHub Release (the `release-app` workflow builds the app first and creates the release, with its `vX.Y.Z` git tag, last).
|
||||
|
||||
**Repo-local by design.** This skill lives in the repo's `.claude/skills/` and is intentionally NOT wired into `install.js` — it is a maintainer dev tool, not part of the shipped product, so it is never installed to `~/.claude/skills/`. Do **not** copy it there: the uninstaller (`uninstallFiles()` in `install.js`) and every re-install's pre-copy cleanup in `install()` both delete every entry matching `/^plan2code-/` under `~/.claude/skills/`, so a copy placed there would be silently removed.
|
||||
|
||||
@@ -103,57 +103,59 @@ Present all three to the user and wait for an explicit answer before any write.
|
||||
|
||||
If the user supplies a suffix, set `title = "v$CHANGELOG_VERSION " + <suffix>` (single space join) and proceed to publish. The tag and notes are unaffected by the suffix.
|
||||
|
||||
### Step 9 — Publish (on approval)
|
||||
### Step 9 - Publish (on approval)
|
||||
|
||||
On approval, write `$notes` to a temp file — never pass multiline text inline via `--notes`, that regresses into a quoting bug — then create the release targeting `main`. Two requirements for the temp file: `$notes` must already hold **real newlines** (per Step 8) because `printf '%s'` / `WriteAllText` write it byte-for-byte — a literal `\n` in the string lands literally in the release body; and it MUST be **UTF-8** because the notes contain emoji (`🎉`, `🐛`, `✨`, `🔧`).
|
||||
The release is created by the `release-app` workflow, **last**, not by this skill. The workflow builds the app on four systems, attaches every file to a draft release, and only then publishes it, so the `vX.Y.Z` tag (which the app's update check watches) never exists before its binaries do. Creating the release here with `gh release create` would put the tag up first and leave users offered an upgrade with nothing to download. Do not do that.
|
||||
|
||||
On approval, write `$notes` to a temp file, never inline (multiline text on the command line is a quoting bug). `$notes` must already hold **real newlines** (per Step 8) because `printf '%s'` / `WriteAllText` write it byte-for-byte, and the file MUST be **UTF-8** because the notes contain emoji. Then start the workflow on `main`, passing the file as the `notes` input (`-F key=@file` reads the file's contents):
|
||||
|
||||
**bash (preferred in this environment):**
|
||||
|
||||
```bash
|
||||
NOTES_FILE=$(mktemp)
|
||||
printf '%s' "$notes" > "$NOTES_FILE"
|
||||
gh release create "$tag" --repo jparkerweb/plan2code --title "$title" --notes-file "$NOTES_FILE" --target main
|
||||
gh workflow run release-app.yml --repo jparkerweb/plan2code --ref main -f version="$CHANGELOG_VERSION" -f title="$title" -F notes=@"$NOTES_FILE"
|
||||
rm -f "$NOTES_FILE"
|
||||
```
|
||||
|
||||
**PowerShell:** do NOT use `Set-Content` — under Windows PowerShell 5.1 it writes ANSI/UTF-16 by default and mangles the emoji into `??`. Write UTF-8 **without BOM** (a BOM would leak into the release body):
|
||||
**PowerShell:** do NOT use `Set-Content` (under Windows PowerShell 5.1 it writes ANSI/UTF-16 and mangles the emoji into `??`). Write UTF-8 **without BOM**:
|
||||
|
||||
```powershell
|
||||
$NotesFile = [System.IO.Path]::GetTempFileName()
|
||||
[System.IO.File]::WriteAllText($NotesFile, $notes, [System.Text.UTF8Encoding]::new($false))
|
||||
gh release create "$tag" --repo jparkerweb/plan2code --title "$title" --notes-file "$NotesFile" --target main
|
||||
gh workflow run release-app.yml --repo jparkerweb/plan2code --ref main -f version="$CHANGELOG_VERSION" -f title="$title" -F notes=@"$NotesFile"
|
||||
Remove-Item -Path $NotesFile
|
||||
```
|
||||
|
||||
Always delete the temp file afterward, regardless of whether `gh release create` succeeded or failed.
|
||||
Always delete the temp file afterward, whether or not the dispatch succeeded. If `gh workflow run` exits non-zero, show its error verbatim.
|
||||
|
||||
**Failure handling — already-exists classification:** if `gh release create` exits non-zero, inspect the error text.
|
||||
|
||||
- If and only if it contains the substring `already exists` (real output: `HTTP 422: Validation Failed` / `Release.tag_name already exists`), report this to the user as already published, not as a raw CLI error:
|
||||
|
||||
> This version ($CHANGELOG_VERSION) was already published as a release — nothing more to do.
|
||||
|
||||
- Every other failure (auth, network, permissions, etc.) must be surfaced to the user verbatim. Never silently reclassify a genuine failure as "already published."
|
||||
|
||||
### Step 10 — Verify
|
||||
|
||||
Confirm the release now exists and report its URL:
|
||||
Then find the run it started and watch it to the end (the builds take a while; tell the user so):
|
||||
|
||||
```bash
|
||||
gh release view "$tag" --repo jparkerweb/plan2code
|
||||
gh run list --repo jparkerweb/plan2code --workflow release-app.yml --event workflow_dispatch --limit 1 --json databaseId,status,createdAt
|
||||
gh run watch <databaseId> --repo jparkerweb/plan2code --exit-status
|
||||
```
|
||||
|
||||
Report the release URL to the user.
|
||||
If the run list shows a run that started before the dispatch, wait a few seconds and list again. If the run fails, show which job failed and stop: no release or tag exists yet (a failed run leaves at most an unpublished draft, which a re-run reuses). Never publish a release by hand to get around a failed build.
|
||||
|
||||
### Step 10 - Verify
|
||||
|
||||
Confirm the release now exists, is published (not a draft) and carries the files, and report its URL:
|
||||
|
||||
```bash
|
||||
gh release view "$tag" --repo jparkerweb/plan2code --json url,isDraft,assets -q '.url, .isDraft, (.assets | length)'
|
||||
```
|
||||
|
||||
Expect `false` for the draft flag and five assets (four binaries and the SHA256SUMS file). Report the release URL to the user.
|
||||
|
||||
## Rules
|
||||
|
||||
- **Repo-local only** — this skill is not part of the installed product; never add it to `install.js`, and never copy it to `~/.claude/skills/` (the uninstaller deletes `plan2code-*` entries there).
|
||||
- **Read-only on version files** — never modify `CHANGELOG.md`, `version.json`, or `package.json`; this skill only reads and compares them.
|
||||
- **Version-sync gate is hard** (Step 4) — if the three version sources disagree, stop and report; do not publish a release from an inconsistent repo.
|
||||
- **Never run a local `git tag` or `git push`** — tag creation is delegated entirely to `gh release create --target main`.
|
||||
- **Always use `--notes-file`**, never inline multiline `--notes`, and always write the notes file as UTF-8 (no BOM) so emoji survive.
|
||||
- **Repo-local only**: this skill is not part of the installed product; never add it to `install.js`, and never copy it to `~/.claude/skills/` (the uninstaller deletes `plan2code-*` entries there).
|
||||
- **Read-only on version files**: never modify `CHANGELOG.md`, `version.json`, or `package.json`; this skill only reads and compares them.
|
||||
- **Version-sync gate is hard** (Step 4): if the three version sources disagree, stop and report; do not publish a release from an inconsistent repo.
|
||||
- **Never run a local `git tag` or `git push`, and never run `gh release create` yourself**: the `release-app` workflow creates the release and its tag after the builds, so the tag never gets ahead of its binaries.
|
||||
- **Always pass the notes through a UTF-8 (no BOM) temp file**, never inline, so emoji survive.
|
||||
- **Always clean up the temp notes file**, even on a mid-run error.
|
||||
- **Always get explicit approval before any write** (Step 8) — no release is created without a yes (or a yes-with-suffix).
|
||||
- **Derive the current version from the highest published semver tag** (Step 5), never from GitHub's manually-pinnable "Latest" flag. On an empty or failed release list, treat it as "no prior release" (baseline `0.0.0`) — no error-text matching needed.
|
||||
- **On a `gh release create` failure** (Step 9), only reclassify as already-published when the error contains `already exists` — every other failure must be shown verbatim, never swallowed.
|
||||
- **Idempotent and safe to re-run** at any time — re-running after a successful publish hits the Step 7 no-op; re-running after a race-lost publish hits the Step 9 already-exists handling.
|
||||
- **Always get explicit approval before any write** (Step 8): no workflow run is started without a yes (or a yes-with-suffix).
|
||||
- **Derive the current version from the highest published semver tag** (Step 5), never from GitHub's manually-pinnable "Latest" flag. On an empty or failed release list, treat it as "no prior release" (baseline `0.0.0`); no error-text matching needed.
|
||||
- **Idempotent and safe to re-run** at any time: re-running after a successful publish hits the Step 7 no-op; re-running after a failed build starts a fresh run, which reuses any leftover draft.
|
||||
@@ -17,8 +17,9 @@ concurrency:
|
||||
group: app-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Speed: a pull request runs on Ubuntu only (the cheapest runner) unless it carries the
|
||||
# `full-matrix` label; pushes to main and manual runs use all three systems. A change that
|
||||
# Speed: pushes and pull requests run on Ubuntu only (the cheapest runner) unless a pull request
|
||||
# carries the `full-matrix` label; manual runs use all three systems. The release build
|
||||
# (release-app.yml) compiles on Windows and macOS too. A change that
|
||||
# touches only the website, the README, the changelog or similar skips the heavy `app` job. The
|
||||
# fast `prose` job runs on every push and pull request. The root `npm test` suite does not run on
|
||||
# pushes or pull requests at all: run it locally, or start `node-tests` by hand.
|
||||
@@ -76,7 +77,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: ${{ fromJSON(github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'full-matrix') && '["ubuntu-latest"]' || '["windows-latest","macos-latest","ubuntu-latest"]') }}
|
||||
os: ${{ fromJSON((github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'full-matrix')) && '["windows-latest","macos-latest","ubuntu-latest"]' || '["ubuntu-latest"]') }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: plan2code-app
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
name: release-app
|
||||
|
||||
# Builds the desktop app on four systems when a GitHub release is published, or a v* tag is
|
||||
# pushed ahead of one, and attaches one file per system, named
|
||||
# The normal way to release is to start this workflow by hand (`plan2code-publish` does it) with
|
||||
# the version and the release notes. It builds first and creates the release LAST, so the vX.Y.Z
|
||||
# tag, which is what the app's update check looks for, only appears once every file is attached
|
||||
# and nobody is offered an upgrade that has no binary yet. A release published by hand, or a v*
|
||||
# tag pushed ahead of one, still starts it as a fallback; the tag then exists before the files.
|
||||
#
|
||||
# Builds the desktop app on four systems and attaches one file per system, named
|
||||
# plan2code-app-<version>-<os>-<arch>[.exe], plus one checksum file
|
||||
# (plan2code-app-<version>-SHA256SUMS.txt). install.js fetches the matching file and checks it
|
||||
# against that list. Linux ships the plain binary, not an AppImage: docs/desktop-app.md documents
|
||||
@@ -9,6 +14,20 @@ name: release-app
|
||||
# how to allow it.
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to release, without the v (it must match CHANGELOG.md, version.json and package.json)'
|
||||
required: true
|
||||
type: string
|
||||
title:
|
||||
description: 'Release title (defaults to the tag)'
|
||||
required: false
|
||||
type: string
|
||||
notes:
|
||||
description: 'Release notes (Markdown)'
|
||||
required: false
|
||||
type: string
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
@@ -22,9 +41,13 @@ permissions:
|
||||
# A release published after its tag push starts a second run for the same tag: queue it behind
|
||||
# the first so two builds never upload over each other.
|
||||
concurrency:
|
||||
group: release-app-${{ github.event.release.tag_name || github.ref_name }}
|
||||
group: release-app-${{ github.event.release.tag_name || (inputs.version && format('v{0}', inputs.version)) || github.ref_name }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
# The release tag: the published release's, the version a manual run was given, or the pushed tag.
|
||||
TAG: ${{ github.event.release.tag_name || (inputs.version && format('v{0}', inputs.version)) || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build (${{ matrix.label }})
|
||||
@@ -50,8 +73,6 @@ jobs:
|
||||
cache: npm
|
||||
cache-dependency-path: plan2code-app/package-lock.json
|
||||
- name: Check the versions agree with the release tag
|
||||
env:
|
||||
TAG: ${{ github.event.release.tag_name || github.ref_name }}
|
||||
run: node scripts/check-versions.mjs --tag "$TAG"
|
||||
- name: Install the pinned Rust toolchain
|
||||
working-directory: plan2code-app
|
||||
@@ -97,7 +118,6 @@ jobs:
|
||||
contents: write
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ github.event.release.tag_name || github.ref_name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/download-artifact@v4.3.0
|
||||
@@ -123,9 +143,30 @@ jobs:
|
||||
cd dist
|
||||
sha256sum plan2code-app-* > "plan2code-app-${VERSION}-SHA256SUMS.txt"
|
||||
cat "plan2code-app-${VERSION}-SHA256SUMS.txt"
|
||||
- name: Make sure the release exists
|
||||
# A tag push alone names no release; create one (same tag, generated notes) so the
|
||||
# upload below always has somewhere to go, whichever trigger ran it.
|
||||
run: gh release view "$TAG" || gh release create "$TAG" --title "$TAG" --generate-notes
|
||||
- name: Attach to the release
|
||||
run: gh release upload "$TAG" dist/* --clobber
|
||||
- name: Attach to the release, creating it last
|
||||
env:
|
||||
RELEASE_TITLE: ${{ inputs.title }}
|
||||
RELEASE_NOTES: ${{ inputs.notes }}
|
||||
# No release yet (a manual run, or a bare tag push): create it as a DRAFT with every file
|
||||
# attached, then publish it, so the tag appears only when the files are already there.
|
||||
# A release that already exists (published by hand) just gets the files. A draft left
|
||||
# by an earlier failed run is reused. Releases made with the workflow's own token do not
|
||||
# start another run.
|
||||
run: |
|
||||
state="$(gh release list --limit 100 --json tagName,isDraft -q ".[] | select(.tagName==\"$TAG\") | .isDraft")"
|
||||
if [ -z "$state" ]; then
|
||||
notes_file="$(mktemp)"
|
||||
if [ -n "$RELEASE_NOTES" ]; then
|
||||
printf '%s' "$RELEASE_NOTES" > "$notes_file"
|
||||
notes_args=(--notes-file "$notes_file")
|
||||
else
|
||||
notes_args=(--generate-notes)
|
||||
fi
|
||||
gh release create "$TAG" dist/* --draft --target "$GITHUB_SHA" --title "${RELEASE_TITLE:-$TAG}" "${notes_args[@]}"
|
||||
state=true
|
||||
else
|
||||
gh release upload "$TAG" dist/* --clobber
|
||||
fi
|
||||
if [ "$state" = "true" ]; then
|
||||
gh release edit "$TAG" --draft=false
|
||||
fi
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
All notable changes to Plan2Code will be documented in this file.
|
||||
|
||||
## v3.0.2
|
||||
|
||||
### ✨ Added
|
||||
|
||||
- **desktop app**: the app now checks GitHub for a newer release when it starts, and its top bar says `Update available: vX.Y.Z` with a button that copies `plan2code update`, the command that brings the app, skills and launcher up together. The web console already showed this in the browser; the app only compared its own version with the installed skills, so it never knew a release was out.
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **releases**: the release workflow now builds all four systems first and creates the release, with its `vX.Y.Z` tag, last, so nobody is offered an upgrade before its downloads exist. CI runs the root `npm test` suite only by hand, and the app job on Ubuntu only for pushes.
|
||||
|
||||
## v3.0.1
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
@@ -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 3.0.1 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
Version 3.0.2 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"private": true,
|
||||
"bin": {
|
||||
"plan2code-install": "./install.js"
|
||||
|
||||
Generated
+2
-2
@@ -757,7 +757,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fake-agent"
|
||||
version = "3.0.1"
|
||||
version = "3.0.2"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
"terminal_size",
|
||||
@@ -2371,7 +2371,7 @@ checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
|
||||
|
||||
[[package]]
|
||||
name = "plan2code-app"
|
||||
version = "3.0.1"
|
||||
version = "3.0.2"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fake-agent"
|
||||
version = "3.0.1"
|
||||
version = "3.0.2"
|
||||
description = "A stand-in agent program for the Plan2Code app's tests"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.12.4",
|
||||
"@xterm/addon-fit": "0.11.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"private": true,
|
||||
"description": "Plan2Code desktop app (Tauri). Separate from the repo root so the root and the web console stay dependency-free.",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "plan2code-app"
|
||||
version = "3.0.1"
|
||||
version = "3.0.2"
|
||||
description = "Plan2Code desktop app"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
@@ -765,6 +765,17 @@ fn version_status(app: tauri::AppHandle) -> versions::VersionStatus {
|
||||
)
|
||||
}
|
||||
|
||||
/// The newest GitHub release's version when it is newer than this app, else none (also none on
|
||||
/// any failure to ask). The page asks once at start and never waits on it.
|
||||
#[tauri::command]
|
||||
async fn check_new_release(app: tauri::AppHandle) -> Option<String> {
|
||||
let version = app.package_info().version.to_string();
|
||||
tauri::async_runtime::spawn_blocking(move || versions::check_new_release(&version))
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
}
|
||||
|
||||
/// What `update_skills` resolves with: the installer's last line, and the version status
|
||||
/// re-read afterwards, so the bar can say plainly whether the mismatch is actually gone.
|
||||
#[derive(serde::Serialize)]
|
||||
@@ -1319,6 +1330,7 @@ fn main() {
|
||||
save_term_panel,
|
||||
save_first_run_done,
|
||||
version_status,
|
||||
check_new_release,
|
||||
update_skills,
|
||||
pick_project_folder,
|
||||
change_project,
|
||||
|
||||
@@ -73,6 +73,84 @@ pub fn status(app: &str, skills: Option<String>) -> VersionStatus {
|
||||
}
|
||||
}
|
||||
|
||||
/// The repo's tags, asked of GitHub the way the web console's own check does it
|
||||
/// (src/web-console/update-check.mjs): `git ls-remote --tags` needs no token and rides on the
|
||||
/// person's own git and proxy setup.
|
||||
const REPO_URL: &str = "https://github.com/jparkerweb/plan2code.git";
|
||||
/// How long the tag lookup may take before it is given up on (nothing waits on it).
|
||||
const RELEASE_CHECK_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
||||
/// The highest plain `vX.Y.Z` tag in `git ls-remote --tags` output, without the `v`. Peeled
|
||||
/// lines (`^{}`) and pre-release or other tag names never match.
|
||||
pub fn latest_tag(text: &str) -> Option<String> {
|
||||
let mut best: Option<((u64, u64, u64), String)> = None;
|
||||
for line in text.lines() {
|
||||
let Some(version) = line.trim().rsplit_once("refs/tags/v").map(|(_, v)| v) else {
|
||||
continue;
|
||||
};
|
||||
let Some(triple) = parse(version) else {
|
||||
continue;
|
||||
};
|
||||
if best.as_ref().is_none_or(|(top, _)| triple > *top) {
|
||||
best = Some((triple, version.to_string()));
|
||||
}
|
||||
}
|
||||
best.map(|(_, version)| version)
|
||||
}
|
||||
|
||||
/// The newest release's version when it is newer than `app`; none when the app is current,
|
||||
/// ahead, or either version is not a plain `X.Y.Z`.
|
||||
pub fn newer_release(app: &str, ls_remote: &str) -> Option<String> {
|
||||
let latest = latest_tag(ls_remote)?;
|
||||
(parse(&latest)? > parse(app)?).then_some(latest)
|
||||
}
|
||||
|
||||
/// Ask GitHub for the newest release and return its version when it is newer than `app`.
|
||||
/// None on any failure (no git, no network, a login prompt, the timeout): a missing answer
|
||||
/// is never a reason to nag. No prompt and no console window.
|
||||
pub fn check_new_release(app: &str) -> Option<String> {
|
||||
let mut command = Command::new("git");
|
||||
command
|
||||
.env("PATH", crate::node_check::resolved_path())
|
||||
.env("GIT_TERMINAL_PROMPT", "0")
|
||||
.env("GCM_INTERACTIVE", "never")
|
||||
.args(["ls-remote", "--tags", REPO_URL])
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::null());
|
||||
if std::env::var_os("GIT_SSH_COMMAND").is_none() {
|
||||
command.env("GIT_SSH_COMMAND", "ssh -o BatchMode=yes");
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
command.creation_flags(0x08000000); // CREATE_NO_WINDOW, as the console calls are
|
||||
}
|
||||
let mut child = command.spawn().ok()?;
|
||||
let mut stdout = child.stdout.take()?;
|
||||
let (tx, rx) = mpsc::channel::<String>();
|
||||
std::thread::spawn(move || {
|
||||
let mut text = String::new();
|
||||
let _ = std::io::Read::read_to_string(&mut stdout, &mut text);
|
||||
let _ = tx.send(text);
|
||||
});
|
||||
match rx.recv_timeout(RELEASE_CHECK_TIMEOUT) {
|
||||
Ok(text) => {
|
||||
let ok = child.wait().is_ok_and(|status| status.success());
|
||||
if ok {
|
||||
newer_release(app, &text)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the existing installer's update (`plan2code update`, through the launcher's own copy),
|
||||
/// which brings the skills, the launcher and the app level. Pinned to the release tag `app_version`
|
||||
/// names, not `main`, so Update skills never pulls in work the app does not know about yet. Blocks
|
||||
@@ -215,6 +293,34 @@ mod tests {
|
||||
assert!(!status("3.0.0", Some("".into())).mismatch);
|
||||
}
|
||||
|
||||
const TAGS: &str = "aaa\trefs/tags/v2.11.0\n\
|
||||
bbb\trefs/tags/v3.0.0\n\
|
||||
ccc\trefs/tags/v3.0.0^{}\n\
|
||||
ddd\trefs/tags/v3.0.1\n\
|
||||
eee\trefs/tags/v3.10.0\n\
|
||||
fff\trefs/tags/v3.11.0-beta\n\
|
||||
ggg\trefs/tags/not-a-version\n";
|
||||
|
||||
#[test]
|
||||
fn the_latest_tag_is_the_highest_plain_version_compared_by_number() {
|
||||
assert_eq!(latest_tag(TAGS).as_deref(), Some("3.10.0"));
|
||||
assert_eq!(
|
||||
latest_tag("aaa\trefs/tags/v3.0.1\r\nbbb\trefs/tags/v3.0.9\r\n").as_deref(),
|
||||
Some("3.0.9")
|
||||
);
|
||||
assert_eq!(latest_tag(""), None);
|
||||
assert_eq!(latest_tag("aaa\trefs/tags/v3.0.0-beta\n"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_newer_release_is_reported_only_when_it_is_ahead_of_the_app() {
|
||||
assert_eq!(newer_release("3.0.0", TAGS).as_deref(), Some("3.10.0"));
|
||||
assert_eq!(newer_release("3.10.0", TAGS), None);
|
||||
assert_eq!(newer_release("3.11.0", TAGS), None);
|
||||
assert_eq!(newer_release("3.0.0-beta", TAGS), None);
|
||||
assert_eq!(newer_release("3.0.0", ""), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reads_the_version_field_of_a_version_file() {
|
||||
let file = temp_file("ok", r#"{ "name": "Plan2Code", "version": "2.11.0" }"#);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Plan2Code",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"identifier": "com.plan2code.desktop",
|
||||
"build": {
|
||||
"frontendDist": "../ui",
|
||||
|
||||
+33
-3
@@ -2,7 +2,7 @@
|
||||
// agent's terminal panel docked at the bottom with a drag handle.
|
||||
|
||||
import { mountTerminal } from './terminal.js';
|
||||
import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle } from './meter.js';
|
||||
import { NEW_RELEASE_COMMAND, attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle } from './meter.js';
|
||||
|
||||
const { invoke, Channel } = window.__TAURI__.core;
|
||||
|
||||
@@ -1012,6 +1012,29 @@ async function checkVersions() {
|
||||
}
|
||||
}
|
||||
|
||||
// Once, at start, and never waited on: is a newer Plan2Code release out on GitHub? The Rust
|
||||
// side asks (the same tag lookup the web console uses) and answers with the newer version, or
|
||||
// nothing when the app is current or the lookup failed.
|
||||
async function checkNewRelease() {
|
||||
try {
|
||||
const latest = await invoke('check_new_release');
|
||||
if (latest) setNewRelease({ latest, copied: false });
|
||||
} catch {
|
||||
// No answer is no reason to nag.
|
||||
}
|
||||
}
|
||||
|
||||
async function copyUpdateCommand() {
|
||||
if (!newRelease) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(NEW_RELEASE_COMMAND);
|
||||
setNewRelease({ ...newRelease, copied: true });
|
||||
} catch {
|
||||
// The webview refused the clipboard: the bar spells the command out instead.
|
||||
setNewRelease({ ...newRelease, manual: true });
|
||||
}
|
||||
}
|
||||
|
||||
async function updateSkills() {
|
||||
setVersionState({ kind: 'updating', line: 'Updating Plan2Code...' });
|
||||
const progress = new Channel();
|
||||
@@ -1225,11 +1248,12 @@ loopStopNowBtn.onclick = () =>
|
||||
// barNextSteps decides which, and its button), with the rest as "+N more".
|
||||
let consoleDead = false;
|
||||
let versionState = null;
|
||||
const NEXT_STEP_ACTIONS = { reconnect: reconnectConsole, 'restart-console': restartConsole, update: updateSkills };
|
||||
let newRelease = null;
|
||||
const NEXT_STEP_ACTIONS = { reconnect: reconnectConsole, 'restart-console': restartConsole, update: updateSkills, 'copy-update': copyUpdateCommand };
|
||||
let nextStepAction = null;
|
||||
|
||||
function renderNextStep() {
|
||||
const steps = barNextSteps({ consoleDead, version: versionState });
|
||||
const steps = barNextSteps({ consoleDead, version: versionState, newRelease });
|
||||
nextStepEl.hidden = steps.length === 0;
|
||||
const [first, ...rest] = steps;
|
||||
nextStepTextEl.textContent = first ? first.text : '';
|
||||
@@ -1249,6 +1273,11 @@ function setVersionState(next) {
|
||||
renderNextStep();
|
||||
}
|
||||
|
||||
function setNewRelease(next) {
|
||||
newRelease = next;
|
||||
renderNextStep();
|
||||
}
|
||||
|
||||
function markConsoleAlive() {
|
||||
consoleDead = false;
|
||||
renderNextStep();
|
||||
@@ -1425,6 +1454,7 @@ async function main() {
|
||||
applyDefaultAgent(state.lastAgent);
|
||||
setInterval(updateBadge, BADGE_POLL_MS);
|
||||
checkVersions();
|
||||
checkNewRelease();
|
||||
|
||||
let reattach = null;
|
||||
try {
|
||||
|
||||
@@ -9,8 +9,14 @@ export const NEXT_STEP_LABELS = {
|
||||
reconnect: 'Reconnect the console',
|
||||
'restart-console': 'Reconnect the console',
|
||||
update: 'Update skills',
|
||||
'copy-update': 'Copy update command',
|
||||
};
|
||||
|
||||
// What a person runs in a terminal to move to the newest release: the same line the web
|
||||
// console's banner gives. The app cannot replace itself, and Update skills is pinned to the
|
||||
// app's own version, so only this brings the app, the skills and the launcher up together.
|
||||
export const NEW_RELEASE_COMMAND = 'plan2code update';
|
||||
|
||||
/**
|
||||
* What the console page's **continue** button types into the agent's
|
||||
* terminal, one write each: the word, then Enter. Claude Code holds typed
|
||||
@@ -76,7 +82,7 @@ export function lastAgentNotice(list, remembered) {
|
||||
* update, its Reconnect (which stops the old console first, so the new skills
|
||||
* are really picked up) covers a console that has also stopped.
|
||||
*/
|
||||
export function barNextSteps({ consoleDead = false, version = null } = {}) {
|
||||
export function barNextSteps({ consoleDead = false, version = null, newRelease = null } = {}) {
|
||||
const v = version || {};
|
||||
const steps = [];
|
||||
if (v.kind === 'updated') {
|
||||
@@ -108,6 +114,17 @@ export function barNextSteps({ consoleDead = false, version = null } = {}) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Last: the pending fix for a mismatch or a stopped console comes before a release that is
|
||||
// merely out. `newRelease` is `{ latest, copied, manual }`.
|
||||
if (newRelease && newRelease.latest) {
|
||||
steps.push(
|
||||
newRelease.manual
|
||||
? { id: 'new-release', text: `Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app`, title: `Plan2Code v${newRelease.latest} is out. Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app.`, tone: 'warn', action: null }
|
||||
: newRelease.copied
|
||||
? { id: 'new-release', text: `Copied: run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app`, title: `Plan2Code v${newRelease.latest} is out. Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app.`, tone: 'ok', action: null }
|
||||
: { id: 'new-release', text: `Update available: v${newRelease.latest}`, title: `Plan2Code v${newRelease.latest} is out. Copy the command, run it in a terminal, then reopen the app.`, tone: 'warn', action: 'copy-update' }
|
||||
);
|
||||
}
|
||||
return steps.map((step) => ({ ...step, label: step.action ? NEXT_STEP_LABELS[step.action] : null }));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS } from "../plan2code-app/ui/meter.js";
|
||||
import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS, NEW_RELEASE_COMMAND } from "../plan2code-app/ui/meter.js";
|
||||
import { findBrowser, launchBrowser } from "./browser.mjs";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
@@ -38,6 +38,34 @@ test("only one control for reconnecting the console is ever offered: after an up
|
||||
assert.deepEqual(steps.map((step) => step.action), ["restart-console"], "the plain reconnect steps aside for the one that stops the old console first");
|
||||
});
|
||||
|
||||
test("a newer GitHub release is offered last, with the command to copy; a mismatch or a stopped console comes first", () => {
|
||||
const newRelease = { latest: "3.0.1" };
|
||||
const ids = (input) => barNextSteps(input).map((step) => step.id);
|
||||
assert.deepEqual(ids({ newRelease }), ["new-release"]);
|
||||
assert.deepEqual(ids({ consoleDead: true, version: { kind: "mismatch", skills: "3.0.0", app: "3.1.0" }, newRelease }), ["console-dead", "mismatch", "new-release"]);
|
||||
const [step] = barNextSteps({ newRelease });
|
||||
assert.equal(step.text, "Update available: v3.0.1");
|
||||
assert.equal(step.label, "Copy update command");
|
||||
assert.equal(step.action, "copy-update");
|
||||
assert.equal(NEW_RELEASE_COMMAND, "plan2code update");
|
||||
assert.deepEqual(barNextSteps({ newRelease: null }), [], "nothing newer, nothing shown");
|
||||
});
|
||||
|
||||
test("after the copy the bar says what to do next; if the clipboard was refused it spells the command out", () => {
|
||||
const [copied] = barNextSteps({ newRelease: { latest: "3.0.1", copied: true } });
|
||||
assert.match(copied.text, /^Copied: run `plan2code update` in a terminal/);
|
||||
assert.equal(copied.action, null);
|
||||
const [manual] = barNextSteps({ newRelease: { latest: "3.0.1", manual: true } });
|
||||
assert.match(manual.text, /^Run `plan2code update` in a terminal/);
|
||||
assert.equal(manual.action, null);
|
||||
});
|
||||
|
||||
test("the app asks once at start for a newer release, and the bar is wired to the copy action", () => {
|
||||
assert.match(APP_JS, /invoke\('check_new_release'\)/);
|
||||
assert.match(APP_JS, /'copy-update': copyUpdateCommand/);
|
||||
assert.match(APP_JS, /barNextSteps\(\{ consoleDead, version: versionState, newRelease \}\)/);
|
||||
});
|
||||
|
||||
test("each version state reads and acts as the old version bar did", () => {
|
||||
const [mismatch] = barNextSteps({ version: { kind: "mismatch", skills: "3.0.0", app: "3.1.0" } });
|
||||
assert.equal(mismatch.text, "Skills v3.0.0, app v3.1.0");
|
||||
@@ -63,7 +91,7 @@ test("every control that reconnects the console carries the same label, never 'R
|
||||
});
|
||||
|
||||
test("app.js draws the bar's right end through barNextSteps, not a hand-rolled copy of its order", () => {
|
||||
assert.match(APP_JS, /const steps = barNextSteps\(\{ consoleDead, version: versionState \}\);/);
|
||||
assert.match(APP_JS, /const steps = barNextSteps\(\{ consoleDead, version: versionState, newRelease \}\);/);
|
||||
for (const gone of ["console-again", "version-update", "permissions-note", "console-status", "project-dir"]) {
|
||||
assert.ok(!INDEX_HTML.includes(`id="${gone}"`), `index.html still has #${gone}`);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Plan2Code",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"description": "A structured 4-step workflow methodology for AI-assisted software development",
|
||||
"keywords": [
|
||||
"ai",
|
||||
|
||||
Reference in new issue
Block a user