Skip to content

Commit ffaf4ca

Browse files
committed
feat: add code-explainer skill with docs, pipeline, and publishing setup
0 parents  commit ffaf4ca

32 files changed

+2768
-0
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
validate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.11"
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
24+
- name: Install Mermaid CLI
25+
run: npm install -g @mermaid-js/mermaid-cli
26+
27+
- name: Compile scripts
28+
working-directory: code-explainer
29+
run: python -c "import glob,py_compile; [py_compile.compile(f, doraise=True) for f in glob.glob('scripts/*.py')]; print('compiled')"
30+
31+
- name: Smoke test
32+
working-directory: code-explainer
33+
run: python scripts/analyze.py analyze --source . --output .ci-out --mode standard --audience nontech --enable-web-enrichment false
34+

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
5+
# Skill local outputs
6+
code-explainer/.out*/
7+
code-explainer/.out-gh/
8+
9+
# OS/editor
10+
.DS_Store
11+
Thumbs.db
12+
.vscode/
13+
.idea/
14+

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2026
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

PUBLISHING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Publishing and Distribution
2+
3+
## 1) Publish to GitHub
4+
5+
From repository root:
6+
7+
```bash
8+
git add .
9+
git commit -m "feat: add code-explainer skill"
10+
git remote add origin https://github.com/<your-org-or-user>/code-explainer.git
11+
git push -u origin main
12+
```
13+
14+
## 2) Verify Install from GitHub
15+
16+
Use the Skills CLI install pattern:
17+
18+
```bash
19+
npx skills add https://github.com/<your-org-or-user>/code-explainer --skill code-explainer
20+
```
21+
22+
Or with Codex system installer script:
23+
24+
```bash
25+
python ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
26+
--repo <your-org-or-user>/code-explainer \
27+
--path code-explainer
28+
```
29+
30+
Dependency note for downstream users:
31+
32+
- Python 3.10+
33+
- Node.js 18+ and npm
34+
- Git
35+
- Mermaid CLI (`@mermaid-js/mermaid-cli`) for full SVG/PNG rendering
36+
37+
Point users to:
38+
39+
- `README.md` -> "Dependencies (Required for Skill Installation/Use)"
40+
- `code-explainer/SKILL.md` -> "Dependencies"
41+
42+
## 3) `skills.sh` Listing Expectations
43+
44+
- `skills.sh` tracks install activity from `npx skills` usage.
45+
- The site updates roughly every 12 hours.
46+
- Removed/unavailable repos can be pruned from listings.
47+
48+
Practical implication:
49+
50+
1. Publish repo publicly.
51+
2. Ensure install command works.
52+
3. Have users install via `npx skills ...` so the skill becomes discoverable through ecosystem tracking.
53+
54+
## 4) Increase Discoverability
55+
56+
1. Add GitHub topics: `agent-skill`, `codex`, `mermaid`, `codebase-analysis`, `onboarding`.
57+
2. Add a short demo GIF in README showing generated overview + deep docs.
58+
3. Publish a GitHub release with example outputs.
59+
4. Share in developer communities with install command and sample output links.

