klynx-cli 0.0.3__tar.gz

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.
Files changed (35) hide show
  1. klynx_cli-0.0.3/PKG-INFO +197 -0
  2. klynx_cli-0.0.3/README.md +185 -0
  3. klynx_cli-0.0.3/__init__.py +7 -0
  4. klynx_cli-0.0.3/app.py +1129 -0
  5. klynx_cli-0.0.3/command_specs.py +128 -0
  6. klynx_cli-0.0.3/config.py +385 -0
  7. klynx_cli-0.0.3/config_screen.py +181 -0
  8. klynx_cli-0.0.3/context.py +128 -0
  9. klynx_cli-0.0.3/context_aware_suggester.py +81 -0
  10. klynx_cli-0.0.3/customization/__init__.py +52 -0
  11. klynx_cli-0.0.3/customization/adapters.py +263 -0
  12. klynx_cli-0.0.3/customization/agent_provider.py +258 -0
  13. klynx_cli-0.0.3/customization/commands.py +148 -0
  14. klynx_cli-0.0.3/customization/config.py +305 -0
  15. klynx_cli-0.0.3/customization/keymap.py +69 -0
  16. klynx_cli-0.0.3/customization/preprocessors.py +167 -0
  17. klynx_cli-0.0.3/customization/renderers.py +257 -0
  18. klynx_cli-0.0.3/env.py +22 -0
  19. klynx_cli-0.0.3/klynx_cli.egg-info/PKG-INFO +197 -0
  20. klynx_cli-0.0.3/klynx_cli.egg-info/SOURCES.txt +50 -0
  21. klynx_cli-0.0.3/klynx_cli.egg-info/dependency_links.txt +1 -0
  22. klynx_cli-0.0.3/klynx_cli.egg-info/entry_points.txt +3 -0
  23. klynx_cli-0.0.3/klynx_cli.egg-info/requires.txt +4 -0
  24. klynx_cli-0.0.3/klynx_cli.egg-info/top_level.txt +1 -0
  25. klynx_cli-0.0.3/main.py +812 -0
  26. klynx_cli-0.0.3/output.py +226 -0
  27. klynx_cli-0.0.3/pyproject.toml +31 -0
  28. klynx_cli-0.0.3/runtime.py +360 -0
  29. klynx_cli-0.0.3/session.py +318 -0
  30. klynx_cli-0.0.3/setup.cfg +4 -0
  31. klynx_cli-0.0.3/stdout_redirector.py +54 -0
  32. klynx_cli-0.0.3/suggestion_input.py +25 -0
  33. klynx_cli-0.0.3/tui_app.py +27 -0
  34. klynx_cli-0.0.3/tui_screen_widget.py +70 -0
  35. klynx_cli-0.0.3/wrapping_log.py +129 -0
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: klynx-cli
3
+ Version: 0.0.3
4
+ Summary: Klynx Textual CLI application package.
5
+ Author-email: QZX <qzx480@gmail.com>
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: klynx>=0.0.15
9
+ Requires-Dist: textual>=0.70.0
10
+ Requires-Dist: pyte>=0.8.2
11
+ Requires-Dist: python-dotenv>=1.0.0
12
+
13
+ # Klynx CLI (`klynx-cli`)
14
+
15
+ `klynx-cli` is the official command-line and TUI interface for Klynx.
16
+ It provides:
17
+
18
+ - An interactive terminal UI (`klynx`)
19
+ - A headless automation mode (`klynx run ...`)
20
+ - Session persistence, model switching, auth helpers, diagnostics, and shell completion
21
+
22
+ The package installs two equivalent commands:
23
+
24
+ - `klynx`
25
+ - `klynx-cli`
26
+
27
+ ## Install (PyPI)
28
+
29
+ ```bash
30
+ pip install -U klynx-cli
31
+ ```
32
+
33
+ Optional browser tooling (needed only for browser-based tools):
34
+
35
+ ```bash
36
+ playwright install chromium
37
+ ```
38
+
39
+ ## Quick Start (5 Minutes)
40
+
41
+ ### 1) Configure your model API key
42
+
43
+ ```bash
44
+ klynx auth login --model gpt-4o
45
+ ```
46
+
47
+ Or set environment variables manually (example):
48
+
49
+ ```bash
50
+ export OPENAI_API_KEY="sk-..."
51
+ ```
52
+
53
+ ### 2) Launch the interactive TUI
54
+
55
+ ```bash
56
+ klynx
57
+ ```
58
+
59
+ ### 3) Run one task immediately
60
+
61
+ ```bash
62
+ klynx "review the current repository and propose a refactor plan"
63
+ ```
64
+
65
+ ### 4) Run in headless mode
66
+
67
+ ```bash
68
+ klynx run "fix the failing tests and explain the root cause"
69
+ ```
70
+
71
+ ### 5) Resume the latest session
72
+
73
+ ```bash
74
+ klynx resume --last
75
+ ```
76
+
77
+ ## Usage Tutorial
78
+
79
+ ### Tutorial A: Interactive coding workflow in TUI
80
+
81
+ 1. Start TUI: `klynx`
82
+ 2. Enter a task, for example:
83
+ - `implement retry logic for the API client and add tests`
84
+ 3. Use slash commands inside TUI:
85
+ - `/help`
86
+ - `/context`
87
+ - `/compact`
88
+ - `/model`
89
+ 4. Continue follow-up prompts in the same session to iterate.
90
+
91
+ ### Tutorial B: CI-friendly headless execution
92
+
93
+ Use `run` for scripted workflows:
94
+
95
+ ```bash
96
+ klynx run --json "summarize current test failures"
97
+ klynx run --show-tools "apply fixes and run verification"
98
+ klynx run --mode plan --approval on-request "design and implement a migration path"
99
+ ```
100
+
101
+ ### Tutorial C: Work across multiple directories
102
+
103
+ Allow additional directories when needed:
104
+
105
+ ```bash
106
+ klynx run --add-dir ../shared-lib --add-dir ../docs "check cross-repo compatibility"
107
+ ```
108
+
109
+ ### Tutorial D: Manage session history
110
+
111
+ ```bash
112
+ klynx session list
113
+ klynx session show --last
114
+ klynx session compact --last
115
+ klynx session delete <session_id>
116
+ ```
117
+
118
+ ## Common Commands
119
+
120
+ ```bash
121
+ klynx run "..."
122
+ klynx resume --last
123
+ klynx session list
124
+ klynx auth status
125
+ klynx auth login --model gpt-4o
126
+ klynx models list
127
+ klynx models set gpt-4o --scope global
128
+ klynx config show
129
+ klynx doctor
130
+ klynx completion powershell
131
+ ```
132
+
133
+ ## Configuration and Credentials
134
+
135
+ Configuration precedence:
136
+
137
+ 1. Built-in defaults
138
+ 2. `~/.klynx/config.toml`
139
+ 3. `.klynx/config.toml`
140
+ 4. `.klynx/tui/config.yaml` (legacy TUI config)
141
+ 5. Environment variables (for example `KLYNX_DEFAULT_PROVIDER`, `KLYNX_DEFAULT_MODEL`)
142
+ 6. CLI overrides (`-c key=value`)
143
+
144
+ Credential lookup precedence:
145
+
146
+ 1. Process environment variables
147
+ 2. `~/.klynx/.env`
148
+ 3. `.klynx/.env`
149
+ 4. Values written by `klynx auth login`
150
+
151
+ ## TUI Output Configuration
152
+
153
+ You can tune transcript visibility in `.klynx/tui/config.yaml`:
154
+
155
+ ```yaml
156
+ output:
157
+ visible_events: [warning, error, answer, tool_exec]
158
+ show_reasoning_indicator: true
159
+ show_raw_stdout: false
160
+ tool_result_max_lines: 8
161
+ ```
162
+
163
+ ## Logging and Diagnostics
164
+
165
+ ```bash
166
+ klynx run --log-level DEBUG --print-logs "debug this task"
167
+ klynx doctor --json
168
+ ```
169
+
170
+ - Logs are written to `~/.klynx/logs/klynx-cli.log`
171
+ - `--print-logs` also mirrors logs to stderr
172
+ - `doctor` checks import health, writable paths, tool availability, and auth readiness
173
+
174
+ ## Shell Completion
175
+
176
+ ```bash
177
+ klynx completion bash
178
+ klynx completion powershell
179
+ ```
180
+
181
+ PowerShell load example:
182
+
183
+ ```powershell
184
+ klynx completion powershell | Invoke-Expression
185
+ ```
186
+
187
+ ## Exit Codes
188
+
189
+ - `0`: success
190
+ - `1`: runtime failure
191
+ - `2`: usage error
192
+ - `3`: config validation failure
193
+ - `4`: session not found
194
+
195
+ ## Related Package
196
+
197
+ `klynx-cli` depends on the core SDK package `klynx` and installs it automatically via PyPI dependency resolution.
@@ -0,0 +1,185 @@
1
+ # Klynx CLI (`klynx-cli`)
2
+
3
+ `klynx-cli` is the official command-line and TUI interface for Klynx.
4
+ It provides:
5
+
6
+ - An interactive terminal UI (`klynx`)
7
+ - A headless automation mode (`klynx run ...`)
8
+ - Session persistence, model switching, auth helpers, diagnostics, and shell completion
9
+
10
+ The package installs two equivalent commands:
11
+
12
+ - `klynx`
13
+ - `klynx-cli`
14
+
15
+ ## Install (PyPI)
16
+
17
+ ```bash
18
+ pip install -U klynx-cli
19
+ ```
20
+
21
+ Optional browser tooling (needed only for browser-based tools):
22
+
23
+ ```bash
24
+ playwright install chromium
25
+ ```
26
+
27
+ ## Quick Start (5 Minutes)
28
+
29
+ ### 1) Configure your model API key
30
+
31
+ ```bash
32
+ klynx auth login --model gpt-4o
33
+ ```
34
+
35
+ Or set environment variables manually (example):
36
+
37
+ ```bash
38
+ export OPENAI_API_KEY="sk-..."
39
+ ```
40
+
41
+ ### 2) Launch the interactive TUI
42
+
43
+ ```bash
44
+ klynx
45
+ ```
46
+
47
+ ### 3) Run one task immediately
48
+
49
+ ```bash
50
+ klynx "review the current repository and propose a refactor plan"
51
+ ```
52
+
53
+ ### 4) Run in headless mode
54
+
55
+ ```bash
56
+ klynx run "fix the failing tests and explain the root cause"
57
+ ```
58
+
59
+ ### 5) Resume the latest session
60
+
61
+ ```bash
62
+ klynx resume --last
63
+ ```
64
+
65
+ ## Usage Tutorial
66
+
67
+ ### Tutorial A: Interactive coding workflow in TUI
68
+
69
+ 1. Start TUI: `klynx`
70
+ 2. Enter a task, for example:
71
+ - `implement retry logic for the API client and add tests`
72
+ 3. Use slash commands inside TUI:
73
+ - `/help`
74
+ - `/context`
75
+ - `/compact`
76
+ - `/model`
77
+ 4. Continue follow-up prompts in the same session to iterate.
78
+
79
+ ### Tutorial B: CI-friendly headless execution
80
+
81
+ Use `run` for scripted workflows:
82
+
83
+ ```bash
84
+ klynx run --json "summarize current test failures"
85
+ klynx run --show-tools "apply fixes and run verification"
86
+ klynx run --mode plan --approval on-request "design and implement a migration path"
87
+ ```
88
+
89
+ ### Tutorial C: Work across multiple directories
90
+
91
+ Allow additional directories when needed:
92
+
93
+ ```bash
94
+ klynx run --add-dir ../shared-lib --add-dir ../docs "check cross-repo compatibility"
95
+ ```
96
+
97
+ ### Tutorial D: Manage session history
98
+
99
+ ```bash
100
+ klynx session list
101
+ klynx session show --last
102
+ klynx session compact --last
103
+ klynx session delete <session_id>
104
+ ```
105
+
106
+ ## Common Commands
107
+
108
+ ```bash
109
+ klynx run "..."
110
+ klynx resume --last
111
+ klynx session list
112
+ klynx auth status
113
+ klynx auth login --model gpt-4o
114
+ klynx models list
115
+ klynx models set gpt-4o --scope global
116
+ klynx config show
117
+ klynx doctor
118
+ klynx completion powershell
119
+ ```
120
+
121
+ ## Configuration and Credentials
122
+
123
+ Configuration precedence:
124
+
125
+ 1. Built-in defaults
126
+ 2. `~/.klynx/config.toml`
127
+ 3. `.klynx/config.toml`
128
+ 4. `.klynx/tui/config.yaml` (legacy TUI config)
129
+ 5. Environment variables (for example `KLYNX_DEFAULT_PROVIDER`, `KLYNX_DEFAULT_MODEL`)
130
+ 6. CLI overrides (`-c key=value`)
131
+
132
+ Credential lookup precedence:
133
+
134
+ 1. Process environment variables
135
+ 2. `~/.klynx/.env`
136
+ 3. `.klynx/.env`
137
+ 4. Values written by `klynx auth login`
138
+
139
+ ## TUI Output Configuration
140
+
141
+ You can tune transcript visibility in `.klynx/tui/config.yaml`:
142
+
143
+ ```yaml
144
+ output:
145
+ visible_events: [warning, error, answer, tool_exec]
146
+ show_reasoning_indicator: true
147
+ show_raw_stdout: false
148
+ tool_result_max_lines: 8
149
+ ```
150
+
151
+ ## Logging and Diagnostics
152
+
153
+ ```bash
154
+ klynx run --log-level DEBUG --print-logs "debug this task"
155
+ klynx doctor --json
156
+ ```
157
+
158
+ - Logs are written to `~/.klynx/logs/klynx-cli.log`
159
+ - `--print-logs` also mirrors logs to stderr
160
+ - `doctor` checks import health, writable paths, tool availability, and auth readiness
161
+
162
+ ## Shell Completion
163
+
164
+ ```bash
165
+ klynx completion bash
166
+ klynx completion powershell
167
+ ```
168
+
169
+ PowerShell load example:
170
+
171
+ ```powershell
172
+ klynx completion powershell | Invoke-Expression
173
+ ```
174
+
175
+ ## Exit Codes
176
+
177
+ - `0`: success
178
+ - `1`: runtime failure
179
+ - `2`: usage error
180
+ - `3`: config validation failure
181
+ - `4`: session not found
182
+
183
+ ## Related Package
184
+
185
+ `klynx-cli` depends on the core SDK package `klynx` and installs it automatically via PyPI dependency resolution.
@@ -0,0 +1,7 @@
1
+ """Klynx TUI app package."""
2
+
3
+ from .app import KlynxTUIApp
4
+
5
+ __all__ = [
6
+ "KlynxTUIApp",
7
+ ]