From db5c1e638d2679c06cff8ed02208d3a38ee6c02c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 14 Nov 2026 22:49:51 +0000 Subject: [PATCH 1/3] Add the roadmap issue form and the skill that files backlog issues. A roadmap idea asks what to build, why, and how to tell it is done. The skill opens that issue with the roadmap label and stops. Co-authored-by: Michael Whitham --- .cursor/skills/roadmap/SKILL.md | 48 ++++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/roadmap.yml | 37 +++++++++++++++++++++++ AGENTS.md | 6 ++++ CONTRIBUTING.md | 8 +++++ README.md | 9 ++++++ 6 files changed, 109 insertions(+) create mode 100644 .cursor/skills/roadmap/SKILL.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/roadmap.yml diff --git a/.cursor/skills/roadmap/SKILL.md b/.cursor/skills/roadmap/SKILL.md new file mode 100644 index 00000000..8f24a2f5 --- /dev/null +++ b/.cursor/skills/roadmap/SKILL.md @@ -0,0 +1,48 @@ +--- +name: roadmap +description: Files a GitHub issue for something Athletic Standard should build. Use when someone asks for a feature, or when you find a public request for Athletic Standard. The issue is labeled roadmap and stays in Backlog. +--- + +# Roadmap + +File one issue on `mwhitham/ath` and stop. The issue uses the label `roadmap`. It starts in Backlog. Do not set a project column. Do not move anything to Up next. + +## Before you open an issue + +Search open issues with the `roadmap` label. + +```sh +gh issue list --repo mwhitham/ath --label roadmap --state open --limit 100 +``` + +If one already asks for the same thing, comment on that issue. Do not open a second issue. + +```sh +gh issue comment NUMBER --repo mwhitham/ath --body "BODY" +``` + +## What to write + +Use a few plain sentences under these headings: + +```markdown +## What to build + +## Why + +## Done when +``` + +Add a picture or a simple diagram only when the words need it. + +Leave out a person's real health numbers, dates, and places. Say what was asked. Link the public post. + +## Open the issue + +```sh +gh issue create --repo mwhitham/ath --label roadmap --title "TITLE" --body "BODY" +``` + +If the command fails, report the error and stop. + +Reply with the issue link. Stop. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..0086358d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/.github/ISSUE_TEMPLATE/roadmap.yml b/.github/ISSUE_TEMPLATE/roadmap.yml new file mode 100644 index 00000000..125b233c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/roadmap.yml @@ -0,0 +1,37 @@ +name: Roadmap idea +description: Something Athletic Standard should build. It starts in Backlog. +labels: + - roadmap +body: + - type: markdown + attributes: + value: | + Write a few plain sentences. Leave out real health numbers, dates, and places. + - type: textarea + id: what + attributes: + label: What to build + description: A few plain sentences. + validations: + required: true + - type: textarea + id: why + attributes: + label: Why + description: Why this is worth building. + validations: + required: true + - type: textarea + id: done + attributes: + label: Done when + description: How we will know this is finished. + validations: + required: true + - type: textarea + id: example + attributes: + label: Example + description: Optional. A picture or a simple diagram, only if the words need it. + validations: + required: false diff --git a/AGENTS.md b/AGENTS.md index 6ad1674e..9320579a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -39,6 +39,12 @@ describe released 0.x behavior. - **Chat:** talking to a person follows [`.cursor/rules/plain-english.mdc`](.cursor/rules/plain-english.mdc). One idea per sentence, the point before the reason, no shop talk, one numbered question at a time. - **SDNN and RMSSD are different statistics** (`hrv_sdnn` vs `hrv_rmssd`); never combine them in one baseline. +## Roadmap + +Roadmap ideas are GitHub issues labeled `roadmap` on `mwhitham/ath`. File one by following [`.cursor/skills/roadmap/SKILL.md`](.cursor/skills/roadmap/SKILL.md). Stop when the issue is open. Do not move an issue to Up next. + +Build from Up next on the public project titled Roadmap: . Take one item. Set it to Now. Open a pull request that closes the issue. Closing the issue moves it to Done. Do not start from Backlog. + ## Verification `pnpm check:public-data && pnpm typecheck && pnpm test && pnpm build` must pass before any commit. The fixture (`examples/demo-athlete/`) is deterministic — regenerate, don't hand-edit. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 348b619e..d91a8814 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,14 @@ Use a feature branch and open a pull request against `main`. Keep each commit to one logical change. +## Roadmap + +Use the Roadmap idea issue form for something to build. The issue is labeled `roadmap` and starts in Backlog. The repository owner moves work to Up next. Build from Up next. + +The public board is the project titled Roadmap: . + +Do not put real health numbers, dates, or places in an issue. Describe the request. A public issue keeps whatever you write. + ## Protect health data Never commit a real health export or athlete file. This rule applies to public and private repositories because clones, logs, and old commits retain deleted data. diff --git a/README.md b/README.md index ee9ec81e..8c1de654 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,15 @@ separate when two devices measure the same quantity. Not an app, not a coach, not medical advice. +## Roadmap + +What is being built is on the public project titled Roadmap: +. + +A new idea starts in Backlog. It is not chosen yet. The repository owner +moves an idea to Up next when it should be built. Open a roadmap idea with +the issue form. + ## Security The database contains sensitive health and training data. Athletic Standard creates From 0764f7d4cd40a2ef601266e4292f2b7f40a7119d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 15 Nov 2026 20:49:00 +0000 Subject: [PATCH 2/3] Create the roadmap board from a workflow. GitHub's workflow token cannot create a personal project, and the built-in project buttons have no API. The workflow uses a personal token to create the label, the public project, and the four columns, then moves new roadmap issues to Backlog and closed ones to Done. Co-authored-by: Michael Whitham --- .github/workflows/roadmap.yml | 43 ++++ AGENTS.md | 2 + CONTRIBUTING.md | 2 +- scripts/roadmap-board.ts | 408 ++++++++++++++++++++++++++++++++++ tests/roadmap-board.test.ts | 65 ++++++ 5 files changed, 519 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/roadmap.yml create mode 100644 scripts/roadmap-board.ts create mode 100644 tests/roadmap-board.test.ts diff --git a/.github/workflows/roadmap.yml b/.github/workflows/roadmap.yml new file mode 100644 index 00000000..c78f8e87 --- /dev/null +++ b/.github/workflows/roadmap.yml @@ -0,0 +1,43 @@ +# Keeps the public Roadmap project in step with issues labeled roadmap. +# GitHub's workflow token cannot create a project on a personal account. +# Add the repository owner's personal access token as ROADMAP_PROJECT_TOKEN, +# then run this workflow from the Actions tab. + +name: Roadmap + +on: + workflow_dispatch: + issues: + types: [opened, labeled, closed, reopened] + +permissions: + contents: read + +jobs: + ensure-board: + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Create the label, project, and columns + env: + ROADMAP_PROJECT_TOKEN: ${{ secrets.ROADMAP_PROJECT_TOKEN }} + REPO: ${{ github.repository }} + run: node --experimental-strip-types scripts/roadmap-board.ts ensure + + sync-item: + if: github.event_name == 'issues' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Move the card + env: + ROADMAP_PROJECT_TOKEN: ${{ secrets.ROADMAP_PROJECT_TOKEN }} + REPO: ${{ github.repository }} + run: node --experimental-strip-types scripts/roadmap-board.ts sync diff --git a/AGENTS.md b/AGENTS.md index 9320579a..a8dcc333 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,6 +43,8 @@ describe released 0.x behavior. Roadmap ideas are GitHub issues labeled `roadmap` on `mwhitham/ath`. File one by following [`.cursor/skills/roadmap/SKILL.md`](.cursor/skills/roadmap/SKILL.md). Stop when the issue is open. Do not move an issue to Up next. +The Roadmap workflow adds a new roadmap issue to Backlog and moves a closed one to Done. It does not set Up next or Now. + Build from Up next on the public project titled Roadmap: . Take one item. Set it to Now. Open a pull request that closes the issue. Closing the issue moves it to Done. Do not start from Backlog. ## Verification diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d91a8814..baf1c976 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Use a feature branch and open a pull request against `main`. Keep each commit to ## Roadmap -Use the Roadmap idea issue form for something to build. The issue is labeled `roadmap` and starts in Backlog. The repository owner moves work to Up next. Build from Up next. +Use the Roadmap idea issue form for something to build. The issue is labeled `roadmap` and starts in Backlog. The Roadmap workflow places it on the board, and moves it to Done when the issue closes. The repository owner moves work to Up next. Build from Up next. The public board is the project titled Roadmap: . diff --git a/scripts/roadmap-board.ts b/scripts/roadmap-board.ts new file mode 100644 index 00000000..5df334d6 --- /dev/null +++ b/scripts/roadmap-board.ts @@ -0,0 +1,408 @@ +/** + * Keeps the public Roadmap project in step with issues labeled roadmap. + * + * GitHub's workflow token cannot create a project on a personal account, and + * the built-in project buttons have no API. This script uses a personal token + * from ROADMAP_PROJECT_TOKEN. It never sets Up next or Now. + */ +import { appendFileSync, readFileSync } from "node:fs"; + +const STATUS = [ + { name: "Backlog", color: "GRAY", description: "Not chosen yet.", renameFrom: ["Todo"] }, + { name: "Up next", color: "YELLOW", description: "Chosen to build.", renameFrom: [] }, + { name: "Now", color: "GREEN", description: "Being built.", renameFrom: ["In Progress"] }, + { name: "Done", color: "PURPLE", description: "Finished.", renameFrom: [] }, +] as const; + +const LABEL = { + name: "roadmap", + color: "1D76DB", + description: "A request for something to build. Starts in Backlog.", +}; + +const TOKEN_HELP = [ + "ROADMAP_PROJECT_TOKEN is not set.", + "Add a personal access token as a repository secret named ROADMAP_PROJECT_TOKEN.", + "A classic token needs the project and public_repo scopes.", + "A fine-grained token needs account Projects read and write, and Issues read and write on this repository.", + "The token must belong to the repository owner.", + "Then run the Roadmap workflow from the Actions tab.", +].join(" "); + +export type IssueEvent = { + action?: string; + label?: { name?: string }; + issue?: { + node_id?: string; + pull_request?: unknown; + labels?: { name?: string }[]; + }; +}; + +export type CardAction = { kind: "ignore" } | { kind: "add" | "set"; status: "Backlog" | "Done" }; + +type ExistingColumn = { id: string; name: string; color: string; description: string }; +type Column = { id?: string; name: string; color: string; description: string }; + +/** + * What to do with one issue event. + * `add` sets Backlog only when the card is new. `set` always sets the status. + */ +export function cardAction(event: IssueEvent): CardAction { + if (event.issue?.pull_request) return { kind: "ignore" }; + const names = (event.issue?.labels ?? []).flatMap((label) => (label.name ? [label.name] : [])); + if (!names.includes(LABEL.name)) return { kind: "ignore" }; + if (event.action === "closed") return { kind: "set", status: "Done" }; + if (event.action === "reopened") return { kind: "set", status: "Backlog" }; + if (event.action === "opened") return { kind: "add", status: "Backlog" }; + if (event.action === "labeled" && event.label?.name === LABEL.name) return { kind: "add", status: "Backlog" }; + return { kind: "ignore" }; +} + +/** + * Four status names, reusing an existing option id when one is already there. + * Any other column is kept. Done keeps its id so it stays the finished column. + */ +export function statusColumns(existing: ExistingColumn[]): Column[] { + const unused = existing.map((option) => ({ ...option })); + const take = (names: readonly string[]): ExistingColumn | null => { + const index = unused.findIndex((option) => names.includes(option.name)); + if (index === -1) return null; + const [taken] = unused.splice(index, 1); + return taken ?? null; + }; + const columns: Column[] = STATUS.map((column) => { + const current = take([column.name]) ?? take(column.renameFrom); + if (!current) return { name: column.name, color: column.color, description: column.description }; + return { id: current.id, name: column.name, color: column.color, description: column.description }; + }); + for (const option of unused) columns.push(option); + return columns; +} + +type RestBody = { message?: string; errors?: { code?: string }[] }; + +async function github(token: string, method: string, url: string, payload?: unknown): Promise<{ status: number; body: unknown }> { + const init: RequestInit = { + method, + headers: { + Authorization: `Bearer ${token}`, + Accept: "application/vnd.github+json", + "Content-Type": "application/json", + "User-Agent": "athleticstandard-roadmap", + "X-GitHub-Api-Version": "2022-11-28", + }, + }; + if (payload !== undefined) init.body = JSON.stringify(payload); + const response = await fetch(url, init); + const text = await response.text(); + return { status: response.status, body: text ? JSON.parse(text) as unknown : {} }; +} + +async function graphql(token: string, query: string, variables: Record): Promise { + const { status, body } = await github(token, "POST", "https://api.github.com/graphql", { query, variables }); + const parsed = body as { data?: T; errors?: { message: string }[]; message?: string }; + if (status !== 200 || parsed.errors) { + const message = parsed.errors?.map((error) => error.message).join("\n") || parsed.message; + throw new Error(message || `GitHub API returned ${status}.`); + } + if (parsed.data === undefined) throw new Error("GitHub API returned no data."); + return parsed.data; +} + +async function ensureLabel(token: string, repo: string): Promise { + const url = `https://api.github.com/repos/${repo}/labels`; + const created = await github(token, "POST", url, LABEL); + if (created.status === 201) return; + const body = created.body as RestBody; + const exists = created.status === 422 && body.errors?.some((error) => error.code === "already_exists"); + if (!exists) throw new Error(body.message || `Could not create the roadmap label (${created.status}).`); + const updated = await github(token, "PATCH", `${url}/${LABEL.name}`, LABEL); + if (updated.status !== 200) { + const updateBody = updated.body as RestBody; + throw new Error(updateBody.message || `Could not update the roadmap label (${updated.status}).`); + } +} + +type ProjectNode = { + id: string; + number: number; + title: string; + url: string; + repositories: { nodes: { nameWithOwner: string }[] }; +}; + +type OwnerContext = { + viewer: { id: string; login: string }; + repository: { id: string } | null; + user: { projectsV2: { nodes: ProjectNode[] } } | null; +}; + +async function loadOwner(token: string, owner: string, name: string): Promise { + const data = await graphql( + token, + `query($owner: String!, $name: String!) { + viewer { id login } + repository(owner: $owner, name: $name) { id } + user(login: $owner) { + projectsV2(first: 50, query: "Roadmap") { + nodes { + id + number + title + url + repositories(first: 20) { nodes { nameWithOwner } } + } + } + } + }`, + { owner, name }, + ); + if (data.viewer.login !== owner) throw new Error("The token must belong to the repository owner."); + if (!data.repository || !data.user) throw new Error("The repository was not found."); + return data; +} + +function chooseProject(projects: ProjectNode[], repo: string): ProjectNode | null { + const named = projects.filter((project) => project.title === "Roadmap"); + const linked = (project: ProjectNode) => project.repositories.nodes.some((repository) => repository.nameWithOwner === repo); + return named.find(linked) ?? named.find((project) => project.repositories.nodes.length === 0) ?? null; +} + +async function createProject(token: string, ownerId: string, repositoryId: string): Promise<{ id: string; url: string }> { + const data = await graphql<{ createProjectV2: { projectV2: { id: string; url: string } } }>( + token, + `mutation($ownerId: ID!, $repositoryId: ID!) { + createProjectV2(input: { ownerId: $ownerId, title: "Roadmap", repositoryId: $repositoryId }) { + projectV2 { id url } + } + }`, + { ownerId, repositoryId }, + ); + return data.createProjectV2.projectV2; +} + +async function publishProject(token: string, projectId: string): Promise { + await graphql( + token, + `mutation($projectId: ID!) { + updateProjectV2(input: { + projectId: $projectId + title: "Roadmap" + public: true + shortDescription: "What is being built for Athletic Standard." + }) { + projectV2 { url } + } + }`, + { projectId }, + ); +} + +function alreadyThere(error: unknown): boolean { + return error instanceof Error && /already/i.test(error.message); +} + +async function linkRepository(token: string, projectId: string, repositoryId: string, alreadyLinked: boolean): Promise { + if (alreadyLinked) return; + try { + await graphql( + token, + `mutation($projectId: ID!, $repositoryId: ID!) { + linkProjectV2ToRepository(input: { projectId: $projectId, repositoryId: $repositoryId }) { + repository { id } + } + }`, + { projectId, repositoryId }, + ); + } catch (error) { + if (!alreadyThere(error)) throw error; + } +} + +type StatusField = { id: string; name: string; options: ExistingColumn[] }; + +function isStatusField(node: { name?: string; id?: string; options?: ExistingColumn[] } | null): node is StatusField { + return node?.name === "Status" && typeof node.id === "string" && Array.isArray(node.options); +} + +async function loadStatus(token: string, projectId: string): Promise<{ url: string; field: StatusField }> { + const data = await graphql<{ + node: { url: string; fields: { nodes: ({ name?: string; id?: string; options?: ExistingColumn[] } | null)[] } }; + }>( + token, + `query($id: ID!) { + node(id: $id) { + ... on ProjectV2 { + url + fields(first: 30) { + nodes { + ... on ProjectV2SingleSelectField { + id + name + options { id name color description } + } + } + } + } + } + }`, + { id: projectId }, + ); + const field = data.node.fields.nodes.find(isStatusField); + if (!field) throw new Error("The project has no Status field."); + return { url: data.node.url, field }; +} + +async function writeStatus(token: string, field: StatusField): Promise { + await graphql( + token, + `mutation($fieldId: ID!, $options: [ProjectV2SingleSelectFieldOptionInput!]!) { + updateProjectV2Field(input: { fieldId: $fieldId, singleSelectOptions: $options }) { + projectV2Field { ... on ProjectV2SingleSelectField { id } } + } + }`, + { fieldId: field.id, options: statusColumns(field.options) }, + ); +} + +function optionId(options: ExistingColumn[], name: string): string { + const option = options.find((item) => item.name === name); + if (!option) throw new Error(`The Status field has no ${name} column. Run the Roadmap workflow from the Actions tab.`); + return option.id; +} + +async function itemOnProject(token: string, issueId: string, projectId: string): Promise<{ id: string } | null> { + const data = await graphql<{ node: { projectItems: { nodes: { id: string; project: { id: string } }[] } } }>( + token, + `query($id: ID!) { + node(id: $id) { + ... on Issue { + projectItems(first: 20) { nodes { id project { id } } } + } + } + }`, + { id: issueId }, + ); + return data.node.projectItems.nodes.find((item) => item.project.id === projectId) ?? null; +} + +async function addItem(token: string, projectId: string, issueId: string): Promise { + try { + const data = await graphql<{ addProjectV2ItemById: { item: { id: string } } }>( + token, + `mutation($projectId: ID!, $contentId: ID!) { + addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) { + item { id } + } + }`, + { projectId, contentId: issueId }, + ); + return data.addProjectV2ItemById.item.id; + } catch (error) { + if (!alreadyThere(error)) throw error; + const existing = await itemOnProject(token, issueId, projectId); + if (!existing) throw error; + return existing.id; + } +} + +async function setStatus(token: string, projectId: string, itemId: string, fieldId: string, option: string): Promise { + await graphql( + token, + `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $projectId + itemId: $itemId + fieldId: $fieldId + value: { singleSelectOptionId: $optionId } + }) { + projectV2Item { id } + } + }`, + { projectId, itemId, fieldId, optionId: option }, + ); +} + +function repositoryParts(): { owner: string; name: string; repo: string } { + const repo = process.env.REPO; + const parts = repo?.split("/") ?? []; + const owner = parts[0]; + const name = parts[1]; + if (!repo || parts.length !== 2 || !owner || !name) throw new Error("REPO must be owner/name."); + return { owner, name, repo }; +} + +function tokenOrNull(): string | null { + const token = process.env.ROADMAP_PROJECT_TOKEN; + return token ? token : null; +} + +async function ensure(): Promise { + const token = tokenOrNull(); + if (!token) throw new Error(TOKEN_HELP); + const { owner, name, repo } = repositoryParts(); + await ensureLabel(token, repo); + const context = await loadOwner(token, owner, name); + let project = chooseProject(context.user?.projectsV2.nodes ?? [], repo); + const created = !project; + if (!project) { + if (!context.repository) throw new Error("The repository was not found."); + project = { + ...(await createProject(token, context.viewer.id, context.repository.id)), + number: 0, + title: "Roadmap", + repositories: { nodes: [] }, + }; + } + await publishProject(token, project.id); + if (!context.repository) throw new Error("The repository was not found."); + const linked = !created && project.repositories.nodes.some((repository) => repository.nameWithOwner === repo); + await linkRepository(token, project.id, context.repository.id, linked); + const status = await loadStatus(token, project.id); + await writeStatus(token, status.field); + console.log(status.url); + if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, `Roadmap board: ${status.url}\n`); +} + +async function sync(): Promise { + const token = tokenOrNull(); + if (!token) { + console.error(TOKEN_HELP); + return; + } + const path = process.env.GITHUB_EVENT_PATH; + if (!path) throw new Error("GITHUB_EVENT_PATH is not set."); + const event = JSON.parse(readFileSync(path, "utf8")) as IssueEvent; + const action = cardAction(event); + if (action.kind === "ignore") return; + const issueId = event.issue?.node_id; + if (!issueId) throw new Error("The issue event has no node id."); + const { owner, name, repo } = repositoryParts(); + const context = await loadOwner(token, owner, name); + const project = chooseProject(context.user?.projectsV2.nodes ?? [], repo); + if (!project) { + console.error("No Roadmap project is linked to this repository. Run the Roadmap workflow from the Actions tab."); + return; + } + const status = await loadStatus(token, project.id); + let item = await itemOnProject(token, issueId, project.id); + const created = !item; + if (!item) item = { id: await addItem(token, project.id, issueId) }; + if (action.kind === "add" && !created) return; + await setStatus(token, project.id, item.id, status.field.id, optionId(status.field.options, action.status)); +} + +async function main(): Promise { + const command = process.argv[2]; + if (command === "ensure") await ensure(); + else if (command === "sync") await sync(); + else throw new Error("Use ensure or sync."); +} + +if (process.argv[1]?.endsWith("roadmap-board.ts")) { + main().catch((error: unknown) => { + console.error(error instanceof Error ? error.message : error); + process.exitCode = 1; + }); +} diff --git a/tests/roadmap-board.test.ts b/tests/roadmap-board.test.ts new file mode 100644 index 00000000..cb121a68 --- /dev/null +++ b/tests/roadmap-board.test.ts @@ -0,0 +1,65 @@ +import { describe, expect, it } from "vitest"; +import { cardAction, statusColumns } from "../scripts/roadmap-board.js"; + +const roadmap = { name: "roadmap" }; + +describe("roadmap card moves", () => { + it("puts a new roadmap issue in Backlog and a closed one in Done", () => { + expect(cardAction({ action: "opened", issue: { labels: [roadmap] } })).toEqual({ + kind: "add", + status: "Backlog", + }); + expect(cardAction({ action: "labeled", label: roadmap, issue: { labels: [roadmap] } })).toEqual({ + kind: "add", + status: "Backlog", + }); + expect(cardAction({ action: "closed", issue: { labels: [roadmap] } })).toEqual({ + kind: "set", + status: "Done", + }); + expect(cardAction({ action: "reopened", issue: { labels: [roadmap] } })).toEqual({ + kind: "set", + status: "Backlog", + }); + }); + + it("leaves other issues alone and never chooses Up next or Now", () => { + expect(cardAction({ action: "opened", issue: { labels: [{ name: "bug" }] } })).toEqual({ kind: "ignore" }); + expect(cardAction({ action: "labeled", label: { name: "bug" }, issue: { labels: [roadmap] } })).toEqual({ + kind: "ignore", + }); + expect(cardAction({ action: "closed", issue: { labels: [], pull_request: {} } })).toEqual({ kind: "ignore" }); + + for (const action of ["opened", "labeled", "closed", "reopened"]) { + const plan = cardAction({ action, label: roadmap, issue: { labels: [roadmap] } }); + expect(plan.kind === "ignore" || plan.status === "Backlog" || plan.status === "Done").toBe(true); + } + }); +}); + +describe("roadmap columns", () => { + it("renames the default columns and keeps Done", () => { + const columns = statusColumns([ + { id: "todo", name: "Todo", color: "GRAY", description: "" }, + { id: "progress", name: "In Progress", color: "YELLOW", description: "" }, + { id: "done", name: "Done", color: "PURPLE", description: "" }, + ]); + expect(columns.map((column) => column.name)).toEqual(["Backlog", "Up next", "Now", "Done"]); + expect(columns.find((column) => column.name === "Backlog")?.id).toBe("todo"); + expect(columns.find((column) => column.name === "Now")?.id).toBe("progress"); + expect(columns.find((column) => column.name === "Done")?.id).toBe("done"); + expect(columns.find((column) => column.name === "Up next")?.id).toBeUndefined(); + }); + + it("keeps a column the owner added", () => { + const columns = statusColumns([ + { id: "backlog", name: "Backlog", color: "GRAY", description: "Not chosen yet." }, + { id: "next", name: "Up next", color: "YELLOW", description: "Chosen to build." }, + { id: "now", name: "Now", color: "GREEN", description: "Being built." }, + { id: "done", name: "Done", color: "PURPLE", description: "Finished." }, + { id: "extra", name: "Later", color: "BLUE", description: "Waiting." }, + ]); + expect(columns.map((column) => column.name)).toEqual(["Backlog", "Up next", "Now", "Done", "Later"]); + expect(columns.find((column) => column.name === "Later")?.id).toBe("extra"); + }); +}); From b7e2612b2bfe11379fe8788afeb5bc3f156a734c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 15 Nov 2026 22:49:20 +0000 Subject: [PATCH 3/3] Point the roadmap workflow at project 3. The board already exists. Setup configures that project and does not create another one. Co-authored-by: Michael Whitham --- .github/workflows/roadmap.yml | 2 ++ AGENTS.md | 2 +- CONTRIBUTING.md | 2 +- README.md | 2 +- scripts/roadmap-board.ts | 66 ++++++++++++++++++----------------- tests/roadmap-board.test.ts | 11 +++++- 6 files changed, 49 insertions(+), 36 deletions(-) diff --git a/.github/workflows/roadmap.yml b/.github/workflows/roadmap.yml index c78f8e87..5106a890 100644 --- a/.github/workflows/roadmap.yml +++ b/.github/workflows/roadmap.yml @@ -25,6 +25,7 @@ jobs: - name: Create the label, project, and columns env: ROADMAP_PROJECT_TOKEN: ${{ secrets.ROADMAP_PROJECT_TOKEN }} + ROADMAP_PROJECT_NUMBER: "3" REPO: ${{ github.repository }} run: node --experimental-strip-types scripts/roadmap-board.ts ensure @@ -39,5 +40,6 @@ jobs: - name: Move the card env: ROADMAP_PROJECT_TOKEN: ${{ secrets.ROADMAP_PROJECT_TOKEN }} + ROADMAP_PROJECT_NUMBER: "3" REPO: ${{ github.repository }} run: node --experimental-strip-types scripts/roadmap-board.ts sync diff --git a/AGENTS.md b/AGENTS.md index a8dcc333..fc58cdac 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -45,7 +45,7 @@ Roadmap ideas are GitHub issues labeled `roadmap` on `mwhitham/ath`. File one by The Roadmap workflow adds a new roadmap issue to Backlog and moves a closed one to Done. It does not set Up next or Now. -Build from Up next on the public project titled Roadmap: . Take one item. Set it to Now. Open a pull request that closes the issue. Closing the issue moves it to Done. Do not start from Backlog. +Build from Up next on the public project titled Roadmap: . Take one item. Set it to Now. Open a pull request that closes the issue. Closing the issue moves it to Done. Do not start from Backlog. ## Verification diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index baf1c976..f6915e26 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ Use a feature branch and open a pull request against `main`. Keep each commit to Use the Roadmap idea issue form for something to build. The issue is labeled `roadmap` and starts in Backlog. The Roadmap workflow places it on the board, and moves it to Done when the issue closes. The repository owner moves work to Up next. Build from Up next. -The public board is the project titled Roadmap: . +The public board is the project titled Roadmap: . Do not put real health numbers, dates, or places in an issue. Describe the request. A public issue keeps whatever you write. diff --git a/README.md b/README.md index 8c1de654..0400a614 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Not an app, not a coach, not medical advice. ## Roadmap What is being built is on the public project titled Roadmap: -. +. A new idea starts in Backlog. It is not chosen yet. The repository owner moves an idea to Up next when it should be built. Open a roadmap idea with diff --git a/scripts/roadmap-board.ts b/scripts/roadmap-board.ts index 5df334d6..d22f01e6 100644 --- a/scripts/roadmap-board.ts +++ b/scripts/roadmap-board.ts @@ -163,23 +163,39 @@ async function loadOwner(token: string, owner: string, name: string): Promise project.title === "Roadmap"); - const linked = (project: ProjectNode) => project.repositories.nodes.some((repository) => repository.nameWithOwner === repo); - return named.find(linked) ?? named.find((project) => project.repositories.nodes.length === 0) ?? null; +/** The live board. Override with ROADMAP_PROJECT_NUMBER. */ +export function projectNumber(raw: string | undefined): number { + const value = raw === undefined || raw === "" ? "3" : raw; + if (!/^[1-9]\d*$/.test(value)) throw new Error("ROADMAP_PROJECT_NUMBER must be a positive integer."); + return Number(value); } -async function createProject(token: string, ownerId: string, repositoryId: string): Promise<{ id: string; url: string }> { - const data = await graphql<{ createProjectV2: { projectV2: { id: string; url: string } } }>( - token, - `mutation($ownerId: ID!, $repositoryId: ID!) { - createProjectV2(input: { ownerId: $ownerId, title: "Roadmap", repositoryId: $repositoryId }) { - projectV2 { id url } - } - }`, - { ownerId, repositoryId }, - ); - return data.createProjectV2.projectV2; +async function loadProjectByNumber(token: string, owner: string, number: number): Promise { + try { + const data = await graphql<{ user: { projectV2: ProjectNode | null } | null }>( + token, + `query($owner: String!, $number: Int!) { + user(login: $owner) { + projectV2(number: $number) { + id + number + title + url + repositories(first: 20) { nodes { nameWithOwner } } + } + } + }`, + { owner, number }, + ); + const project = data.user?.projectV2; + if (!project) throw new Error(`Project ${number} was not found.`); + return project; + } catch (error) { + if (error instanceof Error && /Could not resolve|not found/i.test(error.message)) { + throw new Error(`Project ${number} was not found for ${owner}. The token must belong to the repository owner.`); + } + throw error; + } } async function publishProject(token: string, projectId: string): Promise { @@ -344,20 +360,10 @@ async function ensure(): Promise { const { owner, name, repo } = repositoryParts(); await ensureLabel(token, repo); const context = await loadOwner(token, owner, name); - let project = chooseProject(context.user?.projectsV2.nodes ?? [], repo); - const created = !project; - if (!project) { - if (!context.repository) throw new Error("The repository was not found."); - project = { - ...(await createProject(token, context.viewer.id, context.repository.id)), - number: 0, - title: "Roadmap", - repositories: { nodes: [] }, - }; - } + const project = await loadProjectByNumber(token, owner, projectNumber(process.env.ROADMAP_PROJECT_NUMBER)); await publishProject(token, project.id); if (!context.repository) throw new Error("The repository was not found."); - const linked = !created && project.repositories.nodes.some((repository) => repository.nameWithOwner === repo); + const linked = project.repositories.nodes.some((repository) => repository.nameWithOwner === repo); await linkRepository(token, project.id, context.repository.id, linked); const status = await loadStatus(token, project.id); await writeStatus(token, status.field); @@ -380,11 +386,7 @@ async function sync(): Promise { if (!issueId) throw new Error("The issue event has no node id."); const { owner, name, repo } = repositoryParts(); const context = await loadOwner(token, owner, name); - const project = chooseProject(context.user?.projectsV2.nodes ?? [], repo); - if (!project) { - console.error("No Roadmap project is linked to this repository. Run the Roadmap workflow from the Actions tab."); - return; - } + const project = await loadProjectByNumber(token, owner, projectNumber(process.env.ROADMAP_PROJECT_NUMBER)); const status = await loadStatus(token, project.id); let item = await itemOnProject(token, issueId, project.id); const created = !item; diff --git a/tests/roadmap-board.test.ts b/tests/roadmap-board.test.ts index cb121a68..81d85ed8 100644 --- a/tests/roadmap-board.test.ts +++ b/tests/roadmap-board.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { cardAction, statusColumns } from "../scripts/roadmap-board.js"; +import { cardAction, projectNumber, statusColumns } from "../scripts/roadmap-board.js"; const roadmap = { name: "roadmap" }; @@ -37,6 +37,15 @@ describe("roadmap card moves", () => { }); }); +describe("roadmap project number", () => { + it("uses project 3 unless another number is set", () => { + expect(projectNumber(undefined)).toBe(3); + expect(projectNumber("")).toBe(3); + expect(projectNumber("3")).toBe(3); + expect(() => projectNumber("0")).toThrow(/positive integer/); + }); +}); + describe("roadmap columns", () => { it("renames the default columns and keeps Done", () => { const columns = statusColumns([