machineconfig 4.2__py3-none-any.whl → 4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of machineconfig might be problematic. Click here for more details.
- machineconfig/scripts/python/fire_agents.py +119 -112
- machineconfig/scripts/python/fire_agents_help_launch.py +2 -16
- machineconfig/scripts/python/fire_agents_load_balancer.py +10 -38
- machineconfig/utils/schemas/fire_agents/fire_agents_input.py +4 -16
- {machineconfig-4.2.dist-info → machineconfig-4.4.dist-info}/METADATA +2 -1
- {machineconfig-4.2.dist-info → machineconfig-4.4.dist-info}/RECORD +9 -9
- {machineconfig-4.2.dist-info → machineconfig-4.4.dist-info}/entry_points.txt +1 -1
- {machineconfig-4.2.dist-info → machineconfig-4.4.dist-info}/WHEEL +0 -0
- {machineconfig-4.2.dist-info → machineconfig-4.4.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Utilitfrom pathlib import Path
|
|
2
|
+
from typing import cast, get_args, Iterable, Optional, TypeAlias, Literal
|
|
3
|
+
import json
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
from machineconfig.scripts.python.fire_agents_help_launch import prep_agent_launch, get_agents_launch_layout, AGENTS
|
|
7
|
+
from machineconfig.scripts.python.fire_agents_help_search import search_files_by_pattern, search_python_files
|
|
8
|
+
from machineconfig.scripts.python.fire_agents_load_balancer import chunk_prompts
|
|
9
|
+
from machineconfig.utils.accessories import get_repo_rootch multiple AI agent prompts in a Zellij session.
|
|
2
10
|
|
|
3
11
|
Improved design notes:
|
|
4
12
|
* Clear separation of: input collection, prompt preparation, agent launch.
|
|
@@ -8,146 +16,145 @@ Improved design notes:
|
|
|
8
16
|
"""
|
|
9
17
|
|
|
10
18
|
from pathlib import Path
|
|
11
|
-
from typing import cast,
|
|
19
|
+
from typing import cast, Iterable, Optional, TypeAlias, Literal, get_args
|
|
12
20
|
import json
|
|
13
|
-
import
|
|
21
|
+
import time
|
|
22
|
+
import typer
|
|
14
23
|
|
|
15
24
|
from machineconfig.scripts.python.fire_agents_help_launch import prep_agent_launch, get_agents_launch_layout, AGENTS
|
|
16
25
|
from machineconfig.scripts.python.fire_agents_help_search import search_files_by_pattern, search_python_files
|
|
17
|
-
from machineconfig.scripts.python.fire_agents_load_balancer import chunk_prompts
|
|
18
|
-
from machineconfig.utils.
|
|
26
|
+
from machineconfig.scripts.python.fire_agents_load_balancer import chunk_prompts
|
|
27
|
+
from machineconfig.utils.schemas.layouts.layout_types import LayoutsFile
|
|
19
28
|
from machineconfig.utils.accessories import get_repo_root
|
|
20
29
|
|
|
21
30
|
SEARCH_STRATEGIES: TypeAlias = Literal["file_path", "keyword_search", "filename_pattern"]
|
|
22
31
|
|
|
32
|
+
app = typer.Typer()
|
|
33
|
+
|
|
23
34
|
|
|
24
35
|
def _write_list_file(target: Path, files: Iterable[Path]) -> None:
|
|
25
36
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
26
37
|
target.write_text("\n".join(str(f) for f in files), encoding="utf-8")
|
|
27
38
|
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
@app.command()
|
|
41
|
+
def create(
|
|
42
|
+
context_path: Optional[Path] = typer.Option(None, help="Path to the context file"),
|
|
43
|
+
keyword_search: Optional[str] = typer.Option(None, help="Keyword to search in Python files"),
|
|
44
|
+
filename_pattern: Optional[str] = typer.Option(None, help="Filename pattern to match"),
|
|
45
|
+
separator: str = typer.Option("\n", help="Separator for context"),
|
|
46
|
+
tasks_per_prompt: int = typer.Option(13, help="Number of tasks per prompt"),
|
|
47
|
+
agent: AGENTS = typer.Option(..., help=f"Agent type. One of {', '.join(get_args(AGENTS))}"),
|
|
48
|
+
prompt: Optional[str] = typer.Option(None, help="Prompt prefix as string"),
|
|
49
|
+
prompt_path: Optional[Path] = typer.Option(None, help="Path to prompt file"),
|
|
50
|
+
job_name: str = typer.Option("AI_Agents", help="Job name"),
|
|
51
|
+
keep_separate: bool = typer.Option(True, help="Keep prompt material in separate file to the context."),
|
|
52
|
+
output_path: Optional[Path] = typer.Option(None, help="Path to write the layout.json file"),
|
|
53
|
+
):
|
|
54
|
+
# validate mutual exclusive
|
|
55
|
+
context_options = [context_path, keyword_search, filename_pattern]
|
|
56
|
+
provided_context = [opt for opt in context_options if opt is not None]
|
|
57
|
+
if len(provided_context) != 1:
|
|
58
|
+
raise typer.BadParameter("Exactly one of --context-path, --keyword-search, --filename-pattern must be provided")
|
|
59
|
+
|
|
60
|
+
prompt_options = [prompt, prompt_path]
|
|
61
|
+
provided_prompt = [opt for opt in prompt_options if opt is not None]
|
|
62
|
+
if len(provided_prompt) != 1:
|
|
63
|
+
raise typer.BadParameter("Exactly one of --prompt or --prompt-path must be provided")
|
|
64
|
+
|
|
65
|
+
repo_root = get_repo_root(Path.cwd())
|
|
66
|
+
if repo_root is None:
|
|
67
|
+
typer.echo("💥 Could not determine the repository root. Please run this script from within a git repository.")
|
|
68
|
+
raise typer.Exit(1)
|
|
69
|
+
typer.echo(f"Operating @ {repo_root}")
|
|
70
|
+
|
|
71
|
+
search_strategy = ""
|
|
72
|
+
prompt_material_path = Path("")
|
|
73
|
+
|
|
74
|
+
if context_path is not None:
|
|
75
|
+
search_strategy = "file_path"
|
|
76
|
+
target_file_path = context_path.expanduser().resolve()
|
|
36
77
|
if not target_file_path.exists() or not target_file_path.is_file():
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if not keyword:
|
|
43
|
-
print("No keyword supplied. Exiting.")
|
|
44
|
-
sys.exit(1)
|
|
45
|
-
matching_files = search_python_files(repo_root, keyword)
|
|
78
|
+
raise typer.BadParameter(f"Invalid file path: {target_file_path}")
|
|
79
|
+
prompt_material_path = target_file_path
|
|
80
|
+
elif keyword_search is not None:
|
|
81
|
+
search_strategy = "keyword_search"
|
|
82
|
+
matching_files = search_python_files(repo_root, keyword_search)
|
|
46
83
|
if not matching_files:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
for idx, mf in enumerate(matching_files):
|
|
50
|
-
print(f"{idx:>3}: {mf}")
|
|
51
|
-
print(f"\nFound {len(matching_files)} .py files containing keyword: {keyword}")
|
|
84
|
+
typer.echo(f"💥 No .py files found containing keyword: {keyword_search}")
|
|
85
|
+
raise typer.Exit(1)
|
|
52
86
|
target_file_path = repo_root / ".ai" / "target_file.txt"
|
|
53
87
|
_write_list_file(target_file_path, matching_files)
|
|
54
|
-
|
|
55
|
-
elif
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
print("No pattern supplied. Exiting.")
|
|
59
|
-
sys.exit(1)
|
|
60
|
-
matching_files = search_files_by_pattern(repo_root, pattern)
|
|
88
|
+
prompt_material_path = target_file_path
|
|
89
|
+
elif filename_pattern is not None:
|
|
90
|
+
search_strategy = "filename_pattern"
|
|
91
|
+
matching_files = search_files_by_pattern(repo_root, filename_pattern)
|
|
61
92
|
if not matching_files:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for idx, mf in enumerate(matching_files):
|
|
65
|
-
print(f"{idx:>3}: {mf}")
|
|
66
|
-
print(f"\nFound {len(matching_files)} files matching pattern: {pattern}")
|
|
93
|
+
typer.echo(f"💥 No files found matching pattern: {filename_pattern}")
|
|
94
|
+
raise typer.Exit(1)
|
|
67
95
|
target_file_path = repo_root / ".ai" / "target_file.txt"
|
|
68
96
|
_write_list_file(target_file_path, matching_files)
|
|
69
|
-
|
|
97
|
+
prompt_material_path = target_file_path
|
|
98
|
+
|
|
99
|
+
if prompt_path is not None:
|
|
100
|
+
prompt_prefix = prompt_path.read_text(encoding="utf-8")
|
|
70
101
|
else:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def main(): # noqa: C901 - (complexity acceptable for CLI glue)
|
|
76
|
-
repo_root = get_repo_root(Path.cwd())
|
|
77
|
-
if repo_root is None:
|
|
78
|
-
print("💥 Could not determine the repository root. Please run this script from within a git repository.")
|
|
79
|
-
sys.exit(1)
|
|
80
|
-
print(f"Operating @ {repo_root}")
|
|
81
|
-
|
|
82
|
-
search_strategy = cast(SEARCH_STRATEGIES, choose_from_options(multi=False, msg="Choose one option", header="Choose search strategy:", options=get_args(SEARCH_STRATEGIES)))
|
|
83
|
-
splitting_strategy = cast(SPLITTING_STRATEGY, choose_from_options(multi=False, msg="Choose one option", header="Choose prompt splitting strategy:", options=get_args(SPLITTING_STRATEGY)))
|
|
84
|
-
agent_selected = cast(AGENTS, choose_from_options(multi=False, msg="Choose one option", header="Select agent type", options=get_args(AGENTS)))
|
|
85
|
-
print("Enter prefix prompt (end with Ctrl-D / Ctrl-Z):")
|
|
86
|
-
prompt_prefix = "\n".join(sys.stdin.readlines())
|
|
87
|
-
job_name = input("Enter job name [AI_AGENTS]: ") or "AI_Agents"
|
|
88
|
-
keep_material_in_separate_file_input = input("Keep prompt material in separate file? [y/N]: ").strip().lower() == "y"
|
|
89
|
-
|
|
90
|
-
prompt_material_path, separator = get_prompt_material(search_strategy=search_strategy, repo_root=repo_root)
|
|
91
|
-
match splitting_strategy:
|
|
92
|
-
case "agent_cap":
|
|
93
|
-
agent_cap_input = input(f"Enter maximum number of agents/splits [default: {DEFAULT_AGENT_CAP}]: ").strip()
|
|
94
|
-
agent_cap = int(agent_cap_input) if agent_cap_input else DEFAULT_AGENT_CAP
|
|
95
|
-
task_rows = None
|
|
96
|
-
case "task_rows":
|
|
97
|
-
task_rows_input: str = input("Enter number of rows/tasks per agent [13]: ").strip() or "13"
|
|
98
|
-
task_rows = int(task_rows_input)
|
|
99
|
-
agent_cap = None
|
|
100
|
-
prompt_material_re_splitted = chunk_prompts(prompt_material_path, splitting_strategy, agent_cap=agent_cap, task_rows=task_rows, joiner=separator)
|
|
101
|
-
|
|
102
|
+
prompt_prefix = cast(str, prompt)
|
|
103
|
+
agent_selected = agent
|
|
104
|
+
keep_material_in_separate_file_input = keep_separate
|
|
105
|
+
prompt_material_re_splitted = chunk_prompts(prompt_material_path, tasks_per_prompt=tasks_per_prompt, joiner=separator)
|
|
102
106
|
agents_dir = prep_agent_launch(repo_root=repo_root, prompts_material=prompt_material_re_splitted, keep_material_in_separate_file=keep_material_in_separate_file_input, prompt_prefix=prompt_prefix, agent=agent_selected, job_name=job_name)
|
|
103
|
-
layoutfile = get_agents_launch_layout(session_root=agents_dir)
|
|
104
|
-
|
|
107
|
+
layoutfile = get_agents_launch_layout(session_root=agents_dir)
|
|
105
108
|
regenerate_py_code = f"""
|
|
106
109
|
#!/usr/bin/env uv run --python 3.13 --with machineconfig
|
|
107
110
|
#!/usr/bin/env uv run --no-dev --project $HOME/code/machineconfig
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
job_name = "{job_name}"
|
|
117
|
-
keep_material_in_separate_file_input = {keep_material_in_separate_file_input}
|
|
118
|
-
separator = "{separator}"
|
|
119
|
-
prompt_material_path = Path("{prompt_material_path}")
|
|
120
|
-
agent_cap = {agent_cap}
|
|
121
|
-
task_rows = {task_rows}
|
|
122
|
-
|
|
123
|
-
prompt_material_re_splitted = chunk_prompts(prompt_material_path, splitting_strategy, agent_cap=agent_cap, task_rows=task_rows, joiner=separator)
|
|
124
|
-
agents_dir = prep_agent_launch(repo_root=repo_root, prompts_material=prompt_material_re_splitted, keep_material_in_separate_file=keep_material_in_separate_file_input, prompt_prefix=prompt_prefix, agent=agent_selected, job_name=job_name)
|
|
125
|
-
layout = get_agents_launch_layout(session_root=agents_dir)
|
|
126
|
-
|
|
127
|
-
(agents_dir / "aa_agents_relaunch.py").write_text(data=regenerate_py_code, encoding="utf-8")
|
|
128
|
-
(agents_dir / "layout.json").write_text(data=json.dumps(layout, indent=2), encoding="utf-8")
|
|
129
|
-
|
|
130
|
-
if len(layout["layoutTabs"]) > 25:
|
|
131
|
-
print("Too many agents (>25) to launch. Skipping launch.")
|
|
132
|
-
sys.exit(0)
|
|
133
|
-
manager = ZellijLocalManager(session_layouts=[layout])
|
|
134
|
-
manager.start_all_sessions()
|
|
135
|
-
manager.run_monitoring_routine()
|
|
136
|
-
|
|
111
|
+
fire_agents create --context-path "{prompt_material_path}" \\
|
|
112
|
+
--{search_strategy} "{context_path or keyword_search or filename_pattern}" \\
|
|
113
|
+
--prompt-path "{prompt_path or ''}" \\
|
|
114
|
+
--agent "{agent_selected}" \\
|
|
115
|
+
--job-name "{job_name}" \\
|
|
116
|
+
--tasks-per-prompt {tasks_per_prompt} \\
|
|
117
|
+
--separator "{separator}" \\
|
|
118
|
+
{"--keep-separate" if keep_material_in_separate_file_input else ""}
|
|
137
119
|
"""
|
|
138
120
|
(agents_dir / "aa_agents_relaunch.py").write_text(data=regenerate_py_code, encoding="utf-8")
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
layout_output_path = output_path if output_path is not None else agents_dir / "layout.json"
|
|
122
|
+
layout_output_path.write_text(data=json.dumps(layoutfile, indent=4), encoding="utf-8")
|
|
123
|
+
typer.echo(f"Created agents in {agents_dir}")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@app.command()
|
|
127
|
+
def run(layout_path: Path = typer.Argument(..., help="Path to the layout.json file"),
|
|
128
|
+
max_tabs: int = typer.Option(6, help="Maximum number of tabs to launch"),
|
|
129
|
+
sleep_between_layouts: float = typer.Option(1.0, help="Sleep time in seconds between launching layouts")):
|
|
130
|
+
layoutfile: LayoutsFile = json.loads(layout_path.read_text())
|
|
131
|
+
if len(layoutfile["layouts"][0]["layoutTabs"]) > max_tabs:
|
|
132
|
+
typer.echo(f"Too many tabs (>{max_tabs}) to launch. Skipping launch.")
|
|
133
|
+
raise typer.Exit(0)
|
|
145
134
|
from machineconfig.cluster.sessions_managers.zellij_local_manager import ZellijLocalManager
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
135
|
+
for i, a_layouts in enumerate(layoutfile["layouts"]):
|
|
136
|
+
manager = ZellijLocalManager(session_layouts=[a_layouts])
|
|
137
|
+
manager.start_all_sessions(poll_interval=2, poll_seconds=2)
|
|
138
|
+
manager.run_monitoring_routine(wait_ms=2000)
|
|
139
|
+
if i < len(layoutfile["layouts"]) - 1: # Don't sleep after the last layout
|
|
140
|
+
time.sleep(sleep_between_layouts)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@app.command(help="Adjust layout file to limit max tabs per layout, etc.")
|
|
144
|
+
def load_balance(layout_path: Path = typer.Argument(..., help="Path to the layout.json file"),
|
|
145
|
+
max_thresh: int = typer.Option(..., help="Maximum tabs per layout"),
|
|
146
|
+
thresh_type: Literal['number', 'weight'] = typer.Option(..., help="Threshold type"),
|
|
147
|
+
breaking_method: Literal['moreLayouts', 'combineTabs'] = typer.Option(..., help="Breaking method"),
|
|
148
|
+
output_path: Optional[Path] = typer.Option(None, help="Path to write the adjusted layout.json file")):
|
|
149
|
+
layoutfile: LayoutsFile = json.loads(layout_path.read_text())
|
|
150
|
+
layout_configs = layoutfile["layouts"]
|
|
151
|
+
from machineconfig.cluster.sessions_managers.utils.load_balancer import limit_tab_num
|
|
152
|
+
new_layouts = limit_tab_num(layout_configs=layout_configs, max_thresh=max_thresh, threshold_type=thresh_type, breaking_method=breaking_method)
|
|
153
|
+
layoutfile["layouts"] = new_layouts
|
|
154
|
+
target_file = output_path if output_path is not None else layout_path.parent / f'{layout_path.stem}_adjusted_{max_thresh}_{thresh_type}_{breaking_method}.json'
|
|
155
|
+
target_file.write_text(data=json.dumps(layoutfile, indent=4), encoding="utf-8")
|
|
156
|
+
typer.echo(f"Adjusted layout saved to {target_file}")
|
|
150
157
|
|
|
151
158
|
|
|
152
159
|
if __name__ == "__main__": # pragma: no cover
|
|
153
|
-
|
|
160
|
+
app()
|
|
@@ -7,7 +7,7 @@ from typing import Literal, TypeAlias
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
AGENTS: TypeAlias = Literal[
|
|
10
|
-
"cursor-agent", "gemini", "crush", "q"
|
|
10
|
+
"cursor-agent", "gemini", "crush", "q"
|
|
11
11
|
# warp terminal
|
|
12
12
|
]
|
|
13
13
|
AGENT_NAME_FORMATTER = "agent_{idx}_cmd.sh" # e.g., agent_0_cmd.sh
|
|
@@ -34,7 +34,6 @@ def prep_agent_launch(repo_root: Path, prompts_material: list[str], prompt_prefi
|
|
|
34
34
|
prompt_folder = session_root / "prompts"
|
|
35
35
|
prompt_folder.mkdir(parents=True, exist_ok=True)
|
|
36
36
|
|
|
37
|
-
all_materials_scripts: list[Path] = []
|
|
38
37
|
for idx, a_prompt_material in enumerate(prompts_material):
|
|
39
38
|
prompt_root = prompt_folder / f"agent_{idx}"
|
|
40
39
|
prompt_root.mkdir(parents=True, exist_ok=True)
|
|
@@ -43,7 +42,6 @@ def prep_agent_launch(repo_root: Path, prompts_material: list[str], prompt_prefi
|
|
|
43
42
|
prompt_material_path = prompt_root / f"agent_{idx}_material.txt"
|
|
44
43
|
prompt_material_path.write_text(a_prompt_material, encoding="utf-8")
|
|
45
44
|
prompt_path.write_text(prompt_prefix + f"""\nPlease only look @ {prompt_material_path}. You don't need to do any other work beside the content of this material file.""", encoding="utf-8")
|
|
46
|
-
all_materials_scripts.append(prompt_material_path)
|
|
47
45
|
else:
|
|
48
46
|
prompt_material_path = prompt_path
|
|
49
47
|
prompt_path.write_text(prompt_prefix + """\nPlease only look @ the following:\n""" + a_prompt_material, encoding="utf-8")
|
|
@@ -87,7 +85,7 @@ sleep 0.1
|
|
|
87
85
|
cmd = f"""
|
|
88
86
|
export GEMINI_API_KEY={shlex.quote(api_key)}
|
|
89
87
|
echo "Using Gemini API key $GEMINI_API_KEY"
|
|
90
|
-
|
|
88
|
+
gemini {model_arg} --yolo --prompt {safe_path}
|
|
91
89
|
"""
|
|
92
90
|
case "cursor-agent":
|
|
93
91
|
# As originally implemented
|
|
@@ -103,10 +101,6 @@ crush run {prompt_path}
|
|
|
103
101
|
case "q":
|
|
104
102
|
cmd = f"""
|
|
105
103
|
q chat --no-interactive --trust-all-tools {prompt_path}
|
|
106
|
-
"""
|
|
107
|
-
case "onlyPrepPromptFiles":
|
|
108
|
-
cmd = f"""
|
|
109
|
-
echo "Prepared prompt file at {prompt_path}"
|
|
110
104
|
"""
|
|
111
105
|
case _:
|
|
112
106
|
raise ValueError(f"Unsupported agent type: {agent}")
|
|
@@ -116,11 +110,6 @@ echo "---------END OF AGENT OUTPUT---------"
|
|
|
116
110
|
"""
|
|
117
111
|
agent_cmd_launch_path.write_text(cmd_prefix + cmd + cmd_postfix, encoding="utf-8")
|
|
118
112
|
|
|
119
|
-
# print(f"Launching a template with #{len(tab_config)} agents")
|
|
120
|
-
if len(all_materials_scripts) > 0:
|
|
121
|
-
all_materials_list_path = session_root / "all_materials_redistributed.txt"
|
|
122
|
-
all_materials_list_path.write_text("\n".join(str(p) for p in all_materials_scripts), encoding="utf-8")
|
|
123
|
-
print(f"All prompt materials listed @ {all_materials_list_path}")
|
|
124
113
|
return session_root
|
|
125
114
|
|
|
126
115
|
|
|
@@ -130,14 +119,11 @@ def get_agents_launch_layout(session_root: Path):
|
|
|
130
119
|
tab_config: list[TabConfig] = []
|
|
131
120
|
prompt_root = session_root / "prompts"
|
|
132
121
|
all_dirs_under_prompts = [d for d in prompt_root.iterdir() if d.is_dir()]
|
|
133
|
-
launch_agents_squentially = ""
|
|
134
122
|
for a_prompt_dir in all_dirs_under_prompts:
|
|
135
123
|
idx = a_prompt_dir.name.split("_")[-1] # e.g., agent_0 -> 0
|
|
136
124
|
agent_cmd_path = a_prompt_dir / AGENT_NAME_FORMATTER.format(idx=idx)
|
|
137
125
|
fire_cmd = f"bash {shlex.quote(str(agent_cmd_path))}"
|
|
138
126
|
tab_config.append(TabConfig(tabName=f"Agent{idx}", startDir=str(session_root.parent.parent.parent), command=fire_cmd))
|
|
139
|
-
launch_agents_squentially += f". {shlex.quote(str(agent_cmd_path))}\n"
|
|
140
127
|
layout = LayoutConfig(layoutName="Agents", layoutTabs=tab_config)
|
|
141
|
-
(session_root / "launch_all_agents_sequentially.sh").write_text(launch_agents_squentially, encoding="utf-8")
|
|
142
128
|
layouts_file: LayoutsFile = LayoutsFile(version="1.0", layouts=[layout])
|
|
143
129
|
return layouts_file
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
from
|
|
2
|
-
from math import ceil
|
|
1
|
+
# from math import ceil
|
|
3
2
|
from pathlib import Path
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
"agent_cap", # User decides number of agents, rows/tasks determined automatically
|
|
8
|
-
"task_rows", # User decides number of rows/tasks, number of agents determined automatically
|
|
9
|
-
]
|
|
10
|
-
DEFAULT_AGENT_CAP = 6
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def chunk_prompts(prompt_material_path: Path, strategy: SPLITTING_STRATEGY, joiner: str, *, agent_cap: int | None, task_rows: int | None) -> list[str]:
|
|
5
|
+
def chunk_prompts(prompt_material_path: Path, joiner: str, *, tasks_per_prompt: int) -> list[str]:
|
|
14
6
|
"""Chunk prompts based on splitting strategy.
|
|
15
7
|
|
|
16
8
|
Args:
|
|
@@ -20,31 +12,11 @@ def chunk_prompts(prompt_material_path: Path, strategy: SPLITTING_STRATEGY, join
|
|
|
20
12
|
task_rows: Number of rows/tasks per agent (used with 'task_rows' strategy)
|
|
21
13
|
"""
|
|
22
14
|
prompts = [p for p in prompt_material_path.read_text(encoding="utf-8", errors="ignore").split(joiner) if p.strip() != ""] # drop blank entries
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
print(f"Chunking {len(prompts)} prompts into groups for up to {agent_cap} agents because it exceeds the cap.")
|
|
32
|
-
chunk_size = ceil(len(prompts) / agent_cap)
|
|
33
|
-
grouped: list[str] = []
|
|
34
|
-
for i in range(0, len(prompts), chunk_size):
|
|
35
|
-
grouped.append(joiner.join(prompts[i : i + chunk_size]))
|
|
36
|
-
return grouped
|
|
37
|
-
|
|
38
|
-
elif strategy == "task_rows":
|
|
39
|
-
if task_rows is None:
|
|
40
|
-
raise ValueError("task_rows must be provided when using 'task_rows' strategy")
|
|
41
|
-
if task_rows >= len(prompts):
|
|
42
|
-
return prompts
|
|
43
|
-
print(f"Chunking {len(prompts)} prompts into groups of {task_rows} rows/tasks each.")
|
|
44
|
-
grouped: list[str] = []
|
|
45
|
-
for i in range(0, len(prompts), task_rows):
|
|
46
|
-
grouped.append(joiner.join(prompts[i : i + task_rows]))
|
|
47
|
-
return grouped
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
raise ValueError(f"Unknown splitting strategy: {strategy}")
|
|
15
|
+
if tasks_per_prompt >= len(prompts):
|
|
16
|
+
print("No need to chunk prompts, as tasks_per_prompt >= total prompts.", f"({tasks_per_prompt} >= {len(prompts)})")
|
|
17
|
+
return prompts
|
|
18
|
+
print(f"Chunking {len(prompts)} prompts into groups of {tasks_per_prompt} rows/tasks each.")
|
|
19
|
+
grouped: list[str] = []
|
|
20
|
+
for i in range(0, len(prompts), tasks_per_prompt):
|
|
21
|
+
grouped.append(joiner.join(prompts[i : i + tasks_per_prompt]))
|
|
22
|
+
return grouped
|
|
@@ -6,7 +6,6 @@ capturing all user inputs collected during interactive execution.
|
|
|
6
6
|
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from typing import TypedDict, Literal, NotRequired
|
|
9
|
-
from machineconfig.scripts.python.fire_agents_load_balancer import SPLITTING_STRATEGY
|
|
10
9
|
from machineconfig.scripts.python.fire_agents_help_launch import AGENTS
|
|
11
10
|
|
|
12
11
|
SEARCH_STRATEGIES = Literal["file_path", "keyword_search", "filename_pattern"]
|
|
@@ -21,26 +20,17 @@ class FilePathSearchInput(TypedDict):
|
|
|
21
20
|
|
|
22
21
|
class KeywordSearchInput(TypedDict):
|
|
23
22
|
"""Input for keyword_search strategy."""
|
|
24
|
-
|
|
25
23
|
keyword: str
|
|
26
24
|
|
|
27
25
|
|
|
28
26
|
class FilenamePatternSearchInput(TypedDict):
|
|
29
27
|
"""Input for filename_pattern search strategy."""
|
|
30
|
-
|
|
31
28
|
pattern: str # e.g., '*.py', '*test*', 'config.*'
|
|
32
29
|
|
|
33
30
|
|
|
34
|
-
class
|
|
35
|
-
"""Input for
|
|
36
|
-
|
|
37
|
-
agent_cap: int # Default: 6
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class TaskRowsSplittingInput(TypedDict):
|
|
41
|
-
"""Input for task_rows splitting strategy."""
|
|
42
|
-
|
|
43
|
-
task_rows: int # Default: 13
|
|
31
|
+
class TasksPerPromptSplittingInput(TypedDict):
|
|
32
|
+
"""Input for tasks_per_prompt splitting strategy."""
|
|
33
|
+
tasks_per_prompt: int # Default: 13
|
|
44
34
|
|
|
45
35
|
|
|
46
36
|
class FireAgentsMainInput(TypedDict):
|
|
@@ -49,7 +39,6 @@ class FireAgentsMainInput(TypedDict):
|
|
|
49
39
|
# Core configuration
|
|
50
40
|
repo_root: Path
|
|
51
41
|
search_strategy: SEARCH_STRATEGIES
|
|
52
|
-
splitting_strategy: SPLITTING_STRATEGY
|
|
53
42
|
agent_selected: AGENTS
|
|
54
43
|
prompt_prefix: str
|
|
55
44
|
job_name: str # Default: "AI_Agents"
|
|
@@ -62,8 +51,7 @@ class FireAgentsMainInput(TypedDict):
|
|
|
62
51
|
filename_pattern_input: NotRequired[FilenamePatternSearchInput]
|
|
63
52
|
|
|
64
53
|
# Splitting strategy specific inputs (only one will be present based on splitting_strategy)
|
|
65
|
-
|
|
66
|
-
task_rows_input: NotRequired[TaskRowsSplittingInput]
|
|
54
|
+
tasks_per_prompt: TasksPerPromptSplittingInput
|
|
67
55
|
|
|
68
56
|
|
|
69
57
|
class FireAgentsRuntimeData(TypedDict):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: machineconfig
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.4
|
|
4
4
|
Summary: Dotfiles management package
|
|
5
5
|
Author-email: Alex Al-Saffar <programmer@usa.com>
|
|
6
6
|
License: Apache 2.0
|
|
@@ -26,6 +26,7 @@ Requires-Dist: rclone-python>=0.1.23
|
|
|
26
26
|
Requires-Dist: pyjson5>=1.6.9
|
|
27
27
|
Requires-Dist: typer-slim>=0.19.2
|
|
28
28
|
Requires-Dist: questionary>=2.1.1
|
|
29
|
+
Requires-Dist: typer>=0.19.2
|
|
29
30
|
Provides-Extra: windows
|
|
30
31
|
Requires-Dist: pywin32; extra == "windows"
|
|
31
32
|
Provides-Extra: docs
|
|
@@ -155,10 +155,10 @@ machineconfig/scripts/python/devops_backup_retrieve.py,sha256=jZe5Vki7E2GCMG8hvq
|
|
|
155
155
|
machineconfig/scripts/python/devops_devapps_install.py,sha256=QbRQhNdDRLLtgJwaRl2pbLmWvajb1b_Xte2ql8N3JRs,9096
|
|
156
156
|
machineconfig/scripts/python/devops_update_repos.py,sha256=c5qBc9cuTGDEqDHufkjDT4d_vvJsswv3tlqk9MAulYk,8063
|
|
157
157
|
machineconfig/scripts/python/dotfile.py,sha256=SRcX-9Ak1jRvF-killBTTm2IWcsNxfiLucH6ZsytAFA,2202
|
|
158
|
-
machineconfig/scripts/python/fire_agents.py,sha256=
|
|
159
|
-
machineconfig/scripts/python/fire_agents_help_launch.py,sha256=
|
|
158
|
+
machineconfig/scripts/python/fire_agents.py,sha256=An6OE2dVyni_XGt3V-5kMhPxDSfXOnJuO2N6AokQHyo,8860
|
|
159
|
+
machineconfig/scripts/python/fire_agents_help_launch.py,sha256=TpuARLC_9b3SNMYeYIi_h1qKCSifT074QEvZ-ZK967M,5264
|
|
160
160
|
machineconfig/scripts/python/fire_agents_help_search.py,sha256=qIfSS_su2YJ1Gb0_lu4cbjlJlYMBw0v52NTGiSrGjk8,2991
|
|
161
|
-
machineconfig/scripts/python/fire_agents_load_balancer.py,sha256=
|
|
161
|
+
machineconfig/scripts/python/fire_agents_load_balancer.py,sha256=mpqx3uaQdBXYieuvhdK-qsvLepf9oIMo3pwPj9mSEDI,1079
|
|
162
162
|
machineconfig/scripts/python/fire_jobs.py,sha256=qD_9JtoNTjOjAyX0_QPysfHNQ-qq55t-Tv9ctEK17MI,20569
|
|
163
163
|
machineconfig/scripts/python/fire_jobs_args_helper.py,sha256=VsyPgjWRByZgXz65vmmpyR-2mJo6KwNgwrWFYd3EYqc,2075
|
|
164
164
|
machineconfig/scripts/python/fire_jobs_layout_helper.py,sha256=LHLyp5HxKwut19x2OYKQq8gy4EKon6wNb-jlxx5DoVM,4134
|
|
@@ -402,12 +402,12 @@ machineconfig/utils/installer_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
|
|
|
402
402
|
machineconfig/utils/installer_utils/github_release_bulk.py,sha256=vK5WJ-a566egAIEHdKsn3iOAh5LBqeY4zPDHPgqHVcE,6887
|
|
403
403
|
machineconfig/utils/installer_utils/installer_abc.py,sha256=3jjLHL1xqTPowx52r7BfhjpzF6LQA7CRudjN2QYJP34,10551
|
|
404
404
|
machineconfig/utils/installer_utils/installer_class.py,sha256=6IQswaC9mxIdeaMG-rOt-vqyKGYibBRMvC0UglZ_3mI,20268
|
|
405
|
-
machineconfig/utils/schemas/fire_agents/fire_agents_input.py,sha256=
|
|
405
|
+
machineconfig/utils/schemas/fire_agents/fire_agents_input.py,sha256=pTxvLzIpD5RF508lUUBBkWcc4V1B10J4ylvVgVGkcM0,2037
|
|
406
406
|
machineconfig/utils/schemas/installer/installer_types.py,sha256=DLagmIe0G5-xg7HZ9VrlFCDk1gIbwvX7O4gZjwq0wh0,1326
|
|
407
407
|
machineconfig/utils/schemas/layouts/layout_types.py,sha256=TcqlZdGVoH8htG5fHn1KWXhRdPueAcoyApppZsPAPto,2020
|
|
408
408
|
machineconfig/utils/schemas/repos/repos_types.py,sha256=ECVr-3IVIo8yjmYmVXX2mnDDN1SLSwvQIhx4KDDQHBQ,405
|
|
409
|
-
machineconfig-4.
|
|
410
|
-
machineconfig-4.
|
|
411
|
-
machineconfig-4.
|
|
412
|
-
machineconfig-4.
|
|
413
|
-
machineconfig-4.
|
|
409
|
+
machineconfig-4.4.dist-info/METADATA,sha256=lyni_bLaEQayMHJkaaRhSCbb0g7svm5l25Ek_EaQ7lw,7060
|
|
410
|
+
machineconfig-4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
411
|
+
machineconfig-4.4.dist-info/entry_points.txt,sha256=fhSTJGrT7JZ7PcN-F3nrb5xXIohicZo57rbM23Mdblk,1065
|
|
412
|
+
machineconfig-4.4.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
|
|
413
|
+
machineconfig-4.4.dist-info/RECORD,,
|
|
@@ -7,7 +7,7 @@ cloud_sync = machineconfig.scripts.python.cloud_sync:arg_parser
|
|
|
7
7
|
croshell = machineconfig.scripts.python.croshell:arg_parser
|
|
8
8
|
devops = machineconfig.scripts.python.devops:app
|
|
9
9
|
fire = machineconfig.scripts.python.fire_jobs:main_from_parser
|
|
10
|
-
fire_agents = machineconfig.scripts.python.fire_agents:
|
|
10
|
+
fire_agents = machineconfig.scripts.python.fire_agents:app
|
|
11
11
|
ftpx = machineconfig.scripts.python.ftpx:main_from_parser
|
|
12
12
|
initai = machineconfig.scripts.python.ai.initai:main
|
|
13
13
|
kill_process = machineconfig.utils.procs:main
|
|
File without changes
|
|
File without changes
|