Skip to content

Commit 6a7358f

Browse files
committed
Remove example templates for various programming languages (Node.js, PHP, Python, Ruby, Rust) and mock API server. This includes deleting package files, solution scripts, and associated dependencies to streamline the project structure and focus on core functionality.
1 parent 5227ac7 commit 6a7358f

40 files changed

Lines changed: 65 additions & 8224 deletions

.github/workflows/ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ jobs:
231231
steps:
232232
- uses: actions/checkout@v4
233233

234-
- name: Check required files and ALL 10 language directories
234+
- name: Check required files and at least one supported implementation
235235
run: |
236236
errors=0
237237
ALL_LANGS="python node php go java csharp ruby rust kotlin bash"
@@ -248,19 +248,23 @@ jobs:
248248
errors=$((errors + 1))
249249
fi
250250
251-
# ALL 10 language directories required
251+
# At least one supported language directory required
252+
lang_count=0
252253
for lang in $ALL_LANGS; do
253-
if [ ! -d "$dir/$lang" ]; then
254-
echo "ERROR: $dir is missing $lang/ directory"
255-
errors=$((errors + 1))
254+
if [ -d "$dir/$lang" ]; then
255+
lang_count=$((lang_count + 1))
256256
fi
257257
done
258+
if [ $lang_count -eq 0 ]; then
259+
echo "ERROR: $dir does not contain a supported language directory"
260+
errors=$((errors + 1))
261+
fi
258262
done
259263
if [ $errors -gt 0 ]; then
260264
echo "Found $errors structural errors"
261265
exit 1
262266
fi
263-
echo "All example packs have complete structure (10 languages)"
267+
echo "All example packs have required files and at least one supported implementation"
264268
265269
- name: Check no .env files committed
266270
run: |

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ composer.lock
77
package-lock.json
88
.DS_Store
99
Thumbs.db
10-
11-
# Internal planning directory (excluded from git)
12-
.planning/

CONTRIBUTING.md

Lines changed: 27 additions & 291 deletions
Original file line numberDiff line numberDiff line change
@@ -1,308 +1,44 @@
1-
# Contributing to CaptchaAI Examples
1+
# Working With CaptchaAI Examples
22

3-
## Overview
3+
This repository is maintained internally and published so CaptchaAI clients can get to working example code quickly.
44

