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
7 changes: 7 additions & 0 deletions .changes/planning/fix-8089-pin-repo-path-links-5d2a7c91.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: patch
---

### Fixed

- **interview:** a repo-relative path such as `plugins/x.py:10` in a recommendation, a commitment or an alternative on the 1:1 interview page now links to that file at a pinned commit. Set `meta.commit` to a full 40-character SHA beside `meta.repo`, through the `meta` op or `add-round`'s `meta`. `round.py` refuses any other non-empty commit value. Without a commit, paths stay plain text ([#8089](https://github.com/melodic-software/claude-code-plugins/issues/8089)).
4 changes: 2 additions & 2 deletions plugins/planning/skills/interview/context/surface.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/planning/surface/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ <h1 id="title">Interview</h1>
if (i < s.length) parent.append(s.slice(i));
}
// The page builds its HTML as strings: the renderer's elements go in serialized, so their text stays escaped.
const MD = {heading: 3, repo: () => ({repo: S.doc.meta.repo}), text: qText}, mdBox = document.createElement("div");
const MD = {heading: 3, repo: () => ({repo: S.doc.meta.repo, commit: S.doc.meta.commit}), text: qText}, mdBox = document.createElement("div");
const serialize = fill => { mdBox.replaceChildren(); fill(mdBox); return mdBox.innerHTML; };
const lineHtml = raw => serialize(b => QuestionShape.inline(b, raw, MD));
const mdHtml = src => '<div class="md">' + serialize(b => b.append(QuestionShape.markdown(src, MD))) + "</div>";
Expand Down
8 changes: 6 additions & 2 deletions plugins/planning/surface/round.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
BARE_ISSUE_REF = re.compile(r"(?<![\w/&#-])#\d+\b")
CODE_SPAN = re.compile(r"`[^`\n]+`")
REPO_SLUG = re.compile(r"[\w.-]+/[\w.-]+", re.ASCII)
COMMIT_SHA = re.compile(r"[0-9a-f]{40}") # a full commit SHA, which page links pin; also in shared/session.py
BRANCH_SOURCE_LINK = re.compile(
r"https?://github\.com/[\w.-]+/[\w.-]+/blob/(?![0-9a-f]{7,40}/)[^/\s)]+/", re.ASCII
)
Expand Down Expand Up @@ -893,18 +894,21 @@ def put_group(doc, g):
# The CLI commands and `apply` share them; only the caller loads, locks and saves.


META_KEYS = ("title", "eyebrow", "stages", "next", "repo")
META_KEYS = ("title", "eyebrow", "stages", "next", "repo", "commit")
# add-round's meta may also carry `kind`, stored on the round: a sweep round reconciles earlier answers.
ROUND_KINDS = ("sweep",)


def set_meta(doc, m):
"""Merge title, eyebrow, stages, next and repo into questions.json meta; any other key is refused."""
"""Merge title, eyebrow, stages, next, repo and commit into questions.json meta; any other key, or a commit that is neither empty nor a full SHA, is refused."""
if not isinstance(m, dict):
sys.exit("refused: meta is an object")
extra = sorted(set(m) - set(META_KEYS))
if extra:
sys.exit(f"refused: unknown meta keys {extra} (known: {', '.join(META_KEYS)})")
commit = m.get("commit")
if commit and not (isinstance(commit, str) and COMMIT_SHA.fullmatch(commit)):
sys.exit(f"refused: meta.commit is a full 40-character commit SHA or empty, got {commit!r}")
doc["meta"].update(m)


Expand Down
4 changes: 3 additions & 1 deletion plugins/planning/surface/schema/ops.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@
"eyebrow": {"type": "string"},
"stages": {"type": "object", "additionalProperties": {"type": "string"}},
"next": {"type": "string"},
"repo": {"type": "string"}
"repo": {"type": "string"},
"commit": {"description": "A full 40-character commit SHA, or empty to unlink paths; anything else is refused.", "type": "string"}
}
},
"roundMeta": {
Expand All @@ -228,6 +229,7 @@
"stages": {"type": "object", "additionalProperties": {"type": "string"}},
"next": {"type": "string"},
"repo": {"type": "string"},
"commit": {"type": "string"},
"kind": {"enum": ["sweep"]}
}
},
Expand Down
1 change: 1 addition & 0 deletions plugins/planning/surface/schema/questions.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"stages": {"type": "object", "additionalProperties": {"type": "string"}},
"next": {"type": "string"},
"repo": {"type": "string"},
"commit": {"description": "A full 40-character commit SHA in `repo`: the page links a repo-relative path to that file at this commit, and leaves paths as text when it is empty or absent.", "type": "string"},
"setInRound": {"type": "integer"},
"pluginVersion": {"description": "The planning plugin version that first wrote this file; `round.sh doctor` compares it with the running version.", "type": "string"},
"emojiMarkers": {"type": "boolean"},
Expand Down
2 changes: 1 addition & 1 deletion plugins/planning/surface/surface-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bad() { echo "FAIL: $1"; fail=$((fail + 1)); }

# The browser groups of each part, and each group's check count for the SKIP line.
declare -A PARTS=([main]="ab e live page" [ui-c]="c" [journey]="journey")
declare -A CHECKS=([ab]=97 [c]=207 [e]=20 [journey]=235 [live]=18 [page]=118)
declare -A CHECKS=([ab]=97 [c]=207 [e]=22 [journey]=235 [live]=18 [page]=118)
part=main
case "$#:${1:-}" in
0:) ;;
Expand Down
20 changes: 19 additions & 1 deletion plugins/planning/surface/test_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -3570,7 +3570,7 @@ def test_add_round_with_summary_and_questions_records_them_without_warning(self)


