refactor(skills): apply simplify-pass cleanups across the stack#2612
Merged
Conversation
This was referenced Jun 11, 2026
Contributor
Author
|
React Doctor could not complete this scan.
Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "refactor(skills): apply simplify-pass cl..." | Re-trigger Greptile |
jonathanlab
approved these changes
Jun 11, 2026
17de255 to
24695c3
Compare
840c76b to
8583731
Compare
24695c3 to
bf96408
Compare
8583731 to
46f11a8
Compare
Contributor
Author
Merge activity
|
46f11a8 to
e502baf
Compare
bf96408 to
3f66898
Compare
Reuse: - stripFrontmatter moves to @posthog/shared (CRLF-aware), replacing the diverging workspace-server and UI copies so render and export agree. - getUserSkillsDir() and isProbablyText() in skill-discovery replace eight inline path joins and two binary heuristics across skills, skills-marketplace, and posthog-plugin. - ReplaceSkillDialog replaces three identical confirm-overwrite AlertDialogs; SkillListCard replaces three hand-rolled card rows (local, team, marketplace); installsFormatter is shared. - skillErrors.ts centralizes the "already exists" conflict detection (one place to keep in sync with the throw sites across the tRPC boundary) and toast descriptions via shared getErrorMessage. Simplification: - teamSkillsKeys gains an `all` root key; mutations stop hardcoding the raw string. saveManifest router forwards input directly. - dedupeCodexSkills checks mirrored copies by directory name only (the mirror state stores directory names). - Dead resolveLlmSkill / LlmSkillResolveResponse removed from api-client until a version-history UI needs them. Efficiency: - The team listing query key is now stable: installedLocally marking is a pure core function (markInstalledTeamSkills) applied in the hook, so local skill changes no longer refetch the team list. - exportSkill reads, installTeamSkill writes, and the codex mirror copy/remove phases now run their per-file work in parallel. Generated-By: PostHog Code Task-Id: f4e84f1a-19c9-490c-9b98-47787a7dddcf
…rt tests hermetic Review feedback on #2610/#2611: the "already exists" overwrite detection now keys off SKILL_EXISTS_MARKER in @posthog/shared, used verbatim by the server messages and the UI matcher, so a reword cannot silently break the overwrite dialog; getUserSkillsDir is mocked in skills.test.ts so the codex-import and team-install tests run fully against temp dirs instead of early-returning when the real home directory has a colliding skill. Generated-By: PostHog Code Task-Id: f4e84f1a-19c9-490c-9b98-47787a7dddcf
e502baf to
82345cb
Compare
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
Several small pieces of logic were duplicated or misplaced across the skills feature, making it harder to maintain and extend. Specifically: the "already installed locally" marking was coupled to the team skills fetch,
stripFrontmatterexisted only in the UI package, error-handling patterns were repeated inline across many components, and the card row layout was copy-pasted across three different list surfaces.Changes
Decouple local-install marking from the team skills fetch
listTeamSkillsno longer acceptslocalSkillNamesand no longer marks skills as installed. A new pure functionmarkInstalledTeamSkillshandles that separately.useTeamSkillsnow fetches the team listing once and appliesmarkInstalledTeamSkillsin auseMemo, so local skill changes never trigger a refetch of the remote listing. The query key structure is also cleaned up with a sharedteamSkillsKeys.allroot so invalidations are consistent.Move
stripFrontmatterto@posthog/sharedThe UI-local
stripFrontmatter.tsis deleted. A CRLF-aware version now lives inpackages/shared/src/skills.tsand is exported from the package index. All consumers (SkillDetailPanel,MarketplaceSkillPanel,TeamSkillDetailPanel, the workspace-server export path) import from@posthog/shared.Centralise skill error helpers
A new
skillErrors.tsmodule exposesisSkillExistsErrorandskillErrorDescription. All the scatterederror instanceof Error ? error.message : ""/.includes("already exists")patterns acrossSkillDetailPanel,TeamSkillDetailPanel,MarketplaceSkillPanel,SkillFileEditor,SkillManifestEditor,NewSkillDialog, andSkillFileEditorare replaced with calls to these helpers.Extract
SkillListCardshared componentThe identical card-row markup (icon box, title/subtitle text block, trailing slot, selection highlight) was duplicated in
SkillCard,TeamSkillsSection, andMarketplaceBrowse. It is now a singleSkillListCardcomponent withicon,title,subtitle,isSelected,onClick, andtrailingprops.Extract
ReplaceSkillDialogshared componentThe confirm-overwrite
AlertDialogwas duplicated inMarketplaceSkillPanel,TeamSkillDetailPanel, andSkillDetailPanel. It is now a singleReplaceSkillDialogcomponent parameterised byskillName,verb("Reinstalling" / "Importing"), andonConfirm.Consolidate
getUserSkillsDirandisProbablyTextBoth helpers were defined inline in multiple workspace-server files. They now live in
skill-discovery.tsand are imported wherever needed, removing the repeatedos.homedir()path construction.Parallelise file I/O in the workspace server
Sequential
forloops inmirrorUserSkillsToCodex,exportSkill, andinstallSkillare replaced withPromise.allcalls.Move
installsFormattertouseMarketplace.tsThe
Intl.NumberFormatinstance was duplicated inMarketplaceBrowseandMarketplaceSkillPanel; it is now exported once fromuseMarketplace.ts.Remove unused
resolveLlmSkillAPI methodresolveLlmSkilland itsLlmSkillResolveResponsetype are removed from the API client as they are no longer called anywhere.How did you test this?
TeamSkillsService.listTeamSkillsto reflect the removedlocalSkillNamesparameter.markInstalledTeamSkillsunit test covering name-based matching and unrelated local names.publishSkilland other service methods continue to pass.Automatic notifications