Skip to content

Install rule packs from the public games repo (RPG R7) - #76

Open
luoxin9510 wants to merge 3 commits into
mainfrom
rpg-r7-install
Open

luoxin9510 wants to merge 3 commits into
mainfrom
rpg-r7-install

Conversation

@luoxin9510

Copy link
Copy Markdown
Owner

RPG R7, plugin side.

  • New command "Install rule pack (download)" plus api.availablePacks() and api.installPack(id). Flow: read systems/index.json from luoxin9510/ink-games → pick a pack (the installed version is shown) → a confirm dialog with the source URL, the target folder and an overwrite note → download system.md and every file it lists → write into 规则包/<id>/. Nothing is written if any download fails.
  • The download logic lives in src/templates/install.ts and is pure, tested with a fake fetch (tests/install.test.ts). Paths must be relative to the pack: no .., hidden files or odd characters.
  • Each pack's system.md lists its files under files:; a test keeps that list in step with the folder, and layerSystem drops the field.
  • "New game" also lists packs installed in the vault that have a template. On the same id the installed copy wins.
  • turn-battle: the header and 说明 now say that every party member needs art 1/2/3 (from the Turn battle and narrative check rule packs (RPG R6) #75 review).
  • Fix: export-web on the command line now layers system: and resolves from: like check-ink. Before this, pages exported from pack-based games lost the pack's config.

Tests: 604 pass, lint clean, the build is reproducible. Pair: the ink-games PR for systems/; its CI checks that systems/ matches this repo's packs/, so merge this one first. Not yet checked in Obsidian: the plugin there is still the old build.

🤖 Generated with Claude Code

https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B

luoxin9510 and others added 2 commits November 11, 2026 02:07
@claude

claude Bot commented Nov 10, 2026

Copy link
Copy Markdown

Review: I found no blocking bugs and would merge as is.

Checked and fine:

  • Pack ids and file paths are validated, and a failed download writes nothing.
  • The confirm modal handles both close paths.
  • zh and en strings are both present.
  • No Node APIs in src/; requestUrl and the Vault API are used.
  • install.ts is pure and has tests.

Minor, non-blocking:

  • PACK_SOURCE points at the unpinned main branch, and the downloaded rules.ink is INCLUDEd into the user's stories. The confirm dialog covers consent, but a pinned tag or a hash in the index would be safer later.
  • packBundle() reads every installed pack's files on each newGame/pickNewGame. That is fine at this scale.
  • I only read the diff; I did not run the tests or lint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B
Comment thread src/main.ts
const yes = await new Promise<boolean>((done) => new ConfirmModal(this.app, T().packInstallTitle(id), T().packInstallConfirm(`${source.replace(/\/?$/, "/")}${id}/`, dir, have), T().install, done).open());
if (!yes) return { path: null };
}
const got = await downloadPack(async (url) => (await requestUrl({ url })).text, source, id, (t) => splitNote(t, parseYaml).frontmatter);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things here:

  1. api.installPack(id, { ask: false }) skips the confirm dialog, so any agent or script can download and overwrite files from a remote main branch (including rules.ink, which games INCLUDE) with no user consent. The API accepts an arbitrary source, and the doc says nothing of its risk. Consider honoring ask: false only for a source the caller passes explicitly, or always confirming for the default source.
  2. The "nothing is written if a download fails" guarantee holds for downloads only. If vault.create or modify throws halfway through the write loop, the pack is left half-written and overwritten. The error Notice doesn't say so. Acceptable, but the doc comment should be honest, or the write should roll back.

@claude

claude Bot commented Nov 10, 2026

Copy link
Copy Markdown

Review summary: no blocking bugs found in install.ts (path validation, id check and all-or-nothing download look sound; tests cover them). requestUrl and the Vault API are used correctly, with no Node APIs. One inline note about ask: false bypassing the confirm dialog and writes not being atomic. I would merge once that is considered; I did not run the tests or lint, and the PR notes say it has not yet been tried in Obsidian.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant