upstream-cherry-pick
Audit OTTO's two upstream forks (pi-dev at ../pi, gsd-pi at ../gsd-pi) for fixes and features worth porting. Classifies each commit by applicability and severity, scores conflict risk against docs/UPSTREAM-SYNC.md, files GitHub issues for actionable candidates, and writes a triage report. Use when checking what's new upstream, building the cherry-pick backlog, or before a release. Safe to run in background mode — produces durable artifacts (issues + report file).
- License 许可
- MIT
- 所属仓库
- cmetech/otto-cli
- 最近更新
- 2026-06-17
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- upstream-cherry-pick
- description
- Audit OTTO's two upstream forks (pi-dev at ../pi, gsd-pi at ../gsd-pi) for fixes and features worth porting. Classifies each commit by applicability and severity, scores conflict risk against docs/UPSTREAM-SYNC.md, files GitHub issues for actionable candidates, and writes a triage report. Use when checking what's new upstream, building the cherry-pick backlog, or before a release. Safe to run in background mode — produces durable artifacts (issues + report file).
02 资源文件 56
- 脚本__tests__/integration.test.mjs11.9 KB
- 脚本__tests__/run.test.mjs8.5 KB
- 脚本bin/run.mjs20.6 KB
- 参考文档README.md741 B
- 脚本scripts/__fixtures__/.gitkeep—
- 脚本scripts/__fixtures__/config.bad-regex.json170 B
- 脚本scripts/__fixtures__/config.valid.json1.1 KB
- 脚本scripts/__fixtures__/ledger.sample.md751 B
- 脚本scripts/__tests__/.gitkeep—
- 脚本scripts/__tests__/apply-context-upgrades.test.mjs6.8 KB
- 脚本scripts/__tests__/build-issue-payload.test.mjs23.5 KB
- 脚本scripts/__tests__/classify-applicability.test.mjs2.2 KB
- 脚本scripts/__tests__/classify-severity.test.mjs2.6 KB
- 脚本scripts/__tests__/dedup-check.test.mjs2.2 KB
- 脚本scripts/__tests__/ensure-labels.test.mjs3.9 KB
- 脚本scripts/__tests__/fetch-pr-context.test.mjs6.7 KB
- 脚本scripts/__tests__/file-issue.test.mjs2.5 KB
- 脚本scripts/__tests__/harvest-commits.test.mjs6.4 KB
- 脚本scripts/__tests__/init-scaffold.test.mjs6.3 KB
- 脚本scripts/__tests__/parse-config.test.mjs3.4 KB
- 脚本scripts/__tests__/parse-guidance.test.mjs4.0 KB
- 脚本scripts/__tests__/parse-ledger.test.mjs1.3 KB
- 脚本scripts/__tests__/preflight.test.mjs14.8 KB
- 脚本scripts/__tests__/revalidate-do-not-port.test.mjs2.2 KB
- 脚本scripts/__tests__/run-audit-guidance.test.mjs1.8 KB
- 脚本scripts/__tests__/run-audit-sweep.test.mjs2.1 KB
- 脚本scripts/__tests__/score-conflict-risk.test.mjs1.8 KB
- 脚本scripts/__tests__/state.test.mjs1.9 KB
- 脚本scripts/__tests__/supersession-check.test.mjs4.0 KB
- 脚本scripts/__tests__/sweep-backlog.test.mjs7.7 KB
- 脚本scripts/__tests__/write-report.test.mjs5.5 KB
- 脚本scripts/__tests__/write-sweep-report.test.mjs2.3 KB
- 脚本scripts/.gitkeep—
- 脚本scripts/apply-context-upgrades.mjs6.1 KB
- 脚本scripts/build-issue-payload.mjs15.5 KB
- 脚本scripts/classify-applicability.mjs3.0 KB
- 脚本scripts/classify-severity.mjs3.1 KB
- 脚本scripts/dedup-check.mjs3.5 KB
- 脚本scripts/ensure-labels.mjs6.7 KB
- 脚本scripts/fetch-pr-context.mjs4.9 KB
- 脚本scripts/file-issue.mjs3.6 KB
- 脚本scripts/harvest-commits.mjs5.5 KB
- 脚本scripts/init-scaffold.mjs13.4 KB
- 脚本scripts/parse-config.mjs3.8 KB
- 脚本scripts/parse-guidance.mjs2.4 KB
- 脚本scripts/parse-ledger.mjs1.9 KB
- 脚本scripts/preflight.mjs11.2 KB
- 脚本scripts/revalidate-do-not-port.mjs2.5 KB
- 脚本scripts/run-audit.mjs21.3 KB
- 脚本scripts/score-conflict-risk.mjs1.9 KB
- 脚本scripts/state-read.mjs1.1 KB
- 脚本scripts/state-write.mjs1.5 KB
- 脚本scripts/supersession-check.mjs4.5 KB
- 脚本scripts/sweep-backlog.mjs6.8 KB
- 脚本scripts/write-report.mjs7.7 KB
- 脚本scripts/write-sweep-report.mjs4.0 KB
03 SKILL.md 正文
Upstream Cherry-Pick Audit
When to use
- "What's new upstream in pi-dev?"
- "Have we missed any gsd-pi fixes since the last sync?"
- "Build me a backlog of cherry-pick candidates."
- Before a release, to verify there's no untracked critical fix in upstream.
Safe to run as a background subagent — produces durable artifacts (gh issues + report file). No interactive prompts after --init.
Repo roles — lineage vs inspiration
Each upstream in .planning/upstream-sync-config.json has a role (see docs/OTTO-ALIGNMENT.md §4):
role: "lineage"—pi(../pi),gsd-pi(../gsd-pi). Our maintenance stream. The audit scans these for bugs/stability/security/perf/correctness/dependency fixes (always-port) and feature candidates (run through the alignment fit-check below). These are the only repos the audit and sweep touch.role: "inspiration"—hermes-agent,anton,mempalace(local siblings). A curated reference library read while designing a co-worker feature. Never audited, never cherry-picked (Anton is AGPL-3.0 — reimplement the idea, don't vendor the source). Absentroledefaults tolineagefor back-compat.
run-audit.mjs iterates lineage repos only; naming an inspiration repo (node run-audit.mjs hermes-agent) errors.
Quickest path — the orchestrator
For a normal scan, run the bundled orchestrator instead of hand-driving each step. It executes the entire deterministic pipeline below in one process:
# Preview without filing (recommended first run)
node .claude/skills/upstream-cherry-pick/scripts/run-audit.mjs <upstream> --dry-run
# Real run — files issues, advances state, commits
node .claude/skills/upstream-cherry-pick/scripts/run-audit.mjs <upstream>
Run it from the repo root. Omit <upstream> to scan every upstream in config.
Flags: --dry-run, --no-issue-context, --refresh-cache, --from <commit>,
--no-commit, --guidance-dir <dir>, --no-diff. The orchestrator handles the
per-commit loop, dedup, dry-run report labeling, state advance, and the closing
commit; the agent supplies the judgment-call prose described under "Judgment
calls" below — most importantly, the otto-cli implementation guidance.
The step-by-step process below documents what the orchestrator does internally (and is the fallback if you need to drive a single commit by hand).
Implementation-grade issues: the otto-cli analysis (REQUIRED for real filing)
otto-cli is NOT a 1:1 mirror of its upstream. Packages were renamed and restructured (
packages/ai→packages/pi-ai,packages/coding-agent→packages/pi-coding-agent,packages/tui→packages/pi-tui, pluspi-agent-core,rpc-client,daemon,mcp-server,contracts,native). The upstream "Files touched" list is a starting pointer, not a target map.
A filed issue must be implementation-ready: when the implementation phase picks it up, the analysis is already done, so the job is confirm and apply, not start from scratch. That means every filed candidate carries an otto-cli implementation guidance section answering:
- Upstream intent / root cause — what bug or behavior was upstream fixing? (Not "what the diff does" — why it exists.)
- Fork relevance — is that problem present in our hard fork given our
customizations?
yes/partial/no, with reasoning. Anois the positive justification fornot-needed. - Fix strategy — one of the four values below (machine-readable first line).
- Divergence — how otto-cli's code differs from upstream here.
- Concrete approach — exact edits for
direct-merge/adapted-port; a design sketch (Essence to preserve + how to realize it in our code) foressence-reimplement.
The machine-readable strategy: line (REQUIRED)
Each guidance file's first line must be a literal, machine-readable strategy:
strategy: essence-reimplement # direct-merge | adapted-port | essence-reimplement | not-needed
run-audit.mjs validates the guidance via parse-guidance.mjs (schema: the four
sections above must be present; essence-reimplement must state Essence to
preserve). A missing/malformed new-format file fails the run fast and names
the offending path — repair it, or re-run with --skip-guidance-check
(audit/dry-run only) to file placeholder issues.
The four strategies (fork-divergence-aware):
direct-merge— cherry-pick /git am -3applies clean. →type:cherry-pick-candidateadapted-port— same fix, transcribed to our renamed/restructured paths. →type:port-requiredessence-reimplement— diverged in behavior; the patch won't apply; re-solve the upstream root cause in our code (requires Essence to preserve). →type:port-requirednot-needed— the problem does not exist in our fork (justified byFork relevance: no). →type:do-not-port
The parsed strategy drives two labels: the new fix-strategy:* dimension and
(for routing back-compat) the existing type:* label. Back-compat: a legacy
verdict: line is grandfathered — cherry-pick → direct-merge,
manual-port → adapted-port, do-not-port → not-needed — and legacy files skip
section enforcement. New guidance uses strategy:.
Two-stage workflow for a real (issue-filing) run
The deterministic scripts cannot perform this analysis — it is genuine per-commit code reading against the otto-cli tree. So a real run is two stages:
-
Scan + author guidance. Run
--dry-runto get the candidate list. For each candidate sha, read the upstream diff (git -C ../pi show <sha>), locate the otto-cli equivalent, and write the guidance as markdown to.planning/upstream-audits/guidance/<sha7>.md. Parallelize across subagents for large batches. The five required sections above are the required structure. -
File. Run the orchestrator without
--dry-run. It readsguidance/<sha7>.mdfor each candidate, validates it against the schema, embeds it plus the upstream diff into the issue body, and files. A candidate with missing or malformed guidance aborts the run (naming the path) so no thin issue is filed — author the guidance and re-run, or pass--skip-guidance-checkto deliberately file placeholders.
--no-diff suppresses diff embedding (smaller bodies); --guidance-dir points
at an alternate guidance directory. --revalidate-do-not-port prints a JSON
manifest of existing type:do-not-port issues to re-examine against the new
Fork relevance criterion (no relabeling).
Context budget: finishing a batch in one context window
A large batch (dozens of candidates) will blow the controller's context if it authors guidance inline, because every upstream diff and every otto-cli source read accumulates in the transcript forever. The deterministic scripts are cheap; the guidance loop is what burns context. Run a batch like this:
-
Get the candidate list cheaply. Run
run-audit.mjs <upstream> --manifestand capture its stdout — a compact JSON array (sha,severity,conflictRisk,hasGuidance,subject), a few KB. Do NOT read the full human audit report to harvest shas; the manifest exists precisely so the controller never pays for the 15-KB report. Filter tohasGuidance: false— those are the shas still needing analysis. -
Delegate all guidance authoring to subagents with a thin return contract. Split the un-analyzed shas into slices and dispatch one subagent per slice (
Agenttool, parallel). Each subagent reads the upstream diffs (git -C <path> show <sha>) and the otto-cli source in its own context, writes.planning/upstream-audits/guidance/<sha7>.md(first linestrategy: …), and returns only one line per sha to the controller:<sha7> <strategy> <target-file-or-"none">. The controller never sees a diff or a source file — only the one-liners. This is the single biggest lever. -
Never echo diffs or rendered issue bodies into the conversation. The orchestrator reads and caps diffs (400 lines) itself and embeds them in issue bodies; the controller has no reason to
cata diff, a guidance file, or a filed issue body back into the transcript. Prefer line-ranged reads /grepover whole-file reads when you must look at something. -
File. Once the manifest shows
hasGuidance: trueacross the slice, run the orchestrator without--dry-run/--manifestto file. Re-running--manifestafter authoring is a cheap way to confirm coverage before filing.
Process
For each invocation, follow these steps in order. Each step invokes a specific script under .claude/skills/upstream-cherry-pick/scripts/.
-
Preflight —
scripts/preflight.mjs. If it exits non-zero, print the diagnostics and stop. Do not attempt remediation autonomously beyond the auto-fix actions the script handles internally (label creation, directory creation, state file init). -
Parse config + ledger:
scripts/parse-config.mjs→ in-memory config (compiled regexes)scripts/parse-ledger.mjs→{ heavyFiles, heavyPackages, degraded }fromdocs/UPSTREAM-SYNC.md
-
For each upstream in
config.upstreams(or only the one specified via CLI arg):a. Read state:
scripts/state-read.mjs <upstream>→{ lastAnalyzedCommit, lastAnalyzedAt, lastReportPath }. If empty, prompt the user (or read defaults from config) for the starting commit/tag.b. Harvest commits:
scripts/harvest-commits.mjs <path> <branch> <lastAnalyzedCommit>→ array of commit records.c. For each commit (newest-first):
i. Classify applicability:
scripts/classify-applicability.mjswith config.applicability.notApplicable rules. If NOT_APPLICABLE → append to report's "Not applicable" appendix; skip remaining steps.ii. Classify first-pass severity:
scripts/classify-severity.mjswith config.classifier rubric. If SKIP → append to report's skipped appendix; skip remaining steps.iii. Fetch PR/issue context (per §8.2 fetch policy): for each
#NNNreference in commit.refs,scripts/fetch-pr-context.mjs <upstream.ghRepo> <refNum>. Honor--no-issue-contextflag to skip this step (results in less-informed classification + bare body in filed issues).iv. Apply context upgrades:
scripts/apply-context-upgrades.mjswith first-pass severity + fetched contexts. May upgrade or downgrade (e.g., closednot-planned→ SKIP).v. Score conflict risk:
scripts/score-conflict-risk.mjswith commit.touchedFiles + commit.locByFile + ledger.vi. Build issue payload:
scripts/build-issue-payload.mjswith all the above + ccUser from config + the agent-authoredimplementationGuidance(fromguidance/<sha7>.md) and the upstreamdiff. See "Implementation-grade issues" above — guidance is what makes the issue actionable.vii. Dedup check:
scripts/dedup-check.mjs <targetRepo> <shaShort>. If existing issue found, record as "already filed as #N (state=<OPEN|CLOSED>)" in the report; skip step viii.viii. File the issue:
scripts/file-issue.mjs <targetRepo>(with--dry-runflag, skip this step but still record what would have been filed). -
Write report:
scripts/write-report.mjs <outputDir>with the accumulated run data →.planning/upstream-audits/YYYY-MM-DD-<upstream>-audit.md. -
Update state:
scripts/state-write.mjs <upstream>withlastAnalyzedCommit = HEAD of upstream,lastAnalyzedAt = now,lastReportPath = <report-path>. -
Commit: stage the state file + report; commit with message
"audit(upstream): <name> scan YYYY-MM-DD (<N> issues filed)".
Judgment calls (NOT scripted — agent decides)
These are the only places the LLM contributes prose. Everything else is deterministic script output.
-
otto-cli implementation guidance (the important one): for every candidate that will be filed, perform the per-commit analysis described under "Implementation-grade issues" and write it to
.planning/upstream-audits/guidance/<sha7>.md. This is what turns an issue from a triage pointer into something the implementation phase can confirm-and-apply. The five required sections: upstream intent / root cause, fork relevance, fix strategy, divergence, and concrete approach — with a machine-readablestrategy:first line (direct-merge|adapted-port|essence-reimplement|not-needed) — see "The machine-readablestrategy:line" above; it drives the issue'sfix-strategy:*andtype:*labels. Missing or malformed guidance aborts the run — pass--skip-guidance-checkonly to deliberately file placeholders. -
Alignment fit-check (features only): for a candidate classified
severity:feature, judge its strategic fit againstdocs/OTTO-ALIGNMENT.md§5 and record it in the guidance file's optional## Alignmentsection with a machine-readablealignment: <core|adjacent|out-of-scope>line + a one-line reason citing the criterion.core→ normal port flow;adjacent→ defer;out-of-scope→ surface for a human to close. Bug/stability/security/perf/correctness/dependency fixes skip this — alignment is N/A. When torn, preferadjacent(defer, don't reject).run-audit.mjsreads the verdict and applies thealignment:*label; nothing is auto-closed. -
PR review-thread summarization: when
fetch-pr-context.mjsreturns a PR with reviews/comments, build-issue-payload.mjs renders a generic "Review highlights" section using only flat label/state info. The agent (controller) may enrich this by reading the fetched JSON and writing a 3-5 line excerpt of the most informative review threads into the issue body BEFORE invokingscripts/file-issue.mjs. This is optional — in fully scripted mode (e.g., a scheduled CI run), the payload uses the raw flat info. -
UNCLASSIFIED commits' "manual triage" notes: the report lists each unclassified commit. Optionally, the agent may add a one-line note per commit (e.g., "this looks feature-adjacent but in a touched area — may be worth manual review"). Without these notes, the report just lists subjects.
-
Edge case decisions: cache corruption, unexpected gh errors, partial context fetches. The agent decides whether to abort, retry, or proceed with reduced signal — using the principles documented in §14 of the design spec.
Outputs
- GitHub issues filed on
cmetech/otto-cli(or whateverconfig.targetRepois) — one per non-SKIP, APPLICABLE commit, with full labels, embedded otto-cli implementation guidance + upstream diff, and[sha=<7>]dedup trailer. - Guidance files at
.planning/upstream-audits/guidance/<sha7>.md— the agent-authored per-commit otto-cli analysis embedded into each issue. - Report file at
.planning/upstream-audits/YYYY-MM-DD-<upstream>-audit.md. - State file update at
.planning/upstream-sync-state.json— advanceslastAnalyzedCommit. - Commit on the current branch including the report + state file.
Backlog hygiene sweep (--sweep)
node run-audit.mjs --sweep (alias --revalidate-open) walks open actionable issues (type:port-required + type:cherry-pick-candidate, excluding status:applied/status:superseded) and, per issue, runs three deterministic Class-A checks in the issue's lineage repo:
- reverted — a later commit reverts the sha → auto-tag
status:superseded+ evidence comment. - upstream-closed — the linked upstream issue(s) closed as not-planned/wontfix/duplicate → auto-tag
status:superseded+ evidence comment. - rewritten — later commits touched the same files → advisory only (reported, not tagged — least precise signal).
It also lists open feature issues for an alignment re-check — you re-judge each against the current docs/OTTO-ALIGNMENT.md and (re)apply alignment:* via _common/scripts/issue-update.mjs. Output: .planning/upstream-audits/<date>-backlog-sweep.md. No issue is ever closed by the tool — every verdict is a label + evidence comment for a human. Add --dry-run to detect without mutating. Class B (fork-state re-check) and Class C (within-backlog clustering) are deferred.
Flags
--init— scaffold config, state, and labels (first run). Callsscripts/init-scaffold.mjs(see Task 19).--dry-run— classify and score everything, write the report, but skip the actualgh issue createcalls. Useful for previewing what would be filed.--manifest— classify and score, then print a compact JSON list of file-worthy candidates (sha,severity,conflictRisk,hasGuidance,subject) to stdout and exit. No diff read, payload build, dedup, report, state advance, or commit. Banners go to stderr so stdout is clean JSON. Single upstream → flat array; all upstreams → object keyed by name. Use it to drive cheap subagent dispatch (see "Context budget" above).--no-issue-context— skip the linked-PR/issue fetching step. Faster but reduces classifier accuracy.--refresh-cache— force re-fetch of all PR/issue contexts (bypasses_cache/).--cache-age-warning <days>— warn (non-blocking) when a served_cache/PR/issue context is older than<days>(by file mtime); suggests--refresh-cache.--from <commit>— override the starting commit/tag for this run (ignores stored state).--no-commit— file issues and advance state, but skip the closing git commit.--guidance-dir <dir>— directory of agent-authored<sha7>.mdotto-cli analysis files to embed in issues (default.planning/upstream-audits/guidance).--no-diff— do not embed the upstream diff in issue bodies (smaller bodies).--sweep/--revalidate-open— run the backlog-hygiene supersession sweep (see "Backlog hygiene sweep"). Combine with--dry-runto detect without tagging.
Background execution
This skill is safe to run as a same-session background subagent (Agent tool with run_in_background: true). All side effects are durable (gh issues, state file, report file) and the skill is idempotent on re-run thanks to per-issue sha-trailer dedup.
References
- Design spec:
docs/superpowers/specs/2026-05-29-upstream-cherry-pick-skill-design.md - Divergence ledger:
docs/UPSTREAM-SYNC.md - Plan:
docs/superpowers/plans/2026-05-29-upstream-cherry-pick-skill.md
04 同仓库更多 Skills
write-milestone-brief
Synthesize the current conversation into a milestone brief (PRD). Writes to `M###-CONTEXT.md` by default, or files a GitHub issue only with explicit user confirmation. Use when asked to "turn this into a PRD", "draft a milestone brief", "capture this context", "write it up", or when enough has been discussed to commit the plan to paper. Does not interview — it synthesizes what is already known.
write-docs
Collaborative document authoring workflow for proposals, technical specs, decision docs, README sections, ADRs, and long-form prose that must work for fresh readers. Use when asked to "write the docs", "draft a proposal", "write a spec", "write an RFC", "write the README", or when a document needs to be understandable by someone without this session's context. Three stages: gather context, iterate on structure, reader-test for a stranger.
web-quality-audit
Comprehensive web quality audit covering performance, accessibility, SEO, and best practices. Use when asked to "audit my site", "review web quality", "run lighthouse audit", "check page quality", or "optimize my website".
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
verify-before-complete
Block completion claims until verification evidence has been produced in the current message. Use before marking a task/slice/milestone complete, before creating a commit or PR, before saying "it works" or "tests pass", and any time you are about to claim work is done. The rule is: evidence before claims, always — running the verification must happen now, not "earlier in the session". Fresh output or no claim.
userinterface-wiki
UI/UX best practices for web interfaces. Use when reviewing animations, CSS, audio, typography, UX patterns, prefetching, or icon implementations. Covers 11 categories from animation principles to typography. Outputs file:line findings.