machineconfig 5.66__py3-none-any.whl → 5.67__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.

@@ -9,15 +9,13 @@ from machineconfig.scripts.python.helpers_fire.fire_agents_helper_types import A
9
9
 
10
10
 
11
11
  def create(
12
- context_path: Path = typer.Argument(..., help="Path to the context file"),
12
+ agent: AGENTS = typer.Option(default=..., help=f"Agent type. One of {', '.join(get_args(AGENTS)[:3])}"),
13
+ machine: MATCHINE = typer.Option(default=..., help=f"Machine to run agents on. One of {', '.join(get_args(MATCHINE))}"),
14
+ model: MODEL = typer.Option(default=..., help=f"Model to use (for crush agent). One of {', '.join(get_args(MODEL)[:3])}"),
15
+ provider: PROVIDER = typer.Option(default=..., help=f"Provider to use (for crush agent). One of {', '.join(get_args(PROVIDER)[:3])}"),
16
+ context_path: Optional[Path] = typer.Option(None, help="Path to the context file/folder, defaults to .ai/todo/"),
13
17
  separator: str = typer.Option("\n", help="Separator for context"),
14
18
  tasks_per_prompt: int = typer.Option(13, help="Number of tasks per prompt"),
15
-
16
- agent: AGENTS = typer.Option(..., help=f"Agent type. One of {', '.join(get_args(AGENTS))}"),
17
- machine: MATCHINE = typer.Option(..., help=f"Machine to run agents on. One of {', '.join(get_args(MATCHINE))}"),
18
- model: MODEL = typer.Option(..., help=f"Model to use (for crush agent). One of {', '.join(get_args(MODEL))}"),
19
- provider: PROVIDER = typer.Option(..., help=f"Provider to use (for crush agent). One of {', '.join(get_args(PROVIDER))}"),
20
-
21
19
  prompt: Optional[str] = typer.Option(None, help="Prompt prefix as string"),
22
20
  prompt_path: Optional[Path] = typer.Option(None, help="Path to prompt file"),
23
21
  job_name: str = typer.Option("AI_Agents", help="Job name"),
@@ -43,12 +41,23 @@ def create(
43
41
  raise typer.Exit(1)
44
42
  typer.echo(f"Operating @ {repo_root}")
45
43
 
46
- prompt_material_path = Path("")
44
+ if context_path is None:
45
+ context_path = repo_root / ".ai" / "todo"
46
+
47
+ context_path_resolved = context_path.expanduser().resolve()
48
+ if not context_path_resolved.exists():
49
+ raise typer.BadParameter(f"Path does not exist: {context_path_resolved}")
47
50
 
48
- target_file_path = context_path.expanduser().resolve()
49
- if not target_file_path.exists() or not target_file_path.is_file():
50
- raise typer.BadParameter(f"Invalid file path: {target_file_path}")
51
- prompt_material_path = target_file_path
51
+ if context_path_resolved.is_file():
52
+ prompt_material_re_splitted = chunk_prompts(context_path_resolved, tasks_per_prompt=tasks_per_prompt, joiner=separator)
53
+ elif context_path_resolved.is_dir():
54
+ files = [f for f in context_path_resolved.rglob("*") if f.is_file()]
55
+ if not files:
56
+ raise typer.BadParameter(f"No files found in directory: {context_path_resolved}")
57
+ concatenated = separator.join(f.read_text(encoding="utf-8") for f in files)
58
+ prompt_material_re_splitted = [concatenated]
59
+ else:
60
+ raise typer.BadParameter(f"Path is neither file nor directory: {context_path_resolved}")
52
61
 
53
62
  if prompt_path is not None:
54
63
  prompt_prefix = prompt_path.read_text(encoding="utf-8")
@@ -56,7 +65,6 @@ def create(
56
65
  prompt_prefix = cast(str, prompt)
57
66
  agent_selected = agent
58
67
  keep_material_in_separate_file_input = separate_prompt_from_context
59
- prompt_material_re_splitted = chunk_prompts(prompt_material_path, tasks_per_prompt=tasks_per_prompt, joiner=separator)
60
68
  if agents_dir is None: agents_dir = repo_root / ".ai" / f"tmp_prompts/{job_name}_{randstr()}"
61
69
  else:
62
70
  import shutil
@@ -69,7 +77,7 @@ def create(
69
77
  layoutfile = get_agents_launch_layout(session_root=agents_dir)
70
78
  regenerate_py_code = f"""
71
79
  #!/usr/bin/env uv run --python 3.14 --with machineconfig
72
- agents create "{prompt_material_path}" \\
80
+ agents create "{context_path_resolved}" \\
73
81
  --prompt-path "{prompt_path or ''}" \\
74
82
  --agent "{agent_selected}" \\
75
83
  --machine "{machine}" \\
@@ -153,8 +161,18 @@ def init_config():
153
161
  add_ai_configs(repo_root=Path.cwd())
154
162
 
155
163
  def get_app():
156
- agents_app = typer.Typer(help="🤖 AI Agents management subcommands")
157
- agents_app.command("create", no_args_is_help=True, help="Create agents layout file, ready to run.")(create)
164
+ agents_app = typer.Typer(help="🤖 AI Agents management subcommands", no_args_is_help=True)
165
+ sep = "\n"
166
+ agents_full_help = f"""
167
+ Create agents layout file, ready to run.
168
+ {sep}
169
+ PROVIDER options: {', '.join(get_args(PROVIDER))}
170
+ {sep}
171
+ AGENT options: {', '.join(get_args(AGENTS))}
172
+ {sep}
173
+ MODEL options: {sep.join(get_args(MODEL))}
174
+ """
175
+ agents_app.command("create", no_args_is_help=True, help=agents_full_help)(create)
158
176
  agents_app.command("collect", no_args_is_help=True, help="Collect all agent materials into a single file.")(collect)
159
177
  agents_app.command("make-template", no_args_is_help=False, help="Create a template for fire agents")(template)
160
178
  agents_app.command("make-config", no_args_is_help=False, help="Initialize AI configurations in the current repository")(init_config)
@@ -164,14 +182,10 @@ def get_app():
164
182
  agents_app.command(name="make-symlinks", no_args_is_help=True, help="Create symlinks to the current repo in ~/code_copies/")(create_symlink_command)
165
183
  return agents_app
166
184
 
185
+
167
186
  def main():
168
187
  agents_app = get_app()
169
- import sys
170
- if len(sys.argv) == 1:
171
- agents_app(["--help"])
172
- else:
173
- agents_app()
174
-
188
+ agents_app()
175
189
 
176
190
  if __name__ == "__main__": # pragma: no cover
177
191
  pass
@@ -2,11 +2,12 @@
2
2
  """Script to generate a markdown table with checkboxes for all Python and shell files in the repo."""
3
3
 
4
4
  from pathlib import Path
5
- from typing import Annotated, Literal
5
+ from typing import Annotated, Literal, Optional
6
6
  from rich.console import Console
7
7
  from rich.panel import Panel
8
8
  import typer
9
9
  import subprocess
10
+ import shutil
10
11
 
11
12
 
12
13
  def get_python_files(repo_root: Path, exclude_init: bool = False) -> list[str]:
@@ -112,6 +113,47 @@ def filter_files_by_content(repo_root: Path, files: list[str], keyword: str) ->
112
113
  return filtered_files
113
114
 
114
115
 
116
+ def generate_csv_content(python_files: list[str], shell_files: list[str], repo_root: Path, include_line_count: bool = False) -> str:
117
+ """Generate CSV content with file information."""
118
+ import csv
119
+ import io
120
+
121
+ output = io.StringIO()
122
+ writer = csv.writer(output)
123
+
124
+ # Write header
125
+ if include_line_count:
126
+ writer.writerow(["Type", "Index", "File Path", "Line Count", "Status"])
127
+ else:
128
+ writer.writerow(["Type", "Index", "File Path", "Status"])
129
+
130
+ # Write Python files
131
+ for index, file_path in enumerate(python_files, start=1):
132
+ clean_path = file_path.lstrip("./")
133
+ if include_line_count:
134
+ line_count = count_lines(repo_root / file_path)
135
+ writer.writerow(["Python", index, clean_path, line_count, "[ ]"])
136
+ else:
137
+ writer.writerow(["Python", index, clean_path, "[ ]"])
138
+
139
+ # Write shell files
140
+ for index, file_path in enumerate(shell_files, start=1):
141
+ clean_path = file_path.lstrip("./")
142
+ if include_line_count:
143
+ line_count = count_lines(repo_root / file_path)
144
+ writer.writerow(["Shell", index, clean_path, line_count, "[ ]"])
145
+ else:
146
+ writer.writerow(["Shell", index, clean_path, "[ ]"])
147
+
148
+ return output.getvalue()
149
+
150
+
151
+ def generate_txt_content(python_files: list[str], shell_files: list[str]) -> str:
152
+ """Generate plain text content with file paths."""
153
+ all_files = python_files + shell_files
154
+ return "\n".join(file.lstrip("./") for file in all_files)
155
+
156
+
115
157
  def generate_markdown_table(python_files: list[str], shell_files: list[str], repo_root: Path, include_line_count: bool = False) -> str:
116
158
  """Generate markdown table with checkboxes."""
117
159
  header = "# File Checklist\n\n"
@@ -159,6 +201,40 @@ def generate_markdown_table(python_files: list[str], shell_files: list[str], rep
159
201
  return header + content
160
202
 
161
203
 
204
+ def split_files_into_chunks(all_files: list[str], split_every: Optional[int] = None, split_to: Optional[int] = None) -> list[list[str]]:
205
+ """Split files into chunks based on split_every or split_to."""
206
+ if split_every is not None:
207
+ # Split into chunks of split_every files each
208
+ return [all_files[i:i + split_every] for i in range(0, len(all_files), split_every)]
209
+ elif split_to is not None:
210
+ # Split into exactly split_to chunks
211
+ if split_to <= 0:
212
+ return [all_files]
213
+ chunk_size = max(1, len(all_files) // split_to)
214
+ chunks = []
215
+ for i in range(split_to):
216
+ start = i * chunk_size
217
+ end = start + chunk_size if i < split_to - 1 else len(all_files)
218
+ chunks.append(all_files[start:end])
219
+ return chunks
220
+ else:
221
+ # No splitting
222
+ return [all_files]
223
+
224
+
225
+ def generate_content(python_files: list[str], shell_files: list[str], repo_root: Path,
226
+ format_type: str, include_line_count: bool) -> str:
227
+ """Generate content based on format type."""
228
+ if format_type == "csv":
229
+ return generate_csv_content(python_files, shell_files, repo_root, include_line_count)
230
+ elif format_type == "md":
231
+ return generate_markdown_table(python_files, shell_files, repo_root, include_line_count)
232
+ elif format_type == "txt":
233
+ return generate_txt_content(python_files, shell_files)
234
+ else:
235
+ raise ValueError(f"Unsupported format: {format_type}")
236
+
237
+
162
238
  def create_repo_symlinks(repo_root: Path) -> None:
163
239
  """Create 5 symlinks to repo_root at ~/code_copies/${repo_name}_copy_{i}."""
164
240
  repo_name: str = repo_root.name
@@ -174,22 +250,30 @@ def create_repo_symlinks(repo_root: Path) -> None:
174
250
  def main(
175
251
  pattern: Annotated[str, typer.Argument(help="Pattern or keyword to match files by")],
176
252
  repo: Annotated[str, typer.Argument(help="Repository path. Can be any directory within a git repository.")] = str(Path.cwd()),
177
- strategy: Annotated[Literal["name", "keywords"], typer.Option("--strategy", help="Strategy to filter files: 'name' for filename matching, 'keywords' for content matching")] = "name",
178
- exclude_init: Annotated[bool, typer.Option("--exclude-init", help="Exclude __init__.py files from the checklist")] = False,
179
- include_line_count: Annotated[bool, typer.Option("--line-count", help="Include line count column in the markdown table")] = False,
180
- output_path: Annotated[str, typer.Option("--output-path", help="Path to output the markdown file relative to repo root")] = ".ai/todo/all_files_with_index.md",
253
+ strategy: Annotated[Literal["name", "keywords"], typer.Option("-s", "--strategy", help="Strategy to filter files: 'name' for filename matching, 'keywords' for content matching")] = "name",
254
+ exclude_init: Annotated[bool, typer.Option("-e", "--exclude-init", help="Exclude __init__.py files from the checklist")] = False,
255
+ include_line_count: Annotated[bool, typer.Option("-l", "--line-count", help="Include line count column in the output")] = False,
256
+ output_path: Annotated[str, typer.Option("-o", "--output-path", help="Base path for output files relative to repo root")] = ".ai/todo/files",
257
+ format_type: Annotated[Literal["csv", "md", "txt"], typer.Option("-f", "--format", help="Output format: csv, md (markdown), or txt")] = "md",
258
+ split_every: Annotated[Optional[int], typer.Option("--split-every", help="Split output into multiple files, each containing at most this many results")] = None,
259
+ split_to: Annotated[Optional[int], typer.Option("--split-to", help="Split output into exactly this many files")] = None,
181
260
  ) -> None:
182
- """Generate markdown checklist with Python and shell script files in the repository filtered by pattern."""
261
+ """Generate checklist with Python and shell script files in the repository filtered by pattern."""
183
262
  repo_path = Path(repo).expanduser().absolute()
184
263
  if not is_git_repository(repo_path):
185
264
  console = Console()
186
265
  console.print(Panel(f"❌ ERROR | Not a git repository or not in a git repository: {repo_path}", border_style="bold red", expand=False))
187
266
  raise typer.Exit(code=1)
188
267
 
189
- output_file = repo_path / output_path
268
+ # Delete .ai/todo directory at the start
269
+ todo_dir = repo_path / ".ai" / "todo"
270
+ if todo_dir.exists():
271
+ shutil.rmtree(todo_dir)
272
+
273
+ output_base = repo_path / output_path
190
274
 
191
275
  # Ensure output directory exists
192
- output_file.parent.mkdir(parents=True, exist_ok=True)
276
+ output_base.parent.mkdir(parents=True, exist_ok=True)
193
277
 
194
278
  # Get Python and shell files
195
279
  python_files = get_python_files(repo_path, exclude_init=exclude_init)
@@ -206,20 +290,46 @@ def main(
206
290
  print(f"Repo path: {repo_path}")
207
291
  print(f"Strategy: {strategy}")
208
292
  print(f"Pattern: {pattern}")
293
+ print(f"Format: {format_type}")
209
294
  print(f"Found {len(python_files)} Python files")
210
295
  print(f"Found {len(shell_files)} Shell script files")
211
296
 
212
- # Generate markdown
213
- markdown_content = generate_markdown_table(python_files, shell_files, repo_path, include_line_count)
214
-
215
- # Write to file
216
- output_file.write_text(markdown_content)
297
+ # Combine all files for splitting
298
+ all_files = python_files + shell_files
299
+
300
+ # Split files into chunks
301
+ file_chunks = split_files_into_chunks(all_files, split_every, split_to)
302
+
303
+ # Determine file extension based on format
304
+ extension = {"csv": ".csv", "md": ".md", "txt": ".txt"}[format_type]
305
+
306
+ output_files = []
307
+ for i, chunk in enumerate(file_chunks):
308
+ # Split chunk back into python and shell files
309
+ chunk_python = [f for f in chunk if f in python_files]
310
+ chunk_shell = [f for f in chunk if f in shell_files]
311
+
312
+ # Generate content for this chunk
313
+ content = generate_content(chunk_python, chunk_shell, repo_path, format_type, include_line_count)
314
+
315
+ # Determine output file path
316
+ if len(file_chunks) == 1:
317
+ output_file = output_base.with_suffix(extension)
318
+ else:
319
+ output_file = output_base.parent / f"{output_base.name}_{i+1}{extension}"
320
+
321
+ # Write to file
322
+ output_file.write_text(content)
323
+ output_files.append(output_file)
217
324
 
218
325
  console = Console()
219
- console.print(Panel(f"""✅ SUCCESS | Markdown checklist generated successfully!
220
- 📄 File Location: {output_file}
326
+ success_msg = f"""✅ SUCCESS | Files generated successfully!
327
+ 📄 Output files: {', '.join(str(f.relative_to(repo_path)) for f in output_files)}
221
328
  🐍 Python files: {len(python_files)}
222
- 🔧 Shell files: {len(shell_files)}""", border_style="bold blue", expand=False))
329
+ 🔧 Shell files: {len(shell_files)}
330
+ 📊 Total chunks: {len(file_chunks)}"""
331
+
332
+ console.print(Panel(success_msg, border_style="bold blue", expand=False))
223
333
 
224
334
 
225
335
  def create_symlink_command(num: Annotated[int, typer.Argument(help="Number of symlinks to create (1-5).")] = 5) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machineconfig
3
- Version: 5.66
3
+ Version: 5.67
4
4
  Summary: Dotfiles management package
5
5
  Author-email: Alex Al-Saffar <programmer@usa.com>
6
6
  License: Apache 2.0
@@ -120,7 +120,7 @@ machineconfig/scripts/linux/other/share_smb,sha256=HZX8BKgMlS9JzkGIYnxTsPvoxEBBu
120
120
  machineconfig/scripts/linux/other/start_docker,sha256=_yDN_PPqgzSUnPT7dmniMTpL4IfeeaGy1a2OL3IJlDU,525
121
121
  machineconfig/scripts/linux/other/switch_ip,sha256=NQfeKMBSbFY3eP6M-BadD-TQo5qMP96DTp77KHk2tU8,613
122
122
  machineconfig/scripts/python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
- machineconfig/scripts/python/agents.py,sha256=hWft2sX7ruBU7nmvBfdrjtqNE4Stpu29W12KI-qhPRQ,8721
123
+ machineconfig/scripts/python/agents.py,sha256=FzIGkXEP7k7e11NfUhCmB7R2tOLT6WTiwY0LNHkqWxM,9470
124
124
  machineconfig/scripts/python/cloud.py,sha256=_05zIiBzG4fKhFytg9mjvMBv4qMUtQJL0RtpYUJFZ3Y,920
125
125
  machineconfig/scripts/python/croshell.py,sha256=WGTsrk-ywJgotsZoWeFjUlY52r3YfmQa1gZHTBmZOA4,7186
126
126
  machineconfig/scripts/python/devops.py,sha256=U0_6h9R-1b9PBQraTVoYAzrhGdtjbwyVjlJl4iyeF2E,1583
@@ -131,7 +131,7 @@ machineconfig/scripts/python/ftpx.py,sha256=Kgp0dKX_ULqLV2SP7-G9S_3yjpCqmNUu86X9
131
131
  machineconfig/scripts/python/interactive.py,sha256=Ulxi1Abku8-FtIU7fVtB9PK2cYM3QdH8WuOb9seSCTw,11790
132
132
  machineconfig/scripts/python/sessions.py,sha256=PaMqJvlTbBdz_q5KxLiPwmpDGZvieg0ZTwqOxaoFfrA,9080
133
133
  machineconfig/scripts/python/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
134
- machineconfig/scripts/python/ai/generate_files.py,sha256=5nFiXc__J_8jy77y2B6jWMleCso2zP4Z3YQpZENqH5s,9829
134
+ machineconfig/scripts/python/ai/generate_files.py,sha256=ZRvPwsfQKHNYwkrVjNhJRf-k9xdyo4eaUyOOrDSaY6M,14480
135
135
  machineconfig/scripts/python/ai/initai.py,sha256=53MuUgk92avRPM-U3dy6o_pnEj2thlurC8U6dz41_W0,2089
136
136
  machineconfig/scripts/python/ai/scripts/lint_and_type_check.ps1,sha256=m_z4vzLrvi6bgTZumN8twcbIWb9i8ZHfVJPE8jPdxyc,5074
137
137
  machineconfig/scripts/python/ai/scripts/lint_and_type_check.sh,sha256=Mt9D0LSEwbvVaq_wxTAch4NLyFUuDGHjn6rtEt_9alU,4615
@@ -414,8 +414,8 @@ machineconfig/utils/schemas/fire_agents/fire_agents_input.py,sha256=Xbi59rU35AzR
414
414
  machineconfig/utils/schemas/installer/installer_types.py,sha256=QClRY61QaduBPJoSpdmTIdgS9LS-RvE-QZ-D260tD3o,1214
415
415
  machineconfig/utils/schemas/layouts/layout_types.py,sha256=TcqlZdGVoH8htG5fHn1KWXhRdPueAcoyApppZsPAPto,2020
416
416
  machineconfig/utils/schemas/repos/repos_types.py,sha256=ECVr-3IVIo8yjmYmVXX2mnDDN1SLSwvQIhx4KDDQHBQ,405
417
- machineconfig-5.66.dist-info/METADATA,sha256=BdV63xX7hcbFUOPR31m0wbyRF5oK3fnC2edq8ux033w,3103
418
- machineconfig-5.66.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
419
- machineconfig-5.66.dist-info/entry_points.txt,sha256=M0jwN_brZdXWhmNVeXLvdKxfkv8WhhXFZYcuKBA9qnk,418
420
- machineconfig-5.66.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
421
- machineconfig-5.66.dist-info/RECORD,,
417
+ machineconfig-5.67.dist-info/METADATA,sha256=DNDZeLnBz-OBogYt6KWfkdwQcrvoviW51FHBeAr8gbY,3103
418
+ machineconfig-5.67.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
419
+ machineconfig-5.67.dist-info/entry_points.txt,sha256=M0jwN_brZdXWhmNVeXLvdKxfkv8WhhXFZYcuKBA9qnk,418
420
+ machineconfig-5.67.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
421
+ machineconfig-5.67.dist-info/RECORD,,