linc-spectra 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.
Files changed (67) hide show
  1. linc_spectra-0.1.0/LICENSE +202 -0
  2. linc_spectra-0.1.0/NOTICE +2 -0
  3. linc_spectra-0.1.0/PKG-INFO +161 -0
  4. linc_spectra-0.1.0/README.md +127 -0
  5. linc_spectra-0.1.0/pyproject.toml +113 -0
  6. linc_spectra-0.1.0/setup.cfg +4 -0
  7. linc_spectra-0.1.0/src/linc_spectra/__init__.py +15 -0
  8. linc_spectra-0.1.0/src/linc_spectra/_logging.py +87 -0
  9. linc_spectra-0.1.0/src/linc_spectra/cli.py +321 -0
  10. linc_spectra-0.1.0/src/linc_spectra/core/__init__.py +0 -0
  11. linc_spectra-0.1.0/src/linc_spectra/core/adb_subprocess.py +139 -0
  12. linc_spectra-0.1.0/src/linc_spectra/core/dap_client.py +979 -0
  13. linc_spectra-0.1.0/src/linc_spectra/core/ios_subprocess.py +42 -0
  14. linc_spectra-0.1.0/src/linc_spectra/core/jdb_session.py +1108 -0
  15. linc_spectra-0.1.0/src/linc_spectra/core/jdwp_bridge.py +302 -0
  16. linc_spectra-0.1.0/src/linc_spectra/core/lldb_bridge.py +130 -0
  17. linc_spectra-0.1.0/src/linc_spectra/core/observability.py +232 -0
  18. linc_spectra-0.1.0/src/linc_spectra/core/paths.py +23 -0
  19. linc_spectra-0.1.0/src/linc_spectra/core/ports.py +17 -0
  20. linc_spectra-0.1.0/src/linc_spectra/core/session_manager.py +503 -0
  21. linc_spectra-0.1.0/src/linc_spectra/core/toolchain.py +120 -0
  22. linc_spectra-0.1.0/src/linc_spectra/core/usage_stats.py +196 -0
  23. linc_spectra-0.1.0/src/linc_spectra/core/validation.py +151 -0
  24. linc_spectra-0.1.0/src/linc_spectra/mcp_server.py +1243 -0
  25. linc_spectra-0.1.0/src/linc_spectra.egg-info/PKG-INFO +161 -0
  26. linc_spectra-0.1.0/src/linc_spectra.egg-info/SOURCES.txt +65 -0
  27. linc_spectra-0.1.0/src/linc_spectra.egg-info/dependency_links.txt +1 -0
  28. linc_spectra-0.1.0/src/linc_spectra.egg-info/entry_points.txt +3 -0
  29. linc_spectra-0.1.0/src/linc_spectra.egg-info/requires.txt +16 -0
  30. linc_spectra-0.1.0/src/linc_spectra.egg-info/top_level.txt +1 -0
  31. linc_spectra-0.1.0/tests/test_adapter_stderr.py +146 -0
  32. linc_spectra-0.1.0/tests/test_adb_subprocess.py +275 -0
  33. linc_spectra-0.1.0/tests/test_async_offload.py +205 -0
  34. linc_spectra-0.1.0/tests/test_bounded_waits.py +505 -0
  35. linc_spectra-0.1.0/tests/test_cli_doctor.py +653 -0
  36. linc_spectra-0.1.0/tests/test_cli_fuelcheck.py +164 -0
  37. linc_spectra-0.1.0/tests/test_contracts.py +365 -0
  38. linc_spectra-0.1.0/tests/test_dap_client.py +731 -0
  39. linc_spectra-0.1.0/tests/test_dap_client_failures.py +456 -0
  40. linc_spectra-0.1.0/tests/test_dap_event_store.py +468 -0
  41. linc_spectra-0.1.0/tests/test_dap_framing_bounds.py +335 -0
  42. linc_spectra-0.1.0/tests/test_frame_zero_and_adb_timeouts.py +137 -0
  43. linc_spectra-0.1.0/tests/test_input_validation.py +760 -0
  44. linc_spectra-0.1.0/tests/test_integration_device_pick.py +320 -0
  45. linc_spectra-0.1.0/tests/test_ios_subprocess.py +65 -0
  46. linc_spectra-0.1.0/tests/test_jdb_reader.py +568 -0
  47. linc_spectra-0.1.0/tests/test_jdb_registry.py +568 -0
  48. linc_spectra-0.1.0/tests/test_jdb_session.py +859 -0
  49. linc_spectra-0.1.0/tests/test_jdwp_bridge.py +356 -0
  50. linc_spectra-0.1.0/tests/test_jdwp_env_isolation.py +42 -0
  51. linc_spectra-0.1.0/tests/test_lldb_bridge.py +152 -0
  52. linc_spectra-0.1.0/tests/test_lldb_evaluate.py +158 -0
  53. linc_spectra-0.1.0/tests/test_logging.py +154 -0
  54. linc_spectra-0.1.0/tests/test_mcp_server.py +806 -0
  55. linc_spectra-0.1.0/tests/test_observability.py +871 -0
  56. linc_spectra-0.1.0/tests/test_observability_env_isolation.py +38 -0
  57. linc_spectra-0.1.0/tests/test_public_ci.py +129 -0
  58. linc_spectra-0.1.0/tests/test_public_docs.py +258 -0
  59. linc_spectra-0.1.0/tests/test_repo_manifests.py +59 -0
  60. linc_spectra-0.1.0/tests/test_session_manager.py +494 -0
  61. linc_spectra-0.1.0/tests/test_session_manager_failures.py +187 -0
  62. linc_spectra-0.1.0/tests/test_stdio_protocol.py +208 -0
  63. linc_spectra-0.1.0/tests/test_target_exit.py +272 -0
  64. linc_spectra-0.1.0/tests/test_tool_count.py +118 -0
  65. linc_spectra-0.1.0/tests/test_tool_docs_public.py +96 -0
  66. linc_spectra-0.1.0/tests/test_toolchain.py +359 -0
  67. linc_spectra-0.1.0/tests/test_usage_stats.py +152 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ LINC Spectra
