opencode-skills-collection 3.1.14 → 3.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled-skills/.antigravity-install-manifest.json +36 -1
- package/bundled-skills/007/scripts/full_audit.py +34 -22
- package/bundled-skills/007/scripts/quick_scan.py +24 -15
- package/bundled-skills/007/scripts/scanners/dependency_scanner.py +31 -19
- package/bundled-skills/007/scripts/scanners/injection_scanner.py +24 -14
- package/bundled-skills/007/scripts/scanners/secrets_scanner.py +24 -14
- package/bundled-skills/007/scripts/score_calculator.py +25 -13
- package/bundled-skills/2slides-ppt-generator/scripts/download_slides_pages_voices.py +15 -1
- package/bundled-skills/aegisops-ai/SKILL.md +1 -1
- package/bundled-skills/agent-self-scheduling/SKILL.md +88 -0
- package/bundled-skills/alpha-vantage/SKILL.md +3 -1
- package/bundled-skills/anti-sleep/SKILL.md +90 -0
- package/bundled-skills/api-security-best-practices/SKILL.md +1 -1
- package/bundled-skills/app-store-optimization/SKILL.md +7 -0
- package/bundled-skills/audio-transcriber/scripts/transcribe.py +17 -4
- package/bundled-skills/azure-mgmt-botservice-py/SKILL.md +2 -1
- package/bundled-skills/azure-resource-manager-mysql-dotnet/SKILL.md +2 -1
- package/bundled-skills/azure-resource-manager-postgresql-dotnet/SKILL.md +2 -1
- package/bundled-skills/azure-resource-manager-sql-dotnet/SKILL.md +2 -1
- package/bundled-skills/biopython/SKILL.md +2 -1
- package/bundled-skills/brain-to-docs/SKILL.md +54 -0
- package/bundled-skills/browser-harness/SKILL.md +220 -0
- package/bundled-skills/browser-harness/references/install.md +132 -0
- package/bundled-skills/bumblebee/scripts/render_report.py +16 -3
- package/bundled-skills/bun-development/SKILL.md +1 -1
- package/bundled-skills/cc-skill-security-review/SKILL.md +2 -2
- package/bundled-skills/claude-monitor/scripts/monitor.py +15 -2
- package/bundled-skills/cmux/SKILL.md +250 -0
- package/bundled-skills/code-polish/SKILL.md +192 -0
- package/bundled-skills/code-review-checklist/SKILL.md +1 -1
- package/bundled-skills/codex-subagent/SKILL.md +117 -0
- package/bundled-skills/competitor-analysis/scripts/capture_screenshots.mjs +24 -3
- package/bundled-skills/competitor-analysis/scripts/compile_report.mjs +13 -2
- package/bundled-skills/competitor-analysis/scripts/extract_vs_names.mjs +23 -2
- package/bundled-skills/competitor-analysis/scripts/gate_candidates.mjs +21 -0
- package/bundled-skills/competitor-analysis/scripts/list_urls.mjs +23 -2
- package/bundled-skills/competitor-analysis/scripts/merge_partials.mjs +24 -3
- package/bundled-skills/container-security-hardening/SKILL.md +1 -1
- package/bundled-skills/content-creator/scripts/brand_voice_analyzer.py +15 -1
- package/bundled-skills/content-creator/scripts/seo_optimizer.py +15 -1
- package/bundled-skills/context-kit/SKILL.md +135 -0
- package/bundled-skills/cyber-audit/SKILL.md +138 -0
- package/bundled-skills/deepapi/SKILL.md +649 -0
- package/bundled-skills/delegating-to-agents/SKILL.md +64 -0
- package/bundled-skills/developer-signup-flow/SKILL.md +1 -1
- package/bundled-skills/diary/scripts/fetch_diaries.py +14 -1
- package/bundled-skills/diary/scripts/prepare_context.py +15 -2
- package/bundled-skills/diary/scripts/sync_to_notion.py +14 -1
- package/bundled-skills/dispatch/SKILL.md +19 -7
- package/bundled-skills/distribute-skill-to-all-agents/SKILL.md +85 -0
- package/bundled-skills/docs/integrations/jetski-cortex.md +3 -3
- package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +1 -1
- package/bundled-skills/docs/maintainers/repo-growth-seo.md +3 -3
- package/bundled-skills/docs/maintainers/skills-update-guide.md +1 -1
- package/bundled-skills/docs/users/bundles.md +1 -1
- package/bundled-skills/docs/users/claude-code-skills.md +1 -1
- package/bundled-skills/docs/users/gemini-cli-skills.md +1 -1
- package/bundled-skills/docs/users/getting-started.md +1 -1
- package/bundled-skills/docs/users/kiro-integration.md +1 -1
- package/bundled-skills/docs/users/usage.md +4 -4
- package/bundled-skills/docs/users/visual-guide.md +4 -4
- package/bundled-skills/docx-official/ooxml/scripts/pack.py +30 -3
- package/bundled-skills/docx-official/ooxml/scripts/unpack.py +16 -3
- package/bundled-skills/drizzle-migration-conflict/scripts/check_drizzle_migrations.py +27 -17
- package/bundled-skills/ecl-harness-engineer/agents/creator-config.md +17 -3
- package/bundled-skills/ecl-harness-engineer/references/environment-detection-guide.md +9 -5
- package/bundled-skills/effective-agent-skills/SKILL.md +333 -0
- package/bundled-skills/electron-development/SKILL.md +6 -2
- package/bundled-skills/environment-setup-guide/SKILL.md +2 -5
- package/bundled-skills/expo-ui/scripts/list-components.js +5 -1
- package/bundled-skills/fable-safe-prompt/SKILL.md +79 -0
- package/bundled-skills/folder-specific-claude-and-agents-md/SKILL.md +96 -0
- package/bundled-skills/frontend-slides/scripts/extract-pptx.py +18 -4
- package/bundled-skills/gcp-cloud-run/SKILL.md +2 -1
- package/bundled-skills/gemini-api-integration/SKILL.md +3 -1
- package/bundled-skills/gemini-live-api-dev/SKILL.md +2 -1
- package/bundled-skills/gemini-omni-flash-api/scripts/video/generate_video.py +49 -14
- package/bundled-skills/goal-loop/SKILL.md +175 -0
- package/bundled-skills/hugging-face-evaluation/SKILL.md +1 -1
- package/bundled-skills/hugging-face-jobs/SKILL.md +1 -1
- package/bundled-skills/hugging-face-jobs/scripts/finepdfs-stats.py +14 -1
- package/bundled-skills/hugging-face-model-trainer/scripts/convert_to_gguf.py +10 -1
- package/bundled-skills/hugo-to-markdown/scripts/inventory_hugo_rules.py +14 -1
- package/bundled-skills/image-generator/SKILL.md +3 -1
- package/bundled-skills/instagram/scripts/export.py +18 -7
- package/bundled-skills/interview-style-doc-building/SKILL.md +86 -0
- package/bundled-skills/junta-leiloeiros/scripts/export.py +19 -10
- package/bundled-skills/landing-page-generator/scripts/landing_page_scaffolder.py +15 -1
- package/bundled-skills/linear-claude-skill/SKILL.md +4 -2
- package/bundled-skills/linkedin-post-writer/SKILL.md +159 -0
- package/bundled-skills/linkedin-post-writer/references/hook-formulas.md +482 -0
- package/bundled-skills/llm-council/SKILL.md +4 -2
- package/bundled-skills/loki-mode/examples/todo-app-generated/backend/package-lock.json +5 -6
- package/bundled-skills/loki-mode/examples/todo-app-generated/backend/package.json +2 -3
- package/bundled-skills/markdown-rendering/SKILL.md +72 -0
- package/bundled-skills/matematico-tao/scripts/complexity_analyzer.py +14 -1
- package/bundled-skills/matematico-tao/scripts/dependency_graph.py +15 -2
- package/bundled-skills/mobile-design/scripts/mobile_audit.py +20 -6
- package/bundled-skills/monte-carlo-validation-notebook/scripts/resolve_dbt_schema.py +15 -2
- package/bundled-skills/multi-agent-architect/SKILL.md +1 -1
- package/bundled-skills/odoo-rpc-api/SKILL.md +2 -1
- package/bundled-skills/pci-compliance/SKILL.md +3 -1
- package/bundled-skills/pdf-official/scripts/create_validation_image.py +17 -3
- package/bundled-skills/pdf-official/scripts/extract_form_field_info.py +1 -1
- package/bundled-skills/personal-tool-builder/SKILL.md +1 -1
- package/bundled-skills/pi-custom-model/SKILL.md +68 -0
- package/bundled-skills/pi-web-search/SKILL.md +74 -0
- package/bundled-skills/playwright-skill/run.js +19 -1
- package/bundled-skills/pptx-official/ooxml/scripts/pack.py +30 -3
- package/bundled-skills/pptx-official/ooxml/scripts/unpack.py +16 -3
- package/bundled-skills/pptx-official/scripts/inventory.py +17 -4
- package/bundled-skills/pptx-official/scripts/rearrange.py +15 -2
- package/bundled-skills/pptx-official/scripts/replace.py +16 -3
- package/bundled-skills/product-manager-toolkit/scripts/customer_interview_analyzer.py +15 -1
- package/bundled-skills/production-code-audit/SKILL.md +1 -1
- package/bundled-skills/push-skill-to-github/SKILL.md +61 -0
- package/bundled-skills/rclone-cli/references/commands/rclone_completion_powershell.md +3 -2
- package/bundled-skills/read-all-adrs/SKILL.md +35 -0
- package/bundled-skills/remote-gpu-trainer/scripts/verify_local.py +14 -1
- package/bundled-skills/research-prompt/SKILL.md +63 -0
- package/bundled-skills/run-deep-swe/SKILL.md +120 -0
- package/bundled-skills/senior-architect/scripts/architecture_diagram_generator.py +15 -2
- package/bundled-skills/senior-architect/scripts/dependency_analyzer.py +15 -2
- package/bundled-skills/senior-architect/scripts/project_architect.py +15 -2
- package/bundled-skills/senior-frontend/scripts/bundle_analyzer.py +14 -1
- package/bundled-skills/senior-frontend/scripts/frontend_scaffolder.py +14 -1
- package/bundled-skills/senior-fullstack/scripts/code_quality_analyzer.py +15 -2
- package/bundled-skills/senior-fullstack/scripts/fullstack_scaffolder.py +15 -2
- package/bundled-skills/senior-fullstack/scripts/project_scaffolder.py +15 -2
- package/bundled-skills/setup-help/SKILL.md +50 -0
- package/bundled-skills/shodan-reconnaissance/SKILL.md +2 -1
- package/bundled-skills/short/SKILL.md +28 -0
- package/bundled-skills/skill-creator/scripts/init_skill.py +15 -2
- package/bundled-skills/skill-creator/scripts/package_skill.py +29 -12
- package/bundled-skills/skill-creator/scripts/quick_validate.py +14 -2
- package/bundled-skills/skill-creator-ms/SKILL.md +1 -1
- package/bundled-skills/skill-installer/scripts/install_skill.py +42 -8
- package/bundled-skills/skill-installer/scripts/package_skill.py +29 -17
- package/bundled-skills/skill-installer/scripts/validate_skill.py +37 -22
- package/bundled-skills/stripe-integration/SKILL.md +7 -3
- package/bundled-skills/swiftui-expert-skill/scripts/instruments_parser/xctrace.py +7 -1
- package/bundled-skills/swiftui-expert-skill/scripts/instruments_parser/xml_utils.py +7 -1
- package/bundled-skills/taisly-social-media-posting/SKILL.md +79 -0
- package/bundled-skills/technical-tutorials/SKILL.md +1 -1
- package/bundled-skills/telegram/scripts/setup_project.py +17 -2
- package/bundled-skills/time-ledger/SKILL.md +118 -0
- package/bundled-skills/trading-ledger/SKILL.md +121 -0
- package/bundled-skills/videodb/scripts/ws_listener.py +17 -4
- package/bundled-skills/voice-ai-development/SKILL.md +2 -1
- package/bundled-skills/vps-server-management/SKILL.md +72 -0
- package/bundled-skills/weaviate/scripts/weaviate_conn.py +20 -18
- package/bundled-skills/wgm/SKILL.md +137 -0
- package/bundled-skills/whatsapp-cloud-api/scripts/setup_project.py +16 -1
- package/bundled-skills/workorai/SKILL.md +137 -0
- package/bundled-skills/wp-site-health-auditor/SKILL.md +341 -0
- package/bundled-skills/wp-site-health-auditor/references/catalog.md +135 -0
- package/bundled-skills/writing-skills/render-graphs.js +13 -2
- package/bundled-skills/x-twitter-scraper/SKILL.md +3 -1
- package/bundled-skills/youtube-notetaker/scripts/serve.py +41 -31
- package/bundled-skills/youtube-notetaker/scripts/vtt_to_transcript.py +16 -2
- package/bundled-skills/youtube-notetaker/scripts/write_library_item.py +15 -1
- package/bundled-skills/youtube-transcript/SKILL.md +120 -0
- package/package.json +5 -1
- package/skills_index.json +786 -6
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-polish
|
|
3
|
+
description: Rewrites unprofessional code comments into clear ones and performs non-semantic cleanup. Use to professionalize code without altering logic or behavior.
|
|
4
|
+
risk: critical
|
|
5
|
+
source: community
|
|
6
|
+
date_added: "2026-07-02"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Code Polish
|
|
10
|
+
|
|
11
|
+
A constraint-based protocol for normalizing code comments and performing safe, non-semantic cleanup. This skill exists because human-written code tends to carry casual, outdated, or missing comments, while the goal is professional-grade documentation without touching behavior.
|
|
12
|
+
|
|
13
|
+
This file is self-contained. Do not require any other skill file to execute this protocol.
|
|
14
|
+
|
|
15
|
+
## Prime Directive
|
|
16
|
+
|
|
17
|
+
Comments and non-semantic cleanup are the job. Logic is never the job. If a change would alter what the code *does* — not just what it *says* or how it's *arranged* — it is out of scope, no matter how obviously "correct" the fix seems.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## When to Use
|
|
22
|
+
|
|
23
|
+
Apply this skill when:
|
|
24
|
+
- The user asks to "clean up," "professionalize," or "polish" existing code
|
|
25
|
+
- Code is being prepped for code review, handoff, open-sourcing, or documentation
|
|
26
|
+
- A file has a mix of human and AI-written comments and needs one consistent, professional voice
|
|
27
|
+
- Comments are outdated, missing, redundant, or written casually (venting, placeholders, inside jokes)
|
|
28
|
+
- The user wants comments improved but explicitly does **not** want logic touched
|
|
29
|
+
|
|
30
|
+
Do not apply this skill when:
|
|
31
|
+
- The user wants a bug fixed or behavior changed (that's a different job — logic edits are out of scope here)
|
|
32
|
+
- The user wants a full rewrite or architectural restructuring
|
|
33
|
+
- The only ask is adding new features or functionality
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Phase 0 — Full Read
|
|
38
|
+
|
|
39
|
+
Before editing anything, read the entire file (or the entire relevant module if the codebase is large — not just the function in question). Do not comment or clean incrementally while still reading. A comment written without full context is a guess, and guesses are how "professional" comments end up wrong.
|
|
40
|
+
|
|
41
|
+
Identify:
|
|
42
|
+
- The language and its idiomatic comment/docstring convention (JSDoc, Python docstrings, `///` for Rust, XML doc comments, etc.)
|
|
43
|
+
- Any existing project comment style already in use elsewhere in the file — match it rather than importing a foreign convention
|
|
44
|
+
- Any comment that encodes real, non-obvious information (race conditions, workarounds for external bugs, "don't reorder this" warnings, business-rule justifications)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Phase 1 — Comment Audit
|
|
49
|
+
|
|
50
|
+
Classify every existing comment into one of these categories before touching it:
|
|
51
|
+
|
|
52
|
+
| Category | Example | Action |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| **Junk / venting** | `// wtf is this`, `// idk why but it works` | Remove tone, extract any real information underneath, rewrite professionally — or delete if it truly holds zero information |
|
|
55
|
+
| **Placeholder** | `// fix later`, `// TODO hack` | Convert to a proper `TODO:` note with the actual concern stated plainly, or remove if stale/resolved |
|
|
56
|
+
| **Dead code comments** | Blocks of commented-out code | Remove, unless the surrounding context makes clear it's intentionally preserved (e.g., a documented fallback) — flag these to the user rather than silently deleting |
|
|
57
|
+
| **Redundant** | `i++ // increment i` | Delete — the code already says this |
|
|
58
|
+
| **Outdated / wrong** | Comment describes behavior the code no longer has | Rewrite to match current behavior. Flag to the user that it was stale, don't just silently fix it |
|
|
59
|
+
| **Valuable but informal** | `// careful, this breaks if you call it twice, learned that the hard way` | Preserve the *information*, rewrite the *tone*. Never delete real warnings just because the phrasing is casual |
|
|
60
|
+
| **Missing** | Complex logic, non-obvious business rules, or public APIs with no docstring | Add one. Don't over-comment simple, self-explanatory lines |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Phase 2 — Non-Semantic Cleanup
|
|
65
|
+
|
|
66
|
+
Scope is strictly limited to changes that cannot alter behavior:
|
|
67
|
+
|
|
68
|
+
- Consistent indentation and whitespace
|
|
69
|
+
- Consistent brace/bracket style matching the surrounding file
|
|
70
|
+
- Removing truly dead code (unreachable blocks) — only when unambiguous, and flagged in the summary
|
|
71
|
+
- Splitting overly long lines for readability
|
|
72
|
+
- Local variable renaming for clarity is allowed **only** for private/local-scope names, and only when the improvement is unambiguous — never rename anything exported, public, or referenced across files without calling it out explicitly first
|
|
73
|
+
|
|
74
|
+
Anything beyond this — reordering logic, extracting functions, changing control flow, altering algorithms — is out of scope for this skill.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Phase 3 — Comment Rewrite / Addition
|
|
79
|
+
|
|
80
|
+
Apply these standards to every comment touched or added:
|
|
81
|
+
|
|
82
|
+
- **Explain why, not what.** The code already shows *what* it does; a comment earns its place by explaining intent, tradeoffs, or non-obvious constraints.
|
|
83
|
+
- **Use the language's idiomatic doc format** for functions, classes, and public APIs (JSDoc, docstrings, `///`, etc.) — match the convention already used elsewhere in the file if one exists.
|
|
84
|
+
- **Be concise.** No padding, no restating the obvious, no filler sentences.
|
|
85
|
+
- **No informal register.** No jokes, no venting, no first-person asides ("I think this works because...").
|
|
86
|
+
- **No AI-tell phrasing.** Avoid generic filler like "This function is responsible for..." or "Note that..." padding, and avoid em-dashes. Write plainly and directly, the way a careful senior engineer would.
|
|
87
|
+
- **Don't invent behavior.** If you're not certain why something is done a certain way, say what the code does, not a fabricated justification for why.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Phase 4 — Verification
|
|
92
|
+
|
|
93
|
+
Before presenting the result:
|
|
94
|
+
|
|
95
|
+
- Confirm the edited file's logic is behaviorally identical to the original — comments and whitespace are the only permitted diffs, plus whatever narrow Phase 2 cleanup was done.
|
|
96
|
+
- Re-read the diff end to end, not just the changed lines in isolation, to catch anything that accidentally shifted meaning.
|
|
97
|
+
- If a rewritten comment removes information that was present in the original (even informally stated), that's a failure — go back and preserve it.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Phase 5 — Report Back
|
|
102
|
+
|
|
103
|
+
Summarize for the user, don't just hand back a silent diff:
|
|
104
|
+
- How many comments were rewritten, added, or removed, and why
|
|
105
|
+
- Any comments flagged as "informal but contained a real warning" — confirm the information was preserved
|
|
106
|
+
- Any dead code or stale comments removed, listed explicitly
|
|
107
|
+
- Anything you were unsure about and left alone rather than guessing
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Examples
|
|
112
|
+
|
|
113
|
+
**Junk / venting → professional**
|
|
114
|
+
```js
|
|
115
|
+
// before
|
|
116
|
+
// ugh this took forever to figure out. api rate limits us super hard in prod so we have to do exponential backoff here. just leave it alone
|
|
117
|
+
function retryFetch(url, attempts) { ... }
|
|
118
|
+
|
|
119
|
+
// after
|
|
120
|
+
// Uses exponential backoff to handle aggressive API rate-limiting in production.
|
|
121
|
+
function retryFetch(url, attempts) { ... }
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Redundant → removed**
|
|
125
|
+
```python
|
|
126
|
+
# before
|
|
127
|
+
count += 1 # increment count by 1
|
|
128
|
+
|
|
129
|
+
# after
|
|
130
|
+
count += 1
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Valuable but informal → tone rewritten, information preserved**
|
|
134
|
+
```python
|
|
135
|
+
# before
|
|
136
|
+
# careful, this breaks if you call it twice, learned that the hard way
|
|
137
|
+
|
|
138
|
+
# after
|
|
139
|
+
# Not idempotent: calling this more than once per session corrupts the
|
|
140
|
+
# cache index. Callers must guard against duplicate invocation.
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Missing → added**
|
|
144
|
+
```java
|
|
145
|
+
// before
|
|
146
|
+
public double calculate(double base, int tier) {
|
|
147
|
+
return base * (tier > 2 ? 0.85 : 1.0);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// after
|
|
151
|
+
/**
|
|
152
|
+
* Applies the loyalty discount. Tiers above 2 qualify for a 15% discount;
|
|
153
|
+
* this threshold matches the current pricing policy, not a technical limit.
|
|
154
|
+
*/
|
|
155
|
+
public double calculate(double base, int tier) {
|
|
156
|
+
return base * (tier > 2 ? 0.85 : 1.0);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Outdated / wrong → corrected and flagged**
|
|
161
|
+
```go
|
|
162
|
+
// before
|
|
163
|
+
// returns nil if user not found
|
|
164
|
+
func GetUser(id string) (*User, error) { ... } // now returns ErrNotFound instead
|
|
165
|
+
|
|
166
|
+
// after
|
|
167
|
+
// Returns ErrNotFound if the user does not exist.
|
|
168
|
+
func GetUser(id string) (*User, error) { ... }
|
|
169
|
+
// (flagged to user: original comment was stale — function used to return nil,
|
|
170
|
+
// now returns a named error)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Security & Safety Notes
|
|
176
|
+
|
|
177
|
+
This skill never:
|
|
178
|
+
- Changes program logic, control flow, or algorithmic behavior
|
|
179
|
+
- Restructures code (extracting/inlining functions, reordering execution, changing architecture)
|
|
180
|
+
- Renames anything public, exported, or cross-referenced without explicit confirmation
|
|
181
|
+
- Deletes a comment solely because its tone is casual, without checking whether it carries real information first
|
|
182
|
+
- Fabricates a rationale for a comment when the actual reason isn't knowable from context — state what's certain only
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Limitations
|
|
187
|
+
|
|
188
|
+
- Cannot verify runtime behavior — Phase 4 is a read-through diff check, not a test run. For anything beyond trivial files, the user should still run the actual test suite after applying this skill.
|
|
189
|
+
- Judgment calls on ambiguous cases (e.g., "is this dead code intentional or forgotten?") default to flagging rather than guessing — this means some cleanup will need a quick human yes/no rather than happening silently.
|
|
190
|
+
- Not a substitute for a linter or formatter — Phase 2 cleanup is deliberately conservative and won't enforce a full style guide (e.g., max line length rules, import ordering) unless that's trivially inferable from the surrounding file.
|
|
191
|
+
- Comment quality is bounded by how well the code's actual intent can be inferred from context. If the "why" genuinely isn't recoverable from the file (no domain knowledge, no commit history, no ticket references available), the honest output is a comment describing *what*, not a confident but invented *why*.
|
|
192
|
+
- Large files or unfamiliar codebases increase the risk of Phase 0 missing context that would have changed a comment's wording — flag uncertainty in the Phase 5 report rather than presenting low-confidence rewrites as settled.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codex-subagent
|
|
3
|
+
description: "Launch Codex CLI as an isolated subagent for bounded coding, review, or verification tasks."
|
|
4
|
+
category: agent-orchestration
|
|
5
|
+
risk: critical
|
|
6
|
+
source: community
|
|
7
|
+
source_repo: davidondrej/skills
|
|
8
|
+
source_type: community
|
|
9
|
+
date_added: "2026-07-07"
|
|
10
|
+
author: davidondrej
|
|
11
|
+
tags: [codex, subagents, delegation]
|
|
12
|
+
tools: [claude, codex]
|
|
13
|
+
license: "MIT"
|
|
14
|
+
license_source: "https://github.com/davidondrej/skills/blob/main/LICENSE"
|
|
15
|
+
disable-model-invocation: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Codex CLI as a Subagent
|
|
19
|
+
|
|
20
|
+
## When to Use
|
|
21
|
+
|
|
22
|
+
- Use when a bounded coding, review, or verification task can run in a separate Codex CLI session.
|
|
23
|
+
- Use when parallel work needs explicit file ownership and a clear definition of done.
|
|
24
|
+
|
|
25
|
+
Codex CLI is OpenAI's terminal coding agent. `codex exec` runs it non-interactively:
|
|
26
|
+
it works autonomously in a sandbox, streams progress to stderr, and prints only the
|
|
27
|
+
final message to stdout. Auth reuses the user's ChatGPT subscription — never an API key.
|
|
28
|
+
|
|
29
|
+
## When to delegate
|
|
30
|
+
|
|
31
|
+
- Self-contained coding task with clear success criteria (fix, feature, refactor, review).
|
|
32
|
+
- Parallel work: several independent tasks at once (see Parallel runs).
|
|
33
|
+
- Second opinion / independent verification of your own changes.
|
|
34
|
+
|
|
35
|
+
Do NOT delegate tasks that need conversation context you can't fully write into the prompt.
|
|
36
|
+
|
|
37
|
+
## Preflight
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
codex --version # missing? npm i -g @openai/codex (or: brew install --cask codex)
|
|
41
|
+
codex login status # exit 0 + "Logged in using ChatGPT" = ready
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Not logged in → stop and tell the user to run `codex login` (one-time browser OAuth).
|
|
45
|
+
Never read, print, or copy credentials (`~/.codex/auth.json`).
|
|
46
|
+
|
|
47
|
+
## Launch
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
OUT=$(mktemp /tmp/codex-out.XXXXXX)
|
|
51
|
+
codex exec \
|
|
52
|
+
--cd /path/to/repo \
|
|
53
|
+
--sandbox workspace-write \
|
|
54
|
+
--output-last-message "$OUT" \
|
|
55
|
+
"Full task prompt: goal, constraints, files to touch, definition of done." \
|
|
56
|
+
</dev/null
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- `</dev/null` is MANDATORY when stdin is not a real terminal (background shells,
|
|
60
|
+
scripts): codex treats open stdin as extra context and waits forever for EOF.
|
|
61
|
+
- Codex sees NOTHING of your conversation. Put all context in the prompt:
|
|
62
|
+
goal, relevant paths, constraints, and how to verify it's done.
|
|
63
|
+
- Long prompt? Pipe it via stdin instead: `codex exec [flags] - < /tmp/task.md`.
|
|
64
|
+
- Wrap the command in a background/Bash subagent if your host agent has one
|
|
65
|
+
(Cursor: Task tool with a shell subagent) so Codex's verbose stream stays out
|
|
66
|
+
of the parent context. Fallback: a plain background terminal.
|
|
67
|
+
- Runs take minutes and have no built-in timeout — background it and monitor.
|
|
68
|
+
- Optional: `-m <model>` to override the model, `--json` for JSONL event stream.
|
|
69
|
+
|
|
70
|
+
## Collect results
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cat "$OUT" # final message = the deliverable
|
|
74
|
+
git -C /path/to/repo status --short # see what Codex actually changed
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Follow-up in the same session (run from the same cwd — resume filters by cwd):
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
codex exec resume --last "follow-up instruction" </dev/null
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Parallel runs
|
|
84
|
+
|
|
85
|
+
Parallelize only genuinely independent tasks, and assign file ownership upfront so
|
|
86
|
+
results merge cleanly. One git worktree per Codex run — never two in the same tree:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git worktree add /tmp/wt-taskA -b codex/task-a
|
|
90
|
+
codex exec --cd /tmp/wt-taskA --sandbox workspace-write -o /tmp/outA.md "task A" </dev/null
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Failure modes
|
|
94
|
+
|
|
95
|
+
- Hangs forever with no output → stdin was left open. Kill it, relaunch with `</dev/null`.
|
|
96
|
+
- `codex login status` non-zero → the user must run `codex login`. Don't work around it.
|
|
97
|
+
- ChatGPT plan rate limit hit → report to the user; never retry in a loop.
|
|
98
|
+
- "Not a git repo" error → add `--skip-git-repo-check`, or init a repo first.
|
|
99
|
+
- Network is blocked inside the workspace-write sandbox by default. If the task
|
|
100
|
+
needs it (installs, API calls): `-c sandbox_workspace_write.network_access=true`.
|
|
101
|
+
- NEVER use `--dangerously-bypass-approvals-and-sandbox`.
|
|
102
|
+
|
|
103
|
+
## Rules
|
|
104
|
+
|
|
105
|
+
- One task per launch. Split big jobs into multiple launches.
|
|
106
|
+
- Review Codex's diff yourself before declaring the task done.
|
|
107
|
+
|
|
108
|
+
## Cursor-native wrapper (optional)
|
|
109
|
+
|
|
110
|
+
For auto-routing and `/codex` invocation inside Cursor, add `~/.cursor/agents/codex.md` —
|
|
111
|
+
a custom subagent whose description is "delegates coding tasks to Codex CLI" and whose
|
|
112
|
+
body points at this skill.
|
|
113
|
+
|
|
114
|
+
## Limitations
|
|
115
|
+
|
|
116
|
+
- Adapted from `davidondrej/skills`; verify local paths, tools, credentials, and agent features before acting.
|
|
117
|
+
- For commands, remote access, scheduling, browser automation, or file-changing workflows, get explicit user approval and confirm the target environment first.
|
|
@@ -12,12 +12,33 @@
|
|
|
12
12
|
//
|
|
13
13
|
// Usage: node capture_screenshots.mjs <research-dir> [--mode remote|local] [--concurrency 2]
|
|
14
14
|
|
|
15
|
+
import sanitizeFilename from 'sanitize-filename';
|
|
15
16
|
import { readdirSync, readFileSync, mkdirSync, existsSync } from 'fs';
|
|
16
|
-
import { join } from 'path';
|
|
17
|
+
import { isAbsolute, join, relative, resolve } from 'path';
|
|
17
18
|
import { spawnSync } from 'child_process';
|
|
18
19
|
import { parseFrontmatter } from './md_utils.mjs';
|
|
19
20
|
|
|
20
21
|
const args = process.argv.slice(2);
|
|
22
|
+
function sanitizePathSegments(pathValue) {
|
|
23
|
+
return String(pathValue ?? '').split(/[\\/]+/).filter(Boolean).map((segment) => {
|
|
24
|
+
const sanitized = sanitizeFilename(segment);
|
|
25
|
+
if (sanitized !== segment || !sanitized) {
|
|
26
|
+
throw new Error(`Unsafe path segment: ${segment}`);
|
|
27
|
+
}
|
|
28
|
+
return sanitized;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function safeCliPath(pathValue, baseDir = process.cwd()) {
|
|
33
|
+
const root = resolve(baseDir);
|
|
34
|
+
const target = resolve(root, ...sanitizePathSegments(pathValue));
|
|
35
|
+
const rel = relative(root, target);
|
|
36
|
+
if (rel.startsWith('..') || isAbsolute(rel)) {
|
|
37
|
+
throw new Error(`Path escapes allowed directory: ${pathValue}`);
|
|
38
|
+
}
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
|
|
22
43
|
if (args.includes('--help') || args.includes('-h') || args.length === 0) {
|
|
23
44
|
console.error(`Usage: node capture_screenshots.mjs <research-dir> [options]
|
|
@@ -38,7 +59,7 @@ Options:
|
|
|
38
59
|
process.exit(args.includes('--help') || args.includes('-h') ? 0 : 1);
|
|
39
60
|
}
|
|
40
61
|
|
|
41
|
-
const dir = args[0];
|
|
62
|
+
const dir = safeCliPath(args[0]);
|
|
42
63
|
const modeIdx = args.indexOf('--mode');
|
|
43
64
|
const browseMode = modeIdx !== -1 ? args[modeIdx + 1] : 'remote';
|
|
44
65
|
const modeFlag = browseMode === 'local' ? '--local' : '--remote';
|
|
@@ -63,7 +84,7 @@ if (concurrency > 1) {
|
|
|
63
84
|
concurrency = 1;
|
|
64
85
|
}
|
|
65
86
|
|
|
66
|
-
const shotsDir =
|
|
87
|
+
const shotsDir = safeCliPath('screenshots', dir);
|
|
67
88
|
mkdirSync(shotsDir, { recursive: true });
|
|
68
89
|
|
|
69
90
|
function run(cmd, args, { timeout = 30000 } = {}) {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { readdirSync, readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
10
10
|
import { basename, dirname, join, relative, resolve } from 'path';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
|
+
import sanitizeFilename from 'sanitize-filename';
|
|
12
13
|
import { parseFrontmatter, parseBody, parseSections } from './md_utils.mjs';
|
|
13
14
|
|
|
14
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -17,9 +18,19 @@ const __dirname = dirname(__filename);
|
|
|
17
18
|
const args = process.argv.slice(2);
|
|
18
19
|
const SAFE_SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
19
20
|
|
|
21
|
+
function sanitizePathSegments(pathValue) {
|
|
22
|
+
return String(pathValue ?? '').split(/[\\/]+/).filter(Boolean).map((segment) => {
|
|
23
|
+
const sanitized = sanitizeFilename(segment);
|
|
24
|
+
if (sanitized !== segment || !sanitized) {
|
|
25
|
+
throw new Error(`Unsafe path segment: ${segment}`);
|
|
26
|
+
}
|
|
27
|
+
return sanitized;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
function safeJoin(base, ...parts) {
|
|
21
32
|
const root = resolve(base);
|
|
22
|
-
const target = resolve(root, ...parts);
|
|
33
|
+
const target = resolve(root, ...parts.flatMap(sanitizePathSegments));
|
|
23
34
|
const rel = relative(root, target);
|
|
24
35
|
if (rel.startsWith('..') || rel.startsWith('/')) {
|
|
25
36
|
throw new Error(`Path escapes research directory: ${parts.join('/')}`);
|
|
@@ -32,7 +43,7 @@ function safeResearchDir(rawDir) {
|
|
|
32
43
|
throw new Error('Research directory is required');
|
|
33
44
|
}
|
|
34
45
|
const root = resolve(process.cwd());
|
|
35
|
-
const target =
|
|
46
|
+
const target = safeJoin(root, rawDir);
|
|
36
47
|
const rel = relative(root, target);
|
|
37
48
|
if ((rel.startsWith('..') || rel.startsWith('/')) && process.env.COMPETITOR_ANALYSIS_ALLOW_EXTERNAL_DIR !== '1') {
|
|
38
49
|
throw new Error('Research directory must stay under the current working directory');
|
|
@@ -9,10 +9,31 @@
|
|
|
9
9
|
// Output: newline-delimited JSON to stdout, one object per candidate:
|
|
10
10
|
// { "name": "serper", "hits": 3, "domain": "serper.dev", "example": "Tavily vs Serper..." }
|
|
11
11
|
|
|
12
|
+
import sanitizeFilename from 'sanitize-filename';
|
|
12
13
|
import { readdirSync, readFileSync } from 'fs';
|
|
13
|
-
import { join } from 'path';
|
|
14
|
+
import { isAbsolute, join, relative, resolve } from 'path';
|
|
14
15
|
|
|
15
16
|
const args = process.argv.slice(2);
|
|
17
|
+
function sanitizePathSegments(pathValue) {
|
|
18
|
+
return String(pathValue ?? '').split(/[\\/]+/).filter(Boolean).map((segment) => {
|
|
19
|
+
const sanitized = sanitizeFilename(segment);
|
|
20
|
+
if (sanitized !== segment || !sanitized) {
|
|
21
|
+
throw new Error(`Unsafe path segment: ${segment}`);
|
|
22
|
+
}
|
|
23
|
+
return sanitized;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function safeCliPath(pathValue, baseDir = process.cwd()) {
|
|
28
|
+
const root = resolve(baseDir);
|
|
29
|
+
const target = resolve(root, ...sanitizePathSegments(pathValue));
|
|
30
|
+
const rel = relative(root, target);
|
|
31
|
+
if (rel.startsWith('..') || isAbsolute(rel)) {
|
|
32
|
+
throw new Error(`Path escapes allowed directory: ${pathValue}`);
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
36
|
+
|
|
16
37
|
|
|
17
38
|
if (args.includes('--help') || args.includes('-h') || args.length === 0) {
|
|
18
39
|
console.error(`Usage: node extract_vs_names.mjs <directory> [--prefix <prefix>] [--seed "<csv>"]
|
|
@@ -28,7 +49,7 @@ Options:
|
|
|
28
49
|
process.exit(args.includes('--help') || args.includes('-h') ? 0 : 1);
|
|
29
50
|
}
|
|
30
51
|
|
|
31
|
-
const dir = args[0];
|
|
52
|
+
const dir = safeCliPath(args[0]);
|
|
32
53
|
const prefixIdx = args.indexOf('--prefix');
|
|
33
54
|
const prefix = prefixIdx !== -1 && args[prefixIdx + 1] ? args[prefixIdx + 1] : 'competitor';
|
|
34
55
|
const seedIdx = args.indexOf('--seed');
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// { "url": "https://foo.com", "status": "PASS" | "REJECT" | "UNKNOWN",
|
|
15
15
|
// "matched_includes": [...], "matched_excludes": [...], "title": "...", "hero": "..." }
|
|
16
16
|
|
|
17
|
+
import sanitizeFilename from 'sanitize-filename';
|
|
17
18
|
import { execFile } from 'child_process';
|
|
18
19
|
import { promisify } from 'util';
|
|
19
20
|
import { readFileSync } from 'fs';
|
|
@@ -25,6 +26,26 @@ import { readFileSync } from 'fs';
|
|
|
25
26
|
const execFileAsync = promisify(execFile);
|
|
26
27
|
|
|
27
28
|
const args = process.argv.slice(2);
|
|
29
|
+
function sanitizePathSegments(pathValue) {
|
|
30
|
+
return String(pathValue ?? '').split(/[\\/]+/).filter(Boolean).map((segment) => {
|
|
31
|
+
const sanitized = sanitizeFilename(segment);
|
|
32
|
+
if (sanitized !== segment || !sanitized) {
|
|
33
|
+
throw new Error(`Unsafe path segment: ${segment}`);
|
|
34
|
+
}
|
|
35
|
+
return sanitized;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function safeCliPath(pathValue, baseDir = process.cwd()) {
|
|
40
|
+
const root = resolve(baseDir);
|
|
41
|
+
const target = resolve(root, ...sanitizePathSegments(pathValue));
|
|
42
|
+
const rel = relative(root, target);
|
|
43
|
+
if (rel.startsWith('..') || isAbsolute(rel)) {
|
|
44
|
+
throw new Error(`Path escapes allowed directory: ${pathValue}`);
|
|
45
|
+
}
|
|
46
|
+
return target;
|
|
47
|
+
}
|
|
48
|
+
|
|
28
49
|
|
|
29
50
|
if (args.includes('--help') || args.includes('-h')) {
|
|
30
51
|
console.error(`Usage: cat urls.txt | node gate_candidates.mjs [options]
|
|
@@ -5,10 +5,31 @@
|
|
|
5
5
|
// Reads all {prefix}_discovery_batch_*.json files, deduplicates by domain,
|
|
6
6
|
// outputs one URL per line to stdout, stats to stderr.
|
|
7
7
|
|
|
8
|
+
import sanitizeFilename from 'sanitize-filename';
|
|
8
9
|
import { readdirSync, readFileSync } from 'fs';
|
|
9
|
-
import { join } from 'path';
|
|
10
|
+
import { isAbsolute, join, relative, resolve } from 'path';
|
|
10
11
|
|
|
11
12
|
const args = process.argv.slice(2);
|
|
13
|
+
function sanitizePathSegments(pathValue) {
|
|
14
|
+
return String(pathValue ?? '').split(/[\\/]+/).filter(Boolean).map((segment) => {
|
|
15
|
+
const sanitized = sanitizeFilename(segment);
|
|
16
|
+
if (sanitized !== segment || !sanitized) {
|
|
17
|
+
throw new Error(`Unsafe path segment: ${segment}`);
|
|
18
|
+
}
|
|
19
|
+
return sanitized;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function safeCliPath(pathValue, baseDir = process.cwd()) {
|
|
24
|
+
const root = resolve(baseDir);
|
|
25
|
+
const target = resolve(root, ...sanitizePathSegments(pathValue));
|
|
26
|
+
const rel = relative(root, target);
|
|
27
|
+
if (rel.startsWith('..') || isAbsolute(rel)) {
|
|
28
|
+
throw new Error(`Path escapes allowed directory: ${pathValue}`);
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
}
|
|
32
|
+
|
|
12
33
|
|
|
13
34
|
if (args.includes('--help') || args.includes('-h') || args.length === 0) {
|
|
14
35
|
console.error(`Usage: node list_urls.mjs <directory> [--prefix <prefix>]
|
|
@@ -26,7 +47,7 @@ Examples:
|
|
|
26
47
|
process.exit(args.includes('--help') || args.includes('-h') ? 0 : 1);
|
|
27
48
|
}
|
|
28
49
|
|
|
29
|
-
const dir = args[0];
|
|
50
|
+
const dir = safeCliPath(args[0]);
|
|
30
51
|
const prefixIdx = args.indexOf('--prefix');
|
|
31
52
|
const prefix = prefixIdx !== -1 && args[prefixIdx + 1] ? args[prefixIdx + 1] : 'competitor';
|
|
32
53
|
|
|
@@ -18,11 +18,32 @@
|
|
|
18
18
|
//
|
|
19
19
|
// Usage: node merge_partials.mjs <research-dir>
|
|
20
20
|
|
|
21
|
+
import sanitizeFilename from 'sanitize-filename';
|
|
21
22
|
import { readdirSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
22
|
-
import { join } from 'path';
|
|
23
|
+
import { isAbsolute, join, relative, resolve } from 'path';
|
|
23
24
|
import { parseFrontmatter, parseBody, parseSections } from './md_utils.mjs';
|
|
24
25
|
|
|
25
26
|
const args = process.argv.slice(2);
|
|
27
|
+
function sanitizePathSegments(pathValue) {
|
|
28
|
+
return String(pathValue ?? '').split(/[\\/]+/).filter(Boolean).map((segment) => {
|
|
29
|
+
const sanitized = sanitizeFilename(segment);
|
|
30
|
+
if (sanitized !== segment || !sanitized) {
|
|
31
|
+
throw new Error(`Unsafe path segment: ${segment}`);
|
|
32
|
+
}
|
|
33
|
+
return sanitized;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function safeCliPath(pathValue, baseDir = process.cwd()) {
|
|
38
|
+
const root = resolve(baseDir);
|
|
39
|
+
const target = resolve(root, ...sanitizePathSegments(pathValue));
|
|
40
|
+
const rel = relative(root, target);
|
|
41
|
+
if (rel.startsWith('..') || isAbsolute(rel)) {
|
|
42
|
+
throw new Error(`Path escapes allowed directory: ${pathValue}`);
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
|
|
26
47
|
if (args.includes('--help') || args.includes('-h') || args.length === 0) {
|
|
27
48
|
console.error(`Usage: node merge_partials.mjs <research-dir>
|
|
28
49
|
|
|
@@ -31,8 +52,8 @@ Reads {dir}/partials/{slug}.{lane}.md files and writes consolidated
|
|
|
31
52
|
process.exit(args.includes('--help') || args.includes('-h') ? 0 : 1);
|
|
32
53
|
}
|
|
33
54
|
|
|
34
|
-
const dir = args[0];
|
|
35
|
-
const partialsDir =
|
|
55
|
+
const dir = safeCliPath(args[0]);
|
|
56
|
+
const partialsDir = safeCliPath('partials', dir);
|
|
36
57
|
|
|
37
58
|
const LANES = ['marketing', 'discussion', 'social', 'news', 'technical', 'battle'];
|
|
38
59
|
|
|
@@ -451,7 +451,7 @@ docker run \
|
|
|
451
451
|
--security-opt no-new-privileges:true \ # Prevent privilege escalation via setuid
|
|
452
452
|
--security-opt seccomp=seccomp.json \ # Custom seccomp profile
|
|
453
453
|
--security-opt apparmor=docker-default \ # AppArmor profile
|
|
454
|
-
--pids-limit 100 \ # Prevent
|
|
454
|
+
--pids-limit 100 \ # Prevent runaway process spawning
|
|
455
455
|
--memory 512m \ # OOM protection
|
|
456
456
|
--memory-swap 512m \ # Disable swap
|
|
457
457
|
--cpus 1.0 \ # CPU limit
|
|
@@ -6,6 +6,20 @@ Brand Voice Analyzer - Analyzes content to establish and maintain brand voice co
|
|
|
6
6
|
import re
|
|
7
7
|
from typing import Dict, List, Tuple
|
|
8
8
|
import json
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def safe_user_path(path_value, base_dir="."):
|
|
13
|
+
"""Resolve a CLI path under the current workspace."""
|
|
14
|
+
if base_dir != ".":
|
|
15
|
+
raise ValueError("Custom base directories are not supported for CLI paths")
|
|
16
|
+
base_path = Path.cwd().resolve()
|
|
17
|
+
resolved_path = Path(path_value).expanduser().resolve()
|
|
18
|
+
try:
|
|
19
|
+
resolved_path.relative_to(base_path)
|
|
20
|
+
except ValueError as exc:
|
|
21
|
+
raise ValueError(f"Path escapes allowed directory: {path_value}") from exc
|
|
22
|
+
return resolved_path
|
|
9
23
|
|
|
10
24
|
class BrandVoiceAnalyzer:
|
|
11
25
|
def __init__(self):
|
|
@@ -176,7 +190,7 @@ if __name__ == "__main__":
|
|
|
176
190
|
import sys
|
|
177
191
|
|
|
178
192
|
if len(sys.argv) > 1:
|
|
179
|
-
with
|
|
193
|
+
with safe_user_path(sys.argv[1]).open('r') as f:
|
|
180
194
|
content = f.read()
|
|
181
195
|
|
|
182
196
|
output_format = sys.argv[2] if len(sys.argv) > 2 else 'text'
|
|
@@ -6,6 +6,20 @@ SEO Content Optimizer - Analyzes and optimizes content for SEO
|
|
|
6
6
|
import re
|
|
7
7
|
from typing import Dict, List, Set
|
|
8
8
|
import json
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def safe_user_path(path_value, base_dir="."):
|
|
13
|
+
"""Resolve a CLI path under the current workspace."""
|
|
14
|
+
if base_dir != ".":
|
|
15
|
+
raise ValueError("Custom base directories are not supported for CLI paths")
|
|
16
|
+
base_path = Path.cwd().resolve()
|
|
17
|
+
resolved_path = Path(path_value).expanduser().resolve()
|
|
18
|
+
try:
|
|
19
|
+
resolved_path.relative_to(base_path)
|
|
20
|
+
except ValueError as exc:
|
|
21
|
+
raise ValueError(f"Path escapes allowed directory: {path_value}") from exc
|
|
22
|
+
return resolved_path
|
|
9
23
|
|
|
10
24
|
class SEOOptimizer:
|
|
11
25
|
def __init__(self):
|
|
@@ -408,7 +422,7 @@ if __name__ == "__main__":
|
|
|
408
422
|
import sys
|
|
409
423
|
|
|
410
424
|
if len(sys.argv) > 1:
|
|
411
|
-
with
|
|
425
|
+
with safe_user_path(sys.argv[1]).open('r') as f:
|
|
412
426
|
content = f.read()
|
|
413
427
|
|
|
414
428
|
keyword = sys.argv[2] if len(sys.argv) > 2 else None
|