[PR #6635] [MERGED] feat(capability): let packages register, read, and unlock achievements #7262

Closed
opened 2026-10-23 04:18:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6635
Author: @Gunterlie
Created: 9/24/2026
Status: ✅ Merged
Merged: 9/25/2026
Merged by: @Gunterlie

Base: staging ← Head: feat/6634-package-achievements


📝 Commits (10+)

  • 245983f feat(capability): let packages register, read, and unlock achievements
  • 7c1272b fix(capability): require capability API 1.35 for the achievements permission
  • 0e94e06 Merge branch 'staging' into feat/6634-package-achievements
  • 787bb5c Merge branch 'staging' into feat/6634-package-achievements
  • cc16537 fix(capability): move package achievements to capability API 1.36
  • 218ecc6 Merge remote-tracking branch 'origin/staging' into feat/6634-package-achievements
  • ed96b77 Merge remote-tracking branch 'origin/feat/6634-package-achievements' into feat/6634-package-achievements
  • 11c0c2e fix(capability): address review on package achievements
  • 05858d4 docs(capability): note that achievement progress deadlines bound async waits only
  • 6c90059 Merge remote-tracking branch 'origin/staging' into feat/6634-package-achievements

📊 Changes

15 files changed (+785 additions, -48 deletions)

View changed files

📝 docs/development/optional-agent-packages.md (+47 -0)
📝 docs/home/achievements.md (+10 -0)
📝 packages/client/src/components/chat/HomeAchievements.tsx (+57 -10)
📝 packages/client/src/hooks/use-achievements.ts (+26 -2)
📝 packages/client/src/lib/achievement-toast.tsx (+25 -3)
📝 packages/client/src/localization/locales/en.json (+1 -0)
📝 packages/server/src/services/achievements/achievements.service.ts (+78 -27)
➕ packages/server/src/services/capability-packages/capability-achievement-host.service.ts (+48 -0)
➕ packages/server/src/services/capability-packages/capability-achievement-registry.service.ts (+208 -0)
📝 packages/server/src/services/capability-packages/capability-module-runtime.service.ts (+32 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+15 -1)
📝 packages/shared/src/types/achievement.ts (+37 -1)
📝 packages/shared/src/types/capability-runtime.ts (+4 -0)
➕ scripts/regressions/capability-achievements.regression.ts (+193 -0)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+4 -4)

📄 Description

Closes #6634

Why

Achievements were Engine-only: a hard-coded catalog, fixed metrics, and a fixed icon set. An agent package could not add a badge for its own feature, check if the badge was earned, or unlock it. The user also had no way to see which badges came from which agent.

What

  • Permission + API 1.36. New achievements permission. supportedCapabilityApi goes to 1.36.
  • Register. api.registerAchievements([...]) on the activation context. It follows the registerTool pattern: permission gate, refused after teardown, released on deactivate. Ids become <packageId>.<id>. Built-in ids have no dot, so they cannot collide. A batch with one bad entry registers nothing. Limit: 32 per package.
  • Read / write. api.runtime.achievements.list() / isUnlocked(id) / unlock(id). Each call accepts only ids that the calling package registered. unlock resolves true only for the call that unlocked the badge.
  • Progress. A ranked badge sets target + readProgress(). The package owns the counter and keeps it in its persistence host. The Engine unlocks the badge on the same pass as its own ranked badges. A callback that throws or hangs (2 s) reports 0, so one broken package cannot break the panel.
  • Art. iconPath resolves to the existing package assets route. Unlocked cards only (locked cards keep the padlock). If the image fails, the card falls back to the icon enum (new trophy default).
  • Per-agent section. The Home panel groups cards by source. Engine badges come first, then one section per package, headed "From ". The heading uses the existing group-label style (text-[0.625rem] font-semibold uppercase tracking-wide). With no package badges, the panel renders exactly as before.
  • Toast. Package unlocks happen on the server, so the client finds them on the next status refresh and shows the existing unlock toast. Engine catch-up unlocks stay silent, as documented.
  • No storage change. achievement_unlocks already keys by a plain string id, so there is no new table and no STORAGE_VERSION bump.

Out of scope, on purpose: an HTTP endpoint that lets clients unlock badges (it would let anyone unlock anything), an achievement editor, and reset.

Docs

  • docs/home/achievements.md: new "Achievements from agents" section.
  • docs/development/optional-agent-packages.md: Capability API 1.36 section.
  • Translated docs follow-up: #6645.

