mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6634] [Feature]: Let capability packages register, read, and unlock their own achievements #3716
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3716
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Gunterlie on GitHub (Sep 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6634
Originally assigned to: @Gunterlie on GitHub.
Problem
Achievements are a closed, Engine-only set.
ACHIEVEMENT_DEFINITIONSis a hard-coded array inpackages/shared/src/constants/achievements.ts, the metrics are a fixed union counted off Engine tables inachievements.service.ts, and the icons are a fixedAchievementIconKeyenum mapped to Lucide components inHomeAchievements.tsx.So a capability package (agent) cannot ship achievements for its own feature. Slurp, Noodle, a turn-game package, or any community agent has no way to say "unlock Fed The Noodle after 10 noodle runs", no way to ask whether that badge is already unlocked, and no way to mark it unlocked. Users also get no idea which badges came from which agent.
Everything an agent needs is already present as a pattern — packages already register conversation commands, services, prompt context, and privileged routes through
CapabilityActivationContext, already get a persistence host, and already serve their own static files viaGET /api/capability-packages/:id/assets/*. Achievements are simply the one subsystem nobody wired up.Proposed change
Add a package-contributed achievement lane that reuses the existing registry pattern instead of inventing a second achievement system.
1. Registry + activation API
New
capability-achievement-registry.service.ts, modelled directly oncapability-command-registry.service.ts. Expose on the activation context:Gated by a new
achievementsvalue incapabilityPermissionSchema. IDs are namespaced"<packageId>.<localId>"at registration; the registry rejects a collision with a built-in ID or another package.2. Definition shape
Extend
AchievementDefinition(shared) with two optional fields, both back-compatible:source?: { packageId: string; packageName: string }— absent means Engine.iconUrl?: string— a package-served asset path. The client already falls back toTrophyfor an unknownicon, soiconUrlrenders when present and the enum stays authoritative for built-ins.3. Read / write / progress
On
CapabilityRuntimeHost, add anachievementshost scoped to the calling package's own IDs:list()— definitions + progress for this package.isUnlocked(id)— read whether it is fulfilled.unlock(id)— write that it is fulfilled; returns whether this call is the one that unlocked it, so the package can react once.Counting stays with the package. A registered definition may carry
targetplus an optionalreadProgress(): Promise<number>callback thatstatus()invokes; the package keeps its own counter in the persistence host it already has. This deliberately avoids a new table and aSTORAGE_VERSIONbump —achievement_unlocksis keyed by a plain string ID and already stores arbitrary IDs correctly.4. Status + UI sections
achievements.service.tsmerges registry definitions intostatus(), and unlock/catch-up logic runs over the merged set.HomeAchievements.tsxgroups the grid bysource: the existing ungrouped Engine set first, then one labelled section per package that contributed at least one badge, each headed by the package name. The unlock toast is already definition-driven and needs only theiconUrlpath.5. Lifecycle
Unregistering a package leaves its unlock rows in place (achievements never re-lock, per the documented behaviour) but drops its definitions from
status(), so orphaned IDs simply stop rendering and come back if the package is reinstalled.Scope
packages/shared:AchievementDefinitionfields,PackagedAchievementDefinition,achievementspermission,CapabilityRuntimeHost.achievements, bumpsupportedCapabilityApiminor (1.16 → 1.17).packages/server: new achievement registry service, activation-context wiring incapability-module-runtime.service.ts, merge inachievements.service.ts.packages/client: grouped sections +iconUrlrendering inHomeAchievements.tsxandachievement-toast.tsx.docs/home/achievements.md(agent-contributed badges + per-agent sections), the capability package API reference, and the permission list. Translated docs ondocs-i18nneed a matching update or a[docs-i18n]follow-up issue.Explicitly out of scope
Test plan
iconUrlrenders on both the card and the unlock toast, and that a missing/broken asset falls back to the trophy icon.unlock()returns true once and false on a second call, and that the toast fires exactly once.readProgress-backed badge shows a correct progress bar and auto-unlocks on reachingtarget.achievementspermission is refused atregisterAchievements.pnpm check.