class TestMeta(DirCase):
"""`add-round` meta and the `meta` op: title, eyebrow, stages, next, repo; nothing else."""
"""`add-round` meta and the `meta` op: title, eyebrow, stages, next, repo, commit; nothing else."""

def setUp(self):
super().setUp()
Expand Down Expand Up @@ -3614,6 +3614,24 @@ def test_apply_meta_op_sets_repo(self):
self.assertEqual(rc, 0, out + err)
self.assertEqual(self.doc()["meta"]["repo"], "o/r")

def test_meta_commit_is_set_and_read_back_beside_repo(self):
sha = "0123456789abcdef0123456789abcdef01234567"
ops = {"ops": [{"op": "meta", "set": {"repo": "o/r", "commit": sha}}]}
rc, out, err = self.rp("apply", "--file", self.file("ops.json", ops))
self.assertEqual(rc, 0, out + err)
self.assertEqual((self.doc()["meta"]["repo"], self.doc()["meta"]["commit"]), ("o/r", sha))
spec = {"meta": {"commit": ""}, "questions": [question("Q4", group="g1")]}
rc, out, err = self.rp("add-round", "--file", self.file("r.json", spec))
self.assertEqual(rc, 0, out + err)
self.assertEqual(self.doc()["meta"]["commit"], "")

def test_meta_commit_that_is_not_a_full_sha_is_refused(self):
for commit in ("main", "0123456", "0123456789ABCDEF0123456789ABCDEF01234567"):
ops = {"ops": [{"op": "meta", "set": {"commit": commit}}]}
out = self.assert_refused("apply", "--file", self.file("ops.json", ops))
self.assertIn("meta.commit", out, commit)
self.assertNotIn("commit", self.doc()["meta"])

def test_apply_meta_op_unknown_key_is_refused(self):
ops = {"ops": [{"op": "meta", "set": {"displayName": "Kyle"}}]}
self.assert_refused("apply", "--file", self.file("ops.json", ops))
Expand Down
28 changes: 27 additions & 1 deletion plugins/planning/surface/tests/ui_e.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
async page => { // answer controls: radios by keyboard, a withheld question, paste routing, the focus ring, and the controls while offline or after a restart
async page => { // answer controls: radios by keyboard, a withheld question, repo paths linked at meta.commit, paste routing, the focus ring, and the controls while offline or after a restart
const R = [], ok = (name, pass, detail) => R.push((pass ? "PASS " : "FAIL ") + name + (detail !== undefined ? " [" + detail + "]" : ""));
const errors = [];
page.on("console", m => { if (m.type() === "error") errors.push(m.text()); });
Expand Down Expand Up @@ -48,6 +48,32 @@ async page => { // answer controls: radios by keyboard, a withheld question, pas
await page.unroute("**/api/state");
await nudgeVisible(); await page.waitForTimeout(400);

// #8089: a repo path in a recommendation, a commitment and an alternative links to the file at meta.commit; with no commit it stays text
const SHA = "0123456789abcdef0123456789abcdef01234567", BLOB = p => "https://github.com/o/r/blob/" + SHA + "/" + p;
const withPaths = commit => route => route.fetch().then(async res => {
const body = await res.json();
body.questions.meta = Object.assign({}, body.questions.meta, {repo: "o/r"}, commit ? {commit} : {});
body.questions.questions.forEach(q => { if (q.id === "E1") Object.assign(q, {recommendation: "Yes, per plugins/rec.py:12.", commits: ["Keep docs/commit.md current"], alternatives: [{key: "a", text: "No, see lib/alt.js"}, {key: "b", text: "Only on main"}]}); });
await route.fulfill({response: res, json: body});
});
const pathLinks = () => page.evaluate(() => {
const hrefs = e => e ? [...e.querySelectorAll("a")].map(a => a.getAttribute("href")) : null;
return {rec: hrefs([...document.querySelectorAll("#choices .choice .t")].find(t => /plugins\/rec\.py/.test(t.textContent))), commit: hrefs(document.querySelector(".crow label")), alt: hrefs([...document.querySelectorAll(".alts .alt")].find(a => /lib\/alt\.js/.test(a.textContent)))};
});
await page.route("**/api/state", withPaths(SHA));
await nudgeVisible(); await pick("E1");
await until(() => !!document.querySelector('.alts .alt a[href*="/blob/"]'), 8000);
const pinned = await pathLinks();
ok("with meta.commit, a path in the recommendation, a commitment and an alternative links to the file at that commit", JSON.stringify(pinned) === JSON.stringify({rec: [BLOB("plugins/rec.py") + "#L12"], commit: [BLOB("docs/commit.md")], alt: [BLOB("lib/alt.js")]}), JSON.stringify(pinned));
await page.unroute("**/api/state");
await page.route("**/api/state", withPaths(""));
await nudgeVisible();
await until(() => !document.querySelector('a[href*="/blob/"]') && /docs\/commit\.md/.test(document.body.textContent), 8000);
const unpinned = await pathLinks();
ok(" with no meta.commit, the same paths stay plain text", JSON.stringify(unpinned) === JSON.stringify({rec: [], commit: [], alt: []}), JSON.stringify(unpinned));
await page.unroute("**/api/state");
await nudgeVisible(); await page.waitForTimeout(400);

// arrow keys move through the Decide radios without dropping focus
await pick("E1");
await page.focus('#choices input[value="1"]');
Expand Down
Loading