claude-a11y 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +89 -0
- package/bin/claude-sr.js +4 -0
- package/bin/test-with-speech.sh +96 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +272 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/repl.d.ts +15 -0
- package/dist/cli/repl.js +216 -0
- package/dist/cli/repl.js.map +1 -0
- package/dist/cli/runner.d.ts +35 -0
- package/dist/cli/runner.js +341 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/cli/session.d.ts +27 -0
- package/dist/cli/session.js +41 -0
- package/dist/cli/session.js.map +1 -0
- package/dist/core/announcer.d.ts +25 -0
- package/dist/core/announcer.js +112 -0
- package/dist/core/announcer.js.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.js +31 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/sanitizer.d.ts +31 -0
- package/dist/core/sanitizer.js +225 -0
- package/dist/core/sanitizer.js.map +1 -0
- package/dist/core/speech-formatter.d.ts +65 -0
- package/dist/core/speech-formatter.js +244 -0
- package/dist/core/speech-formatter.js.map +1 -0
- package/dist/core/stream-parser.d.ts +26 -0
- package/dist/core/stream-parser.js +148 -0
- package/dist/core/stream-parser.js.map +1 -0
- package/dist/core/types.d.ts +102 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/verbosity.d.ts +17 -0
- package/dist/core/verbosity.js +92 -0
- package/dist/core/verbosity.js.map +1 -0
- package/package.json +271 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jackie McGraw
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# claude-a11y
|
|
2
|
+
|
|
3
|
+
Screen reader formatting for AI chat responses.
|
|
4
|
+
|
|
5
|
+
Transforms Markdown output from AI assistants into text that screen readers can announce clearly. Code blocks, tables, headings, and formatting markers are replaced with structured announcements.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
As a CLI wrapper for Claude Code:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install -g claude-a11y
|
|
13
|
+
claude-sr
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
As a library:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm install claude-a11y
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
As a VS Code/Cursor extension: install "Accessible AI Chat" from the VS Code Marketplace, or download the .vsix from GitHub Releases.
|
|
23
|
+
|
|
24
|
+
## What it does
|
|
25
|
+
|
|
26
|
+
Without formatting, a screen reader announces a Python code block as "backtick backtick backtick python print open paren hello close paren backtick backtick backtick."
|
|
27
|
+
|
|
28
|
+
With claude-a11y, it becomes "[Python] print hello [End Python]."
|
|
29
|
+
|
|
30
|
+
Specific transformations:
|
|
31
|
+
|
|
32
|
+
1. Code blocks: language announced before and after the block
|
|
33
|
+
2. Tables: column count and headers announced, rows labeled
|
|
34
|
+
3. Headings, subheadings, quotes: announced with clear markers
|
|
35
|
+
4. Bullet points: "Bullet:" prefix instead of asterisk or dash
|
|
36
|
+
5. Separators: "[Separator]" instead of three dashes
|
|
37
|
+
6. Strikethrough: "[Strikethrough]" and "[End Strikethrough]" markers
|
|
38
|
+
7. Images: alt text announced, or "[Image]" if none
|
|
39
|
+
|
|
40
|
+
## CLI usage
|
|
41
|
+
|
|
42
|
+
Run Claude Code with screen reader formatting:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
claude-sr
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The wrapper spawns Claude Code as a subprocess, strips ANSI escape codes and spinner animations, formats Markdown responses, and sends clean text to stdout. It announces "Still working..." during long responses so you know the process has not frozen.
|
|
49
|
+
|
|
50
|
+
## Library usage
|
|
51
|
+
|
|
52
|
+
In TypeScript or JavaScript:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { formatForSpeech, sanitize } from "claude-a11y";
|
|
56
|
+
|
|
57
|
+
const raw = "## Hello\n\n```python\nprint('hi')\n```";
|
|
58
|
+
const accessible = formatForSpeech(raw);
|
|
59
|
+
// "[Subheading] Hello\n[Python]\nprint('hi')\n[End Python]"
|
|
60
|
+
|
|
61
|
+
const ansiGarbage = "\x1b[32mgreen text\x1b[0m";
|
|
62
|
+
const clean = sanitize(ansiGarbage);
|
|
63
|
+
// "green text"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## VS Code extension
|
|
67
|
+
|
|
68
|
+
When installed in VS Code or Cursor:
|
|
69
|
+
|
|
70
|
+
- The `@accessible` chat participant formats responses from Copilot Chat
|
|
71
|
+
- Screen reader detection auto-enables formatting
|
|
72
|
+
- Three verbosity levels: minimal, normal, detailed
|
|
73
|
+
- Cursor workbench patching injects accessibility into the Cursor chat panel
|
|
74
|
+
|
|
75
|
+
## Verbosity levels
|
|
76
|
+
|
|
77
|
+
- Minimal: code block markers only, no heading or table annotations
|
|
78
|
+
- Default: all structural markers
|
|
79
|
+
- Verbose: full detail including image descriptions and row counts
|
|
80
|
+
|
|
81
|
+
## Links
|
|
82
|
+
|
|
83
|
+
- Source: https://github.com/JacquelineDMcGraw/claude-a11y
|
|
84
|
+
- Issues: https://github.com/JacquelineDMcGraw/claude-a11y/issues
|
|
85
|
+
- Chrome extension: https://github.com/JacquelineDMcGraw/claude-a11y/tree/main/packages/browser
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
package/bin/claude-sr.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test-with-speech.sh — Quick way to hear what claude-sr sounds like
|
|
3
|
+
#
|
|
4
|
+
# Usage:
|
|
5
|
+
# ./bin/test-with-speech.sh # Uses default test prompt
|
|
6
|
+
# ./bin/test-with-speech.sh "your question" # Custom prompt
|
|
7
|
+
# ./bin/test-with-speech.sh --voiceover # Start VoiceOver first (macOS)
|
|
8
|
+
# ./bin/test-with-speech.sh --say # Pipe through macOS `say`
|
|
9
|
+
#
|
|
10
|
+
# Screen reader options by platform:
|
|
11
|
+
# macOS: VoiceOver (built-in) — Cmd+F5 to toggle, or pass --voiceover
|
|
12
|
+
# Windows: NVDA (free) — https://www.nvaccess.org/download/
|
|
13
|
+
# Linux: Orca (built-in on GNOME) — Super+Alt+S to toggle
|
|
14
|
+
#
|
|
15
|
+
# The --say flag is the fastest way to demo on macOS without a full screen reader.
|
|
16
|
+
# It pipes claude-sr output through the `say` command for instant text-to-speech.
|
|
17
|
+
|
|
18
|
+
set -euo pipefail
|
|
19
|
+
|
|
20
|
+
DEFAULT_PROMPT="Explain how to print hello world in python, with a code example"
|
|
21
|
+
USE_VOICEOVER=false
|
|
22
|
+
USE_SAY=false
|
|
23
|
+
PROMPT=""
|
|
24
|
+
|
|
25
|
+
# Parse flags
|
|
26
|
+
while [[ $# -gt 0 ]]; do
|
|
27
|
+
case "$1" in
|
|
28
|
+
--voiceover)
|
|
29
|
+
USE_VOICEOVER=true
|
|
30
|
+
shift
|
|
31
|
+
;;
|
|
32
|
+
--say)
|
|
33
|
+
USE_SAY=true
|
|
34
|
+
shift
|
|
35
|
+
;;
|
|
36
|
+
*)
|
|
37
|
+
PROMPT="$1"
|
|
38
|
+
shift
|
|
39
|
+
;;
|
|
40
|
+
esac
|
|
41
|
+
done
|
|
42
|
+
|
|
43
|
+
PROMPT="${PROMPT:-$DEFAULT_PROMPT}"
|
|
44
|
+
|
|
45
|
+
# Resolve claude-sr path
|
|
46
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
47
|
+
CLAUDE_SR="$SCRIPT_DIR/claude-sr.js"
|
|
48
|
+
|
|
49
|
+
if ! command -v node &>/dev/null; then
|
|
50
|
+
echo "Error: Node.js is required. Install from https://nodejs.org" >&2
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# macOS VoiceOver
|
|
55
|
+
if $USE_VOICEOVER; then
|
|
56
|
+
if [[ "$(uname)" != "Darwin" ]]; then
|
|
57
|
+
echo "Error: --voiceover is macOS only. Use NVDA (Windows) or Orca (Linux)." >&2
|
|
58
|
+
exit 1
|
|
59
|
+
fi
|
|
60
|
+
echo "Starting VoiceOver..."
|
|
61
|
+
# Toggle VoiceOver on via AppleScript
|
|
62
|
+
osascript -e 'tell application "System Events" to key code 96 using {command down}' 2>/dev/null || true
|
|
63
|
+
sleep 2
|
|
64
|
+
echo "VoiceOver should be active. Running claude-sr..."
|
|
65
|
+
echo ""
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
if $USE_SAY; then
|
|
69
|
+
if ! command -v say &>/dev/null; then
|
|
70
|
+
echo "Error: 'say' command not found. This flag is macOS only." >&2
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
echo "Running claude-sr and piping to speech..."
|
|
74
|
+
echo "Prompt: $PROMPT"
|
|
75
|
+
echo ""
|
|
76
|
+
|
|
77
|
+
# Run claude-sr, show the text AND speak it
|
|
78
|
+
OUTPUT=$(node "$CLAUDE_SR" "$PROMPT" 2>/dev/null)
|
|
79
|
+
echo "$OUTPUT"
|
|
80
|
+
echo ""
|
|
81
|
+
echo "--- Speaking output ---"
|
|
82
|
+
echo "$OUTPUT" | say -r 200
|
|
83
|
+
echo "Done."
|
|
84
|
+
else
|
|
85
|
+
echo "Running: claude-sr \"$PROMPT\""
|
|
86
|
+
echo ""
|
|
87
|
+
echo "Tip: Turn on your screen reader first to hear the difference!"
|
|
88
|
+
echo " macOS: Cmd+F5 (VoiceOver)"
|
|
89
|
+
echo " Windows: Install NVDA from https://www.nvaccess.org/download/"
|
|
90
|
+
echo " Linux: Super+Alt+S (Orca)"
|
|
91
|
+
echo ""
|
|
92
|
+
echo "Or re-run with --say for instant macOS text-to-speech demo."
|
|
93
|
+
echo "---"
|
|
94
|
+
echo ""
|
|
95
|
+
node "$CLAUDE_SR" "$PROMPT"
|
|
96
|
+
fi
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI entry point for claude-a11y (claude-sr).
|
|
4
|
+
*
|
|
5
|
+
* Parses command-line arguments and routes to either one-shot mode or
|
|
6
|
+
* the conversational REPL.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const node_util_1 = require("node:util");
|
|
10
|
+
const runner_js_1 = require("./runner.js");
|
|
11
|
+
const repl_js_1 = require("./repl.js");
|
|
12
|
+
const index_js_1 = require("../core/index.js");
|
|
13
|
+
const VERSION = (() => {
|
|
14
|
+
try {
|
|
15
|
+
return require("../package.json").version;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return "1.1.0";
|
|
19
|
+
}
|
|
20
|
+
})();
|
|
21
|
+
const HELP_TEXT = `claude-sr — Screen-reader-friendly interface to Claude Code
|
|
22
|
+
|
|
23
|
+
USAGE
|
|
24
|
+
claude-sr Start conversational REPL
|
|
25
|
+
claude-sr "your prompt" One-shot query (like claude -p)
|
|
26
|
+
claude-sr --raw "your prompt" One-shot without speech formatting
|
|
27
|
+
claude-sr -c Continue most recent conversation
|
|
28
|
+
claude-sr -r <session-id> Resume specific session
|
|
29
|
+
|
|
30
|
+
SCREEN READER FEATURES
|
|
31
|
+
* No spinners, animations, or line rewriting
|
|
32
|
+
* No ANSI color codes or formatting
|
|
33
|
+
* Plain, linear, append-only text output
|
|
34
|
+
* Tool activity announced as plain text
|
|
35
|
+
* Fully compatible with NVDA, JAWS, VoiceOver, and Orca
|
|
36
|
+
|
|
37
|
+
REPL COMMANDS
|
|
38
|
+
/help Show this help
|
|
39
|
+
/new Start new session
|
|
40
|
+
/session Show current session ID
|
|
41
|
+
/cost Show accumulated cost
|
|
42
|
+
/version Show version info
|
|
43
|
+
/compact Compact conversation context
|
|
44
|
+
/clear Clear screen
|
|
45
|
+
/exit Exit (also: /quit, Ctrl+D)
|
|
46
|
+
|
|
47
|
+
CLAUDE-SR FLAGS
|
|
48
|
+
--raw Disable speech formatting (sanitized passthrough)
|
|
49
|
+
--quiet Suppress heartbeat and status messages on stderr
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
FLAGS (passed through to claude)
|
|
53
|
+
-m, --model <model> Set model (sonnet, opus, haiku, or full name)
|
|
54
|
+
-c, --continue Continue most recent conversation
|
|
55
|
+
-r, --resume <id> Resume specific session
|
|
56
|
+
--allowedTools <tools> Tools to allow without prompting
|
|
57
|
+
--disallowedTools <tools> Tools to disallow
|
|
58
|
+
--permission-mode <mode> Permission mode (plan, acceptEdits, etc.)
|
|
59
|
+
--system-prompt <text> Replace system prompt
|
|
60
|
+
--append-system-prompt <text> Append to system prompt
|
|
61
|
+
--mcp-config <path> Load MCP servers from JSON
|
|
62
|
+
--max-turns <n> Limit agentic turns
|
|
63
|
+
--verbose Enable verbose output
|
|
64
|
+
--add-dir <paths> Add working directories
|
|
65
|
+
--agents <json> Define custom subagents
|
|
66
|
+
--tools <list> Specify available tools
|
|
67
|
+
--dangerously-skip-permissions Skip all permission prompts
|
|
68
|
+
--fallback-model <model> Fallback model when primary overloaded
|
|
69
|
+
--json-schema <schema> Get structured JSON output
|
|
70
|
+
|
|
71
|
+
All other claude flags are passed through automatically.
|
|
72
|
+
|
|
73
|
+
ENVIRONMENT
|
|
74
|
+
CLAUDE_SR_PROMPT Custom prompt character (default: "> ")
|
|
75
|
+
CLAUDE_SR_ANNOUNCE Set to "0" to suppress tool announcements
|
|
76
|
+
|
|
77
|
+
EXAMPLES
|
|
78
|
+
claude-sr Interactive coding session
|
|
79
|
+
claude-sr "explain this project" Quick question
|
|
80
|
+
claude-sr -c "now add tests" Continue last conversation
|
|
81
|
+
echo "fix lint errors" | claude-sr Piped input
|
|
82
|
+
claude-sr --model opus "review PR" Use specific model
|
|
83
|
+
|
|
84
|
+
REQUIREMENTS
|
|
85
|
+
Claude Code CLI must be installed and authenticated.
|
|
86
|
+
Install: https://docs.anthropic.com/en/docs/claude-code/overview
|
|
87
|
+
|
|
88
|
+
ABOUT
|
|
89
|
+
GitHub: https://github.com/JacquelineDMcGraw/claude-a11y
|
|
90
|
+
License: MIT
|
|
91
|
+
`;
|
|
92
|
+
function parseCliArgs(argv) {
|
|
93
|
+
// Use Node's parseArgs with strict: false to allow unknown flags through
|
|
94
|
+
let values;
|
|
95
|
+
let positionals;
|
|
96
|
+
try {
|
|
97
|
+
const result = (0, node_util_1.parseArgs)({
|
|
98
|
+
args: argv.slice(2), // skip node and script path
|
|
99
|
+
options: {
|
|
100
|
+
// claude-sr specific
|
|
101
|
+
help: { type: "boolean", short: "h", default: false },
|
|
102
|
+
version: { type: "boolean", short: "v", default: false },
|
|
103
|
+
raw: { type: "boolean", default: false },
|
|
104
|
+
quiet: { type: "boolean", default: false },
|
|
105
|
+
// Session management
|
|
106
|
+
continue: { type: "boolean", short: "c", default: false },
|
|
107
|
+
resume: { type: "string", short: "r" },
|
|
108
|
+
// Passthrough string flags
|
|
109
|
+
model: { type: "string", short: "m" },
|
|
110
|
+
allowedTools: { type: "string" },
|
|
111
|
+
disallowedTools: { type: "string" },
|
|
112
|
+
"permission-mode": { type: "string" },
|
|
113
|
+
"system-prompt": { type: "string" },
|
|
114
|
+
"system-prompt-file": { type: "string" },
|
|
115
|
+
"append-system-prompt": { type: "string" },
|
|
116
|
+
"mcp-config": { type: "string" },
|
|
117
|
+
"max-turns": { type: "string" },
|
|
118
|
+
"add-dir": { type: "string" },
|
|
119
|
+
agents: { type: "string" },
|
|
120
|
+
tools: { type: "string" },
|
|
121
|
+
"fallback-model": { type: "string" },
|
|
122
|
+
"setting-sources": { type: "string" },
|
|
123
|
+
settings: { type: "string" },
|
|
124
|
+
"json-schema": { type: "string" },
|
|
125
|
+
// Passthrough boolean flags
|
|
126
|
+
verbose: { type: "boolean", default: false },
|
|
127
|
+
"dangerously-skip-permissions": { type: "boolean", default: false },
|
|
128
|
+
debug: { type: "boolean", default: false },
|
|
129
|
+
},
|
|
130
|
+
allowPositionals: true,
|
|
131
|
+
strict: false,
|
|
132
|
+
});
|
|
133
|
+
values = result.values;
|
|
134
|
+
positionals = result.positionals;
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// If parsing fails, fall back to manual extraction
|
|
138
|
+
values = {};
|
|
139
|
+
positionals = [];
|
|
140
|
+
const args = argv.slice(2);
|
|
141
|
+
for (let i = 0; i < args.length; i++) {
|
|
142
|
+
const arg = args[i];
|
|
143
|
+
if (arg === "-h" || arg === "--help")
|
|
144
|
+
values.help = true;
|
|
145
|
+
else if (arg === "-v" || arg === "--version")
|
|
146
|
+
values.version = true;
|
|
147
|
+
else if (!arg.startsWith("-"))
|
|
148
|
+
positionals.push(arg);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Build passthrough args for claude
|
|
152
|
+
const passthroughArgs = [];
|
|
153
|
+
// String flags
|
|
154
|
+
const stringFlags = [
|
|
155
|
+
["--model", values.model],
|
|
156
|
+
["--allowedTools", values.allowedTools],
|
|
157
|
+
["--disallowedTools", values.disallowedTools],
|
|
158
|
+
["--permission-mode", values["permission-mode"]],
|
|
159
|
+
["--system-prompt", values["system-prompt"]],
|
|
160
|
+
["--system-prompt-file", values["system-prompt-file"]],
|
|
161
|
+
["--append-system-prompt", values["append-system-prompt"]],
|
|
162
|
+
["--mcp-config", values["mcp-config"]],
|
|
163
|
+
["--max-turns", values["max-turns"]],
|
|
164
|
+
["--add-dir", values["add-dir"]],
|
|
165
|
+
["--agents", values.agents],
|
|
166
|
+
["--tools", values.tools],
|
|
167
|
+
["--fallback-model", values["fallback-model"]],
|
|
168
|
+
["--setting-sources", values["setting-sources"]],
|
|
169
|
+
["--settings", values.settings],
|
|
170
|
+
["--json-schema", values["json-schema"]],
|
|
171
|
+
];
|
|
172
|
+
for (const [flag, value] of stringFlags) {
|
|
173
|
+
if (value !== undefined) {
|
|
174
|
+
passthroughArgs.push(flag, value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Boolean flags
|
|
178
|
+
if (values.verbose)
|
|
179
|
+
passthroughArgs.push("--verbose");
|
|
180
|
+
if (values["dangerously-skip-permissions"])
|
|
181
|
+
passthroughArgs.push("--dangerously-skip-permissions");
|
|
182
|
+
if (values.debug)
|
|
183
|
+
passthroughArgs.push("--debug");
|
|
184
|
+
// Determine prompt: either from positionals or -p flag usage
|
|
185
|
+
let prompt = null;
|
|
186
|
+
if (positionals.length > 0) {
|
|
187
|
+
prompt = positionals.join(" ");
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
help: values.help ?? false,
|
|
191
|
+
version: values.version ?? false,
|
|
192
|
+
raw: values.raw ?? false,
|
|
193
|
+
quiet: values.quiet ?? false,
|
|
194
|
+
prompt,
|
|
195
|
+
continueSession: values.continue ?? false,
|
|
196
|
+
resumeId: values.resume ?? null,
|
|
197
|
+
passthroughArgs,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// --- Main ---
|
|
201
|
+
async function main() {
|
|
202
|
+
const args = parseCliArgs(process.argv);
|
|
203
|
+
// Initialize the speech formatter if not already loaded synchronously (bundled builds)
|
|
204
|
+
await (0, index_js_1.initFormatter)();
|
|
205
|
+
// Handle --help
|
|
206
|
+
if (args.help) {
|
|
207
|
+
process.stdout.write(HELP_TEXT);
|
|
208
|
+
process.exit(0);
|
|
209
|
+
}
|
|
210
|
+
// Handle --version
|
|
211
|
+
if (args.version) {
|
|
212
|
+
process.stdout.write(`claude-a11y v${VERSION}\n`);
|
|
213
|
+
process.exit(0);
|
|
214
|
+
}
|
|
215
|
+
// Check claude is installed
|
|
216
|
+
if (!(0, runner_js_1.checkClaudeInstalled)()) {
|
|
217
|
+
process.stderr.write("[Error] Claude Code CLI not found.\n" +
|
|
218
|
+
"\n" +
|
|
219
|
+
"claude-a11y requires the Claude Code CLI to be installed and authenticated.\n" +
|
|
220
|
+
"Install it from: https://docs.anthropic.com/en/docs/claude-code/overview\n" +
|
|
221
|
+
"\n" +
|
|
222
|
+
"After installing, run: claude login\n");
|
|
223
|
+
process.exit(1);
|
|
224
|
+
}
|
|
225
|
+
if (args.raw) {
|
|
226
|
+
(0, runner_js_1.setPassthroughMode)(true);
|
|
227
|
+
}
|
|
228
|
+
if (args.quiet) {
|
|
229
|
+
(0, runner_js_1.setQuietMode)(true);
|
|
230
|
+
}
|
|
231
|
+
// Determine mode: one-shot or REPL
|
|
232
|
+
const isOneShot = args.prompt !== null || !process.stdin.isTTY;
|
|
233
|
+
if (isOneShot) {
|
|
234
|
+
// One-shot mode
|
|
235
|
+
const claudeArgs = [...args.passthroughArgs];
|
|
236
|
+
// Add session flags
|
|
237
|
+
if (args.continueSession)
|
|
238
|
+
claudeArgs.push("--continue");
|
|
239
|
+
if (args.resumeId)
|
|
240
|
+
claudeArgs.push("--resume", args.resumeId);
|
|
241
|
+
// Add prompt
|
|
242
|
+
if (args.prompt) {
|
|
243
|
+
claudeArgs.push("-p", args.prompt);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
// Reading from piped stdin — collect all input first
|
|
247
|
+
const chunks = [];
|
|
248
|
+
for await (const chunk of process.stdin) {
|
|
249
|
+
chunks.push(chunk);
|
|
250
|
+
}
|
|
251
|
+
const input = (0, index_js_1.sanitize)(Buffer.concat(chunks).toString("utf-8")).trim();
|
|
252
|
+
if (!input) {
|
|
253
|
+
process.stderr.write("[Error] No input provided.\n");
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
claudeArgs.push("-p", input);
|
|
257
|
+
}
|
|
258
|
+
const exitCode = await (0, runner_js_1.runOneShot)(claudeArgs);
|
|
259
|
+
process.exitCode = exitCode;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
// REPL mode
|
|
263
|
+
const baseArgs = [...args.passthroughArgs];
|
|
264
|
+
await (0, repl_js_1.startRepl)(baseArgs, args.resumeId ?? undefined);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// Run
|
|
268
|
+
main().catch((err) => {
|
|
269
|
+
process.stderr.write(`[Error] ${err.message}\n`);
|
|
270
|
+
process.exit(1);
|
|
271
|
+
});
|
|
272
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,yCAAsC;AACtC,2CAAiG;AACjG,uCAAsC;AACtC,+CAA2D;AAE3D,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE;IACpB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AC;AACH,CAAC;AAED,MAAM;AACN,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversational REPL loop for multi-turn Claude sessions.
|
|
3
|
+
*
|
|
4
|
+
* Uses readline for input, spawns claude -p for each turn, and maintains
|
|
5
|
+
* session context via --resume. All output is sanitized for screen readers.
|
|
6
|
+
*
|
|
7
|
+
* Key design decisions:
|
|
8
|
+
* - readline prompt goes to stderr (not stdout) so piping captures only responses
|
|
9
|
+
* - stdout is exclusively for Claude's sanitized response text
|
|
10
|
+
* - stderr is for prompts, tool announcements, thinking indicators, errors
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Start the conversational REPL.
|
|
14
|
+
*/
|
|
15
|
+
export declare function startRepl(baseArgs: string[], initialSessionId?: string): Promise<void>;
|