Skip to content

feat(prompt): inject optional system info#79

Merged
69gg merged 4 commits into
mainfrom
feature/system-watcher
Jun 25, 2026
Merged

feat(prompt): inject optional system info#79
69gg merged 4 commits into
mainfrom
feature/system-watcher

Conversation

@69gg

@69gg 69gg commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add optional [prompt.system_info] injection for cross-platform host/runtime/resource details
  • Keep the master switch disabled by default and allow per-section visibility toggles
  • Bump version to 3.6.4 and add changelog notes

Tests

  • uv run pytest tests/test_prompt_system_info.py tests/test_prompt_builder_message_order.py tests/test_config_api.py tests/test_config_from_mapping.py tests/test_config_template_sync.py
  • pre-commit: ruff format --check, ruff check, mypy
  • version bump pre-commit: console/chat npm, TypeScript, Vitest, Cargo fmt/check/test

Summary by CodeRabbit

  • New Features
    • Added an optional “current system information” block to prompts (disabled by default).
    • You can opt in via prompt.system_info.enabled and control each category (OS, runtime, host, CPU, memory/swap, disks, network, process, uptime).
    • If data collection fails for specific items, only those items are omitted without breaking prompt generation.
  • Documentation
    • Updated the configuration example and configuration docs with the new prompt.system_info section and placement/order notes.
  • Bug Fixes
    • Improved prompt-building order to remain cache-friendly and consistent.

69gg and others added 3 commits June 24, 2026 21:25
Co-authored-by: GPT-5 Codex <noreply@openai.com>
Co-authored-by: GPT-5 Codex <noreply@openai.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d35aeb73-0e7a-47a2-b0a2-902eee39c394

📥 Commits

Reviewing files that changed from the base of the PR and between f2f2908 and ac5576a.

📒 Files selected for processing (7)
  • scripts/bump_version.py
  • src/Undefined/__init__.py
  • src/Undefined/ai/prompts/builder.py
  • src/Undefined/ai/prompts/system_info.py
  • tests/test_bump_version_script.py
  • tests/test_prompt_builder_message_order.py
  • tests/test_prompt_system_info.py
✅ Files skipped from review due to trivial changes (1)
  • src/Undefined/init.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Undefined/ai/prompts/builder.py
  • src/Undefined/ai/prompts/system_info.py

📝 Walkthrough

Walkthrough

Adds an optional [prompt.system_info] prompt source, wires it through config loading and prompt building, adds tests and docs for the new prompt block, and bumps project/app versions to 3.6.4.

Changes

System Info Prompt Injection

Layer / File(s) Summary
Config model and parsing
src/Undefined/config/models.py, src/Undefined/config/__init__.py, src/Undefined/config/config_class.py, src/Undefined/config/domain_parsers.py, src/Undefined/config/load_sections/domains.py, config.toml.example
Defines PromptSystemInfoConfig, exports it, adds it to Config, parses prompt.system_info, and adds the example config block.
System info collector
src/Undefined/ai/prompts/system_info.py
Adds the system-info prompt builder, formatting helpers, psutil-backed collectors, per-section builders, and build_prompt_system_info.
PromptBuilder integration
src/Undefined/ai/prompts/builder.py
Imports build_prompt_system_info, builds system info from runtime config on a background thread, and appends it as a system message when non-empty.
Tests, docs, and changelog
tests/test_config_api.py, tests/test_prompt_system_info.py, tests/test_prompt_builder_message_order.py, docs/configuration.md, docs/message-batching.md, CHANGELOG.md
Adds coverage for config parsing, system-info formatting, prompt ordering, background-thread execution, and documents the new config section and prompt order note.

v3.6.4 Version Bump

Layer / File(s) Summary
Version metadata updates
pyproject.toml, src/Undefined/__init__.py, apps/undefined-chat/package.json, apps/undefined-chat/src-tauri/Cargo.toml, apps/undefined-chat/src-tauri/tauri.conf.json, apps/undefined-console/package.json, apps/undefined-console/src-tauri/Cargo.toml, apps/undefined-console/src-tauri/tauri.conf.json
Updates version metadata from 3.6.3 to 3.6.4.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant PromptBuilder
  participant build_prompt_system_info

  Caller->>PromptBuilder: build_messages(inputs)
  PromptBuilder->>PromptBuilder: read runtime_config.prompt_system_info
  PromptBuilder->>build_prompt_system_info: build_prompt_system_info(config)
  build_prompt_system_info-->>PromptBuilder: system info text or ""
  PromptBuilder->>PromptBuilder: append system message when non-empty
  PromptBuilder-->>Caller: messages list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • 69gg/Undefined#69: Also changes src/Undefined/ai/prompts/builder.py prompt ordering and message assembly logic.

