Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/changelog-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ permissions:

jobs:
changelog:
uses: WireCatLabs/cli-base/.github/workflows/changelog-guard.yml@ea16e6b6b800332d39c71e7b74a4ccc2cf548a60 # v0.109.0
uses: WireCatLabs/cli-base/.github/workflows/changelog-guard.yml@21b2f80c76fb46cf433deba6edb59cfbeb4b6676 # v0.112.0
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions:

jobs:
ci:
uses: WireCatLabs/cli-base/.github/workflows/node-ci.yml@ea16e6b6b800332d39c71e7b74a4ccc2cf548a60 # v0.109.0
uses: WireCatLabs/cli-base/.github/workflows/node-ci.yml@21b2f80c76fb46cf433deba6edb59cfbeb4b6676 # v0.112.0
with:
pack: ${{ inputs.pack || false }}
bun-run: pnpm build && pnpm smoke:bun
Expand Down Expand Up @@ -73,6 +73,12 @@ jobs:
run: pnpm build
- if: steps.scope.outputs.quick != 'true'
run: pnpm test
# Reads the argv log the tests just wrote; bin/release leaves it here with the tests. Node 22.16 loads the
# matrix's .ts program only with the flag.
- if: steps.scope.outputs.quick != 'true'
env:
NODE_OPTIONS: --experimental-strip-types
run: pnpm run --if-present test:matrix:check
- if: steps.scope.outputs.quick != 'true'
run: pnpm smoke:node

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/monthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
contents: read
actions: read
security-events: write
uses: WireCatLabs/cli-base/.github/workflows/release-checks.yml@ea16e6b6b800332d39c71e7b74a4ccc2cf548a60 # v0.109.0
uses: WireCatLabs/cli-base/.github/workflows/release-checks.yml@21b2f80c76fb46cf433deba6edb59cfbeb4b6676 # v0.112.0
with:
dependencies: true
languages: '["actions","javascript-typescript"]'
4 changes: 2 additions & 2 deletions .github/workflows/release-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
permissions:
contents: read
actions: write
uses: WireCatLabs/cli-base/.github/workflows/release-start.yml@ea16e6b6b800332d39c71e7b74a4ccc2cf548a60 # v0.109.0
uses: WireCatLabs/cli-base/.github/workflows/release-start.yml@21b2f80c76fb46cf433deba6edb59cfbeb4b6676 # v0.112.0
with:
app-client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
check: '[ -d kit ] || pnpm exec cli-dev live check --version "$VERSION"'
check: '[ -d kit ] || grep -qs "\"preset\": \"generic\"" template.json || pnpm exec cli-dev live check --version "$VERSION"'
secrets:
app-private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
contents: read
actions: read
security-events: write
uses: WireCatLabs/cli-base/.github/workflows/release-checks.yml@ea16e6b6b800332d39c71e7b74a4ccc2cf548a60 # v0.109.0
uses: WireCatLabs/cli-base/.github/workflows/release-checks.yml@21b2f80c76fb46cf433deba6edb59cfbeb4b6676 # v0.112.0

build:
needs: [checks, validation]
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
node_modules
dist/
coverage/
*.tsbuildinfo
Expand Down
7 changes: 4 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ Replace, your service's own:
`--json=a,b` and the MCP schema come from one schema (WC-CMD-19, WC-CMD-20); `show`; `create` and `update`.
- **The strict fake**, `src/testing/fake-comments.ts`: it refuses an unknown path, parameter or field, so a name typed
from memory fails a test instead of reaching the owner's account. Build yours from the documentation.
- **The tests**, `src/comments.test.ts` and `src/sample/transport.test.ts`. Keep each case for your commands: a deny
stops a read before any request, `--dry-run` sends nothing, a lost write is `outcome_unknown`, a recorded run is
named after its command, and the token reaches no output, run record or file.
- **The tests**, `src/comments.test.ts`, `src/commands/session.test.ts` and `src/sample/transport.test.ts`. Keep each
case for your commands: a deny stops a read before any request, `--dry-run` sends nothing, a lost write is
`outcome_unknown`, a recorded run is named after its command, `session start` keeps a token only once the service
took it, and the token reaches no output, run record or file.

