.openai.azure.com/
8 | AZURE_API_VERSION_IMAGE=2024-02-01
9 | AZURE_ENTRA_AUTH_IMAGE=False
10 |
--------------------------------------------------------------------------------
/src/config/bedrock.env.example:
--------------------------------------------------------------------------------
1 | BEDROCK_ACCESS_KEY=
2 | BEDROCK_SECRET_KEY=
--------------------------------------------------------------------------------
/src/config/bfl.env.example:
--------------------------------------------------------------------------------
1 | BFL_API_KEY=
2 | BFL_API_URL=https://api.bfl.ml/v1/
3 |
--------------------------------------------------------------------------------
/src/config/deepl.env.example:
--------------------------------------------------------------------------------
1 | DEEPL_API_KEY=
2 | DEEPL_API_URL=https://api-free.deepl.com/v2/translate
3 |
--------------------------------------------------------------------------------
/src/config/deepseek.env.example:
--------------------------------------------------------------------------------
1 | DEEPSEEK_API_KEY=
2 | DEEPSEEK_API_URL=https://api.deepseek.com/beta/chat/completions
--------------------------------------------------------------------------------
/src/config/fireworks.env.example:
--------------------------------------------------------------------------------
1 | FIREWORKS_API_KEY=
2 | FIREWORKS_API_URL=https://api.fireworks.ai/inference/v1/chat/completions
3 |
--------------------------------------------------------------------------------
/src/config/gemini.env.example:
--------------------------------------------------------------------------------
1 | GEMINI_API_KEY=
2 | GEMINI_API_URL=https://generativelanguage.googleapis.com/v1beta/models/
--------------------------------------------------------------------------------
/src/config/github.env.example:
--------------------------------------------------------------------------------
1 | GITHUB_MODELS_TOKEN=
2 | GITHUB_MODELS_API_URL=https://models.inference.ai.azure.com/chat/completions
--------------------------------------------------------------------------------
/src/config/gpt4all.env:
--------------------------------------------------------------------------------
1 | GPT4ALL_MODEL_PATH_WINDOWS=%LOCALAPPDATA%\nomic.ai\GPT4All
--------------------------------------------------------------------------------
/src/config/groq.env.example:
--------------------------------------------------------------------------------
1 | GROQ_API_KEY=
2 | GROQ_API_URL=https://api.groq.com/openai/v1/chat/completions
--------------------------------------------------------------------------------
/src/config/hf.env.example:
--------------------------------------------------------------------------------
1 | HF_API_KEY=
2 | HF_API_URL=https://api-inference.huggingface.co/models/
3 |
--------------------------------------------------------------------------------
/src/config/ideogramai.env.example:
--------------------------------------------------------------------------------
1 | IDEOGRAMAI_API_KEY=
2 | IDEOGRAMAI_API_URL=https://api.ideogram.ai/generate
3 | IDEOGRAMAI_API_V3_URL=https://api.ideogram.ai/v1/ideogram-v3/generate
4 |
--------------------------------------------------------------------------------
/src/config/lmstudio.env:
--------------------------------------------------------------------------------
1 | LMSTUDIO_API_URL=http://localhost:1234/v1/chat/completions
--------------------------------------------------------------------------------
/src/config/mistral.env.example:
--------------------------------------------------------------------------------
1 | MISTRAL_API_KEY=
2 | MISTRAL_API_URL=https://api.mistral.ai/v1/chat/completions
--------------------------------------------------------------------------------
/src/config/mlx.env:
--------------------------------------------------------------------------------
1 | MLX_API_URL=http://localhost:8080/v1/chat/completions
--------------------------------------------------------------------------------
/src/config/ollama.env:
--------------------------------------------------------------------------------
1 | OLLAMA_API_URL=http://localhost:11434/v1/chat/completions
--------------------------------------------------------------------------------
/src/config/openai.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=
2 | OPENAI_API_URL=https://api.openai.com/v1/chat/completions
3 |
4 | OPENAI_API_KEY_IMAGE=
5 | OPENAI_API_URL_IMAGE=https://api.openai.com/v1/images/generations
6 |
--------------------------------------------------------------------------------
/src/config/openrouter.env.example:
--------------------------------------------------------------------------------
1 | OPENROUTER_API_KEY=
2 | OPENROUTER_API_URL=https://openrouter.ai/api/v1/chat/completions
--------------------------------------------------------------------------------
/src/config/perplexity.env.example:
--------------------------------------------------------------------------------
1 | PERPLEXITY_API_KEY=
2 | PERPLEXITY_API_URL=https://api.perplexity.ai/chat/completions
--------------------------------------------------------------------------------
/src/config/recraftai.env.example:
--------------------------------------------------------------------------------
1 | RECRAFT_API_TOKEN=
2 | RECRAFT_API_URL=https://external.api.recraft.ai/v1/images/generations
3 |
--------------------------------------------------------------------------------
/src/config/stabilityai.env.example:
--------------------------------------------------------------------------------
1 | STABILITYAI_API_KEY=
2 | STABILITYAI_API_URL=https://api.stability.ai/v2beta/stable-image/generate/
3 |
--------------------------------------------------------------------------------
/src/config/vertexai.env.example:
--------------------------------------------------------------------------------
1 | GCP_CLIENT_ID=
2 | GCP_CLIENT_SECRET=
3 |
4 | VERTEXAI_ACCESS_TOKEN=
5 |
6 | VERTEXAI_PROJECT_ID=
7 | VERTEXAI_API_ENDPOINT=us-central1-aiplatform.googleapis.com
8 | VERTEXAI_LOCATION_ID=us-central1
9 |
10 | VERTEXAI_PROJECT_ID_IMAGE=
11 | VERTEXAI_API_ENDPOINT_IMAGE=us-central1-aiplatform.googleapis.com
12 | VERTEXAI_LOCATION_ID_IMAGE=us-central1
13 |
--------------------------------------------------------------------------------
/src/config/xai.env.example:
--------------------------------------------------------------------------------
1 | XAI_API_KEY=
2 | XAI_API_URL=https://api.x.ai/v1/chat/completions
3 |
--------------------------------------------------------------------------------
/src/config_translate.py:
--------------------------------------------------------------------------------
1 | import os
2 | from types import SimpleNamespace
3 | from file_helper import load_env
4 |
5 | CLOUD_TYPE_TRANSLATION = 'DEEPL'
6 |
7 | def get_translation_config(CLOUD_TYPE_TRANSLATION: str = CLOUD_TYPE_TRANSLATION) -> SimpleNamespace:
8 |
9 | config = SimpleNamespace(
10 | CLOUD_TYPE_TRANSLATION=CLOUD_TYPE_TRANSLATION
11 | )
12 |
13 | config.LOG = True
14 | config.TURBO_MODE = True # just generate text topics
15 | config.TRANSLATION_HEADERS = {"Content-Type": "application/json"}
16 |
17 | load_env(CLOUD_TYPE_TRANSLATION.split("+")[0])
18 |
19 | if "DEEPL" in CLOUD_TYPE_TRANSLATION:
20 | # config.DEEPL_BASE_URL = "https://api.deepl.com/v2/translate" # paid version
21 | config.DEEPL_BASE_URL = os.getenv('DEEPL_API_URL') # free version
22 | config.TRANSLATION_HEADERS = {**config.TRANSLATION_HEADERS, "Authorization": "DeepL-Auth-Key " + (os.getenv('DEEPL_API_KEY') or "")}
23 |
24 | else:
25 | raise Exception("Error: Unknown CLOUD_TYPE_TRANSLATION")
26 |
27 | return config
28 |
--------------------------------------------------------------------------------
/src/constraints_agents.txt:
--------------------------------------------------------------------------------
1 | chroma-hnswlib==999.999.999
--------------------------------------------------------------------------------
/src/file_helper.py:
--------------------------------------------------------------------------------
1 | import re
2 | import os
3 | import sys
4 |
5 | from dotenv import load_dotenv
6 | from importlib import import_module
7 | import importlib.util as import_util
8 |
9 | MARKMAP_TEMPLATE = """
10 |
11 |
19 |
20 | """
21 |
22 | MERMAID_TEMPLATE= """
23 |
24 | %%{init: {"theme": "dark"}}%%
25 | {{mermaid}}
26 |
27 | """
28 |
29 |
30 | if sys.platform.startswith('win'):
31 | platform = "win"
32 | elif sys.platform.startswith('darwin'):
33 | platform = "darwin"
34 |
35 | def sanitize_folder_name(folder_name):
36 | folder_name = re.sub(r'[<>:"/\\|?*]', '', folder_name)
37 | folder_name = folder_name.strip('. ')
38 | folder_name = re.sub(r'[ .]', '_', folder_name)
39 | if not folder_name:
40 | folder_name = "unnamed_folder"
41 | folder_name = folder_name[:255]
42 | reserved_names = ["CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"]
43 | if folder_name.upper() in reserved_names:
44 | folder_name = "_" + folder_name
45 | return folder_name
46 |
47 | def create_folder_if_not_exists(root_path, central_topic_text):
48 | folder_path = os.path.join(root_path, f"⚡️{sanitize_folder_name(central_topic_text)}")
49 | if not os.path.exists(folder_path): os.makedirs(folder_path)
50 | return folder_path
51 |
52 | def open_file(file_path, platform):
53 | if platform == "darwin":
54 | os.system(f"open {file_path}")
55 | if platform == "win":
56 | import subprocess
57 | subprocess.Popen(f'cmd /k start explorer.exe "{file_path}"', shell=False)
58 |
59 | def get_new_file_paths(folder_name, guid):
60 | doc_folder_path = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), folder_name)
61 | if not os.path.exists(doc_folder_path): os.makedirs(doc_folder_path)
62 | file_name = f"{guid}.html"
63 | file_path = os.path.join(doc_folder_path, file_name)
64 | return file_path
65 |
66 | def generate_glossary_html(content, guid):
67 | file_path = get_new_file_paths("docs", guid)
68 | try:
69 | import markdown
70 | html_fragment = markdown.markdown(content)
71 | except Exception as e:
72 | with open(file_path + ".error", 'w') as f:
73 | f.write(f'caught {str(e)}: e')
74 | raise
75 | template = get_template_content("glossary.html")
76 | html = template.replace("{{title}}", "Glossary").replace("{{body}}", html_fragment.replace("", "
"))
77 | with open(file_path, 'w') as f:
78 | f.write(html)
79 | open_file(file_path, platform)
80 |
81 | def generate_argumentation_html(content, guid):
82 | file_path = get_new_file_paths("docs", guid)
83 | try:
84 | import markdown
85 | html_fragment = markdown.markdown(content)
86 | except Exception as e:
87 | with open(file_path + ".error", 'w') as f:
88 | f.write(f'caught {str(e)}: e')
89 | raise
90 | template = get_template_content("argumentation.html")
91 | html = template.replace("{{title}}", "Notes").replace("{{body}}", html_fragment.replace("", "
"))
92 | with open(file_path, 'w') as f:
93 | f.write(html)
94 | open_file(file_path, platform)
95 |
96 | def generate_markmap_html(content, max_topic_level, guid):
97 | file_path = get_new_file_paths("docs", guid)
98 | this_content = MARKMAP_TEMPLATE.replace("{{colorFreezeLevel}}", str(max_topic_level)).replace("{{markmap}}", content)
99 | template = get_template_content("markmap.html")
100 | html = template.replace("{{body}}", this_content).replace("{{title}}", "Markmap")
101 | with open(file_path, 'w') as f:
102 | f.write(html)
103 | open_file(file_path, platform)
104 |
105 | def generate_mermaid_html(content, max_topic_level, guid, do_open_file = True):
106 | file_path = get_new_file_paths("docs", guid)
107 | this_content = MERMAID_TEMPLATE.replace("{{mermaid}}", content)
108 | template = get_template_content("mermaid.html")
109 | html = template.replace("{{body}}", this_content).replace("{{title}}", "Mermaid")
110 | with open(file_path, 'w') as f:
111 | f.write(html)
112 | if do_open_file:
113 | open_file(file_path, platform)
114 |
115 | def get_template_content(template_name):
116 | templates_folder_path = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "templates")
117 | with open(os.path.join(templates_folder_path, template_name), 'r') as f:
118 | template = f.read()
119 | return template
120 |
121 | def log_input_output(input, output, prompt):
122 | try:
123 | folder_path = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "log")
124 | if not os.path.exists(folder_path): os.makedirs(folder_path)
125 | with open(folder_path + "/input.txt", "w", encoding='utf-8', errors='ignore') as file:
126 | file.write(input)
127 | with open(folder_path + "/output.txt", "w", encoding='utf-8') as file:
128 | file.write(output)
129 | with open(folder_path + "/prompt.txt", "w", encoding='utf-8') as file:
130 | file.write(prompt)
131 | except Exception as e:
132 | print(f"Error writing log files: {str(e)}")
133 |
134 | def get_image_file_paths(library_folder, top_most_topic, guid):
135 | folder_path_images = create_folder_if_not_exists(root_path=os.path.join(library_folder, "Images"), central_topic_text=top_most_topic)
136 | folder_path_background_images = create_folder_if_not_exists(root_path=os.path.join(library_folder, "Background Images"), central_topic_text=top_most_topic)
137 | file_name = f"{guid}.png"
138 | file_paths = [os.path.join(folder_path_images, file_name), os.path.join(folder_path_background_images, file_name)]
139 | return file_paths
140 |
141 | def load_env(env_name: str):
142 | env_path = os.path.join(os.path.dirname(__file__), 'config', f"{env_name.lower()}.env")
143 | if os.path.exists(env_path):
144 | load_dotenv(dotenv_path=env_path, override=True)
145 |
146 | def load_class(module_name, class_name):
147 | mod = import_module(module_name)
148 | cls = getattr(mod, class_name)
149 | return cls
150 |
151 | def load_module_from_path(path, name):
152 | spec = import_util.spec_from_file_location(name, path)
153 | module = import_util.module_from_spec(spec)
154 | sys.modules[name] = module
155 | spec.loader.exec_module(module)
156 | return module
--------------------------------------------------------------------------------
/src/input_helper.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 | import pymupdf4llm
4 | import pymupdf
5 | import pathlib
6 | import text_helper
7 | import base64
8 | from math import ceil
9 | from PIL import Image
10 | import io
11 |
12 | def load_pdf_files(optimization_level=2, as_images=False, as_images_dpi=200, mime_type="image/png", as_base64=False):
13 | docs = {}
14 | input_folder_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "input"), "pdf")
15 | if os.path.exists(input_folder_path):
16 | for root, dirs, files in os.walk(input_folder_path):
17 | for filename in files:
18 | if filename.endswith('.pdf'):
19 | input_file_path = os.path.join(root, filename)
20 |
21 | if not as_images:
22 | output_file_path = input_file_path.lower().replace(".pdf", ".md")
23 | if not os.path.exists(output_file_path):
24 | doc = pymupdf4llm.to_markdown(input_file_path) #, page_chunks=True)
25 | extract_and_optimize(optimization_level, output_file_path, doc)
26 | if as_base64:
27 | docs[filename] = load_file_as_base64(output_file_path)
28 | else:
29 | with open(output_file_path, 'r') as file:
30 | docs[filename] = file.read()
31 | else:
32 | images = []
33 | for page in pymupdf.open(input_file_path):
34 | pix = page.get_pixmap(dpi=as_images_dpi)
35 | output_file_path = input_file_path.lower().replace(".pdf", ("-page-%i.png" % page.number))
36 | if not os.path.exists(output_file_path):
37 | pix.save(output_file_path)
38 | if as_base64:
39 | images.append(load_file_as_base64(output_file_path))
40 | else:
41 | with open(output_file_path, 'rb') as file:
42 | images.append(file.read())
43 | docs[filename] = images
44 | return docs
45 |
46 | def extract_and_optimize(optimization_level, output_file_path, md_text):
47 | token_count = text_helper.num_tokens_from_string(md_text, "cl100k_base")
48 | if optimization_level > 0:
49 | pathlib.Path(output_file_path.replace(".md", "_original.md")).write_bytes(md_text.encode())
50 |
51 | if optimization_level > 0:
52 | md_text = text_helper.remove_section(md_text, "Introduction")
53 | md_text = text_helper.remove_section(md_text, "Conclusion")
54 | md_text = text_helper.remove_section(md_text, "References")
55 |
56 | if optimization_level > 1:
57 | md_text = text_helper.cleanse_markdown(md_text, optimization_level)
58 |
59 | pathlib.Path(output_file_path).write_bytes(md_text.encode())
60 |
61 | token_count_cleaned = text_helper.num_tokens_from_string(md_text, "cl100k_base")
62 | print(f"Token count: {token_count} -> {token_count_cleaned} @ level {optimization_level}")
63 | else:
64 | pathlib.Path(output_file_path).write_bytes(md_text.encode())
65 |
66 | def load_pdfsimple_files():
67 | docs_base64 = {}
68 | input_folder_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "input"), "pdf")
69 | if os.path.exists(input_folder_path):
70 | for root, dirs, files in os.walk(input_folder_path):
71 | for filename in files:
72 | if filename.endswith('.pdf'):
73 | input_file_path = os.path.join(root, filename)
74 | docs_base64[filename] = load_file_as_base64(input_file_path)
75 | return docs_base64
76 |
77 | def load_file_as_base64(file_path):
78 | if os.path.exists(file_path):
79 | with open(file_path, 'rb') as file:
80 | binary_data = file.read()
81 | base64_encoded = base64.b64encode(binary_data)
82 | base64_string = base64_encoded.decode('utf-8')
83 | return base64_string
84 |
85 | def load_text_files(format="md"):
86 | md_texts = {}
87 | input_folder_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "input"), format)
88 | if os.path.exists(input_folder_path):
89 | for root, dirs, files in os.walk(input_folder_path):
90 | for filename in files:
91 | if filename.endswith("." + format):
92 | input_file_path = os.path.join(root, filename)
93 | with open(input_file_path, 'r') as file:
94 | md_texts[filename] = file.read()
95 | return md_texts
96 |
97 | def calculate_image_tokens(base64_image: str) -> int:
98 | image_data = base64.b64decode(base64_image)
99 | image = Image.open(io.BytesIO(image_data))
100 | width, height = image.size
101 |
102 | if width > 2048 or height > 2048:
103 | aspect_ratio = width / height
104 | if aspect_ratio > 1:
105 | width, height = 2048, int(2048 / aspect_ratio)
106 | else:
107 | width, height = int(2048 * aspect_ratio), 2048
108 |
109 | if width >= height and height > 768:
110 | width, height = int((768 / height) * width), 768
111 | elif height > width and width > 768:
112 | width, height = 768, int((768 / width) * height)
113 |
114 | tiles_width = ceil(width / 512)
115 | tiles_height = ceil(height / 512)
116 |
117 | total_tokens = 85 + 170 * (tiles_width * tiles_height)
118 | return total_tokens
119 |
--------------------------------------------------------------------------------
/src/mermaid/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robertZaufall/mindmanager_ai/e018469aac9986b736877484df271529f43e1940/src/mermaid/__init__.py
--------------------------------------------------------------------------------
/src/mermaid/mermaid_helper.py:
--------------------------------------------------------------------------------
1 | import re
2 | import os
3 | import sys
4 |
5 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6 | from mindmap.mindmap import MindmapTopic
7 |
8 | INDENT_SIZE = 2
9 | LINE_SEPARATOR = "\n"
10 |
11 | line_separator = LINE_SEPARATOR
12 | indent_size = INDENT_SIZE
13 | use_round = False
14 | use_root = True
15 |
16 | class MermaidTopic:
17 | def __init__(self, text='', level=0):
18 | self.text = text
19 | self.level = level
20 |
21 | class MermaidMindmap:
22 | def __init__(self, mermaid_mindmap: str=''):
23 | self.mermaid_mindmap = mermaid_mindmap
24 |
25 | if self.mermaid_mindmap:
26 | if validate_mermaid(mermaid_mindmap):
27 | raise ValueError("The Mermaid mindmap is not valid.")
28 | self.mermaid_topics: list['MermaidTopic'] = self.parse_mermaid(mermaid_mindmap)
29 | self.max_topic_level: int = max(topic.level for topic in self.mermaid_topics)
30 | else:
31 | self.mermaid_topics = []
32 | self.max_topic_level = 0
33 |
34 | def parse_mermaid(self, mermaid):
35 | mermaid_topics = []
36 | mermaid_lines_array = mermaid.split(line_separator)
37 | if len(mermaid_lines_array) > 1:
38 | for mermaid_line in mermaid_lines_array[1:]:
39 | if mermaid_line.strip():
40 | indent_level = (len(mermaid_line) - len(mermaid_line.lstrip())) // indent_size
41 | mermaid_topic = MermaidTopic(mermaid_line.strip(), indent_level - 1)
42 | mermaid_topics.append(mermaid_topic)
43 | return mermaid_topics
44 |
45 | def export_to_markmap(self):
46 | max_topic_level = 1
47 | lines = self.mermaid_mindmap.split(line_separator)
48 | for i in range(1, len(lines)):
49 | level = (len(lines[i]) - len(lines[i].lstrip())) // indent_size
50 | if level > max_topic_level:
51 | max_topic_level = level
52 | if i < len(lines) - 1:
53 | next_level = (len(lines[i+1]) - len(lines[i+1].lstrip())) // indent_size
54 | if next_level > level:
55 | lines[i] = "#" * int(level) + " " + lines[i].lstrip()
56 | else:
57 | lines[i] = "- " + lines[i].lstrip()
58 | else:
59 | lines[i] = "#" * int(level) + " " + lines[i].lstrip()
60 | return line_separator.join(lines[1:]), max_topic_level - 1
61 |
62 | def export_to_mermaid(self, replacements=True):
63 | mermaid = self.mermaid_mindmap
64 | if replacements:
65 | mermaid = mermaid \
66 | .replace("(", "#40;").replace(")", "#41;") \
67 | .replace("{", "#123;").replace("}", "#125;") \
68 | .replace("[", "#91;").replace("]", "#93;")
69 | max_topic_level = 1
70 | lines = mermaid.split(line_separator)
71 | for i in range(1, len(lines)):
72 | level = (len(lines[i]) - len(lines[i].lstrip())) // indent_size
73 | if level > max_topic_level:
74 | max_topic_level = level
75 | if i < len(lines) - 1:
76 | next_level = (len(lines[i+1]) - len(lines[i+1].lstrip())) // indent_size
77 | if next_level > level:
78 | lines[i] = " " * indent_size * int(level) + "(" + lines[i].lstrip() + ")"
79 | else:
80 | lines[i] = " " * indent_size * int(level) + lines[i].lstrip()
81 | else:
82 | if len(lines[i].strip()) > 0:
83 | lines[i] = " " * indent_size * int(level) + "(" + lines[i].lstrip() + ")"
84 | return line_separator.join(lines), max_topic_level - 1
85 |
86 | def create_mindmap_from_mermaid(self) -> MindmapTopic:
87 | mindmap_nodes = [MindmapTopic(text=mt.text, level=mt.level) for mt in self.mermaid_topics]
88 | root = mindmap_nodes[0]
89 | for i in range(1, len(mindmap_nodes)):
90 | curr_node = mindmap_nodes[i]
91 | prev_node = mindmap_nodes[i - 1]
92 | if curr_node.level > prev_node.level:
93 | curr_node.parent = prev_node
94 | prev_node.subtopics.append(curr_node)
95 | elif curr_node.level == prev_node.level:
96 | parent = prev_node.parent
97 | curr_node.parent = parent
98 | if parent:
99 | parent.subtopics.append(curr_node)
100 | else:
101 | target_level = curr_node.level - 1
102 | j = i - 1
103 | while j >= 0 and mindmap_nodes[j].level != target_level:
104 | j -= 1
105 | if j >= 0:
106 | parent = mindmap_nodes[j]
107 | curr_node.parent = parent
108 | parent.subtopics.append(curr_node)
109 | return root
110 |
111 | def get_root(): return "root" if use_root and use_round else ""
112 | def get_left_round(): return "(" if use_round else ""
113 | def get_right_round(): return ")" if use_round else ""
114 | def get_space_string(level): return ' ' * level * indent_size
115 |
116 | def validate_mermaid(mermaid_mindmap):
117 | pattern_text = r"^(?:\s{" + str(indent_size) + r"})*\S.*"
118 | pattern = re.compile(pattern_text, re.MULTILINE)
119 | matches = pattern.findall(mermaid_mindmap)
120 | non_empty_lines = [line for line in mermaid_mindmap.split(line_separator) if line.strip() and not line.strip().startswith('//')]
121 | if len(matches) == len(non_empty_lines):
122 | return False # All lines match the pattern
123 | else:
124 | return True # Some lines do not match the pattern
125 |
126 | def get_mermaid_from_mindmap(mindmap):
127 |
128 | def get_mermaid_line(level, topic):
129 | if level == 0:
130 | return (
131 | f"mindmap{line_separator}"
132 | f"{get_space_string(1)}{get_root()}{get_left_round()}{topic}{get_right_round()}{line_separator}"
133 | )
134 | if level > 1:
135 | return f"{get_space_string(level)}{get_left_round()}{topic}{get_right_round()}{line_separator}"
136 |
137 | def recurse_topics(mermaid_mindmap, this_topic, level):
138 | this_topic_text = this_topic.text
139 | if level == 0:
140 | top_level = get_mermaid_line(0, this_topic_text)
141 | mermaid_mindmap = recurse_topics(top_level, this_topic, 1)
142 | return mermaid_mindmap
143 | if level > 1:
144 | mermaid_mindmap += get_mermaid_line(level, this_topic_text)
145 | for child_topic in this_topic.subtopics:
146 | mermaid_mindmap = recurse_topics(mermaid_mindmap, child_topic, level + 1)
147 | return mermaid_mindmap
148 | return recurse_topics("", mindmap, 0)
149 |
--------------------------------------------------------------------------------
/src/requirements.txt:
--------------------------------------------------------------------------------
1 | requests
2 | httpx
3 | regex
4 | markdown
5 | markdown-it-py
6 | Pillow
7 | tiktoken
8 | pymupdf4llm
9 | gpt4all
10 | sv_ttk
11 | ollama
12 | python-dotenv
13 | nltk
14 | mindm
--------------------------------------------------------------------------------
/src/requirements_agents.txt:
--------------------------------------------------------------------------------
1 | openai
2 | duckduckgo-search
3 | yfinance
4 | langchain
5 | langchain-community
6 | agno
7 | autogen-core
8 | autogen-agentchat
9 | autogen-ext[openai,azure]
--------------------------------------------------------------------------------
/src/requirements_auth.txt:
--------------------------------------------------------------------------------
1 | openai
2 | azure.identity
3 | google-auth
4 | google-auth-oauthlib
5 | google-auth-httplib2
6 | google-api-python-client
7 | google-cloud-aiplatform
8 | google-auth
--------------------------------------------------------------------------------
/src/requirements_auth_aws.txt:
--------------------------------------------------------------------------------
1 | boto3
2 |
--------------------------------------------------------------------------------
/src/requirements_mac_mlx.txt:
--------------------------------------------------------------------------------
1 | mlx>=0.11
2 | mlx-lm
3 | mlxserver
4 | huggingface-hub
5 | numpy
6 | tqdm
7 | torch==2.3.1
8 | torchaudio==2.3.1
9 | torchvision==0.18.1
10 | mflux
11 |
12 |
--------------------------------------------------------------------------------
/src/templates/argumentation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{title}}
5 |
9 |
10 |
11 | {{body}}
12 |
13 |
--------------------------------------------------------------------------------
/src/templates/glossary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{title}}
5 |
11 |
12 | {{body}}
13 |
14 |
--------------------------------------------------------------------------------
/src/templates/markmap.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{title}}
5 |
8 |
9 |
10 | {{body}}
11 |
12 |
--------------------------------------------------------------------------------
/src/templates/mermaid.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{title}}
5 |
8 |
9 |
10 |
11 | {{body}}
12 |
13 |
--------------------------------------------------------------------------------
/src/text_helper.py:
--------------------------------------------------------------------------------
1 | import tiktoken
2 | import markdown_it
3 | import re
4 | import nltk
5 | from nltk.corpus import stopwords
6 | from nltk.tokenize import word_tokenize, sent_tokenize
7 | from nltk.stem import SnowballStemmer
8 | import string
9 | import heapq
10 |
11 | def num_tokens_from_string(string: str, encoding_name: str) -> int:
12 | encoding = tiktoken.get_encoding(encoding_name)
13 | num_tokens = len(encoding.encode(string))
14 | return num_tokens
15 |
16 | def remove_section(markdown_content, section_title):
17 | escaped_title = re.escape(section_title)
18 | pattern = rf'(?:^|\n)(?P#{1,3}|\*\*)\s*{escaped_title}\s*(\*\*)?\n(.*?)(?=\n((?P=level)#|\*\*)|\Z)'
19 | cleaned_content = re.sub(pattern, '', markdown_content, flags=re.DOTALL | re.MULTILINE)
20 | cleaned_content = cleaned_content.rstrip() + '\n'
21 | return cleaned_content
22 |
23 | def guess_language(text):
24 | sample_text = text[:1000].lower()
25 | tokens = word_tokenize(sample_text)
26 | supported_languages = {lang for lang in SnowballStemmer.languages if lang != "porter"}
27 | available_languages = [lang for lang in stopwords.fileids() if lang in supported_languages]
28 | stopword_counts = {}
29 | for lang in available_languages:
30 | sw = set(stopwords.words(lang))
31 | count = sum(1 for token in tokens if token in sw)
32 | stopword_counts[lang] = count
33 | max_count = max(stopword_counts.values(), default=0)
34 | candidate_languages = [lang for lang, count in stopword_counts.items() if count == max_count]
35 | if not candidate_languages:
36 | return "unknown"
37 | priority = [lang for lang in SnowballStemmer.languages if lang != "porter"]
38 | for lang in priority:
39 | if lang in candidate_languages:
40 | return lang
41 | return candidate_languages[0]
42 |
43 | def nltk_summarize(text, language='english', reduction_ratio=0.5):
44 | sentences = sent_tokenize(text)
45 | if len(sentences) < 2:
46 | return text
47 | stop_words = set(stopwords.words(language))
48 | words = word_tokenize(text.lower())
49 | freq_table = {}
50 | for word in words:
51 | if word in stop_words or word in string.punctuation:
52 | continue
53 | freq_table[word] = freq_table.get(word, 0) + 1
54 | sentence_scores = {}
55 | for sentence in sentences:
56 | sentence_words = word_tokenize(sentence.lower())
57 | sentence_length = len(sentence_words)
58 | for word in sentence_words:
59 | if word in freq_table:
60 | sentence_scores[sentence] = sentence_scores.get(sentence, 0) + freq_table[word]
61 | if sentence in sentence_scores and sentence_length > 0:
62 | sentence_scores[sentence] /= sentence_length
63 | num_sentences = max(1, int(len(sentences) * reduction_ratio))
64 | summary_sentences = heapq.nlargest(num_sentences, sentence_scores, key=sentence_scores.get)
65 | summary_sentences = [sentence for sentence in sentences if sentence in summary_sentences]
66 | return " ".join(summary_sentences)
67 |
68 | def summarize_and_stem(text, language='english', reduction_ratio=0.5):
69 | summary = nltk_summarize(text, language, reduction_ratio)
70 | sentences = sent_tokenize(summary)
71 | stemmed_sentences = []
72 | for i, sentence in enumerate(sentences):
73 | tokens = word_tokenize(sentence)
74 | tokens = [token for token in tokens if token not in string.punctuation]
75 | stemmer = SnowballStemmer(language.lower())
76 | stemmed_tokens = [stemmer.stem(token) for token in tokens]
77 | stemmed_sentences.append(" ".join(stemmed_tokens))
78 | result = ". ".join([s.strip() for s in stemmed_sentences]) + "."
79 | return result.strip()
80 |
81 | def cleanse_markdown(markdown_text, optimization_level = 1):
82 | def clean_line(line):
83 | # Remove special characters (except #, -, *, and .)
84 | line = re.sub(r'[^\w\s#\-*.]', '', line)
85 |
86 | # Convert to lowercase
87 | line = line.lower()
88 |
89 | # Remove common stop words (expand this list as needed)
90 | stop_words = set(['the', 'a', 'an', 'in', 'on', 'at', 'to', 'for', 'of', 'and', 'or', 'but'])
91 | words = line.split()
92 | line = ' '.join([word for word in words if word not in stop_words])
93 |
94 | # Remove URLs
95 | line = re.sub(r'http\S+', '', line)
96 |
97 | # Remove extra spaces
98 | line = ' '.join(line.split())
99 |
100 | return line
101 |
102 | # Remove code blocks
103 | markdown_text = re.sub(r'```[\s\S]*?```', '', markdown_text)
104 |
105 | # Remove tables
106 | markdown_text = re.sub(r'\|.*\|', '', markdown_text) # Remove table rows
107 | markdown_text = re.sub(r'^\s*[-:]+\s*\|', '', markdown_text, flags=re.MULTILINE) # Remove table headers
108 |
109 | # Split the markdown into lines
110 | lines = markdown_text.split('\n')
111 |
112 | # Clean each line while preserving structure
113 | cleaned_lines = []
114 | for line in lines:
115 | if line.strip() and not line.strip().startswith('|'): # Additional check to remove any remaining table lines
116 | cleaned_lines.append(clean_line(line))
117 |
118 | # Join the cleaned lines back together
119 | result = '\n'.join(cleaned_lines)
120 |
121 | if optimization_level > 1:
122 | nltk.download('punkt')
123 | nltk.download('stopwords')
124 | nltk.download('punkt_tab')
125 | language = guess_language(result)
126 | result = summarize_and_stem(result, language=language, reduction_ratio=0.75)
127 |
128 | return result
129 |
130 | def cleanse_title(text):
131 | return text.replace(".pdf", "").replace(".md", "").replace("_", " ").replace("-", " ")
132 |
133 | def clean_result(input):
134 | result = input \
135 | .replace("```mermaid", "") \
136 | .replace("Here is the refined mindmap:\n\n", "") \
137 | .replace("Here is the refined mind map:\n\n", "") \
138 | .replace("Here is the refined mindmap data:", "") \
139 | .replace("Here is the refined mindmap in Mermaid syntax:", "") \
140 | .replace("Here is the refined mind map in Mermaid syntax:", "") \
141 | .replace("Here is the mindmap in Mermaid syntax based on the summary:", "") \
142 | .replace("mermaid mindmap\n", "") \
143 | .replace("mermaid\n", "") \
144 | .replace("2 space", "") \
145 | .replace("```", "") \
146 | .lstrip("\n") \
147 | .lstrip()
148 |
149 | lines = result.split("\n")
150 | if lines[0].startswith(" "):
151 | result = "\n".join(line[2:] for line in lines)
152 | return result.lstrip("\n").lstrip()
153 |
--------------------------------------------------------------------------------
/windows/capex_opex.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "capex_opex"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/cluster.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "cluster"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/complexity_1.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "complexity_1"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/complexity_2.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "complexity_2"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/complexity_3.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "complexity_3"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/examples.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "examples"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/exp.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "exp"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/exp_prj_prc_org.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "exp_prj_prc_org"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/generate_glossary.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "glossary"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/generate_image.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "image"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/install.bat:
--------------------------------------------------------------------------------
1 | choco install python3
2 |
3 | pip install -r .\..\src\requirements.txt
4 | pip install -r .\..\src\requirements_win.txt
5 | pip install -r .\..\src\requirements_auth.txt
6 |
7 | powershell -ExecutionPolicy Bypass -File .\macro_registration.ps1
8 | pause
9 |
--------------------------------------------------------------------------------
/windows/macro_registration.ps1:
--------------------------------------------------------------------------------
1 | $mindManagerVersion = $null
2 |
3 | if (Test-Path "HKCU:\Software\Mindjet\MindManager\23\AddIns") {
4 | $mindManagerVersion = "23"
5 | }
6 | elseif (Test-Path "HKCU:\Software\Mindjet\MindManager\24\AddIns") {
7 | $mindManagerVersion = "24"
8 | }
9 | elseif (Test-Path "HKCU:\Software\Mindjet\MindManager\25\AddIns") {
10 | $mindManagerVersion = "25"
11 | }
12 | elseif (Test-Path "HKCU:\Software\Mindjet\MindManager\26\AddIns") {
13 | $mindManagerVersion = "26"
14 | }
15 |
16 | if ($null -eq $mindManagerVersion) {
17 | Write-Output "No MindManager version registry keys found."
18 | exit 1
19 | }
20 | else {
21 | Write-Output "Using MindManager version $mindManagerVersion."
22 | }
23 |
24 | $localAppDataPath = [System.Environment]::GetFolderPath('LocalApplicationData')
25 | $baseRegistryPath = "HKCU:\Software\Mindjet\MindManager\$mindManagerVersion\Macro"
26 | $appMacrosPath = (Join-Path $localAppDataPath "Mindjet\MindManager\$mindManagerVersion\macros\windows")
27 |
28 | # Define the macros with their respective GUIDs, names, and file paths
29 | $macros = @(
30 | @{ GUID = "{04d9db3e-16b7-4bd8-aa47-00ebfabb2693}"; Name = "Translate to EN"; Path = "translate_en.mmbas" },
31 | @{ GUID = "{056ff458-4156-48c0-a051-0510da9aa1aa}"; Name = "Translate to DE"; Path = "translate_de.mmbas" },
32 | @{ GUID = "{07815d9b-2bd4-4dee-acee-15908829985f}"; Name = "Cluster"; Path = "cluster.mmbas" },
33 | @{ GUID = "{1ca2390b-fbfe-4bb5-b526-6b3deadf2ba3}"; Name = "Examples"; Path = "examples.mmbas" },
34 | @{ GUID = "{2472b281-2c60-4b2a-9ee0-8b360678fcfd}"; Name = "Refine"; Path = "refine.mmbas" },
35 | @{ GUID = "{24cb6b18-fcb3-4b01-afab-614c1738d507}"; Name = "Refine Development"; Path = "refine_dev.mmbas" },
36 | @{ GUID = "{3f7f8343-ab71-45d3-8abf-c687f61dc7ec}"; Name = "CAPEX_OPEX"; Path = "capex_opex.mmbas" },
37 | @{ GUID = "{45e93099-cb4e-41e7-8698-2e36d3954dde}"; Name = "Expertise"; Path = "exp.mmbas" },
38 | @{ GUID = "{4aed2571-e766-432a-b08e-81ffb94b7e8b}"; Name = "Project_Organization"; Path = "prj_org.mmbas" },
39 | @{ GUID = "{559A2618-399D-4D21-B96E-5919F83F1C4C}"; Name = "Process_Organization"; Path = "prc_org.mmbas" },
40 | @{ GUID = "{6591ca0c-3410-48a8-a00a-d6d1ee3c51a1}"; Name = "Project_Process_Organization"; Path = "prj_prc_org.mmbas" },
41 | @{ GUID = "{6fd5b0b5-c373-4c6b-9793-2b10d8442ca7}"; Name = "Expertise_Project_Process_Organization"; Path = "exp_prj_prc_org.mmbas" },
42 | @{ GUID = "{8133688c-2aa4-4faa-ab9c-07b8cde5d5bf}"; Name = "Complexity_1"; Path = "complexity_1.mmbas" },
43 | @{ GUID = "{875aed98-dd01-4667-a3ef-2a87d3fb00b7}"; Name = "Complexity_2"; Path = "complexity_2.mmbas" },
44 | @{ GUID = "{e53fe7fc-645d-437a-a8c2-92226dfb5a65}"; Name = "Complexity_3"; Path = "complexity_3.mmbas" },
45 | @{ GUID = "{e9e5ac24-228c-46e0-867b-9df3bb2c372a}"; Name = "Generate Image"; Path = "generate_image.mmbas" } ,
46 | @{ GUID = "{eca7391c-87c7-4ba2-be26-5ce7db82f457}"; Name = "Generate Glossary"; Path = "generate_glossary.mmbas" }
47 | )
48 |
49 | # Loop through each macro and process it
50 | foreach ($macro in $macros) {
51 | # Construct the full registry path for the current macro
52 | $registryPath = Join-Path $baseRegistryPath $macro.GUID
53 |
54 | # Check if the registry key exists and delete it if it does
55 | if (Test-Path $registryPath) {
56 | Remove-Item -Path $registryPath -Recurse
57 | }
58 |
59 | # Create the registry key
60 | New-Item -Path $registryPath -Force
61 |
62 | # Set the required registry values
63 | Set-ItemProperty -Path $registryPath -Name "Name" -Value $macro.Name
64 | Set-ItemProperty -Path $registryPath -Name "Path" -Value (Join-Path $appMacrosPath $macro.Path)
65 | Set-ItemProperty -Path $registryPath -Name "Description" -Value ""
66 | Set-ItemProperty -Path $registryPath -Name "Menu" -Value 17 # 0x11 in hexadecimal
67 |
68 | # Update version references inside the .mmbas file
69 | $filePath = Join-Path $appMacrosPath $macro.Path
70 | if (Test-Path $filePath) {
71 | $fileContent = Get-Content $filePath -Raw
72 | # Replace any existing digit(s) after 'MindManager\' with the configured version
73 | $updatedContent = $fileContent -replace '(?<=MindManager\\)\d+', $mindManagerVersion
74 |
75 | # Trim trailing newlines
76 | $updatedContent = $updatedContent.TrimEnd("`r","`n")
77 |
78 | # Write back without adding extra newlines
79 | [System.IO.File]::WriteAllText($filePath, $updatedContent, [System.Text.Encoding]::UTF8)
80 | }
81 | }
82 |
83 | Write-Output "Registry keys have been successfully created or updated."
84 |
--------------------------------------------------------------------------------
/windows/prc_org.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "prc_org"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/prj_org.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "prj_org"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/prj_prc_org.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "prj_prc_org"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/refine.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "refine"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/refine_dev.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "refine_def"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/translate_de.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "translate_deepl+DE"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------
/windows/translate_en.mmbas:
--------------------------------------------------------------------------------
1 | '#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\Windows\System32\wshom.ocx#Windows Script Host Object Model#IWshRuntimeLibrary
2 | '#Language "WWB-COM"
3 |
4 | Option Explicit
5 |
6 | Sub Main
7 | Dim wsh, scriptPath, action
8 | Set wsh = CreateObject("WScript.Shell")
9 |
10 | scriptPath = wsh.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Mindjet\MindManager\23\macros\src"
11 |
12 | action = "translate_deepl+EN-US"
13 |
14 | wsh.Run "cmd /c python " + scriptPath + "\process.py " + action, 0, True
15 | End Sub
--------------------------------------------------------------------------------