ahafrog 0.2.0__py3-none-any.whl

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 (48) hide show
  1. ahafrog/__init__.py +3 -0
  2. ahafrog/cli.py +66 -0
  3. ahafrog/engine/engine.js +709 -0
  4. ahafrog/engine/minigames/simulation.js +263 -0
  5. ahafrog/engine/pixelpack.js +393 -0
  6. ahafrog/engine/player.html +285 -0
  7. ahafrog/engine/shell-stage.html +54 -0
  8. ahafrog/engine/shell.css +316 -0
  9. ahafrog/engine/shell.js +166 -0
  10. ahafrog/engine/template.html +412 -0
  11. ahafrog/generator/__init__.py +1 -0
  12. ahafrog/generator/api.py +282 -0
  13. ahafrog/generator/assembler.py +1583 -0
  14. ahafrog/generator/cancel.py +66 -0
  15. ahafrog/generator/course_assembler.py +566 -0
  16. ahafrog/generator/course_pipeline.py +336 -0
  17. ahafrog/generator/documents.py +368 -0
  18. ahafrog/generator/i18n.py +1064 -0
  19. ahafrog/generator/package_builder.py +161 -0
  20. ahafrog/generator/pipeline.py +2716 -0
  21. ahafrog/generator/prompts.py +2287 -0
  22. ahafrog/generator/sandbox.py +278 -0
  23. ahafrog/generator/sandbox_harness.js +653 -0
  24. ahafrog/generator/structure.py +443 -0
  25. ahafrog/generator/theme_light.py +189 -0
  26. ahafrog/node/engine-state.js +46 -0
  27. ahafrog/node/package.json +13 -0
  28. ahafrog/node/server.js +91 -0
  29. ahafrog/server.py +1326 -0
  30. ahafrog/static/ahafrog.png +0 -0
  31. ahafrog/static/frog/aha.json +1 -0
  32. ahafrog/static/frog/crying.json +1 -0
  33. ahafrog/static/frog/excited.json +1 -0
  34. ahafrog/static/frog/happy.json +1 -0
  35. ahafrog/static/frog/idle.json +1 -0
  36. ahafrog/static/frog/sad.json +1 -0
  37. ahafrog/static/frog/walk_left.json +1 -0
  38. ahafrog/static/frog/walk_right.json +1 -0
  39. ahafrog/static/index.html +469 -0
  40. ahafrog/static/studio.html +2065 -0
  41. ahafrog/static/vendor/lottie_light.min.js +4 -0
  42. ahafrog-0.2.0.dist-info/METADATA +86 -0
  43. ahafrog-0.2.0.dist-info/RECORD +48 -0
  44. ahafrog-0.2.0.dist-info/WHEEL +5 -0
  45. ahafrog-0.2.0.dist-info/entry_points.txt +2 -0
  46. ahafrog-0.2.0.dist-info/licenses/LICENSE +661 -0
  47. ahafrog-0.2.0.dist-info/licenses/LICENSE-AGPL-3.0 +673 -0
  48. ahafrog-0.2.0.dist-info/top_level.txt +1 -0
ahafrog/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ # AhaFrog — AI Game-Based Learning Studio (https://github.com/yh2072/ahafrog)
2
+
3
+ __version__ = "0.1.1"
ahafrog/cli.py ADDED
@@ -0,0 +1,66 @@
1
+ # -- Created by Yuqi Hang (github.com/yh2072) --
2
+ """`ahafrog` — start the Studio.
3
+
4
+ Installing the package used to leave you holding
5
+ `uvicorn ahafrog.server:app --host 127.0.0.1 --port 8000`, which is a lot to
6
+ remember for "run the thing I just installed", and easy to get subtly wrong
7
+ (bind the wrong interface, forget the module path). This is that line, with
8
+ the defaults already chosen.
9
+
10
+ The server loads .env from the working directory on import, and starts the
11
+ bundled Node engine itself, so there is nothing to arrange here beyond
12
+ picking the address and saying where to look.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import argparse
18
+ import sys
19
+ import threading
20
+ import webbrowser
21
+
22
+
23
+ def main(argv: list[str] | None = None) -> int:
24
+ parser = argparse.ArgumentParser(
25
+ prog="ahafrog",
26
+ description="Turn learning material into playable browser mini-games.",
27
+ )
28
+ parser.add_argument("--host", default="127.0.0.1",
29
+ help="interface to bind (default: 127.0.0.1, local only)")
30
+ parser.add_argument("--port", type=int, default=8000, help="port (default: 8000)")
31
+ parser.add_argument("--no-open", action="store_true",
32
+ help="do not open a browser")
33
+ parser.add_argument("--reload", action="store_true",
34
+ help="reload on code changes (for development)")
35
+ parser.add_argument("--version", action="store_true", help="print the version and exit")
36
+ args = parser.parse_args(argv)
37
+
38
+ if args.version:
39
+ try:
40
+ from importlib.metadata import version
41
+ print(version("ahafrog"))
42
+ except Exception:
43
+ print("unknown")
44
+ return 0
45
+
46
+ try:
47
+ import uvicorn
48
+ except ImportError:
49
+ print("uvicorn is missing — reinstall with: pip install -U ahafrog", file=sys.stderr)
50
+ return 1
51
+
52
+ url = f"http://{'localhost' if args.host in ('127.0.0.1', '0.0.0.0') else args.host}:{args.port}/"
53
+ print(f"\n AhaFrog Studio → {url}\n")
54
+
55
+ if not args.no_open:
56
+ # After uvicorn is listening, not before, or the first load 404s on a
57
+ # socket that is not up yet. A daemon thread so Ctrl-C still exits.
58
+ threading.Timer(1.5, lambda: webbrowser.open(url)).start()
59
+
60
+ uvicorn.run("ahafrog.server:app", host=args.host, port=args.port,
61
+ reload=args.reload, log_level="info")
62
+ return 0
63
+
64
+
65
+ if __name__ == "__main__":
66
+ raise SystemExit(main())