Remove the sample only once your own commands and their tests cover each pattern above: the skeleton alone is below
the coverage floor, and the floor is never lowered (WC-TEST-11). To remove it, run
Expand Down
21 changes: 16 additions & 5 deletions bin/live
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
// scripts/live.sh with the token on stdin, records the pass in docs/dev/live-checks.txt and, when the branch has an
// open pull request, commits the record, pushes it and adds its line to the pull request's Conformance section.
//
// bin/live <keyring account> [arguments for scripts/live.sh, such as the test page's link]
// bin/live <keyring account> [--again] [arguments for scripts/live.sh, such as the test page's link]
//
// Linux only: it reads the keyring with secret-tool and runs scripts/live.sh with bash.
// The token is the keyring entry `service ydisk account <keyring account>`, stored once with
// secret-tool store --label="ydisk live check" service ydisk account <keyring account>
// It stays in this process and reaches scripts/live.sh on stdin only: never an argument, the environment or the
// screen. A version whose shipped code already has a record is not checked again.
// screen. A version whose shipped code already has a record is not checked again, and it says so; --again runs the
// check anyway, as after a change to scripts/live.sh alone, which the record does not cover.
import { execFileSync, spawnSync } from "node:child_process"
import { existsSync, readFileSync, realpathSync } from "node:fs"
import { join, resolve } from "node:path"
Expand Down Expand Up @@ -105,16 +106,26 @@ const check = async (account, version, args) => {
}

