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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: patch
---

### Changed

- Tidied check-deck.mjs: the K2 refusal reuses the local-result helper, and the header usage lists the hosted argument the parser already accepts.
8 changes: 3 additions & 5 deletions plugins/visualization/skills/present/scripts/check-deck.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// publish would send. Prints one JSON object.
//
// check-deck.mjs <root> <PUBLIC|PRIVATE|INTERNAL|UNKNOWN|NONE> --class K0|K1|K2
// [--argument terminal|file|artifact] [--option <plugin medium option>]
// [--argument terminal|file|artifact|hosted] [--option <plugin medium option>]
// Exit 0 decided (read `medium`), 1 a deck refused, 2 usage or an unreadable root.

import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync } from "node:fs";
Expand Down Expand Up @@ -186,7 +186,7 @@ function workTree(dir) {
* @param {{root: string, visibility: string, cls: string, layers?: {argument?: string|null, option?: string|null, home?: string, project?: string|null, dataDir?: string|null}}} input
*/
export function checkDeck({ root, visibility, cls, layers = {} }) {
const local = (exit, reason) => ({ exit, result: { medium: "file", class: cls, reason } });
const local = (exit, reason, refused) => ({ exit, result: { medium: "file", class: cls, reason, ...(refused && { refused }) } });
const resolved = resolve(root);
if (lstatSync(resolved).isSymbolicLink() || realpathSync(resolved) !== resolved) {
return local(2, `the deck root ${resolved} is or passes through a symlink; pass its real path`);
Expand All @@ -212,9 +212,7 @@ export function checkDeck({ root, visibility, cls, layers = {} }) {
if (badTitle) return local(1, badTitle);
if (cls === "K2") {
const refused = k2Refusals(files);
if (refused.length) {
return { exit: 1, result: { medium: "file", class: cls, reason: "a K2 deck carries more than text in the slide format", refused } };
}
if (refused.length) return local(1, "a K2 deck carries more than text in the slide format", refused);
}
const { argument = null, option = null, home, project = findRoot(), dataDir = process.env.CLAUDE_PLUGIN_DATA || null } = layers;
const resolution = resolveMedium({ lane: "visualization:present", argument, userConfig: option, projectRoot: project }, { ...(home ? { userHome: home } : {}), dataDir });
Expand Down
7 changes: 7 additions & 0 deletions plugins/visualization/tests/present.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ describe("check-deck", () => {
assert.deepEqual(result.refused, [{ file: "project/slides/s1.html", carries }]);
});
}
test("a K2 refusal prints medium, class, reason and refused in that order; other refusals carry no refused key", () => {
const k2 = checkDeck({ root: deck({ s1: slide("s1", hostile[0][1]) }), visibility: "PUBLIC", cls: "K2" });
assert.deepEqual(Object.keys(k2.result), ["medium", "class", "reason", "refused"]);
assert.equal(k2.result.class, "K2");
const untitled = checkDeck({ root: deck(plain, { v: 4, order: ["cover"] }), visibility: "PUBLIC", cls: "K2" });
assert.deepEqual(Object.keys(untitled.result), ["medium", "class", "reason"]);
});
test("a K2 deck of escaped text and uploaded images passes; text that reads like markup does not trip it", () => {
const body = [
"<h2>Fix &lt;script&gt; onload = 1 url(x) href=x &amp; > done</h2>",
Expand Down
Loading