diffpilot 0.0.1__py3-none-any.whl
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.
- diffpilot/__init__.py +11 -0
- diffpilot/__init__.pyi +3 -0
- diffpilot/__main__.py +3 -0
- diffpilot/__main__.pyi +1 -0
- diffpilot/agents.py +438 -0
- diffpilot/agents.pyi +81 -0
- diffpilot/agentsmd.py +97 -0
- diffpilot/agentsmd.pyi +12 -0
- diffpilot/bootstrap.py +456 -0
- diffpilot/bootstrap.pyi +49 -0
- diffpilot/cli.py +731 -0
- diffpilot/cli.pyi +62 -0
- diffpilot/config.py +342 -0
- diffpilot/config.pyi +109 -0
- diffpilot/core.py +333 -0
- diffpilot/core.pyi +26 -0
- diffpilot/events.py +172 -0
- diffpilot/events.pyi +28 -0
- diffpilot/gitdiff.py +170 -0
- diffpilot/gitdiff.pyi +14 -0
- diffpilot/index.py +242 -0
- diffpilot/index.pyi +60 -0
- diffpilot/jev.py +203 -0
- diffpilot/jev.pyi +33 -0
- diffpilot/llm.py +141 -0
- diffpilot/llm.pyi +28 -0
- diffpilot/ops.py +285 -0
- diffpilot/ops.pyi +31 -0
- diffpilot/prompts.py +432 -0
- diffpilot/prompts.pyi +28 -0
- diffpilot/py.typed +0 -0
- diffpilot/schemas.py +110 -0
- diffpilot/schemas.pyi +88 -0
- diffpilot/store.py +315 -0
- diffpilot/store.pyi +43 -0
- diffpilot/verify.py +352 -0
- diffpilot/verify.pyi +58 -0
- diffpilot-0.0.1.dist-info/METADATA +80 -0
- diffpilot-0.0.1.dist-info/RECORD +42 -0
- diffpilot-0.0.1.dist-info/WHEEL +5 -0
- diffpilot-0.0.1.dist-info/entry_points.txt +2 -0
- diffpilot-0.0.1.dist-info/top_level.txt +1 -0
diffpilot/cli.pyi
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from collections.abc import Awaitable, Callable as Callable
|
|
3
|
+
from diffpilot import __version__ as __version__, agentsmd as agentsmd, bootstrap as bootstrap, config as config, core as core, events as events, gitdiff as gitdiff, verify as verify
|
|
4
|
+
from diffpilot.config import CONFIG_NAME as CONFIG_NAME, Config as Config, DPError as DPError
|
|
5
|
+
from diffpilot.index import Index as Index
|
|
6
|
+
from diffpilot.jev import Jev as Jev, rank as rank
|
|
7
|
+
from diffpilot.llm import Engine as Engine
|
|
8
|
+
from diffpilot.ops import import_doc as import_doc, open_index as open_index
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Annotated, Any
|
|
11
|
+
|
|
12
|
+
out: Incomplete
|
|
13
|
+
err: Incomplete
|
|
14
|
+
log: Incomplete
|
|
15
|
+
HELP: str
|
|
16
|
+
app: Incomplete
|
|
17
|
+
Text: Incomplete
|
|
18
|
+
FromFile: Incomplete
|
|
19
|
+
Files: Incomplete
|
|
20
|
+
NoCache: Incomplete
|
|
21
|
+
|
|
22
|
+
def emit(text: str) -> None: ...
|
|
23
|
+
def busy(msg: str) -> Any: ...
|
|
24
|
+
def render_lines(res: dict) -> None: ...
|
|
25
|
+
def render_ask(res: dict) -> None: ...
|
|
26
|
+
def render_brief(res: dict) -> None: ...
|
|
27
|
+
def render_init(res: dict) -> None: ...
|
|
28
|
+
def render_search(res: dict) -> None: ...
|
|
29
|
+
def render_log(res: dict) -> None: ...
|
|
30
|
+
def render_agentsmd(res: dict) -> None: ...
|
|
31
|
+
def setup_logging(cfg: Config, quiet: bool = False) -> None: ...
|
|
32
|
+
async def execute(name: str, fn: Callable[..., Awaitable[dict]], kwargs: dict, render: Callable[[dict], None], as_json: bool, quiet: bool) -> int: ...
|
|
33
|
+
def command(name: str, *aliases: str, render: Callable[[dict], None] = ...) -> Callable: ...
|
|
34
|
+
def read_input(text: str | None, from_file: Path | None, required: bool = True) -> str: ...
|
|
35
|
+
def version_callback(value: bool) -> None: ...
|
|
36
|
+
def main_options(version: Annotated[bool, None] = False) -> None: ...
|
|
37
|
+
async def init(cfg: Config, with_bootstrap: Annotated[bool, None] = False, include: Annotated[list[str] | None, None] = None, exclude: Annotated[list[str] | None, None] = None, max_files: Annotated[int, None] = 200, force: Annotated[bool, None] = False) -> dict: ...
|
|
38
|
+
async def brief(cfg: Config, text: Text = None, from_file: FromFile = None, files: Files = None, no_cache: NoCache = False) -> dict: ...
|
|
39
|
+
async def ask(cfg: Config, text: Text = None, from_file: FromFile = None, files: Files = None, no_cache: NoCache = False) -> dict: ...
|
|
40
|
+
async def note(cfg: Config, text: Text = None, from_file: FromFile = None, files: Files = None) -> dict: ...
|
|
41
|
+
async def finish(cfg: Config, text: Text = None, from_file: FromFile = None, files: Files = None, no_diff: Annotated[bool, None] = False) -> dict: ...
|
|
42
|
+
|
|
43
|
+
WRITE_STORES: Incomplete
|
|
44
|
+
WRITE_HELP: Incomplete
|
|
45
|
+
|
|
46
|
+
async def outline(cfg: Config, store: Annotated[str | None, None] = None, depth: Annotated[int, None] = 0, grep: Annotated[str, None] = '') -> dict: ...
|
|
47
|
+
async def show(cfg: Config, refs: Annotated[list[str], None]) -> dict: ...
|
|
48
|
+
async def search(cfg: Config, terms: Annotated[str, None], limit: Annotated[int, None] = 8, rerank: Annotated[bool, None] = False, store: Annotated[str | None, None] = None) -> dict: ...
|
|
49
|
+
async def log_(cfg: Config, n: Annotated[int, None] = 20, since: Annotated[str | None, None] = None) -> dict: ...
|
|
50
|
+
async def changelog(cfg: Config, base: Annotated[str | None, None] = None, range_: Annotated[str | None, None] = None, staged: Annotated[bool, None] = False, write: Annotated[bool, None] = False, version: Annotated[str | None, None] = None) -> dict: ...
|
|
51
|
+
async def coverage(cfg: Config, paths: Annotated[list[str], None], fix: Annotated[bool, None] = False, into: Annotated[str | None, None] = None) -> dict: ...
|
|
52
|
+
async def import_(cfg: Config, path: Annotated[str, None], into: Annotated[str, None]) -> dict: ...
|
|
53
|
+
async def verify_(cfg: Config, targets: Annotated[list[str] | None, None] = None, show_all: Annotated[bool, None] = False) -> dict: ...
|
|
54
|
+
async def update_agentsmd(cfg: Config, force: Annotated[bool, None] = False) -> dict: ...
|
|
55
|
+
async def sync(cfg: Config) -> dict: ...
|
|
56
|
+
async def doctor(cfg: Config, offline: Annotated[bool, None] = False) -> dict: ...
|
|
57
|
+
|
|
58
|
+
WARN_ONLY: Incomplete
|
|
59
|
+
BACKTICK_PATH: Incomplete
|
|
60
|
+
|
|
61
|
+
async def inbox(cfg: Config, process: Annotated[bool, None] = False) -> dict: ...
|
|
62
|
+
def main() -> None: ...
|
diffpilot/config.py
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"""diffpilot.toml loading."""
|
|
2
|
+
|
|
3
|
+
import fnmatch
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
import subprocess
|
|
7
|
+
import tomllib
|
|
8
|
+
from dataclasses import dataclass, field, fields
|
|
9
|
+
from pathlib import Path, PurePosixPath
|
|
10
|
+
|
|
11
|
+
CONFIG_NAME = 'diffpilot.toml'
|
|
12
|
+
STORE_TITLES = {
|
|
13
|
+
'prd': 'Product Requirements',
|
|
14
|
+
'impl': 'Implementation Notes',
|
|
15
|
+
'instructions': 'Project Instructions',
|
|
16
|
+
}
|
|
17
|
+
CATEGORY = re.compile(r'^[a-z0-9][a-z0-9_-]*$')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class DPError(Exception):
|
|
21
|
+
"""User-facing error with a process exit code (0 ok, 1 usage/config, 2 auth, 3 LLM, 4 invalid output, 5 lock)."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, message: str, code: int = 1) -> None:
|
|
24
|
+
super().__init__(message)
|
|
25
|
+
self.code = code
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class Paths: # all relative to the repository root
|
|
30
|
+
prd: str = 'docs/PRD.md'
|
|
31
|
+
impl: str = 'docs/implementation.md'
|
|
32
|
+
instructions: str = 'docs/instructions.md'
|
|
33
|
+
changelog: str = 'docs/CHANGELOG.md'
|
|
34
|
+
agents_md: str = 'AGENTS.md'
|
|
35
|
+
state_dir: str = '.diffpilot'
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass
|
|
39
|
+
class LLM:
|
|
40
|
+
backend: str = 'auto' # auto | codex | openrouter; auto = Codex if logged in, else OpenRouter
|
|
41
|
+
model: str = 'gpt-5.6-terra'
|
|
42
|
+
fast_model: str = 'gpt-5.6-luna' # summaries, extraction; empty = same as model
|
|
43
|
+
reasoning: str = 'medium'
|
|
44
|
+
fast_reasoning: str = 'low'
|
|
45
|
+
timeout_s: int = 300
|
|
46
|
+
max_requests: int = 20 # per agent run, including tool turns and review retries
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class Auth:
|
|
51
|
+
codex_home: str = '' # dir with Codex auth.json; empty = $CODEX_HOME or ~/.codex
|
|
52
|
+
openrouter_api_key: str = '' # enables Jev; $OPENROUTER_API_KEY wins
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class Jev:
|
|
57
|
+
"""TypeSafe Jev via OpenRouter: fast typed decisions (rerank, routing). Off without an OpenRouter key."""
|
|
58
|
+
|
|
59
|
+
enabled: bool = True
|
|
60
|
+
model: str = 'jev-latest' # System One id; OpenRouter maps it to ~typesafe/jev-latest
|
|
61
|
+
timeout_s: int = 20
|
|
62
|
+
threshold: float = 0.3 # min relevance probability for a section to be prefetched
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class Behavior:
|
|
67
|
+
detail: str = 'normal' # brief | normal | detailed
|
|
68
|
+
answer_budget: int = 600
|
|
69
|
+
context_budget: int = 12000
|
|
70
|
+
code_access: bool = True
|
|
71
|
+
language: str = 'en'
|
|
72
|
+
agents_md_lines: int = 40 # target size of the `## diffpilot - resume` section
|
|
73
|
+
verify: bool = True # self-review of drafts (edits see the real diff) before returning/writing
|
|
74
|
+
history: list[str] = field(default_factory=list) # ref globs of history sections, besides dated/"log" headings
|
|
75
|
+
git: bool = True # false: never run git (finish acts as --no-diff, no changelog from diffs)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class Verify:
|
|
80
|
+
data: list[str] = field(default_factory=list) # globs of data files to check numbers against
|
|
81
|
+
aliases: dict[str, list[str]] = field(default_factory=dict) # doc word -> data keys, e.g. goal = ["kills"]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@dataclass
|
|
85
|
+
class Doctor:
|
|
86
|
+
ignore: list[str] = field(default_factory=list) # globs of docs that are not project knowledge
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@dataclass
|
|
90
|
+
class Logging:
|
|
91
|
+
level: str = 'warning'
|
|
92
|
+
trace: bool = False
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@dataclass
|
|
96
|
+
class Config:
|
|
97
|
+
root: Path
|
|
98
|
+
paths: Paths = field(default_factory=Paths)
|
|
99
|
+
auth: Auth = field(default_factory=Auth)
|
|
100
|
+
llm: LLM = field(default_factory=LLM)
|
|
101
|
+
jev: Jev = field(default_factory=Jev)
|
|
102
|
+
behavior: Behavior = field(default_factory=Behavior)
|
|
103
|
+
logging: Logging = field(default_factory=Logging)
|
|
104
|
+
doctor: Doctor = field(default_factory=Doctor)
|
|
105
|
+
verify: Verify = field(default_factory=Verify)
|
|
106
|
+
prd_categories: dict[str, str] = field(default_factory=dict) # name -> scope description
|
|
107
|
+
category_paths: dict[str, str] = field(default_factory=dict) # name -> existing doc adopted in place
|
|
108
|
+
home: Path = field(default_factory=lambda: home_dir())
|
|
109
|
+
file_exists: bool = False
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def stores(self) -> tuple[str, ...]:
|
|
113
|
+
"""All stores: prd, its categories (`prd.<name>`), impl, instructions."""
|
|
114
|
+
return ('prd', *(f'prd.{c}' for c in self.prd_categories), 'impl', 'instructions')
|
|
115
|
+
|
|
116
|
+
def family(self, store: str) -> tuple[str, ...]:
|
|
117
|
+
"""Return a store plus its sub-stores (prd -> prd and all PRD categories)."""
|
|
118
|
+
return tuple(s for s in self.stores if s == store or s.startswith(store + '.'))
|
|
119
|
+
|
|
120
|
+
def store_title(self, store: str) -> str:
|
|
121
|
+
base, _, cat = store.partition('.')
|
|
122
|
+
if cat:
|
|
123
|
+
return f'Product Requirements: {cat} — {self.prd_categories[cat]}'
|
|
124
|
+
return STORE_TITLES[base]
|
|
125
|
+
|
|
126
|
+
def store_path(self, store: str) -> Path:
|
|
127
|
+
base, _, cat = store.partition('.')
|
|
128
|
+
if cat in self.category_paths:
|
|
129
|
+
return self.root / self.category_paths[cat]
|
|
130
|
+
if cat: # docs/PRD.md -> docs/prd/<cat>.md
|
|
131
|
+
return self.root / Path(self.paths.prd).parent / 'prd' / f'{cat}.md'
|
|
132
|
+
return self.root / getattr(self.paths, base)
|
|
133
|
+
|
|
134
|
+
def rel(self, path: Path) -> str:
|
|
135
|
+
return path.relative_to(self.root).as_posix()
|
|
136
|
+
|
|
137
|
+
def is_own(self, rel: str) -> bool:
|
|
138
|
+
"""Return whether a repo-relative path is diffpilot output (stores, changelog, state): never read as a source."""
|
|
139
|
+
state = self.paths.state_dir.rstrip('/')
|
|
140
|
+
own = {self.rel(self.store_path(s)) for s in (*self.stores, 'changelog')}
|
|
141
|
+
return rel in own or rel == state or rel.startswith(state + '/')
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def state(self) -> Path:
|
|
145
|
+
return self.root / self.paths.state_dir
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def openrouter_key(self) -> str:
|
|
149
|
+
return os.environ.get('OPENROUTER_API_KEY') or self.auth.openrouter_api_key
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def codex_home(self) -> Path:
|
|
153
|
+
raw = self.auth.codex_home or os.environ.get('CODEX_HOME') or '~/.codex'
|
|
154
|
+
path = Path(raw).expanduser()
|
|
155
|
+
return path if path.is_absolute() else self.root / path
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def git_ignored(cfg: Config, paths: list[str]) -> set[str]:
|
|
159
|
+
"""Repo-relative paths ignored by git: `git check-ignore`, or with [behavior].git off the root .gitignore."""
|
|
160
|
+
if not paths:
|
|
161
|
+
return set()
|
|
162
|
+
if cfg.behavior.git:
|
|
163
|
+
try:
|
|
164
|
+
r = subprocess.run(
|
|
165
|
+
['git', 'check-ignore', '--no-index', '--stdin'],
|
|
166
|
+
cwd=cfg.root,
|
|
167
|
+
input='\n'.join(paths),
|
|
168
|
+
capture_output=True,
|
|
169
|
+
text=True,
|
|
170
|
+
)
|
|
171
|
+
if r.returncode in (0, 1): # 128: not a git repository -> fall back to the pattern match
|
|
172
|
+
return set(r.stdout.split())
|
|
173
|
+
except OSError:
|
|
174
|
+
pass
|
|
175
|
+
# ponytail: root .gitignore only, negations ignored (over-ignores); nested .gitignore files are not read
|
|
176
|
+
gi = cfg.root / '.gitignore'
|
|
177
|
+
lines = gi.read_text(encoding='utf-8', errors='replace').splitlines() if gi.exists() else []
|
|
178
|
+
pats = [p.strip().strip('/') for p in lines if p.strip() and not p.lstrip().startswith(('#', '!'))]
|
|
179
|
+
|
|
180
|
+
def hit(rel: str) -> bool:
|
|
181
|
+
parts = PurePosixPath(rel).parts
|
|
182
|
+
prefixes = ['/'.join(parts[: i + 1]) for i in range(len(parts))]
|
|
183
|
+
return any(fnmatch.fnmatch(x, p) for p in pats for x in (prefixes if '/' in p else parts))
|
|
184
|
+
|
|
185
|
+
return {p for p in paths if hit(p)}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def find_root(start: Path) -> Path:
|
|
189
|
+
for parent in [start, *start.parents]:
|
|
190
|
+
if (parent / CONFIG_NAME).exists():
|
|
191
|
+
return parent
|
|
192
|
+
try:
|
|
193
|
+
out = subprocess.run(
|
|
194
|
+
['git', 'rev-parse', '--show-toplevel'], cwd=start, capture_output=True, text=True, check=True
|
|
195
|
+
)
|
|
196
|
+
return Path(out.stdout.strip())
|
|
197
|
+
except (OSError, subprocess.CalledProcessError):
|
|
198
|
+
return start
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def home_dir() -> Path:
|
|
202
|
+
"""Directory of the global diffpilot.toml, shared by all projects."""
|
|
203
|
+
return Path(os.environ.get('DIFFPILOT_HOME') or '~/.diffpilot').expanduser()
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _read_toml(path: Path) -> dict:
|
|
207
|
+
try:
|
|
208
|
+
return tomllib.loads(path.read_text(encoding='utf-8'))
|
|
209
|
+
except tomllib.TOMLDecodeError as e:
|
|
210
|
+
raise DPError(f'{path}: {e}') from e
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
MOVED = {
|
|
214
|
+
('paths', 'docs_dir'): 'removed: write full paths like prd = "docs/PRD.md"',
|
|
215
|
+
('llm', 'codex_home'): 'moved to [auth].codex_home',
|
|
216
|
+
}
|
|
217
|
+
SECTIONS = ('paths', 'prd_categories', 'auth', 'llm', 'jev', 'behavior', 'logging', 'doctor', 'verify')
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _apply(cfg: Config, path: Path) -> None:
|
|
221
|
+
data = _read_toml(path)
|
|
222
|
+
for section, values in data.items():
|
|
223
|
+
if section not in SECTIONS or not isinstance(values, dict):
|
|
224
|
+
raise DPError(f'{path}: unknown section [{section}]')
|
|
225
|
+
if section == 'prd_categories':
|
|
226
|
+
for name, desc in values.items():
|
|
227
|
+
table = isinstance(desc, dict) and set(desc) == {'scope', 'path'}
|
|
228
|
+
ok = all(isinstance(v, str) for v in (desc.values() if table else [desc]))
|
|
229
|
+
if ok and table: # a store path is a write boundary: repo-relative Markdown only
|
|
230
|
+
rel = PurePosixPath(desc['path'])
|
|
231
|
+
ok = not rel.is_absolute() and '..' not in rel.parts and rel.suffix == '.md'
|
|
232
|
+
if not CATEGORY.match(name) or not ok:
|
|
233
|
+
raise DPError(
|
|
234
|
+
f'{path}: [prd_categories].{name} must be a lowercase name = "scope description"'
|
|
235
|
+
' or { scope = "...", path = "docs/<existing>.md" }'
|
|
236
|
+
)
|
|
237
|
+
cfg.prd_categories[name] = desc['scope'] if table else desc
|
|
238
|
+
if table:
|
|
239
|
+
cfg.category_paths[name] = desc['path']
|
|
240
|
+
else:
|
|
241
|
+
cfg.category_paths.pop(name, None)
|
|
242
|
+
continue
|
|
243
|
+
obj = getattr(cfg, section)
|
|
244
|
+
known = {f.name for f in fields(obj)}
|
|
245
|
+
for key, value in values.items():
|
|
246
|
+
if key not in known:
|
|
247
|
+
hint = f' ({MOVED[section, key]})' if (section, key) in MOVED else ''
|
|
248
|
+
raise DPError(f'{path}: unknown key [{section}].{key}{hint}')
|
|
249
|
+
setattr(obj, key, value)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def load(start: Path | None = None) -> Config:
|
|
253
|
+
"""Defaults < ~/.diffpilot/diffpilot.toml (global) < <repo>/diffpilot.toml (project) < environment.
|
|
254
|
+
|
|
255
|
+
Both files accept the same sections; the project file overrides the global one key by key.
|
|
256
|
+
"""
|
|
257
|
+
root = find_root((start or Path.cwd()).resolve())
|
|
258
|
+
cfg = Config(root=root)
|
|
259
|
+
if (cfg.home / CONFIG_NAME).exists():
|
|
260
|
+
_apply(cfg, cfg.home / CONFIG_NAME)
|
|
261
|
+
path = root / CONFIG_NAME
|
|
262
|
+
if path.exists() and path.resolve() != (cfg.home / CONFIG_NAME).resolve():
|
|
263
|
+
cfg.file_exists = True
|
|
264
|
+
_apply(cfg, path)
|
|
265
|
+
env = {
|
|
266
|
+
'DIFFPILOT_BACKEND': (cfg.llm, 'backend'),
|
|
267
|
+
'DIFFPILOT_MODEL': (cfg.llm, 'model'),
|
|
268
|
+
'DIFFPILOT_FAST_MODEL': (cfg.llm, 'fast_model'),
|
|
269
|
+
'DIFFPILOT_REASONING': (cfg.llm, 'reasoning'),
|
|
270
|
+
'DIFFPILOT_LOG_LEVEL': (cfg.logging, 'level'),
|
|
271
|
+
}
|
|
272
|
+
for name, (obj, attr) in env.items():
|
|
273
|
+
if os.environ.get(name):
|
|
274
|
+
setattr(obj, attr, os.environ[name])
|
|
275
|
+
return cfg
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
DEFAULT_TOML = """\
|
|
279
|
+
# diffpilot project configuration. All keys are optional; defaults shown.
|
|
280
|
+
# Shared settings (auth, models, Jev) live in ~/.diffpilot/diffpilot.toml. Any section or key from it
|
|
281
|
+
# may be set here to override it for this project; keep secrets out of this file if it is committed.
|
|
282
|
+
|
|
283
|
+
[paths] # relative to the repository root
|
|
284
|
+
prd = "docs/PRD.md" # current product requirements (general vision)
|
|
285
|
+
impl = "docs/implementation.md" # how and why things are built
|
|
286
|
+
instructions = "docs/instructions.md" # standing rules for working on the project
|
|
287
|
+
changelog = "docs/CHANGELOG.md"
|
|
288
|
+
agents_md = "AGENTS.md"
|
|
289
|
+
state_dir = ".diffpilot"
|
|
290
|
+
|
|
291
|
+
# Optional PRD categories: details of one area go to docs/prd/<name>.md, PRD.md keeps the overview.
|
|
292
|
+
# The description tells diffpilot what belongs there. To adopt an existing spec in place (no lossy bootstrap
|
|
293
|
+
# extraction), give its path: mobs = { scope = "...", path = "docs/mobs.md" }
|
|
294
|
+
[prd_categories]
|
|
295
|
+
# mobs = "Enemies and creatures: stats, behavior, spawning, loot"
|
|
296
|
+
|
|
297
|
+
[behavior]
|
|
298
|
+
detail = "normal" # brief | normal | detailed
|
|
299
|
+
answer_budget = 600
|
|
300
|
+
context_budget = 12000 # max tokens of doc content per LLM call
|
|
301
|
+
code_access = true # ask/brief may read source files
|
|
302
|
+
language = "en"
|
|
303
|
+
agents_md_lines = 40 # target size of the "## diffpilot - resume" section
|
|
304
|
+
verify = true # review drafts before writing/answering (+1-2 turns, better results)
|
|
305
|
+
history = [] # ref globs of history sections (dated and "log"/"archive" headings are)
|
|
306
|
+
git = true # false: diffpilot never runs git (finish without diff, no diff changelog)
|
|
307
|
+
|
|
308
|
+
[doctor]
|
|
309
|
+
ignore = [] # doc globs that are not project knowledge, e.g. "marketing/**"
|
|
310
|
+
|
|
311
|
+
[verify] # `diffpilot verify`: numbers in the stores vs data files (no LLM)
|
|
312
|
+
data = [] # e.g. ["assets/data/**/*.ron", "src/constants.rs"]
|
|
313
|
+
aliases = {} # doc word -> data keys, e.g. { goal = ["kills"] }
|
|
314
|
+
"""
|
|
315
|
+
|
|
316
|
+
GLOBAL_TOML = """\
|
|
317
|
+
# diffpilot settings shared by all projects (keep this file private: it holds credentials).
|
|
318
|
+
# A project's diffpilot.toml may override any section or key.
|
|
319
|
+
|
|
320
|
+
[auth]
|
|
321
|
+
codex_home = "" # dir with Codex auth.json; empty = $CODEX_HOME or ~/.codex
|
|
322
|
+
openrouter_api_key = "" # https://openrouter.ai/settings/keys; enables Jev ($OPENROUTER_API_KEY wins)
|
|
323
|
+
|
|
324
|
+
[llm]
|
|
325
|
+
backend = "auto" # auto (Codex if logged in, else OpenRouter) | codex | openrouter
|
|
326
|
+
model = "gpt-5.6-terra" # Codex model, or an OpenRouter id such as "openai/gpt-5"
|
|
327
|
+
fast_model = "gpt-5.6-luna" # summaries / extraction; empty = same as model
|
|
328
|
+
reasoning = "medium" # low | medium | high | xhigh
|
|
329
|
+
fast_reasoning = "low"
|
|
330
|
+
timeout_s = 300
|
|
331
|
+
max_requests = 20 # per agent run (tool turns + review retries)
|
|
332
|
+
|
|
333
|
+
[jev] # TypeSafe Jev via OpenRouter: fast relevance ranking and store routing
|
|
334
|
+
enabled = true # off automatically without an OpenRouter key
|
|
335
|
+
model = "jev-latest"
|
|
336
|
+
timeout_s = 20
|
|
337
|
+
threshold = 0.3 # min relevance probability for a section to be prefetched
|
|
338
|
+
|
|
339
|
+
[logging]
|
|
340
|
+
level = "warning" # error | warning | info | debug
|
|
341
|
+
trace = false # save LLM transcripts to .diffpilot/runs/
|
|
342
|
+
"""
|
diffpilot/config.pyi
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
CONFIG_NAME: str
|
|
6
|
+
STORE_TITLES: Incomplete
|
|
7
|
+
CATEGORY: Incomplete
|
|
8
|
+
|
|
9
|
+
class DPError(Exception):
|
|
10
|
+
code: Incomplete
|
|
11
|
+
def __init__(self, message: str, code: int = 1) -> None: ...
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class Paths:
|
|
15
|
+
prd: str = ...
|
|
16
|
+
impl: str = ...
|
|
17
|
+
instructions: str = ...
|
|
18
|
+
changelog: str = ...
|
|
19
|
+
agents_md: str = ...
|
|
20
|
+
state_dir: str = ...
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class LLM:
|
|
24
|
+
backend: str = ...
|
|
25
|
+
model: str = ...
|
|
26
|
+
fast_model: str = ...
|
|
27
|
+
reasoning: str = ...
|
|
28
|
+
fast_reasoning: str = ...
|
|
29
|
+
timeout_s: int = ...
|
|
30
|
+
max_requests: int = ...
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class Auth:
|
|
34
|
+
codex_home: str = ...
|
|
35
|
+
openrouter_api_key: str = ...
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class Jev:
|
|
39
|
+
enabled: bool = ...
|
|
40
|
+
model: str = ...
|
|
41
|
+
timeout_s: int = ...
|
|
42
|
+
threshold: float = ...
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class Behavior:
|
|
46
|
+
detail: str = ...
|
|
47
|
+
answer_budget: int = ...
|
|
48
|
+
context_budget: int = ...
|
|
49
|
+
code_access: bool = ...
|
|
50
|
+
language: str = ...
|
|
51
|
+
agents_md_lines: int = ...
|
|
52
|
+
verify: bool = ...
|
|
53
|
+
history: list[str] = field(default_factory=list)
|
|
54
|
+
git: bool = ...
|
|
55
|
+
|
|
56
|
+
@dataclass
|
|
57
|
+
class Verify:
|
|
58
|
+
data: list[str] = field(default_factory=list)
|
|
59
|
+
aliases: dict[str, list[str]] = field(default_factory=dict)
|
|
60
|
+
|
|
61
|
+
@dataclass
|
|
62
|
+
class Doctor:
|
|
63
|
+
ignore: list[str] = field(default_factory=list)
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class Logging:
|
|
67
|
+
level: str = ...
|
|
68
|
+
trace: bool = ...
|
|
69
|
+
|
|
70
|
+
@dataclass
|
|
71
|
+
class Config:
|
|
72
|
+
root: Path
|
|
73
|
+
paths: Paths = field(default_factory=Paths)
|
|
74
|
+
auth: Auth = field(default_factory=Auth)
|
|
75
|
+
llm: LLM = field(default_factory=LLM)
|
|
76
|
+
jev: Jev = field(default_factory=Jev)
|
|
77
|
+
behavior: Behavior = field(default_factory=Behavior)
|
|
78
|
+
logging: Logging = field(default_factory=Logging)
|
|
79
|
+
doctor: Doctor = field(default_factory=Doctor)
|
|
80
|
+
verify: Verify = field(default_factory=Verify)
|
|
81
|
+
prd_categories: dict[str, str] = field(default_factory=dict)
|
|
82
|
+
category_paths: dict[str, str] = field(default_factory=dict)
|
|
83
|
+
home: Path = field(default_factory=Incomplete)
|
|
84
|
+
file_exists: bool = ...
|
|
85
|
+
@property
|
|
86
|
+
def stores(self) -> tuple[str, ...]: ...
|
|
87
|
+
def family(self, store: str) -> tuple[str, ...]: ...
|
|
88
|
+
def store_title(self, store: str) -> str: ...
|
|
89
|
+
def store_path(self, store: str) -> Path: ...
|
|
90
|
+
def rel(self, path: Path) -> str: ...
|
|
91
|
+
def is_own(self, rel: str) -> bool: ...
|
|
92
|
+
@property
|
|
93
|
+
def state(self) -> Path: ...
|
|
94
|
+
@property
|
|
95
|
+
def openrouter_key(self) -> str: ...
|
|
96
|
+
@property
|
|
97
|
+
def codex_home(self) -> Path: ...
|
|
98
|
+
|
|
99
|
+
def git_ignored(cfg: Config, paths: list[str]) -> set[str]: ...
|
|
100
|
+
def find_root(start: Path) -> Path: ...
|
|
101
|
+
def home_dir() -> Path: ...
|
|
102
|
+
|
|
103
|
+
MOVED: Incomplete
|
|
104
|
+
SECTIONS: Incomplete
|
|
105
|
+
|
|
106
|
+
def load(start: Path | None = None) -> Config: ...
|
|
107
|
+
|
|
108
|
+
DEFAULT_TOML: str
|
|
109
|
+
GLOBAL_TOML: str
|