-
Notifications
You must be signed in to change notification settings - Fork 44
Add --accessible flag for screen reader support #16
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,8 @@ export function runCli(argv: string[]): void { | |
| program | ||
| .name("primer") | ||
| .description("Prime repositories for AI-assisted development") | ||
| .version("0.1.0"); | ||
| .version("0.1.0") | ||
| .option("--accessible", "Enable screen reader friendly output (removes box-drawing characters, replaces Unicode symbols with text)"); | ||
|
||
|
|
||
| program | ||
| .command("init") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,16 @@ | ||
| import React from "react"; | ||
| import { render } from "ink"; | ||
| import { Command } from "commander"; | ||
| import { BatchTui } from "../ui/BatchTui"; | ||
| import { getGitHubToken } from "../services/github"; | ||
|
|
||
| type BatchOptions = { | ||
| output?: string; | ||
| }; | ||
|
|
||
| export async function batchCommand(options: BatchOptions): Promise<void> { | ||
| export async function batchCommand(options: BatchOptions, cmd: Command): Promise<void> { | ||
| const token = await getGitHubToken(); | ||
|
|
||
| if (!token) { | ||
| console.error("Error: GitHub authentication required."); | ||
| console.error(""); | ||
|
|
@@ -22,10 +23,11 @@ export async function batchCommand(options: BatchOptions): Promise<void> { | |
| return; | ||
| } | ||
|
|
||
| const accessible = cmd.parent?.opts().accessible || process.env.INK_SCREEN_READER === "true"; | ||
| const { waitUntilExit } = render( | ||
| <BatchTui token={token} outputPath={options.output} /> | ||
| <BatchTui token={token} outputPath={options.output} accessible={accessible} />, | ||
| { isScreenReaderEnabled: accessible } | ||
|
Comment on lines
+26
to
+29
|
||
| ); | ||
|
|
||
|
|
||
| await waitUntilExit(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,21 @@ | ||
| import path from "path"; | ||
| import React from "react"; | ||
| import { render } from "ink"; | ||
| import { Command } from "commander"; | ||
| import { PrimerTui } from "../ui/tui"; | ||
|
|
||
| type TuiOptions = { | ||
| repo?: string; | ||
| animation?: boolean; | ||
| }; | ||
|
|
||
| export async function tuiCommand(options: TuiOptions): Promise<void> { | ||
| export async function tuiCommand(options: TuiOptions, cmd: Command): Promise<void> { | ||
| const repoPath = path.resolve(options.repo ?? process.cwd()); | ||
| const skipAnimation = options.animation === false; | ||
| const { waitUntilExit } = render(<PrimerTui repoPath={repoPath} skipAnimation={skipAnimation} />); | ||
| const accessible = cmd.parent?.opts().accessible || process.env.INK_SCREEN_READER === "true"; | ||
| const { waitUntilExit } = render( | ||
| <PrimerTui repoPath={repoPath} skipAnimation={skipAnimation || accessible} accessible={accessible} />, | ||
| { isScreenReaderEnabled: accessible } | ||
|
Comment on lines
+15
to
+18
|
||
| ); | ||
| await waitUntilExit(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ import { StaticBanner } from "./AnimatedBanner"; | |||||
| type Props = { | ||||||
| token: string; | ||||||
| outputPath?: string; | ||||||
| accessible?: boolean; | ||||||
| }; | ||||||
|
|
||||||
| type Status = | ||||||
|
|
@@ -38,7 +39,7 @@ type ProcessResult = { | |||||
| error?: string; | ||||||
| }; | ||||||
|
|
||||||
| export function BatchTui({ token, outputPath }: Props): React.JSX.Element { | ||||||
| export function BatchTui({ token, outputPath, accessible = false }: Props): React.JSX.Element { | ||||||
| const app = useApp(); | ||||||
| const [status, setStatus] = useState<Status>("loading-orgs"); | ||||||
| const [message, setMessage] = useState<string>("Fetching organizations..."); | ||||||
|
|
@@ -315,8 +316,8 @@ export function BatchTui({ token, outputPath }: Props): React.JSX.Element { | |||||
| }; | ||||||
|
|
||||||
| return ( | ||||||
| <Box flexDirection="column" padding={1} borderStyle="round"> | ||||||
| <StaticBanner /> | ||||||
| <Box flexDirection="column" padding={1} borderStyle={accessible ? undefined : "round"}> | ||||||
| <StaticBanner accessible={accessible} /> | ||||||
| <Text color="cyan">Batch Processing - Prime repositories at scale</Text> | ||||||
| <Box marginTop={1}> | ||||||
| <Text>{message}</Text> | ||||||
|
|
@@ -338,8 +339,8 @@ export function BatchTui({ token, outputPath }: Props): React.JSX.Element { | |||||
| const isCursor = realIndex === cursorIndex; | ||||||
| return ( | ||||||
| <Text key={org.login}> | ||||||
| <Text color={isCursor ? "cyan" : undefined}>{isCursor ? "❯ " : " "}</Text> | ||||||
| <Text color={isSelected ? "green" : "gray"}>{isSelected ? "◉" : "○"} </Text> | ||||||
| <Text color={isCursor ? "cyan" : undefined}>{isCursor ? (accessible ? "> " : "❯ ") : " "}</Text> | ||||||
| <Text color={isSelected ? "green" : "gray"}>{isSelected ? (accessible ? "[x]" : "◉") : (accessible ? "[ ]" : "○")} </Text> | ||||||
| <Text>{org.name ?? org.login}</Text> | ||||||
| <Text color="gray"> ({org.login})</Text> | ||||||
| </Text> | ||||||
|
|
@@ -364,9 +365,9 @@ export function BatchTui({ token, outputPath }: Props): React.JSX.Element { | |||||
| const isCursor = realIndex === cursorIndex; | ||||||
| return ( | ||||||
| <Text key={repo.fullName}> | ||||||
| <Text color={isCursor ? "cyan" : undefined}>{isCursor ? "❯ " : " "}</Text> | ||||||
| <Text color={isSelected ? "green" : "gray"}>{isSelected ? "◉" : "○"} </Text> | ||||||
| <Text color={repo.hasInstructions ? "green" : "red"}>{repo.hasInstructions ? "✓" : "✗"} </Text> | ||||||
| <Text color={isCursor ? "cyan" : undefined}>{isCursor ? (accessible ? "> " : "❯ ") : " "}</Text> | ||||||
| <Text color={isSelected ? "green" : "gray"}>{isSelected ? (accessible ? "[x]" : "◉") : (accessible ? "[ ]" : "○")} </Text> | ||||||
| <Text color={repo.hasInstructions ? "green" : "red"}>{repo.hasInstructions ? (accessible ? "HAS" : "✓") : (accessible ? "NEEDS" : "✗")} </Text> | ||||||
|
||||||
| <Text color={repo.hasInstructions ? "green" : "red"}>{repo.hasInstructions ? (accessible ? "HAS" : "✓") : (accessible ? "NEEDS" : "✗")} </Text> | |
| <Text color={repo.hasInstructions ? "green" : "red"}>{repo.hasInstructions ? (accessible ? "HAS_INSTRUCTIONS" : "✓") : (accessible ? "NEEDS_INSTRUCTIONS" : "✗")} </Text> |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,11 +12,12 @@ import { getGitHubToken } from "../services/github"; | |||||||||
| type Props = { | ||||||||||
| repoPath: string; | ||||||||||
| skipAnimation?: boolean; | ||||||||||
| accessible?: boolean; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| type Status = "intro" | "idle" | "analyzing" | "generating" | "evaluating" | "preview" | "done" | "error" | "batch"; | ||||||||||
|
|
||||||||||
| export function PrimerTui({ repoPath, skipAnimation = false }: Props): React.JSX.Element { | ||||||||||
| export function PrimerTui({ repoPath, skipAnimation = false, accessible = false }: Props): React.JSX.Element { | ||||||||||
| const app = useApp(); | ||||||||||
| const [status, setStatus] = useState<Status>(skipAnimation ? "idle" : "intro"); | ||||||||||
| const [analysis, setAnalysis] = useState<RepoAnalysis | null>(null); | ||||||||||
|
|
@@ -161,15 +162,15 @@ export function PrimerTui({ repoPath, skipAnimation = false }: Props): React.JSX | |||||||||
|
|
||||||||||
| // Render BatchTui when in batch mode | ||||||||||
| if (status === "batch" && batchToken) { | ||||||||||
| return <BatchTui token={batchToken} />; | ||||||||||
| return <BatchTui token={batchToken} accessible={accessible} />; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return ( | ||||||||||
| <Box flexDirection="column" padding={1} borderStyle="round"> | ||||||||||
| <Box flexDirection="column" padding={1} borderStyle={accessible ? undefined : "round"}> | ||||||||||
| {status === "intro" ? ( | ||||||||||
| <AnimatedBanner onComplete={handleAnimationComplete} /> | ||||||||||
| ) : ( | ||||||||||
| <StaticBanner /> | ||||||||||
| <StaticBanner accessible={accessible} /> | ||||||||||
| )} | ||||||||||
| <Text color="cyan">Prime your repo for AI.</Text> | ||||||||||
| <Text color="gray">Repo: {repoLabel}</Text> | ||||||||||
|
|
@@ -187,17 +188,17 @@ export function PrimerTui({ repoPath, skipAnimation = false }: Props): React.JSX | |||||||||
| <Text>{message}</Text> | ||||||||||
| </Box> | ||||||||||
| {status === "preview" && generatedContent && ( | ||||||||||
| <Box flexDirection="column" marginTop={1} borderStyle="single" borderColor="gray" paddingX={1}> | ||||||||||
| <Box flexDirection="column" marginTop={1} borderStyle={accessible ? undefined : "single"} borderColor="gray" paddingX={1}> | ||||||||||
| <Text color="cyan" bold>Preview (.github/copilot-instructions.md):</Text> | ||||||||||
| <Text color="gray">{truncatedPreview}</Text> | ||||||||||
| </Box> | ||||||||||
| )} | ||||||||||
| {evalResults && evalResults.length > 0 && ( | ||||||||||
| <Box flexDirection="column" marginTop={1} borderStyle="single" borderColor="gray" paddingX={1}> | ||||||||||
| <Box flexDirection="column" marginTop={1} borderStyle={accessible ? undefined : "single"} borderColor="gray" paddingX={1}> | ||||||||||
| <Text color="cyan" bold>Eval Results:</Text> | ||||||||||
| {evalResults.map((r) => ( | ||||||||||
| <Text key={r.id} color={r.verdict === "pass" ? "green" : r.verdict === "fail" ? "red" : "yellow"}> | ||||||||||
| {r.verdict === "pass" ? "✓" : r.verdict === "fail" ? "✗" : "?"} {r.id}: {r.verdict} (score: {r.score}) | ||||||||||
| {r.verdict === "pass" ? (accessible ? "PASS" : "✓") : r.verdict === "fail" ? (accessible ? "FAIL" : "✗") : "?"} {r.id}: {r.verdict} (score: {r.score}) | ||||||||||
|
||||||||||
| {r.verdict === "pass" ? (accessible ? "PASS" : "✓") : r.verdict === "fail" ? (accessible ? "FAIL" : "✗") : "?"} {r.id}: {r.verdict} (score: {r.score}) | |
| {accessible | |
| ? `Verdict: ${r.verdict === "pass" ? "PASS" : r.verdict === "fail" ? "FAIL" : "UNKNOWN"} ${r.id} (score: ${r.score})` | |
| : `${r.verdict === "pass" ? "✓" : r.verdict === "fail" ? "✗" : "?"} ${r.id}: ${r.verdict} (score: ${r.score})`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI version is hardcoded as
0.1.0, butpackage.jsonis1.0.0. This can cause confusing/mismatchedprimer --versionoutput. Consider sourcing the version frompackage.json(or keeping these in sync).