Skip to content

fix(agentmain): reject unknown CLI arguments#697

Closed
Kailigithub wants to merge 1155 commits into
lsdefine:mainfrom
Kailigithub:fix/issue-566-argparse-guard-v2
Closed

fix(agentmain): reject unknown CLI arguments#697
Kailigithub wants to merge 1155 commits into
lsdefine:mainfrom
Kailigithub:fix/issue-566-argparse-guard-v2

Conversation

@Kailigithub

Copy link
Copy Markdown
Contributor

Summary

Reject unsupported command-line arguments before GenericAgent initializes. This makes mistyped launch modes such as --goal fail with argparse's non-zero error instead of falling through to the interactive path.

Closes #566

Changes

  • Validate parse_known_args() leftovers when --reflect is not active.
  • Preserve the existing extra-argument forwarding used by reflect scripts.

Verification

  • python3 -m py_compile agentmain.py
  • Regression harness passes on the fix: --goal /tmp/goal.json exits 2 with an argparse error and does not reach runtime initialization.
  • The same harness fails on the pre-fix source with ZeroDivisionError from runtime initialization instead of the expected argument error.
  • git diff --check
  • Existing targeted Ruff findings are unchanged (F541 and F401); no finding is introduced at the changed lines.

lsdefine and others added 30 commits June 14, 2026 09:43
… prevent UI freeze

ESC cancel sent session/cancel RPC but never cleared the busy flag, leaving the UI stuck if the server-side cancelled event never arrived. Also clear busy on all sessions when the bridge closes so pending poll loops exit cleanly.

Co-authored-by: dilong888 <dilong888@users.noreply.github.com>
v3 的 _do_restore 此前只把历史载入内存 backend.history,不碰当前进程日志。native 后端逐轮只把新增消息 append 到 model_responses_{pid}.txt,恢复出的旧历史从不写入当前日志——续聊只追加增量,下次 /continue 扫到的本进程文件就只剩续聊部分,旧历史丢失。