2
+ Copyright 2026 LINC Innovations LLC
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: linc-spectra
3
+ Version: 0.1.0
4
+ Summary: AI-driven mobile debugging — spectral analysis of running apps
5
+ Author: LINC Innovations
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/LincForge/spectra
8
+ Project-URL: Source, https://github.com/LincForge/spectra
9
+ Project-URL: Issues, https://github.com/LincForge/spectra/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: >=3.13
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: NOTICE
18
+ Requires-Dist: pyyaml>=6.0
19
+ Requires-Dist: click>=8.1.7
20
+ Requires-Dist: rich>=13.7.0
21
+ Requires-Dist: mcp>=1.0.0
22
+ Requires-Dist: python-dateutil>=2.8.2
23
+ Requires-Dist: structlog>=25.0
24
+ Requires-Dist: linc-cli-kit>=0.1.4
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
29
+ Requires-Dist: ruff>=0.9; extra == "dev"
30
+ Requires-Dist: bandit>=1.7; extra == "dev"
31
+ Requires-Dist: mutmut<4,>=3.5; extra == "dev"
32
+ Requires-Dist: pre-commit>=4.0; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # linc-spectra
36
+
37
+ Attach a debugger to a running Android app (JDWP via `kotlin-debug-adapter`, or zero-config `jdb` by fully-qualified name with no sources) or iOS-simulator app (`lldb-dap`) and read what UI and logcat cannot show — locals at a method hit, exception frames — through <!-- SPECTRA:TOOL-COUNT -->14<!-- /SPECTRA:TOOL-COUNT --> MCP tools.
38
+
39
+ ## Install
40
+
41
+ **Prerequisites:** Python 3.13+ (stock macOS `python3` is older; `uv tool install linc-spectra` fetches its own Python 3.13 automatically, whereas running `pip` or `pip3` on an older interpreter fails with `No matching distribution found for linc-cli-kit`).
42
+
43
+ Install with [uv](https://docs.astral.sh/uv/), `pipx`, or `pip` (Python >= 3.13):
44
+
45
+ - `uv tool install linc-spectra`
46
+ - `pipx install linc-spectra`
47
+ - `pip install linc-spectra`
48
+
49
+ `uv tool install` places `spectra` (and `linc-spectra`) in `~/.local/bin`; a shell without `~/.local/bin` on `PATH` gets exit code `127` (`command not found`) — run `uv tool update-shell` and open a new shell (or add `~/.local/bin` to `PATH`).
50
+
51
+ Then check your environment with `uvx linc-spectra doctor` (or `spectra doctor` once installed):
52
+
53
+ - **What it checks:** `adb`, `kotlin-debug-adapter`, `jdb`, `lldb-dap` (macOS only), `xcrun` (macOS only), and `python` (>= 3.13). On macOS, `doctor` probes the `/usr/bin/jdb` and `/usr/bin/xcrun` stubs and reports them as failed until a JDK or Xcode / Command Line Tools is installed.
54
+ - **Exit codes:** exits `0` when at least one debugger lane is usable (Android: `adb` plus `kotlin-debug-adapter` or `jdb`; iOS on macOS: `xcrun` plus `lldb-dap`), or exits `1` with a `hint:` line for every failed check. Pass `--json` (`spectra doctor --json`) for a single `{ok, checks}` JSON object on stdout.
55
+
56
+ ## Adapters
57
+
58
+ - **Android — zero-config `jdb` lane:** requires `adb` (Android SDK `platform-tools`), a debuggable build (`android:debuggable="true"`), and `jdb` (ships with any JDK on `PATH`). Breaks on methods and exceptions by fully-qualified JVM name without local source files.
59
+ - **Android — full DAP lane:** requires `adb`, a debuggable build, local source files, and [`kotlin-debug-adapter`](https://github.com/fwcd/kotlin-debug-adapter). Unpack a release zip from [`fwcd/kotlin-debug-adapter`](https://github.com/fwcd/kotlin-debug-adapter/releases) so `adapter/bin/kotlin-debug-adapter` is on `PATH` or installed under `~/tools/kotlin-debug-adapter/` (`~/tools/kotlin-debug-adapter/adapter/bin/kotlin-debug-adapter`).
60
+ - **iOS — simulator lane (experimental):** requires macOS with Xcode's `lldb-dap` (checked on `PATH` first, then resolved via `xcrun -f lldb-dap`) and `xcrun`; `spectra doctor` reports the macOS `/usr/bin/jdb` and `/usr/bin/xcrun` stubs as failed until a JDK or Xcode is installed. Simulator only.
61
+
62
+ ## Finding your device id
63
+
64
+ - **Android (`device` / `device_serial`):** run `adb devices` and use the value in the first (serial) column (for example, `emulator-5554`).
65
+ - **iOS Simulator (`device` / `device_serial`):** run `xcrun simctl list devices booted` to find the booted simulator UDID, or pass the literal `booted`.
66
+
67
+ ## Quickstart
68
+
69
+ <!-- quickstart:start -->
70
+ Register the MCP server and run either the zero-config `jdb` flow (no local sources) or the full DAP flow:
71
+
72
+ ```bash
73
+ claude mcp add linc-spectra -- spectra bellows
74
+ # Or run directly without a global install:
75
+ claude mcp add linc-spectra -- uvx linc-spectra bellows
76
+
77
+ # Zero-config flow (Android jdb — no local source checkout needed):
78
+ # spectra_method_breakpoint(device="emulator-5554", package="com.example.app", method_fqn="com.example.app.AuthRepository.login")
79
+ # -> trigger the UI in the app
80
+ # -> spectra_method_locals(session_id="<session_id>")
81
+
82
+ # Full DAP flow (Android kotlin-debug-adapter or iOS lldb-dap):
83
+ # spectra_attach(device="emulator-5554", package="com.example.app", platform="android")
84
+ # -> spectra_breakpoint(session_id="<session_id>", source_path="/abs/path/AuthRepository.kt", lines="42")
85
+ # -> spectra_continue(session_id="<session_id>")
86
+ # -> spectra_stacktrace(session_id="<session_id>")
87
+ # -> spectra_variables(session_id="<session_id>", frame_id=0) # 0 = stopped thread's top frame, or an id from spectra_stacktrace
88
+ # -> spectra_detach(session_id="<session_id>")
89
+ ```
90
+ <!-- quickstart:end -->
91
+
92
+ ## MCP Tools (14)
93
+
94
+ linc-spectra exposes <!-- SPECTRA:TOOL-COUNT -->14<!-- /SPECTRA:TOOL-COUNT --> MCP tools grouped by workflow.
95
+
96
+ ### DAP Session
97
+
98
+ | Tool | Description |
99
+ |------|-------------|
100
+ | `spectra_attach` | Attach a DAP debugger to a running debuggable app (Android JDWP or iOS Simulator LLDB) |
101
+ | `spectra_detach` | Detach the debugger, remove port forwards, and clean up the session |
102
+ | `spectra_sessions` | List all active debug sessions |
103
+
104
+ ### Stepping
105
+
106
+ | Tool | Description |
107
+ |------|-------------|
108
+ | `spectra_breakpoint` | Set `file:line` breakpoints on local source files |
109
+ | `spectra_continue` | Resume execution and wait for the next breakpoint or stop event |
110
+ | `spectra_step` | Step `next` (over), `in` (into), or `out` (out of the current frame) |
111
+
112
+ ### Inspection
113
+
114
+ | Tool | Description |
115
+ |------|-------------|
116
+ | `spectra_stacktrace` | Get the call stack for the stopped thread |
117
+ | `spectra_variables` | Inspect local and scope variables at a stack frame |
118
+ | `spectra_evaluate` | Evaluate an expression in the current frame context (REPL at a breakpoint) |
119
+
120
+ ### Zero-Config jdb
121
+
122
+ | Tool | Description |
123
+ |------|-------------|
124
+ | `spectra_method_breakpoint` | Arm a zero-config breakpoint on a method by fully-qualified name (`<class>.<method>`) with no local sources |
125
+ | `spectra_method_locals` | Harvest captured local variables from an armed `spectra_method_breakpoint` hit |
126
+ | `spectra_exception_breakpoint` | Arm a zero-config exception catchpoint by fully-qualified exception class name |
127
+ | `spectra_exception_info` | Harvest the throwing frame, thread, and locals from an armed `spectra_exception_breakpoint` |
128
+
129
+ ### Analytics
130
+
131
+ | Tool | Description |
132
+ |------|-------------|
133
+ | `spectra_usage_stats` | Aggregate per-tool call counts, latency percentiles, and error rates from `$LINC_HOME/mcp-calls.jsonl` |
134
+
135
+ ## Limitations
136
+
137
+ - **Upstream `kotlin-debug-adapter` exception breakpoints do not work:** use `spectra_exception_breakpoint` (the `jdb` catchpoint) instead.
138
+ - **`file:line` breakpoints report `verified: true` even without local sources:** `kotlin-debug-adapter` marks non-existent paths as verified even though they can never bind; `spectra_breakpoint` attaches a `warning` field when `source_path` is missing locally (use `spectra_method_breakpoint` when you do not have the source checkout).
139
+ - **One debugger per process:** a target process exposes a single JDWP connection at a time — detach any active DAP session before arming a `jdb` session on the same app (and vice versa).
140
+ - **iOS simulator only:** iOS debugging via `lldb-dap` supports booted iOS simulators on macOS only (experimental; physical iOS devices are not supported).
141
+ - **iOS `spectra_evaluate` takes expressions only:** iOS expressions run in `lldb-dap`'s expression-only (`watch`) context and LLDB commands (such as backtick-prefixed commands) are refused.
142
+ - **`jdb` renders values as text:** a debuggee string containing line breaks can add a fake `name = value` line to a `jdb` reply (`spectra` keeps the first value of a name within a reply).
143
+ - **Bounded `jdb` waits and stepping:** `spectra_method_locals` and `spectra_exception_info` wait at most `180 s` (`wait_s` `0`–`180`), and manual stepping takes `max_steps` `0`–`16`.
144
+ - **Python >= 3.13:** requires Python 3.13 or newer.
145
+
146
+ ## Trust
147
+
148
+ - **No telemetry, no phone-home.** spectra runs locally over stdio MCP and opens no network listener; it talks only to your local `adb`, `jdb`, `kotlin-debug-adapter`, `xcrun`, and `lldb-dap` processes.
149
+ - **Local usage log under your control.** Every MCP tool call is recorded in `$LINC_HOME/mcp-calls.jsonl` (default `~/.linc/mcp-calls.jsonl`, rotated at 10 MB). Control logging with `SPECTRA_USAGE_LOG=off|redacted|full`:
150
+ - `redacted` (default) — sensitive fields (`expression` and `source_path`) are replaced by length-only placeholders (`<redacted len=N>`, no digest), expression text is scrubbed from recorded error strings, and the log file is opened owner-only (`0600`) with `O_NOFOLLOW`.
151
+ - `off` — nothing is written to disk.
152
+ - `full` — raw parameter values are logged (long strings truncated at 500 characters, byte buffers summarized by length). Opt in only on a machine you trust.
153
+ - **`spectra_evaluate` runs code inside the debuggee.** By design, `spectra_evaluate` and the `jdb` tools execute inside the attached debuggable application. Identifiers that reach `adb shell`, `xcrun simctl`, or `jdb` stdin are validated with strict `re.fullmatch` patterns before execution. See [SECURITY.md](https://github.com/LincForge/spectra/blob/main/SECURITY.md) for the threat model and vulnerability reporting instructions.
154
+
155
+ ## How this repo works
156
+
157
+ This repository is a **release mirror** of LINC's private repository — each release lands here as a single commit. Issues are welcome; pull requests are accepted by arrangement (open an issue first). See [CONTRIBUTING.md](https://github.com/LincForge/spectra/blob/main/CONTRIBUTING.md).
158
+
159
+ ---
160
+
161
+ Built by [LINC Innovations](https://lincinnovations.com/audit?utm_source=github&utm_medium=readme&utm_campaign=spectra). Licensed under [Apache-2.0](https://github.com/LincForge/spectra/blob/main/LICENSE).
@@ -0,0 +1,127 @@
1
+ # linc-spectra
2
+
3
+ Attach a debugger to a running Android app (JDWP via `kotlin-debug-adapter`, or zero-config `jdb` by fully-qualified name with no sources) or iOS-simulator app (`lldb-dap`) and read what UI and logcat cannot show — locals at a method hit, exception frames — through <!-- SPECTRA:TOOL-COUNT -->14<!-- /SPECTRA:TOOL-COUNT --> MCP tools.
4
+
5
+ ## Install
6
+
7
+ **Prerequisites:** Python 3.13+ (stock macOS `python3` is older; `uv tool install linc-spectra` fetches its own Python 3.13 automatically, whereas running `pip` or `pip3` on an older interpreter fails with `No matching distribution found for linc-cli-kit`).
8
+
9
+ Install with [uv](https://docs.astral.sh/uv/), `pipx`, or `pip` (Python >= 3.13):
10
+
11
+ - `uv tool install linc-spectra`
12
+ - `pipx install linc-spectra`
13
+ - `pip install linc-spectra`
14
+
15
+ `uv tool install` places `spectra` (and `linc-spectra`) in `~/.local/bin`; a shell without `~/.local/bin` on `PATH` gets exit code `127` (`command not found`) — run `uv tool update-shell` and open a new shell (or add `~/.local/bin` to `PATH`).
16
+
17
+ Then check your environment with `uvx linc-spectra doctor` (or `spectra doctor` once installed):
18
+
19
+ - **What it checks:** `adb`, `kotlin-debug-adapter`, `jdb`, `lldb-dap` (macOS only), `xcrun` (macOS only), and `python` (>= 3.13). On macOS, `doctor` probes the `/usr/bin/jdb` and `/usr/bin/xcrun` stubs and reports them as failed until a JDK or Xcode / Command Line Tools is installed.
20
+ - **Exit codes:** exits `0` when at least one debugger lane is usable (Android: `adb` plus `kotlin-debug-adapter` or `jdb`; iOS on macOS: `xcrun` plus `lldb-dap`), or exits `1` with a `hint:` line for every failed check. Pass `--json` (`spectra doctor --json`) for a single `{ok, checks}` JSON object on stdout.
21
+
22
+ ## Adapters
23
+
24
+ - **Android — zero-config `jdb` lane:** requires `adb` (Android SDK `platform-tools`), a debuggable build (`android:debuggable="true"`), and `jdb` (ships with any JDK on `PATH`). Breaks on methods and exceptions by fully-qualified JVM name without local source files.
25
+ - **Android — full DAP lane:** requires `adb`, a debuggable build, local source files, and [`kotlin-debug-adapter`](https://github.com/fwcd/kotlin-debug-adapter). Unpack a release zip from [`fwcd/kotlin-debug-adapter`](https://github.com/fwcd/kotlin-debug-adapter/releases) so `adapter/bin/kotlin-debug-adapter` is on `PATH` or installed under `~/tools/kotlin-debug-adapter/` (`~/tools/kotlin-debug-adapter/adapter/bin/kotlin-debug-adapter`).
26
+ - **iOS — simulator lane (experimental):** requires macOS with Xcode's `lldb-dap` (checked on `PATH` first, then resolved via `xcrun -f lldb-dap`) and `xcrun`; `spectra doctor` reports the macOS `/usr/bin/jdb` and `/usr/bin/xcrun` stubs as failed until a JDK or Xcode is installed. Simulator only.
27
+
28
+ ## Finding your device id
29
+
30
+ - **Android (`device` / `device_serial`):** run `adb devices` and use the value in the first (serial) column (for example, `emulator-5554`).
31
+ - **iOS Simulator (`device` / `device_serial`):** run `xcrun simctl list devices booted` to find the booted simulator UDID, or pass the literal `booted`.
32
+
33
+ ## Quickstart
34
+
35
+ <!-- quickstart:start -->
36
+ Register the MCP server and run either the zero-config `jdb` flow (no local sources) or the full DAP flow:
37
+
38
+ ```bash
39
+ claude mcp add linc-spectra -- spectra bellows
40
+ # Or run directly without a global install:
41
+ claude mcp add linc-spectra -- uvx linc-spectra bellows
42
+
43
+ # Zero-config flow (Android jdb — no local source checkout needed):
44
+ # spectra_method_breakpoint(device="emulator-5554", package="com.example.app", method_fqn="com.example.app.AuthRepository.login")
45
+ # -> trigger the UI in the app
46
+ # -> spectra_method_locals(session_id="<session_id>")
47
+
48
+ # Full DAP flow (Android kotlin-debug-adapter or iOS lldb-dap):
49
+ # spectra_attach(device="emulator-5554", package="com.example.app", platform="android")
50
+ # -> spectra_breakpoint(session_id="<session_id>", source_path="/abs/path/AuthRepository.kt", lines="42")
51
+ # -> spectra_continue(session_id="<session_id>")
52
+ # -> spectra_stacktrace(session_id="<session_id>")
53
+ # -> spectra_variables(session_id="<session_id>", frame_id=0) # 0 = stopped thread's top frame, or an id from spectra_stacktrace
54
+ # -> spectra_detach(session_id="<session_id>")
55
+ ```
56
+ <!-- quickstart:end -->
57
+
58
+ ## MCP Tools (14)
59
+
60
+ linc-spectra exposes <!-- SPECTRA:TOOL-COUNT -->14<!-- /SPECTRA:TOOL-COUNT --> MCP tools grouped by workflow.
61
+
62
+ ### DAP Session
63
+
64
+ | Tool | Description |
65
+ |------|-------------|
66
+ | `spectra_attach` | Attach a DAP debugger to a running debuggable app (Android JDWP or iOS Simulator LLDB) |
67
+ | `spectra_detach` | Detach the debugger, remove port forwards, and clean up the session |
68
+ | `spectra_sessions` | List all active debug sessions |
69
+
70
+ ### Stepping
71
+
72
+ | Tool | Description |
73
+ |------|-------------|
74
+ | `spectra_breakpoint` | Set `file:line` breakpoints on local source files |
75
+ | `spectra_continue` | Resume execution and wait for the next breakpoint or stop event |
76
+ | `spectra_step` | Step `next` (over), `in` (into), or `out` (out of the current frame) |
77
+
78
+ ### Inspection
79
+
80
+ | Tool | Description |
81
+ |------|-------------|
82
+ | `spectra_stacktrace` | Get the call stack for the stopped thread |
83
+ | `spectra_variables` | Inspect local and scope variables at a stack frame |
84
+ | `spectra_evaluate` | Evaluate an expression in the current frame context (REPL at a breakpoint) |
85
+
86
+ ### Zero-Config jdb
87
+
88
+ | Tool | Description |
89
+ |------|-------------|
90
+ | `spectra_method_breakpoint` | Arm a zero-config breakpoint on a method by fully-qualified name (`<class>.<method>`) with no local sources |
91
+ | `spectra_method_locals` | Harvest captured local variables from an armed `spectra_method_breakpoint` hit |
92
+ | `spectra_exception_breakpoint` | Arm a zero-config exception catchpoint by fully-qualified exception class name |
93
+ | `spectra_exception_info` | Harvest the throwing frame, thread, and locals from an armed `spectra_exception_breakpoint` |
94
+
95
+ ### Analytics
96
+
97
+ | Tool | Description |
98
+ |------|-------------|
99
+ | `spectra_usage_stats` | Aggregate per-tool call counts, latency percentiles, and error rates from `$LINC_HOME/mcp-calls.jsonl` |
100
+
101
+ ## Limitations
102
+
103
+ - **Upstream `kotlin-debug-adapter` exception breakpoints do not work:** use `spectra_exception_breakpoint` (the `jdb` catchpoint) instead.
104
+ - **`file:line` breakpoints report `verified: true` even without local sources:** `kotlin-debug-adapter` marks non-existent paths as verified even though they can never bind; `spectra_breakpoint` attaches a `warning` field when `source_path` is missing locally (use `spectra_method_breakpoint` when you do not have the source checkout).
105
+ - **One debugger per process:** a target process exposes a single JDWP connection at a time — detach any active DAP session before arming a `jdb` session on the same app (and vice versa).
106
+ - **iOS simulator only:** iOS debugging via `lldb-dap` supports booted iOS simulators on macOS only (experimental; physical iOS devices are not supported).
107
+ - **iOS `spectra_evaluate` takes expressions only:** iOS expressions run in `lldb-dap`'s expression-only (`watch`) context and LLDB commands (such as backtick-prefixed commands) are refused.
108
+ - **`jdb` renders values as text:** a debuggee string containing line breaks can add a fake `name = value` line to a `jdb` reply (`spectra` keeps the first value of a name within a reply).
109
+ - **Bounded `jdb` waits and stepping:** `spectra_method_locals` and `spectra_exception_info` wait at most `180 s` (`wait_s` `0`–`180`), and manual stepping takes `max_steps` `0`–`16`.
110
+ - **Python >= 3.13:** requires Python 3.13 or newer.
111
+
112
+ ## Trust
113
+
114
+ - **No telemetry, no phone-home.** spectra runs locally over stdio MCP and opens no network listener; it talks only to your local `adb`, `jdb`, `kotlin-debug-adapter`, `xcrun`, and `lldb-dap` processes.
115
+ - **Local usage log under your control.** Every MCP tool call is recorded in `$LINC_HOME/mcp-calls.jsonl` (default `~/.linc/mcp-calls.jsonl`, rotated at 10 MB). Control logging with `SPECTRA_USAGE_LOG=off|redacted|full`:
116
+ - `redacted` (default) — sensitive fields (`expression` and `source_path`) are replaced by length-only placeholders (`<redacted len=N>`, no digest), expression text is scrubbed from recorded error strings, and the log file is opened owner-only (`0600`) with `O_NOFOLLOW`.
117
+ - `off` — nothing is written to disk.
118
+ - `full` — raw parameter values are logged (long strings truncated at 500 characters, byte buffers summarized by length). Opt in only on a machine you trust.
119
+ - **`spectra_evaluate` runs code inside the debuggee.** By design, `spectra_evaluate` and the `jdb` tools execute inside the attached debuggable application. Identifiers that reach `adb shell`, `xcrun simctl`, or `jdb` stdin are validated with strict `re.fullmatch` patterns before execution. See [SECURITY.md](https://github.com/LincForge/spectra/blob/main/SECURITY.md) for the threat model and vulnerability reporting instructions.
120
+
121
+ ## How this repo works
122
+
123
+ This repository is a **release mirror** of LINC's private repository — each release lands here as a single commit. Issues are welcome; pull requests are accepted by arrangement (open an issue first). See [CONTRIBUTING.md](https://github.com/LincForge/spectra/blob/main/CONTRIBUTING.md).
124
+
125
+ ---
126
+
127
+ Built by [LINC Innovations](https://lincinnovations.com/audit?utm_source=github&utm_medium=readme&utm_campaign=spectra). Licensed under [Apache-2.0](https://github.com/LincForge/spectra/blob/main/LICENSE).
@@ -0,0 +1,113 @@
1
+ [project]
2
+ name = "linc-spectra"
3
+ version = "0.1.0"
4
+ description = "AI-driven mobile debugging — spectral analysis of running apps"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = [
8
+ "LICENSE",
9
+ "NOTICE",
10
+ ]
11
+ requires-python = ">=3.13"
12
+ authors = [
13
+ { name = "LINC Innovations" },
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.13",
20
+ ]
21
+ dependencies = [
22
+ "pyyaml>=6.0",
23
+ "click>=8.1.7",
24
+ "rich>=13.7.0",
25
+ "mcp>=1.0.0",
26
+ "python-dateutil>=2.8.2",
27
+ "structlog>=25.0",
28
+ "linc-cli-kit>=0.1.4",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/LincForge/spectra"
33
+ Source = "https://github.com/LincForge/spectra"
34
+ Issues = "https://github.com/LincForge/spectra/issues"
35
+
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=8.0",
39
+ "pytest-cov>=5.0",
40
+ "pytest-asyncio>=0.24",
41
+ "ruff>=0.9",
42
+ "bandit>=1.7",
43
+ "mutmut>=3.5,<4",
44
+ "pre-commit>=4.0",
45
+ ]
46
+
47
+ [project.scripts]
48
+ spectra = "linc_spectra.cli:main"
49
+ linc-spectra = "linc_spectra.cli:main"
50
+
51
+ [tool.setuptools.packages.find]
52
+ where = [
53
+ "src",
54
+ ]
55
+
56
+ [tool.ruff]
57
+ line-length = 99
58
+ target-version = "py313"
59
+
60
+ [tool.ruff.lint]
61
+ select = [
62
+ "E",
63
+ "F",
64
+ "I",
65
+ "UP",
66
+ "B",
67
+ "SIM",
68
+ "RUF",
69
+ ]
70
+ extend-select = [
71
+ "S101",
72
+ ]
73
+
74
+ [tool.ruff.lint.per-file-ignores]
75
+ "src/linc_spectra/mcp_server.py" = [
76
+ "E501",
77
+ "SIM115",
78
+ ]
79
+ "tests/**" = [
80
+ "S101",
81
+ ]
82
+ "**/test_*.py" = [
83
+ "S101",
84
+ ]
85
+ "**/*_test.py" = [
86
+ "S101",
87
+ ]
88
+ "**/conftest.py" = [
89
+ "S101",
90
+ ]
91
+ "**/testing.py" = [
92
+ "S101",
93
+ ]
94
+
95
+ [tool.ruff.lint.isort]
96
+ known-first-party = [
97
+ "linc_spectra",
98
+ ]
99
+
100
+ [tool.pytest.ini_options]
101
+ testpaths = [
102
+ "tests",
103
+ ]
104
+ markers = [
105
+ "integration: requires real devices (deselect with -m 'not integration')",
106
+ "device: touches a real device or simulator; deselected by the publish selfcheck",
107
+ ]
108
+
109
+ [build-system]
110
+ requires = [
111
+ "setuptools>=77.0",
112
+ ]
113
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ """Linc Spectra — AI-driven mobile debugging via DAP protocol."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+
6
+ def _resolve_version() -> str:
7
+ """Return the installed distribution version, or ``"0.0.0"`` when not installed."""
8
+ try:
9
+ return version("linc-spectra")
10
+ except PackageNotFoundError:
11
+ return "0.0.0"
12
+
13
+
14
+ __version__ = _resolve_version()
15
+ __author__ = "LINC"