continualcode 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,11 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+
4
+ .DS_Store
5
+
6
+ .env
7
+ .venv/
8
+ venv/
9
+
10
+ training_data/*.jsonl
11
+ preference_data/*.jsonl
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Surya Dantuluri
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.
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: continualcode
3
+ Version: 0.1.0
4
+ Summary: Human-in-the-loop coding agent with online learning via prompt distillation
5
+ Project-URL: Homepage, https://github.com/sdan/continualcode
6
+ Project-URL: Repository, https://github.com/sdan/continualcode
7
+ Author-email: Surya Dantuluri <surya@prava.dev>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: claude-code,coding-agent,context-distillation,fine-tuning,llm,prompt-distillation,rlhf,tui
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: textual>=0.40.0
23
+ Requires-Dist: tinker-cookbook>=0.1.0
24
+ Requires-Dist: torch>=2.0.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # ContinualCode
31
+
32
+ Human-in-the-loop coding agent with online learning via prompt distillation.
33
+
34
+ A Claude Code-style TUI that learns from your approvals. When you approve or edit a tool call, the model trains on that feedback in real-time.
35
+
36
+ ## Features
37
+
38
+ - **Claude Code-style approval UI** - 4-option selection with keyboard navigation
39
+ - **Online prompt distillation** - Model learns to internalize policy without needing the policy prompt
40
+ - **Permission memory** - "Don't ask again" for trusted directories
41
+ - **Correction feedback** - Type what the model should have done (for DPO training)
42
+ - **Checkpoint save/load** - Ctrl+S to save, resume later with `--checkpoint`
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install continualcode
48
+ ```
49
+
50
+ ## Quick Start
51
+
52
+ ```bash
53
+ # Run the TUI
54
+ continualcode
55
+
56
+ # With a custom policy file
57
+ continualcode --policy ./my_rules.md
58
+
59
+ # Resume from checkpoint
60
+ continualcode --checkpoint ./checkpoints/step_000100
61
+
62
+ # Inference only (no training)
63
+ continualcode --no-training
64
+ ```
65
+
66
+ ## Environment Variables
67
+
68
+ | Variable | Default | Description |
69
+ |----------|---------|-------------|
70
+ | `MODEL` | `Qwen/Qwen3-4B-Instruct-2507` | Base model |
71
+ | `TINKER_URL` | `None` | Tinker service URL |
72
+ | `TINKER_API_KEY` | `None` | Tinker API key |
73
+ | `ENABLE_TRAINING` | `1` | Enable LoRA training |
74
+ | `LEARNING_RATE` | `1e-5` | Adam learning rate |
75
+ | `LORA_RANK` | `32` | LoRA rank |
76
+ | `POLICY_PATH` | `./policy_memory.md` | Policy file injected into teacher prefix |
77
+ | `DISTILL_MODE` | `on_policy` | `on_policy` or `off_policy` |
78
+ | `CHECKPOINT_DIR` | `./checkpoints` | Where Ctrl+S saves checkpoints |
79
+ | `LOAD_CHECKPOINT` | `""` | Checkpoint to load on startup |
80
+
81
+ ## How It Works
82
+
83
+ **Prompt distillation** trains a model to behave *as if* it had access to a long policy prompt, without actually needing it at inference time:
84
+
85
+ 1. **Generation** uses a "teacher" prefix that includes your policy file
86
+ 2. **Training** uses a "student" prefix without the policy
87
+ 3. The model learns to produce the same (approved) outputs without the policy context
88
+
89
+ Two distillation modes:
90
+ - `off_policy`: Classic SFT on approved outputs
91
+ - `on_policy`: Sample from student, score with teacher logprobs, update via importance sampling
92
+
93
+ ## Keybindings
94
+
95
+ | Key | Action |
96
+ |-----|--------|
97
+ | `Enter` | Send message |
98
+ | `Ctrl+S` | Save checkpoint |
99
+ | `Ctrl+L` | Clear conversation |
100
+ | `Ctrl+C` | Quit |
101
+ | `?` | Show help |
102
+
103
+ **Approval UI:**
104
+ | Key | Action |
105
+ |-----|--------|
106
+ | `1` / `y` | Approve |
107
+ | `2` / `Shift+Tab` | Approve + remember |
108
+ | `3` / `n` / `Esc` | Deny |
109
+ | `4` / `Tab` | Type correction |
110
+ | `e` | Edit args in $EDITOR |
111
+ | Arrow keys | Navigate options |
112
+
113
+ ## License
114
+
115
+ MIT
@@ -0,0 +1,86 @@
1
+ # ContinualCode
2
+
3
+ Human-in-the-loop coding agent with online learning via prompt distillation.
4
+
5
+ A Claude Code-style TUI that learns from your approvals. When you approve or edit a tool call, the model trains on that feedback in real-time.
6
+
7
+ ## Features
8
+
9
+ - **Claude Code-style approval UI** - 4-option selection with keyboard navigation
10
+ - **Online prompt distillation** - Model learns to internalize policy without needing the policy prompt
11
+ - **Permission memory** - "Don't ask again" for trusted directories
12
+ - **Correction feedback** - Type what the model should have done (for DPO training)
13
+ - **Checkpoint save/load** - Ctrl+S to save, resume later with `--checkpoint`
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install continualcode
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # Run the TUI
25
+ continualcode
26
+
27
+ # With a custom policy file
28
+ continualcode --policy ./my_rules.md
29
+
30
+ # Resume from checkpoint
31
+ continualcode --checkpoint ./checkpoints/step_000100
32
+
33
+ # Inference only (no training)
34
+ continualcode --no-training
35
+ ```
36
+
37
+ ## Environment Variables
38
+
39
+ | Variable | Default | Description |
40
+ |----------|---------|-------------|
41
+ | `MODEL` | `Qwen/Qwen3-4B-Instruct-2507` | Base model |
42
+ | `TINKER_URL` | `None` | Tinker service URL |
43
+ | `TINKER_API_KEY` | `None` | Tinker API key |
44
+ | `ENABLE_TRAINING` | `1` | Enable LoRA training |
45
+ | `LEARNING_RATE` | `1e-5` | Adam learning rate |
46
+ | `LORA_RANK` | `32` | LoRA rank |
47
+ | `POLICY_PATH` | `./policy_memory.md` | Policy file injected into teacher prefix |
48
+ | `DISTILL_MODE` | `on_policy` | `on_policy` or `off_policy` |
49
+ | `CHECKPOINT_DIR` | `./checkpoints` | Where Ctrl+S saves checkpoints |
50
+ | `LOAD_CHECKPOINT` | `""` | Checkpoint to load on startup |
51
+
52
+ ## How It Works
53
+
54
+ **Prompt distillation** trains a model to behave *as if* it had access to a long policy prompt, without actually needing it at inference time:
55
+
56
+ 1. **Generation** uses a "teacher" prefix that includes your policy file
57
+ 2. **Training** uses a "student" prefix without the policy
58
+ 3. The model learns to produce the same (approved) outputs without the policy context
59
+
60
+ Two distillation modes:
61
+ - `off_policy`: Classic SFT on approved outputs
62
+ - `on_policy`: Sample from student, score with teacher logprobs, update via importance sampling
63
+
64
+ ## Keybindings
65
+
66
+ | Key | Action |
67
+ |-----|--------|
68
+ | `Enter` | Send message |
69
+ | `Ctrl+S` | Save checkpoint |
70
+ | `Ctrl+L` | Clear conversation |
71
+ | `Ctrl+C` | Quit |
72
+ | `?` | Show help |
73
+
74
+ **Approval UI:**
75
+ | Key | Action |
76
+ |-----|--------|
77
+ | `1` / `y` | Approve |
78
+ | `2` / `Shift+Tab` | Approve + remember |
79
+ | `3` / `n` / `Esc` | Deny |
80
+ | `4` / `Tab` | Type correction |
81
+ | `e` | Edit args in $EDITOR |
82
+ | Arrow keys | Navigate options |
83
+
84
+ ## License
85
+
86
+ MIT
@@ -0,0 +1,47 @@
1
+ # Demo: Async Worker Pool Bug
2
+
3
+ A subtle concurrency bug that would trip up experienced systems programmers.
4
+
5
+ ## The Bug
6
+
7
+ `async_pool.py` has a race condition in task submission. The bug:
8
+
9
+ ```python
10
+ async def submit(self, coro_fn, *args, **kwargs) -> int:
11
+ task_id = self._task_counter
12
+ self._task_counter += 1
13
+
14
+ asyncio.create_task(self._run_task(task_id, coro_fn, *args, **kwargs))
15
+ return task_id
16
+ ```
17
+
18
+ **Problem**: `create_task()` schedules the coroutine but doesn't `await` it. The task
19
+ starts running immediately (or on next tick). If the task completes *before* the caller
20
+ adds `task_id` to their tracking list, and `gather_all` is called right after, there's
21
+ a window where results can be missed.
22
+
23
+ More subtly: the `_task_counter` increment and task creation aren't atomic with respect
24
+ to the event loop. Under high concurrency with very fast tasks, IDs can get reused or
25
+ results can land in `_results` before the caller even knows what ID they got.
26
+
27
+ ## How to Trigger
28
+
29
+ Run with many fast tasks:
30
+ ```bash
31
+ python async_pool.py
32
+ ```
33
+
34
+ The bug is intermittent - it depends on task timing and event loop scheduling.
35
+
36
+ ## The Fix
37
+
38
+ The `submit()` method should await the task being tracked properly, or use a different
39
+ pattern like returning a `Future` that the caller can await, rather than an ID-based
40
+ lookup system that races with task completion.
41
+
42
+ ## Demo Prompt
43
+
44
+ ```
45
+ There's a race condition in async_pool.py where tasks occasionally get lost under
46
+ high concurrency. The pool reports fewer results than tasks submitted. Find and fix it.
47
+ ```
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "continualcode"
7
+ version = "0.1.0"
8
+ description = "Human-in-the-loop coding agent with online learning via prompt distillation"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ { name = "Surya Dantuluri", email = "surya@prava.dev" }
13
+ ]
14
+ keywords = [
15
+ "llm",
16
+ "coding-agent",
17
+ "fine-tuning",
18
+ "rlhf",
19
+ "prompt-distillation",
20
+ "context-distillation",
21
+ "tui",
22
+ "claude-code",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 3 - Alpha",
26
+ "Environment :: Console",
27
+ "Intended Audience :: Developers",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3.10",
31
+ "Programming Language :: Python :: 3.11",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Topic :: Software Development",
34
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
35
+ ]
36
+ requires-python = ">=3.10"
37
+ dependencies = [
38
+ "textual>=0.40.0",
39
+ "tinker-cookbook>=0.1.0",
40
+ "torch>=2.0.0",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ dev = [
45
+ "pytest>=7.0.0",
46
+ "ruff>=0.1.0",
47
+ ]
48
+
49
+ [project.urls]
50
+ Homepage = "https://github.com/sdan/continualcode"
51
+ Repository = "https://github.com/sdan/continualcode"
52
+
53
+ [project.scripts]
54
+ continualcode = "continualcode.cli:main"
55
+
56
+ [tool.hatch.build.targets.wheel]
57
+ packages = ["src/continualcode"]
58
+
59
+ [tool.hatch.build.targets.sdist]
60
+ include = [
61
+ "src/continualcode",
62
+ "README.md",
63
+ "LICENSE",
64
+ ]
65
+
66
+ [tool.ruff]
67
+ line-length = 100
68
+ target-version = "py310"
69
+
70
+ [tool.ruff.lint]
71
+ select = ["E", "F", "I", "W"]
@@ -0,0 +1,17 @@
1
+ """
2
+ ContinualCode - Human-in-the-loop coding agent with online learning.
3
+
4
+ A Claude Code-style TUI that learns from your approvals via prompt distillation.
5
+ """
6
+
7
+ __version__ = "0.1.0"
8
+
9
+ from continualcode.session import ContextDistillSession
10
+ from continualcode.tools import TOOL_SPECS, READONLY_TOOLS, execute_tool
11
+
12
+ __all__ = [
13
+ "ContextDistillSession",
14
+ "TOOL_SPECS",
15
+ "READONLY_TOOLS",
16
+ "execute_tool",
17
+ ]
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ CLI entry point for ContinualCode.
4
+
5
+ Usage:
6
+ continualcode # Run the TUI
7
+ continualcode --help # Show help
8
+ continualcode --version # Show version
9
+ """
10
+
11
+ import argparse
12
+ import sys
13
+
14
+
15
+ def main() -> int:
16
+ parser = argparse.ArgumentParser(
17
+ prog="continualcode",
18
+ description="Human-in-the-loop coding agent with online learning via prompt distillation",
19
+ )
20
+ parser.add_argument(
21
+ "--version",
22
+ action="version",
23
+ version="%(prog)s 0.1.0",
24
+ )
25
+ parser.add_argument(
26
+ "--model",
27
+ default=None,
28
+ help="Override MODEL environment variable",
29
+ )
30
+ parser.add_argument(
31
+ "--policy",
32
+ default=None,
33
+ help="Path to policy file (default: ./policy_memory.md)",
34
+ )
35
+ parser.add_argument(
36
+ "--checkpoint",
37
+ default=None,
38
+ help="Load checkpoint on startup",
39
+ )
40
+ parser.add_argument(
41
+ "--no-training",
42
+ action="store_true",
43
+ help="Disable training (inference only)",
44
+ )
45
+
46
+ args = parser.parse_args()
47
+
48
+ # Set environment variables from CLI args
49
+ import os
50
+ if args.model:
51
+ os.environ["MODEL"] = args.model
52
+ if args.policy:
53
+ os.environ["POLICY_PATH"] = args.policy
54
+ if args.checkpoint:
55
+ os.environ["LOAD_CHECKPOINT"] = args.checkpoint
56
+ if args.no_training:
57
+ os.environ["ENABLE_TRAINING"] = "0"
58
+
59
+ # Import and run the TUI
60
+ from continualcode.tui import TinkerCodeApp
61
+ app = TinkerCodeApp()
62
+ app.run()
63
+ return 0
64
+
65
+
66
+ if __name__ == "__main__":
67
+ sys.exit(main())