Poem

🐰 I sniffed the prompt, then twitched my nose,
New system facts in careful rows.
enabled=False keeps things tucked tight,
But when it’s on, the prompt feels bright.
Version 3.6.4 hops along,
With tests and docs in rabbit song.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: optional system info injection into prompts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/system-watcher

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Undefined/__init__.py`:
- Line 27: The module-level __version__ assignment in __init__.py is missing an
explicit type annotation required by strict mypy checks. Update the __version__
symbol to be explicitly annotated as a string in the same place where the
version constant is defined so the package stays fully type-annotated and
consistent with the coding guidelines.

In `@src/Undefined/ai/prompts/builder.py`:
- Around line 524-537: The system-info gathering in build_messages() is blocking
the async event loop because build_prompt_system_info() and the psutil-based
runtime_config access are called directly inside the coroutine. Move the work
behind asyncio.to_thread() (or another background execution path) in the
self._runtime_config_getter / build_prompt_system_info flow, and keep the
existing logger.debug behavior so the system message append still happens after
the off-thread result is returned.

In `@src/Undefined/ai/prompts/system_info.py`:
- Around line 181-187: The CPU usage line built by _build_cpu_usage_line
currently uses psutil.cpu_percent(interval=None) directly, which can return an
initial baseline 0.0 reading; update this path so the first displayed value is
representative by either priming psutil once at startup or documenting the
baseline behavior, and keep the change localized to _build_cpu_usage_line and
any startup initialization around psutil usage.
- Around line 143-147: The omitted-partition notice in the system info formatter
is calculated from the wrong counter, so it almost never appears. Update the
partition-truncation logic in the function that builds the `lines` list to base
the “其余 … 个分区已省略” count on the total number of partitions being iterated, not on
`seen_mounts`, since `seen_mounts` stops increasing when the loop breaks in the
early-exit path. Keep the existing `max_items` limit behavior, but compute the
skipped count from the full partition collection so the suffix is appended
whenever there are more valid partitions than `max_items`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b3ec1829-6ba3-4371-b637-b7b000492736

📥 Commits

Reviewing files that changed from the base of the PR and between f864726 and f2f2908.

⛔ Files ignored due to path filters (5)
  • apps/undefined-chat/package-lock.json is excluded by !**/package-lock.json
  • apps/undefined-chat/src-tauri/Cargo.lock is excluded by !**/*.lock
  • apps/undefined-console/package-lock.json is excluded by !**/package-lock.json
  • apps/undefined-console/src-tauri/Cargo.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (22)
  • CHANGELOG.md
  • apps/undefined-chat/package.json
  • apps/undefined-chat/src-tauri/Cargo.toml
  • apps/undefined-chat/src-tauri/tauri.conf.json
  • apps/undefined-console/package.json
  • apps/undefined-console/src-tauri/Cargo.toml
  • apps/undefined-console/src-tauri/tauri.conf.json
  • config.toml.example
  • docs/configuration.md
  • docs/message-batching.md
  • pyproject.toml
  • src/Undefined/__init__.py
  • src/Undefined/ai/prompts/builder.py
  • src/Undefined/ai/prompts/system_info.py
  • src/Undefined/config/__init__.py
  • src/Undefined/config/config_class.py
  • src/Undefined/config/domain_parsers.py
  • src/Undefined/config/load_sections/domains.py
  • src/Undefined/config/models.py
  • tests/test_config_api.py
  • tests/test_prompt_builder_message_order.py
  • tests/test_prompt_system_info.py

Comment thread src/Undefined/__init__.py Outdated
Comment thread src/Undefined/ai/prompts/builder.py
Comment thread src/Undefined/ai/prompts/system_info.py Outdated
Comment thread src/Undefined/ai/prompts/system_info.py
Co-authored-by: GPT-5 Codex <noreply@openai.com>
@69gg 69gg merged commit 35f87de into main Jun 25, 2026
4 checks passed
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