Skip to content

Commit 7daf270

Browse files
Merge branch 'main' into crew/docs-contributing-onboarding
2 parents b778254 + 02f4bf3 commit 7daf270

124 files changed

Lines changed: 2798 additions & 1216 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ jobs:
2929
run: cd sdpm/vendor && sha256sum -c SHA256SUMS
3030
- name: Test
3131
run: uv run pytest tests/ -v --cov=sdpm --cov-report=term
32+
# Report only: the text each session puts in front of the model (at start, and with
33+
# the guides its role names), with +/- against the base commit when it can be measured.
34+
- name: Context size report
35+
env:
36+
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
37+
run: |
38+
base_args=()
39+
if [[ "$BASE_SHA" =~ ^[0-9a-f]{40}$ && "$BASE_SHA" != 0000000000000000000000000000000000000000 ]] \
40+
&& git fetch --quiet --depth=1 origin "$BASE_SHA" \
41+
&& git worktree add --quiet --detach "$RUNNER_TEMP/base" "$BASE_SHA" \
42+
&& uv run python scripts/context_size.py --root "$RUNNER_TEMP/base" --json "$RUNNER_TEMP/base.json" > /dev/null; then
43+
base_args=(--base "$RUNNER_TEMP/base.json")
44+
else
45+
echo "::notice::Base commit not measured; the report has no +/- column."
46+
fi
47+
uv run python scripts/context_size.py --json "$RUNNER_TEMP/context-size.json" "${base_args[@]}" >> "$GITHUB_STEP_SUMMARY"
3248
3349
# Local-surface guard: boots servers/local over real stdio (no mocks) and
3450
# exercises filesystem-anchored resolution (templates, workflows). The unit

‎CHANGELOG.md‎

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,69 @@ Under an Upgrading section, the bullets after **Local installs (`sdpm update`).*
1515

1616
### Added
1717