5-
This repository holds full working code examples that accompany [CaptchaAI blog articles](https://blog.captchaai.com). Each example is a complete, runnable project — not a snippet.
5+
The public contract here is simple: each pack under `articles/{slug}/` is a client-facing example, and the README inside that pack is the setup and usage guide clients should follow.
66

7-
## Support tiers
7+
## Public vs private
88

9-
Every example pack is classified into a support tier:
9+
- Public: blog articles on `blog.captchaai.com` and the example packs in this repository.
10+
- Private: the editorial workflow, generation pipeline, maintenance scripts, and internal review process used to create and update those outputs.
1011

11-
| Tier | Badge | Criteria |
12-
|------|-------|----------|
13-
| **Verified** | 🟢 | All 10 languages CI-linted, solver-correct, manually reviewed |
14-
| **Standard** | 🟡 | All 10 languages present, scaffolded from verified templates, basic validation passes |
15-
| **Generated** || Scaffolded from template, may have known issues pending review |
12+
This public repo intentionally contains the published packs only. Internal templates, tools, scaffolding, repair scripts, smoke tooling, and other maintenance automation stay in the private factory.
1613

17-
### Promotion path
14+
This repo exists to serve clients, not to document the internal factory that produces content and examples.
1815

19-
```
20-
Generated → Standard → Verified
21-
```
16+
## Support levels
2217

23-
**Generated → Standard:** Fix any null labels, fix mojibake, ensure blog backlink, pass CI.
18+
We use support levels to describe the current confidence level honestly, not to imply perfection across every included language.
2419

25-
**Standard → Verified:** All 10 languages CI-linted, solver correctness validated (method + response field + params), manual code review completed.
20+
| Tier | Badge | What it means |
21+
|------|-------|---------------|
22+
| **Verified** | 🟢 | The pack's reference flow has been reviewed closely and checked against current CaptchaAI behavior and repo validation. This is the highest-confidence level in the public repo, but not every included language always receives identical review depth. |
23+
| **Standard** | 🟡 | The pack is documented, available, and structurally checked. At least one implementation has been reviewed, while other included implementations may still be receiving lighter validation or iterative improvement. |
24+
| **Available** || The pack is published because it is useful to clients, with lighter review depth than Standard or Verified. It is available for reference without claiming perfect parity across every included implementation. |
2625

27-
### CI-validated languages
26+
## Language coverage
2827

29-
The following languages are checked in CI:
28+
Many packs currently include Python, Node.js, PHP, Go, Java, C#, Ruby, Rust, Kotlin, and Bash.
3029

31-
| Language | CI Check | Status |
32-
|----------|----------|--------|
33-
| Python | `ruff` (syntax + style) | Enforced |
34-
| Node.js | `acorn` (ECMAScript 2020) | Enforced |
35-
| PHP | `php -l` (syntax) | Enforced |
36-
| Go | `go vet` / `gofmt` | Enforced |
37-
| Ruby | `ruby -c` (syntax) | Enforced |
38-
| Bash | `bash -n` + `shellcheck` | Enforced |
39-
| Java | `javac` (compilation) | Enforced |
40-
| Kotlin | `kotlinc` (syntax) | Best-effort |
41-
| C# || Planned |
42-
| Rust || Planned |
30+
That is a current coverage choice, not a permanent promise for every pack now or later. The README and support tier of a specific pack are the source of truth for what level of support you should expect.
4331

44-
## When to add an example
32+
## What we check publicly
4533

46-
An example pack should be created when:
34+
The public quality bar focuses on usefulness and honesty:
4735

48-
- The blog article type is: API tutorial, Tutorial, Integration guide, Framework, DevOps tutorial, Project tutorial, or Use case guide
49-
- The example provides clear value beyond the in-article code snippets
50-
- The article has a complete draft (not a placeholder)
51-
- The article's `editorial_review` is not `manual-only`
36+
- Correct CaptchaAI API endpoints and parameter usage
37+
- Clear setup instructions and environment configuration
38+
- A working blog backlink for context
39+
- Lint or compile checks where toolchains are available
40+
- Deeper runtime or smoke validation on selected reference flows
5241

53-
Do **not** create an example pack when:
42+
## External contributions
5443

55-
- The in-article snippet is sufficient on its own
56-
- The article is a comparison, explainer, or reference with no meaningful runnable code
57-
- The example would be shallow or trivial (single API call with no workflow)
58-
59-
## Structure
60-
61-
Every example pack lives under `articles/{slug}/` and must contain:
62-
63-
```
64-
articles/{slug}/
65-
README.md # Setup, usage, expected output, troubleshooting
66-
.env.example # All required environment variables with descriptive comments
67-
.gitignore # Excludes .env, build artifacts for all languages
68-
python/ # Python implementation
69-
solve.py
70-
requirements.txt
71-
node/ # Node.js implementation
72-
solve.js
73-
package.json
74-
php/ # PHP implementation
75-
solve.php
76-
composer.json
77-
go/ # Go implementation
78-
solve.go
79-
go.mod
80-
java/ # Java implementation
81-
Solve.java
82-
csharp/ # C# implementation
83-
Solve.cs
84-
Solve.csproj
85-
ruby/ # Ruby implementation
86-
solve.rb
87-
Gemfile
88-
rust/ # Rust implementation
89-
src/main.rs
90-
Cargo.toml
91-
kotlin/ # Kotlin implementation
92-
solve.kt
93-
bash/ # Bash/cURL implementation
94-
solve.sh
95-
```
96-
97-
## Supported languages
98-
99-
Every example pack **must** include all 10 supported languages:
100-
101-
| Language | Directory | Entry point | Manifest |
102-
|----------|-----------|-------------|----------|
103-
| Python | `python/` | `solve.py` | `requirements.txt` |
104-
| Node.js | `node/` | `solve.js` | `package.json` |
105-
| PHP | `php/` | `solve.php` | `composer.json` |
106-
| Go | `go/` | `solve.go` | `go.mod` |
107-
| Java | `java/` | `Solve.java` ||
108-
| C# | `csharp/` | `Solve.cs` | `Solve.csproj` |
109-
| Ruby | `ruby/` | `solve.rb` | `Gemfile` |
110-
| Rust | `rust/` | `src/main.rs` | `Cargo.toml` |
111-
| Kotlin | `kotlin/` | `solve.kt` ||
112-
| Bash/cURL | `bash/` | `solve.sh` ||
113-
114-
## Code requirements
115-
116-
### API endpoints
117-
118-
- Submit: `https://ocr.captchaai.com/in.php`
119-
- Poll: `https://ocr.captchaai.com/res.php`
120-
- Always use `json=1` for structured responses
121-
- Never hardcode alternative or mock endpoints
122-
123-
### Credentials
124-
125-
- Load from `.env` file (dotenv for languages that support it, manual parsing for others)
126-
- Use `YOUR_API_KEY` as the placeholder in `.env.example`
127-
- Use `YOUR_SITE_KEY` as the placeholder for sitekeys
128-
- Never commit real API keys
129-
- `.gitignore` must exclude `.env`
130-
131-
### Input validation
132-
133-
Every example must validate before making any API call:
134-
135-
- API key is set and not a placeholder
136-
- Sitekey is set and not a placeholder
137-
- Page URL is set and not the default example value
138-
- Exit immediately with a clear message on missing config
139-
140-
### Polling
141-
142-
- Wait 15-20 seconds before first poll
143-
- Poll every 5 seconds (configurable via `POLL_INTERVAL`)
144-
- Handle `CAPCHA_NOT_READY` as normal in-progress
145-
- Implement a maximum timeout (default: 120 seconds, configurable via `MAX_TIMEOUT`)
146-
- Log each poll attempt with attempt number
147-
148-
### Error handling
149-
150-
Handle **all** documented error categories:
151-
152-
| Category | Errors | Handling |
153-
|----------|--------|----------|
154-
| Auth | `ERROR_WRONG_USER_KEY`, `ERROR_KEY_DOES_NOT_EXIST`, `IP_BANNED` | Exit with clear message about API key |
155-
| Balance | `ERROR_ZERO_BALANCE` | Exit with message to top up account |
156-
| Input | `ERROR_PAGEURL`, `ERROR_WRONG_GOOGLEKEY`, `ERROR_BAD_PARAMETERS`, `ERROR_BAD_TOKEN_OR_PAGEURL` | Exit with parameter validation message |
157-
| Transient | `ERROR_SERVER_ERROR`, `ERROR_INTERNAL_SERVER_ERROR` | Retry with exponential backoff (cap at 30s) |
158-
| Solve | `ERROR_CAPTCHA_UNSOLVABLE` | Exit with message to verify parameters |
159-
| Proxy | `ERROR_BAD_PROXY`, `ERROR_PROXY_CONNECTION_FAILED` | Exit with message to check proxy config |
160-
161-
### Token injection guidance
162-
163-
The final output message must reference the **correct** response field for the CAPTCHA type:
164-
165-
| CAPTCHA Type | Response field |
166-
|-------------|---------------|
167-
| reCAPTCHA v2/v3 | `g-recaptcha-response` |
168-
| Cloudflare Turnstile | `cf-turnstile-response` |
169-
| GeeTest | Custom callback |
170-
| hCaptcha | `h-captcha-response` |
171-
| Image CAPTCHA | Direct text value |
172-
173-
**Never** use `g-recaptcha-response` for non-reCAPTCHA types. This is a hard rule.
174-
175-
### Output format
176-
177-
All languages must produce identical output format:
178-
179-
```
180-
[*] Submitting {CAPTCHA_TYPE} task...
181-
[+] Task submitted. ID: {id}
182-
[*] Waiting 15s before first poll...
183-
[*] Polling for result (attempt {n})...
184-
[*] Not ready yet, waiting {n}s...
185-
[+] Solved! Token: {first_50_chars}...
186-
[+] Full token length: {n} characters
187-
188-
Next step: inject this token into the target page's
189-
{correct_response_field} hidden field and submit the form.
190-
```
191-
192-
### Expected output
193-
194-
Include a section in the README showing what a successful run looks like.
195-
196-
### Code style
197-
198-
- Python: PEP 8
199-
- Node.js: StandardJS or Prettier defaults
200-
- PHP: PSR-12
201-
- Go: gofmt
202-
- Java: Google Java Style
203-
- C#: .NET conventions
204-
- Ruby: Standard Ruby style
205-
- Rust: rustfmt
206-
- Kotlin: Kotlin Coding Conventions
207-
- Bash: ShellCheck-clean
208-
209-
## README template
210-
211-
Every example README must include:
212-
213-
1. Title (matches the article)
214-
2. Description (includes CAPTCHA type)
215-
3. Languages list
216-
4. Link to the blog article
217-
5. Prerequisites (with version requirements)
218-
6. Setup instructions (clone → install → configure → run) for **every** language
219-
7. Environment variables table with descriptions
220-
8. How it works (4-step flow)
221-
9. Expected output (full console output)
222-
10. Common errors table (error → cause → fix)
223-
11. Troubleshooting (at least 3 scenarios)
224-
12. API docs link
225-
13. Related examples
226-
227-
## Linking
228-
229-
- Example README links to: blog article, API docs, related examples
230-
- Blog article links to: example repo path using a **clickable anchor**, not a raw URL
231-
232-
Correct article CTA format:
233-
234-
```md
235-
## Full runnable example
236-
237-
Need a complete working project with environment setup, polling, retries, and error handling?
238-
239-
[See the full runnable example on GitHub →](https://github.com/CaptchaAI/CaptchaAI-Examples/tree/main/articles/{slug})
240-
```
241-
242-
## Quality checklist — Code
243-
244-
Before submitting, **every language** in the example pack must pass:
245-
246-
### Correctness
247-
- [ ] Code uses real CaptchaAI API endpoints (`in.php` submit, `res.php` poll)
248-
- [ ] API method parameter matches the CAPTCHA type (e.g. `turnstile` not `userrecaptcha` for Turnstile)
249-
- [ ] Token injection message references the correct response field for the CAPTCHA type
250-
- [ ] Field names in code match the API documentation exactly
251-
- [ ] `.env.example` lists all required variables with descriptive comments
252-
253-
### Consistency across languages
254-
- [ ] All languages use the same `.env` variable names
255-
- [ ] All languages use the same poll interval default (5s)
256-
- [ ] All languages use the same max timeout default (120s)
257-
- [ ] All languages use the same initial wait (15s)
258-
- [ ] All languages produce the same output format
259-
- [ ] All languages handle the same error categories
260-
- [ ] All languages validate config before making API calls
261-
262-
### Error handling
263-
- [ ] Auth errors → clear message about API key
264-
- [ ] Balance errors → message to top up
265-
- [ ] Input errors → parameter validation message
266-
- [ ] Transient errors → retry with exponential backoff (cap at 30s)
267-
- [ ] Solve errors → exit with verify message
268-
- [ ] Proxy errors → exit with proxy check message
269-
- [ ] Network errors → caught and reported (not unhandled crashes)
270-
- [ ] Missing config → clear message before any API call
271-
272-
### Security
273-
- [ ] No real API keys, tokens, or secrets in code
274-
- [ ] No hardcoded credentials
275-
- [ ] `.gitignore` excludes `.env` and all build artifacts
276-
- [ ] HTTP timeouts set on all requests (30s)
277-
- [ ] No eval() or equivalent dynamic code execution
278-
279-
### Quality
280-
- [ ] Code follows the language's standard style guide
281-
- [ ] Setup instructions work from clone to first run
282-
- [ ] README links back to the blog article
283-
- [ ] Expected output in README matches actual output format
284-
- [ ] Dependencies are minimal (prefer stdlib where possible)
285-
286-
## Quality checklist — README
287-
288-
- [ ] Title matches the blog article title
289-
- [ ] Description mentions the specific CAPTCHA type
290-
- [ ] All supported languages are listed
291-
- [ ] Prerequisites include version requirements
292-
- [ ] Setup instructions cover every language
293-
- [ ] Environment variables table is complete
294-
- [ ] How it works matches the actual code flow
295-
- [ ] Expected output matches what the code actually prints
296-
- [ ] Common errors table covers all 6 error categories
297-
- [ ] Troubleshooting covers at least 3 failure scenarios
298-
- [ ] No references to wrong CAPTCHA types (e.g. reCAPTCHA wording in a Turnstile example)
299-
300-
## Scaffolding
301-
302-
New example packs are scaffolded using the tool in the `cai_content` repository:
303-
304-
```bash
305-
python scripts/scaffold_example_pack.py articles/{slug}.md --examples-repo ../CaptchaAI-Examples
306-
```
307-
308-
This generates the directory structure, README template, `.env.example`, and starter code files for all 10 languages.
44+
This repository is not running a broad external contribution workflow right now. If that changes, this file will be updated.

0 commit comments

Comments
 (0)