python-tty 0.1.4__tar.gz → 0.1.6__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 (82) hide show
  1. {python_tty-0.1.4/src/python_tty.egg-info → python_tty-0.1.6}/PKG-INFO +5 -1
  2. {python_tty-0.1.4 → python_tty-0.1.6}/docs/LOG.md +69 -2
  3. {python_tty-0.1.4 → python_tty-0.1.6}/docs/context.md +934 -164
  4. {python_tty-0.1.4 → python_tty-0.1.6}/setup.py +4 -0
  5. python_tty-0.1.6/src/python_tty/__init__.py +25 -0
  6. python_tty-0.1.6/src/python_tty/audit/__init__.py +7 -0
  7. python_tty-0.1.6/src/python_tty/audit/sink.py +141 -0
  8. {python_tty-0.1.4/src/python_tty/utils → python_tty-0.1.6/src/python_tty/audit}/ui_logger.py +3 -4
  9. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/examples/root_commands.py +2 -3
  10. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/mixins.py +4 -5
  11. python_tty-0.1.6/src/python_tty/config/__init__.py +16 -0
  12. python_tty-0.1.6/src/python_tty/config/config.py +92 -0
  13. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/console_factory.py +52 -3
  14. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/core.py +3 -4
  15. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/manager.py +5 -5
  16. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/registry.py +33 -0
  17. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/executor/executor.py +91 -17
  18. python_tty-0.1.6/src/python_tty/meta/__init__.py +96 -0
  19. python_tty-0.1.6/src/python_tty/runtime/__init__.py +29 -0
  20. python_tty-0.1.6/src/python_tty/runtime/events.py +147 -0
  21. python_tty-0.1.6/src/python_tty/runtime/provider.py +62 -0
  22. python_tty-0.1.4/src/python_tty/ui/output.py → python_tty-0.1.6/src/python_tty/runtime/router.py +53 -11
  23. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/utils/__init__.py +1 -3
  24. {python_tty-0.1.4 → python_tty-0.1.6/src/python_tty.egg-info}/PKG-INFO +5 -1
  25. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty.egg-info/SOURCES.txt +9 -4
  26. python_tty-0.1.6/src/python_tty.egg-info/requires.txt +6 -0
  27. python_tty-0.1.6/tests/__init__.py +0 -0
  28. python_tty-0.1.4/src/python_tty/__init__.py +0 -15
  29. python_tty-0.1.4/src/python_tty/config/__init__.py +0 -9
  30. python_tty-0.1.4/src/python_tty/config/config.py +0 -37
  31. python_tty-0.1.4/src/python_tty/ui/__init__.py +0 -13
  32. python_tty-0.1.4/src/python_tty/ui/events.py +0 -55
  33. python_tty-0.1.4/src/python_tty.egg-info/requires.txt +0 -2
  34. {python_tty-0.1.4 → python_tty-0.1.6}/.github/workflows/python-publish.yml +0 -0
  35. {python_tty-0.1.4 → python_tty-0.1.6}/.gitignore +0 -0
  36. {python_tty-0.1.4 → python_tty-0.1.6}/LICENSE +0 -0
  37. {python_tty-0.1.4 → python_tty-0.1.6}/MANIFEST.in +0 -0
  38. {python_tty-0.1.4 → python_tty-0.1.6}/NOTICE +0 -0
  39. {python_tty-0.1.4 → python_tty-0.1.6}/README.md +0 -0
  40. {python_tty-0.1.4 → python_tty-0.1.6}/README_zh.md +0 -0
  41. {python_tty-0.1.4 → python_tty-0.1.6}/demos/__init__.py +0 -0
  42. {python_tty-0.1.4 → python_tty-0.1.6}/demos/chat_room/__init__.py +0 -0
  43. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/__init__.py +0 -0
  44. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/commands/__init__.py +0 -0
  45. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/commands/root_commands.py +0 -0
  46. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/consoles/__init__.py +0 -0
  47. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/consoles/root.py +0 -0
  48. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/core/__init__.py +0 -0
  49. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/core/file_manager.py +0 -0
  50. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/exceptions/__init__.py +0 -0
  51. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/exceptions/console_exception.py +0 -0
  52. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/main.py +0 -0
  53. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/setup.py +0 -0
  54. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/utils/__init__.py +0 -0
  55. {python_tty-0.1.4 → python_tty-0.1.6}/demos/file_manager/utils/table.py +0 -0
  56. {python_tty-0.1.4 → python_tty-0.1.6}/pyproject.toml +0 -0
  57. {python_tty-0.1.4 → python_tty-0.1.6}/requirements.txt +0 -0
  58. {python_tty-0.1.4 → python_tty-0.1.6}/setup.cfg +0 -0
  59. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/__init__.py +0 -0
  60. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/core.py +0 -0
  61. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/decorators.py +0 -0
  62. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/examples/__init__.py +0 -0
  63. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/examples/sub_commands.py +0 -0
  64. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/general.py +0 -0
  65. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/commands/registry.py +0 -0
  66. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/__init__.py +0 -0
  67. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/decorators.py +0 -0
  68. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/examples/__init__.py +0 -0
  69. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/examples/root_console.py +0 -0
  70. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/examples/sub_console.py +0 -0
  71. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/consoles/loader.py +0 -0
  72. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/exceptions/__init__.py +0 -0
  73. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/exceptions/console_exception.py +0 -0
  74. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/executor/__init__.py +0 -0
  75. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/executor/models.py +0 -0
  76. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/frontends/__init__.py +0 -0
  77. {python_tty-0.1.4/src/python_tty/meta → python_tty-0.1.6/src/python_tty/frontends/rpc}/__init__.py +0 -0
  78. {python_tty-0.1.4/tests → python_tty-0.1.6/src/python_tty/frontends/web}/__init__.py +0 -0
  79. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/utils/table.py +0 -0
  80. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty/utils/tokenize.py +0 -0
  81. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty.egg-info/dependency_links.txt +0 -0
  82. {python_tty-0.1.4 → python_tty-0.1.6}/src/python_tty.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-tty
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: A multi-console TTY framework for complex CLI/TTY apps
5
5
  Home-page: https://github.com/ROOKIEMIE/python-tty
