kedi-debugger 0.1.0__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.
@@ -0,0 +1,16 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .env
6
+ .env.*
7
+ .pypirc
8
+ .coverage
9
+ .coverage.*
10
+ coverage.xml
11
+ htmlcov/
12
+ .pytest_cache/
13
+ .ruff_cache/
14
+ build/
15
+ dist/
16
+ .DS_Store
@@ -0,0 +1,203 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ Copyright © 2025 - Kedi Programming Language
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright [yyyy] [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.5
2
+ Name: kedi-debugger
3
+ Version: 0.1.0
4
+ Summary: Optional stdio Debug Adapter Protocol backend for Kedi
5
+ Project-URL: Documentation, https://docs.kedi-lang.org/tooling/debugger/
6
+ Project-URL: Source, https://github.com/kedi-lang/kedi-debugger
7
+ Project-URL: Tracker, https://github.com/kedi-lang/kedi-debugger/issues
8
+ License: Apache-2.0
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: kedi<0.2,>=0.1.1
12
+ Requires-Dist: python-dotenv<2,>=1.2.2
13
+ Description-Content-Type: text/markdown
14
+
15
+ # Kedi Debugger
16
+
17
+ An optional, local Debug Adapter Protocol (DAP) backend shared by the Kedi VS Code
18
+ and Zed extensions. The protocol supervisor owns a separate Kedi worker process.
19
+ The normal runtime does not import this package or record debugger snapshots.
20
+
21
+ This package lives in [kedi-lang/kedi-debugger](https://github.com/kedi-lang/kedi-debugger)
22
+ and is pinned as the `debugger/` submodule in the Kedi repository. From an existing
23
+ Kedi checkout, initialize it with `git submodule update --init debugger`.
24
+
25
+ ## Local Installation
26
+
27
+ The updated editor extensions automatically install this package in their shared
28
+ managed environment, including upgrades of existing managed installations. This
29
+ requires the matching runtime and debugger releases on the package index; source
30
+ changes do not publish those releases.
31
+
32
+ For local development or a selected host Python, use the same interpreter for
33
+ the editor, Kedi, debugger, and program dependencies:
34
+
35
+ ```sh
36
+ python -m pip install -e /path/to/kedi
37
+ python -m pip install --no-deps -e /path/to/kedi/debugger
38
+ python -c 'import kedi_debugger; from kedi.debugging import DebugEvent, observe_execution'
39
+ ```
40
+
41
+ This source checkout adds runtime hooks that older Kedi installations do not have.
42
+ The debugger and updated extensions have not been published automatically. A
43
+ missing package is an installation error, not a reason to select another Python.
44
+ Both extensions reuse the selected host interpreter or `~/.kedi/editor-venv`;
45
+ neither creates a second debugger environment or modifies a host environment.
46
+
47
+ The machine-facing entry point is `python -m kedi_debugger --stdio`.
48
+ `kedi debug --stdio` is an equivalent CLI bridge. Start the backend through an
49
+ editor, not an interactive terminal: stdin/stdout carry DAP frames.
50
+
51
+ ## Launch Contract
52
+
53
+ ```json
54
+ {
55
+ "type": "kedi",
56
+ "request": "launch",
57
+ "name": "Debug Kedi",
58
+ "program": "${file}",
59
+ "cwd": "${workspaceFolder}",
60
+ "args": [],
61
+ "env": {},
62
+ "stopOnEntry": true
63
+ }
64
+ ```
65
+
66
+ `adapter` and `model` optionally select the existing CLI runtime defaults;
67
+ program/profile directives still follow normal Kedi rules. Before starting the
68
+ worker or importing Kedi, the debugger finds the nearest `.env` starting at
69
+ `cwd` and searching its parents. Without `cwd`, it starts at the program's
70
+ directory. It loads one file, not a merge of every parent file. API keys and
71
+ `KEDI_ADAPTER`, `KEDI_ADAPTER_MODEL`, and `MODEL_NAME` are available before model
72
+ selection, including when the editor was opened outside a terminal.
73
+
74
+ Launch `env` entries take priority over inherited environment variables, which
75
+ take priority over `.env` values. Strings override values; null removes a
76
+ variable even if `.env` defines it; an empty string remains an empty value.
77
+ Dotenv quoting, multiline values, and `${NAME}` interpolation are supported.
78
+ Explicit launch `adapter`/`model` fields take priority over environment defaults.
79
+ Missing `.env` files are optional; unreadable or invalid files fail launch without
80
+ printing their contents. The supervisor's own environment is never mutated.
81
+
82
+ Set `PYTHON_DOTENV_DISABLED=1` in the inherited environment or launch `env` to
83
+ skip dotenv discovery. After resolving the worker environment, the debugger sets
84
+ this flag for the worker to prevent later `load_dotenv()` calls from finding a
85
+ different file or restoring removed variables. Restart the debug session after
86
+ changing `.env`. Known credentials from the loaded file are masked in debugger
87
+ output and inspections. Keep credentials out of checked-in launch files.
88
+
89
+ The selected interpreter launches both supervisor and worker; launch arguments
90
+ cannot silently replace it.
91
+
92
+ ## Execution Controls
93
+
94
+ - Breakpoints stop before executable Kedi statements. Unsupported locations and
95
+ conditional/log/hit-count breakpoints are rejected, not silently relocated.
96
+ - Step into enters a Kedi procedure; next steps over it; step out reaches the
97
+ next boundary after it returns. Embedded Python blocks are opaque units.
98
+ - Pause requests the next cooperative boundary. It cannot freeze an active
99
+ network call or arbitrary Python instruction.
100
+ - Independent model jobs remain concurrent. A stop affects one lane and never
101
+ claims that every thread stopped. Continue normally releases paused lanes;
102
+ a single-thread request releases only the selected lane.
103
+ Stepping also resumes paused peers by default so a capture can receive its
104
+ result. Explicit single-thread stepping can wait for a paused producer; resume
105
+ that producer separately when needed.
106
+ - Optional exception/event filters `model_input` and `model_result` expose the
107
+ prepared model input before its conversation transaction and its returned
108
+ result afterward. `exceptions` stops at raised Kedi execution boundaries.
109
+ - Request assembly is observation-only inside a conversation transaction. The
110
+ `request` scope contains the actual assembled Kedi prompt/instructions/tool
111
+ names, not an invented provider wire payload. Available usage is observed, not
112
+ estimated. The `model_input` scope precedes request-transforming hooks.
113
+ Nested synchronous tool execution is also observation-only while the model
114
+ transaction owns its resources. A propagated tool failure can stop afterward,
115
+ once the transaction has released them. Provider failures from parallel model
116
+ jobs reach exception stops just like failures on the main lane.
117
+
118
+ Pausing does not suspend external deadlines, undo effects, replay a request, or
119
+ override tool approval. Interactive stdin and terminal approval prompts are not
120
+ supported in the DAP worker. Existing noninteractive approval policies continue
121
+ to apply; a denied tool is not automatically approved for debugging.
122
+
123
+ ## Read-only Inspection
124
+
125
+ Native editor stack/scopes/variables show lexical locals, bounded closure scopes, globals, Python prelude
126
+ values, recent model observations, and changes in captured values. Completed
127
+ captures expose their already-published values, including typed fields, without
128
+ calling `resolve()` or waiting. Pending/failed/cancelled captures remain explicit.
129
+ Inspecting a result never makes another model or tool call. Unknown objects stay
130
+ opaque rather than running their repr, properties, serializers, or iterators.
131
+
132
+ Watch/evaluate accepts names and paths such as `answer`, `record.name`, and
133
+ `items[0]`, restricted to already captured values. It cannot run Python, call
134
+ functions, mutate state, or retrieve omitted/truncated values. Handles expire
135
+ when their lane resumes. After outstanding jobs drain, a bounded final snapshot stays in the process until
136
+ the editor disconnects; there is no persistent execution archive.
137
+
138
+ When distinct dictionary keys have the same display name (for example `1` and
139
+ `"1"`), watch evaluation rejects the ambiguous path instead of guessing. Inspect
140
+ the displayed variables directly in that case.
141
+
142
+ Snapshots bound items, depth, text length and encoded bytes. Limits and cycles
143
+ are visible, not represented as complete values. Sensitive field names and known
144
+ environment secrets are redacted, including source responses without shifting
145
+ their line positions. Arbitrary user text can still contain unknown
146
+ sensitive information; review before sharing screenshots or logs. There is no
147
+ Logfire dependency or telemetry exporter configured by the debugger.
148
+
149
+ Large containers cannot consume the slots reserved for later sibling bindings.
150
+ Each scope has a separate item budget within the bounded stop snapshot; empty
151
+ and scalar scopes have valid inspection references too. A truncated scope includes
152
+ a `<snapshot>` notice so omitted bindings are not mistaken for missing program
153
+ variables. Resolved promises display their memoized value, not a later replacement
154
+ in the shared model-result mapping.
155
+
156
+ ## Restart and Run State
157
+
158
+ Use the editor's **Restart/Rerun** action after saving source or `.env` changes.
159
+ The adapter supports the DAP terminate/disconnect restart sequence: the editor
160
+ launches a fresh adapter and worker, with fresh configuration and breakpoints.
161
+ There is no in-place hot reload of an executing program. Attempting to continue
162
+ after a source edit leaves execution paused and explains the required restart
163
+ in the console.
164
+
165
+ Thread names stay stable. Running/stopped state comes from DAP control events,
166
+ not a cached suffix on the thread name. Clients supporting progress reporting
167
+ receive balanced capture-wait progress events; already-completed captures do
168
+ not report waiting. Completion ends outstanding progress and sends thread-exit
169
+ events before the program's exit code and session termination.
170
+
171
+ Statement stepping stops at the next eligible Kedi statement, not at each
172
+ internal model observation on the same line. Explicit model event breakpoints
173
+ continue to work. A statement is stopped **before** it executes, so a newly
174
+ assigned value becomes visible at the following stop. On normal completion,
175
+ editors may clear their Variables panel; inspect before continuing past the
176
+ last breakpoint when you need to retain the view.
177
+
178
+ ## Boundaries
179
+
180
+ Launch trusted saved `.kedi` files only. There is no remote attach, hot reload,
181
+ reverse execution, arbitrary evaluate, Python-internal stepping, notebook/REPL
182
+ debugging, terminal input, or subagent-internal async stepping. Synchronous
183
+ observers on an asyncio loop are observation-only. Blocking unmanaged code may
184
+ need worker termination; that does not imply rollback or graceful cleanup of
185
+ remote services. Only the owned process group is terminated.
186
+
187
+ Source snapshots are frozen for the session. Changed sources are rejected before
188
+ configuration or resuming execution; restart to run an edited program. The actual
189
+ compiled source is checked too, including imported Kedi modules.
190
+
191
+ ## Validation
192
+
193
+ The runtime integration tests live in the parent
194
+ [Kedi repository](https://github.com/kedi-lang/kedi/tree/stable/tests), not in
195
+ this package checkout. From that repository's development environment:
196
+
197
+ ```sh
198
+ python -m pytest tests/test_debugging.py tests/test_debugger_*.py
199
+ ```
200
+
201
+ These tests use deterministic adapters and actual DAP subprocesses. They do not
202
+ call Claude, other paid providers, or Terminal-Bench tasks. Editor extension
203
+ builds/tests are separate from these backend tests; installing/publishing the
204
+ extensions is a separate release step.
205
+
206
+ Protocol reference: [DAP overview](https://microsoft.github.io/debug-adapter-protocol/overview).
@@ -0,0 +1,192 @@
1
+ # Kedi Debugger
2
+
3
+ An optional, local Debug Adapter Protocol (DAP) backend shared by the Kedi VS Code
4
+ and Zed extensions. The protocol supervisor owns a separate Kedi worker process.
5
+ The normal runtime does not import this package or record debugger snapshots.
6
+
7
+ This package lives in [kedi-lang/kedi-debugger](https://github.com/kedi-lang/kedi-debugger)
8
+ and is pinned as the `debugger/` submodule in the Kedi repository. From an existing
9
+ Kedi checkout, initialize it with `git submodule update --init debugger`.
10
+
11
+ ## Local Installation
12
+
13
+ The updated editor extensions automatically install this package in their shared
14
+ managed environment, including upgrades of existing managed installations. This
15
+ requires the matching runtime and debugger releases on the package index; source
16
+ changes do not publish those releases.
17
+
18
+ For local development or a selected host Python, use the same interpreter for
19
+ the editor, Kedi, debugger, and program dependencies:
20
+
21
+ ```sh
22
+ python -m pip install -e /path/to/kedi
23
+ python -m pip install --no-deps -e /path/to/kedi/debugger
24
+ python -c 'import kedi_debugger; from kedi.debugging import DebugEvent, observe_execution'
25
+ ```
26
+
27
+ This source checkout adds runtime hooks that older Kedi installations do not have.
28
+ The debugger and updated extensions have not been published automatically. A
29
+ missing package is an installation error, not a reason to select another Python.
30
+ Both extensions reuse the selected host interpreter or `~/.kedi/editor-venv`;
31
+ neither creates a second debugger environment or modifies a host environment.
32
+
33
+ The machine-facing entry point is `python -m kedi_debugger --stdio`.
34
+ `kedi debug --stdio` is an equivalent CLI bridge. Start the backend through an
35
+ editor, not an interactive terminal: stdin/stdout carry DAP frames.
36
+
37
+ ## Launch Contract
38
+
39
+ ```json
40
+ {
41
+ "type": "kedi",
42
+ "request": "launch",
43
+ "name": "Debug Kedi",
44
+ "program": "${file}",
45
+ "cwd": "${workspaceFolder}",
46
+ "args": [],
47
+ "env": {},
48
+ "stopOnEntry": true
49
+ }
50
+ ```
51
+
52
+ `adapter` and `model` optionally select the existing CLI runtime defaults;
53
+ program/profile directives still follow normal Kedi rules. Before starting the
54
+ worker or importing Kedi, the debugger finds the nearest `.env` starting at
55
+ `cwd` and searching its parents. Without `cwd`, it starts at the program's
56
+ directory. It loads one file, not a merge of every parent file. API keys and
57
+ `KEDI_ADAPTER`, `KEDI_ADAPTER_MODEL`, and `MODEL_NAME` are available before model
58
+ selection, including when the editor was opened outside a terminal.
59
+
60
+ Launch `env` entries take priority over inherited environment variables, which
61
+ take priority over `.env` values. Strings override values; null removes a
62
+ variable even if `.env` defines it; an empty string remains an empty value.
63
+ Dotenv quoting, multiline values, and `${NAME}` interpolation are supported.
64
+ Explicit launch `adapter`/`model` fields take priority over environment defaults.
65
+ Missing `.env` files are optional; unreadable or invalid files fail launch without
66
+ printing their contents. The supervisor's own environment is never mutated.
67
+
68
+ Set `PYTHON_DOTENV_DISABLED=1` in the inherited environment or launch `env` to
69
+ skip dotenv discovery. After resolving the worker environment, the debugger sets
70
+ this flag for the worker to prevent later `load_dotenv()` calls from finding a
71
+ different file or restoring removed variables. Restart the debug session after
72
+ changing `.env`. Known credentials from the loaded file are masked in debugger
73
+ output and inspections. Keep credentials out of checked-in launch files.
74
+
75
+ The selected interpreter launches both supervisor and worker; launch arguments
76
+ cannot silently replace it.
77
+
78
+ ## Execution Controls
79
+
80
+ - Breakpoints stop before executable Kedi statements. Unsupported locations and
81
+ conditional/log/hit-count breakpoints are rejected, not silently relocated.
82
+ - Step into enters a Kedi procedure; next steps over it; step out reaches the
83
+ next boundary after it returns. Embedded Python blocks are opaque units.
84
+ - Pause requests the next cooperative boundary. It cannot freeze an active
85
+ network call or arbitrary Python instruction.
86
+ - Independent model jobs remain concurrent. A stop affects one lane and never
87
+ claims that every thread stopped. Continue normally releases paused lanes;
88
+ a single-thread request releases only the selected lane.
89
+ Stepping also resumes paused peers by default so a capture can receive its
90
+ result. Explicit single-thread stepping can wait for a paused producer; resume
91
+ that producer separately when needed.
92
+ - Optional exception/event filters `model_input` and `model_result` expose the
93
+ prepared model input before its conversation transaction and its returned
94
+ result afterward. `exceptions` stops at raised Kedi execution boundaries.
95
+ - Request assembly is observation-only inside a conversation transaction. The
96
+ `request` scope contains the actual assembled Kedi prompt/instructions/tool
97
+ names, not an invented provider wire payload. Available usage is observed, not
98
+ estimated. The `model_input` scope precedes request-transforming hooks.
99
+ Nested synchronous tool execution is also observation-only while the model
100
+ transaction owns its resources. A propagated tool failure can stop afterward,
101
+ once the transaction has released them. Provider failures from parallel model
102
+ jobs reach exception stops just like failures on the main lane.
103
+
104
+ Pausing does not suspend external deadlines, undo effects, replay a request, or
105
+ override tool approval. Interactive stdin and terminal approval prompts are not
106
+ supported in the DAP worker. Existing noninteractive approval policies continue
107
+ to apply; a denied tool is not automatically approved for debugging.
108
+
109
+ ## Read-only Inspection
110
+
111
+ Native editor stack/scopes/variables show lexical locals, bounded closure scopes, globals, Python prelude
112
+ values, recent model observations, and changes in captured values. Completed
113
+ captures expose their already-published values, including typed fields, without
114
+ calling `resolve()` or waiting. Pending/failed/cancelled captures remain explicit.
115
+ Inspecting a result never makes another model or tool call. Unknown objects stay
116
+ opaque rather than running their repr, properties, serializers, or iterators.
117
+
118
+ Watch/evaluate accepts names and paths such as `answer`, `record.name`, and
119
+ `items[0]`, restricted to already captured values. It cannot run Python, call
120
+ functions, mutate state, or retrieve omitted/truncated values. Handles expire
121
+ when their lane resumes. After outstanding jobs drain, a bounded final snapshot stays in the process until
122
+ the editor disconnects; there is no persistent execution archive.
123
+
124
+ When distinct dictionary keys have the same display name (for example `1` and
125
+ `"1"`), watch evaluation rejects the ambiguous path instead of guessing. Inspect
126
+ the displayed variables directly in that case.
127
+
128
+ Snapshots bound items, depth, text length and encoded bytes. Limits and cycles
129
+ are visible, not represented as complete values. Sensitive field names and known
130
+ environment secrets are redacted, including source responses without shifting
131
+ their line positions. Arbitrary user text can still contain unknown
132
+ sensitive information; review before sharing screenshots or logs. There is no
133
+ Logfire dependency or telemetry exporter configured by the debugger.
134
+
135
+ Large containers cannot consume the slots reserved for later sibling bindings.
136
+ Each scope has a separate item budget within the bounded stop snapshot; empty
137
+ and scalar scopes have valid inspection references too. A truncated scope includes
138
+ a `<snapshot>` notice so omitted bindings are not mistaken for missing program
139
+ variables. Resolved promises display their memoized value, not a later replacement
140
+ in the shared model-result mapping.
141
+
142
+ ## Restart and Run State
143
+
144
+ Use the editor's **Restart/Rerun** action after saving source or `.env` changes.
145
+ The adapter supports the DAP terminate/disconnect restart sequence: the editor
146
+ launches a fresh adapter and worker, with fresh configuration and breakpoints.
147
+ There is no in-place hot reload of an executing program. Attempting to continue
148
+ after a source edit leaves execution paused and explains the required restart
149
+ in the console.
150
+
151
+ Thread names stay stable. Running/stopped state comes from DAP control events,
152
+ not a cached suffix on the thread name. Clients supporting progress reporting
153
+ receive balanced capture-wait progress events; already-completed captures do
154
+ not report waiting. Completion ends outstanding progress and sends thread-exit
155
+ events before the program's exit code and session termination.
156
+
157
+ Statement stepping stops at the next eligible Kedi statement, not at each
158
+ internal model observation on the same line. Explicit model event breakpoints
159
+ continue to work. A statement is stopped **before** it executes, so a newly
160
+ assigned value becomes visible at the following stop. On normal completion,
161
+ editors may clear their Variables panel; inspect before continuing past the
162
+ last breakpoint when you need to retain the view.
163
+
164
+ ## Boundaries
165
+
166
+ Launch trusted saved `.kedi` files only. There is no remote attach, hot reload,
167
+ reverse execution, arbitrary evaluate, Python-internal stepping, notebook/REPL
168
+ debugging, terminal input, or subagent-internal async stepping. Synchronous
169
+ observers on an asyncio loop are observation-only. Blocking unmanaged code may
170
+ need worker termination; that does not imply rollback or graceful cleanup of
171
+ remote services. Only the owned process group is terminated.
172
+
173
+ Source snapshots are frozen for the session. Changed sources are rejected before
174
+ configuration or resuming execution; restart to run an edited program. The actual
175
+ compiled source is checked too, including imported Kedi modules.
176
+
177
+ ## Validation
178
+
179
+ The runtime integration tests live in the parent
180
+ [Kedi repository](https://github.com/kedi-lang/kedi/tree/stable/tests), not in
181
+ this package checkout. From that repository's development environment:
182
+
183
+ ```sh
184
+ python -m pytest tests/test_debugging.py tests/test_debugger_*.py
185
+ ```
186
+
187
+ These tests use deterministic adapters and actual DAP subprocesses. They do not
188
+ call Claude, other paid providers, or Terminal-Bench tasks. Editor extension
189
+ builds/tests are separate from these backend tests; installing/publishing the
190
+ extensions is a separate release step.
191
+
192
+ Protocol reference: [DAP overview](https://microsoft.github.io/debug-adapter-protocol/overview).
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["hatchling==1.32.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "kedi-debugger"
7
+ version = "0.1.0"
8
+ description = "Optional stdio Debug Adapter Protocol backend for Kedi"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {text = "Apache-2.0"}
12
+ dependencies = ["kedi>=0.1.1,<0.2", "python-dotenv>=1.2.2,<2"]
13
+
14
+ [project.scripts]
15
+ kedi-debugger = "kedi_debugger.__main__:main"
16
+
17
+ [project.urls]
18
+ Documentation = "https://docs.kedi-lang.org/tooling/debugger/"
19
+ Source = "https://github.com/kedi-lang/kedi-debugger"
20
+ Tracker = "https://github.com/kedi-lang/kedi-debugger/issues"
21
+
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["src/kedi_debugger"]
24
+
25
+ [tool.ruff]
26
+ line-length = 100
27
+ target-version = "py311"
28
+
29
+ [tool.ruff.lint]
30
+ # Ruff 0.17 widened its default rule set; keep the rules this project was linted with.
31
+ select = ["E4", "E7", "E9", "F"]
@@ -0,0 +1,7 @@
1
+ """Optional Kedi debugger. Importing the transport does not load the runtime."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ __all__ = ["__version__"]