comet-code 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.
- comet_code-0.1.0/.claude/settings.local.json +9 -0
- comet_code-0.1.0/.gitignore +5 -0
- comet_code-0.1.0/.python-version +1 -0
- comet_code-0.1.0/LICENSE +21 -0
- comet_code-0.1.0/PKG-INFO +154 -0
- comet_code-0.1.0/README.md +122 -0
- comet_code-0.1.0/main.py +91 -0
- comet_code-0.1.0/pyproject.toml +55 -0
- comet_code-0.1.0/src/cli/__init__.py +1 -0
- comet_code-0.1.0/src/cli/commands.py +266 -0
- comet_code-0.1.0/src/cli/completer.py +18 -0
- comet_code-0.1.0/src/cli/render.py +420 -0
- comet_code-0.1.0/src/cli/state.py +18 -0
- comet_code-0.1.0/src/cli/ui.py +424 -0
- comet_code-0.1.0/src/config.py +97 -0
- comet_code-0.1.0/src/core/__init__.py +1 -0
- comet_code-0.1.0/src/core/graph.py +62 -0
- comet_code-0.1.0/src/core/graph_state.py +52 -0
- comet_code-0.1.0/src/core/nodes.py +711 -0
- comet_code-0.1.0/src/core/orchestrator.py +217 -0
- comet_code-0.1.0/src/llm/__init__.py +1 -0
- comet_code-0.1.0/src/llm/models.py +46 -0
- comet_code-0.1.0/src/llm/openrouter_client.py +32 -0
- comet_code-0.1.0/src/llm/prompts.py +179 -0
- comet_code-0.1.0/src/output/__init__.py +1 -0
- comet_code-0.1.0/src/patching/__init__.py +1 -0
- comet_code-0.1.0/src/retrieval/__init__.py +1 -0
- comet_code-0.1.0/src/sandbox/__init__.py +1 -0
- comet_code-0.1.0/src/schemas/__init__.py +1 -0
- comet_code-0.1.0/src/schemas/attempt.py +65 -0
- comet_code-0.1.0/src/schemas/code_chunk.py +30 -0
- comet_code-0.1.0/src/schemas/events.py +33 -0
- comet_code-0.1.0/src/schemas/mode_policy.py +11 -0
- comet_code-0.1.0/src/schemas/plan.py +34 -0
- comet_code-0.1.0/src/schemas/session.py +36 -0
- comet_code-0.1.0/src/schemas/task.py +66 -0
- comet_code-0.1.0/src/schemas/tool.py +24 -0
- comet_code-0.1.0/src/tools/__init__.py +450 -0
- comet_code-0.1.0/src/verify/__init__.py +1 -0
- comet_code-0.1.0/tests/test_cli_render.py +126 -0
- comet_code-0.1.0/tests/test_cli_ui.py +60 -0
- comet_code-0.1.0/tests/test_limit_handling.py +227 -0
- comet_code-0.1.0/tests/test_tool_approval.py +114 -0
- comet_code-0.1.0/tests/test_tools_schema.py +48 -0
- comet_code-0.1.0/uv.lock +838 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
comet_code-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pritivi Rajkumar
|
|
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,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: comet-code
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Agentic CLI coding assistant
|
|
5
|
+
Project-URL: Homepage, https://github.com/pritivi03/comet-code
|
|
6
|
+
Project-URL: Repository, https://github.com/pritivi03/comet-code
|
|
7
|
+
Project-URL: Issues, https://github.com/pritivi03/comet-code/issues
|
|
8
|
+
Author: Pritivi Rajkumar
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent,cli,coding-assistant,langgraph,llm,openrouter
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development
|
|
21
|
+
Classifier: Topic :: Utilities
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Requires-Dist: httpx>=0.27.0
|
|
24
|
+
Requires-Dist: langchain-core>=1.2.28
|
|
25
|
+
Requires-Dist: langchain-openai>=1.1.12
|
|
26
|
+
Requires-Dist: langgraph>=1.1.6
|
|
27
|
+
Requires-Dist: prompt-toolkit>=3.0.47
|
|
28
|
+
Requires-Dist: pydantic>=2.7.0
|
|
29
|
+
Requires-Dist: rich>=13.7.0
|
|
30
|
+
Requires-Dist: typer>=0.12.0
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# CometCode
|
|
34
|
+
|
|
35
|
+
An agentic coding assistant for the terminal. Give it a task — it reads your codebase, reasons about what to change, proposes edits, and applies them only after you approve.
|
|
36
|
+
|
|
37
|
+
Built from scratch on **LangGraph** and **OpenRouter**, with a streaming **Rich** terminal UI.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Demo
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
mode → implement
|
|
45
|
+
╭────────────────────────────────────────────────────────────╮
|
|
46
|
+
│ add a /clear command that resets conversation history │
|
|
47
|
+
╰────────────────────────────────────────────────────────────╯
|
|
48
|
+
|
|
49
|
+
tool
|
|
50
|
+
● Read src/cli/commands.py done
|
|
51
|
+
└ def handle_command(text, console, state, orchestrator):
|
|
52
|
+
● Edit src/cli/commands.py done
|
|
53
|
+
└ [ok] replaced 1 occurrence(s)
|
|
54
|
+
|
|
55
|
+
╭──────────────────────────── response ──────────────────────╮
|
|
56
|
+
│ Added `/clear` — it calls `orchestrator.reset_history()` │
|
|
57
|
+
│ and clears `state.last_tool_history`. │
|
|
58
|
+
╰────────────────────────────────────────────────────────────╯
|
|
59
|
+
|
|
60
|
+
↓ ~3.2k tokens Cooked for 8s
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Architecture
|
|
66
|
+
|
|
67
|
+
CometCode is structured as a **LangGraph state machine** where each node receives the full `AgentState` and returns state updates. The graph has two nodes — `call_llm` and `execute_tools` — connected by conditional edges that route based on the model's response type.
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
START → call_llm ──→ execute_tools ──┐
|
|
71
|
+
↑ │
|
|
72
|
+
└────────────────────────┘
|
|
73
|
+
(loops until final answer or budget exhausted)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Key design decisions:**
|
|
77
|
+
|
|
78
|
+
- **AgentState as the single source of truth** — conversation history, token budgets, tool-call counters, evidence notes, and attempt metadata all live in one typed dict that flows through the graph. Nodes are pure: they receive state, return a patch.
|
|
79
|
+
|
|
80
|
+
- **Dual invocation paths** — models that support native function calling stream through `_invoke_native`; models that don't fall back to `_invoke_json_fallback` with a structured Pydantic output schema. The rest of the system is unaware of the difference.
|
|
81
|
+
|
|
82
|
+
- **Explicit budget enforcement** — the graph tracks `tool_calls_used`, `consecutive_no_signal`, and `repeat_call_streak`. Hitting any limit triggers a soft-stop: the model is forced into a final answer using whatever evidence it collected, rather than erroring.
|
|
83
|
+
|
|
84
|
+
- **Human-in-the-loop approval** — mutating tools (`write_file`, `replace_text`) are gated behind a `request_approval` callback. After approval and execution, the loop returns to the LLM so it sees the updated file state before proposing the next edit — preventing duplicate proposals.
|
|
85
|
+
|
|
86
|
+
- **Mode-scoped prompting** — `explain`, `debug`, `refactor`, `implement`, and `plan` modes each carry different system instructions and tool permissions. Read-only modes (`explain`, `plan`) never receive mutating tools in their schema.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Features
|
|
91
|
+
|
|
92
|
+
- **Five task modes** — `explain`, `debug`, `refactor`, `implement`, `plan`
|
|
93
|
+
- **Multi-model support** — route to any OpenRouter model; native tool calling used when available, JSON schema fallback otherwise
|
|
94
|
+
- **Streaming terminal UI** — live spinner with real-time token count and elapsed timer; tool history with colored unified diffs for proposed changes
|
|
95
|
+
- **Persistent conversation history** — context carries across turns within a session; mode switches are surfaced to the model explicitly
|
|
96
|
+
- **Slash command interface** — `/mode`, `/model`, `/tools`, `/clear`, `/help` with tab-completion
|
|
97
|
+
- **Self-limiting agent** — budget caps on tool calls, no-signal streaks, and repeated identical calls; graceful degradation to best-effort answers
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Stack
|
|
102
|
+
|
|
103
|
+
| Layer | Technology |
|
|
104
|
+
|---|---|
|
|
105
|
+
| Agent orchestration | [LangGraph](https://github.com/langchain-ai/langgraph) |
|
|
106
|
+
| LLM routing | [OpenRouter](https://openrouter.ai) via LangChain `ChatOpenAI` |
|
|
107
|
+
| Terminal UI | [Rich](https://github.com/Textualize/rich) + [prompt_toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit) |
|
|
108
|
+
| Schema validation | [Pydantic v2](https://docs.pydantic.dev) |
|
|
109
|
+
| Python | 3.12+ |
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Getting Started
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
git clone https://github.com/pritivi03/comet-code
|
|
117
|
+
cd comet-code
|
|
118
|
+
python -m venv .venv && source .venv/bin/activate
|
|
119
|
+
pip install -r requirements.txt
|
|
120
|
+
|
|
121
|
+
# Add your OpenRouter API key
|
|
122
|
+
echo "OPENROUTER_API_KEY=your_key_here" > .env
|
|
123
|
+
|
|
124
|
+
python -m main
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Slash commands
|
|
128
|
+
|
|
129
|
+
| Command | Description |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `/mode <name>` | Switch task mode (`explain`, `debug`, `refactor`, `implement`, `plan`) |
|
|
132
|
+
| `/model <name>` | Switch model (by alias, slug, or label) |
|
|
133
|
+
| `/tools` | Show last run tool history |
|
|
134
|
+
| `/clear` | Reset conversation history |
|
|
135
|
+
| `/help` | List all commands |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Project Layout
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
src/
|
|
143
|
+
cli/ # Terminal UI, input handling, rendering, slash commands
|
|
144
|
+
core/ # LangGraph graph, nodes, orchestrator, state schema
|
|
145
|
+
llm/ # OpenRouter client, model catalog, prompt builder
|
|
146
|
+
schemas/ # Pydantic models (events, tasks, state, tools)
|
|
147
|
+
tools/ # Tool implementations (read_file, search_text, replace_text, …)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# CometCode
|
|
2
|
+
|
|
3
|
+
An agentic coding assistant for the terminal. Give it a task — it reads your codebase, reasons about what to change, proposes edits, and applies them only after you approve.
|
|
4
|
+
|
|
5
|
+
Built from scratch on **LangGraph** and **OpenRouter**, with a streaming **Rich** terminal UI.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Demo
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
mode → implement
|
|
13
|
+
╭────────────────────────────────────────────────────────────╮
|
|
14
|
+
│ add a /clear command that resets conversation history │
|
|
15
|
+
╰────────────────────────────────────────────────────────────╯
|
|
16
|
+
|
|
17
|
+
tool
|
|
18
|
+
● Read src/cli/commands.py done
|
|
19
|
+
└ def handle_command(text, console, state, orchestrator):
|
|
20
|
+
● Edit src/cli/commands.py done
|
|
21
|
+
└ [ok] replaced 1 occurrence(s)
|
|
22
|
+
|
|
23
|
+
╭──────────────────────────── response ──────────────────────╮
|
|
24
|
+
│ Added `/clear` — it calls `orchestrator.reset_history()` │
|
|
25
|
+
│ and clears `state.last_tool_history`. │
|
|
26
|
+
╰────────────────────────────────────────────────────────────╯
|
|
27
|
+
|
|
28
|
+
↓ ~3.2k tokens Cooked for 8s
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Architecture
|
|
34
|
+
|
|
35
|
+
CometCode is structured as a **LangGraph state machine** where each node receives the full `AgentState` and returns state updates. The graph has two nodes — `call_llm` and `execute_tools` — connected by conditional edges that route based on the model's response type.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
START → call_llm ──→ execute_tools ──┐
|
|
39
|
+
↑ │
|
|
40
|
+
└────────────────────────┘
|
|
41
|
+
(loops until final answer or budget exhausted)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Key design decisions:**
|
|
45
|
+
|
|
46
|
+
- **AgentState as the single source of truth** — conversation history, token budgets, tool-call counters, evidence notes, and attempt metadata all live in one typed dict that flows through the graph. Nodes are pure: they receive state, return a patch.
|
|
47
|
+
|
|
48
|
+
- **Dual invocation paths** — models that support native function calling stream through `_invoke_native`; models that don't fall back to `_invoke_json_fallback` with a structured Pydantic output schema. The rest of the system is unaware of the difference.
|
|
49
|
+
|
|
50
|
+
- **Explicit budget enforcement** — the graph tracks `tool_calls_used`, `consecutive_no_signal`, and `repeat_call_streak`. Hitting any limit triggers a soft-stop: the model is forced into a final answer using whatever evidence it collected, rather than erroring.
|
|
51
|
+
|
|
52
|
+
- **Human-in-the-loop approval** — mutating tools (`write_file`, `replace_text`) are gated behind a `request_approval` callback. After approval and execution, the loop returns to the LLM so it sees the updated file state before proposing the next edit — preventing duplicate proposals.
|
|
53
|
+
|
|
54
|
+
- **Mode-scoped prompting** — `explain`, `debug`, `refactor`, `implement`, and `plan` modes each carry different system instructions and tool permissions. Read-only modes (`explain`, `plan`) never receive mutating tools in their schema.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **Five task modes** — `explain`, `debug`, `refactor`, `implement`, `plan`
|
|
61
|
+
- **Multi-model support** — route to any OpenRouter model; native tool calling used when available, JSON schema fallback otherwise
|
|
62
|
+
- **Streaming terminal UI** — live spinner with real-time token count and elapsed timer; tool history with colored unified diffs for proposed changes
|
|
63
|
+
- **Persistent conversation history** — context carries across turns within a session; mode switches are surfaced to the model explicitly
|
|
64
|
+
- **Slash command interface** — `/mode`, `/model`, `/tools`, `/clear`, `/help` with tab-completion
|
|
65
|
+
- **Self-limiting agent** — budget caps on tool calls, no-signal streaks, and repeated identical calls; graceful degradation to best-effort answers
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Stack
|
|
70
|
+
|
|
71
|
+
| Layer | Technology |
|
|
72
|
+
|---|---|
|
|
73
|
+
| Agent orchestration | [LangGraph](https://github.com/langchain-ai/langgraph) |
|
|
74
|
+
| LLM routing | [OpenRouter](https://openrouter.ai) via LangChain `ChatOpenAI` |
|
|
75
|
+
| Terminal UI | [Rich](https://github.com/Textualize/rich) + [prompt_toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit) |
|
|
76
|
+
| Schema validation | [Pydantic v2](https://docs.pydantic.dev) |
|
|
77
|
+
| Python | 3.12+ |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Getting Started
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
git clone https://github.com/pritivi03/comet-code
|
|
85
|
+
cd comet-code
|
|
86
|
+
python -m venv .venv && source .venv/bin/activate
|
|
87
|
+
pip install -r requirements.txt
|
|
88
|
+
|
|
89
|
+
# Add your OpenRouter API key
|
|
90
|
+
echo "OPENROUTER_API_KEY=your_key_here" > .env
|
|
91
|
+
|
|
92
|
+
python -m main
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Slash commands
|
|
96
|
+
|
|
97
|
+
| Command | Description |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `/mode <name>` | Switch task mode (`explain`, `debug`, `refactor`, `implement`, `plan`) |
|
|
100
|
+
| `/model <name>` | Switch model (by alias, slug, or label) |
|
|
101
|
+
| `/tools` | Show last run tool history |
|
|
102
|
+
| `/clear` | Reset conversation history |
|
|
103
|
+
| `/help` | List all commands |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Project Layout
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
src/
|
|
111
|
+
cli/ # Terminal UI, input handling, rendering, slash commands
|
|
112
|
+
core/ # LangGraph graph, nodes, orchestrator, state schema
|
|
113
|
+
llm/ # OpenRouter client, model catalog, prompt builder
|
|
114
|
+
schemas/ # Pydantic models (events, tasks, state, tools)
|
|
115
|
+
tools/ # Tool implementations (read_file, search_text, replace_text, …)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
comet_code-0.1.0/main.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Comet entrypoint.
|
|
2
|
+
|
|
3
|
+
Installed as the `comet` console script via pyproject.toml.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import warnings
|
|
9
|
+
warnings.filterwarnings("ignore", ".*Pydantic V1.*")
|
|
10
|
+
|
|
11
|
+
import typer
|
|
12
|
+
from rich.console import Console
|
|
13
|
+
from rich.panel import Panel
|
|
14
|
+
from rich.text import Text
|
|
15
|
+
|
|
16
|
+
from cli.ui import run_shell
|
|
17
|
+
from config import config_file_path, is_valid_key, mask_key, resolve_api_key, save_key
|
|
18
|
+
|
|
19
|
+
app = typer.Typer(
|
|
20
|
+
name="comet",
|
|
21
|
+
help="Comet — agentic CLI coding assistant.",
|
|
22
|
+
no_args_is_help=False,
|
|
23
|
+
add_completion=False,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _prompt_for_key(console: Console) -> str | None:
|
|
28
|
+
"""Ask the user for an OpenRouter API key on first run.
|
|
29
|
+
|
|
30
|
+
Returns the key if provided (and optionally saved), or None if skipped.
|
|
31
|
+
"""
|
|
32
|
+
console.print(
|
|
33
|
+
Panel(
|
|
34
|
+
Text.from_markup(
|
|
35
|
+
"No OpenRouter API key found.\n\n"
|
|
36
|
+
"Get one at [bold]https://openrouter.ai/keys[/bold]\n\n"
|
|
37
|
+
"You can also skip this and set it later:\n"
|
|
38
|
+
" • Set [bold]OPENROUTER_API_KEY[/bold] in your environment\n"
|
|
39
|
+
f" • Or run [bold]/key set <key>[/bold] inside the shell (saves to {config_file_path()})"
|
|
40
|
+
),
|
|
41
|
+
title="[bold bright_cyan]API Key Setup[/bold bright_cyan]",
|
|
42
|
+
border_style="bright_blue",
|
|
43
|
+
padding=(1, 2),
|
|
44
|
+
)
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
while True:
|
|
48
|
+
raw = console.input(
|
|
49
|
+
"[bold bright_cyan]Enter API key[/bold bright_cyan] [dim](or press Enter to skip)[/dim]: "
|
|
50
|
+
).strip()
|
|
51
|
+
|
|
52
|
+
if not raw:
|
|
53
|
+
console.print("[dim]Skipping — you can set it later with /key set <key>[/dim]")
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
if not is_valid_key(raw):
|
|
57
|
+
console.print("[red]Invalid key:[/red] OpenRouter keys must start with [bold]sk-or-[/bold]")
|
|
58
|
+
continue
|
|
59
|
+
|
|
60
|
+
save_prompt = console.input(
|
|
61
|
+
f"[dim]Save to {config_file_path()}?[/dim] [bold bright_cyan][Y/n][/bold bright_cyan] "
|
|
62
|
+
).strip().lower()
|
|
63
|
+
|
|
64
|
+
if save_prompt in {"", "y", "yes"}:
|
|
65
|
+
save_key(raw)
|
|
66
|
+
console.print(
|
|
67
|
+
f"[bright_cyan]Saved[/bright_cyan] [dim]{mask_key(raw)} ({config_file_path()})[/dim]"
|
|
68
|
+
)
|
|
69
|
+
else:
|
|
70
|
+
console.print("[dim]Key not saved — will only be used for this session[/dim]")
|
|
71
|
+
|
|
72
|
+
return raw
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@app.callback(invoke_without_command=True)
|
|
76
|
+
def main(ctx: typer.Context) -> None:
|
|
77
|
+
"""Launch the interactive Comet shell when no subcommand is given."""
|
|
78
|
+
if ctx.invoked_subcommand is not None:
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
console = Console()
|
|
82
|
+
api_key = resolve_api_key()
|
|
83
|
+
|
|
84
|
+
if api_key is None:
|
|
85
|
+
api_key = _prompt_for_key(console) or ""
|
|
86
|
+
|
|
87
|
+
run_shell(api_key=api_key)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
app()
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "comet-code"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Agentic CLI coding assistant"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Pritivi Rajkumar" },
|
|
9
|
+
]
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
keywords = ["cli", "coding-assistant", "llm", "agent", "openrouter", "langgraph"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Environment :: Console",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Topic :: Software Development",
|
|
22
|
+
"Topic :: Utilities",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"typer>=0.12.0",
|
|
26
|
+
"rich>=13.7.0",
|
|
27
|
+
"prompt-toolkit>=3.0.47",
|
|
28
|
+
"pydantic>=2.7.0",
|
|
29
|
+
"httpx>=0.27.0",
|
|
30
|
+
"langgraph>=1.1.6",
|
|
31
|
+
"langchain-core>=1.2.28",
|
|
32
|
+
"langchain-openai>=1.1.12",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/pritivi03/comet-code"
|
|
37
|
+
Repository = "https://github.com/pritivi03/comet-code"
|
|
38
|
+
Issues = "https://github.com/pritivi03/comet-code/issues"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
comet = "main:app"
|
|
42
|
+
|
|
43
|
+
[build-system]
|
|
44
|
+
requires = ["hatchling"]
|
|
45
|
+
build-backend = "hatchling.build"
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.wheel]
|
|
48
|
+
packages = [
|
|
49
|
+
"src/cli",
|
|
50
|
+
"src/core",
|
|
51
|
+
"src/llm",
|
|
52
|
+
"src/schemas",
|
|
53
|
+
"src/tools",
|
|
54
|
+
]
|
|
55
|
+
force-include = { "main.py" = "main.py", "src/config.py" = "config.py" }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""CLI entrypoints."""
|