README.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# code-explainer
2+
3+
`code-explainer` is an open-source skill that analyzes either a local repository folder or a GitHub URL and produces onboarding explainers for PMs, designers, and engineers.
4+
5+
Outputs include:
6+
7+
- Crisp top-level overview (`OVERVIEW.md`)
8+
- Linked deep explainers (architecture, modules, flows, dependencies, glossary)
9+
- Mermaid source diagrams (`.mmd`)
10+
- Rendered SVG and PNG diagrams
11+
- Confidence, attribution, and quality reports (`meta/*.json`)
12+
13+
## Repository Layout
14+
15+
```text
16+
code-explainer/
17+
SKILL.md
18+
agents/openai.yaml
19+
scripts/
20+
references/
21+
assets/templates/
22+
```
23+
24+
## Dependencies (Required for Skill Installation/Use)
25+
26+
Install these before using the skill:
27+
28+
- Python `3.10+`
29+
- Node.js `18+` and npm
30+
- Git
31+
32+
For high-fidelity diagram rendering (`SVG` + `PNG` via Mermaid CLI):
33+
34+
- Mermaid CLI (`mmdc`) from `@mermaid-js/mermaid-cli`
35+
36+
If `mmdc` is missing, the skill still runs but uses fallback rendering and reports it in `meta/render_report.json`.
37+
38+
## Install Runtime Dependencies
39+
40+
### Windows (PowerShell)
41+
42+
```powershell
43+
powershell -ExecutionPolicy Bypass -File .\code-explainer\scripts\install_runtime.ps1
44+
```
45+
46+
### macOS/Linux
47+
48+
```bash
49+
bash ./code-explainer/scripts/install_runtime.sh
50+
```
51+
52+
## Troubleshooting Dependencies
53+
54+
### 1) `mmdc` is not recognized
55+
56+
If you see: `mmdc: command not found` or `The term 'mmdc' is not recognized`
57+
58+
Run:
59+
60+
```bash
61+
npm install -g @mermaid-js/mermaid-cli
62+
mmdc --version
63+
```
64+
65+
If it still fails:
66+
67+
1. Open a new terminal session.
68+
2. Check global npm bin path:
69+
70+
```bash
71+
npm bin -g
72+
```
73+
74+
3. Ensure that path is on your `PATH` environment variable.
75+
76+
### 2) Mermaid rendering fails with Chromium/Puppeteer errors
77+
78+
If you see browser launch errors from `mmdc`:
79+
80+
1. Reinstall Mermaid CLI:
81+
82+
```bash
83+
npm uninstall -g @mermaid-js/mermaid-cli
84+
npm install -g @mermaid-js/mermaid-cli
85+
```
86+
87+
2. Re-run:
88+
89+
```bash
90+
mmdc --version
91+
```
92+
93+
3. If still blocked, the skill will continue with fallback rendering and report it in `meta/render_report.json`.
94+
95+
### 3) `npm install -g` permission errors
96+
97+
- Windows: run PowerShell as Administrator and retry.
98+
- macOS/Linux: avoid `sudo npm install -g` if possible; use Node version managers (`nvm`, `fnm`, `asdf`) and retry.
99+
100+
### 4) `python` command not found
101+
102+
Confirm Python install:
103+
104+
```bash
105+
python --version
106+
```
107+
108+
If unavailable on Windows but `py` exists:
109+
110+
```powershell
111+
py --version
112+
```
113+
114+
Install Python 3.10+ and ensure it is added to `PATH`.
115+
116+
### 5) `git` command not found for GitHub URL analysis
117+
118+
Install Git and verify:
119+
120+
```bash
121+
git --version
122+
```
123+
124+
Local folder analysis can still run without Git, but GitHub URL source mode requires it.
125+
126+
## Install Sequence (Fresh Machine)
127+
128+
1. Install runtime dependencies (section above).
129+
2. Install skill into Codex:
130+
131+
```powershell
132+
powershell -ExecutionPolicy Bypass -File .\install_to_codex.ps1
133+
```
134+
135+
3. Restart Codex to load the new skill.
136+
137+
## Run
138+
139+
```bash
140+
cd code-explainer
141+
python scripts/analyze.py analyze \
142+
--source <local_path_or_github_url> \
143+
--output <output_dir> \
144+
--mode standard \
145+
--audience nontech \
146+
--enable-web-enrichment true
147+
```
148+
149+
## Install Into Codex
150+
151+
Use the installer script:
152+
153+
```powershell
154+
powershell -ExecutionPolicy Bypass -File .\install_to_codex.ps1
155+
```
156+
157+
Or copy manually to:
158+
159+
```text
160+
~/.codex/skills/code-explainer
161+
```
162+
163+
Then restart Codex so it picks up the new skill.
164+
165+
## Open-Source Publishing
166+
167+
1. Initialize git in this repository.
168+
2. Commit files.
169+
3. Push to GitHub.
170+
4. Add `topics` such as: `codex-skill`, `agent-skill`, `mermaid`, `codebase-analysis`, `onboarding`.
171+
5. Submit/list the repository on skill directories (see notes in your assistant response).

0 commit comments

Comments
 (0)