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
- Confirm Scope: Ask for the corpus location and the target knowledge base directory.
- Schema Confirmation: Guide the user to confirm
templates/meta.md。 - Target Definition: Confirm
templates/prompt_template.md。
Phase 2: Space Initialization
- Initialize
memories-offrepository: Create the knowledge directory in the location specified by the user and executememocli init。 - Configure Metadata: Use the cp command to write the contents of
templates/meta.mdinto the knowledge base'smeta.md; or dynamically generate it based on the user's previous inputmeta.md。 - Copy Corpus: In
memocli initin the created knowledge base, create thechat_ressubdirectory to store the normalized raw corpus; then copy the raw logs tochat_res, renaming them in order toYYYY-MM-DD_NNN_orig_name.md。 - 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 theTASKfile 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 ([ ]):
- Automatic Positioning: When starting the task, directly locate the first
TASKin the[ ]file with status - Generate Prompt: Run
python scripts/generate_prompt.py .... This script now dynamically injectsmemoclisyntax supporting "combined operations" (such as establishing relations while appending content). - Execute Extraction Subtasks (Atomic Operations):
- Combined Instructions First: Prioritize using
append-update --add-rel-outand 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.
- Combined Instructions First: Prioritize using
- Record and Commit:
- Check the
TASKfile 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.
- Check the
- 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/inparameter. Increate-entityorappend-update, complete relationship modeling synchronously to improve extraction efficiency. - Dynamic Syntax Verification:
generate_prompt.pycallsmemocli --helpin 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|| trueto ignore already-existing errors. - Redundant
lsor globalsearch。
- After identifying an entity, directly
- Mandatory Provenance: All
append-updatemust includefilename: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.