candide 0.0.1__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.
- candide-0.0.1/.github/workflows/pypi.yaml +34 -0
- candide-0.0.1/.gitignore +6 -0
- candide-0.0.1/LICENSE +21 -0
- candide-0.0.1/PKG-INFO +70 -0
- candide-0.0.1/README.md +46 -0
- candide-0.0.1/docs/superpowers/plans/2026-11-30-first-slice.md +278 -0
- candide-0.0.1/docs/superpowers/specs/2026-11-30-candide-architecture-design.md +209 -0
- candide-0.0.1/pyproject.toml +47 -0
- candide-0.0.1/src/candide/__init__.py +3 -0
- candide-0.0.1/src/candide/__main__.py +21 -0
- candide-0.0.1/src/candide/app.py +44 -0
- candide-0.0.1/src/candide/core/__init__.py +0 -0
- candide-0.0.1/src/candide/core/code_model.py +88 -0
- candide-0.0.1/src/candide/core/commands.py +72 -0
- candide-0.0.1/src/candide/core/core.py +84 -0
- candide-0.0.1/src/candide/core/documents.py +108 -0
- candide-0.0.1/src/candide/core/facts.py +153 -0
- candide-0.0.1/src/candide/core/languages.py +44 -0
- candide-0.0.1/src/candide/core/location.py +39 -0
- candide-0.0.1/src/candide/core/panels.py +54 -0
- candide-0.0.1/src/candide/core/plugins.py +28 -0
- candide-0.0.1/src/candide/core/workspace.py +121 -0
- candide-0.0.1/src/candide/kernel.py +200 -0
- candide-0.0.1/src/candide/languages/python.toml +4 -0
- candide-0.0.1/src/candide/lsp/__init__.py +0 -0
- candide-0.0.1/src/candide/lsp/session.py +653 -0
- candide-0.0.1/src/candide/mcp_server.py +111 -0
- candide-0.0.1/src/candide/plugins/__init__.py +0 -0
- candide-0.0.1/src/candide/plugins/meson.py +87 -0
- candide-0.0.1/src/candide/plugins/python_lang.py +175 -0
- candide-0.0.1/tests/core/test_code_model.py +93 -0
- candide-0.0.1/tests/core/test_commands.py +92 -0
- candide-0.0.1/tests/core/test_core.py +150 -0
- candide-0.0.1/tests/core/test_documents.py +107 -0
- candide-0.0.1/tests/core/test_facts.py +185 -0
- candide-0.0.1/tests/core/test_languages.py +12 -0
- candide-0.0.1/tests/core/test_location.py +19 -0
- candide-0.0.1/tests/core/test_workspace.py +184 -0
- candide-0.0.1/tests/fixtures/meson_project/builddir/meson-info/intro-buildoptions.json +10 -0
- candide-0.0.1/tests/fixtures/meson_project/builddir/meson-info/intro-targets.json +20 -0
- candide-0.0.1/tests/fixtures/meson_project/builddir/meson-info/intro-tests.json +15 -0
- candide-0.0.1/tests/fixtures/meson_project/meson.build +8 -0
- candide-0.0.1/tests/lsp/test_session.py +706 -0
- candide-0.0.1/tests/plugins/test_meson.py +85 -0
- candide-0.0.1/tests/plugins/test_python_lang.py +226 -0
- candide-0.0.1/tests/test_app.py +36 -0
- candide-0.0.1/tests/test_kernel.py +112 -0
- candide-0.0.1/tests/test_mcp_server.py +149 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Publishes candide to PyPI through trusted publishing (no token): PyPI trusts this workflow, in
|
|
2
|
+
# this repository, by its file name. Runs on a version tag (v0.0.1) or by hand.
|
|
3
|
+
name: pypi
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags: ['v*']
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-24.04
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: '3.13'
|
|
18
|
+
- run: pip install build && python -m build
|
|
19
|
+
- uses: actions/upload-artifact@v4
|
|
20
|
+
with:
|
|
21
|
+
name: dist
|
|
22
|
+
path: dist/
|
|
23
|
+
|
|
24
|
+
publish:
|
|
25
|
+
needs: build
|
|
26
|
+
runs-on: ubuntu-24.04
|
|
27
|
+
permissions:
|
|
28
|
+
id-token: write # the OIDC token PyPI checks against the trusted publisher
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/download-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist
|
|
34
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
candide-0.0.1/.gitignore
ADDED
candide-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexis Jeandet
|
|
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.
|
candide-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: candide
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A code editor built on PRISM, where AI agents edit alongside you as peers.
|
|
5
|
+
Project-URL: Repository, https://github.com/PRISM-GUI/candide
|
|
6
|
+
Author: Alexis Jeandet
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Requires-Dist: basedpyright
|
|
11
|
+
Requires-Dist: duckdb>=2
|
|
12
|
+
Requires-Dist: ipython>=9
|
|
13
|
+
Requires-Dist: lsprotocol
|
|
14
|
+
Requires-Dist: mcp>=2
|
|
15
|
+
Requires-Dist: pandas>=2
|
|
16
|
+
Requires-Dist: prism-gui>=0.1.0
|
|
17
|
+
Requires-Dist: pydantic>=2
|
|
18
|
+
Requires-Dist: pygls>=2
|
|
19
|
+
Requires-Dist: watchfiles>=1
|
|
20
|
+
Provides-Extra: test
|
|
21
|
+
Requires-Dist: pytest; extra == 'test'
|
|
22
|
+
Requires-Dist: pytest-timeout; extra == 'test'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# Candide
|
|
26
|
+
|
|
27
|
+
A code editor built on [PRISM](https://github.com/PRISM-GUI/PRISM), where AI agents edit alongside
|
|
28
|
+
you as peers.
|
|
29
|
+
|
|
30
|
+
> *Il faut cultiver notre jardin.* -- Voltaire, *Candide*
|
|
31
|
+
|
|
32
|
+
## The name
|
|
33
|
+
|
|
34
|
+
The IDE is in the word: cand-IDE. In Voltaire's novel, Candide is the optimist who is taught that
|
|
35
|
+
all is for the best in the best of all possible worlds. An AI agent reporting that everything went
|
|
36
|
+
well is that kind of optimism, so Candide shows you exactly what the agent changed, and you decide.
|
|
37
|
+
The book ends with "we must tend our garden": your code is your garden.
|
|
38
|
+
|
|
39
|
+
## What it aims to be
|
|
40
|
+
|
|
41
|
+
- **Agents are peers.** An agent edits the same shared document as you, through
|
|
42
|
+
[ycpp](https://github.com/PRISM-GUI/ycpp), PRISM's Yjs-compatible CRDT. Its edits show as
|
|
43
|
+
tracked changes you accept or reject, and you both keep typing meanwhile.
|
|
44
|
+
- **Co-editing.** People join the same document over the same protocol, and any Yjs client can too.
|
|
45
|
+
- **Desktop and browser.** The same app runs natively and in a web page through Pyodide. Every
|
|
46
|
+
integration (language servers, git, agents) sits behind a small interface with a desktop and a
|
|
47
|
+
browser version; peers meet over the network either way.
|
|
48
|
+
- **Useful features, kept simple.** Python decides what happens; PRISM's C++ does the heavy work
|
|
49
|
+
(the text buffer, layout, drawing, merging). Language servers, git, tree-sitter and AI SDKs come
|
|
50
|
+
from Python packages instead of being rewritten.
|
|
51
|
+
|
|
52
|
+
## Status
|
|
53
|
+
|
|
54
|
+
A first window: `candide FILE` opens one file in a code editor with syntax highlighting, and Ctrl+S
|
|
55
|
+
saves it.
|
|
56
|
+
|
|
57
|
+
## Run it
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
pip install candide # or: uv tool install candide
|
|
61
|
+
candide hello.py
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
PRISM comes as a dependency (`prism-gui` on PyPI, wheels for Linux and macOS). To work on Candide
|
|
65
|
+
against a local PRISM build instead: `pip install -e . --no-deps`, then run with
|
|
66
|
+
`PYTHONPATH=/path/to/PRISM/builddir/python`. Tests: `python -m pytest`.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT
|
candide-0.0.1/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Candide
|
|
2
|
+
|
|
3
|
+
A code editor built on [PRISM](https://github.com/PRISM-GUI/PRISM), where AI agents edit alongside
|
|
4
|
+
you as peers.
|
|
5
|
+
|
|
6
|
+
> *Il faut cultiver notre jardin.* -- Voltaire, *Candide*
|
|
7
|
+
|
|
8
|
+
## The name
|
|
9
|
+
|
|
10
|
+
The IDE is in the word: cand-IDE. In Voltaire's novel, Candide is the optimist who is taught that
|
|
11
|
+
all is for the best in the best of all possible worlds. An AI agent reporting that everything went
|
|
12
|
+
well is that kind of optimism, so Candide shows you exactly what the agent changed, and you decide.
|
|
13
|
+
The book ends with "we must tend our garden": your code is your garden.
|
|
14
|
+
|
|
15
|
+
## What it aims to be
|
|
16
|
+
|
|
17
|
+
- **Agents are peers.** An agent edits the same shared document as you, through
|
|
18
|
+
[ycpp](https://github.com/PRISM-GUI/ycpp), PRISM's Yjs-compatible CRDT. Its edits show as
|
|
19
|
+
tracked changes you accept or reject, and you both keep typing meanwhile.
|
|
20
|
+
- **Co-editing.** People join the same document over the same protocol, and any Yjs client can too.
|
|
21
|
+
- **Desktop and browser.** The same app runs natively and in a web page through Pyodide. Every
|
|
22
|
+
integration (language servers, git, agents) sits behind a small interface with a desktop and a
|
|
23
|
+
browser version; peers meet over the network either way.
|
|
24
|
+
- **Useful features, kept simple.** Python decides what happens; PRISM's C++ does the heavy work
|
|
25
|
+
(the text buffer, layout, drawing, merging). Language servers, git, tree-sitter and AI SDKs come
|
|
26
|
+
from Python packages instead of being rewritten.
|
|
27
|
+
|
|
28
|
+
## Status
|
|
29
|
+
|
|
30
|
+
A first window: `candide FILE` opens one file in a code editor with syntax highlighting, and Ctrl+S
|
|
31
|
+
saves it.
|
|
32
|
+
|
|
33
|
+
## Run it
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
pip install candide # or: uv tool install candide
|
|
37
|
+
candide hello.py
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
PRISM comes as a dependency (`prism-gui` on PyPI, wheels for Linux and macOS). To work on Candide
|
|
41
|
+
against a local PRISM build instead: `pip install -e . --no-deps`, then run with
|
|
42
|
+
`PYTHONPATH=/path/to/PRISM/builddir/python`. Tests: `python -m pytest`.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Candide first slice Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** The core of five nouns plus the command registry, a Meson plugin and a Python language
|
|
6
|
+
plugin over a language server, so that Candide shows diagnostics, jumps to definitions, hovers and
|
|
7
|
+
completes in Python files, and the same commands answer the palette, a Jupyter kernel and agents over MCP.
|
|
8
|
+
|
|
9
|
+
**Architecture:** Plain Python services (`Workspace`, `Documents`, `CodeModel`, `Facts`, `Panels`,
|
|
10
|
+
`Commands`) gathered in one `Core`; features are plugins found through the `candide.plugins` entry
|
|
11
|
+
point group. Everything below the UI is headless and tested without PRISM; the UI tasks at the end
|
|
12
|
+
consume PRISM APIs listed under "Needs from PRISM", built in a separate PRISM plan.
|
|
13
|
+
|
|
14
|
+
**Tech Stack:** Python >= 3.11, PRISM (`prism-gui`, `import prism`), duckdb, pydantic 2, pygls 2
|
|
15
|
+
(its `LanguageClient`) with lsprotocol, basedpyright (the Python language server), mcp (FastMCP,
|
|
16
|
+
streamable HTTP), IPython (an in-process shell on its own thread, JupyQt's pattern), watchfiles, pytest.
|
|
17
|
+
|
|
18
|
+
**Spec:** `docs/superpowers/specs/2026-11-30-candide-architecture-design.md`
|
|
19
|
+
|
|
20
|
+
## Global Constraints
|
|
21
|
+
|
|
22
|
+
- Python >= 3.11. Dependencies go in `pyproject.toml` `[project.dependencies]`; test-only ones in the `test` extra.
|
|
23
|
+
- Plugins never import each other; they meet through `Core`.
|
|
24
|
+
- A location is a workspace-relative POSIX path plus a range in lines and UTF-16 columns (LSP's convention), 0-based.
|
|
25
|
+
- Facts carry the document version they were computed on.
|
|
26
|
+
- Every command is a typed function; read-only commands are open to agents, mutating ones are refused over MCP in this slice.
|
|
27
|
+
- No subprocess for anything Meson already writes to disk: read `meson-info/*.json`.
|
|
28
|
+
- Language bundles are TOML data files in `src/candide/languages/`.
|
|
29
|
+
- Desktop only. Run the tests with `python -m pytest`; the UI tasks need a PRISM build on `PYTHONPATH`.
|
|
30
|
+
|
|
31
|
+
## Review Focus
|
|
32
|
+
|
|
33
|
+
1. A line with characters outside the BMP (an emoji) or non-ASCII: positions convert between PRISM's bytes and LSP's UTF-16 without drift. → Task 1.
|
|
34
|
+
2. The language server is missing or dies: Candide keeps editing, says so once, and restarts the server on the next open. → Task 8.
|
|
35
|
+
3. Diagnostics for an older version arrive after a newer edit: they are kept with their version, and the view can tell them stale. → Tasks 2 and 9.
|
|
36
|
+
4. An agent sends SQL that writes (`DROP TABLE facts`): refused, the facts intact. → Task 2 (and Task 11 over MCP).
|
|
37
|
+
5. A Meson project with no build folder yet, or a stale one: the workspace still opens, with no active build folder. → Task 6.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### Task 1: Package skeleton, locations and position conversion
|
|
42
|
+
|
|
43
|
+
**Files:**
|
|
44
|
+
- Modify: `pyproject.toml` (dependencies: `duckdb>=2`, `pydantic>=2`, `pygls>=2`, `lsprotocol`, `basedpyright`, `mcp>=2`, `ipython>=9`, `watchfiles>=1`; test extra: `pytest`, `pytest-timeout`)
|
|
45
|
+
- Create: `src/candide/core/__init__.py`, `src/candide/core/location.py`
|
|
46
|
+
- Test: `tests/core/test_location.py`
|
|
47
|
+
|
|
48
|
+
**Interfaces:**
|
|
49
|
+
- Produces: `Position(line: int, character: int)` and `Range(start: Position, end: Position)` (frozen dataclasses, UTF-16 characters); `Location(path: str, range: Range)`; `utf16_to_byte(line_text: str, character: int) -> int`; `byte_to_utf16(line_text: str, byte: int) -> int` (byte = UTF-8 offset, as PRISM's `{block, byte}` positions).
|
|
50
|
+
|
|
51
|
+
- [ ] **Step 1: Write the failing tests**
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
def test_ascii_is_the_same_both_ways():
|
|
55
|
+
assert utf16_to_byte("hello", 3) == 3 and byte_to_utf16("hello", 3) == 3
|
|
56
|
+
|
|
57
|
+
def test_emoji_counts_two_utf16_units_and_four_bytes():
|
|
58
|
+
line = "a😀b"
|
|
59
|
+
assert utf16_to_byte(line, 3) == 5 # after the emoji
|
|
60
|
+
assert byte_to_utf16(line, 5) == 3
|
|
61
|
+
|
|
62
|
+
def test_accented_letter_is_one_unit_two_bytes():
|
|
63
|
+
assert utf16_to_byte("é=1", 1) == 2 and byte_to_utf16("é=1", 2) == 1
|
|
64
|
+
|
|
65
|
+
def test_positions_past_the_end_clamp_to_the_line_end():
|
|
66
|
+
assert utf16_to_byte("ab", 10) == 2 and byte_to_utf16("ab", 10) == 2
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- [ ] **Step 2: Run them to see them fail** — `python -m pytest tests/core/test_location.py -v`: import error.
|
|
70
|
+
- [ ] **Step 3: Implement** the dataclasses and the two functions in `location.py` (walk the string by code point; a code point above U+FFFF is 2 units).
|
|
71
|
+
- [ ] **Step 4: Run them to see them pass.**
|
|
72
|
+
- [ ] **Step 5: Commit** — `feat(core): locations, and positions between PRISM bytes and LSP UTF-16`
|
|
73
|
+
|
|
74
|
+
### Task 2: Facts in DuckDB
|
|
75
|
+
|
|
76
|
+
**Files:**
|
|
77
|
+
- Create: `src/candide/core/facts.py`
|
|
78
|
+
- Test: `tests/core/test_facts.py`
|
|
79
|
+
|
|
80
|
+
**Interfaces:**
|
|
81
|
+
- Consumes: `Location`, `Range`, `Position` (Task 1).
|
|
82
|
+
- Produces: `Fact(kind: str, location: Location, source: str, version: int | None, message: str = "", value: float | None = None, data: dict | None = None)`; `class Facts` with `__init__(self, path: pathlib.Path | None)` (None: in memory), `replace(self, source: str, path: str, facts: list[Fact]) -> None` (drops that source's facts for that file, inserts the new ones, then notifies), `of(self, path: str, kind: str | None = None) -> list[Fact]`, `query(self, sql: str) -> list[dict]` (read-only), `to_pandas(self, sql: str)`, `observe(self, callback: Callable[[str], None]) -> Callable[[], None]` (called with the changed path; returns an unsubscribe).
|
|
83
|
+
- One table `facts(kind, path, start_line, start_char, end_line, end_char, source, version, message, value DOUBLE, data JSON)`.
|
|
84
|
+
|
|
85
|
+
- [ ] **Step 1: Write the failing tests**
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
def test_replace_swaps_one_sources_facts_for_one_file(tmp_path): ...
|
|
89
|
+
# two sources on a.py, one on b.py; replace("lsp", "a.py", [new]) leaves the other source and b.py
|
|
90
|
+
def test_facts_keep_their_version(): ... # of("a.py")[0].version == 7
|
|
91
|
+
def test_query_returns_rows_as_dicts(): ... # query("select count(*) as n from facts") == [{"n": 2}]
|
|
92
|
+
def test_query_refuses_writes():
|
|
93
|
+
with pytest.raises(PermissionError):
|
|
94
|
+
facts.query("DROP TABLE facts")
|
|
95
|
+
assert facts.of("a.py") # still there
|
|
96
|
+
def test_observers_hear_the_changed_path(): ...
|
|
97
|
+
def test_facts_survive_a_reopen(tmp_path): ... # Facts(tmp_path/"f.duckdb") written, closed, reopened
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- [ ] **Step 2: Run them to see them fail.**
|
|
101
|
+
- [ ] **Step 3: Implement.** Reads go through a second connection opened `read_only=True` on file databases; for the in-memory one, accept only statements DuckDB classifies as SELECT (`duckdb` `extract_statements` + `StatementType.SELECT`), else `PermissionError`. Do both checks for file databases.
|
|
102
|
+
- [ ] **Step 4: Run them to see them pass.**
|
|
103
|
+
- [ ] **Step 5: Commit** — `feat(core): facts in DuckDB, read-only queries`
|
|
104
|
+
|
|
105
|
+
### Task 3: The command registry
|
|
106
|
+
|
|
107
|
+
**Files:**
|
|
108
|
+
- Create: `src/candide/core/commands.py`
|
|
109
|
+
- Test: `tests/core/test_commands.py`
|
|
110
|
+
|
|
111
|
+
**Interfaces:**
|
|
112
|
+
- Produces: `class Commands` with `command(self, name: str, *, mutating: bool = False)` (decorator; the function's type hints define its arguments), `run(self, name: str, **args) -> Any` (validates args with a pydantic model built from the signature), `list(self) -> list[CommandInfo]`, `CommandInfo(name: str, doc: str, mutating: bool, schema: dict)` (`schema`: the JSON schema of the arguments, from `pydantic.create_model`).
|
|
113
|
+
|
|
114
|
+
- [ ] **Step 1: Write the failing tests**
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
def test_a_registered_command_runs_with_validated_arguments():
|
|
118
|
+
@commands.command("demo.add")
|
|
119
|
+
def add(a: int, b: int = 1) -> int:
|
|
120
|
+
"""Adds."""
|
|
121
|
+
return a + b
|
|
122
|
+
assert commands.run("demo.add", a="2") == 3 # coerced by pydantic
|
|
123
|
+
def test_bad_arguments_raise_a_validation_error(): ... # run("demo.add", a="x") -> pydantic.ValidationError
|
|
124
|
+
def test_list_gives_name_doc_mutating_and_schema(): ... # schema["properties"]["a"]["type"] == "integer"
|
|
125
|
+
def test_unknown_command_raises_key_error(): ...
|
|
126
|
+
def test_a_name_registered_twice_is_refused(): ... # ValueError
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(core): the command registry`
|
|
130
|
+
|
|
131
|
+
### Task 4: Core, plugins and documents
|
|
132
|
+
|
|
133
|
+
**Files:**
|
|
134
|
+
- Create: `src/candide/core/core.py`, `src/candide/core/documents.py`, `src/candide/core/panels.py`, `src/candide/core/code_model.py`, `src/candide/core/plugins.py`
|
|
135
|
+
- Modify: `pyproject.toml` (`[project.entry-points."candide.plugins"]` gets the slice's plugins as they land)
|
|
136
|
+
- Test: `tests/core/test_core.py`, `tests/core/test_documents.py`, `tests/core/test_code_model.py`
|
|
137
|
+
|
|
138
|
+
**Interfaces:**
|
|
139
|
+
- Produces:
|
|
140
|
+
- `Document(path: str, language: str, text: str, version: int)`; `class Documents` with `open(self, path: str) -> Document` (reads the file, language from the bundles' patterns, version 0), `change(self, path: str, text: str) -> Document` (version + 1), `close(self, path: str)`, `get(self, path: str) -> Document | None`, `observe(self, callback: Callable[[str, Document | None], None])` (event: `"open" | "change" | "close"`).
|
|
141
|
+
- `class CodeModel` with `add_provider(self, language: str, provider: CodeProvider)`, and `definition(self, loc: Location) -> list[Location]`, `hover(self, loc: Location) -> str | None`, `completions(self, loc: Location) -> list[Completion]` that ask the provider of the document's language (none: empty). `CodeProvider` is a `typing.Protocol` with those three methods. `Completion(label: str, insert: str = "", detail: str = "")` (PRISM's `text::Completion` fields).
|
|
142
|
+
- `class Panels`: dock panels, as PRISM's `vb.dock` takes them. `add(self, name: str, title: str, build: Callable[[object], None], area: str = "right")` (`build(vb)` fills the panel; `area` in `"left" | "center" | "right" | "bottom"` places it in the default layout), `entries(self) -> list[tuple[str, str, Callable]]` (for `vb.dock`), `default_layout(self)` (a `prism.dock_split` of `prism.dock_group`s by area: left, center, right side by side, bottom under them; built only when `prism` imports). A name added twice raises `ValueError`.
|
|
143
|
+
- `Core(workspace, documents, code_model, facts, panels, commands, languages)`; `load_plugins(core: Core, names: list[str] | None = None) -> list[str]` (entry point group `candide.plugins`; each entry point is a callable `activate(core: Core) -> None`; a plugin that raises is skipped and reported, the others load).
|
|
144
|
+
- Consumes: `Facts` (2), `Commands` (3), `Workspace` (5) and `Languages` (7) are injected; for this task's tests use `Workspace(tmp_path)` and a `Languages` with only the Python bundle once Tasks 5 and 7 exist, or stand-ins before.
|
|
145
|
+
|
|
146
|
+
- [ ] **Step 1: Write the failing tests** — `test_change_bumps_the_version`, `test_observers_hear_open_change_close`, `test_code_model_asks_the_provider_of_the_documents_language`, `test_no_provider_gives_empty_answers`, `test_a_failing_plugin_does_not_stop_the_others` (register two fake entry points with `importlib.metadata` monkeypatched).
|
|
147
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(core): Core, documents, code model, panels, plugin loading`
|
|
148
|
+
|
|
149
|
+
### Task 5: The workspace
|
|
150
|
+
|
|
151
|
+
**Files:**
|
|
152
|
+
- Create: `src/candide/core/workspace.py`
|
|
153
|
+
- Test: `tests/core/test_workspace.py`
|
|
154
|
+
|
|
155
|
+
**Interfaces:**
|
|
156
|
+
- Produces: `class Workspace` with `__init__(self, root: pathlib.Path)`, `files(self) -> list[str]` (relative POSIX paths, sorted; skips `.git`, `__pycache__`, `.venv`, and any folder containing `meson-info/`), `watch(self) -> None` / `stop(self)` (a `watchfiles` thread), `observe(self, callback: Callable[[set[str]], None])` (changed relative paths), `build_systems: list[BuildSystem]`, `active_build: BuildFolder | None`, `set_active_build(self, folder: BuildFolder | None)`, `observe_build(self, callback)`. `BuildSystem` Protocol: `name: str`, `folders(self) -> list[BuildFolder]`; `BuildFolder(path: pathlib.Path, name: str, compile_commands: pathlib.Path | None, python_paths: list[pathlib.Path])`.
|
|
157
|
+
|
|
158
|
+
- [ ] **Step 1: Write the failing tests** — `test_files_skip_vcs_caches_and_build_folders`, `test_a_new_file_is_reported_by_watch` (`pytest.mark.timeout(10)`), `test_active_build_starts_empty_and_notifies_on_change`.
|
|
159
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(core): the workspace and build folders`
|
|
160
|
+
|
|
161
|
+
### Task 6: The Meson plugin
|
|
162
|
+
|
|
163
|
+
**Files:**
|
|
164
|
+
- Create: `src/candide/plugins/meson.py`
|
|
165
|
+
- Create: `tests/fixtures/meson_project/` (a `meson.build`, and `build/meson-info/` with hand-written `intro-targets.json`, `intro-tests.json`, `intro-buildoptions.json` holding one executable, one Python extension module whose output is `build/python/_ext.cpython-312-x86_64-linux-gnu.so`, and one test)
|
|
166
|
+
- Test: `tests/plugins/test_meson.py`
|
|
167
|
+
|
|
168
|
+
**Interfaces:**
|
|
169
|
+
- Consumes: `Workspace`, `BuildSystem`, `BuildFolder` (5), `Commands` (3).
|
|
170
|
+
- Produces: `activate(core)`: when `meson.build` is at the root, adds a `MesonBuild` to `core.workspace.build_systems` and makes the first folder active (by name, `builddir` first). `MesonBuild.folders()` reads `<folder>/meson-info/*.json` for every direct child folder holding `meson-info/`; `python_paths` = the output folders of targets whose `type` is `"shared module"` with a Python extension suffix; `compile_commands` = `<folder>/compile_commands.json` if present. Command `meson.tests() -> list[str]` (read-only).
|
|
171
|
+
|
|
172
|
+
- [ ] **Step 1: Write the failing tests** — `test_finds_the_build_folder_and_its_python_path`, `test_lists_tests`, `test_a_project_with_no_build_folder_has_none_active` (copy the fixture without `build/`), `test_a_broken_intro_file_is_skipped_not_fatal`.
|
|
173
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(meson): build folders, Python paths and tests from meson-info`
|
|
174
|
+
|
|
175
|
+
### Task 7: Language bundles
|
|
176
|
+
|
|
177
|
+
**Files:**
|
|
178
|
+
- Create: `src/candide/core/languages.py`, `src/candide/languages/python.toml`
|
|
179
|
+
- Test: `tests/core/test_languages.py`
|
|
180
|
+
|
|
181
|
+
**Interfaces:**
|
|
182
|
+
- Produces: `Language(name: str, patterns: list[str], highlight: str, server: list[str] | None, server_settings: dict)` and `class Languages` with `load_builtin(cls) -> Languages` (every `*.toml` in `candide/languages`), `for_path(self, path: str) -> Language | None` (fnmatch on the file name).
|
|
183
|
+
- `python.toml`: `name = "python"`, `patterns = ["*.py", "*.pyi"]`, `highlight = "python"`, `server = ["basedpyright-langserver", "--stdio"]`.
|
|
184
|
+
|
|
185
|
+
- [ ] **Steps 1-5:** tests `test_python_files_map_to_python`, `test_unknown_files_map_to_none`; fail, implement, pass, commit — `feat(core): language bundles as TOML`
|
|
186
|
+
|
|
187
|
+
### Task 8: The LSP client
|
|
188
|
+
|
|
189
|
+
**Files:**
|
|
190
|
+
- Create: `src/candide/lsp/__init__.py`, `src/candide/lsp/session.py`
|
|
191
|
+
- Test: `tests/lsp/test_session.py` (needs `basedpyright-langserver` on PATH; `pytest.mark.timeout(60)`)
|
|
192
|
+
|
|
193
|
+
**Interfaces:**
|
|
194
|
+
- Consumes: `Location`, `Range`, `Position` (1), `Completion` (4).
|
|
195
|
+
- Produces: `class LspSession` with `__init__(self, command: list[str], root: pathlib.Path, settings: dict, on_diagnostics: Callable[[str, int | None, list[Diagnostic]], None], on_status: Callable[[str], None])`; `start(self)` (pygls `LanguageClient` on its own thread with its own asyncio loop; `initialize` with the root URI and `settings` as `initializationOptions` and `workspace/configuration` answers), `stop(self)`; `open(self, path, language, text, version)`, `change(self, path, text, version)` (full-text sync), `close(self, path)`; and blocking calls with a timeout: `definition(self, loc) -> list[Location]`, `hover(self, loc) -> str | None`, `completions(self, loc) -> list[Completion]`. `Diagnostic(range: Range, severity: str, message: str)` with `severity` in `"error" | "warning" | "info" | "hint"`. A server that is missing or exits: `on_status("python language server unavailable: <reason>")` once, calls return empty, and the next `open` tries a restart.
|
|
196
|
+
|
|
197
|
+
- [ ] **Step 1: Write the failing tests** (a tmp project with `a.py` = `x: int = "a"\ndef f():\n return 1\nf()\n`):
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
def test_diagnostics_arrive_for_a_type_error(): ... # one "error" on line 0, version 0
|
|
201
|
+
def test_definition_of_a_call_points_at_the_def(): ... # loc of "f" on line 3 -> line 1
|
|
202
|
+
def test_hover_names_the_function(): ... # "def f()" in the hover text
|
|
203
|
+
def test_completions_include_a_local_name(): ... # "f" among labels after typing "f" on a new line
|
|
204
|
+
def test_a_missing_server_reports_once_and_answers_empty(): ... # command ["no-such-server"]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(lsp): a language server session on its own thread`
|
|
208
|
+
|
|
209
|
+
### Task 9: The Python language plugin
|
|
210
|
+
|
|
211
|
+
**Files:**
|
|
212
|
+
- Create: `src/candide/plugins/python_lang.py`
|
|
213
|
+
- Test: `tests/plugins/test_python_lang.py` (needs basedpyright; timeout 60)
|
|
214
|
+
|
|
215
|
+
**Interfaces:**
|
|
216
|
+
- Consumes: `Core` and its services (4, 5, 7), `LspSession` (8), `Facts.replace` (2).
|
|
217
|
+
- Produces: `activate(core)`: one `LspSession` per workspace for Python, started lazily on the first Python document; forwards `Documents` open/change/close; writes diagnostics as facts (`kind="diagnostic"`, `source="lsp:python"`, `version` from the server, `message`, `data={"severity": ...}`) through `Facts.replace`; registers itself as the `CodeModel` provider for `"python"`; passes the active build folder's `python_paths` as basedpyright's `python.analysis.extraPaths`, and restarts the session when the active build folder changes. Commands: `diagnostics.list(path: str | None = None) -> list[dict]` (read-only), `facts.query(sql: str) -> list[dict]` (read-only).
|
|
218
|
+
|
|
219
|
+
- [ ] **Step 1: Write the failing tests** — `test_opening_a_file_fills_diagnostic_facts`, `test_an_edit_replaces_them_with_the_new_versions`, `test_definition_goes_through_the_code_model`, `test_extra_paths_follow_the_active_build_folder` (a fixture module in a fake build folder's python path resolves: no "import could not be resolved" diagnostic).
|
|
220
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(python): diagnostics as facts, definitions, hover, completion`
|
|
221
|
+
|
|
222
|
+
### Task 10: The kernel
|
|
223
|
+
|
|
224
|
+
The pattern JupyQt proved in SciQLop (https://github.com/SciQLop/jupyqt, `src/jupyqt/kernel/thread.py`
|
|
225
|
+
and `shell.py`): no ipykernel, no ZMQ. An `InteractiveShell` subclass lives on its own thread with an
|
|
226
|
+
asyncio loop; everything reaches it through that thread; an interrupt is an async exception raised
|
|
227
|
+
in the thread with `ctypes.pythonapi.PyThreadState_SetAsyncExc`. Read those two files first and
|
|
228
|
+
follow them. (jupyqt itself requires PySide6, so Candide copies the pattern instead of depending on it.)
|
|
229
|
+
|
|
230
|
+
**Files:**
|
|
231
|
+
- Create: `src/candide/kernel.py`
|
|
232
|
+
- Test: `tests/test_kernel.py` (timeout 30)
|
|
233
|
+
|
|
234
|
+
**Interfaces:**
|
|
235
|
+
- Consumes: `Core`.
|
|
236
|
+
- Produces: `class Kernel` with `__init__(self, core: Core)` (creates the shell on the calling thread, so magics and completers register there, with `core` and `run = core.commands.run` in its namespace; `enable_gui` is a no-op), `start(self)`, `stop(self)`, `execute(self, code: str, timeout: float | None = None) -> CellResult` (runs on the kernel thread; `CellResult(stdout: str, stderr: str, result: str | None, error: str | None)`), `complete(self, code: str, cursor: int) -> list[str]`, `interrupt(self)`. The console panel (Task 12) talks to it directly; attaching an outside Jupyter front end is out of this slice.
|
|
237
|
+
|
|
238
|
+
- [ ] **Step 1: Write the failing tests** — `test_a_cell_runs_a_command` (`execute("run('demo.add', a=2)").result == "3"`), `test_output_is_captured` (`print('hi')` → stdout `"hi\n"`), `test_an_error_is_reported_not_raised` (`1/0` → `error` mentions ZeroDivisionError), `test_interrupt_stops_a_long_cell` (`while True: pass` interrupted within 2 s, then `execute("1+1").result == "2"`), `test_completion_offers_core` (`"co"` → `"core"` among results).
|
|
239
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(kernel): an IPython shell on its own thread, JupyQt's pattern`
|
|
240
|
+
|
|
241
|
+
### Task 11: The MCP server
|
|
242
|
+
|
|
243
|
+
**Files:**
|
|
244
|
+
- Create: `src/candide/mcp_server.py`
|
|
245
|
+
- Test: `tests/test_mcp_server.py`
|
|
246
|
+
|
|
247
|
+
**Interfaces:**
|
|
248
|
+
- Consumes: `Commands.list`, `Commands.run` (3).
|
|
249
|
+
- Produces: `start_mcp(core: Core, port: int = 0) -> str` (FastMCP over streamable HTTP on 127.0.0.1, its own thread; returns the URL, e.g. `http://127.0.0.1:43211/mcp`). Every command becomes a tool with its schema. A mutating command answers "refused: needs the user's approval" without running.
|
|
250
|
+
|
|
251
|
+
- [ ] **Step 1: Write the failing tests** with the `mcp` client: `test_tools_list_the_commands`, `test_a_read_only_tool_runs`, `test_a_mutating_tool_is_refused`, `test_facts_query_refuses_writes_over_mcp` (`DROP TABLE facts` comes back as an error, the facts intact).
|
|
252
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(mcp): the command registry as MCP tools`
|
|
253
|
+
|
|
254
|
+
### Task 12: The window (needs PRISM, see below)
|
|
255
|
+
|
|
256
|
+
**Files:**
|
|
257
|
+
- Modify: `src/candide/app.py`, `src/candide/__main__.py` (`candide [FOLDER]`, default `.`; starts the core, plugins, kernel and MCP server, prints the MCP URL)
|
|
258
|
+
- Test: `tests/test_app.py` (headless PRISM; skipped without `prism`)
|
|
259
|
+
|
|
260
|
+
**Interfaces:**
|
|
261
|
+
- Consumes: everything above, and from PRISM: `tree.on_select`, `doc.set_language`, `doc.set_marks`, `doc.caret`/`doc.set_caret`, `doc.set_completer`, `doc.set_hover`.
|
|
262
|
+
- Produces: a window that is one PRISM dock (`vb.dock(layout, core.panels.entries())`, the layout a `prism.dock_layout` whose value is saved to and restored from `<workspace>/.candide/layout.json`): the file tree (left), the editor (center), the diagnostics list and a console panel with a `Kernel` prompt (bottom), each a panel registered through `Panels.add`; and a command palette (Ctrl+Shift+P: a popup with a text field filtering `Commands.list()`, Enter runs the command; its result in the status line).
|
|
263
|
+
|
|
264
|
+
- [ ] **Step 1: Write the failing tests** — `test_selecting_a_file_opens_it` (simulate `on_select`), `test_diagnostics_become_marks` (a fact for line 0 → `set_marks` received a mark on line 0), `test_go_to_definition_moves_the_caret` (F12), `test_palette_lists_and_runs_a_command`.
|
|
265
|
+
- [ ] **Steps 2-5:** fail, implement, pass, commit — `feat(app): the window: tree, editor with diagnostics, definitions, hover, completion, palette`
|
|
266
|
+
|
|
267
|
+
## Needs from PRISM (a separate PRISM plan, before Task 12)
|
|
268
|
+
|
|
269
|
+
The Python binding's additions, in PRISM's terms (`{block, byte}` positions; Candide converts):
|
|
270
|
+
|
|
271
|
+
- `tree.on_select(callback)`: called with the node id when a row is picked.
|
|
272
|
+
- `doc.set_language(name)`: the highlighter of a code editor showing `doc` changes.
|
|
273
|
+
- `doc.set_marks(marks)`: marks are `(block, begin_byte, end_byte, kind, message)` with kind
|
|
274
|
+
`"error" | "warning" | "info"`, drawn as a squiggle under the range and a dot in the gutter, the
|
|
275
|
+
message as a tooltip; replaces the previous marks.
|
|
276
|
+
- `doc.caret() -> (block, byte)` and `doc.set_caret(block, byte)` (scrolls to it).
|
|
277
|
+
- `doc.set_completer(fn(block, byte) -> list[tuple[label, insert, detail]])` over PRISM's `Completer`.
|
|
278
|
+
- `doc.set_hover(fn(block, byte) -> str | None)`: a tooltip after the pointer rests on text.
|