Add app agents list and prompt, and document prompts for the seed agents

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-29 16:20:23 +02:00
1 parent 4e3c3f130e
commit 2534803df3
3 files changed
+106 -6

No files matched your search

+61
View File
@@ -5,6 +5,7 @@
app worker [--workers http=8,cpu=1] [--until-idle]
app companies seed|add|set-board|detach|discover|check
app searches add|list|remove
app agents list|prompt
app stages [extract|summarise on|off]
app db init
@@ -110,6 +111,17 @@ def build_parser() -> argparse.ArgumentParser:
"remove", help="stop running a search and close its open roles")
search_remove.add_argument("name")
agents = sub.add_parser("agents", help="search agents and their prompts")
agents_sub = agents.add_subparsers(dest="action", required=True)
agents_sub.add_parser("list", help="every agent and its prompts")
prompt = agents_sub.add_parser(
"prompt", help="add a prompt to an agent, replace its text, or --remove it")
prompt.add_argument("agent", help="the agent's name")
prompt.add_argument("name", help='the prompt\'s name, e.g. "AI leadership"')
prompt.add_argument("text", nargs="?", default="",
help="what the agent looks for, in a sentence or a paragraph")
prompt.add_argument("--remove", action="store_true", help="remove the prompt instead")
stages = sub.add_parser(
"stages", help="show whether extract and summarise run, or switch one")
stages.add_argument("name", nargs="?", choices=["extract", "summarise"])
@@ -135,6 +147,8 @@ def main(argv: list[str] | None = None) -> int:
return run_companies(args)
if args.command == "searches":
return run_searches(args)
if args.command == "agents":
return run_agents(args)
if args.command == "stages":
return run_stages(args)
return init_db(args)
@@ -420,6 +434,53 @@ def add_search(config: config_mod.Config, store: Store, args: argparse.Namespace
return 0
def run_agents(args: argparse.Namespace) -> int:
"""`app agents list` prints every agent and its prompts. `app agents
prompt "Wolf, next role" "AI leadership" "Head of AI ..."` adds that
prompt at the end, or replaces the text of the one of that name in its
place; `--remove` removes it. The agent's other fields stay as they are.
Scores follow at the next `score`."""
from app.models import Prompt
from app.storage import Store
config = config_mod.load(args.config)
store = Store(config.database)
if args.action == "list":
for each in store.agents():
print(each.name + ("" if each.enabled else " (off)"))
for p in each.prompts:
text = " ".join(p.text.split())
print(f" {p.name}: {text[:100] + '…' if len(text) > 100 else text}")
return 0
agent = next((a for a in store.agents() if a.name == args.agent), None)
if agent is None:
print(f"agents prompt: no agent named {args.agent!r}", file=sys.stderr)
return 1
named = args.name.strip().casefold()
prompts = [p for p in agent.prompts if not (args.remove and p.name.casefold() == named)]
if args.remove and len(prompts) == len(agent.prompts):
print(f"agents prompt: {agent.name!r} has no prompt named {args.name!r}",
file=sys.stderr)
return 1
if not args.remove:
try:
new = Prompt(name=args.name, text=args.text)
except ValueError as exc:
print(f"agents prompt: {exc}", file=sys.stderr)
return 1
at = next((n for n, p in enumerate(prompts) if p.name.casefold() == named), None)
if at is None:
prompts.append(new)
else:
prompts[at] = new
saved = store.save_agent(agent.name, gates=agent.gates, weights=agent.weights,
enabled=agent.enabled, agent_id=agent.id, limits=agent.limits,
prompts=prompts)
print(json.dumps({"agent": saved.name, "prompts": [p.name for p in saved.prompts]},
ensure_ascii=False))
return 0
def run_stages(args: argparse.Namespace) -> int:
"""`app stages` prints what `GET /api/stages` returns; `app stages extract
on` stores the switch through the function `PUT /api/stages/extract`