Skip to content

claw: OOP round 2 — shell UX, audio fix, -Werror, build cleanup#97

Merged
zevorn merged 7 commits intomainfrom
claw/oop-refactor
Mar 20, 2026
Merged

claw: OOP round 2 — shell UX, audio fix, -Werror, build cleanup#97
zevorn merged 7 commits intomainfrom
claw/oop-refactor

Conversation

@zevorn
Copy link
Copy Markdown
Owner

@zevorn zevorn commented Mar 19, 2026

Summary

Post-merge refinements for the OOP refactor branch (Round 2), rebased onto latest main.

Shell UX

  • Unified prompt style: you> for user input, rt-claw> for AI reply, error> / sched> for status — symmetric, no angle brackets
  • Shell overflow fix: drain remaining bytes on buffer-full input to prevent command leakage
  • MAC address: added to /system_info output
  • Empty task name: reject empty names in scheduler tool

Audio

  • ES8311 beep noise fix: fade-in/fade-out envelope and PA stabilization delay to eliminate pop/click on xiaozhi-xmini

Build Quality

  • -Werror enforced project-wide: Meson werror=true + ESP-IDF target_compile_options(PRIVATE -Werror) for all project code; vendor/third-party excluded
  • tool_mouse warnings fixed: move unsupported stubs inside CONFIG_RTCLAW_TOOL_MOUSE guard
  • CMake configure-time warnings fixed: move Meson object glob to build-time helper script (was erroneously running at configure time when objects don't exist yet)
  • Zynq macro redefinition fixed: #ifndef guards on STDIN_BASEADDRESS / STDOUT_BASEADDRESS
  • Zynq linker RWX warning suppressed: --no-warn-rwx-segments (bare-metal expected)

IM Cleanup

  • Remove redundant tool registration stubs from feishu/telegram (handled by OOP framework)
  • Guard service registration with CONFIG_RTCLAW_*_ENABLE

Tests

  • Fix shell_prompt pattern to match help text line (line-buffered stdout)
  • Remove redundant section collect from claw_tools_init (broke Zynq unit tests)

Docs

  • Update Discord invite link
  • Document -Werror policy in CLAUDE.md and coding-style.md (EN/ZH)
  • Update shell output examples in blog

Changes (12 commits)

Commit Scope
claw: collect tools in claw_tools_init, guard IM service registration Tool init + IM
claw: fix compilation warnings and enable audio on xiaozhi-xmini Build
claw: fix shell prompt, add MAC to system info, reject empty sched name Shell + sched
drivers: fix ES8311 beep noise with fade envelope and PA stabilization Audio
claw: fix shell input overflow and scheduler NVS restore Shell + NVS
claw: remove redundant section collect from claw_tools_init Test fix
tests: revert shell_prompt pattern to match help text line Test fix
claw: unify shell prefixes to you> / rt-claw> style Shell UX
drivers: fix unused warnings in tool_mouse stub code Build
build: fix CMake configure-time warnings and Zynq macro redefinition Build
build: enable -Werror for all project code Build
docs: update Discord link, shell prefixes, and -Werror policy Docs

Test plan

  • make test-unit-zynq — all suites pass
  • make test-smoke-zynq — boot test pass
  • make test-smoke-vexpress — boot test pass
  • make build-linux — zero warnings
  • Linux functional tests — boot + shell prompt pass
  • make build-esp32c3-qemu — CI
  • make test-smoke-esp32c3 — CI
  • make build-esp32c3-xiaozhi-xmini — verify ES8311 audio on hardware

@zevorn zevorn force-pushed the claw/oop-refactor branch from 41c8c78 to 05af220 Compare March 20, 2026 10:45
zevorn added 5 commits March 20, 2026 18:52
[P2] claw_tools_init: call claw_tool_core_collect_from_section()
on non-ESP-IDF platforms so callers using claw_tools_init()
outside claw_init() still get the tool registry populated.
collect_from_section is idempotent (re-registering the same
pointer is a no-op since the node is already in the list).

[P3] feishu/telegram: guard CLAW_SERVICE_REGISTER with
CONFIG_RTCLAW_FEISHU_ENABLE / CONFIG_RTCLAW_TELEGRAM_ENABLE.
Previously the no-op service stubs were unconditionally
registered, consuming service slots and reporting misleading
lifecycle state when the feature is disabled.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
- Move IM service registration blocks (deps, ops, ctx, register) inside
  #ifdef CONFIG_RTCLAW_{FEISHU,TELEGRAM}_ENABLE guards to eliminate
  unused variable/function warnings when services are disabled.
  Remove now-unnecessary stub functions and tentative definitions from
  the #else blocks; keep only the setter/getter stubs needed by shell.
- Scope s_collected inside #ifndef CLAW_PLATFORM_ESP_IDF block in
  claw_init.c to avoid unused variable warning on ESP-IDF builds.
- Mark pa_pin as __attribute__((unused)) in xiaozhi-xmini board.c
  since it is only used when CONFIG_RTCLAW_AUDIO_ENABLE is set.
- Add __attribute__((unused)) to test framework static variables in
  tests/unit/framework/test.h to suppress warnings in compilation
  units that include the header but don't use all macros.
- Remove unused reply/argv variables in test_ai_skill.c.
- Enable CONFIG_RTCLAW_AUDIO_ENABLE in xiaozhi-xmini sdkconfig for
  full hardware component testing on V1 boards.

All 7+ platform targets (ESP32-C3 x3, ESP32-S3 x2, vexpress-a9,
zynq-a9, linux) pass clean build with zero rt-claw code warnings.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
- Change interactive shell prompt from "<You>" to "rt-claw chat>" on
  both ESP-IDF and Linux platforms to match AC-6 requirement.
- Update functional test platform.py shell_prompt accordingly.
- Add MAC address (WiFi STA) and heap usage (free_heap, min_free_heap)
  to ESP-IDF system_info tool response for AC-5.2 compliance.
- Reject empty task name in both tool_sched.c (tool layer) and
  scheduler.c (core layer) for AC-5.3 negative case compliance.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
- Extract tone generation into generate_tone() so play_melody() can
  call it directly without PA toggling on every note.
- Apply 10ms linear fade-in/out envelope to eliminate abrupt signal
  start/stop click artifacts.
- Add 50ms PA stabilization delay after enable and 30ms silence
  drain before disable to suppress Class-D amplifier pop noise.
- es8311_audio_beep() still manages its own PA for standalone use.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
- Shell: after buffer reaches capacity (255 bytes), drain remaining
  input bytes until newline to prevent overflow leaking into the
  next command.  Applied to both ESP-IDF and Linux shell.
- Scheduler NVS restore: assign interval_s and count to runtime
  context so that subsequent sched_nvs_save() does not write zero
  values back, corrupting the persistent record.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
@zevorn zevorn force-pushed the claw/oop-refactor branch from 05af220 to ca99fe8 Compare March 20, 2026 10:55
@zevorn zevorn changed the title Claw/oop refactor claw: OOP refinements, audio fix, and shell improvements Mar 20, 2026
zevorn added 2 commits March 20, 2026 19:14
claw_init() already calls claw_tool_core_collect_from_section()
before services start. The duplicate call in claw_tools_init()
is harmless in normal boot (guarded by s_collected flag) but
breaks Zynq unit tests: the test binary does not call claw_init(),
so the collect pulls in all production tools, exhausting cJSON
heap during test_tools_to_json assertions.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
The ConsoleBuffer reads stdout line-by-line (splits on \n). The
actual shell prompt "rt-claw chat> " has no trailing newline (it
waits for user input), so the pattern "rt-claw chat>" never
matches a complete line. Revert to "rt-claw chat" which matches
the help text "rt-claw chat  (type /help for commands)\n" that
does end with a newline.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
@zevorn zevorn merged commit 1943c71 into main Mar 20, 2026
11 checks passed
@zevorn zevorn changed the title claw: OOP refinements, audio fix, and shell improvements claw: OOP round 2 — shell UX, audio fix, -Werror, build cleanup Mar 20, 2026
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.

1 participant