const main = async () => {
const [account, ...args] = process.argv.slice(2)
const [account, ...rest] = process.argv.slice(2)
const again = rest.includes("--again")
const args = rest.filter((arg) => arg !== "--again")
if (!account || account === "--help" || account === "-h") {
process.stdout.write(`Usage: ${join(ROOT, "bin/live")} <keyring account> [arguments for scripts/live.sh]\n`)
const usage = "<keyring account> [--again] [arguments for scripts/live.sh]"
process.stdout.write(`Usage: ${join(ROOT, "bin/live")} ${usage}\n`)
process.exitCode = account ? 0 : 2
return
}
if (existsSync(KIT)) fail("this is cli-template itself, which has no service to check")
const { version } = JSON.parse(readFileSync(PACKAGE_JSON, "utf8"))
const current = run("pnpm", ["exec", "cli-dev", "live", "check", "--version", version], { stdio: "ignore" })
const record = current.status === 0 ? recordOf(version) : await check(account, version, args)
const checked = current.status === 0 && !again
if (checked) {
process.stdout.write(
`Not run: ${version}'s shipped code already passed. Run with --again to check it anyway, as after a change to ` +
"scripts/live.sh alone.\n",
)
}
const record = checked ? recordOf(version) : await check(account, version, args)
if (!record) fail(`no record for ${version} in ${RECORDS}`)

const view = run("gh", ["pr", "view", "--json", "url,state,body"], { stdio: ["ignore", "pipe", "ignore"] })
Expand Down
74 changes: 53 additions & 21 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Publishes the version in package.json and tags it. Run on a clean `main` that matches origin/main. An agent may run
# it without --local; --local is for the owner's first release only. When npm already has that version, or a higher
# one, it raises it to the next free one through a pull request and publishes that (WC-REL-5). Nothing is published
# until `pnpm release:check` passes.
# until `pnpm release:check` passes: without --local its tests run in release.yml, the other checks here.
#
# bin/release # publishes from GitHub Actions (.github/workflows/release.yml, npm trusted publishing)
# bin/release --local # publishes from this computer: NPM_TOKEN if exported, else the keyring, else `npm login`
Expand Down Expand Up @@ -60,8 +60,9 @@ if [ -n "$first" ] && [ -n "$(npm view "$package" version --prefer-online 2>/dev
exit 1
fi
# The code released is the code a person checked against the real service (WC-REL-17). Only the template has kit/,
# and no service to check; every CLI made from it has a template.json too, so that file cannot tell them apart.
[ -d kit ] || pnpm exec cli-dev live check --version "$version"
# and no service to check; every CLI made from it has a template.json too, so that file cannot tell them apart. A CLI
# made with --preset generic is outside WireCat, and WC-REL-17 leaves its live check to its owner.
[ -d kit ] || grep -qs '"preset": "generic"' template.json || pnpm exec cli-dev live check --version "$version"
# A 404 for a package npm has never seen is "not published", like any other failure of `npm view`.
published() {
npm view "$package@$version" version --prefer-online >/dev/null 2>&1
Expand Down Expand Up @@ -121,17 +122,9 @@ published || folded=$(pnpm exec cli-dev changelog fold --land --version "$versio
[ -z "$folded" ] || echo "$folded"
rerun_if_changed "$@"

# Two sessions preparing the same number is normal; the second takes the next free one.
latest=$(npm view "$package" version --prefer-online 2>/dev/null || true)
versions=$(npm view "$package" versions --json --prefer-online 2>/dev/null || true)
next=$(pnpm exec cli-dev next-version "$version" "$latest" "$versions")
fragments=$(find changes -maxdepth 1 -type f -name '*.md' ! -name README.md 2>/dev/null | wc -l)
if [ "$next" != "$version" ]; then
taken=""
if published; then taken=1; why="$version is already on npm"; else why="$version is not above npm's latest $latest"; fi
next=$(pnpm exec cli-dev changelog level --next "$next")
echo "$why — publishing $next instead"
# A version npm already has keeps its changelog section; the unreleased one becomes the new version.
# Raises the version from $1 to $2 in package.json, src/version.ts and the CHANGELOG heading. With $3 set, npm has
# $1, so its section stays and the unreleased one becomes $2.
renumber() {
node -e 'const fs = require("fs"); const [o, n, taken] = process.argv.slice(1)
const swap = (file, from, to) => {
const text = fs.readFileSync(file, "utf8")
Expand All @@ -145,10 +138,30 @@ if [ "$next" != "$version" ]; then
const log = fs.readFileSync("CHANGELOG.md", "utf8")
if (taken && log.includes("\n## Unreleased\n")) swap("CHANGELOG.md", "\n## Unreleased\n", `\n## ${n} — ${today}\n`)
else if (taken) swap("CHANGELOG.md", "\n## ", `\n## ${n} — ${today}\n\n## `)
else swap("CHANGELOG.md", `\n## ${o} — `, `\n## ${n} — `)' "$version" "$next" "$taken"
else swap("CHANGELOG.md", `\n## ${o} — `, `\n## ${n} — `)' "$1" "$2" "$3"
}

# Two sessions preparing the same number is normal; the second takes the next free one.
latest=$(npm view "$package" version --prefer-online 2>/dev/null || true)
versions=$(npm view "$package" versions --json --prefer-online 2>/dev/null || true)
next=$(pnpm exec cli-dev next-version "$version" "$latest" "$versions")
fragments=$(find changes -maxdepth 1 -type f -name '*.md' ! -name README.md 2>/dev/null | wc -l)
if [ "$next" != "$version" ]; then
taken=""
if published; then taken=1; why="$version is already on npm"; else why="$version is not above npm's latest $latest"; fi
renumber "$version" "$next" "$taken"
pnpm exec cli-dev changelog fragments --collect "$next"
body="bin/release: $why. Only the number changes: package.json, src/version.ts, the CHANGELOG heading, and the
changes/ fragments collected under it.
# next-version keeps the level of the version it raises; the section, with the fragments now in it, may need more:
# an Added is a minor.
levelled=$(pnpm exec cli-dev changelog level --next "$next")
if [ "$levelled" != "$next" ]; then
levelled=$(pnpm exec cli-dev next-version "$levelled" "$latest" "$versions")
renumber "$next" "$levelled" ""
next=$levelled
fi
echo "$why — publishing $next instead"
body="bin/release: $why. Only the number changes, to the level the changelog needs: package.json, src/version.ts,
the CHANGELOG heading, and the changes/ fragments collected under it.

## Conformance

Expand All @@ -157,10 +170,20 @@ The release pull request of $version recorded the checks; this one changes only
rerun_if_changed "$@"
version=$next
elif [ "$fragments" -gt 0 ]; then
# The version was dated by hand; fragments merged since then still belong to it.
# The version was dated by hand; fragments merged since then still belong to it, and may need a higher level.
pnpm exec cli-dev changelog fragments --collect "$version"
land "release/$version-changes" "chore(changelog): collect changes/ into $version" \
"bin/release: the changes/ fragments merged since $version was dated, collected into its section."
levelled=$(pnpm exec cli-dev changelog level --next "$version")
if [ "$levelled" != "$version" ]; then
levelled=$(pnpm exec cli-dev next-version "$levelled" "$latest" "$versions")
renumber "$version" "$levelled" ""
echo "the changes/ fragments need $levelled — publishing it instead of $version"
land "release/$levelled" "chore(release): $levelled" \
"bin/release: the changes/ fragments merged since $version was dated need $levelled, collected into its section."
version=$levelled
else
land "release/$version-changes" "chore(changelog): collect changes/ into $version" \
"bin/release: the changes/ fragments merged since $version was dated, collected into its section."
fi
rerun_if_changed "$@"
fi
top=$(sed -n '/^## /{p;q;}' CHANGELOG.md)
Expand All @@ -174,7 +197,16 @@ if published; then
fi

echo "== checks for $version =="
pnpm release:check
if [ "$mode" = ci ]; then
# release.yml runs the tests on this commit before it publishes, and the test matrix check that needs their argv
# log. Run here too, they only time out on a busy computer.
checks=$(node -p 'require("./package.json").scripts["release:check"]' |
sed -e 's/pnpm test:coverage && //' -e 's/ && pnpm test:coverage//' \
-e 's/pnpm test:matrix:check && //' -e 's/ && pnpm test:matrix:check//')
sh -c "$checks"
else
pnpm release:check
fi

if [ "$mode" = ci ]; then
last_run() {
Expand Down
4 changes: 3 additions & 1 deletion bin/setup-github
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ const main = async () => {
process.stdout.write("main pushed\n")
}
} else {
gh(["repo", "create", REPO, "--public", "--description", description, "--source", ROOT, "--remote", "origin", "--push"])
// --push would send the branch checked out, which on a feature branch becomes the default and takes the ruleset.
gh(["repo", "create", REPO, "--public", "--description", description, "--source", ROOT, "--remote", "origin"])
git("push", "-q", "-u", "origin", "main")
process.stdout.write(`${REPO} created and main pushed\n`)
}
gh(["repo", "edit", REPO, "--delete-branch-on-merge"])
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/reference-clis.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ picked by the first question of the [design interview](skills/design-interview/S
| --- | --- |
| messenger | [whatsapp-cli](https://github.com/WireCatLabs/whatsapp-cli), then [tg-cli](https://github.com/WireCatLabs/tg-cli) and [max-cli](https://github.com/WireCatLabs/max-cli) |
| mail | [mail-cli](https://github.com/WireCatLabs/mail-cli) |
| files and documents | [notion-cli](https://github.com/WireCatLabs/notion-cli) for the sync and cli-core's document contracts, then [drive-cli](https://github.com/WireCatLabs/drive-cli) for the command tree |
| files and documents | [ydisk-cli](https://github.com/WireCatLabs/ydisk-cli) for cli-core's `documentLibraryCommands` and the contracts, [drive-cli](https://github.com/WireCatLabs/drive-cli) for the command tree, [notion-cli](https://github.com/WireCatLabs/notion-cli) for a source with a change feed |
| calendar | [gcal-cli](https://github.com/WireCatLabs/gcal-cli) |
| meetings | [zoom-cli](https://github.com/WireCatLabs/zoom-cli) |
| notes | [cli-memo](https://github.com/WireCatLabs/cli-memo) |
Expand Down
Loading
Loading