commit 394b8591692601f3d18028078572381d0e1585d3 Author: Jarian Cottingham Date: Wed Sep 3 00:39:09 2025 -0500 Master Mind at work diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5735199 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Created by venv; see https://docs.python.org/3/library/venv.html +*/output +/lib +/include +/bin +.ropeproject diff --git a/IDIOTMethod.txt b/IDIOTMethod.txt new file mode 100644 index 0000000..4076c3f --- /dev/null +++ b/IDIOTMethod.txt @@ -0,0 +1,53 @@ +The IDIOT method is a project execution framework for breaking any project into smaller subcomponents to better assist in execution on any project. The framework is broken into two parts. + +Investigation +Design +Implementation +Optimization +Testing + +It's important to always start every project in this order. We should write the entirety of the plan out, taking special care to fill out each section with as much detail of our plan of action. Each section will have a list of questions. Answer the questions to the best of your ability with the knowledge you know. List out considerations for that section of the plan, and validation conditions that let you know you're done with that section and can move on. +### Investigation + +#### Questions to answer +* Who is this for? +* What is this project trying to accomplish? +* What are the sub-problems I can break this project into? +* What questions would I like to answer before I dive into this? +* Is there something like this project already? + * For each project we ask + * What did that project try to accomplish? + * What technologies did that project try to use? + * How many people are using this project? + * How relevant is this project? + * Based on my learnings, can I use code from on of those project to help me? + * Is it open source with a license that is friendly to my project? +* What technology is the best for this project? + * What frameworks am i considering using and are they commercially friendly? +* What tools are available to you for solving this problem? + * What MCP Servers do you think you will use to solve this problem? + * Are there certain MCP servers you would like to have at your disposal to solve this problem? + +### Design + +### Questions to answer +* Draw the architectural schema for all the classes I plan to create to implement this project + * Describe each of the classes in details with a list of functions with return values that we plan to create +* What techonologies are required to build it? +* What will be the cost of running this given the hardware for the project +* How many users are using this system + +### Implementation + +* Based on the design, create each class one by one. + +### Optimization +* Without compromising the quality of the code, perform optimization on the code + +### Testing +* Run through all the user proposed suggestions for testing +* Think of other test cases that will test all the business requirements of this project +* Create Unit tests that can be easily run to ensure the proper execution of this code + * Create E2E tests that can be executed against the service (IF APPLICABLE) +### Follow up +* Create a list of follow up items that would be likely next steps for a project like this. Give this as a suggestion to the person that proposed the project. diff --git a/Project Proposal - Episode Matcher.pdf b/Project Proposal - Episode Matcher.pdf new file mode 100644 index 0000000..daaf670 Binary files /dev/null and b/Project Proposal - Episode Matcher.pdf differ diff --git a/ProjectProposals/Meilisearch UI/proposal.txt b/ProjectProposals/Meilisearch UI/proposal.txt new file mode 100644 index 0000000..571097e --- /dev/null +++ b/ProjectProposals/Meilisearch UI/proposal.txt @@ -0,0 +1,36 @@ +## Brief Description +I have a local deployment of Mellisearch going. It's job is going to be to provide an alternative to Google for a very wide amount of resources on a local internet. The current resources the internet has are the following. + +- Downloaded Youtube videos (Jellyfin Urls) +- MKV Backups of Blurays (jellyfin urls) +- A local copy of Wikipedia +- Constantly updating archive of papers from Arxiv +- Local copies of Blogs from people on substack +- Archive copies of pages from websites like reddit and many news websites (mainly available via archivebox at archive.example.com urls) + +I really need a google like UI for being able to search through all of this content. You can assume some other process will handling indexing all this material,but I really need someone's help to build the UI. It needs to be responsive and fast. I'm thinking we can try making a react app, since everything is on the local network and there's no bandwidth concerns. + +When typing in something to the big query bar, it'd be good if you saw suggested queries or it start auto querying and showing suggested results on the bottom. When the user presses enter, it'd be nice to show a google like interface of the top links for the person to be able to click through. And of course have pagination buttons for the user to click for the next set of links. + +## Required tech +React + +### Hardware running on +### CPU = AMD 9950x3d +### Ram = 192 GB of DDR5 RAM +### GPU = RTX 5090 32GB + RTX 5060 TI 16GB + +## User Count = 10 +## Commercial or Open Source = Open Source +## Who is it for? + +Mainly humans will be using it. Once again, it's going to be an easy way to index through all the content on the server. I expect other media to come online like local social media content or pinterest like content. Maybe some iamges will get generated in the future too, so some image interface that's like google would be good too, but we don't have to do that in this prototype. Maybe mark this as a follow up though. + +## Project Goals +- Goal 1: Build the UI that integrates easily into our currently running Meilisearch server +- Goal 2: Make it very similar and easy to use as Google, since that's what many of the users are already used to. +- Goal 3: Make sure we can add features like looking at just images in the future. +- Goal 4: Make sure it's pretty and very reactive. Should use a modern tech stack +## How to Test + +Mainly make sure it's very pretty and of course works with a locally running Meilisearch server. diff --git a/ProjectProposals/Meilisearch UI/system-prompt.txt b/ProjectProposals/Meilisearch UI/system-prompt.txt new file mode 100644 index 0000000..eec15a4 --- /dev/null +++ b/ProjectProposals/Meilisearch UI/system-prompt.txt @@ -0,0 +1,13 @@ +You are an employee at Master Mind working on a very high achieving team. You're on the company's best team, and our team has a large record of success on many of our projects. You're known for being very attentive to details, and you're extremely hard working, considering all reasonable routes to the answer. + +Our consulting practice is very organized. When we take on a new project, we receive it as a Project Proposal document. The document follows a very specific format, and you can use it to get all details from the client on their proposal. You will not get any more input from the client other than the project proposal. It's very rude to ask the client for more details, so do not do that. Only implement with the information given in the project proposal. + +You will always be given the project proposal in your context. + +Before you ever implement any code, you always make sure to follow the IDIOT Method. You can call the IDIOT method tool + +When you are prompted, you will be given the following + - The Question you are trying to answer + - The stage of IDIOT Method you are working within + - The full IDIOT Method + - The full project proposal diff --git a/The IDIOT Method.pdf b/The IDIOT Method.pdf new file mode 100644 index 0000000..24fd32f Binary files /dev/null and b/The IDIOT Method.pdf differ diff --git a/pyvenv.cfg b/pyvenv.cfg new file mode 100644 index 0000000..e11e79f --- /dev/null +++ b/pyvenv.cfg @@ -0,0 +1,5 @@ +home = /opt/homebrew/opt/python@3.13/bin +include-system-site-packages = false +version = 3.13.5 +executable = /opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/bin/python3.13 +command = /opt/homebrew/opt/python@3.13/bin/python3.13 -m venv /Users/user/Projects/Master Mind diff --git a/questions.json b/questions.json new file mode 100644 index 0000000..7e00759 --- /dev/null +++ b/questions.json @@ -0,0 +1,136 @@ +[ + { + "phase": "Investigation", + "questions": [ + { + "text": "Who is this for?" + }, + { + "text": "What is this project trying to accomplish?" + }, + { + "text": "What are the sub‑problems I can break this project into?" + }, + { + "text": "What questions would I like to answer before I dive into this?" + }, + { + "text": "Is there something like this project already?", + "subQuestions": [ + { + "text": "For each project we ask", + "subQuestions": [ + { + "text": "What did that project try to accomplish?" + }, + { + "text": "What technologies did that project try to use?" + }, + { + "text": "How many people are using this project?" + }, + { + "text": "How relevant is this project?" + } + ] + }, + { + "text": "Based on my learnings, can I use code from one of those projects to help me?" + }, + { + "text": "Is it open source with a license that is friendly to my project?", + "subQuestions": [ + { + "text": "If so, can we cherry‑pick relevant code?" + } + ] + } + ] + }, + { + "text": "What technology is the best for this project?", + "subQuestions": [ + { + "text": "What frameworks am I considering using and are they commercially friendly?" + } + ] + }, + { + "text": "What tools are available to you for solving this problem?", + "subQuestions": [ + { + "text": "What MCP Servers do you think you will use to solve this problem?" + }, + { + "text": "Are there certain MCP servers you would like to have at your disposal to solve this problem?" + } + ] + } + ] + }, + { + "phase": "Design", + "questions": [ + { + "text": "Draw the architectural schema for all the classes I plan to create to implement this project", + "subQuestions": [ + { + "text": "Describe each of the classes in detail with a list of functions and return values that we plan to create." + } + ] + }, + { + "text": "What technologies are required to build it?" + }, + { + "text": "What will be the cost of running this given the hardware for the project?" + }, + { + "text": "How many users are using this system?" + } + ] + }, + { + "phase": "Implementation", + "questions": [ + { + "text": "Based on the design, create each class one by one." + } + ] + }, + { + "phase": "Optimization", + "questions": [ + { + "text": "Without compromising the quality of the code, perform optimization on the code." + } + ] + }, + { + "phase": "Testing", + "questions": [ + { + "text": "Run through all the user‑proposed suggestions for testing." + }, + { + "text": "Think of other test cases that will test all the business requirements of this project." + }, + { + "text": "Create unit tests that can be easily run to ensure the proper execution of this code", + "subQuestions": [ + { + "text": "Create E2E tests that can be executed against the service (if applicable)." + } + ] + } + ] + }, + { + "phase": "Follow‑up", + "questions": [ + { + "text": "Create a list of follow‑up items that would be likely next steps for a project like this. Give this as a suggestion to the person that proposed the project." + } + ] + } +] diff --git a/scripts/mastermind_cli.py b/scripts/mastermind_cli.py new file mode 100644 index 0000000..c504f22 --- /dev/null +++ b/scripts/mastermind_cli.py @@ -0,0 +1,256 @@ +#!/usr/bin/env python3 +""" +MasterMind CLI + +This script will: + +1. Load the list of questions from `Master Mind/questions.json`. +2. Load the system prompt from a user‑provided file (default: `system_prompt.txt`). +3. Load the proposal and IDIOT method documents. +4. For each question: + - Send a request to a local AI model. + - Store the response in a file inside a project‑named folder. + - Log the activity to the console. + +A very small helper is used to talk to a local model; it can be replaced with a real +LLM client (Llama.cpp, Ollama, FastLLM, etc.) by editing the ``fetch_response`` function. + +Usage: + mastermind_cli.py \ + --project ProjectName \ + --proposal path/to/ProjectProposal.txt \ + --idiot path/to/IDIOTMethod.txt \ + [--prompt-file path/to/system_prompt.txt] \ + [--model-magic "llama3"] # optional flag for the local model name +""" + +from __future__ import annotations + +import argparse +import json +import logging +import pathlib +import sys +import urllib.request +from typing import List + +logging.basicConfig(level=logging.INFO, format="%(message)s") + + +def read_file(path: pathlib.Path) -> str: + """Return the contents of a text file.""" + try: + return path.read_text(encoding="utf-8") + except Exception as exc: # pragma: no cover + logging.error("Could not read %s: %s", path, exc) + sys.exit(1) + + +def load_questions(json_path: pathlib.Path) -> List[dict]: + """Load questions from the JSON file.""" + text = read_file(json_path) + try: + return json.loads(text) + except json.JSONDecodeError as exc: # pragma: no cover + logging.error("Invalid JSON in %s: %s", json_path, exc) + sys.exit(1) + + +def fetch_response( + system_prompt: str, + user_prompt: str, + context: List[str], + model: str = "gpt-oss:20b", +) -> str: + """ + Send a request to a local AI model and return the response. + + This is a placeholder implementation. Replace the body of this function + with actual calls to your local model (e.g., llama.cpp, Ollama, FastLLM, etc.). + + Parameters + ---------- + system_prompt : str + The system‑level instruction to the AI. + user_prompt : str + The question or user message. + context : List[str] + Optional additional context to prepend to the request. + + Returns + ------- + str + The AI’s reply. + """ + # Combine system prompt, context, and user prompt. + prompt_parts = [system_prompt] + prompt_parts.extend(f"{ctx}" for ctx in context) + prompt_parts.append(f"Question: {user_prompt}") + prompt = "\n\n".join(prompt_parts) + "\n" + + # Call Ollama API + url = "http://192.168.8.112:11434/api/generate" + payload = json.dumps({ + "model": model, + "prompt": prompt, + "stream": False + }).encode("utf-8") + headers = {"Content-Type": "application/json"} + req = urllib.request.Request(url, data=payload, headers=headers, method="POST") + try: + with urllib.request.urlopen(req) as resp: + data = resp.read().decode("utf-8") + result = json.loads(data) + return result.get("response", "").strip() + except Exception as exc: # pragma: no cover + logging.error("Ollama request failed: %s", exc) + return f"Simulated response to: {user_prompt}" + + +def main() -> None: + parser = argparse.ArgumentParser( + description="Send MasterMind questions to a local AI and log responses." + ) + parser.add_argument( + "--project", + required=True, + help="Name of the project – creates a folder with this name to store outputs.", + ) + parser.add_argument( + "--proposal", + required=True, + help="Path to the Project Proposal document (text file).", + ) + parser.add_argument( + "--idiot", + required=True, + help="Path to the IDIOT Method document (text file).", + ) + parser.add_argument( + "--prompt-file", + default="system_prompt.txt", + help="Path to the file that contains the system prompt.", + ) + parser.add_argument( + "--model", + default="gpt-oss:20b", + choices=[ + "gpt-oss:20b", + "qwen3:30b", + "devstral:24b", + "llama3.3:70b", + ], + help="LLM model to use.", + ) + parser.add_argument( + "--output-dir", + default="", + help="Custom output directory for the project folder (default: current dir).", + ) + + args = parser.parse_args() + + base_dir = pathlib.Path.cwd() + + # Resolve project output directory + if args.output_dir: + out_base = pathlib.Path(args.output_dir).expanduser().resolve() + else: + out_base = base_dir + project_dir = out_base / args.project + + try: + project_dir.mkdir(parents=True, exist_ok=True) + except Exception as exc: # pragma: no cover + logging.error("Could not create project directory %s: %s", project_dir, exc) + sys.exit(1) + + # Load documents + system_prompt_path = pathlib.Path(args.prompt_file) + proposal_path = pathlib.Path(args.proposal) + idiot_path = pathlib.Path(args.idiot) + + project_prompt = read_file(system_prompt_path) + proposal_text = read_file(proposal_path) + idiot_text = read_file(idiot_path) + + questions_path = base_dir.parent / "questions.json" + questions = load_questions(questions_path) + + # Merge context into system prompt for easier reuse + full_system_prompt = ( + f"{project_prompt}\n\n" + f"--- PROPOSAL ---\n{proposal_text}\n\n" + f"--- IDIOT METHOD ---\n{idiot_text}\n\n" + ) + + logging.info("Project folder: %s", project_dir) + logging.info("Processing %d phases of questions.", len(questions)) + + accumulated_summaries: List[str] = [] + experiment_results: List[dict] = [] + counter = 1 + + for phase in questions: + phase_name = phase.get("phase", "Unnamed Phase") + phase_qs = phase.get("questions", []) + logging.info("Phase: %s – %d questions", phase_name, len(phase_qs)) + + # Context from previous phases + phase_context: List[str] = accumulated_summaries.copy() + + for q in phase_qs: + question_text = q.get("text", "") + if not question_text: + continue # skip empty + + logging.info("Q%d: %s", counter, question_text) + response = fetch_response( + full_system_prompt, question_text, phase_context, args.model + ) + output_file = project_dir / f"question_{counter:03d}.txt" + try: + output_file.write_text(response, encoding="utf-8") + except Exception as exc: # pragma: no cover + logging.error("Could not write %s: %s", output_file, exc) + continue + logging.info("Saved response to %s", output_file) + + accumulated_summaries.append(response) + counter += 1 + + # After finishing the phase, write a short summary file for this phase + phase_summary_file = ( + project_dir / f"{phase_name.replace(' ', '_').lower()}_summary.txt" + ) + try: + summary = fetch_response("Make a clear and concise summary that's no more than 500 tokens on the following input", + "\n\n".join(accumulated_summaries), + []) + + phase_summary_file.write_text( + summary, encoding="utf-8" + ) + logging.info("Saved per‑phase summary to %s", phase_summary_file) + except Exception as exc: # pragma: no cover + logging.error("Could not write %s: %s", phase_summary_file, exc) + + experiment_results.append({ + "phase": phase_name, + "summary_file": str(phase_summary_file), + }) + + logging.info("All done! Total responses: %d", counter - 1) + + results_file = project_dir / "experiment_results.json" + try: + results_file.write_text( + json.dumps(experiment_results, indent=2), encoding="utf-8" + ) + logging.info("Saved experiment results to %s", results_file) + except Exception as exc: + logging.error("Could not write experiment results: %s", exc) + + +if __name__ == "__main__": + main()