Skip to content

feat: add researchclaw init command and config auto-detection#12

Merged
Jiaaqiliu merged 1 commit intoaiming-lab:mainfrom
jecanore:feat/init-command
Mar 17, 2026
Merged

feat: add researchclaw init command and config auto-detection#12
Jiaaqiliu merged 1 commit intoaiming-lab:mainfrom
jecanore:feat/init-command

Conversation

@jecanore
Copy link
Contributor

Problem

First-time setup requires manually copying config.researchclaw.example.yaml to config.arc.yaml, then hand-editing provider URLs and API key variable names. The CLI also hardcodes --config to config.yaml, so it never finds config.arc.yaml without an explicit flag.

Solution

  • Add researchclaw init — copies the example template, prompts for LLM provider (openai, openrouter, deepseek, acp), and writes config.arc.yaml with the right defaults
  • Change --config default from "config.yaml" to auto-detect: tries config.arc.yaml first, then config.yaml
  • When no config exists, the error message now suggests researchclaw init

Test plan

  • researchclaw init creates config.arc.yaml with correct provider settings
  • Refuses overwrite without --force; --force overwrites
  • Auto-detection prefers config.arc.yaml over config.yaml
  • Missing config prints researchclaw init hint
  • Full suite passes (1260 tests, 9 new)

- Add resolve_config_path() to search for config.arc.yaml then config.yaml
- Change --config default to None (auto-detect) on run/validate/doctor
- Add _resolve_config_or_exit() helper with init hint on missing config
- Add `researchclaw init` subcommand with interactive provider selection
- String-based template replacement preserves YAML comments
@Jiaaqiliu Jiaaqiliu merged commit 556254f into aiming-lab:main Mar 17, 2026
Jiaaqiliu added a commit that referenced this pull request Mar 17, 2026
Merged community PRs:
- PR #12: researchclaw init command and config auto-detection
- PR #14: CONTRIBUTING.md
- PR #17: ssh_remote and colab_drive experiment sandbox backends
- PR #19: native Anthropic Messages API support via adapter pattern

Additional fixes:
- Deduplicate pyproject.toml optional-dependencies section
- Handle OSError in colab drive availability check
- Add test_outputs and local docs to .gitignore
@Jiaaqiliu
Copy link
Collaborator

Hi @jecanore, thanks for this excellent contribution!

We've reviewed and merged this PR. The researchclaw init command and config auto-detection are now part of main.

A few notes on what we adjusted during integration:

  • We resolved merge conflicts with our existing cli.py and config.py (MetaClaw bridge features were added in parallel).
  • The pyproject.toml optional-dependencies section had a minor duplication after merge, which we fixed.

We also noticed a couple of areas for future improvement (not blocking):

  • The provider string replacement in cmd_init() matches "openai" but the example config uses "openai-compatible" — this means the replacement is currently a no-op. We'll fix this in a follow-up.
  • The example config is resolved from CWD (Path.cwd() / EXAMPLE_CONFIG), so researchclaw init only works from the repo root. Bundling the template inside the package would make it work after pip install.

Overall, great work — clean code, good test coverage. Thanks for contributing!

Jiaaqiliu added a commit that referenced this pull request Mar 17, 2026
PR #12 (cli init):
- Fix provider replacement: match "openai-compatible" instead of "openai"
- Fix example config path: search repo root + package dir, not just CWD
- Handle EOFError on stdin close during interactive prompt
- Return exit code 1 when refusing to overwrite existing config

PR #17 (SSH/Colab sandbox):
- Fix shell injection: shlex.quote() all user-supplied values in commands
- Fix SSH option ordering: ConnectTimeout placed before hostname
- Fix subdirectory support: run_project() and scp_upload() now copy dirs
- Fix Docker cmd: add explicit python3 invocation, fix GPU flag quoting
- Add cleanup of remote dir on upload failure

PR #19 (Anthropic adapter):
- Fix stop_reason mapping: end_turn→stop, max_tokens→length (truncation)
- Fix MetaClaw conflict: adapter uses original URL, not proxy URL
- Extract all text content blocks, not just the first
- Concatenate multiple system messages instead of dropping earlier ones
- Catch all httpx transport errors (ReadError, RemoteProtocolError, etc.)
- Detect Anthropic error responses before conversion

config.py:
- Remove 84 lines of duplicate function definitions (dead code)
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.

2 participants