feat(rulebook): augment get_project with applicable_rules + MCP instructions
This commit is contained in:
@@ -20,6 +20,16 @@ Hierarchy: Project -> Milestone -> Task/Note.
|
||||
unchanged on updates.
|
||||
- For optional integer FKs (project_id, milestone_id, parent_id), use 0 to mean
|
||||
"not set".
|
||||
|
||||
Scribe maintains a Rulebook system (Rulebook -> Topic -> Rule). Rules carry
|
||||
an actionable statement plus optional Why and How-to-apply context. When you
|
||||
start work on a project, get_project(id) returns applicable_rules (the rules
|
||||
from rulebooks the project subscribes to) and subscribed_rulebooks. Consult
|
||||
these before making decisions about workflow, conventions, or scope. Full
|
||||
text (Why / How-to-apply) is available via get_rule(id). You may create new
|
||||
rules via create_rule when you notice a pattern worth codifying — coordinate
|
||||
with the operator on whether it belongs in an existing rulebook+topic or a
|
||||
new one.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ from __future__ import annotations
|
||||
from fabledassistant.mcp._context import current_user_id
|
||||
from fabledassistant.services import milestones as milestones_svc
|
||||
from fabledassistant.services import projects as projects_svc
|
||||
from fabledassistant.services import rulebooks as rulebooks_svc
|
||||
|
||||
|
||||
async def list_projects() -> dict:
|
||||
@@ -33,10 +34,11 @@ async def list_projects() -> dict:
|
||||
|
||||
|
||||
async def get_project(project_id: int) -> dict:
|
||||
"""Fetch a Scribe project by ID, including its milestone summary.
|
||||
"""Fetch a Scribe project by ID.
|
||||
|
||||
Returns full project fields plus a milestone_summary list with each
|
||||
milestone's id, title, status, and task counts.
|
||||
Returns full project fields, a milestone_summary list, and the
|
||||
rulebook-applicable_rules / subscribed_rulebooks pair the assistant
|
||||
should consult when working on this project.
|
||||
"""
|
||||
uid = current_user_id()
|
||||
project = await projects_svc.get_project(uid, project_id)
|
||||
@@ -46,6 +48,12 @@ async def get_project(project_id: int) -> dict:
|
||||
data["milestone_summary"] = await milestones_svc.get_project_milestone_summary(
|
||||
uid, project_id,
|
||||
)
|
||||
applicable = await rulebooks_svc.get_applicable_rules(
|
||||
project_id=project_id, user_id=uid,
|
||||
)
|
||||
data["applicable_rules"] = applicable["rules"]
|
||||
data["applicable_rules_truncated"] = applicable["truncated"]
|
||||
data["subscribed_rulebooks"] = applicable["subscribed_rulebooks"]
|
||||
return data
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user