Repository navigation
Conversation
Carry forward the pack-builder half of upstream thekannen#17 on top of 1.4.2. Publish with O_CREAT|O_EXCL into Dungeondraft's configured asset folder only, add one companion tool (no Assets.UpdateTree refresh), and cover no-clobber and path limits in offline tests. Co-authored-by: arhidavid <arhidavid@users.noreply.github.com>
Owner
|
Thank you, David. This handles every point from #17: exclusive create, writes limited to the asset folder, no refresh tool, and one new tool instead of three. The Windows live run (restart, include, place, save and reopen, transparency in the DD2VTT export) is exactly the evidence it needed. I've ported it as your commit for 1.4.3, with a few changes:
It'll ship in 1.4.3, credited to you. I'll update the asset-pack docs page on knownframe.com. Thanks again for following up on this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and behavior
Follow-up to thekannen/battlemap-mcp#17:
import_imagealready shipped in upstream 1.4.2. This PR is the pack-builder half only, based on current upstreammain/ 1.4.2.create_image_pack(filename, name, images, pack_id="", author="")builds a native.dungeondraft_packof named, tagged PNG objects. The archive includes the root registration manifest and innerpack.json, plus native tags/sets. Existing files are never overwritten. Writes are limited to Dungeondraft’s configured asset folder.Workflow after create: restart Dungeondraft (verified live) — or rescan packs in the Assets window (unverified without restart) →
prepare_map_with_packswith the returned id →list_assets/search_pack_contents/place_object.search_pack_contentscan already see the new archive on disk before a rescan/restart.Design choice (tool count)
Adds one companion tool:
create_image_pack.import_image(embed-in-map vs library pack are different jobs).prepare_map_with_packs(that tool rewrites map headers; packing PNGs does not belong there).refresh_asset_packs(see note 3 below).Addressing thekannen’s #17 notes
No-clobber / portable publish. Replaced
os.linkwithO_CREAT | O_EXCLopen of the final destination, then write +fsync. That works on exFAT, FAT32, and network shares where hard links fail. A competing writer that claims the name first surfaces as “already exists”; this call only unlinks a file it created.Where packs may be written.
filenameis a bare name (same style asprepare_map_with_packs). The destination is resolved underpack_contents.assets_directory()only (config.inicustom_assets_directoryorBATTLEMAP_MCP_ASSETS_DIR). Absolute/outside paths are refused.refresh_asset_packs/Assets.UpdateTree— deferred. The Add native PNG object import and optional tagged asset packs #17 live notes reported a native read error and editor exit when an invalid early test archive was moved during cleanup while Dungeondraft was running; that “do not move mounted packs” restriction remains documented. Neither our cloud environment nor our live pass isolatedUpdateTree, and this PR does not expose refresh. Safe path: ask the user to restart Dungeondraft (or rescan in the Assets window), then callprepare_map_with_packs. If a later live session clearly shows refresh-only is safe, that can be a small follow-up.Fewer new tools. One new tool instead of three (
import_imagealready upstream; refresh omitted).Implementation
server/battlemap_mcp/image_import.pywith pack building (reuses PNG validation).create_image_packas a companion tool inbridge_client.py.docs/image-pack.md; PROTOCOL / docs README updated.import_image.Validation
Offline CI/checks:
python server/tools/gate.pypassed (format, lint, bridge/contract/lifecycle/engine, skills, agent docs, types, tests).tools/release.py checkpassed.server/tests/test_image_import.py: pack round-trip, root manifest, no-clobber race, asset-folder path limit, reserved Colorable tag, corrupt PNG refusal.Live Windows + Dungeondraft check on
a61209d(running the PR’s 1.4.2-matched bridge source hash):python server/tools/gate.pypassed on Windows with a fresh temporary folder.create_image_packrefused an outside path (../…), wrote a two-PNG.dungeondraft_packinside Dungeondraft’s configured asset folder, and refused to overwrite it (file hash stayed identical);search_pack_contentsfound both tags on disk immediately.list_asset_packssaw the pack,prepare_map_with_packsadded it to a scratch map copy, both tagged objects were discoverable and placeable, and both survived save and reopen; pixel checks confirmed transparent centers in the DD2VTT export.Documentation pages needing maintainer update
AI assistance
Code and PR text were written with AI assistance (Cursor / Codex).