forked from retoor/devplacepy
chore: add retoor header to all devplacepy source files and update style agent header rule
The diff adds the mandatory `retoor <retoor@molodetz.nl>` header comment to every `.py` file under `devplacepy/` (including `__init__.py` and `routers/__init__.py`), and updates the `StyleAgent` in `agents/style.py` to instruct agents to only add the header on created or already-edited files rather than sweeping the entire repo. The `agents/base.py` operating protocol is also revised to reorder and clarify tool discipline rules.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from devplacepy.services.base import BaseService
|
||||
from devplacepy.services.manager import service_manager
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from devplacepy.services.bot.service import BotsService
|
||||
|
||||
__all__ = ["BotsService"]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
import hashlib
|
||||
import logging
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import random
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import random
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import json
|
||||
import logging
|
||||
import random
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import fcntl
|
||||
import json
|
||||
import logging
|
||||
@@ -44,7 +46,7 @@ class ArticleRegistry:
|
||||
fd = os.open(str(self.path), os.O_RDWR | os.O_CREAT)
|
||||
fcntl.flock(fd, fcntl.LOCK_EX)
|
||||
data = {}
|
||||
if os.path.getsize(str(self.path)) > 0:
|
||||
if self.path.stat().st_size > 0:
|
||||
chunks = []
|
||||
while True:
|
||||
chunk = os.read(fd, 65536)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
import importlib
|
||||
import logging
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -123,8 +123,6 @@ async def _bootstrap_auth(client: PlatformClient, settings: Settings) -> str:
|
||||
|
||||
|
||||
def _resolve_owner(settings: Settings) -> tuple[str, str]:
|
||||
"""Resolve the local DevPlace user behind the CLI's credentials so the CLI shares the
|
||||
same per-user memory, tasks, and admin analytics as the web session for that account."""
|
||||
try:
|
||||
from devplacepy.database import db, get_table
|
||||
|
||||
|
||||
@@ -56,8 +56,6 @@ NAT64_PREFIXES = (
|
||||
|
||||
|
||||
def _effective_address(address: Any) -> Any:
|
||||
"""Resolve NAT64 / IPv4-mapped IPv6 to the embedded IPv4 so DNS64 networks
|
||||
don't make public sites look like reserved addresses."""
|
||||
if isinstance(address, ipaddress.IPv6Address):
|
||||
if address.ipv4_mapped is not None:
|
||||
return address.ipv4_mapped
|
||||
|
||||
@@ -6,27 +6,33 @@ import shutil
|
||||
import sys
|
||||
import zipfile
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
FIXED_DATE = (1980, 1, 1, 0, 0, 0)
|
||||
|
||||
CHUNK_SIZE = 1024 * 1024
|
||||
|
||||
|
||||
def _build(source_dir: str, output_path: str) -> dict:
|
||||
bytes_in = 0
|
||||
file_count = 0
|
||||
dir_count = 0
|
||||
source_path = Path(source_dir)
|
||||
output_path_obj = Path(output_path)
|
||||
with zipfile.ZipFile(output_path, "w", zipfile.ZIP_DEFLATED) as archive:
|
||||
for root, dirs, files in os.walk(source_dir):
|
||||
dirs.sort()
|
||||
root_path = Path(root)
|
||||
for name in dirs:
|
||||
dir_count += 1
|
||||
arcname = os.path.relpath(os.path.join(root, name), source_dir) + "/"
|
||||
arcname = str(Path(root_path / name).relative_to(source_path)) + "/"
|
||||
info = zipfile.ZipInfo(arcname, date_time=FIXED_DATE)
|
||||
info.external_attr = (0o040755 << 16) | 0x10
|
||||
archive.writestr(info, b"")
|
||||
for name in sorted(files):
|
||||
full = os.path.join(root, name)
|
||||
arcname = os.path.relpath(full, source_dir)
|
||||
bytes_in += os.path.getsize(full)
|
||||
full = str(root_path / name)
|
||||
arcname = str(Path(full).relative_to(source_path))
|
||||
bytes_in += Path(full).stat().st_size
|
||||
info = zipfile.ZipInfo(arcname, date_time=FIXED_DATE)
|
||||
info.compress_type = zipfile.ZIP_DEFLATED
|
||||
info.external_attr = 0o644 << 16
|
||||
@@ -36,12 +42,12 @@ def _build(source_dir: str, output_path: str) -> dict:
|
||||
|
||||
crc = 0
|
||||
with open(output_path, "rb") as handle:
|
||||
for chunk in iter(lambda: handle.read(1024 * 1024), b""):
|
||||
for chunk in iter(lambda: handle.read(CHUNK_SIZE), b""):
|
||||
crc = zlib.crc32(chunk, crc)
|
||||
|
||||
return {
|
||||
"bytes_in": bytes_in,
|
||||
"bytes_out": os.path.getsize(output_path),
|
||||
"bytes_out": output_path_obj.stat().st_size,
|
||||
"file_count": file_count,
|
||||
"dir_count": dir_count,
|
||||
"crc32": crc & 0xFFFFFFFF,
|
||||
@@ -53,7 +59,7 @@ def main(argv: list) -> int:
|
||||
sys.stderr.write("usage: zip_worker <source_dir> <output_zip>\n")
|
||||
return 2
|
||||
source_dir, output_path = argv[1], argv[2]
|
||||
if not os.path.isdir(source_dir):
|
||||
if not Path(source_dir).is_dir():
|
||||
sys.stderr.write(f"source directory not found: {source_dir}\n")
|
||||
return 3
|
||||
stats = _build(source_dir, output_path)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from devplacepy.services.openai_gateway.service import GatewayService
|
||||
|
||||
__all__ = ["GatewayService"]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
UPSTREAM_URL_DEFAULT = "https://api.deepseek.com/chat/completions"
|
||||
MODEL_DEFAULT = "deepseek-v4-flash"
|
||||
TIMEOUT_DEFAULT = 300
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
import hashlib
|
||||
import logging
|
||||
|
||||
Reference in New Issue
Block a user