6
6
  Author: ROOKIEMIE
@@ -12,8 +12,12 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  License-File: NOTICE
15
+ Requires-Dist: fastapi>=0.110.0
16
+ Requires-Dist: grpcio>=1.60.0
15
17
  Requires-Dist: prompt_toolkit>=3.0.32
18
+ Requires-Dist: protobuf>=4.25.0
16
19
  Requires-Dist: tqdm
20
+ Requires-Dist: uvicorn>=0.27.0
17
21
  Dynamic: author
18
22
  Dynamic: classifier
19
23
  Dynamic: description
@@ -1,5 +1,74 @@
1
1
  # 阶段记录
2
2
 
3
+ ## 2026/01/27/02
4
+
5
+ 1. rpc侧应该模仿console/core模块中execute和run方法的实现,重新构建invocation并投递至executor,source为rpc。不要复用现有console的submit过程,应该形成一条独立的submit过程。
6
+ 2. 新增runtime.proto。
7
+ 3. 新增grpc aio server,协程模式。
8
+
9
+ ## 2026/01/27/01
10
+
11
+ 目标:
12
+ 1. 把框架的整体结构并发式地跑起来:
13
+ 一个进程,两类 event loop:
14
+ - 主线程:一个 asyncio loop
15
+ - FastAPI(Meta API:HTTP + WS)
16
+ - gRPC aio server(Invoke + StreamEvents)
17
+ - CommandExecutor(作为“唯一运行时入口”,最好也在这个 loop 上)
18
+ - TTY 线程:一个独立线程
19
+ - prompt_toolkit 的 PromptSession/应用运行(它内部也会用 asyncio,但你可以在这个线程里创建自己的 loop 或让 prompt_toolkit 管理)
20
+ - TTY 发起命令:通过 submit_threadsafe() 把 invocation 投递到主线程 executor loop
21
+ - 输出:OutputRouter 把事件安全地写回 TTY(run_in_terminal / patch_stdout 等)
22
+ 2. 原始的V2开发规划:
23
+ - Step 0:把 Executor 插进去(让命令可后台执行)
24
+ - 把 BaseConsole.execute 改成 submit invocation
25
+ - TTY 调用也走 executor
26
+ - 先用同步等待结果也行,但建议至少把执行从 console loop 中剥离
27
+ - Step 1:定义 Invocation / Run / Event 三个核心数据结构
28
+ - 这是 Web/RPC/TTY 共用的“运行时协议”
29
+ - 有了它,Meta/RPC 都只是“外壳”
30
+ - Step 2:Meta Descriptor v1(argv-only)
31
+ - 从 registry 导出 consoles/commands/argspec(min/max)
32
+ - revision hash
33
+ - Step 3:RPC proto v1(Invoke + StreamEvents)
34
+ - 先走通 unary invoke + server streaming 事件
35
+ - Step 4:Meta HTTP/WS server(只读)
36
+ - /meta + ws snapshot
37
+ - ETag 缓存
38
+ - Step 5:把 allowlist + audit + mTLS 完整接入 RPC
39
+ - RPC 默认 deny
40
+ - 命令必须显式 exposure.rpc=true 才可调用
41
+ - audit 强制落盘
42
+
43
+ 下一步规划:
44
+ 1. RPC proto + aio server:直接复用你现有 Invocation/RunState/RuntimeEvent,把 RuntimeEvent 流映射为 gRPC server streaming。
45
+ 2. Meta HTTP/WS:GET /meta 返回 export_meta(),ETag = revision(你已算出 revision)。WS snapshot 可先做“连接后推一次 meta+revision”,后续再做增量。
46
+ 3. Web实现位于frontends/web,RPC实现位于frontends/rpc;根据需要可以进一步增加子包。
47
+
48
+ ## 2026/01/26/02
49
+
50
+ 1. 修改了OutputRouter的emit,使之可以输出STATE。
51
+ 2. 就目前的实现来说“全量输出审计”仅针对executor生效,对于proxy_print以及ConsoleHandler暂不生效;需要为OutputRouter增加一个attach_audit_sink方法,从而允许在factory中将auditsink注入其中,任何地方只要走 OutputRouter,就会被审计(如果开启)。
52
+ 3. 为ConsoleRegistry 增加公开读取 API(例如 iter_consoles() / get_root() / get_subs()),meta 不要直接获取私有成员;meta v1 就带上 ConsoleManager 里已经维护了的 tree: {root, children} 或在 console entry 上带 children: [],之后外部系统生成 UI/适配更简单。
53
+
54
+ ## 2026/01/26/01
55
+
56
+ 1. 为UIEvent补充三个字段
57
+ - source: "tty" | "rpc" | "framework" | "service"(输入源:框架tty、rpc、使用者custom调用输出)
58
+ - ts/seq: 时间戳/序号(用于审计与重放顺序稳定)
59
+ 2. 增加一个类AuditSink,用以实现“Invocation + RunState + Events”落盘,audit的完整传递路径为:Executor 发出 state/log/stdout 事件 → OutputRouter 渲染其中 stdout/log → AuditSink 把“Invocation + RunState + Events”落盘。目前utils包中的ui_logger模块似乎并没有使用,我认为是使用增加一个包,叫做audit,然后将这个模块移至audit包下重命名并重构其中的实现,以满足这里对于audit落盘的需要。
60
+ 3. 把框架的整体结构并发式地跑起来:
61
+ 一个进程,两类 event loop:
62
+ - 主线程:一个 asyncio loop
63
+ - FastAPI(Meta API:HTTP + WS)
64
+ - gRPC aio server(Invoke + StreamEvents)
65
+ - CommandExecutor(作为“唯一运行时入口”,最好也在这个 loop 上)
66
+ - TTY 线程:一个独立线程
67
+ - prompt_toolkit 的 PromptSession/应用运行(它内部也会用 asyncio,但你可以在这个线程里创建自己的 loop 或让 prompt_toolkit 管理)
68
+ - TTY 发起命令:通过 submit_threadsafe() 把 invocation 投递到主线程 executor loop
69
+ - 输出:OutputRouter 把事件安全地写回 TTY(run_in_terminal / patch_stdout 等)
70
+ 4. 给出一个初步的meta实现(目前meta包中的实现还是空的),需要从从 registry 导出 consoles/commands/argspec 的 JSON(或 dict)结构;revision hash:未看到对 meta 做 canonical 序列化并生成 hash/ETag 的实现。
71
+
3
72
  ## 2026/01/24/01
4
73
 
5
74
  目前存在问题及初步解决方案:
@@ -205,13 +274,11 @@ BaseConsole.execute(cmd):
205
274
  收益:你从“一个 TTY 框架作者”升级成“一个 CLI+API 双栈控制平面作者”。
206
275
 
207
276
 
208
-
209
277
  ## 2024/03/29
210
278
 
211
279
  Demo中的File Manager正在开发中......
212
280
 
213
281
 
214
-
215
282
  ## 2024/03/27
216
283
  为BaseCommand中的校验器CommandValidator添加了一个变量``` enable_undefined_command ```,
217
284
  用于控制Console级别的校验器是否在用户输入一些非命令时的拦截行为,该变量在BaseCommand构造时将传入Console校验器CommandValidator中,