-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Ask to remove skills if successful #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /** | ||
| * SkillsScreen — Ask whether to keep installed skills in .claude/skills/. | ||
| * | ||
| * Shown after the outro summary so users see the agent's output first, | ||
| * then decide whether to keep the skills that powered it. | ||
| * | ||
| * When done, calls store.setSkillsComplete() and exits the process. | ||
| */ | ||
|
|
||
| import { Box, Text } from 'ink'; | ||
| import { useState, useEffect } from 'react'; | ||
| import { useSyncExternalStore } from 'react'; | ||
| import { readdir, rm } from 'node:fs/promises'; | ||
| import { join } from 'node:path'; | ||
| import type { WizardStore } from '../store.js'; | ||
| import { ConfirmationInput } from '../primitives/index.js'; | ||
| import { Colors } from '../styles.js'; | ||
| import { CONTEXT_MILL_URL } from '../../../lib/constants.js'; | ||
|
|
||
| interface SkillsScreenProps { | ||
| store: WizardStore; | ||
| } | ||
|
|
||
| interface SkillEntry { | ||
| name: string; | ||
| children: string[]; | ||
| } | ||
|
|
||
| enum Phase { | ||
| Loading = 'loading', | ||
| Ask = 'ask', | ||
| Removing = 'removing', | ||
| Done = 'done', | ||
| } | ||
|
|
||
| export const SkillsScreen = ({ store }: SkillsScreenProps) => { | ||
| useSyncExternalStore( | ||
| (cb) => store.subscribe(cb), | ||
| () => store.getSnapshot(), | ||
| ); | ||
|
|
||
| const [phase, setPhase] = useState<Phase>(Phase.Loading); | ||
| const [skills, setSkills] = useState<SkillEntry[]>([]); | ||
|
|
||
| const skillsDir = join(store.session.installDir, '.claude', 'skills'); | ||
|
|
||
| useEffect(() => { | ||
| void (async () => { | ||
| try { | ||
| const entries = await readdir(skillsDir, { withFileTypes: true }); | ||
| const dirs = entries.filter((e) => e.isDirectory()); | ||
| const result: SkillEntry[] = []; | ||
| for (const dir of dirs) { | ||
| const children = await readdir(join(skillsDir, dir.name)); | ||
| result.push({ name: dir.name, children }); | ||
| } | ||
| if (result.length === 0) { | ||
| store.setSkillsComplete(true); | ||
| process.exit(0); | ||
| } | ||
| setSkills(result); | ||
| setPhase(Phase.Ask); | ||
| } catch { | ||
| store.setSkillsComplete(true); | ||
| process.exit(0); | ||
| } | ||
| })(); | ||
| }, []); // eslint-disable-line | ||
|
|
||
| const handleKeep = () => { | ||
| store.setSkillsComplete(true); | ||
| process.exit(0); | ||
| }; | ||
|
|
||
| const handleRemove = async () => { | ||
| setPhase(Phase.Removing); | ||
| try { | ||
| await rm(skillsDir, { recursive: true, force: true }); | ||
| } catch { | ||
| // Best-effort removal | ||
| } | ||
| setPhase(Phase.Done); | ||
| store.setSkillsComplete(false); | ||
| process.exit(0); | ||
| }; | ||
|
|
||
| return ( | ||
| <Box flexDirection="column" flexGrow={1}> | ||
| <Text bold color={Colors.accent}> | ||
| Keep the skills? | ||
| </Text> | ||
|
|
||
| <Box marginTop={1} flexDirection="column"> | ||
| {phase === Phase.Loading && ( | ||
| <Text dimColor>Checking installed skills...</Text> | ||
| )} | ||
|
|
||
| {phase === Phase.Ask && ( | ||
| <> | ||
| <Text dimColor> | ||
| The wizard installed open-source skills that help AI coding agents | ||
| integrate PostHog into your project: | ||
| </Text> | ||
| <Box marginTop={1} flexDirection="column" marginLeft={2}> | ||
| <Text dimColor>.claude/</Text> | ||
| <Text dimColor> skills/</Text> | ||
| {skills.map((skill) => ( | ||
| <Box key={skill.name} flexDirection="column"> | ||
| <Text dimColor> {skill.name}/</Text> | ||
| {skill.children.map((child) => ( | ||
| <Text key={child} dimColor> | ||
| {' '} | ||
| {child} | ||
| </Text> | ||
| ))} | ||
| </Box> | ||
| ))} | ||
| </Box> | ||
| <Box marginTop={1}> | ||
| <Text dimColor> | ||
| Source: <Text color="cyan">{CONTEXT_MILL_URL}</Text> | ||
| </Text> | ||
| </Box> | ||
| <Box marginTop={1}> | ||
| <ConfirmationInput | ||
| message="Keep the installed skills?" | ||
| confirmLabel="Keep [Enter]" | ||
| cancelLabel="Remove [Esc]" | ||
| onConfirm={handleKeep} | ||
| onCancel={() => void handleRemove()} | ||
| /> | ||
| </Box> | ||
| </> | ||
| )} | ||
|
|
||
| {phase === Phase.Removing && <Text dimColor>Removing skills...</Text>} | ||
|
|
||
| {phase === Phase.Done && <Text dimColor>Skills removed.</Text>} | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| }; |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.