Merge branch 'feature/hub-gate-chips-glossary' into unify/skills-20261114
This commit is contained in:
commit
4496479e86
14 files changed
+400
-48
No files matched your search
@@ -72,8 +72,7 @@ const Ancestry = (() => {
|
||||
const level = LEVELS.includes(found.level) ? found.level : "none";
|
||||
const source = typeof found.source === "string" ? found.source : "";
|
||||
const own = source === branch;
|
||||
const from = own ? "own rule" : source ? `from ${source}` : "no rule";
|
||||
return {action, level, source, own, inherited: !own, icon: LEVEL_ICONS[level], title: `${action}: ${level} · ${from}`};
|
||||
return {action, level, source, own, inherited: !own, icon: LEVEL_ICONS[level]};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
const Glossary = (() => {
|
||||
"use strict";
|
||||
const RULE_HINTS = {
|
||||
ask: "Grants matching asks in matching directories, never a command with a warning (rm -r, push, --force, sudo, pipes into a shell …). The passkey signs the rule and the agents it applies to once; the hook checks signature, pattern and agent itself.",
|
||||
review: "Grants reviews of matching branches and worktrees, only when their gate is green, for every agent: a review names no session. The passkey signs the rule once; the commit skill checks signature and pattern itself.",
|
||||
decision: "Takes the recommended option in decisions of matching agents. The passkey signs the rule once; the decisions themselves stay unsigned.",
|
||||
};
|
||||
const OFFICE_VERBS = {
|
||||
appoint: ["Appoint", "bi-person-plus", "council.py claim --operator on the host: the chosen session gets the free office."],
|
||||
takeover: ["Hand over", "bi-arrow-left-right", "council.py takeover --operator on the host: the office goes to the chosen session, even if the current holder is still alive."],
|
||||
recall: ["Recall", "bi-person-x", "council.py release --operator on the host: the office becomes free, even if the holder is still alive."],
|
||||
};
|
||||
const GATE_ACTIONS = {
|
||||
commit: "a commit on this branch needs a gate receipt for its tree that meets the level; the commit-msg and pre-merge-commit hooks check it.",
|
||||
merge: "a merge into this branch needs a receipt that meets the level; the pre-merge-commit hook checks it, the pre-push hook checks fast-forward and squash merges.",
|
||||
push: "pushing this branch needs a receipt that meets the level for the tree of every pushed commit; the pre-push hook checks it.",
|
||||
pr: "a pull request from this branch needs the level; gates.py resolve reports it, no git hook checks it.",
|
||||
};
|
||||
const GATE_LEVELS = {
|
||||
none: "no receipt needed.",
|
||||
quick: "gates.py quick passed on the staged files: Python syntax, JSON, bash -n and git diff --check.",
|
||||
test: "a green make test on the exact tree, GPU tests off.",
|
||||
"quality-high": "a green make quality-high on the exact tree, GPU tests off.",
|
||||
e2e: "a green make e2e on the exact tree, GPU tests off; the strictest level.",
|
||||
};
|
||||
const RECEIPT = ["receipt", "a green run records one for its tree; it meets its own level and every lower one for 30 days."];
|
||||
const GATE_SOURCES = {
|
||||
own: ["own rule", "the branch sets this level itself."],
|
||||
inherited: ["inherited from", "the branch sets no level, so the strictest level of its parent branches applies; the chip names the branch that sets it."],
|
||||
unset: ["no rule", "neither the branch nor a parent sets a level, so the action needs no receipt."],
|
||||
staged: ["staged", "changed here, not applied yet: Apply signs every staged change with one passkey signature, Discard drops them."],
|
||||
};
|
||||
const GATE_CYCLE = ["click, Enter or Space", "cycles the own rule through none, quick, test, quality-high and e2e, then back to inherited."];
|
||||
const BRANCH_MARKS = {
|
||||
merged: ["merged", "pkgmgr branch gc found every tip of the branch in the default branch or a merge line."],
|
||||
unmerged: ["not merged", "the branch holds commits the default branch does not have."],
|
||||
protected: ["protected", "the default or a protected branch: gc never deletes it."],
|
||||
stale: ["stale", "pkgmgr branch gc marks the entry stale; the Reason line says why."],
|
||||
unpushed: ["commits unpushed", "local commits its upstream does not have yet."],
|
||||
behind: ["commits behind", "upstream commits the local branch does not have yet."],
|
||||
gone: ["upstream gone", "the remote branch it tracks was deleted."],
|
||||
detached: ["no upstream", "the branch tracks no remote branch."],
|
||||
skip: ["gc skips", "pkgmgr branch gc leaves the branch alone for the reason shown."],
|
||||
reason: ["Reason", "pkgmgr's own words: merged by ancestor, by patch or by a pull request; unmerged with the commits not in the default branch; no own commits; dirty with the changed paths; default or protected branch."],
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} mark one Ancestry.gateMarks entry: action, level, source and own.
|
||||
* @param {Object|null} staged the staged change of the chip, its level null when it drops the own rule.
|
||||
* @returns {Object} text: the chip text, also its aria-label; hint: the tooltip that explains it.
|
||||
*/
|
||||
function gateChip(mark, staged) {
|
||||
const kind = staged ? "staged" : mark.own ? "own" : mark.source ? "inherited" : "unset";
|
||||
const level = staged ? staged.level || "inherited" : mark.level;
|
||||
const from = kind === "inherited" ? `${GATE_SOURCES.inherited[0]} ${mark.source}` : GATE_SOURCES[kind][0];
|
||||
const text = `${mark.action}: ${level} (${from})`;
|
||||
const meaning = Object.hasOwn(GATE_LEVELS, level) ? GATE_LEVELS[level] : GATE_SOURCES.inherited[1];
|
||||
return {text, hint: [text, `${mark.action}: ${GATE_ACTIONS[mark.action]}`, `${level}: ${meaning}`, `${from}: ${GATE_SOURCES[kind][1]}`, `${GATE_CYCLE[0]}: ${GATE_CYCLE[1]}`].join("\n")};
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array<[string, Array<[string, string]>]>} the sections the Explain action lists, each a heading and its [term, meaning] rows.
|
||||
*/
|
||||
function explain() {
|
||||
return [
|
||||
["Gate actions", Object.entries(GATE_ACTIONS)],
|
||||
["Gate levels", [...Object.entries(GATE_LEVELS), RECEIPT]],
|
||||
["Where a level comes from", [...Object.values(GATE_SOURCES), GATE_CYCLE]],
|
||||
["Branch marks", Object.values(BRANCH_MARKS)],
|
||||
];
|
||||
}
|
||||
|
||||
return {RULE_HINTS, OFFICE_VERBS, GATE_ACTIONS, GATE_LEVELS, GATE_SOURCES, GATE_CYCLE, RECEIPT, BRANCH_MARKS, gateChip, explain};
|
||||
})();
|
||||
if (typeof module === "object" && module.exports) {
|
||||
module.exports = Glossary;
|
||||
}
|
||||
@@ -495,6 +495,8 @@ pre.notes { margin: 0; padding: 8px 10px; background: var(--sunken); border-radi
|
||||
|
||||
{% include "panels.js" %}
|
||||
|
||||
{% include "glossary.js" %}
|
||||
|
||||
{% include "ancestry.js" %}
|
||||
|
||||
{% include "popup.js" %}
|
||||
|
||||
@@ -20,30 +20,43 @@
|
||||
return ((tree.data && tree.data.gates) || {})[repo] ? tree.data.gates[repo][name] || null : null;
|
||||
}
|
||||
|
||||
function gateIcons(repo, name) {
|
||||
function gateChips(repo, name) {
|
||||
const found = gatesOf(repo, name);
|
||||
const own = (found && found.rules) || {};
|
||||
return h("span", {class: "gates", role: "group", "aria-label": `Gates of ${name}`}, Ancestry.gateMarks(name, found).map((mark) => {
|
||||
return h("span", {class: "gates", role: "group", "aria-label": `Gates of ${name}`, "data-repo": repo, "data-branch": name}, Ancestry.gateMarks(name, found).map((mark) => {
|
||||
const key = `rule\u0000${repo}\u0000${name}\u0000${mark.action}`;
|
||||
const staged = gateStage.items.find((item) => item.key === key);
|
||||
const staged = gateStage.items.find((item) => item.key === key) || null;
|
||||
const current = Object.hasOwn(own, mark.action) ? own[mark.action] : null;
|
||||
const level = staged ? staged.level || "none" : mark.level;
|
||||
const title = staged ? `${mark.action}: ${staged.level || "inherited"} · staged` : mark.title;
|
||||
const chip = Glossary.gateChip(mark, staged);
|
||||
const cycle = (event) => {
|
||||
const group = event.currentTarget.closest(".gates");
|
||||
const button = event.currentTarget;
|
||||
const group = button.closest(".gates");
|
||||
const focused = document.activeElement === button;
|
||||
const next = Ancestry.nextRule(staged ? staged.level : current);
|
||||
stageGate(key, next === current ? null : {argv: Ancestry.ruleArgv(repo, name, mark.action, next), level: next});
|
||||
if (group && group.isConnected) {
|
||||
group.replaceWith(gateIcons(repo, name));
|
||||
const fresh = group && group.isConnected ? gateChips(repo, name) : null;
|
||||
if (fresh) {
|
||||
group.replaceWith(fresh);
|
||||
}
|
||||
const holder = fresh || [...document.querySelectorAll("#main .gates")].find((node) => node.dataset.repo === repo && node.dataset.branch === name);
|
||||
if (focused && holder) {
|
||||
holder.querySelector(`.gate-mark[data-action="${mark.action}"]`).focus();
|
||||
}
|
||||
};
|
||||
return h("button", {
|
||||
type: "button", class: ["gate-mark", "icon-only", mark.inherited && !staged ? "inherited" : "", staged ? "pending" : ""].filter(Boolean).join(" "),
|
||||
"data-action": mark.action, "data-level": level, "data-source": mark.source, ...named(`${mark.action} gate`, title), on: {click: cycle},
|
||||
}, icon(Ancestry.LEVEL_ICONS[level]));
|
||||
type: "button", class: ["gate-mark", mark.inherited && !staged ? "inherited" : "", staged ? "pending" : ""].filter(Boolean).join(" "),
|
||||
"data-action": mark.action, "data-level": level, "data-source": mark.source, ...named(revealed(chip.text), revealedLines(chip.hint)), on: {click: cycle},
|
||||
}, icon(Ancestry.LEVEL_ICONS[level]), h("span", {class: "gate-text"}, revealed(chip.text)));
|
||||
}));
|
||||
}
|
||||
|
||||
function gateExplain() {
|
||||
return h("details", {class: "gate-explain"}, h("summary", {title: "Explain: what each mark of this branch means"}, icon("bi-question-circle"), "Explain"),
|
||||
Glossary.explain().map(([heading, rows]) => h("section", {}, h("h4", {}, heading),
|
||||
h("dl", {class: "glossary"}, rows.map(([term, meaning]) => h("div", {}, h("dt", {}, term), h("dd", {}, meaning)))))));
|
||||
}
|
||||
|
||||
function gateApply() {
|
||||
const count = gateStage.items.length;
|
||||
if (!count) {
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
body.push(meta([["Path", data.path], ["Remote", data.remote], ["Default", data.default], ["Forge", data.forge], ["As of", data.scanned_at]]),
|
||||
h("p", {class: "muted"}, `${data.branches.length} Branches · ${data.branches.reduce((sum, entry) => sum + entry.worktrees.length, 0) + data.detached.length} Worktrees`));
|
||||
} else if (node.kind === "branch") {
|
||||
body.push(h("div", {class: "states"}, branchStates(data), gateIcons(node.repo, data.name)), meta([["Upstream", data.upstream], ["Head", data.head.slice(0, 12), data.head], ["Merged into", data.merged_into], ["Reason", data.reason]]),
|
||||
body.push(h("div", {class: "states"}, branchStates(data), gateChips(node.repo, data.name)), gateExplain(), meta([["Upstream", data.upstream], ["Head", data.head.slice(0, 12), data.head], ["Merged into", data.merged_into], ["Reason", data.reason]]),
|
||||
data.worktrees.map((wt) => flowDetails(wt.flow, data.name)),
|
||||
h("h3", {}, "Dry run"), h("pre", {class: "notes"}, data.plan.join("\n")), glance ? null : h("div", {class: "actions"}, deleteButton(data)));
|
||||
} else if (node.kind === "worktree") {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
const OFFICE_RESULTS = {done: ["done", "ok"], refused: ["refused", "bad"], failed: ["failed", "bad"]};
|
||||
const OFFICE_VERBS = {
|
||||
appoint: ["Appoint", "bi-person-plus", "council.py claim --operator on the host: the chosen session gets the free office."],
|
||||
takeover: ["Hand over", "bi-arrow-left-right", "council.py takeover --operator on the host: the office goes to the chosen session, even if the current holder is still alive."],
|
||||
recall: ["Recall", "bi-person-x", "council.py release --operator on the host: the office becomes free, even if the holder is still alive."],
|
||||
};
|
||||
const OFFICE_VERBS = Glossary.OFFICE_VERBS;
|
||||
const OFFICE_HINT = "The host checks your passkey signature itself and refuses if the holder changed since the signature.";
|
||||
|
||||
function successors(office, holder) {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
const RULE_KINDS = {ask: "Ask: tool + command pattern", review: "Review: branch pattern + gate green", decision: "Decision: take the recommendation"};
|
||||
const RULE_HINTS = {
|
||||
ask: "Grants matching asks in matching directories, never a command with a warning (rm -r, push, --force, sudo, pipes into a shell …). The passkey signs the rule and the agents it applies to once; the hook checks signature, pattern and agent itself.",
|
||||
review: "Grants reviews of matching branches and worktrees, only when their gate is green, for every agent: a review names no session. The passkey signs the rule once; the commit skill checks signature and pattern itself.",
|
||||
decision: "Takes the recommended option in decisions of matching agents. The passkey signs the rule once; the decisions themselves stay unsigned.",
|
||||
};
|
||||
const RULE_HINTS = Glossary.RULE_HINTS;
|
||||
|
||||
/**
|
||||
* @param {Object} rule the stored rule to turn on again, which widens what agents may do.
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
const result = resultOf(repo, entry);
|
||||
return h("div", {class: "branch-row", "data-item": `artifact:${artifactRef(`branch:${repo.path}\u0000${entry.name}`)}`},
|
||||
h("div", {class: "branch-name", "data-star-slot": ""}, h("strong", {}, entry.name), h("span", {class: "states"}, branchStates(entry)), entry.upstream ? h("span", {class: "muted"}, `↔ ${entry.upstream}`) : null,
|
||||
h("span", {class: "muted", title: entry.head}, entry.head.slice(0, 10)), result ? resultChip(result) : null, h("span", {class: "spacer"}), gateIcons(repo.path, entry.name), glance ? null : deleteButton(entry)),
|
||||
h("span", {class: "muted", title: entry.head}, entry.head.slice(0, 10)), result ? resultChip(result) : null, h("span", {class: "spacer"}), gateChips(repo.path, entry.name), glance ? null : deleteButton(entry)),
|
||||
entry.worktrees.map(worktreeRow));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,20 @@ svg .ancestry-edge.dropping { stroke: var(--bad); opacity: .5; }
|
||||
svg .ancestry-node { cursor: grab; }
|
||||
svg .ancestry-node:active { cursor: grabbing; }
|
||||
svg .ancestry-node .label { fill: var(--text); font-size: var(--fs-2xs); }
|
||||
.gates { display: inline-flex; align-items: center; gap: 2px; }
|
||||
.gate-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }
|
||||
.gates { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
|
||||
.gate-mark { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; padding: 1px 9px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--neutral-soft); color: var(--text); font: inherit; font-size: var(--fs-xs); font-weight: 650; line-height: 20px; text-align: start; cursor: pointer; }
|
||||
.gate-mark .bi { flex: none; }
|
||||
.gate-mark .gate-text { min-width: 0; overflow-wrap: anywhere; }
|
||||
.gate-mark:hover { background: var(--hover); }
|
||||
.gate-mark.inherited { opacity: .4; }
|
||||
.gate-mark.pending { outline: 1px dashed var(--info); color: var(--info); }
|
||||
.gate-mark:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
||||
.gate-mark.inherited { border-style: dashed; background: transparent; color: var(--muted); }
|
||||
.gate-mark.pending { border: 1px dashed var(--info); background: var(--info-soft); color: var(--info); }
|
||||
.gate-explain { margin: 4px 0 8px; }
|
||||
.gate-explain > summary { display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; color: var(--accent); font-weight: 650; cursor: pointer; }
|
||||
.gate-explain h4 { margin: 10px 0 4px; color: var(--muted); font-size: var(--fs-xs); font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
|
||||
.glossary { display: grid; gap: 4px; margin: 0; }
|
||||
.glossary > div { display: grid; grid-template-columns: minmax(0, 9em) minmax(0, 1fr); gap: 8px; }
|
||||
.glossary dt { font-weight: 650; overflow-wrap: anywhere; }
|
||||
.glossary dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
|
||||
.gate-apply, .gate-staged { display: inline-flex; align-items: center; gap: 4px; }
|
||||
.dry-run.locked pre { opacity: .6; }
|
||||
Reference in new issue
Block a user