remove outdated commands: preflight, utils, self legacy group

preflight referenced non-existent work-order.md (replaced by agent-tasks.md).
utils only contained albany-cleanup (Albany supercomputer no longer used).
self was a legacy backward-compat group — update/uninstall are already top-level.
This commit is contained in:
Zhengshou Lai
2026-05-05 00:19:25 +08:00
parent 3e4cf618a8
commit c75cba9fee
6 changed files with 5 additions and 172 deletions
-2
View File
@@ -31,8 +31,6 @@ mytoolkit --help
| `ssh` | `list` / `connect` / `tunnel` / `cmd` |
| `git` | `proxy` (set/unset/list/status) |
| `server` | Manage dev/serve servers |
| `preflight` | Pre-flight checks for work-order execution |
| `utils` | `albany-cleanup` |
| `update` | Reinstall from local repo |
| `uninstall` | Uninstall |
+2 -7
View File
@@ -4,7 +4,7 @@ from pathlib import Path
import click
from bin.commands import pdf, image, latex, video, bib, utils
from bin.commands import pdf, image, latex, video, bib
from bin.commands.convert import convert_cmd
from bin.commands.env import env_cmd
from bin.commands.templates import templates_cmd
@@ -13,9 +13,7 @@ from bin.commands.git import git_cmd
from bin.commands.server import server_cmd
from bin.commands.webpage import webpage_cmd
from bin.commands.mail import mail
from bin.commands.preflight import preflight_cmd
from bin.commands.self_mgmt import update_cmd, uninstall_cmd, self_cmd
from bin.utils import handle_errors
from bin.commands.self_mgmt import update_cmd, uninstall_cmd
@click.group()
@@ -32,7 +30,6 @@ cli.add_command(image.image)
cli.add_command(latex.latex)
cli.add_command(video.video)
cli.add_command(bib.bib)
cli.add_command(utils.utils)
cli.add_command(env_cmd)
cli.add_command(templates_cmd)
cli.add_command(ssh_cmd)
@@ -40,10 +37,8 @@ cli.add_command(git_cmd)
cli.add_command(server_cmd)
cli.add_command(webpage_cmd)
cli.add_command(mail)
cli.add_command(preflight_cmd)
cli.add_command(update_cmd)
cli.add_command(uninstall_cmd)
cli.add_command(self_cmd)
def main():
+3 -3
View File
@@ -1,11 +1,11 @@
"""MyCLI subcommands."""
from . import pdf, image, latex, video, bib, utils
from . import pdf, image, latex, video, bib
from .env import env_cmd
from .ssh import ssh_cmd
from .git import git_cmd
from .server import server_cmd
from .webpage import webpage_cmd
from .self_mgmt import self_cmd, update_cmd, uninstall_cmd
from .self_mgmt import update_cmd, uninstall_cmd
__all__ = ["pdf", "image", "latex", "video", "bib", "utils", "env_cmd", "ssh_cmd", "git_cmd", "server_cmd", "webpage_cmd", "self_cmd", "update_cmd", "uninstall_cmd"]
__all__ = ["pdf", "image", "latex", "video", "bib", "env_cmd", "ssh_cmd", "git_cmd", "server_cmd", "webpage_cmd", "update_cmd", "uninstall_cmd"]
-119
View File
@@ -1,119 +0,0 @@
"""Pre-flight check for work-order consistency and system health."""
import json
import os
import re
import sys
from pathlib import Path
import click
@click.command(name="preflight")
def preflight_cmd():
"""Run pre-flight checks before executing work orders."""
issues = []
warnings = []
click.secho("Running pre-flight checks...", fg="cyan")
click.echo("")
# === Check 1: work-order.md vs checkpoint JSON consistency ===
work_order = Path.home() / "workspace/assistant/work-order.md"
if work_order.exists():
content = work_order.read_text()
# Find progress numbers like "进度: X/Y 步骤"
progress_match = re.search(r"进度[:]\s*(\d+)/(\d+)\s*步骤", content)
if progress_match:
wo_current = int(progress_match.group(1))
wo_total = int(progress_match.group(2))
# Find checkpoint files referenced in work-order
cp_match = re.search(r"进度档[:]\s*(\S+)", content)
if cp_match:
cp_path = Path.home() / "workspace" / cp_match.group(1)
if cp_path.exists():
try:
cp = json.loads(cp_path.read_text())
cp_current = cp.get("currentStep", 0)
cp_total = cp.get("totalSteps", 0)
cp_completed = len(cp.get("completedSteps", []))
if wo_current != cp_current or wo_total != cp_total:
issues.append(
f"进度不一致: 工作单 {wo_current}/{wo_total} vs 进度档 {cp_current}/{cp_total}"
)
elif cp_current != cp_completed + 1 and cp_current <= cp_total:
# currentStep should be next step to do (completed + 1)
# unless all completed
pass
except json.JSONDecodeError:
warnings.append(f"进度档 JSON 损坏: {cp_path}")
# Check for duplicate step numbers in step list
step_lines = re.findall(r"-\s*\[[x ]\]\s*\d+\.", content)
step_nums = []
for line in step_lines:
m = re.search(r"(\d+)\.", line)
if m:
step_nums.append(int(m.group(1)))
seen = set()
for num in step_nums:
if num in seen:
issues.append(f"步骤 {num} 在清单中重复出现")
seen.add(num)
# Check for gaps in step numbering
if step_nums:
expected = list(range(1, max(step_nums) + 1))
missing = [n for n in expected if n not in seen]
if missing:
warnings.append(f"步骤编号缺失: {missing}")
else:
warnings.append("工作单文件不存在")
# === Check 2: .zshrc PATH references ===
zshrc = Path.home() / ".zshrc"
if zshrc.exists():
zshrc_content = zshrc.read_text()
# Find paths in PATH exports (lines starting with export PATH=)
for line in zshrc_content.splitlines():
if not line.strip().startswith("export PATH="):
continue
refs = re.findall(r"/Users/\S+", line)
for ref in refs:
full_path = Path(ref).expanduser()
if not full_path.exists():
issues.append(f".zshrc PATH 引用失效: {ref}")
else:
warnings.append(".zshrc 不存在")
# === Check 3: Workspace symlink health ===
workspace = Path.home() / "workspace"
if workspace.exists():
for item in workspace.iterdir():
if item.is_symlink():
if not item.exists():
issues.append(f"符号链接失效: {item.name} -> {os.readlink(item)}")
# === Report ===
click.echo("-" * 50)
if issues:
click.secho(f"发现 {len(issues)} 个问题:", fg="red")
for issue in issues:
click.secho(f" [x] {issue}", fg="red")
else:
click.secho("未发现严重问题", fg="green")
if warnings:
click.secho(f"\n{len(warnings)} 个警告:", fg="yellow")
for w in warnings:
click.secho(f" [!] {w}", fg="yellow")
click.echo("-" * 50)
if issues:
sys.exit(1)
-9
View File
@@ -107,12 +107,3 @@ def uninstall_cmd():
click.secho("mytoolkit removed.", fg="green")
# Backward compatibility: keep self_cmd group for any existing scripts
@click.group(name="self")
def self_cmd():
"""Manage mytoolkit itself (legacy, use 'update'/'uninstall' directly)."""
pass
self_cmd.add_command(update_cmd, name="update")
self_cmd.add_command(uninstall_cmd, name="uninstall")
-32
View File
@@ -1,32 +0,0 @@
"""Utility commands."""
from pathlib import Path
import click
from bin.utils import handle_errors
@click.group()
def utils():
"""Miscellaneous utilities."""
pass
@utils.command("albany-cleanup")
@click.option("--dry-run", "-n", is_flag=True, help="Show what would be done")
@handle_errors
def albany_cleanup(dry_run):
"""Clean up Albany temporary files (phalanx_*)."""
count = 0
for file in Path(".").glob("phalanx_*"):
if dry_run:
click.echo(f"Would remove: {file}")
else:
file.unlink()
count += 1
if dry_run:
click.echo("Dry run completed")
else:
click.echo(f"Removed {count} Albany temporary files")