SuperAPI AI Directory

im-wiki-extractor

General & other

View repository

Updated 10-15 17:31

About this skill

Agent Skill: im-wiki-extractor (Group Chat Knowledge Graph Extractor)

1. Overview

This skill is designed to transform unstructured chat records (such as group chat history) into a structured knowledge graph stored in the repository generated by memories-off Agent Skill. It emphasizes a "gradual incremental" processing approach, using a "sliding window" of 100 lines at a time to process super-long logs, thereby avoiding model context limits. This skill dynamically injects the tool's help information to ensure the sub-agent generates 100% correct CLI instructions.

External Dependencies and Specification Notes

This Skill depends on the memories-off library for entity management and long-term memory. Before executing any task, you must first consult and fully follow the memories-off-declare.md declaration document in the current directory to obtain the entity type specifications and encapsulated sub-process operation details defined therein.

2. Extraction Definition (Schema)

The extraction task should follow the entity and relation specifications given by the user. In templates/meta.md an example definition is included, defining entity types (Member, Opinion, Info, etc.) and their relation predicates (Propose, Discuss, etc.). Users can adjust it according to actual needs.

3. Workflow Phases

Phase 1: Preparation and Interview

  1. Confirm Scope: Ask for the corpus location and the target knowledge base directory.
  2. Schema Confirmation: Guide the user to confirm templates/meta.md。
  3. Target Definition: Confirm templates/prompt_template.md。

Phase 2: Space Initialization

  1. Initialize memories-off repository: Create the knowledge directory in the location specified by the user and execute memocli init。
  2. Configure Metadata: Use the cp command to write the contents of templates/meta.md into the knowledge base's meta.md; or dynamically generate it based on the user's previous input meta.md。
  3. Copy Corpus: In memocli init in the created knowledge base, create the chat_res subdirectory to store the normalized raw corpus; then copy the raw logs to chat_res, renaming them in order to YYYY-MM-DD_NNN_orig_name.md。
  4. Task Decomposition and Status Tracking: Run python scripts/setup_workspace.py path_to_chat_res TASK_YYYY-MM-DD.md. This script scans the corpus and generates the TASK file with line-numbered shards (100 lines) and preceding context (50 lines).

Phase 3: Incremental Extraction Loop (Resume from Breakpoint)

For each incomplete shard defined in the TASK file ([ ]):

  1. Automatic Positioning: When starting the task, directly locate the first TASK in the [ ] file with status
  2. Generate Prompt: Run python scripts/generate_prompt.py .... This script now dynamically injects memocli syntax supporting "combined operations" (such as establishing relations while appending content).
  3. Execute Extraction Subtasks (Atomic Operations):
    • Combined Instructions First: Prioritize using append-update --add-rel-out and other combined instructions to reduce the number of tool calls.
    • Automatic Path Detection: By default, execute in the knowledge base root directory, with no need to explicitly pass in --path。
    • Failure Handling: If execution is interrupted, directly reprocess the shard on the next attempt.
  4. Record and Commit:
    • Check the TASK file to confirm the shard status has been updated to [x]。
    • Standardized Commit: Execute memocli commit -r "processed chunk [ID]". This command automatically triggers a full-database audit and generates a standard Git commit message.
  5. Check and Continue: Move on to the next shard.

4. Execution Principles

  • Identity: The entity name is the file name. Type prefixes are strictly prohibited.
  • Combined Ops: Make full use of memocli 's --add-rel-out/in parameter. In create-entity or append-update , complete relationship modeling synchronously to improve extraction efficiency.
  • Dynamic Syntax Verification: generate_prompt.py calls memocli --help in real time to ensure the syntax used by sub-agents matches the version installed in the current environment 100%.
  • Minimal Probing:
    • After identifying an entity, directly create-entity, using || true to ignore already-existing errors.
    • Redundant ls or global search。
  • Mandatory Provenance: All append-update must include filename:line_range。

5. Resources

Scripts

  • scripts/setup_workspace.py: Initialize the shard task list.
  • scripts/generate_prompt.py: Dynamically assemble the sub-agent prompt containing authoritative CLI syntax.

Templates

  • templates/prompt_template.md: Core task template, containing metadata and tool operation placeholders.
  • templates/meta.md: Graph ontology definition template.