fix: remove add_ and get_developer_rules
This commit is contained in:
parent
18e4bb48fd
commit
21b1f6b39c
1 changed files with 0 additions and 130 deletions
|
|
@ -90,97 +90,6 @@ async def health_check(request):
|
||||||
return JSONResponse({"status": "ok"})
|
return JSONResponse({"status": "ok"})
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
|
||||||
async def cognee_add_developer_rules(
|
|
||||||
base_path: str = ".", graph_model_file: str = None, graph_model_name: str = None
|
|
||||||
) -> list:
|
|
||||||
"""
|
|
||||||
Ingest core developer rule files into Cognee's memory layer.
|
|
||||||
|
|
||||||
This function loads a predefined set of developer-related configuration,
|
|
||||||
rule, and documentation files from the base repository and assigns them
|
|
||||||
to the special 'developer_rules' node set in Cognee. It ensures these
|
|
||||||
foundational files are always part of the structured memory graph.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
base_path : str
|
|
||||||
Root path to resolve relative file paths. Defaults to current directory.
|
|
||||||
|
|
||||||
graph_model_file : str, optional
|
|
||||||
Optional path to a custom schema file for knowledge graph generation.
|
|
||||||
|
|
||||||
graph_model_name : str, optional
|
|
||||||
Optional class name to use from the graph_model_file schema.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
list
|
|
||||||
A message indicating how many rule files were scheduled for ingestion,
|
|
||||||
and how to check their processing status.
|
|
||||||
|
|
||||||
Notes
|
|
||||||
-----
|
|
||||||
- Each file is processed asynchronously in the background.
|
|
||||||
- Files are attached to the 'developer_rules' node set.
|
|
||||||
- Missing files are skipped with a logged warning.
|
|
||||||
"""
|
|
||||||
|
|
||||||
developer_rule_paths = [
|
|
||||||
".cursorrules",
|
|
||||||
".cursor/rules",
|
|
||||||
".same/todos.md",
|
|
||||||
".windsurfrules",
|
|
||||||
".clinerules",
|
|
||||||
"CLAUDE.md",
|
|
||||||
".sourcegraph/memory.md",
|
|
||||||
"AGENT.md",
|
|
||||||
"AGENTS.md",
|
|
||||||
]
|
|
||||||
|
|
||||||
async def cognify_task(file_path: str) -> None:
|
|
||||||
with redirect_stdout(sys.stderr):
|
|
||||||
logger.info(f"Starting cognify for: {file_path}")
|
|
||||||
try:
|
|
||||||
await cognee_client.add(file_path, node_set=["developer_rules"])
|
|
||||||
|
|
||||||
model = None
|
|
||||||
if graph_model_file and graph_model_name:
|
|
||||||
if cognee_client.use_api:
|
|
||||||
logger.warning(
|
|
||||||
"Custom graph models are not supported in API mode, ignoring."
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
from cognee.shared.data_models import KnowledgeGraph
|
|
||||||
|
|
||||||
model = load_class(graph_model_file, graph_model_name)
|
|
||||||
|
|
||||||
await cognee_client.cognify(graph_model=model)
|
|
||||||
logger.info(f"Cognify finished for: {file_path}")
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Cognify failed for {file_path}: {str(e)}")
|
|
||||||
raise ValueError(f"Failed to cognify: {str(e)}")
|
|
||||||
|
|
||||||
tasks = []
|
|
||||||
for rel_path in developer_rule_paths:
|
|
||||||
abs_path = os.path.join(base_path, rel_path)
|
|
||||||
if os.path.isfile(abs_path):
|
|
||||||
tasks.append(asyncio.create_task(cognify_task(abs_path)))
|
|
||||||
else:
|
|
||||||
logger.warning(f"Skipped missing developer rule file: {abs_path}")
|
|
||||||
log_file = get_log_file_location()
|
|
||||||
return [
|
|
||||||
types.TextContent(
|
|
||||||
type="text",
|
|
||||||
text=(
|
|
||||||
f"Started cognify for {len(tasks)} developer rule files in background.\n"
|
|
||||||
f"All are added to the `developer_rules` node set.\n"
|
|
||||||
f"Use `cognify_status` or check logs at {log_file} to monitor progress."
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def cognify(
|
async def cognify(
|
||||||
data: str, graph_model_file: str = None, graph_model_name: str = None, custom_prompt: str = None
|
data: str, graph_model_file: str = None, graph_model_name: str = None, custom_prompt: str = None
|
||||||
|
|
@ -561,45 +470,6 @@ async def search(search_query: str, search_type: str) -> list:
|
||||||
return [types.TextContent(type="text", text=search_results)]
|
return [types.TextContent(type="text", text=search_results)]
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
|
||||||
async def get_developer_rules() -> list:
|
|
||||||
"""
|
|
||||||
Retrieve all developer rules that were generated based on previous interactions.
|
|
||||||
|
|
||||||
This tool queries the Cognee knowledge graph and returns a list of developer
|
|
||||||
rules.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
list
|
|
||||||
A list containing a single TextContent object with the retrieved developer rules.
|
|
||||||
The format is plain text containing the developer rules in bulletpoints.
|
|
||||||
|
|
||||||
Notes
|
|
||||||
-----
|
|
||||||
- The specific logic for fetching rules is handled internally.
|
|
||||||
- This tool does not accept any parameters and is intended for simple rule inspection use cases.
|
|
||||||
"""
|
|
||||||
|
|
||||||
async def fetch_rules_from_cognee() -> str:
|
|
||||||
"""Collect all developer rules from Cognee"""
|
|
||||||
with redirect_stdout(sys.stderr):
|
|
||||||
if cognee_client.use_api:
|
|
||||||
logger.warning("Developer rules retrieval is not available in API mode")
|
|
||||||
return "Developer rules retrieval is not available in API mode"
|
|
||||||
|
|
||||||
developer_rules = await get_existing_rules(rules_nodeset_name="coding_agent_rules")
|
|
||||||
return developer_rules
|
|
||||||
|
|
||||||
rules_text = await fetch_rules_from_cognee()
|
|
||||||
|
|
||||||
return [types.TextContent(type="text", text=rules_text)]
|
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def list_data(dataset_id: str = None) -> list:
|
async def list_data(dataset_id: str = None) -> list:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue