hoodscript 1.1.0__tar.gz

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.
Files changed (85) hide show
  1. hoodscript-1.1.0/.gitignore +13 -0
  2. hoodscript-1.1.0/CHANGELOG.md +183 -0
  3. hoodscript-1.1.0/CODE_OF_CONDUCT.md +69 -0
  4. hoodscript-1.1.0/CONTRIBUTING.md +122 -0
  5. hoodscript-1.1.0/LICENSE +3 -0
  6. hoodscript-1.1.0/PKG-INFO +183 -0
  7. hoodscript-1.1.0/README.md +145 -0
  8. hoodscript-1.1.0/SECURITY.md +101 -0
  9. hoodscript-1.1.0/SPRINT_PLAN.md +458 -0
  10. hoodscript-1.1.0/docs/adr/0001-token-pipeline-over-parser.md +40 -0
  11. hoodscript-1.1.0/docs/adr/0002-keyword-reconciliation.md +38 -0
  12. hoodscript-1.1.0/docs/adr/0003-inclusive-ranges.md +27 -0
  13. hoodscript-1.1.0/docs/adr/README.md +10 -0
  14. hoodscript-1.1.0/docs/archive/HOODSCRIPT_COMPLETE_MASTER_SYSTEM.md +76 -0
  15. hoodscript-1.1.0/docs/archive/HOODSCRIPT_FULL_ENGINEERING_SUITE.md +87 -0
  16. hoodscript-1.1.0/docs/archive/HOODSCRIPT_UNSPRED_FEATURES_ROADMAP.md +45 -0
  17. hoodscript-1.1.0/docs/curriculum.md +343 -0
  18. hoodscript-1.1.0/docs/keywords.md +81 -0
  19. hoodscript-1.1.0/docs/onboarding.md +235 -0
  20. hoodscript-1.1.0/out.txt +1 -0
  21. hoodscript-1.1.0/playground/app.js +482 -0
  22. hoodscript-1.1.0/playground/bundle.js +2 -0
  23. hoodscript-1.1.0/playground/examples.js +59 -0
  24. hoodscript-1.1.0/playground/hoodscript-latest-py3-none-any.whl +0 -0
  25. hoodscript-1.1.0/playground/index.html +92 -0
  26. hoodscript-1.1.0/playground/style.css +469 -0
  27. hoodscript-1.1.0/playground/worker.js +271 -0
  28. hoodscript-1.1.0/pyproject.toml +79 -0
  29. hoodscript-1.1.0/scripts/build_playground.py +108 -0
  30. hoodscript-1.1.0/scripts/gen_keywords.py +63 -0
  31. hoodscript-1.1.0/src/hoodscript/__init__.py +9 -0
  32. hoodscript-1.1.0/src/hoodscript/__main__.py +6 -0
  33. hoodscript-1.1.0/src/hoodscript/_version.py +24 -0
  34. hoodscript-1.1.0/src/hoodscript/cache.py +36 -0
  35. hoodscript-1.1.0/src/hoodscript/cli.py +468 -0
  36. hoodscript-1.1.0/src/hoodscript/constants.py +69 -0
  37. hoodscript-1.1.0/src/hoodscript/debugger.py +71 -0
  38. hoodscript-1.1.0/src/hoodscript/errors/__init__.py +12 -0
  39. hoodscript-1.1.0/src/hoodscript/errors/catalog.py +315 -0
  40. hoodscript-1.1.0/src/hoodscript/errors/renderer.py +85 -0
  41. hoodscript-1.1.0/src/hoodscript/errors/translator.py +207 -0
  42. hoodscript-1.1.0/src/hoodscript/formatter.py +78 -0
  43. hoodscript-1.1.0/src/hoodscript/importer.py +40 -0
  44. hoodscript-1.1.0/src/hoodscript/linter.py +253 -0
  45. hoodscript-1.1.0/src/hoodscript/lsp.py +253 -0
  46. hoodscript-1.1.0/src/hoodscript/migrator.py +31 -0
  47. hoodscript-1.1.0/src/hoodscript/patterns.py +442 -0
  48. hoodscript-1.1.0/src/hoodscript/repl.py +177 -0
  49. hoodscript-1.1.0/src/hoodscript/sandbox.py +215 -0
  50. hoodscript-1.1.0/src/hoodscript/stubs.py +16 -0
  51. hoodscript-1.1.0/src/hoodscript/traceback_handler.py +63 -0
  52. hoodscript-1.1.0/src/hoodscript/transpiler.py +46 -0
  53. hoodscript-1.1.0/src/hoodscript/tutor.py +232 -0
  54. hoodscript-1.1.0/tests/security/conftest.py +0 -0
  55. hoodscript-1.1.0/tests/security/corpus/deep_nesting.hs +1 -0
  56. hoodscript-1.1.0/tests/security/corpus/fork_bomb.hs +2 -0
  57. hoodscript-1.1.0/tests/security/corpus/huge_literal.hs +2 -0
  58. hoodscript-1.1.0/tests/security/corpus/import_escapes.hs +3 -0
  59. hoodscript-1.1.0/tests/security/corpus/infinite_recursion.hs +4 -0
  60. hoodscript-1.1.0/tests/security/corpus/open_file.hs +1 -0
  61. hoodscript-1.1.0/tests/security/corpus/pathological_indent.hs +4 -0
  62. hoodscript-1.1.0/tests/security/corpus/runaway_output.hs +2 -0
  63. hoodscript-1.1.0/tests/security/corpus/runaway_time.hs +2 -0
  64. hoodscript-1.1.0/tests/security/test_corpus.py +48 -0
  65. hoodscript-1.1.0/tests/security/test_exec_sites.py +16 -0
  66. hoodscript-1.1.0/tests/security/test_fuzz.py +111 -0
  67. hoodscript-1.1.0/tests/security/test_sandbox.py +96 -0
  68. hoodscript-1.1.0/tests/test_cli.py +100 -0
  69. hoodscript-1.1.0/tests/test_conformance.py +83 -0
  70. hoodscript-1.1.0/tests/test_debugger.py +71 -0
  71. hoodscript-1.1.0/tests/test_docs.py +66 -0
  72. hoodscript-1.1.0/tests/test_errors.py +128 -0
  73. hoodscript-1.1.0/tests/test_fmt.py +95 -0
  74. hoodscript-1.1.0/tests/test_grammar_canonical.py +19 -0
  75. hoodscript-1.1.0/tests/test_importer.py +11 -0
  76. hoodscript-1.1.0/tests/test_keywords_doc.py +10 -0
  77. hoodscript-1.1.0/tests/test_learn.py +47 -0
  78. hoodscript-1.1.0/tests/test_lint.py +90 -0
  79. hoodscript-1.1.0/tests/test_lsp_features.py +141 -0
  80. hoodscript-1.1.0/tests/test_patterns.py +114 -0
  81. hoodscript-1.1.0/tests/test_playground.py +232 -0
  82. hoodscript-1.1.0/tests/test_release.py +101 -0
  83. hoodscript-1.1.0/tests/test_repl.py +85 -0
  84. hoodscript-1.1.0/tests/test_transpiler.py +6 -0
  85. hoodscript-1.1.0/tests/test_vscode_extension.py +99 -0
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv/
5
+ *.egg-info/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .mypy_cache/
9
+ dist/
10
+ build/
11
+ node_modules/
12
+ *.vsix
13
+ src/hoodscript/_version.py
@@ -0,0 +1,183 @@
1
+ # Changelog
2
+
3
+ All notable changes to HoodScript. Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
+ Versioning: the keyword set is the public API; changing it is at least a minor bump.
5
+
6
+ ## [1.1.0] — 2026-09-11
7
+
8
+ The reconciled language. Every keyword is now either cited in
9
+ `hoodscript/docs/linguistics.md` or labeled plain English; the multi-token
10
+ grammar forms from `GRAMMAR.md` are implemented; every error is explained in
11
+ plain English.
12
+
13
+ ### Changed — keyword set (breaking)
14
+
15
+ Applied the signed `GRAMMAR.md` v1.1 (Sprints 1–2). The v1.0.0 words had
16
+ never been through the sourcing policy; on review most had no dictionary
17
+ attestation of AAVE origin.
18
+
19
+ | v1.0.0 | v1.1 | Reason |
20
+ |---|---|---|
21
+ | `cook` | `bet` | `cook`: attributed to one rapper, 2010 — fails the 2005 test. `bet`: M-W, AAE 1980s |
22
+ | `serve` | `dip` | `serve`: no attestation. `dip`: "to leave, in black slang, early 20th c." (Dictionary.com) |
23
+ | `crew` | `fam` | cut on re-verification in v1.0; `fam`: OED |
24
+ | `holler` | `holla` | attested spelling (Smitherman; Dictionary.com) |
25
+ | `Facts` / `Cap` | `no cap` / `cap` | `Facts` fails the 2005 test; `no cap` is the best-attested Tier B entry |
26
+ | `Ghost` | `None` | no attestation found |
27
+ | `mine` | `self` | plain English; Python's word |
28
+ | `say` / `or_say` / `otherwise` | `if` / `else if` / `else` | plain English; Python's words |
29
+ | `run_thru … up_in` | `be … in` | Tier A habitual *be* (YGDP) |
30
+ | `keep_goin_if Facts` | `steady:` | Tier A intensive continuative (YGDP) |
31
+ | `attempt` | `tryna` | Tier A |
32
+ | `aint` | `ain't` | Tier A, apostrophe restored |
33
+ | `on_the_side` / `hold_up` | `finna` / `done` | Tier A |
34
+ | `crash_out` `catch_heat` `stand_on_it` `rock_with` `cut` `whole_city` `outside_scope` `inspect` `scenario` `keep_pushin` `bring_in` `outta` `quick_cook` `pass_it` `and_also` `or_else` `straight_is` | Python's word | invented compounds; not slang, not AAVE, not dictionary words |
35
+ | `check_mic` `count_up` `span` `what_kind` `built_like` `word` `whole_num` `point_num` `lineup` `ledger` `circle` `locked_lineup` `unlock_file` `tally` `index_run` `pair_up` `every_single` `any_at_all` `weed_out` `apply_all` `ancestor` | Python's builtin | 21 English metaphors with no AAVE claim; every alias was a thing to learn |
36
+ | `GhostFileTrip` / `StandOnItTrip` | `MissingFileTrip` / `AssertTrip` | their roots were cut |
37
+
38
+ Kept: `chill` (`pass`, newly attested), `regardless`, `skip`, `catch`,
39
+ `throw`, `ask`, and the `*Trip` exception family (`trip`: single source,
40
+ kept by owner decision). Migration: `py2hood` on the `-c` output of an old
41
+ file produces the new spelling; the crash reporter suggests `holla` when it
42
+ sees `holler`.
43
+
44
+ ### Added
45
+
46
+ - **Pattern layer** (`src/hoodscript/patterns.py`, Sprint 3): the multi-token
47
+ forms `ain't` / `ain't nobody` → `not`, `no cap` → `True`, `it's x` →
48
+ `(x is not None)`, `steady:` → `while True:`, `BIN X = v` → `X: Final = v`,
49
+ inclusive ranges `a..b` → `range(a, b + 1)`, `else if` → `elif`, and
50
+ statement-form `holla x, y` / `ask x`. Implemented as text edits at token
51
+ positions so bytes outside a pattern and every line number are untouched.
52
+ - **JPE error engine** (`src/hoodscript/errors/`, Sprint 4): 35 catalogued
53
+ diagnostics `HS0001`–`HS0299`, each with what / why / fix in plain English
54
+ and a worked example the test suite executes. "Did you mean?" from the
55
+ names actually in scope (variables, attributes via `dir(obj)`, modules
56
+ including sibling `.hs` files, and the HoodScript keywords). Friendly type
57
+ names ("a whole number", not "a int"). SyntaxError messages re-worded in
58
+ HoodScript terms. Plain-text renderer always; `rich` panel on terminals
59
+ with the new `hoodscript[pretty]` extra. `--python-traceback` /
60
+ `HOODSCRIPT_PYTHON_TRACEBACK=1` escape hatch.
61
+ - **Security hardening & sandbox** (`src/hoodscript/sandbox.py`, `SECURITY.md`, Sprint 6):
62
+ Capability gates (`--sandbox` / `HOODSCRIPT_SANDBOX=1`) default-closed:
63
+ `--allow-fs` (gates `open()` and filesystem stdlib via `NoAccessTrip` / `HS0121`),
64
+ `--allow-net` (gates `socket`, `urllib`, `http` imports), and
65
+ `--allow-clock` (gates `time`, `datetime`). Hard resource budgets: recursion
66
+ ceiling (`--max-depth`, default 256), output volume cap (`--max-output`, default 1,000,000 bytes,
67
+ `BudgetTrip` / `HS0131`), and wall-clock timeout (`--max-seconds`, default 10s,
68
+ `BudgetTrip` / `HS0130`). Hostile corpus in `tests/security/corpus/` refused with
69
+ plain-English JPE diagnostics; 100k-iteration front-end fuzz test verified.
70
+ - **Developer tools suite & CLI tour** (`cli.py`, `repl.py`, `formatter.py`, `linter.py`, `tutor.py`, Sprint 7):
71
+ - CLI tour: Running `hoodscript` with no arguments prints a welcoming quick-start tour instead of an argparse dump.
72
+ - Subcommands: `run`, `build`, `check`, `fmt`, `lint`, `repl`, `tokens`, `learn`, `lsp`, `version`, `completion`.
73
+ - Formatter (`hoodscript fmt`): `hood2py` -> `ruff format` -> `py2hood`. Verified idempotent (`fmt(fmt(x)) == fmt(x)`) on the entire corpus and doc blocks.
74
+ - Linter (`hoodscript lint`): Plain-English diagnostics for unused variables (`HL001`), unreachable code (`HL002`), and type mismatches (`HL003` via `mypy`).
75
+ - Enhanced REPL (`hoodscript repl`): `--mirror` mode echoing Python line-by-line; persistent history (`~/.hoodscript_history`); multi-line continuation; tab autocompletion over keywords, builtins, and scope.
76
+ - Interactive tutor (`hoodscript learn`): Drives `docs/curriculum.md` lessons interactively across topics (`basics`, `flow`, `functions`, `classes`, `errors`, `async`, `mirror`, `all`).
77
+ - Shell completion: bash and zsh autocompletion scripts via `hoodscript completion [bash|zsh]`.
78
+ - **Editor & debugger integration** (`editors/vscode/`, `lsp.py`, `debugger.py`, Sprint 8):
79
+ - VS Code extension: Packaged `.vsix` (`hoodscript-1.0.0.vsix`) with TextMate grammar for v1.1 keywords and patterns, snippets for `bet`/`fam`/`tryna`/`be`/`steady`/`finna`/`holla`/`ask`/`BIN`, `.hs` and `.hood` file association, language configuration, icon, and README.
80
+ - LSP enhancements: Go-to-definition and document symbols via `jedi` on 1:1 transpiled Python; formatting provider via `src/hoodscript/formatter.py`; real-time linter diagnostics integrated from `src/hoodscript/linter.py` (`hoodlint`).
81
+ - DAP Debugger (`hoodscript debug` / `src/hoodscript/debugger.py`): Native debugging on `.hs` files with `debugpy` preserving 1:1 line numbers and breakpoint mapping; bundled `launch.json` template for F5 execution and attach.
82
+ - **Release packaging, dependency diet, and governance** (`pyproject.toml`, `CODE_OF_CONDUCT.md`, `.github/`, `docs/adr/`, Sprint 9):
83
+ - Zero required runtime dependencies: core package installs with `dependencies = []`. Dropped `pygments` and `libcst`. Extras partitioned into `[repl]`, `[lsp]`, `[pretty]`, and `[all]`.
84
+ - Dynamic versioning via `hatch-vcs` from git tag with `1.1.0` fallback; `hoodscript version` reports active release version.
85
+ - Governance: `CODE_OF_CONDUCT.md` adapted for linguistic respect and community safety; GitHub issue templates (bug report, feature request, and 7-step keyword proposal); PR checklist.
86
+ - Architecture Decision Records (`docs/adr/`): ADR-0001 (Token pipeline over parser), ADR-0002 (Linguistic sourcing & keyword reconciliation), ADR-0003 (Inclusive range syntax `a..b`).
87
+ - Release automation: `.github/workflows/release.yml` building and publishing to PyPI via Trusted Publishing on tag push.
88
+ - **Client-side Web Playground** (`playground/`, `scripts/build_playground.py`, `src/hoodscript/cli.py`, Sprint 10):
89
+ - Pure WebAssembly runtime running Pyodide in a dedicated background Web Worker, loading the pure-Python `hoodscript` wheel built in Sprint 9.
90
+ - Interactive split-pane UI: left `.hood` editor with line-sync gutter and 4-space tab indentation; right pane showing real-time debounced 1:1 transpilation to Python.
91
+ - In-page JPE error engine: renders styled crash report cards (`HS0001`–`HS0299`) with "What happened", "Why", "Try this", and expandable Python traceback.
92
+ - Curriculum gallery: preloaded with lessons 1–10 from `docs/curriculum.md` and the canonical spec program from `GRAMMAR.md`.
93
+ - Zero-backend architecture: URL permalinks via fragment hash (`#code=...`), "Share" button copying link to clipboard.
94
+ - Strict Content Security Policy (`script-src 'self' ... 'wasm-unsafe-eval'`), zero `eval()` in page JS.
95
+ - Sandbox & Tab Safety: In-browser execution runs under default-closed `Sandbox()` (FS, Net, Clock gated); main-thread watchdog timer terminates hung workers (e.g. `runaway_time.hs` infinite loops) after 5 seconds and renders `HS0130 BudgetTrip` without freezing the browser tab.
96
+ - CLI subcommand: `hoodscript playground [--port PORT] [--no-browser]` serves the playground locally and launches the default browser.
97
+ - `BadImportTrip` → `ImportError` in the `*Trip` family.
98
+ - LSP: diagnostics use the error catalog (code, span, what + fix); hover
99
+ covers the pattern forms.
100
+ - `docs/keywords.md`, generated from `constants.py` by
101
+ `scripts/gen_keywords.py`; a test fails if it is stale.
102
+ - `MANUAL.md` (17 chapters), `docs/onboarding.md`, `docs/curriculum.md`
103
+ (10 lessons) rewritten for v1.1. Every ```hood block in the docs is
104
+ executed by the test suite, and where the doc shows output, the output is
105
+ asserted verbatim (Sprint 5).
106
+ - `SPRINT_PLAN.md` reconciling six earlier planning documents; superseded
107
+ ones archived under `docs/archive/`.
108
+ - Playground published to GitHub Pages by `.github/workflows/pages.yml` on every
109
+ push that touches it or the package: https://khaoticdev62.github.io/hoodscript/
110
+ - `CHANGELOG.md`, `CONTRIBUTING.md`, `PROMPTS.md` v2 (agent prompt pack aligned with
111
+ the audited repo; replaces the v1.0.0 generation prompt whose lexicon was cut).
112
+ - CI on Ubuntu / macOS / Windows × Python 3.10–3.13, plus a build job.
113
+
114
+ ### QA audit of Sprints 6–10 (2026-09-11)
115
+
116
+ Sprints 6–10 landed as one batch and were audited end to end before being
117
+ accepted. Everything above is true *after* this pass; before it, twelve
118
+ defects were found and fixed:
119
+
120
+ - `hoodscript fmt` (and LSP formatting) rewrote `ain't` / `no cap` / `it's` /
121
+ `steady:` / `a..b` / `BIN` / `holla x` into Python and wrote it back. `py2hood`
122
+ now reverses every pattern form (`src/hoodscript/patterns.py::reverse_patterns`),
123
+ so `fmt` preserves the grammar and is idempotent on the full doc corpus.
124
+ One normalisation remains: `ain't nobody x` → `ain't x` (Python can't tell them apart).
125
+ - Playground: the sandbox started a `threading.Timer`, impossible under Pyodide,
126
+ and `worker.js` imported a `deactivate()` that did not exist — every run would
127
+ have failed. Thread-less hosts now fall back to the JS watchdog; `deactivate()`
128
+ exists; the worker redirects stdout *before* activating so the output cap
129
+ applies. Verified in headless Chrome: transpile, run, `HS0001` with suggestion
130
+ and frames, `HS0121` sandbox refusal, `HS0131` output cap.
131
+ - Wall-clock budget was a single catchable `KeyboardInterrupt`; a bare `catch:`
132
+ disabled it. Now two-stage: soft interrupt at the budget, hard `os._exit(3)`
133
+ with a report at budget + max(1 s, 20 %).
134
+ - `hoodscript lint`: HL002 mapped ruff's return-*style* rules (`RET50x`) to
135
+ "unreachable" and missed real unreachable code; now an exact `ast` check.
136
+ HL003 never fired (mypy needs `--check-untyped-defs`). With ruff absent it
137
+ printed "No issues found." — now a clear message and exit 2; new `[tools]` extra.
138
+ - `hoodscript learn` read `docs/curriculum.md` via the repo root — broken for
139
+ wheel installs; the curriculum now ships inside the package.
140
+ - REPL: builtin completion used `dir(__builtins__)` (a dict); a bracket-continued
141
+ header (`bet f(a,` ⏎ `b):`) ran after its first body line.
142
+ - Transpiler: NUL-byte location off by one; lone surrogates raised a raw
143
+ `UnicodeEncodeError`.
144
+ - Crash reports lost their frames when the program's file is a pseudo-file
145
+ (`<hood>`, `<repl>`) and `sys.executable` is empty (Pyodide).
146
+ - Debugger turned `exit()` into a crash report.
147
+ - `SECURITY.md` claimed two exec sites; there are four (`tests/security/test_exec_sites.py` guards the list).
148
+ - A local `v1.1.0` tag had been created on unaudited content; deleted. Tagging is a release decision.
149
+
150
+ ### Fixed
151
+
152
+ - Transpiler no longer rewrites attribute names: `fut.done()` survives
153
+ `done` being a keyword (previously `s.cut(1)` became `s.del(1)`).
154
+ - Running a file now puts its directory on `sys.path`, so `import sibling`
155
+ works from the `hoodscript` console script in any cwd.
156
+ - Crash reports drop launcher frames (runpy, console script), pick the most
157
+ specific `*Trip` name (a `SyntaxError` is `BadSyntaxTrip`, not `Problem`),
158
+ and show file:line for compile-time errors.
159
+ - REPL: one-line compound statements work; an error no longer ends the
160
+ session; `chill` exits as the banner says.
161
+ - Piped output on Windows is UTF-8, so reports aren't mangled.
162
+ - Three modules did not parse in the original 1.0.0 tree (newline escapes
163
+ had been expanded inside string literals); `migrator.py` lacked `import os`.
164
+ - Transpiler intercepts embedded null bytes (`\x00`) with a clean `SyntaxError`
165
+ to avoid CPython 3.13 tokenizer crash, and maps `tokenize.TokenError` and
166
+ `UnicodeDecodeError` to syntax errors for JPE catalog handling.
167
+
168
+ ### Removed
169
+
170
+ - `HOOD_BUILTINS` and builtin injection. The generated Python has no
171
+ HoodScript runtime in it at all.
172
+ - `HOODSCRIPT_SPEC.md` (described a different product); duplicate root
173
+ copies of the prototype's `MANUAL.md`, `PROMPTS.md`, `SPRINT_0.md`.
174
+
175
+ ## [1.0.0] — 2026-09-11
176
+
177
+ Initial release package: token-stream transpiler, PEP 451 import hook with
178
+ PEP 552 bytecode cache, CLI, REPL, crash reports with `*Trip` names,
179
+ `py2hood` / `hood2py`, stub generator, pygls language server (diagnostics,
180
+ hover, completion). Keyword set later found to be uncited — see v1.1.0.
181
+
182
+ [1.1.0]: https://github.com/khaoticdev62/hoodscript/compare/bf801ab...v1.1.0
183
+ [1.0.0]: https://github.com/khaoticdev62/hoodscript/commits/bf801ab
@@ -0,0 +1,69 @@
1
+ # HoodScript Community Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free and empowering experience for everyone, regardless of
7
+ age, body size, visible or invisible disability, ethnicity, sex characteristics,
8
+ gender identity and expression, level of experience, education, socio-economic
9
+ status, nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ HoodScript is built on African American Vernacular English (AAVE), a linguistic
13
+ system with deep history, systematic grammatical rules, and rich cultural
14
+ significance. We pledge to treat the language, its speakers, and the community
15
+ that created it with rigor, authenticity, and respect.
16
+
17
+ ## Our Standards
18
+
19
+ Examples of behavior that contributes to a positive environment for our
20
+ community include:
21
+
22
+ * Demonstrating empathy, kindness, and linguistic respect toward other people
23
+ * Respecting the 1:1 mapping law and grammatical sourcing standards of HoodScript
24
+ * Being respectful of differing opinions, viewpoints, and lived experiences
25
+ * Giving and gracefully accepting constructive feedback
26
+ * Accepting responsibility and apologizing to those affected by our mistakes,
27
+ and learning from the experience
28
+ * Focusing on what is best not just for us as individuals, but for the overall
29
+ community
30
+
31
+ Examples of unacceptable behavior include:
32
+
33
+ * The use of sexualized language or imagery, and sexual attention or advances
34
+ of any kind
35
+ * Trolling, insulting or derogatory comments, and personal or political attacks
36
+ * Mockery or trivialization of African American Vernacular English (AAVE) as
37
+ "broken English", "slang", or inferior grammar
38
+ * Public or private harassment
39
+ * Publishing others' private information, such as a physical or email address,
40
+ without their explicit permission
41
+ * Other conduct which could reasonably be considered inappropriate in a
42
+ professional setting
43
+
44
+ ## Enforcement Responsibilities
45
+
46
+ Community leaders are responsible for clarifying and enforcing our standards of
47
+ acceptable behavior and will take appropriate and fair corrective action in
48
+ response to any behavior that they deem inappropriate, threatening, offensive,
49
+ or harmful.
50
+
51
+ Community leaders have the right and responsibility to remove, edit, or reject
52
+ comments, commits, code, wiki edits, issues, and other contributions that are
53
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
54
+ decisions when appropriate.
55
+
56
+ ## Scope
57
+
58
+ This Code of Conduct applies within all project spaces (code repositories, issue
59
+ trackers, pull requests, discussion forums), and it also applies when an
60
+ individual is officially representing the project in public spaces.
61
+
62
+ ## Reporting and Attribution
63
+
64
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
65
+ reported to the project maintainers. All complaints will be reviewed and
66
+ investigated promptly and fairly.
67
+
68
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
69
+ version 2.1.
@@ -0,0 +1,122 @@
1
+ # Contributing to HoodScript
2
+
3
+ Three rules govern everything else. Read them first.
4
+
5
+ ## The three rules
6
+
7
+ ### 1. The 1:1 Law
8
+
9
+ > Every HoodScript construct maps to exactly one Python keyword, builtin, or
10
+ > `ast` node. If it cannot, it does not enter the language.
11
+
12
+ The implementation is a token rewrite (`src/hoodscript/transpiler.py`) plus a
13
+ small pattern layer for multi-token forms (`src/hoodscript/patterns.py`).
14
+ There is no parser, no intermediate representation, no template. **Line N of
15
+ the generated Python is line N of the source, always** — the crash reporter,
16
+ the language server, `linecache`, and every debugger rely on it. A change
17
+ that inserts or removes a line is a bug.
18
+
19
+ ### 2. Rule Zero
20
+
21
+ > Every keyword derives from a documented feature of AAVE — not from slang
22
+ > vocabulary, and not from another language. Every other word is Python's
23
+ > own, or plain English kept deliberately and labeled as such.
24
+
25
+ **No keyword ships without a citation.** To propose one, follow the seven
26
+ steps in [`hoodscript/docs/lexical-sourcing.md`](hoodscript/docs/lexical-sourcing.md) §5:
27
+ classify (Tier A grammar / Tier B lexical), source it (a Yale GDP page for
28
+ Tier A; two dictionaries stating AAVE origin for Tier B), grep CORAAL, run
29
+ the currency/liability screen (`hoodscript/scripts/screen_keyword.py`), name
30
+ the `ast` node, write the citation into
31
+ [`hoodscript/docs/linguistics.md`](hoodscript/docs/linguistics.md), then add
32
+ it to the table. Urban Dictionary is a screen, never a citation. A keyword
33
+ that fails any step doesn't ship — and the rejection is recorded, because the
34
+ cuts are the proof the policy works.
35
+
36
+ Write about AAVE the way a linguist does: a rule-governed variety with a
37
+ systematic grammar. Not "slang," not "broken English," no scare quotes.
38
+
39
+ ### 3. Never a raw traceback
40
+
41
+ > A Python traceback must never reach the user for a HoodScript-level problem.
42
+
43
+ Every error the system can produce has an entry in
44
+ [`src/hoodscript/errors/catalog.py`](src/hoodscript/errors/catalog.py) with a
45
+ stable code, a what / why / fix in plain English, and a worked example. The
46
+ test suite refuses an entry without a working example. Prose rules are in the
47
+ catalog's docstring: explain to a smart person who has never programmed,
48
+ never blame, never "invalid" or "illegal," gloss every term in the same
49
+ sentence. Read your message aloud; if it sounds like a compiler, rewrite it.
50
+
51
+ ## Setup
52
+
53
+ ```bash
54
+ git clone https://github.com/khaoticdev62/hoodscript && cd hoodscript
55
+ python3 -m venv .venv && source .venv/bin/activate
56
+ pip install -e ".[dev]"
57
+ ```
58
+
59
+ ## The gate
60
+
61
+ Before every push:
62
+
63
+ ```bash
64
+ ruff check && pytest
65
+ ```
66
+
67
+ That is exactly what CI runs, on Ubuntu, macOS, and Windows × Python
68
+ 3.10–3.13, plus a CLI smoke test. Python's exception *messages* differ between
69
+ versions (`was never closed` vs `EOF in multi-line statement`), so a catalog
70
+ pattern that passes locally can fail on another version — let the matrix
71
+ tell you.
72
+
73
+ ## Where things live
74
+
75
+ | Change | Where | Test that guards it |
76
+ |---|---|---|
77
+ | A single-word keyword | `src/hoodscript/constants.py` (after the sourcing procedure) | `tests/test_conformance.py` — add a case; `docs/keywords.md` must be regenerated (`scripts/gen_keywords.py > docs/keywords.md`) |
78
+ | A multi-token form | `src/hoodscript/patterns.py` + a rule row in `GRAMMAR.md` | `tests/test_patterns.py`; `tests/test_grammar_canonical.py` holds the canonical program byte for byte |
79
+ | An error explanation | `src/hoodscript/errors/catalog.py` | `tests/test_errors.py` runs every entry's example three ways |
80
+ | A doc example | `README.md`, `MANUAL.md`, `docs/*.md` | `tests/test_docs.py` runs every ```hood block and asserts the documented output |
81
+ | The CLI / REPL / LSP | `src/hoodscript/cli.py`, `repl.py`, `lsp.py` | CI smoke test; add to `tests/` |
82
+
83
+ The `hoodscript/` subdirectory is the frozen Sprint 0–1 prototype: its
84
+ linguistic research and sourcing policy are authoritative, its code is not.
85
+ Don't build there.
86
+
87
+ ## Docs are tests
88
+
89
+ Any ` ```hood ` block in the user docs is executed. If the next untagged
90
+ code block in the same section shows output, that output is compared
91
+ verbatim. Mark a block that is *supposed* to crash with `# expect-crash` as
92
+ its first line. Show forms that don't run yet in a ` ```text ` fence, never
93
+ ` ```hood `.
94
+
95
+ ## Style
96
+
97
+ - Dense is fine. The codebase uses one-line `def`s and `if x: y` where it
98
+ reads well; `E701`/`E702` are off deliberately. Line length 120.
99
+ - Complete files. Never `# ... rest unchanged`.
100
+ - Preserve comments, docstrings, and license notices.
101
+ - Match the surrounding voice in docs: direct, second person, no hedging.
102
+
103
+ ## Commits and sprints
104
+
105
+ Work follows [`SPRINT_PLAN.md`](SPRINT_PLAN.md), one sprint at a time, each
106
+ with a gate. Commit at the gate with a message that says what changed and
107
+ why; the changelog is written from those messages. Update `CLAUDE.md` when a
108
+ decision changes — stale context is worse than none.
109
+
110
+ ## Working with an AI agent
111
+
112
+ Paste the standing brief from [`PROMPTS.md`](PROMPTS.md) §0 at the top of
113
+ the prompt and use the task template that matches the change. Never give an
114
+ agent the v1.0.0 lexicon (`cook`, `serve`, …) or ask for `libcst`; both were
115
+ cut deliberately and the tests will fail.
116
+
117
+ ## Reporting a bug
118
+
119
+ The crash report's code (`HS0001`) plus the output of
120
+ `hoodscript --python-traceback file.hs` is the ideal report. If you hit
121
+ `HS9999` ("I don't have a plain-English explanation for this yet"), that's a
122
+ catalog gap — please file it with the program that produced it.
@@ -0,0 +1,3 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HoodScript Core Contributors
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.5
2
+ Name: hoodscript
3
+ Version: 1.1.0
4
+ Summary: A production-grade Python 3 conlang based on AAVE with 1:1 AST parity.
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Provides-Extra: all
9
+ Requires-Dist: jedi>=0.19.1; extra == 'all'
10
+ Requires-Dist: mypy>=1.9.0; extra == 'all'
11
+ Requires-Dist: prompt-toolkit>=3.0.40; extra == 'all'
12
+ Requires-Dist: pygls<2,>=1.3.1; extra == 'all'
13
+ Requires-Dist: rich>=13.7; extra == 'all'
14
+ Requires-Dist: ruff>=0.3.0; extra == 'all'
15
+ Provides-Extra: dev
16
+ Requires-Dist: build>=1.1.0; extra == 'dev'
17
+ Requires-Dist: debugpy>=1.8.0; extra == 'dev'
18
+ Requires-Dist: hatch-vcs>=0.4.0; extra == 'dev'
19
+ Requires-Dist: jedi>=0.19.1; extra == 'dev'
20
+ Requires-Dist: mypy>=1.9.0; extra == 'dev'
21
+ Requires-Dist: prompt-toolkit>=3.0.40; extra == 'dev'
22
+ Requires-Dist: pygls<2,>=1.3.1; extra == 'dev'
23
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
24
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
25
+ Requires-Dist: rich>=13.7; extra == 'dev'
26
+ Requires-Dist: ruff>=0.3.0; extra == 'dev'
27
+ Provides-Extra: lsp
28
+ Requires-Dist: jedi>=0.19.1; extra == 'lsp'
29
+ Requires-Dist: pygls<2,>=1.3.1; extra == 'lsp'
30
+ Provides-Extra: pretty
31
+ Requires-Dist: rich>=13.7; extra == 'pretty'
32
+ Provides-Extra: repl
33
+ Requires-Dist: prompt-toolkit>=3.0.40; extra == 'repl'
34
+ Provides-Extra: tools
35
+ Requires-Dist: mypy>=1.9.0; extra == 'tools'
36
+ Requires-Dist: ruff>=0.3.0; extra == 'tools'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # HoodScript
40
+
41
+ A Python 3 dialect whose grammar keywords come from documented features of
42
+ African American Vernacular English, with **strict 1:1 mapping to Python** and
43
+ **crash reports written in plain English**.
44
+
45
+ ```hood
46
+ bet greet(who, greeting="wassup"):
47
+ dip greeting + ", " + who
48
+
49
+ fam Dog:
50
+ bet __init__(self, name):
51
+ self.name = name
52
+ bet speak(self):
53
+ dip self.name + " says woof"
54
+
55
+ be i in 1..3:
56
+ holla greet("fam"), Dog("Rex").speak(), i
57
+ ```
58
+
59
+ Every keyword is one Python keyword under a different name. `bet` *is* `def`.
60
+ `dip` *is* `return`. `be` *is* `for`. Nothing is added, nothing is
61
+ reinterpreted. That means:
62
+
63
+ - `.hs` files can import any Python package (`numpy`, `fastapi`, `json`, …)
64
+ - Python files can import `.hs` modules after one line: `hoodscript.install()`
65
+ - Type checkers, linters, profilers, and debuggers all work on the output
66
+ - `hood2py` gives you back plain Python whenever you want to leave
67
+
68
+ **Every keyword is cited.** Tier A grammar words (`be`, `finna`, `done`,
69
+ `tryna`) each have a Yale Grammatical Diversity Project page. Tier B lexical
70
+ words (`bet`, `fam`, `holla`, `dip`, `chill`, `cap`) each have dictionary
71
+ attestation of AAVE origin. The rest is Python's own word or plain English,
72
+ labeled as such. Sources: [`hoodscript/docs/linguistics.md`](hoodscript/docs/linguistics.md).
73
+ Spec: [`GRAMMAR.md`](GRAMMAR.md). Full table: [`docs/keywords.md`](docs/keywords.md).
74
+
75
+ ## Try it in the browser
76
+
77
+ **[khaoticdev62.github.io/hoodscript](https://khaoticdev62.github.io/hoodscript/)** —
78
+ HoodScript on the left, the exact Python on the right, live. Runs entirely in
79
+ your browser (Pyodide); nothing is sent anywhere. Programs run inside the
80
+ sandbox, so `import os` is refused and a runaway loop is stopped.
81
+
82
+ ## Install
83
+
84
+ ```bash
85
+ git clone https://github.com/khaoticdev62/hoodscript && cd hoodscript
86
+ python3 -m venv .venv && source .venv/bin/activate
87
+ pip install -e ".[dev]"
88
+ ```
89
+
90
+ Requires Python ≥ 3.10. To try it with **no install at all**, prefix commands
91
+ with `PYTHONPATH=src` and use `python3 -m hoodscript` instead of `hoodscript`.
92
+
93
+ ## Run
94
+
95
+ ```bash
96
+ hoodscript hello.hs # transpile + execute
97
+ hoodscript -c hello.hs # print the Python it becomes
98
+ hoodscript repl --mirror # interactive REPL (hood> prompt; chill to exit; --mirror shows the Python)
99
+ hoodscript fmt|lint <file.hs> # formatter / linter (pip install "hoodscript[tools]")
100
+ hoodscript learn [topic] # interactive tutor driving docs/curriculum.md
101
+ hoodscript # a short tour of all commands
102
+ hoodscript lsp # language server over stdio, for editors
103
+ hoodscript make-stubs f.py # emit a .pyi-style stub with empty bodies
104
+ ```
105
+
106
+ ## Convert
107
+
108
+ ```bash
109
+ hood2py program.hs > program.py # HoodScript → Python
110
+ py2hood program.py > program.hs # Python → HoodScript
111
+ ```
112
+
113
+ Both are token-level rewrites: comments, spacing, and line numbers survive
114
+ round-trips untouched.
115
+
116
+ ## Crash reports
117
+
118
+ Unhandled exceptions never show a raw Python traceback. Every error is
119
+ translated into plain English — what happened, why, and what to do — with a
120
+ "did you mean?" computed from what was actually in scope:
121
+
122
+ ```
123
+ 🚨 HOODSCRIPT CRASH REPORT — HS0001 UnknownNameTrip
124
+
125
+ File "boom.hs", line 4, in <module>()
126
+ main()
127
+ File "boom.hs", line 3, in main()
128
+ holla totl
129
+ ^^^^
130
+
131
+ What happened: I can't find anything called 'totl'.
132
+ Why: Nothing gave 'totl' a value before line 3, or it was spelled differently when it was created.
133
+ Fix: Did you mean 'total'? If not, set it first: `totl = ...` above this line.
134
+
135
+ (run with --python-traceback to see the raw Python error)
136
+ ```
137
+
138
+ Thirty-five catalogued diagnostics (`HS0001`–`HS0299`), each with a worked
139
+ example that the test suite executes. `pip install "hoodscript[pretty]"` adds
140
+ colour and a box on terminals. `--python-traceback` shows the raw Python when
141
+ you're debugging the compiler rather than a program.
142
+
143
+ ## The language in one screen
144
+
145
+ | Python | HoodScript | | Python | HoodScript |
146
+ |---|---|---|---|---|
147
+ | `def` / `return` | `bet` / `dip` | | `try` / `except` / `finally` | `tryna` / `catch` / `regardless` |
148
+ | `class` | `fam` | | `raise` | `throw` |
149
+ | `for` | `be` | | `continue` / `pass` | `skip` / `chill` |
150
+ | `async` / `await` | `finna` / `done` | | `False` | `cap` |
151
+ | `print` / `input` | `holla` / `ask` | | `ValueError`, `KeyError`, … | `BadValueTrip`, `MissingKeyTrip`, … |
152
+ | `True` | `no cap` | | `not` | `ain't` / `ain't nobody` |
153
+ | `while True:` | `steady:` | | `x is not None` | `it's x` |
154
+ | `X: Final = v` | `BIN X = v` | | `range(a, b + 1)` | `a..b` |
155
+ | `elif` | `else if` | | | |
156
+
157
+ Everything else — `if`, `else`, `while`, `import`, `with`, `match`, `None`,
158
+ `self`, every builtin — is Python's own word, and every Python keyword still
159
+ works in a `.hs` file.
160
+
161
+ ## Learn
162
+
163
+ - [`docs/onboarding.md`](docs/onboarding.md) — from zero to a running program in ten minutes
164
+ - [`docs/curriculum.md`](docs/curriculum.md) — ten lessons, each with a runnable file
165
+ - [`MANUAL.md`](MANUAL.md) — the full manual
166
+ - [`agents.md`](agents.md) — architecture and subsystem walkthrough
167
+ - [`CLAUDE.md`](CLAUDE.md) — the standing brief for anyone (human or agent) changing the code
168
+ - [`SPRINT_PLAN.md`](SPRINT_PLAN.md) — what's next · [`CHANGELOG.md`](CHANGELOG.md) · [`CONTRIBUTING.md`](CONTRIBUTING.md)
169
+
170
+ ## Repo layout
171
+
172
+ ```
173
+ src/hoodscript/ the package (transpiler, importer, cache, CLI, REPL, LSP, migrator)
174
+ tests/ pytest suite — includes one conformance test per keyword and one run per doc example
175
+ docs/ onboarding, curriculum, generated keyword table, archived plans
176
+ scripts/ gen_keywords.py
177
+ editors/vscode/ extension manifest
178
+ hoodscript/ Sprint 0–1 prototype: linguistic research, sourcing policy, v1.0 grammar — reference only
179
+ ```
180
+
181
+ ## License
182
+
183
+ MIT — see [LICENSE](LICENSE).