From 86efeeeac84ee04b6c73b38b61cbfd35244e624e Mon Sep 17 00:00:00 2001 From: Boris Date: Mon, 19 May 2025 11:38:01 +0200 Subject: [PATCH 1/3] fix: pipeline run status migration (#836) ## Description ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --- .../1d0bb7fede17_add_pipeline_run_status.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 alembic/versions/1d0bb7fede17_add_pipeline_run_status.py diff --git a/alembic/versions/1d0bb7fede17_add_pipeline_run_status.py b/alembic/versions/1d0bb7fede17_add_pipeline_run_status.py new file mode 100644 index 000000000..fe1fb689b --- /dev/null +++ b/alembic/versions/1d0bb7fede17_add_pipeline_run_status.py @@ -0,0 +1,39 @@ +"""Add pipeline run status + +Revision ID: 1d0bb7fede17 +Revises: 482cd6517ce4 +Create Date: 2025-05-19 10:58:15.993314 + +""" + +from typing import Sequence, Union + +from alembic import op + +from cognee.infrastructure.databases.relational.get_relational_engine import get_relational_engine +from cognee.modules.pipelines.models.PipelineRun import PipelineRun, PipelineRunStatus + + +# revision identifiers, used by Alembic. +revision: str = "1d0bb7fede17" +down_revision: Union[str, None] = "482cd6517ce4" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +async def upgrade() -> None: + db_engine = get_relational_engine() + + if db_engine.engine.dialect.name == "postgresql": + op.execute( + f"ALTER TYPE {PipelineRun.status} ADD VALUE IF NOT EXISTS '{str(PipelineRunStatus.DATASET_PROCESSING_INITIATED)}'" + ) + else: + op.execute(f""" + ALTER TABLE {PipelineRun} + MODIFY COLUMN {PipelineRun.status} ENUM('{PipelineRunStatus.DATASET_PROCESSING_INITIATED}', '{PipelineRunStatus.DATASET_PROCESSING_STARTED}', '{PipelineRunStatus.DATASET_PROCESSING_COMPLETED}', '{PipelineRunStatus.DATASET_PROCESSING_ERRORED}') NOT NULL + """) + + +def downgrade() -> None: + pass From 3ed9504375b9795d25a86791891a6d43d770ecda Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Mon, 19 May 2025 13:16:58 +0200 Subject: [PATCH 2/3] feat: Add developer rules (#833) ## Description ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --- cognee-mcp/src/server.py | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/cognee-mcp/src/server.py b/cognee-mcp/src/server.py index 6a0ff41d0..fffbaf223 100755 --- a/cognee-mcp/src/server.py +++ b/cognee-mcp/src/server.py @@ -23,6 +23,87 @@ logger = get_logger() log_file = get_log_file_location() +@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.add(file_path, nodeset="developer_rules") + model = KnowledgeGraph + if graph_model_file and graph_model_name: + model = load_class(graph_model_file, graph_model_name) + await cognee.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)}") + + 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}") + + 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() async def cognify(data: str, graph_model_file: str = None, graph_model_name: str = None) -> list: """ From a874988db68c7024f4f359916fc939974759f495 Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Mon, 19 May 2025 13:18:36 +0200 Subject: [PATCH 3/3] fix: Fixes pipeline run status migration (#838) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …exist case ## Description Fixes pipeline run status migration ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --- .../1d0bb7fede17_add_pipeline_run_status.py | 14 ++++---------- alembic/versions/482cd6517ce4_add_default_user.py | 5 ++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/alembic/versions/1d0bb7fede17_add_pipeline_run_status.py b/alembic/versions/1d0bb7fede17_add_pipeline_run_status.py index fe1fb689b..5e0e99dba 100644 --- a/alembic/versions/1d0bb7fede17_add_pipeline_run_status.py +++ b/alembic/versions/1d0bb7fede17_add_pipeline_run_status.py @@ -1,9 +1,8 @@ -"""Add pipeline run status +"""Add pipeline run status Revision ID: 1d0bb7fede17 Revises: 482cd6517ce4 Create Date: 2025-05-19 10:58:15.993314 - """ from typing import Sequence, Union @@ -18,21 +17,16 @@ from cognee.modules.pipelines.models.PipelineRun import PipelineRun, PipelineRun revision: str = "1d0bb7fede17" down_revision: Union[str, None] = "482cd6517ce4" branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = "482cd6517ce4" -async def upgrade() -> None: +def upgrade() -> None: db_engine = get_relational_engine() if db_engine.engine.dialect.name == "postgresql": op.execute( - f"ALTER TYPE {PipelineRun.status} ADD VALUE IF NOT EXISTS '{str(PipelineRunStatus.DATASET_PROCESSING_INITIATED)}'" + "ALTER TYPE pipelinerunstatus ADD VALUE IF NOT EXISTS 'DATASET_PROCESSING_INITIATED'" ) - else: - op.execute(f""" - ALTER TABLE {PipelineRun} - MODIFY COLUMN {PipelineRun.status} ENUM('{PipelineRunStatus.DATASET_PROCESSING_INITIATED}', '{PipelineRunStatus.DATASET_PROCESSING_STARTED}', '{PipelineRunStatus.DATASET_PROCESSING_COMPLETED}', '{PipelineRunStatus.DATASET_PROCESSING_ERRORED}') NOT NULL - """) def downgrade() -> None: diff --git a/alembic/versions/482cd6517ce4_add_default_user.py b/alembic/versions/482cd6517ce4_add_default_user.py index 92429e1e4..078dce7fd 100644 --- a/alembic/versions/482cd6517ce4_add_default_user.py +++ b/alembic/versions/482cd6517ce4_add_default_user.py @@ -21,7 +21,10 @@ depends_on: Union[str, Sequence[str], None] = "8057ae7329c2" def upgrade() -> None: - await_only(create_default_user()) + try: + await_only(create_default_user()) + except Exception: + pass def downgrade() -> None: