From 678d891b42d72770025df2e11ff0f40beb0371fb Mon Sep 17 00:00:00 2001 From: KaifAhmad1 Date: Wed, 8 Apr 2026 22:54:26 +0530 Subject: [PATCH] Fix plugin hooks JSON, align Skill docs with repo API, and make skill generation portable --- plugins/.claude-plugin/README.md | 1 - plugins/hooks/hooks.json | 3 ++- plugins/skills/deduplicate/SKILL.md | 18 ++++++++++------- plugins/skills/export/SKILL.md | 30 +++++++++++++++++++++++------ plugins/skills/ingest/SKILL.md | 9 +++++---- write_missing_skills.py | 7 +++++-- 6 files changed, 47 insertions(+), 21 deletions(-) diff --git a/plugins/.claude-plugin/README.md b/plugins/.claude-plugin/README.md index 50349b42..96e2b412 100644 --- a/plugins/.claude-plugin/README.md +++ b/plugins/.claude-plugin/README.md @@ -16,7 +16,6 @@ This folder contains the plugin metadata for the Semantica Claude/Cursor/Codex p ```bash /plugin marketplace add /semantica ``` -``` ## Supported platforms diff --git a/plugins/hooks/hooks.json b/plugins/hooks/hooks.json index 80393528..eb7d9d28 100644 --- a/plugins/hooks/hooks.json +++ b/plugins/hooks/hooks.json @@ -1,7 +1,8 @@ { "hooks": { "PostToolUse": [ - {"matcher": "Write|Edit", "hooks": [{"type": "command", "command": "FILE=$(jq -r .tool_input.file_path 2>/dev/null); if echo $FILE | grep -qE semantica/; then python -c "import ast,sys; ast.parse(open(sys.argv[1]).read())" $FILE 2>&1; fi"}]}, + {"matcher": "Write|Edit", "hooks": [{"type": "command", "command": "FILE=$(jq -r .tool_input.file_path 2>/dev/null); if echo $FILE | grep -qE semantica/; then python -c 'import ast,sys; ast.parse(open(sys.argv[1]).read())' $FILE 2>&1; fi"}]}, + {"matcher": "Write|Edit", "hooks": [{"type": "command", "command": "echo PostToolUse provenance check"}]} ], "PreToolUse": [ diff --git a/plugins/skills/deduplicate/SKILL.md b/plugins/skills/deduplicate/SKILL.md index 7ce2abf7..bfcaedaf 100644 --- a/plugins/skills/deduplicate/SKILL.md +++ b/plugins/skills/deduplicate/SKILL.md @@ -1,6 +1,6 @@ --- name: deduplicate -description: Identify and merge duplicate entities, relations, and graph objects in Semantica using fuzzy matching, schema heuristics, and graph similarity. +description: Detect duplicate entities, duplicate groups, and relationship duplicates in Semantica using fuzzy matching, schema heuristics, and graph similarity. --- # /semantica:deduplicate @@ -13,25 +13,29 @@ Remove duplicates from the knowledge graph. Usage: `/semantica:deduplicate ] [--field ]` -Find and merge duplicate entities. +Detect duplicate entities and group them by similarity. ```python from semantica.deduplication import DuplicateDetector finder = DuplicateDetector() -merged = finder.merge_duplicates(entity_type=entity_type, threshold=threshold) +candidates = finder.detect_duplicates(entities, threshold=threshold) +groups = finder.detect_duplicate_groups(entities, threshold=threshold) ``` -Output: merged entity IDs, discarded duplicates, and merge confidence. +Output: duplicate candidate list, duplicate groups, and representative merge recommendations. --- ## `relations [--similarity ]` -Detect duplicate relationships and normalize edges. +Detect duplicate relationships and normalize edge representations. ```python -relations = finder.find_duplicate_relations(similarity=similarity) +from semantica.deduplication import DuplicateDetector + +finder = DuplicateDetector() +relations = finder.detect_duplicates(relation_list, threshold=similarity) ``` -Result: relation clusters, normalized relation set, and cleanup summary. +Result: duplicate relation candidates, normalized relationship groups, and cleanup summary. diff --git a/plugins/skills/export/SKILL.md b/plugins/skills/export/SKILL.md index 8fbe27d6..e53b5a6b 100644 --- a/plugins/skills/export/SKILL.md +++ b/plugins/skills/export/SKILL.md @@ -16,22 +16,23 @@ Export knowledge graph data. Usage: `/semantica:export [args]` Export graph data as JSON. ```python -from semantica.export import GraphExporter +from semantica.export.methods import export_json -exporter = GraphExporter() -exporter.export_json(output_path=output, filter_query=filter_query) +export_json(data=graph_data, file_path=output, format='json') ``` Output: JSON file or inline JSON payload. --- -## `rdf [--format turtle|xml|ntriples] [--output ]` +## `rdf [--format turtle|rdfxml|jsonld|ntriples|n3] [--output ]` Export the graph in RDF serialization. ```python -exporter.export_rdf(format='turtle', output_path=output) +from semantica.export.methods import export_rdf + +export_rdf(data=graph_data, file_path=output, format='turtle') ``` Return: RDF text or file path. @@ -43,7 +44,24 @@ Return: RDF text or file path. Export nodes and edges to Parquet for analytics. ```python -exporter.export_parquet(output_path=output) +from semantica.export.methods import export_parquet + +export_parquet(data=graph_data, file_path=output, compression='snappy') ``` Output: Parquet dataset ready for downstream processing. + +--- + +## `graphml|gexf|dot [--output ]` + +Export the graph to a supported graph format. + +```python +from semantica.export import GraphExporter + +exporter = GraphExporter(format='graphml', include_attributes=True) +exporter.export(graph_data, output) +``` + +Output: Graph format file suitable for visualization tools. diff --git a/plugins/skills/ingest/SKILL.md b/plugins/skills/ingest/SKILL.md index b7a016c4..065cbf9c 100644 --- a/plugins/skills/ingest/SKILL.md +++ b/plugins/skills/ingest/SKILL.md @@ -16,10 +16,9 @@ Ingest new data into the knowledge graph. Usage: `/semantica:ingest [ar Ingest structured data from a local file. ```python -from semantica.ingest import DataIngestor +from semantica.ingest import ingest_file -ingestor = DataIngestor() -ingestor.ingest_file(file_path=path, file_format=file_format) +data = ingest_file(file_path=path, method='file', file_format=file_format) ``` Output: imported node/edge count and ingestion summary. @@ -31,7 +30,9 @@ Output: imported node/edge count and ingestion summary. Ingest data from a database source. ```python -ingestor.ingest_database(connection_string=conn, query=query) +from semantica.ingest import ingest_database + +result = ingest_database(connection_string=conn, query=query) ``` Return: rows ingested, mapped entities, and warnings. diff --git a/write_missing_skills.py b/write_missing_skills.py index ffbf291d..6ff96067 100644 --- a/write_missing_skills.py +++ b/write_missing_skills.py @@ -1,6 +1,9 @@ import os -base = r'c:\Users\Mohd Kaif\semantica\plugins\skills' +base = os.getenv( + 'SKILLS_OUT_DIR', + os.path.join(os.path.dirname(os.path.abspath(__file__)), 'plugins', 'skills') +) SKILLS = {} @@ -1025,7 +1028,7 @@ Flag as WARNING if gap rate > 5%. for skill_name, content in SKILLS.items(): path = os.path.join(base, skill_name, 'SKILL.md') os.makedirs(os.path.dirname(path), exist_ok=True) - with open(path, 'w') as f: + with open(path, 'w', encoding='utf-8', newline='\n') as f: f.write(content) print(f'written: {skill_name}')