18-
- **Speaker notes policy** (`deck.json` `"notesMode"`). `"keep"` (the default, unchanged
19-
behaviour) writes each slide's `notes` as speaker notes; `"strip"` leaves them out of the
20-
.pptx; `"export"` leaves them out and writes them to `<output stem>.notes.md` next to the
21-
.pptx (one `## pageNN — title` section per slide, `{{...}}` styling removed), returned as
22-
`notes_path` by `generate_pptx`. A deck handed to an audience no longer carries the
23-
presenter's script, which imported slides often bring along in their original notes. The
24-
slide files keep their `notes`, so composing and `check_specs` are unchanged; an invalid
25-
value is a `check_specs` error and stops the build. Partial builds (`iso.pptx`) write no
26-
notes file; a full build in `keep` or `strip` mode deletes a notes file left by an earlier
27-
`export` build. PPTX decks only. On the AWS stack the remote `generate_pptx` uploads the
28-
notes beside the deck (`pptx/<deckId>/<build>.notes.md`, deck record `notesS3Key`) and
29-
returns `notesS3Key` and a signed `notesUrl`.
18+
- **Speaker notes destination** (`deck.json` `"speakerNotes"`, #666). `"pptx"` (the
19+
default, unchanged behaviour) writes each slide's `notes` as speaker notes; `"markdown"`
20+
leaves them out of the .pptx and writes them to `<output stem>.notes.md` beside it (one
21+
`## pageNN — title` section per slide, `{{...}}` styling removed), returned as `notes_path`
22+
by `generate_pptx`. A deck handed to an audience no longer carries the presenter's script,
23+
which imported slides often bring along in their original notes. The slide files keep their
24+
`notes`, so composing is unchanged; an invalid value is a `check_specs` error and stops the
25+
build. Partial builds (`iso.pptx`) write no notes file; a full `"pptx"` build deletes a
26+
notes file left by an earlier `"markdown"` build. PPTX decks only. On the AWS stack the
27+
remote `generate_pptx` uploads the notes beside the deck (`pptx/<deckId>/<build>.notes.md`,
28+
deck record `notesS3Key`) and returns `notesS3Key` and a signed `notesUrl`; the rebuild
29+
after `run_python` uploads them and updates `notesS3Key` the same way.
30+
- **Download PPTX with or without speaker notes** (Web UI, both modes). The deck list "⋯"
31+
menu has two download items, with speaker notes and without speaker notes; on the AWS
32+
stack the deck view's PPTX button opens a menu with the same two choices (the local
33+
"Open PPTX" button is unchanged). "With speaker notes" is unavailable for a deck built with `speakerNotes: "markdown"`,
34+
whose stored .pptx holds no notes. The copy without notes is made from the stored .pptx
35+
without a rebuild (`sdpm.engine.notes.strip_speaker_notes`): `GET /decks/{id}/pptx?notes=without`
36+
on the AWS stack, which keeps it beside the build as `pptx/<deckId>/<build>.nonotes.pptx`
37+
for later downloads, and `GET /api/decks/{id}/pptx?notes=without` locally. Deck list items
38+
and the deck detail carry `speakerNotes` (`"pptx"` | `"markdown"`) for the stored .pptx.
39+
- **`deck-json-spec` guide.** Every `deck.json` field of PPTX and HTML decks in one list:
40+
required or optional, default, who writes it and which format it affects.
41+
`start_presentation` returns it as `static.deck_spec`, and the AWS stack's agent puts it in
42+
the orchestrator's system prompt; `slide-json-spec` and `slide-html-spec` point to it.
3043
- **Area charts** (`chartType: "area"`, #620). An area chart takes the same categories and
3144
series as a bar chart; `stacked: true` stacks the areas, and series `color`, `valueAxis`,
3245
`categoryAxis`, `style`, `legend` and `dataLabels` work as for `bar`. `pptx_to_json`
3346
reads an area or stacked area chart back as `area`, so an edited one is rebuilt from its
3447
JSON; a 100% stacked area chart still keeps its `_chartXml`. New `chart-area` guide.
3548
Local mode and the AWS stack (SdpmRuntime).
49+
- **Context size report** (#679). `scripts/context_size.py` measures the text each session
50+
puts in front of the model: server instructions, tool definitions, prompts, `start_*`
51+
payloads, guides, bundled styles, the agent system prompts and the text the agent inserts,
52+
and client wiring text, per item and per role bundle (at start, and with the guides the role
53+
names), in chars, bytes and approximate tokens (tiktoken `o200k_base`). Contributor files
54+
(AGENTS.md, steering) get a table of their own, and the report lists what it does not
55+
measure. CI writes the table, with +/- against the base commit, to the `python` job
56+
summary. Report only; nothing fails on size. Development only.
3657

3758
### Fixed
3859

60+
- **A textbox border keeps its `lineOpacity`** (#667). The textbox builder ignored
61+
`lineOpacity`, so a translucent border came out fully opaque, and a PPTX → JSON → PPTX
62+
round trip lost the opacity `pptx_to_json` had read. It now writes the border alpha as
63+
shapes do. Local mode and the AWS stack (SdpmRuntime).
64+
65+
- **Charts keep theme styling when `valueAxis` or `categoryAxis` is set.** Setting either
66+
no longer drops theme styling of the axis tick labels, axis lines and title. Only a chart
67+
read back from a PPTX keeps the styling it came with; JSON written by hand or by an agent
68+
(e.g. a radar chart that sets only the scoring scale) now gets the themed tick-label
69+
size, colour and font. Local mode and the AWS stack (SdpmRuntime). (#630)
70+
71+
- **Built PPTX decks carry a document title and language.** The PPTX title (`dc:title`)
72+
came from `deck.json` `title`, or, without one, from the first slide's title placeholder.
73+
The orchestrator did not write `title`, and a cover drawn with elements keeps no title
74+
placeholder, so many decks had no document title. The orchestrator now writes `title`
75+
(as the cover states it) and `language` into `deck.json` with the outline, and
76+
`check_specs` warns when a PPTX deck has no `title` (a warning; it does not stop the
77+
build). Translation now translates `title` along with the slides (`translate_extract.py`
78+
puts it in the dictionary, `translate_apply.py` writes it back) and sets the variant's
79+
`language` to `--target-lang`. Existing decks are unchanged until their `deck.json` gets a
80+
`title`. Local mode and the AWS stack (SdpmRuntime, SdpmData).
3981
- **Moving between Decks, Styles and Templates no longer flashes the screen.** The rail and
4082
the logo were plain links, so every move reloaded the page: the whole screen was drawn
4183
again, the text showed in English for a moment before the chosen language, and the Cloud
@@ -47,6 +89,11 @@ Under an Upgrading section, the bullets after **Local installs (`sdpm update`).*
4789
axis, plot area or chart space, out of schema order. PowerPoint accepts that, but strict
4890
readers and validators can reject the file. It is now inserted at its schema position.
4991
Local mode and the AWS stack (SdpmRuntime).
92+
- **Bar chart gap width and overlap follow the OOXML schema order** (#665). A bar chart's
93+
`c:gapWidth` and `c:overlap` were appended after its axis IDs, out of schema order, for
94+
clustered and stacked bars. PowerPoint accepts that, but strict readers and validators can
95+
reject the file. They are now inserted before the axis IDs; their values are unchanged.
96+
Local mode and the AWS stack (SdpmRuntime).
5097
- **A shape's `paragraphs` take the documented `list` key** (#586). `list: {"type": "disc"}`
5198
was ignored on shapes, so the paragraph had no bullet; it now makes a bullet, and a
5299
numbered `type` and `level` work as in a textbox. `bullet` still works as before. Local
@@ -96,6 +143,14 @@ bundle. Charts gain a radar type, and `deploy.sh` checks who owns its source buc
96143
The Claude Desktop bundle (`sdpm.mcpb`) now carries it as its icon. Web UI
97144
(`deploy_webui.sh`) and the next release's bundle.
98145

146+
### Removed
147+
148+
- **Dead layout routing code.** The `_spread_overlapping_bends` pass and the bend-spreading
149+
helpers only it used (`_resolve_crossing_search`, `_separate_close_bends`,
150+
`_align_same_source_bends`, `_separate_close_horizontal_segments`, `_apply_bend_shift_*`,
151+
`_update_bend_x`, `_min_bend_separation`, `_find_first_crossing`) are gone from
152+
`sdpm.engine.layout`. Nothing called them, so generated layouts are unchanged.
153+
99154
### Security
100155

101156
- **deploy.sh: the source bucket is account-scoped and its owner is checked.** `deploy.sh`
@@ -186,6 +241,10 @@ its data directories, and XML from outside the repository goes through one expli
186241

187242
### Added
188243

244+
- **Font-size token check covers inline directives.** `{{22pt:text}}`, `{{bold,18pt:text}}` and
245+
`{{24pt,link:URL:text}}` are now checked against the style's `--fs-*` tokens like `fontSize`
246+
fields, nested ones like `{{bold:{{22pt:text}}}}` included, and reported with an `:inline`
247+
location (part of #135).
189248
- **A writing guide for Japanese decks (`writing-ja`).** For a Japanese deck the
190249
orchestrator reads it before writing the outline, and composers read it before writing any
191250
slide text in every pass, in both PPTX and HTML. It says how headlines, bullets, diagram labels and speaker notes are

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ make format # ruff format (write changes)
4242

4343
For web-ui / infra TypeScript changes, use `npm ci` in the respective directory.
4444

45+
When you change a role document, a guide, a prompt or a tool description, check how much text it puts in front of the model: `uv run python scripts/context_size.py` prints chars, bytes and approximate tokens per session (for example, Local MCP orchestrator = instructions + tool definitions + the `start_presentation` payload). CI writes the same table, with +/- against the base commit, to the job summary of the `python` job. At equal quality, shorter wins.
46+
4547
The [Developer guide](docs/en/developer-guide.md) covers working from a checkout next to an installed release (`make register-dev`, `npm run dev:local`) and deploying with the CDK.
4648

4749
## Security scanning

‎agent/modes/__init__.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ def _role(tool: str) -> Part:
7272
"run_style_python", "list_styles", "analyze_template", "read_attachment",
7373
]
7474

75+
# The deck.json field reference start_presentation returns with the role document:
76+
# deck-independent, so it sits before the cache point and is cached with it.
77+
_DECK_SPEC = Part(
78+
Source.mcp("start_presentation", {}, pick="static.deck_spec"), target="system", label="deck-json-spec",
79+
)
80+
7581
_INTERACTION_DIALOGUE = Part(Source.file("wiring/interaction_dialogue"), target="system")
7682
_INTERACTION_FAST = Part(Source.file("wiring/interaction_fast"), target="system")
7783

@@ -82,6 +88,7 @@ def _orchestrator(*wiring: Part, use_composer: bool = True, **overrides) -> Mode
8288
parts=[
8389
_COMMON_LANGUAGE,
8490
_role("start_presentation"),
91+
_DECK_SPEC,
8592
*wiring,
8693
_COMMON_ATTACHMENTS,
8794
*([_WIRING_COMPOSE_REPORT] if use_composer else []),

‎api/index.py‎

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Ported from spec-driven-presentation-maker-web deck-api, upload-api.
1515
"""
1616

17+
import io
1718
import json
1819
import os
1920
import re
@@ -44,7 +45,7 @@
4445
presigned_html_url,
4546
slide_size,
4647
)
47-
from shared.artifact_keys import build_html_preview_key_map, preview_prefix as html_preview_prefix
48+
from shared.artifact_keys import build_html_preview_key_map, no_notes_pptx_key, preview_prefix as html_preview_prefix
4849
from shared.review import (
4950
MAX_BODY_BYTES as REVIEW_MAX_BODY_BYTES,
5051
build_review_file,
@@ -197,6 +198,14 @@ def _html_presigned(key: str, purpose: str = "view", deck_name: str = "") -> Opt
197198
return None
198199

199200

201+
PPTX_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
202+
203+
204+
def _is_pptx_key(key: object) -> bool:
205+
"""A key under ``pptx/`` ending in ``.pptx``, without ``..``."""
206+
return isinstance(key, str) and key.startswith("pptx/") and key.endswith(".pptx") and ".." not in key
207+
208+
200209
def _pptx_download_url(key: str, deck_name: str = "") -> Optional[str]:
201210
"""Signed URL that downloads a built PPTX as ``<deck title>.pptx``.
202211
@@ -206,7 +215,7 @@ def _pptx_download_url(key: str, deck_name: str = "") -> Optional[str]:
206215
Without CloudFront configured, an S3 presign on the API's client (as before).
207216
None for a key outside ``pptx/**.pptx``.
208217
"""
209-
if not isinstance(key, str) or not key.startswith("pptx/") or not key.endswith(".pptx") or ".." in key:
218+
if not _is_pptx_key(key):
210219
return None
211220
disposition = attachment_disposition(deck_name, ".pptx")
212221
return _cf_signed_url(key, query={"response-content-disposition": disposition}) or s3_client.generate_presigned_url(
@@ -267,6 +276,13 @@ def _get_deck_extras(deck_items: List[Dict]) -> Dict[str, Dict]:
267276
return extras
268277

269278

279+
def _speaker_notes(record: Dict) -> str:
280+
"""How the stored PPTX holds its speaker notes: ``"markdown"`` when the last build
281+
wrote them to a separate file (``notesS3Key``, deck.json ``speakerNotes``
282+
``"markdown"``), so there is no download with notes; ``"pptx"`` otherwise."""
283+
return "markdown" if record.get("notesS3Key") else "pptx"
284+
285+
270286
def _deck_summary(item: Dict, extras: Dict[str, Dict], owner: bool = False) -> Dict[str, Any]:
271287
"""Build a consistent deck summary dict from a DDB item.
272288
@@ -290,6 +306,7 @@ def _deck_summary(item: Dict, extras: Dict[str, Dict], owner: bool = False) -> D
290306
"visibility": item.get("visibility", "private"),
291307
# A built PPTX exists (GET /decks/{id}/pptx signs it on demand; the list stays URL-free).
292308
"hasPptx": bool(item.get("pptxS3Key")),
309+
"speakerNotes": _speaker_notes(item),
293310
}
294311
if owner:
295312
summary["chatSessionId"] = _chat_session_id(item)
@@ -1072,6 +1089,13 @@ def get_deck_pptx(deck_id: str) -> Any:
10721089
Same read permission as get_deck (owner, or viewer of a public deck); 404 when no
10731090
PPTX is built or the deck is an HTML deck (get_deck gives those no pptxUrl either).
10741091
1092+
Query parameters:
1093+
notes: ``without`` signs a copy without speaker notes, made from the stored
1094+
PPTX on the first such request and kept beside it
1095+
(``pptx/<deck>/<build>.nonotes.pptx``; a rebuild has a new build id, so the
1096+
copy always matches the stored PPTX). Any other value, or none, signs the
1097+
stored PPTX.
1098+
10751099
Returns:
10761100
Dict with url and expiresIn (seconds).
10771101
"""
@@ -1083,12 +1107,40 @@ def get_deck_pptx(deck_id: str) -> Any:
10831107

10841108
deck = decision.deck
10851109
pptx_key = deck.get("pptxS3Key")
1086-
url = _pptx_download_url(pptx_key, deck.get("name", "")) if pptx_key else None
1087-
if not url or is_html_deck(_read_deck_json(deck_id)):
1110+
if not _is_pptx_key(pptx_key) or is_html_deck(_read_deck_json(deck_id)):
10881111
return {"error": "PPTX not built yet"}, 404
1112+
if app.current_event.get_query_string_value("notes") == "without":
1113+
pptx_key = _no_notes_copy(pptx_key)
1114+
url = _pptx_download_url(pptx_key, deck.get("name", ""))
10891115
return {"url": url, "expiresIn": PRESIGNED_URL_EXPIRY}
10901116

10911117

1118+
def _no_notes_copy(pptx_key: str) -> str:
1119+
"""Key of the copy of ``pptx_key`` without speaker notes, made on first use.
1120+
1121+
The copy is ``sdpm.engine.notes.strip_speaker_notes`` of the stored PPTX (no
1122+
rebuild); a read error or a broken PPTX propagates (500).
1123+
"""
1124+
from sdpm.engine.notes import strip_speaker_notes
1125+
1126+
key = no_notes_pptx_key(pptx_key)
1127+
if key is None:
1128+
raise ValueError(f"not a stored PPTX key: {pptx_key!r}")
1129+
try:
1130+
s3_client.head_object(Bucket=BUCKET_NAME, Key=key)
1131+
exists = True
1132+
except Exception:
1133+
exists = False
1134+
if exists:
1135+
return key
1136+
body = s3_client.get_object(Bucket=BUCKET_NAME, Key=pptx_key)["Body"].read()
1137+
out = io.BytesIO()
1138+
removed = strip_speaker_notes(io.BytesIO(body), out)
1139+
s3_client.put_object(Bucket=BUCKET_NAME, Key=key, Body=out.getvalue(), ContentType=PPTX_CONTENT_TYPE)
1140+
logger.info(f"Made {key} ({removed} notes slides removed)")
1141+
return key
1142+
1143+
10921144
@app.get("/decks/<deck_id>")
10931145
def get_deck(deck_id: str) -> Dict[str, Any]:
10941146
"""Get deck details with presigned URLs. Reads slides from S3 (deck.json + slides/*.json)."""
@@ -1175,6 +1227,7 @@ def get_deck(deck_id: str) -> Dict[str, Any]:
11751227
"template": template,
11761228
"defsUrl": preview_url(defs_key) if has_defs else None,
11771229
"pptxUrl": _pptx_download_url(pptx_key, deck.get("name", "")) if pptx_key else None,
1230+
"speakerNotes": _speaker_notes(deck),
11781231
"slideSize": slide_size(deck_json),
11791232
"updatedAt": deck.get("updatedAt", ""),
11801233
"chatSessionId": _owner_chat_session_id(decision),

‎api/pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ description = "spec-driven-presentation-maker REST API Lambda (Layer 4)"
55
requires-python = ">=3.11"
66
# Versions are locked in the workspace uv.lock (root); scripts/bundle_api_lambda.sh
77
# bundles from it. api/ needs sdpm/sdpm only for sdpm.engine.analyzer (template listing
8-
# and uploaded-template analysis); sdpm-skill brings its dependencies, and with them the
8+
# and uploaded-template analysis) and sdpm.engine.notes (the PPTX download without speaker
9+
# notes); sdpm-skill brings its dependencies, and with them the
910
# core's document parsers, which api/ does not import. The bundle copies sdpm/sdpm itself.
1011
dependencies = [
1112
"sdpm-skill",

‎docs/en/architecture.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ S3 (pptx bucket):
132132
decks/{deckId}/includes/ — code block JSON
133133
decks/{deckId}/compose/ — per-slide SVG compose JSON (for Web UI animation)
134134
previews/{deckId}/{slideId}.png — slide previews
135+
pptx/{deckId}/{build}.pptx — built PPTX (DynamoDB pptxS3Key)
136+
pptx/{deckId}/{build}.notes.md — its speaker notes with speakerNotes "markdown" (notesS3Key)
137+
pptx/{deckId}/{build}.nonotes.pptx — copy without speaker notes, made on the first such download
135138
html/{deckId}/{uuid}.html — HTML deck output.html (DynamoDB htmlS3Key)
136139
html/{deckId}/preview/{slug}_{epoch}.html — HTML slide thumbnails (latest epoch wins)
137140
template-html-cache/{cacheKey}/ — template HTML conversion (theme.css, template.json,

0 commit comments

Comments
 (0)