Files
nisse/nisse-dev/src/nisse_dev/main.py
T
dongarandClaude Opus 5.5 f84bb70839
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m44s
The new loop's core: intake, restatement, go-ahead, threads (M2.1, PR B)
nisse_dev.loop runs alongside control.py, chosen with `loop: new`.
Issues assigned to the agent (by an operator, or filed by one) become work
items, each with a Matrix thread. A driver run is one model with tools
until it calls a waiting tool: restate puts rev-N up for a go-ahead, bound
to the revision on screen when the reply arrived; ask_human waits for an
answer; close_item closes the item and its issue. Before the go-ahead the
driver can look but not change or close anything. One item is active at a
time; replies in an item's thread go to it. On boot, an item cut off
mid-run waits on the operator, and waiting points are put up again.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
2026-10-02 23:46:42 +00:00

52 lines
1.4 KiB
Python

"""Entry point for the dev agent.
Loads configuration, builds the agent, and stays up until told to stop.
Shutdown is deliberate rather than abrupt: L8's durability guarantees assume
the process may die at any moment, but a clean stop still beats relying on
them.
"""
import os
import signal
import sys
from pathlib import Path
from types import FrameType
from nisse_dev.agent import build_agent
from nisse_dev.config import AgentConfig, ConfigError
from nisse_dev.envfile import load_env_file
def main() -> int:
load_env_file(Path(os.environ.get("NISSE_ENV", ".env")).expanduser())
try:
config = AgentConfig.load()
except ConfigError as exc:
# Fail here rather than twenty minutes into a milestone on the one
# call that needed the missing value.
print(f"nisse-dev: {exc}", file=sys.stderr)
return 2
if config.loop == "new":
from nisse_dev.loop.build import build_loop_agent
agent = build_loop_agent(config)
else:
agent = build_agent(config)
def shutdown(_signum: int, _frame: FrameType | None) -> None:
print("nisse-dev: stopping", file=sys.stderr)
agent.stop()
signal.signal(signal.SIGINT, shutdown)
signal.signal(signal.SIGTERM, shutdown)
agent.start()
print(f"nisse-dev: ready as {agent.account} on {config.project}", file=sys.stderr)
agent.wait()
return 0
if __name__ == "__main__":
raise SystemExit(main())