Validation

  • pnpm check passes.
  • New scripts/regressions/capability-achievements.regression.ts passes. It covers namespacing, the asset URL, the progress fallback, collision and invalid-id refusal, the all-or-nothing batch, ownership and permission guards, and release.

Dev Engine test (dev-marinara, before the 1.36 move)

A throwaway test agent registered five badges. Verified live: its own section, package art, broken-art fallback to the trophy, locked padlock, target auto-unlock, isUnlocked, refusal to unlock a built-in badge, and one unlock pop-up with the page open (desktop and 390 px). Not observed live: unlock() returning true (the regression covers it).

Manual verification

  • Sideload a test package that registers two badges on a dev Engine. Manually verify that a "From " section appears after the Engine badges.
  • Manually verify that iconPath art renders on an unlocked card, and that a broken path falls back to the trophy icon.
  • Manually verify that unlock() returns true once and false on a second call, and that the toast appears once.
  • Manually verify that a readProgress badge shows the progress bar and auto-unlocks at target.
  • Manually verify that a package without the achievements permission fails activation at registerAchievements.
  • Manually verify that uninstalling hides the section, and that reinstalling shows the badges as unlocked again.
  • Manually verify that the panel with no package badges looks the same as on staging, on wide and narrow widths.

Summary by CodeRabbit

  • New Features
    • Installed agents can contribute up to 32 achievements, with progress tracking and unlocks.
    • Agent achievements appear in labeled sections of the Achievements window, and the total includes achievements from installed agents. Unlocked badges can display agent-provided artwork.
    • Unlock notifications are shown for newly earned agent achievements. Removing or deactivating an agent hides its achievements but preserves unlocks; reinstalling restores them.
  • Documentation
    • Added guidance on agent achievements and the Capability API 1.36 requirement.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6635 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 9/24/2026 **Status:** ✅ Merged **Merged:** 9/25/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `feat/6634-package-achievements` --- ### 📝 Commits (10+) - [`245983f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/245983fc0bb666d94483f1b5cfd7000a09052bbd) feat(capability): let packages register, read, and unlock achievements - [`7c1272b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7c1272b4bfc19b50caea7c80ae97a627474bda38) fix(capability): require capability API 1.35 for the achievements permission - [`0e94e06`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0e94e068496c90831889a9a34f1108d1ba27e319) Merge branch 'staging' into feat/6634-package-achievements - [`787bb5c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/787bb5c0b03762cbe5a22b57a53f18a98c9b2888) Merge branch 'staging' into feat/6634-package-achievements - [`cc16537`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cc165373fc1e94908afb244df5b59e401c74a81f) fix(capability): move package achievements to capability API 1.36 - [`218ecc6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/218ecc64a1f0190135ed06a0909d7c591940506a) Merge remote-tracking branch 'origin/staging' into feat/6634-package-achievements - [`ed96b77`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ed96b77a26cbd6cb7e733a57612c55ba6c1a8988) Merge remote-tracking branch 'origin/feat/6634-package-achievements' into feat/6634-package-achievements - [`11c0c2e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/11c0c2e27faa227ec474abbf9ecef0eceecdf475) fix(capability): address review on package achievements - [`05858d4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/05858d48e24f1c051a7cf87960f75360a4c9412f) docs(capability): note that achievement progress deadlines bound async waits only - [`6c90059`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6c900594d06e6de14e1d4c4577bc78b1ce86232b) Merge remote-tracking branch 'origin/staging' into feat/6634-package-achievements ### 📊 Changes **15 files changed** (+785 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `docs/development/optional-agent-packages.md` (+47 -0) 📝 `docs/home/achievements.md` (+10 -0) 📝 `packages/client/src/components/chat/HomeAchievements.tsx` (+57 -10) 📝 `packages/client/src/hooks/use-achievements.ts` (+26 -2) 📝 `packages/client/src/lib/achievement-toast.tsx` (+25 -3) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) 📝 `packages/server/src/services/achievements/achievements.service.ts` (+78 -27) ➕ `packages/server/src/services/capability-packages/capability-achievement-host.service.ts` (+48 -0) ➕ `packages/server/src/services/capability-packages/capability-achievement-registry.service.ts` (+208 -0) 📝 `packages/server/src/services/capability-packages/capability-module-runtime.service.ts` (+32 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+15 -1) 📝 `packages/shared/src/types/achievement.ts` (+37 -1) 📝 `packages/shared/src/types/capability-runtime.ts` (+4 -0) ➕ `scripts/regressions/capability-achievements.regression.ts` (+193 -0) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+4 -4) </details> ### 📄 Description Closes #6634 ## Why Achievements were Engine-only: a hard-coded catalog, fixed metrics, and a fixed icon set. An agent package could not add a badge for its own feature, check if the badge was earned, or unlock it. The user also had no way to see which badges came from which agent. ## What - **Permission + API 1.36.** New `achievements` permission. `supportedCapabilityApi` goes to 1.36. - **Register.** `api.registerAchievements([...])` on the activation context. It follows the `registerTool` pattern: permission gate, refused after teardown, released on deactivate. Ids become `<packageId>.<id>`. Built-in ids have no dot, so they cannot collide. A batch with one bad entry registers nothing. Limit: 32 per package. - **Read / write.** `api.runtime.achievements.list() / isUnlocked(id) / unlock(id)`. Each call accepts only ids that the calling package registered. `unlock` resolves true only for the call that unlocked the badge. - **Progress.** A ranked badge sets `target` + `readProgress()`. The package owns the counter and keeps it in its persistence host. The Engine unlocks the badge on the same pass as its own ranked badges. A callback that throws or hangs (2 s) reports 0, so one broken package cannot break the panel. - **Art.** `iconPath` resolves to the existing package assets route. Unlocked cards only (locked cards keep the padlock). If the image fails, the card falls back to the `icon` enum (new `trophy` default). - **Per-agent section.** The Home panel groups cards by `source`. Engine badges come first, then one section per package, headed "From <package name>". The heading uses the existing group-label style (`text-[0.625rem] font-semibold uppercase tracking-wide`). With no package badges, the panel renders exactly as before. - **Toast.** Package unlocks happen on the server, so the client finds them on the next status refresh and shows the existing unlock toast. Engine catch-up unlocks stay silent, as documented. - **No storage change.** `achievement_unlocks` already keys by a plain string id, so there is no new table and no `STORAGE_VERSION` bump. Out of scope, on purpose: an HTTP endpoint that lets clients unlock badges (it would let anyone unlock anything), an achievement editor, and reset. ## Docs - `docs/home/achievements.md`: new "Achievements from agents" section. - `docs/development/optional-agent-packages.md`: Capability API 1.36 section. - Translated docs follow-up: #6645. ## Validation - `pnpm check` passes. - New `scripts/regressions/capability-achievements.regression.ts` passes. It covers namespacing, the asset URL, the progress fallback, collision and invalid-id refusal, the all-or-nothing batch, ownership and permission guards, and release. ## Dev Engine test (dev-marinara, before the 1.36 move) A throwaway test agent registered five badges. Verified live: its own section, package art, broken-art fallback to the trophy, locked padlock, target auto-unlock, `isUnlocked`, refusal to unlock a built-in badge, and one unlock pop-up with the page open (desktop and 390 px). Not observed live: `unlock()` returning `true` (the regression covers it). ## Manual verification - [ ] Sideload a test package that registers two badges on a dev Engine. Manually verify that a "From <package>" section appears after the Engine badges. - [ ] Manually verify that `iconPath` art renders on an unlocked card, and that a broken path falls back to the trophy icon. - [ ] Manually verify that `unlock()` returns true once and false on a second call, and that the toast appears once. - [ ] Manually verify that a `readProgress` badge shows the progress bar and auto-unlocks at `target`. - [ ] Manually verify that a package without the `achievements` permission fails activation at `registerAchievements`. - [ ] Manually verify that uninstalling hides the section, and that reinstalling shows the badges as unlocked again. - [ ] Manually verify that the panel with no package badges looks the same as on `staging`, on wide and narrow widths. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Installed agents can contribute up to 32 achievements, with progress tracking and unlocks. * Agent achievements appear in labeled sections of the Achievements window, and the total includes achievements from installed agents. Unlocked badges can display agent-provided artwork. * Unlock notifications are shown for newly earned agent achievements. Removing or deactivating an agent hides its achievements but preserves unlocks; reinstalling restores them. * **Documentation** * Added guidance on agent achievements and the Capability API 1.36 requirement. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:03 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7262
No description provided.