slidemind 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "slidemind",
3
+ "interface": {
4
+ "displayName": "slidemind",
5
+ "shortDescription": "On-brand PowerPoint decks from your coding agent",
6
+ "longDescription": "slidemind connects Codex to the slidemind PowerPoint add-in over its local bridge, so the agent can build and edit native .pptx decks against whatever corporate design the add-in has active. It is brand-agnostic: the corporate design, the layout palette, and the OOXML render all live in the add-in, and the agent reads every brand rule from the design bundle it serves. This marketplace publishes the slidemind plugin, which carries the authoring and search skills. The slidemind CLI itself is installed separately from public npm (npm install -g slidemind); the skills explain that step when the command is missing."
7
+ },
8
+ "plugins": [
9
+ {
10
+ "name": "slidemind",
11
+ "description": "Build and edit native, on-brand PowerPoint decks against the active corporate design.",
12
+ "source": {
13
+ "source": "local",
14
+ "path": "./"
15
+ },
16
+ "policy": {
17
+ "installation": "AVAILABLE",
18
+ "authentication": "ON_INSTALL"
19
+ },
20
+ "category": "Productivity",
21
+ "interface": {
22
+ "displayName": "slidemind",
23
+ "shortDescription": "On-brand PowerPoint decks from Codex",
24
+ "developerName": "statworx",
25
+ "longDescription": "Adds two skills. slidemind-create-slides owns the intake, plan, create and edit workflow that turns per-slide sources into an editable .pptx rendered by the add-in, plus a local HTML preview. slidemind-search discovers and reuses existing slides and brand imagery from the corporate design's engines, or from a PowerPoint file on disk. Both are brand-agnostic and read the active corporate design's rules, layout palette, and authoring workflow from the design bundle the add-in serves. Requires the slidemind CLI (npm install -g slidemind) and an open PowerPoint with the add-in for anything that renders or reads a live deck."
26
+ }
27
+ }
28
+ ]
29
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slidemind",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Connect Claude Code to the slidemind PowerPoint add-in — build and edit native, on-brand PowerPoint decks against the active corporate design, from the terminal.",
5
5
  "author": {
6
6
  "name": "statworx",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slidemind",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Connect Codex to the slidemind PowerPoint add-in — build and edit native, on-brand PowerPoint decks against the active corporate design. Requires the slidemind CLI (npm install -g slidemind); the skills explain the install when it is missing.",
5
5
  "author": {
6
6
  "name": "statworx",
@@ -20,6 +20,7 @@
20
20
  "interface": {
21
21
  "displayName": "slidemind",
22
22
  "shortDescription": "On-brand PowerPoint decks from Codex",
23
+ "longDescription": "Adds two skills. slidemind-create-slides owns the intake, plan, create and edit workflow that turns per-slide sources into an editable .pptx rendered by the add-in, plus a local HTML preview. slidemind-search discovers and reuses existing slides and brand imagery from the corporate design's engines, or from a PowerPoint file on disk. Both are brand-agnostic and read the active corporate design's rules, layout palette, and authoring workflow from the design bundle the add-in serves. Requires the slidemind CLI (npm install -g slidemind) and an open PowerPoint with the add-in for anything that renders or reads a live deck.",
23
24
  "developerName": "statworx",
24
25
  "category": "Productivity",
25
26
  "capabilities": [
@@ -1,6 +1,6 @@
1
- # CLAUDE.md
1
+ # AGENTS.md
2
2
 
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3
+ Guidance for coding agents working in this repository. `CLAUDE.md` is a symlink to this file — there is ONE guidance document, so edit it here and every harness sees the change. (It used to be two near-identical files kept in sync by hand, which drifted.)
4
4
 
5
5
  ## Project purpose
6
6
 
@@ -24,12 +24,19 @@ npm install -g slidemind
24
24
  slidemind init --for all # claude | codex | opencode | all | none
25
25
  ```
26
26
 
27
- `npx slidemind <command>` runs it without a global install. `slidemind update` is a thin wrapper over `npm install -g slidemind@latest` (`--ref <version>` to pin, `--for <target>` to control the redeploy). The `files` whitelist in `package.json` controls what ships (`bin/ src/ skills/ .claude-plugin/ .codex-plugin/ CLAUDE.md README.md`); `archive/`, `docs/`, `scripts/`, `test/`, and `.agents/` are excluded.
27
+ `npx slidemind <command>` runs it without a global install. `slidemind update` is a thin wrapper over `npm install -g slidemind@latest` (`--ref <version>` to pin, `--for <target>` to control the redeploy). The `files` whitelist in `package.json` controls what ships (`bin/ src/ skills/ .claude-plugin/ .codex-plugin/ .agents/plugins/ AGENTS.md README.md`); `archive/`, `docs/`, `scripts/`, and `test/` are excluded. Two traps live in that list:
28
+
29
+ - `.agents/plugins/`, **not** `.agents/` — `files` globs the filesystem rather than git, and `.agents/` also holds gitignored per-developer harness scratch that a bare entry would publish.
30
+ - `AGENTS.md`, **not** `CLAUDE.md` — `CLAUDE.md` is a symlink and **npm silently drops symlinks from the tarball**, so listing it would ship nothing at all. The repo keeps the symlink for local harness convenience; the package ships the real `AGENTS.md`.
31
+
32
+ A packaging test guards both.
28
33
 
29
34
  Both agent harnesses can also install slidemind as a **plugin** — this private repo doubles as the marketplace (a public marketplace repo can be split out later; the files move as-is). The marketplace is named `slidemind`, NOT `statworx`: the team already registers a `statworx` marketplace from `STATWORX/intern-marketplace-test`, and both harnesses allow only one marketplace per name.
30
35
 
31
- - **Claude Code** (one step, no `npm -g`): `/plugin marketplace add STATWORX/intern-slidemind-cli` → `/plugin install slidemind@slidemind`. The marketplace entry (`.claude-plugin/marketplace.json`) points at the **public npm package, unpinned** — Claude installs the latest tarball and the installed version comes from the tarball's `.claude-plugin/plugin.json`, so only the marketplace add needs repo access. The tarball's `bin/slidemind` + `bin/slidemind.cmd` shims land on PATH inside plugin sessions, so the plugin carries the CLI too.
32
- - **Codex**: `codex plugin marketplace add STATWORX/intern-slidemind-cli` → `codex plugin add slidemind@slidemind`. Codex clones the repo (marketplace file `.agents/plugins/marketplace.json`; plugin manifest `.codex-plugin/plugin.json`; plugin source = repo root) and carries the skills only — the CLI still arrives via `npm install -g slidemind`, which the skills' remediation covers.
36
+ - **Claude Code** (one step, no `npm -g`, **no GitHub account**): `/plugin marketplace add https://unpkg.com/slidemind/.claude-plugin/marketplace.json` → `/plugin install slidemind@slidemind`. A Claude marketplace source may be a plain HTTPS URL, and an npm CDN serves files straight out of the published tarball — which ships `.claude-plugin/marketplace.json`. So the marketplace needs no repo of its own and follows releases automatically (no version in the URL, no version pin in the plugin entry). `https://cdn.jsdelivr.net/npm/slidemind/.claude-plugin/marketplace.json` is the equivalent fallback. The tarball's `bin/slidemind` + `bin/slidemind.cmd` shims land on PATH inside plugin sessions, so the plugin carries the CLI too. (`/plugin marketplace add STATWORX/intern-slidemind-cli` also works but needs read access to this private repo — prefer the URL.)
37
+ - **Codex**: a Codex marketplace source must be a **local path or a git remote** — no URL, no npm — so the CDN trick does NOT transfer. Instead the tarball ships `.agents/plugins/marketplace.json`, which makes the INSTALLED package a valid local marketplace: `npm install -g slidemind` → `codex plugin marketplace add "$(npm root -g)/slidemind"` → `codex plugin add slidemind@slidemind`. No GitHub account needed. (`codex plugin marketplace add STATWORX/intern-slidemind-cli` works for anyone with repo access.) Codex plugins cannot put a binary on PATH, so the CLI always comes from npm; the skills' remediation covers that.
38
+
39
+ > The Codex **admin console** validates harder than the CLI does: it rejects an import when any `interface` block lacks a non-blank `longDescription`, which `codex plugin add` never complains about. `test/plugin-manifests.test.mjs` guards it.
33
40
 
34
41
  `slidemind init --for <target>` remains the universal fallback on all three harnesses; the Claude installer prints a dedup hint when it detects the plugin is also installed.
35
42
 
@@ -73,7 +80,7 @@ Teammates pick up the release with `npm install -g slidemind@latest` (or `slidem
73
80
  slidemind/
74
81
  ├── package.json npm package metadata, single bin: slidemind
75
82
  ├── README.md end-user quickstart
76
- ├── CLAUDE.md this file
83
+ ├── AGENTS.md this file (CLAUDE.md is a symlink to it)
77
84
  ├── .claude-plugin/
78
85
  │ ├── plugin.json Claude Code plugin manifest (version release-synced to package.json)
79
86
  │ └── marketplace.json Claude Code marketplace — serves the plugin from public npm, unpinned
@@ -144,6 +151,24 @@ slidemind uninstall --for <target> # remove the skill (also clears the bundle
144
151
 
145
152
  **The design truth lives in the add-in, not the CLI.** The `.pptx` is rendered server-side over the local bridge (no local exporter), the corporate design is fetched as a bundle, brand imagery comes from the add-in's engine, and slide reuse (extract / insert / splice) executes in the add-in too. So `create`/`build-pptx`/`push`/`ls engines`/`search`/`insert-slide`/`add-slide` all hard-require an **open PowerPoint host with the slidemind add-in and an active corporate design**. The engine-search + slide-reuse wire contract is in `docs/slidemind-cli-connect/11-engine-search-slide-reuse.md`; see `docs/slidemind-cli-connect/` for the rest.
146
153
 
154
+ ## External skill packs (this repo ships none)
155
+
156
+ Some decks build from a **template pack** (`mode: "fill-template"` in the pack's `skill.json`) rather than from the design bundle. Those packs are distributed privately, on their own — as a harness plugin, an admin-pushed workspace skill, or a hand-installed directory. **This package must never carry, name, or hardcode anything from one.** No layout component names, no template file names, no master-fixed titles, no client names. `src/pptx/fill/` is generic machinery; every pack-specific fact is read from the pack:
157
+
158
+ | Fact | Read from |
159
+ |---|---|
160
+ | semantic name → shape id | `fields.json` |
161
+ | repeat groups | `repeats.json` |
162
+ | immutable tables, hygiene deletions, freeform placeholders | `skill.json` `policy` |
163
+ | layout component naming | `skill.json` `components` — `{ canonical, localized }`, regex sources; `canonical` group 1 is the slide number, `localized` group 1 the locale and group 2 the number |
164
+ | template-fixed slide titles | `skill.json` `policy.fixedTitles` — `{ <locale>: [{ stem, title }] }`, `stem` a case-insensitive regex on the slide file stem |
165
+
166
+ A pack that declares no `components.canonical` fails loudly in `layoutNumber()` — returning null instead would silently demote every master-backed slide to freeform and build a deck that quietly lost its template.
167
+
168
+ Packs resolve through `locateSkillDir()` (`src/builders/resolve-skill.mjs`): `$SLIDEMIND_SKILLS_DIR/<name>` → `~/.config/slidemind/skills/<name>` → `<package>/skills/<name>` → the **harness** skill and plugin dirs (`~/.claude`, `~/.codex`, opencode; both `<name>` and `slidemind-<name>`). That last tier is what makes every distribution channel work — a plugin or admin upload lands the pack in a harness directory, never in ours — and it ranks *after* the package so this CLI's own skills are never shadowed by a stale copy.
169
+
170
+ Pack-dependent integration tests belong in the pack's own repo, not here.
171
+
147
172
  ## Design system ground rules
148
173
 
149
174
  The corporate design is **served by the add-in, not shipped by the CLI.** `slidemind download-bundle` materializes it (keyed by the deck's `.bundle-ref.json`) into `${XDG_CACHE_HOME:-~/.cache}/slidemind/bundles/<presFP>/`:
package/README.md CHANGED
@@ -135,16 +135,20 @@ npx slidemind <command>
135
135
 
136
136
  ### Install as a plugin (Claude Code / Codex)
137
137
 
138
- Both harnesses can install slidemind as a **plugin** from this repo's marketplace instead of the two-command npm flow. The repo is private, so the one-time `marketplace add` uses your existing GitHub credentials (`gh auth login`, a git credential helper, or SSH).
138
+ Both harnesses can install slidemind as a **plugin** instead of the two-command npm flow.
139
139
 
140
- **Claude Code — fully self-contained (no `npm install -g` needed):**
140
+ **Claude Code — fully self-contained (no `npm install -g`, no GitHub account):**
141
141
 
142
142
  ```
143
- /plugin marketplace add STATWORX/intern-slidemind-cli
143
+ /plugin marketplace add https://unpkg.com/slidemind/.claude-plugin/marketplace.json
144
144
  /plugin install slidemind@slidemind
145
145
  ```
146
146
 
147
- The plugin ships both skills *and* the CLI: under the hood Claude Code installs the public npm package and puts `slidemind` on `PATH` inside its sessions (the headless-Chrome heads-up above applies to this install too). Outside Claude Code sessions the command is not on your `PATH` — add the global install if you also want to drive the CLI by hand. Updates ship with every release; apply them via `/plugin`. If background marketplace refreshes fail against the private repo, use SSH for the marketplace add or set `CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1`.
147
+ The marketplace is served straight out of the published npm package — the tarball ships `.claude-plugin/marketplace.json`, and an npm CDN serves it over plain HTTPS. Nothing here needs repo access, and it follows releases automatically (no version in the URL, no version pin in the plugin entry). `https://cdn.jsdelivr.net/npm/slidemind/.claude-plugin/marketplace.json` works the same way.
148
+
149
+ The plugin ships both skills *and* the CLI: Claude Code installs the public npm package and puts `slidemind` on `PATH` inside its sessions (the headless-Chrome heads-up above applies to this install too). Outside Claude Code sessions the command is not on your `PATH` — add the global install if you also want to drive the CLI by hand. Apply updates via `/plugin`.
150
+
151
+ > `/plugin marketplace add STATWORX/intern-slidemind-cli` also works if you have read access to the repo, but the URL above is preferred — it needs no credentials. If background refreshes ever fail against the private repo, use SSH or set `CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1`.
148
152
 
149
153
  **Codex — skills via plugin, CLI via npm:**
150
154
 
@@ -153,7 +157,7 @@ codex plugin marketplace add STATWORX/intern-slidemind-cli
153
157
  codex plugin add slidemind@slidemind
154
158
  ```
155
159
 
156
- Codex plugins carry the skills only — the CLI still comes from `npm install -g slidemind` (the skills walk you through it if it's missing). `slidemind init --for codex` remains the most robust path; it additionally writes an `~/.codex/AGENTS.md` pointer.
160
+ Codex plugins carry the skills only — the CLI still comes from `npm install -g slidemind` (the skills walk you through it if it's missing). Codex clones the repo for this, so it needs read access; without it, get the skills from your workspace's Codex admin skill upload and the CLI from npm. `slidemind init --for codex` remains the most robust path; it additionally writes an `~/.codex/AGENTS.md` pointer.
157
161
 
158
162
  > Already ran `slidemind init` and switching to a plugin? Drop the copied skills once with `slidemind uninstall --for claude` (or `--for codex`) so they don't duplicate the plugin's.
159
163
 
package/bin/slidemind.mjs CHANGED
@@ -468,6 +468,13 @@ async function cmdBuildPptx(rest) {
468
468
  deckDir,
469
469
  locale: skill.locale ?? "en",
470
470
  srcDir: SRC_DIR,
471
+ // Both are the PACK's contract, read from its skill.json — this CLI
472
+ // knows no layout names and no template-fixed titles of its own.
473
+ components: {
474
+ ...(skill.manifest?.components ?? {}),
475
+ skillDir: skill.skillDir,
476
+ },
477
+ policy: skill.manifest?.policy ?? {},
471
478
  onLog: (line) => process.stdout.write(` ${line}\n`),
472
479
  });
473
480
  for (const w of ff.warnings) process.stderr.write(` warning: ${w}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slidemind",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Connect Claude Code, Codex & opencode to the slidemind PowerPoint add-in — let your coding agent build and edit native, on-brand PowerPoint decks against your active corporate design, from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,8 @@
20
20
  "skills/",
21
21
  ".claude-plugin/",
22
22
  ".codex-plugin/",
23
- "CLAUDE.md",
23
+ ".agents/plugins/",
24
+ "AGENTS.md",
24
25
  "README.md"
25
26
  ],
26
27
  "scripts": {
@@ -840,10 +840,10 @@ export async function buildDeck(deckDir, opts = {}) {
840
840
  if (!fs.existsSync(slidesDir) || !fs.statSync(slidesDir).isDirectory()) {
841
841
  throw new Error(`Expected a 'slides/' folder in ${deckDir}`);
842
842
  }
843
- if (skill.mode === "fill-template" && !opts.internalProposalFreeformRender) {
844
- // Proposal decks are PPTX-native. The exporter may render freeform JSX
843
+ if (skill.mode === "fill-template" && !opts.internalFillFreeformRender) {
844
+ // fill-template decks are PPTX-native. The exporter may render freeform JSX
845
845
  // inserts internally, but `slidemind build` should not create a lossy
846
- // presentation.html artifact for proposal decks.
846
+ // presentation.html artifact for them.
847
847
  throw new Error(
848
848
  `Deck ${path.basename(deckDir)} uses skill '${skill.skillName}' (mode ` +
849
849
  `fill-template); it has no HTML preview. Run 'slidemind build-pptx ` +
@@ -92,12 +92,15 @@ export function resolveDeckMode(deckDir) {
92
92
  }
93
93
  }
94
94
 
95
- // Skill packs can live outside the npm package: confidential template packs
96
- // (e.g. proposal masters) install to the user-level skills dir and are found
97
- // FIRST, so the public package never has to carry them. Lookup order:
95
+ // Skill packs can live outside the npm package: private, org-internal packs
96
+ // (templates, brand-specific assets) are distributed on their own and this
97
+ // package never carries them. Lookup order:
98
98
  // 1. $SLIDEMIND_SKILLS_DIR/<name> (tests / non-standard installs)
99
99
  // 2. ~/.config/slidemind/skills/<name>
100
- // 3. <package>/skills/<name>
100
+ // 3. <package>/skills/<name> (this CLI's own skills win on their names)
101
+ // 4. the harness skill + plugin dirs (see harnessSkillDirs)
102
+ // 3 precedes 4 so adding 4 is strictly additive: it is reached only for names
103
+ // this package does not ship, i.e. exactly the externally-distributed packs.
101
104
  export function userSkillsRoot() {
102
105
  return (
103
106
  process.env.SLIDEMIND_SKILLS_DIR ||
@@ -109,12 +112,69 @@ export function userSkillsRoot() {
109
112
  );
110
113
  }
111
114
 
112
- function locateSkillDir(skillName) {
115
+ // Every distribution channel a pack can arrive through — a Claude Code or
116
+ // Codex plugin, or a workspace/admin-pushed skill — installs it into a HARNESS
117
+ // directory, not ours. Without these the agent reads the pack's SKILL.md and
118
+ // the build then fails to find the pack's own templates, which looks like a
119
+ // broken pack rather than a lookup gap.
120
+ //
121
+ // Installers namespace copied skills as `slidemind-<name>`, so both spellings
122
+ // are tried. Plugin caches nest as <root>/<marketplace>/<plugin>/skills/<name>.
123
+ function harnessRoots() {
124
+ const home = os.homedir();
125
+ return [
126
+ path.join(home, ".claude"),
127
+ path.join(home, ".codex"),
128
+ // opencode keeps its config under XDG.
129
+ path.join(
130
+ process.env.XDG_CONFIG_HOME || path.join(home, ".config"),
131
+ "opencode",
132
+ ),
133
+ ];
134
+ }
135
+
136
+ function harnessSkillDirs(skillName) {
137
+ const names = [skillName, `slidemind-${skillName}`];
138
+ const dirs = [];
139
+ for (const root of harnessRoots()) {
140
+ for (const name of names) dirs.push(path.join(root, "skills", name));
141
+ // Plugin caches: <root>/plugins/cache/<marketplace>/<plugin>/skills/<name>
142
+ const cacheRoot = path.join(root, "plugins", "cache");
143
+ let marketplaces = [];
144
+ try {
145
+ marketplaces = fs.readdirSync(cacheRoot);
146
+ } catch {
147
+ continue;
148
+ }
149
+ for (const mp of marketplaces) {
150
+ let plugins = [];
151
+ try {
152
+ plugins = fs.readdirSync(path.join(cacheRoot, mp));
153
+ } catch {
154
+ continue;
155
+ }
156
+ for (const plugin of plugins) {
157
+ for (const name of names) {
158
+ dirs.push(path.join(cacheRoot, mp, plugin, "skills", name));
159
+ }
160
+ }
161
+ }
162
+ }
163
+ return dirs;
164
+ }
165
+
166
+ // Exported for tests: the pack-location rules are the contract every external
167
+ // distribution channel depends on, and they deserve assertions that do not
168
+ // also have to satisfy design resolution.
169
+ export function locateSkillDir(skillName) {
113
170
  const candidates = [
114
171
  path.join(userSkillsRoot(), skillName),
115
172
  path.join(PACKAGE_ROOT, "skills", skillName),
173
+ ...harnessSkillDirs(skillName),
116
174
  ];
117
- return firstExisting(candidates) ?? candidates[candidates.length - 1];
175
+ // The fallback stays the package path, so a missing pack still reports the
176
+ // location a bundled skill would live at rather than a harness cache dir.
177
+ return firstExisting(candidates) ?? path.join(PACKAGE_ROOT, "skills", skillName);
118
178
  }
119
179
 
120
180
  export function resolveSkill(skillName, planMeta = {}, opts = {}) {
@@ -1,5 +1,5 @@
1
1
  // The fill-template deck builder — the host-free `build-pptx` path for
2
- // proposal-style packs (mode: "fill-template" in the pack's skill.json).
2
+ // template packs (mode: "fill-template" in the pack's skill.json).
3
3
  //
4
4
  // Assembly direction: the template .pptx is cloned WHOLE (masters, layouts,
5
5
  // media, tags, embeddings), then only declared shapes inside the clone are
@@ -74,7 +74,7 @@ export async function buildFillTemplateDeck({ deckDir, skill, outPath, onLog })
74
74
  problems.push(err.message);
75
75
  continue;
76
76
  }
77
- const layout = layoutNumber(parsed.component, locale);
77
+ const layout = layoutNumber(parsed.component, locale, pack.components);
78
78
  if (!layout) {
79
79
  problems.push(`${file}: <${parsed.component}> is a freeform (create-slides) slide with no ` +
80
80
  `rendered artifact next to it — 'slidemind build-pptx' renders slides/${file.replace(/\.jsx$/, "")}.pptx ` +
@@ -190,6 +190,9 @@ function loadPack(skill) {
190
190
  fields,
191
191
  repeats: read("repeats.json", {}),
192
192
  policy: skill.manifest.policy ?? {},
193
+ // The pack's layout-component naming contract (see parse-slides.mjs).
194
+ // skillDir rides along so a bad pattern names the pack that shipped it.
195
+ components: { ...(skill.manifest.components ?? {}), skillDir: skill.skillDir },
193
196
  };
194
197
  }
195
198
 
@@ -283,7 +286,7 @@ function checkIdentities(sequence, warnings, problems) {
283
286
  problems.push(`WP count mismatch: slide 10 declares ${wpItems.length} work packages but there are ${details.length} WP-detail files (slide 11)`);
284
287
  }
285
288
  // Every WP detail must carry FULL bullet lists — a section left empty (or a
286
- // one-liner) is a defect in a client proposal, not a style choice.
289
+ // one-liner) is a defect in a client deliverable, not a style choice.
287
290
  details.forEach((d, i) => {
288
291
  for (const section of ["services", "assumptions", "deliverables"]) {
289
292
  const lines = asLines(d.props?.[section]);
@@ -1,12 +1,12 @@
1
1
  // In-deck freeform slides for fill-template decks.
2
2
  //
3
- // Contract: a proposal deck's slides/ may carry create-slides freeform JSX
3
+ // Contract: a fill-template deck's slides/ may carry create-slides freeform JSX
4
4
  // (NN-name.jsx composing the design bundle's layouts) directly next to the
5
5
  // master-backed slides — no sibling deck. The rendered native artifact lives
6
6
  // beside its source as NN-name.pptx; the fill engine inserts that artifact at
7
7
  // the filename position like any native slide. This module keeps the
8
8
  // artifacts fresh: stale or missing renders go through the add-in's render
9
- // path (the ONLY host-dependent step of a proposal build) and are folded to
9
+ // path (the ONLY host-dependent step of such a build) and are folded to
10
10
  // pruned one-slide packages. Unchanged freeform slides rebuild fully offline.
11
11
 
12
12
  import crypto from "node:crypto";
@@ -22,22 +22,26 @@ import { layoutNumber } from "./parse-slides.mjs";
22
22
 
23
23
  const SIDE_CAR = ".freeform-renders.json";
24
24
 
25
- // The template's Challenge/Solution slides carry FIXED titles; freeform
26
- // replacements must keep them so the deck reads like the master.
27
- const FIXED_TITLES = {
28
- en: [
29
- { stem: /challenge/i, title: "Challenge" },
30
- { stem: /solution/i, title: "Solution" },
31
- ],
32
- de: [
33
- { stem: /challenge|herausforderung/i, title: "Herausforderung" },
34
- { stem: /solution|loesung|lösung/i, title: "Lösung" },
35
- ],
36
- };
25
+ // Some templates fix a slide's title (the master prints it, so a freeform
26
+ // replacement must keep it or the deck stops reading like the master). WHICH
27
+ // slides, and in which locale, is the pack's business — it declares them in
28
+ // skill.json as policy.fixedTitles:
29
+ //
30
+ // "fixedTitles": {
31
+ // "en": [ { "stem": "agenda", "title": "Agenda" } ],
32
+ // "de": [ { "stem": "agenda|ablauf", "title": "Ablauf" } ]
33
+ // }
34
+ //
35
+ // `stem` is a case-insensitive regex matched against the slide file's stem.
36
+ // A pack that declares none simply gets no title warnings.
37
+ function fixedTitleRules(policy, locale) {
38
+ const all = policy?.fixedTitles ?? {};
39
+ return all[locale] ?? all.en ?? [];
40
+ }
37
41
 
38
- function isFreeformSource(src) {
42
+ function isFreeformSource(src, components) {
39
43
  const comp = src.match(/<([A-Z][A-Za-z0-9]*)/)?.[1];
40
- return Boolean(comp) && layoutNumber(comp, "en") === null;
44
+ return Boolean(comp) && layoutNumber(comp, "en", components) === null;
41
45
  }
42
46
 
43
47
  function contentHash(parts) {
@@ -53,9 +57,10 @@ function slideText(bytes) {
53
57
  return [...(xml ?? "").matchAll(/<a:t>([^<]*)<\/a:t>/g)].map((m) => m[1]).join("\n");
54
58
  }
55
59
 
56
- function fixedTitleWarning(stem, bytes, locale) {
57
- const rules = FIXED_TITLES[locale] ?? FIXED_TITLES.en;
58
- const rule = rules.find((r) => r.stem.test(stem));
60
+ function fixedTitleWarning(stem, bytes, locale, policy) {
61
+ const rule = fixedTitleRules(policy, locale).find((r) =>
62
+ new RegExp(r.stem, "i").test(stem),
63
+ );
59
64
  if (!rule) return null;
60
65
  if (slideText(bytes).includes(rule.title)) return null;
61
66
  return (
@@ -69,7 +74,14 @@ function fixedTitleWarning(stem, bytes, locale) {
69
74
  * `{ rendered, warnings }`; throws with the offending file named when a stale
70
75
  * render is needed but the paired backend cannot render.
71
76
  */
72
- export async function ensureFreeformRenders({ deckDir, locale = "en", srcDir, onLog = () => {} }) {
77
+ export async function ensureFreeformRenders({
78
+ deckDir,
79
+ locale = "en",
80
+ srcDir,
81
+ components,
82
+ policy = {},
83
+ onLog = () => {},
84
+ }) {
73
85
  const slidesDir = path.join(deckDir, "slides");
74
86
  const jsxFiles = fs.existsSync(slidesDir)
75
87
  ? fs.readdirSync(slidesDir).filter((f) => f.endsWith(".jsx")).sort()
@@ -77,7 +89,9 @@ export async function ensureFreeformRenders({ deckDir, locale = "en", srcDir, on
77
89
  const items = [];
78
90
  for (const file of jsxFiles) {
79
91
  const src = fs.readFileSync(path.join(slidesDir, file), "utf8");
80
- if (isFreeformSource(src)) items.push({ file, stem: file.replace(/\.jsx$/, ""), src });
92
+ if (isFreeformSource(src, components)) {
93
+ items.push({ file, stem: file.replace(/\.jsx$/, ""), src });
94
+ }
81
95
  }
82
96
  const warnings = [];
83
97
  if (items.length === 0) return { rendered: 0, warnings };
@@ -149,7 +163,7 @@ export async function ensureFreeformRenders({ deckDir, locale = "en", srcDir, on
149
163
  for (const it of items) {
150
164
  const target = path.join(slidesDir, `${it.stem}.pptx`);
151
165
  if (!fs.existsSync(target)) continue;
152
- const warn = fixedTitleWarning(it.stem, fs.readFileSync(target), locale);
166
+ const warn = fixedTitleWarning(it.stem, fs.readFileSync(target), locale, policy);
153
167
  if (warn) warnings.push(warn);
154
168
  }
155
169
  return { rendered: stale.length, warnings };
@@ -1,27 +1,61 @@
1
- // Parser for proposal slide files. Proposal JSX is declarative by contract —
2
- // one default export returning exactly one <SlideProposalLayoutNN …/> element
3
- // whose props are data literals. That constraint is what makes a real JSX
4
- // runtime unnecessary: attributes are scanned textually and brace expressions
5
- // are evaluated as plain JS literals in an empty vm sandbox.
1
+ // Parser for fill-template slide files. Their JSX is declarative by contract —
2
+ // one default export returning exactly one <SomeLayout …/> element whose props
3
+ // are data literals. That constraint is what makes a real JSX runtime
4
+ // unnecessary: attributes are scanned textually and brace expressions are
5
+ // evaluated as plain JS literals in an empty vm sandbox.
6
+ //
7
+ // The component NAMES are the pack's business, not this engine's: a pack ships
8
+ // its own layouts under its own naming scheme, so it declares the scheme in
9
+ // skill.json and this file only applies it.
6
10
 
7
11
  import vm from "node:vm";
8
12
 
9
- // Accepted component spellings → template slide number.
10
- // SlideProposalLayout07 (canonical, locale-neutral)
11
- // SlideProposalEn07Slide7 / SlideProposalDe07Slide7 (generated concrete names)
12
- export function layoutNumber(component, locale) {
13
- let m = component.match(/^SlideProposalLayout(\d{2})$/);
13
+ // Compiled once per distinct pattern — layoutNumber runs per slide file.
14
+ const patternCache = new Map();
15
+ function compile(pattern, which, skillDir) {
16
+ let re = patternCache.get(pattern);
17
+ if (re) return re;
18
+ try {
19
+ re = new RegExp(pattern);
20
+ } catch (err) {
21
+ throw new Error(
22
+ `pack ${skillDir ?? "(unknown)"}: skill.json components.${which} is not a ` +
23
+ `valid regular expression (${err.message})`,
24
+ );
25
+ }
26
+ patternCache.set(pattern, re);
27
+ return re;
28
+ }
29
+
30
+ // Map a component name → the template slide number it fills, or null when the
31
+ // component is not master-backed at all (i.e. a freeform slide).
32
+ //
33
+ // `components` comes from the pack's skill.json and declares two patterns:
34
+ // canonical — locale-neutral spelling; capture group 1 is the slide number
35
+ // localized — optional generated spelling; group 1 is the locale, group 2
36
+ // the slide number (so a locale mismatch can be reported)
37
+ export function layoutNumber(component, locale, components) {
38
+ if (!components || !components.canonical) {
39
+ throw new Error(
40
+ "fill-template pack declares no components.canonical pattern in " +
41
+ "skill.json — the pack owns its layout naming contract and must " +
42
+ "declare it, e.g. { \"components\": { \"canonical\": \"^MyLayout(\\\\d{2})$\" } }",
43
+ );
44
+ }
45
+ let m = component.match(compile(components.canonical, "canonical", components.skillDir));
14
46
  if (m) return { no: Number(m[1]) };
15
- m = component.match(/^SlideProposal(En|De)(\d{2})Slide\d+$/);
16
- if (m) {
17
- const compLocale = m[1].toLowerCase();
18
- return {
19
- no: Number(m[2]),
20
- warn:
21
- compLocale === locale
22
- ? `use the canonical <SlideProposalLayout${m[2]}> alias`
23
- : `component locale "${compLocale}" does not match deck locale "${locale}"`,
24
- };
47
+ if (components.localized) {
48
+ m = component.match(compile(components.localized, "localized", components.skillDir));
49
+ if (m) {
50
+ const compLocale = String(m[1]).toLowerCase();
51
+ return {
52
+ no: Number(m[2]),
53
+ warn:
54
+ compLocale === locale
55
+ ? `use the canonical alias for slide ${Number(m[2])}`
56
+ : `component locale "${compLocale}" does not match deck locale "${locale}"`,
57
+ };
58
+ }
25
59
  }
26
60
  return null;
27
61
  }
@@ -81,7 +115,7 @@ function evalLiteral(expr, file) {
81
115
  return value === undefined ? undefined : JSON.parse(JSON.stringify(value));
82
116
  } catch (err) {
83
117
  throw new Error(`${file}: cannot evaluate prop expression (${err.message}). ` +
84
- `Proposal props must be data literals — strings, numbers, arrays, objects.`);
118
+ `Slide props must be data literals — strings, numbers, arrays, objects.`);
85
119
  }
86
120
  }
87
121
 
@@ -136,7 +170,7 @@ export function parseSlideFile(source, file) {
136
170
  const inner = closeIdx > 0 ? src.slice(i + 1, closeIdx).trim() : "";
137
171
  if (inner) {
138
172
  throw new Error(
139
- `${file}: <${component}> has children. Master-backed proposal slides are ` +
173
+ `${file}: <${component}> has children. Master-backed slides are ` +
140
174
  `self-closing props-only elements; freeform content belongs to create-slides.`,
141
175
  );
142
176
  }
@@ -30,7 +30,7 @@ const stripHighlight = (rPr) =>
30
30
 
31
31
  const SHAPE_TAGS = ["sp", "pic", "cxnSp", "graphicFrame"];
32
32
 
33
- // Top-level shape blocks of one kind. The proposal masters keep all editable
33
+ // Top-level shape blocks of one kind. Template masters keep all editable
34
34
  // shapes at spTree top level (verified by inventory); grouped shapes are not
35
35
  // addressed by the pack metadata.
36
36
  export function* blocks(xml, tag) {