Skip to content

feat: add Codex wiki bundle export workflow and local artifact ignore rules#1677

Open
Juanzitooh wants to merge 4 commits intoopentibiabr:mainfrom
Juanzitooh:feat/codex
Open

feat: add Codex wiki bundle export workflow and local artifact ignore rules#1677
Juanzitooh wants to merge 4 commits intoopentibiabr:mainfrom
Juanzitooh:feat/codex

Conversation

@Juanzitooh
Copy link
Copy Markdown
Contributor

@Juanzitooh Juanzitooh commented Mar 28, 2026

Description

This PR adds a Codex wiki bundle workflow for local documentation export and usage.

Summary of changes:

  • Adds tools/export_wiki_bundle.py to export a local wiki bundle for Codex usage.
  • Updates ignore rules for local Codex wiki artifacts so generated local files do not pollute regular feature branches.
  • Adds docs/README.md with instructions for generating and using the wiki bundle (python3 tools/export_wiki_bundle.py), including expected output flow.

Motivation/context:

  • Make it easy to generate a consistent local docs bundle for Codex-assisted workflows.
  • Keep local generated artifacts out of normal source-control diffs.
  • Provide a documented and reproducible process for contributors.

Dependencies:

  • Python 3 available in the local environment.
  • Repository write permissions for local generated files.

Behavior

Actual

There was no standardized tool + documented flow to export a Codex wiki bundle, and local generated artifacts could leak into branch changes.

Expected

Contributors can run a single script to export the wiki bundle, follow documented steps in docs/README.md, and keep local generated artifacts ignored by git.

Fixes

(issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested

  • Ran python3 tools/export_wiki_bundle.py locally and validated script execution/output generation.
  • Verified docs instructions in docs/README.md match the implemented script flow.
  • Verified local Codex wiki artifacts are covered by ignore rules and do not appear unexpectedly in git status.

Test Configuration:

  • Server Version: N/A
  • Client: OTClient (branch feat/codex)
  • Operating System: Ubuntu 24.04 LTS

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • Documentation

    • Added a bilingual user guide describing how to package, distribute, customize, and use Codex wiki/agent bundles, plus extraction and translation workflows.
  • New Features

    • Added a CLI tool that assembles referenced documentation into a deployable ZIP bundle, reports missing references, and prints generation stats.

not tested by explicit user decision
not tested by explicit user decision
not tested by explicit user decision
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

📝 Walkthrough

Walkthrough

Adds documentation, .gitignore entries, and a new CLI tool to collect referenced wiki files and produce a compressed "wiki bundle" ZIP for distribution and use with Codex/OTClient.

Changes

Cohort / File(s) Summary
Configuration & Exclusions
\.gitignore
Added ignore rules for generated/exported documentation and agent files (e.g., docs/roadmap/, codex_export_*.zip, various AGENTS*.md, selected modules/*.md and src/client/*.md).
Documentation
docs/README.md
New bilingual (PT-BR/EN) README describing expected bundle contents, generation (python3 tools/export_wiki_bundle.py), publishing steps, default release URLs, extraction/usage instructions for Codex, and recommended translation workflow.
Tooling
tools/export_wiki_bundle.py
New executable CLI that locates wiki.md, extracts backtick-delimited paths, de-duplicates and filters entries (excludes configured prefixes), recursively collects files, emits warnings for missing entries, and writes a deflated ZIP containing repo-relative paths.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User as User (CLI)
    participant Script as export_wiki_bundle.py
    participant FS as Repository FS
    participant Zip as ZIP Archive

    rect rgba(135,206,250,0.5)
    User->>Script: run `python3 tools/export_wiki_bundle.py`
    end
    rect rgba(144,238,144,0.5)
    Script->>FS: locate `wiki.md` (root or docs/)
    Script->>FS: read wiki content
    Script->>Script: parse backtick-delimited paths (dedupe, order)
    Script->>Script: filter out excluded prefixes
    Script->>FS: resolve each path (file or directory)
    FS-->>Script: return files (or missing warnings)
    end
    rect rgba(255,182,193,0.5)
    Script->>Zip: write resolved files with repo-relative paths
    Zip-->>Script: confirm archive written
    Script->>User: print summary, warnings, output path
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through backticks, found each line,

Packed pages snug, a bundle fine.
A README hums in two tongues bright,
The exporter zips them up just right.
Hop, share, and let Codex bite. 📦✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding a Codex wiki bundle export workflow and local artifact ignore rules, matching the changeset which includes tools/export_wiki_bundle.py, docs/README.md, and .gitignore updates.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
tools/export_wiki_bundle.py (1)

68-68: Prefer iterable unpacking over concatenation.

Using [*items] syntax is more idiomatic and avoids creating an intermediate list.

♻️ Suggested fix
-    paths = [wiki_path.relative_to(repo_root).as_posix(), "AGENTS.global.md"] + raw_paths
+    paths = [wiki_path.relative_to(repo_root).as_posix(), "AGENTS.global.md", *raw_paths]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/export_wiki_bundle.py` at line 68, The paths list is built by
concatenating lists; update the assignment of paths to use iterable unpacking so
the first two elements (derived from wiki_path.relative_to(repo_root).as_posix()
and the literal "AGENTS.global.md") are followed by the expanded raw_paths
iterable (use the * unpacking operator on raw_paths) to avoid creating an extra
intermediate list; modify the line that assigns paths (referencing variables
paths, wiki_path, repo_root, and raw_paths) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/README.md`:
- Around line 100-104: Update the two constants used in the English section so
they point to the upstream repository: replace the values assigned to
RELEASE_PAGE_URL and WIKI_BUNDLE_URL (the lines containing
`RELEASE_PAGE_URL=...` and `WIKI_BUNDLE_URL=...`) so the host path uses
`opentibiabr/otclient` instead of `Juanzitooh/otclient`, ensuring both the
release tag URL and the direct zip download URL are corrected.
- Around line 29-33: The RELEASE_PAGE_URL and WIKI_BUNDLE_URL values currently
point to the fork `Juanzitooh/otclient`; update both constants (RELEASE_PAGE_URL
and WIKI_BUNDLE_URL) to use the target repository `opentibiabr/otclient`
instead, and make the same replacements in the English section occurrences
referenced (lines around the English section, currently at lines 100 and 104) so
all download/release links point to opentibiabr/otclient.

In `@tools/export_wiki_bundle.py`:
- Around line 60-68: Add a short docstring or inline comment near the top of
export_wiki_bundle.py (close to wiki_path, parse_paths, and the logic that
builds paths = [..., "AGENTS.global.md"] + raw_paths) clarifying that wiki.md
(or docs/wiki.md) is mandatory and the script will exit with error if missing,
while AGENTS.global.md is optional and will be included only if present; update
the comment near the filtering logic that skips non-slash paths to note this
behavior so future readers understand the hard vs soft dependency.

---

Nitpick comments:
In `@tools/export_wiki_bundle.py`:
- Line 68: The paths list is built by concatenating lists; update the assignment
of paths to use iterable unpacking so the first two elements (derived from
wiki_path.relative_to(repo_root).as_posix() and the literal "AGENTS.global.md")
are followed by the expanded raw_paths iterable (use the * unpacking operator on
raw_paths) to avoid creating an extra intermediate list; modify the line that
assigns paths (referencing variables paths, wiki_path, repo_root, and raw_paths)
accordingly.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 82f448eb-ba1f-4db1-9470-3ac6d1d71fe1

📥 Commits

Reviewing files that changed from the base of the PR and between 294896c and 886264d.

📒 Files selected for processing (3)
  • .gitignore
  • docs/README.md
  • tools/export_wiki_bundle.py

Comment on lines +29 to +33
`RELEASE_PAGE_URL=https://github.com/Juanzitooh/otclient/releases/tag/codex`

Download direto do zip:

`WIKI_BUNDLE_URL=https://github.com/Juanzitooh/otclient/releases/download/codex/codex_export_otclient.zip`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Update URLs to point to the target repository, not the fork.

The URLs reference Juanzitooh/otclient (the author's fork) but this PR targets opentibiabr/otclient. After merge, users following this documentation will download from the wrong location or get 404s if the fork release doesn't exist.

🔧 Suggested fix
-`RELEASE_PAGE_URL=https://github.com/Juanzitooh/otclient/releases/tag/codex`
+`RELEASE_PAGE_URL=https://github.com/opentibiabr/otclient/releases/tag/codex`

 Download direto do zip:

-`WIKI_BUNDLE_URL=https://github.com/Juanzitooh/otclient/releases/download/codex/codex_export_otclient.zip`
+`WIKI_BUNDLE_URL=https://github.com/opentibiabr/otclient/releases/download/codex/codex_export_otclient.zip`

Also apply the same fix to lines 100 and 104 in the English section.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
`RELEASE_PAGE_URL=https://github.com/Juanzitooh/otclient/releases/tag/codex`
Download direto do zip:
`WIKI_BUNDLE_URL=https://github.com/Juanzitooh/otclient/releases/download/codex/codex_export_otclient.zip`
`RELEASE_PAGE_URL=https://github.com/opentibiabr/otclient/releases/tag/codex`
Download direto do zip:
`WIKI_BUNDLE_URL=https://github.com/opentibiabr/otclient/releases/download/codex/codex_export_otclient.zip`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/README.md` around lines 29 - 33, The RELEASE_PAGE_URL and
WIKI_BUNDLE_URL values currently point to the fork `Juanzitooh/otclient`; update
both constants (RELEASE_PAGE_URL and WIKI_BUNDLE_URL) to use the target
repository `opentibiabr/otclient` instead, and make the same replacements in the
English section occurrences referenced (lines around the English section,
currently at lines 100 and 104) so all download/release links point to
opentibiabr/otclient.

Comment on lines +100 to +104
`RELEASE_PAGE_URL=https://github.com/Juanzitooh/otclient/releases/tag/codex`

Direct zip download:

`WIKI_BUNDLE_URL=https://github.com/Juanzitooh/otclient/releases/download/codex/codex_export_otclient.zip`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Same URL issue in English section.

These URLs also need to be updated to point to opentibiabr/otclient instead of the fork.

🔧 Suggested fix
-`RELEASE_PAGE_URL=https://github.com/Juanzitooh/otclient/releases/tag/codex`
+`RELEASE_PAGE_URL=https://github.com/opentibiabr/otclient/releases/tag/codex`

 Direct zip download:

-`WIKI_BUNDLE_URL=https://github.com/Juanzitooh/otclient/releases/download/codex/codex_export_otclient.zip`
+`WIKI_BUNDLE_URL=https://github.com/opentibiabr/otclient/releases/download/codex/codex_export_otclient.zip`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
`RELEASE_PAGE_URL=https://github.com/Juanzitooh/otclient/releases/tag/codex`
Direct zip download:
`WIKI_BUNDLE_URL=https://github.com/Juanzitooh/otclient/releases/download/codex/codex_export_otclient.zip`
`RELEASE_PAGE_URL=https://github.com/opentibiabr/otclient/releases/tag/codex`
Direct zip download:
`WIKI_BUNDLE_URL=https://github.com/opentibiabr/otclient/releases/download/codex/codex_export_otclient.zip`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/README.md` around lines 100 - 104, Update the two constants used in the
English section so they point to the upstream repository: replace the values
assigned to RELEASE_PAGE_URL and WIKI_BUNDLE_URL (the lines containing
`RELEASE_PAGE_URL=...` and `WIKI_BUNDLE_URL=...`) so the host path uses
`opentibiabr/otclient` instead of `Juanzitooh/otclient`, ensuring both the
release tag URL and the direct zip download URL are corrected.

Comment on lines +60 to +68
if wiki_path is None:
print("Erro: wiki.md (raiz) ou docs/wiki.md nao encontrado no repo.", file=sys.stderr)
return 1

wiki_text = wiki_path.read_text(encoding="utf-8")
raw_paths = parse_paths(wiki_text)

# Sempre inclui a wiki encontrada e o AGENTS global.
paths = [wiki_path.relative_to(repo_root).as_posix(), "AGENTS.global.md"] + raw_paths
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if wiki.md or AGENTS.global.md exist in the repository
echo "=== Checking for wiki.md ==="
fd -t f -i "wiki.md"

echo "=== Checking for AGENTS.global.md ==="
fd -t f -i "AGENTS.global.md"

echo "=== Listing docs/ contents if exists ==="
if [ -d "docs" ]; then
  tree docs -L 2 2>/dev/null || ls -la docs/
fi

Repository: opentibiabr/otclient

Length of output: 320


🏁 Script executed:

# Read the full script to understand context and any comments about required files
wc -l tools/export_wiki_bundle.py

Repository: opentibiabr/otclient

Length of output: 95


🏁 Script executed:

# Check the full script content with line numbers
cat -n tools/export_wiki_bundle.py

Repository: opentibiabr/otclient

Length of output: 4787


🏁 Script executed:

# Search for any documentation or README that mentions wiki.md or AGENTS.global.md
rg -i "wiki\.md|agents\.global" --type md

Repository: opentibiabr/otclient

Length of output: 674


🏁 Script executed:

# Check if there's any documentation in the PR or script comments about these files
rg -i "wiki\.md|agents\.global" -A 2 -B 2

Repository: opentibiabr/otclient

Length of output: 3629


Script documentation could clarify file requirements.

The script has a hard requirement for wiki.md (or docs/wiki.md) which will cause it to exit with error if missing. This is intentional and documented in docs/README.md. However, AGENTS.global.md is already designed to be optional—it's included in the bundle if it exists, but silently skipped if missing (line 43-44 filters reporting to only paths containing "/" to avoid "ruido de tokens textuais").

Consider adding a docstring clarification or comment in the script distinguishing the requirements: wiki.md is mandatory for the script to function, while AGENTS.global.md is a soft dependency included only if present. This would prevent confusion when running the script on fresh setups.

🧰 Tools
🪛 Ruff (0.15.7)

[warning] 68-68: Consider iterable unpacking instead of concatenation

Replace with iterable unpacking

(RUF005)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/export_wiki_bundle.py` around lines 60 - 68, Add a short docstring or
inline comment near the top of export_wiki_bundle.py (close to wiki_path,
parse_paths, and the logic that builds paths = [..., "AGENTS.global.md"] +
raw_paths) clarifying that wiki.md (or docs/wiki.md) is mandatory and the script
will exit with error if missing, while AGENTS.global.md is optional and will be
included only if present; update the comment near the filtering logic that skips
non-slash paths to note this behavior so future readers understand the hard vs
soft dependency.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tools/export_wiki_bundle.py (2)

68-72: Consider iterable unpacking instead of list concatenation.

Ruff flagged this as RUF005. Using unpacking is slightly more idiomatic in modern Python.

♻️ Proposed fix using iterable unpacking
-    paths = [
-        wiki_path.relative_to(repo_root).as_posix(),
-        "AGENTS.global.md",
-        "tools/export_wiki_bundle.py",
-    ] + raw_paths
+    paths = [
+        wiki_path.relative_to(repo_root).as_posix(),
+        "AGENTS.global.md",
+        "tools/export_wiki_bundle.py",
+        *raw_paths,
+    ]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/export_wiki_bundle.py` around lines 68 - 72, Replace the list
concatenation used to build the paths variable with iterable unpacking: when
constructing the paths list where wiki_path, "AGENTS.global.md", and
"tools/export_wiki_bundle.py" are combined with raw_paths, expand raw_paths into
the literal list using unpacking so raw_paths items are inlined rather than
appended via +; update the expression that assigns to paths (referencing
variables paths, raw_paths, wiki_path, repo_root) accordingly.

64-64: Consider handling encoding errors gracefully.

read_text(encoding="utf-8") will raise UnicodeDecodeError if wiki.md contains invalid UTF-8 bytes. For a local dev tool this is low risk, but a try-except with a user-friendly message would improve robustness.

♻️ Optional fix for encoding error handling
-    wiki_text = wiki_path.read_text(encoding="utf-8")
+    try:
+        wiki_text = wiki_path.read_text(encoding="utf-8")
+    except UnicodeDecodeError as e:
+        print(f"Erro: falha ao ler {wiki_path} como UTF-8: {e}", file=sys.stderr)
+        return 1
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/export_wiki_bundle.py` at line 64, Wrap the
wiki_path.read_text(encoding="utf-8") call in a try/except that catches
UnicodeDecodeError, referencing the wiki_text assignment and wiki_path.read_text
call; on error, log or raise a user-friendly message that includes the file name
and the decode error, then optionally fallback to a tolerant decode (e.g., read
bytes via wiki_path.read_bytes() and decode(..., errors="replace")) so the tool
can proceed instead of crashing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tools/export_wiki_bundle.py`:
- Around line 68-72: Replace the list concatenation used to build the paths
variable with iterable unpacking: when constructing the paths list where
wiki_path, "AGENTS.global.md", and "tools/export_wiki_bundle.py" are combined
with raw_paths, expand raw_paths into the literal list using unpacking so
raw_paths items are inlined rather than appended via +; update the expression
that assigns to paths (referencing variables paths, raw_paths, wiki_path,
repo_root) accordingly.
- Line 64: Wrap the wiki_path.read_text(encoding="utf-8") call in a try/except
that catches UnicodeDecodeError, referencing the wiki_text assignment and
wiki_path.read_text call; on error, log or raise a user-friendly message that
includes the file name and the decode error, then optionally fallback to a
tolerant decode (e.g., read bytes via wiki_path.read_bytes() and decode(...,
errors="replace")) so the tool can proceed instead of crashing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ca4027f-643b-4b0f-8653-a399d5c8ffb3

📥 Commits

Reviewing files that changed from the base of the PR and between 886264d and 18c6fb4.

📒 Files selected for processing (1)
  • tools/export_wiki_bundle.py

@Sorky96
Copy link
Copy Markdown

Sorky96 commented Apr 5, 2026

Agents.md should not contain any language other than English. It's a waste of tokens

## Documentation Growth Rules
- Escrever em PT-BR com termos tecnicos em ingles quando necessario.
- Frases curtas, listas objetivas e escopo claro no inicio.
- Quebrar guias grandes por subpasta e manter o guia pai como indice.
- Reaproveitar contexto existente antes de criar novo arquivo.

Yeah buddy, hard no go for me.

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