对齐 v2 _do_continue_restore:恢复前 reset_conversation(快照+清空当前日志),恢复后 copyfile(源日志 → 当前日志),续聊便接在完整历史之后。
…d, AXClick)Feat/macos ax enhancements (lsdefine#611)

* feat(memory): enhance macOS AX control (resolve_pid fix, enabled field, AXClick)

- _resolve_pid: fix bundle_id branch (used un-imported AppKit), 3-tier match (bundle id > app name exact > substring)
- AXElements: collect 'enabled' field (SOP: check disabled before click)
- AXClick: AXPress-first then fallback to physical-coord Click, honest success判定 via pixel diff
- AXFind: add enabled_only filter, refactor if-forest into _hit helper

* docs(ljqCtrl): tighten macOS AX guidance, drop boilerplate & app-specific detail

- collapse 5-line cross-platform import boilerplate to one line
- generalize control-identifier tip (remove app-specific identifiers)
Annotate config block to guide new GA instances: enumerate candidate
mykey.py variable names and experimentally probe which config works;
only print var/field names, model, apibase host/path, status codes and
error types (never full dict or apikey/token); include a config format
example. Also flag that apibase/endpoint may differ per provider/proxy
at the two request-building sites.
…conflict) (lsdefine#617)

/continue N 默认改为「原地续」:接管原会话日志、后续轮次写回同一文件,取代旧的
镜像复制(supersedes b4356c7 的 mirror 方案),不再每次续接都 fork 新会话、日志增殖。

- 空闲会话 → 直接原地接管;被活进程占用 → 弹窗确认后才复制一份续。
- 每会话出生持锁(temp/model_responses/.locks/<logid>.lock),整进程共用一个心跳
  线程每 5s touch mtime、30s 无心跳判死可接管;atexit 干净释放,崩溃/强杀靠超时兜底。
- 切走/新对话不再「快照+清空」(原 _snapshot_current_log 因 logid≠pid 实为死代码,
  从未生成过快照),旧日志原样留作空闲会话,新对话铸新 logid。
- list_sessions 新增 exclude_log,修正 exclude_pid=getpid 失效导致当前会话出现在
  自己列表里的问题。
- continue_cmd 仅新增函数,reset_conversation/restore/handle 未改动 → 其他前端
  (IM/qt/streamlit 等)行为完全不变。
- 改动仅限 continue_cmd.py + tui_v3.py + tuiapp_v2.py;rewind/worldline 逻辑不在本 PR。
Update WeChat group 21 QR code image.

Co-authored-by: AspasZhang <AspasZhang@users.noreply.github.com>
…ne#621)

In-place /continue retargets agent.log_path to the restored file, so the
reset bind `_bind_workspace(None)` ran during restore was persisting
session_ws_set(path, "") — erasing that session's own workspace mapping to
"" (read back as "explicitly off") before we read it, which also short-
circuited the log-scan fallback. The continued session never re-entered its
workspace.

Add a `persist` flag to `_bind_workspace`; the restore-time reset passes
persist=False so it only refreshes in-memory state. The session→workspace
map is now written solely by explicit /workspace, /workspace off, and a
successful restore.
Trend chart fix:
- SVG had preserveAspectRatio="none" which stretched the viewBox 600x260
  non-uniformly to the container (max-width 760 x height 280), making text
  ~15% wider than tall ("扁").
- Switch to preserveAspectRatio="xMidYMid meet" so text renders at correct
  aspect, and replace fixed container height with aspect-ratio:600/260 +
  min-height:280px so chart fills naturally without distortion.

Color theme cleanup (user-requested):
- Drop 8-color mac-style palette, keep only a single gray light theme.
- --accent now hard-coded gray (#8e8e93); removed --swatch-2..8 and all
  html[data-theme="N"] / .swatch[data-theme="N"] CSS rules.
- Remove the entire "颜色" (set.theme) block from settings page.
- applyTheme() stubbed: still callable for backward compat with stored
  ga_theme values, but always normalizes to theme '1'.
- Drop set.theme i18n entries (zh + en).

Cache busters: styles.css 136→137, app.js 181→182.
Sidebar:
- 快速接入官方模型 header restyled to match 配置 button (foot-row style:
  transparent bg, padding, hover state, lightning icon on left,
  caretRight chevron on right that rotates 90deg when expanded).
- Drop the "填好 API Key 即可使用" subtitle for single-line consistency.
- Drop the "展开/折叠" tooltip on the head.
- Bump both .pq-head and .foot-row padding to 14px so the buttons look
  substantial.
- Set .sidebar-foot margin-top:6px to match .provider-quickstart's internal
  gap:6px — uniform 6px rhythm between pq-head→DeepSeek→Qwen→配置.

Services page:
- Remove the "IM 消息通道与后台进程,集中查看、启停与日志" subtitle.
- Align .svc-tabs margin with .tok-tabs (margin:10px 0 0) so the title
  position and tab bar position match the Token usage page.

Token page (i18n):
- zh: "Conductor" → "指挥家" on tab label, total/current row labels,
  tooltip, and the new tok.condOffline string (replaces hard-coded text).
- en remains "Conductor" (English UI keeps the English name).

Token table column widths:
- Switch to table-layout:fixed. Number columns 80px each, cache-rate 85px.
- First column (session name) gets the rest of the width; overflow truncates
  with ellipsis. JS adds title="<full name>" so hover shows the complete
  session title as a tooltip. No more column-width jitter when switching
  Chat/指挥家 tabs.

Color tweaks (no hardcoded values):
- .pq-btn background var(--bg-base) → var(--field-bg) (lighter).
- .model-guide border var(--accent) → var(--line-base); background
  var(--accent-bg) → var(--field-bg) (lighter, neutral).
# Conflicts:
#	desktop_release/TODO.md
#	desktop_release/apps/linux/README.md
#	desktop_release/scripts/linux/install_linux.sh
- Consolidate font stack: remove GA Lexend/Noto Sans, use system sans (SF Pro/Segoe UI)
- Reduce CSS font variables from 6 to 3 (--font-sans, --font-mono, --font-brand)
- Converge font-weights to match reference spec (700→600 headings, 600→500 labels)
- Add explicit font-family to pre/code blocks
- Compact nav-item: 28px height, 8px padding, 16px icons
- Remove 'token' from all UI copy, simplify to 'Usage'/'用量'
- Add cache-buster to fonts.css link
…sdefine#614)

On macOS the screenshot path lacked a counterpart to win32's
ClientToScreen. Detecting a target inside a cropped GrabScreen(bbox)
image and feeding the in-image (px,py) straight to Click silently
mis-clicks because the crop-origin offset is dropped.

- add CropToScreen(bbox, x, y): in-crop coords -> absolute physical
  coords (pure crop-origin add, no scaling)
- GrabScreen docstring: warn about the crop-origin trap and not to
  hand-roll screencapture -R (it takes logical points)
- Click 0%-pixel-change warning now names the common causes
- ljqCtrl_sop.md: add macOS subsection mirroring the win32 trap note
Co-authored-by: octo-patch <octo-patch@github.com>
feat: typography alignment with system font baseline
lsdefine and others added 27 commits July 11, 2026 22:05
…OP); ga.py: file_patch/file_write 保持原文件换行符, 修复LF文件被污染成CRLF; _arg 类型强转修复字符串false等
Add maxlen_multiplier derived from context_win (capped 3x); drives per-tool
truncation caps and history compression interval. WebScan uses half-increment
growth to avoid saturating its 35000 base. Docs updated for the new coupling.
Hard-delete path can preserve the first K history messages, insert a "..." gap, and strip dangling tool_use at the cut. Default 0 keeps previous behavior.
Ignore assets/glm52_instruction.txt and assets/gpt55_instruction.txt
so local customizations stay out of the repo.
…#681)

The agent's default cwd is the temp/ subdirectory, where git resolves
'-- <file>' pathspecs relative to cwd. Fed the root-relative paths that
'git diff --name-only' prints, 'git checkout upstream/main -- <file>'
fails with "pathspec did not match", breaking the working-tree
reconcile steps of /update. The prompt now tells the agent to run every
git command from the repo root (_ROOT), in both EN and ZH.

Co-authored-by: Shen Hao <shenhao-stu@users.noreply.github.com>
…sdefine#673)

When OS revokes master stdout, bare print() raises BrokenPipeError and aborts WS handle before tab registration, causing stale web_scan data and extension reconnect loops. Mirror ga.py safe_print across TMWebDriver log sites.

Closes lsdefine#672
Merge desktop fork updates into upstream main
c921bad tightened blank-turn detection by stripping <thinking>/<summary>
and treating meta-only replies as empty. That is too aggressive for the
main agent loop (summary-only / thinking-only turns get forced retries).
Keep desktop_bridge behavior; only revert ga.py core path.
fix(desktop): restore permissive empty-turn handling
Replace the README community QR with the current WeChat experience group image (wechat_group22.jpg) following the existing numbering convention.
Use pid+nanos for user_prompt temp filename to avoid same-second collisions under concurrent --func / run_subagents.

Fixes lsdefine#665
- Optional helper hook when available; warn reopen if used

- Sidebar cleanup: drop auto_start, tighten hr CSS
- Probe optional helper availability; show button only if present

- Bridge route for optional helper; i18n + cache bump

- llmcore: maxlen_multiplier factor 0.85->0.75
@Kailigithub

Copy link
Copy Markdown
Contributor Author

Closing in favor of the rewrite on current main — the original branch had accumulated ~60K lines of stale drift (from a baseline many weeks behind upstream), making it impossible to rebase cleanly. The underlying fix is identical (7-line guard rejecting unknown CLI args unless --reflect is set); the rewrite applies the same diff on top of current main without any of the drift.

New PR will be linked in a follow-up comment. Diff preserved on the original branch (fix/issue-566-argguard-unknown-args) for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Goal Hive can silently hang when launched with unsupported --goal argument