Skip to content

fix/feat: address open issues #14, #12, #11, #16#17

Merged
KHAEntertainment merged 16 commits intomasterfrom
claude/review-open-issues-RBCuj
Mar 21, 2026
Merged

fix/feat: address open issues #14, #12, #11, #16#17
KHAEntertainment merged 16 commits intomasterfrom
claude/review-open-issues-RBCuj

Conversation

@KHAEntertainment
Copy link
Copy Markdown
Owner

Summary

Addresses all four non-enhancement open issues. Enhancement-labeled issues #9 (Interactive TUI) and #13 (Secure Credentials) are deferred as requested.

All Traycee AI implementation plans were validated before implementation.


fix(#14) — File Write Flow: Absolute Path Rejection + Silent Failures

  • _safe_dest() now rebases absolute paths (e.g. /home/user/.sandbox/task.py) to just the filename under the output directory with a warning, instead of raising and silently skipping
  • When --write-files produces zero written files, the full response is saved to <output-dir>/grok-response.txt and the process exits with code 1 so callers can detect the failure

feat(#12) — Configurable Grounding System Prompt

  • Added DEFAULT_GROUNDING_PROMPT constant establishing Grok's role as a coding assistant
  • load_grounding_prompt() reads ~/.config/grok-swarm/system-prompt.txt for user customisation, falling back to the default
  • call_grok() prepends the grounding prompt before any mode-specific content; orchestrate mode is unaffected (user owns the full system prompt)

feat(#11) — Token/Cost Usage Dashboard

  • New src/bridge/usage_tracker.py: logs every API call to ~/.config/grok-swarm/usage.json (newline-delimited JSON, stdlib only); aggregates calls, tokens, and estimated cost (OpenRouter pricing for x-ai/grok-4.20-multi-agent-beta: $5/M prompt, $15/M completion)
  • grok_bridge.py: calls record_usage() after each successful API call (failures silently ignored so tracking never aborts main flow)
  • cli.py: new grok-swarm stats [--days N] subcommand prints a formatted report

feat(#16) — Autonomous grok-swarm-agent (fixing the open PR)

The existing PR on feature/grok-swarm-agent had three bugs preventing it from running:

  1. Both grok_bridge.py and grok_agent.py imported get_filename_pattern_string from src/shared/patternsthat module was never committed, causing ImportError at startup
  2. lang_path_pattern in the PR was narrowed to only match absolute paths (/...) — silently dropping relative-path annotations like python:cli.py
  3. call_grok() in the PR lost its thinking parameter — breaking high-thinking/16-agent mode

Fixes applied:

  • Created src/shared/__init__.py + patterns.py with get_filename_pattern_string()
  • Fixed lang_path_pattern in grok_agent.py to match relative OR absolute paths
  • grok_bridge.py imports shared patterns with graceful try/except fallback
  • All new files from the feature branch incorporated: src/agent/grok_agent.py, src/plugin/grok_agent_plugin.ts, platforms/claude/skills/grok-swarm-agent/SKILL.md, platforms/claude/commands/grok-swarm-agent.sh

chore — skills/grok-refactor/bridge/ sync

All changes above applied identically to the duplicate skills/grok-refactor/bridge/ tree. Updated SKILL.md to document grounding prompt config and the new stats subcommand.


Test plan

  • python3 src/bridge/grok_bridge.py --help — no ImportError
  • python3 src/bridge/cli.py stats — prints "No usage data recorded yet"
  • python3 src/agent/grok_agent.py --help — no ImportError
  • Pass response with # FILE: /abs/path/file.py to parse_and_write_files() → writes file.py with warning, not silent skip
  • Confirm grounding prompt appears in system content on a live call
  • After a live call, grok-swarm stats shows the recorded entry

https://claude.ai/code/session_01No9S6TZbfTgocHwHYWwxRN

claude added 5 commits March 21, 2026 04:30
- _safe_dest() now rebases absolute paths (e.g. /home/user/.sandbox/foo.py)
  to just the filename under the output directory instead of raising an error,
  printing a warning so the user knows the rebase occurred
- When --write-files produces zero written files, the full response is saved
  to <output-dir>/grok-response.txt and the process exits with code 1 so
  callers can detect the failure rather than silently succeeding

Closes #14

https://claude.ai/code/session_01No9S6TZbfTgocHwHYWwxRN
Prepends a grounding identity prompt to every mode-specific system prompt
so Grok always operates as a focused coding assistant.

- DEFAULT_GROUNDING_PROMPT constant establishes role/expectations
- load_grounding_prompt() reads ~/.config/grok-swarm/system-prompt.txt
  for user customisation, falling back to the default
- call_grok() now prepends the grounding prompt before mode content
- orchestrate mode is unaffected: system_override keeps full control

Closes #12

https://claude.ai/code/session_01No9S6TZbfTgocHwHYWwxRN
- New src/bridge/usage_tracker.py: records every API call to
  ~/.config/grok-swarm/usage.json (newline-delimited JSON) using
  stdlib only; aggregates calls, tokens, cost, and time; formats
  a human-readable table
- grok_bridge.py: imports usage_tracker and calls record_usage()
  after each successful API call (failures are silently swallowed
  so tracking never aborts the main flow)
- cli.py: new `grok-swarm stats [--days N]` subcommand prints the
  aggregated stats table

Pricing based on OpenRouter's published rates for
x-ai/grok-4.20-multi-agent-beta ($5/M prompt, $15/M completion).

Closes #11

https://claude.ai/code/session_01No9S6TZbfTgocHwHYWwxRN
Brings in the grok-swarm-agent feature from the open PR on
feature/grok-swarm-agent, fixing three regressions before landing:

Bug fixes vs. the open PR:
- Created src/shared/patterns.py (get_filename_pattern_string()) which
  was imported but never committed, causing ImportError at startup
- Fixed lang_path_pattern in grok_agent.py to match relative paths
  (python:cli.py) in addition to absolute paths — the PR's narrowed
  pattern ^(\w+):(/...) silently dropped relative-path annotations
- src/bridge/grok_bridge.py now imports shared patterns gracefully
  (try/except) so the bridge still works without the shared module

New files:
- src/shared/__init__.py + patterns.py — shared regex utilities
- src/agent/__init__.py + grok_agent.py — autonomous iterative agent loop
  (file discovery → Grok call → parse/apply → verify → iterate up to 5x)
- src/plugin/grok_agent_plugin.ts — OpenClaw/Claude Code tool registration
- platforms/claude/skills/grok-swarm-agent/SKILL.md — skill documentation
- platforms/claude/commands/grok-swarm-agent.sh — slash command

Updated:
- src/plugin/index.ts — imports and registers the agent tool

Closes #16

https://claude.ai/code/session_01No9S6TZbfTgocHwHYWwxRN
Applies all issue fixes (#14, #12, #11, #16) to the duplicate
skills/grok-refactor/bridge/ files so both installation paths stay
in parity:

- grok_bridge.py: absolute path rebasing, fallback response save,
  grounding prompt, usage tracking, shared patterns Pattern 3
- usage_tracker.py: new (copied from src/bridge/)
- shared/patterns.py: new (provides get_filename_pattern_string())
- SKILL.md: documents grounding prompt config and stats subcommand

https://claude.ai/code/session_01No9S6TZbfTgocHwHYWwxRN
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 21, 2026

Warning

Rate limit exceeded

@KHAEntertainment has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8069b28-fd44-47bd-953a-a74e3b1442f1

📥 Commits

Reviewing files that changed from the base of the PR and between f93b9b8 and 26f8cbf.

📒 Files selected for processing (8)
  • skills/grok-refactor/SKILL.md
  • skills/grok-refactor/bridge/grok_bridge.py
  • skills/grok-refactor/bridge/usage_tracker.py
  • skills/grok-refactor/shared/patterns.py
  • src/bridge/cli.py
  • src/bridge/usage_tracker.py
  • src/plugin/grok_agent_plugin.ts
  • src/plugin/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/review-open-issues-RBCuj

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 and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Addresses multiple open issues by improving file-write robustness, adding configurable system grounding, introducing persistent usage/cost tracking with a stats command, and adding an autonomous “grok-swarm-agent” workflow (plus mirrored updates in the skills/grok-refactor/ tree).

Changes:

  • Improve Grok response file parsing/writing: rebase absolute paths, add fallback response persistence + nonzero exit on zero writes, and support additional filename annotation format.
  • Add configurable grounding system prompt and persistent token/cost usage tracking with a grok-swarm stats [--days N] subcommand.
  • Introduce an autonomous Grok agent loop and OpenClaw/Claude integration (plugin tool registration + Claude command/skill docs).

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/shared/patterns.py Adds shared regex helper for filename-style annotations in code blocks.
src/shared/init.py Defines shared package marker.
src/plugin/index.ts Registers the new autonomous agent tool from the OpenClaw plugin entrypoint.
src/plugin/grok_agent_plugin.ts Implements the OpenClaw tool that spawns the Python autonomous agent.
src/bridge/usage_tracker.py Adds persistent newline-delimited JSON usage logging and aggregation/report formatting.
src/bridge/grok_bridge.py Adds grounding prompt support, usage logging hook, improved file parsing/writing behavior and safer absolute-path handling.
src/bridge/cli.py Adds stats subcommand that prints formatted usage report.
src/agent/grok_agent.py Adds the autonomous iterative agent loop with parsing/apply/verify capabilities.
src/agent/init.py Defines agent package marker.
skills/grok-refactor/shared/patterns.py Mirrors shared filename regex helper into skills bundle.
skills/grok-refactor/bridge/usage_tracker.py Mirrors usage tracking into skills bundle.
skills/grok-refactor/bridge/grok_bridge.py Mirrors bridge improvements into skills bundle (grounding, parsing, fallback write, thinking mode).
skills/grok-refactor/SKILL.md Documents grounding prompt configuration and usage stats command.
platforms/claude/skills/grok-swarm-agent/SKILL.md Adds Claude skill documentation for the autonomous agent.
platforms/claude/commands/grok-swarm-agent.sh Adds Claude command wrapper to invoke the autonomous agent script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/plugin/index.ts
Comment thread src/plugin/index.ts Outdated
Comment thread src/plugin/grok_agent_plugin.ts
Comment thread platforms/claude/commands/grok-swarm-agent.sh
Comment thread src/bridge/usage_tracker.py Outdated
Comment thread src/plugin/grok_agent_plugin.ts
Comment thread src/plugin/grok_agent_plugin.ts
Comment thread src/bridge/grok_bridge.py Outdated
Comment thread platforms/claude/skills/grok-swarm-agent/SKILL.md
Comment thread src/plugin/grok_agent_plugin.ts
@KHAEntertainment
Copy link
Copy Markdown
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 21, 2026

@KHAEntertainment I've opened a new pull request, #18, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits March 21, 2026 05:20
fix: address PR review comments — agent plugin correctness, shell injection, datetime safety, Pattern 3 parsing
Resolve conflicts by keeping master (PR #16) canonical versions
for all overlapping files, preserving the PR branch's non-conflicting
ESM fix in src/plugin/index.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 21, 2026

@KHAEntertainment I've opened a new pull request, #20, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 21, 2026

@KHAEntertainment I've opened a new pull request, #21, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 21, 2026

@KHAEntertainment I've opened a new pull request, #22, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits March 21, 2026 05:38
…rdcoded python3

Co-authored-by: KHAEntertainment <43256680+KHAEntertainment@users.noreply.github.com>
Agent-Logs-Url: https://github.com/KHAEntertainment/grok-multiagent-plugin/sessions/aa43e519-f955-4eac-ab29-27a12839c43c
No-op: SKILL.md Options table already uses correct single-pipe format
…r-one

Use `api.config?.pythonPath` in `grok_agent_plugin.ts` instead of hardcoded `python3`
fix: make plugin entry-point async to permit await import()
@KHAEntertainment KHAEntertainment merged commit 0597875 into master Mar 21, 2026
1 check 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.

4 participants