trellis-runtime 0.6.5__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.
- common/__init__.py +92 -0
- common/active_task.py +628 -0
- common/cli_adapter.py +851 -0
- common/config.py +445 -0
- common/developer.py +190 -0
- common/git.py +31 -0
- common/git_context.py +106 -0
- common/io.py +37 -0
- common/log.py +45 -0
- common/packages_context.py +238 -0
- common/paths.py +447 -0
- common/safe_commit.py +315 -0
- common/session_context.py +821 -0
- common/task_context.py +223 -0
- common/task_queue.py +188 -0
- common/task_store.py +776 -0
- common/task_utils.py +274 -0
- common/tasks.py +112 -0
- common/trellis_config.py +131 -0
- common/types.py +110 -0
- common/workflow_phase.py +212 -0
- trellis_runtime/__init__.py +0 -0
- trellis_runtime/upstream/__init__.py +0 -0
- trellis_runtime/upstream/entry/__init__.py +0 -0
- trellis_runtime/upstream/entry/add_session.py +574 -0
- trellis_runtime/upstream/entry/get_context.py +16 -0
- trellis_runtime/upstream/entry/get_developer.py +26 -0
- trellis_runtime/upstream/entry/init_developer.py +51 -0
- trellis_runtime/upstream/entry/task.py +500 -0
- trellis_runtime/upstream/hooks/__init__.py +0 -0
- trellis_runtime/upstream/hooks/inject_shell_session_context.py +183 -0
- trellis_runtime/upstream/hooks/inject_subagent_context.py +771 -0
- trellis_runtime/upstream/hooks/inject_workflow_state.py +408 -0
- trellis_runtime/upstream/hooks/session_start.py +844 -0
- trellis_runtime-0.6.5.dist-info/METADATA +7 -0
- trellis_runtime-0.6.5.dist-info/RECORD +39 -0
- trellis_runtime-0.6.5.dist-info/WHEEL +4 -0
- trellis_runtime-0.6.5.dist-info/entry_points.txt +10 -0
- trellis_runtime-0.6.5.dist-info/licenses/LICENSE +235 -0
common/__init__.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Common utilities for Trellis workflow scripts.
|
|
3
|
+
|
|
4
|
+
This module provides shared functionality used by other Trellis scripts.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import io
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
# =============================================================================
|
|
11
|
+
# Windows Encoding Fix (MUST be at top, before any other output)
|
|
12
|
+
# =============================================================================
|
|
13
|
+
# On Windows, stdout defaults to the system code page (often GBK/CP936).
|
|
14
|
+
# This causes UnicodeEncodeError when printing non-ASCII characters.
|
|
15
|
+
#
|
|
16
|
+
# Any script that imports from common will automatically get this fix.
|
|
17
|
+
# =============================================================================
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _configure_stream(stream: object) -> object:
|
|
21
|
+
"""Configure a stream for UTF-8 encoding on Windows."""
|
|
22
|
+
# Try reconfigure() first (Python 3.7+, more reliable)
|
|
23
|
+
if hasattr(stream, "reconfigure"):
|
|
24
|
+
stream.reconfigure(encoding="utf-8", errors="replace") # type: ignore[union-attr]
|
|
25
|
+
return stream
|
|
26
|
+
# Fallback: detach and rewrap with TextIOWrapper
|
|
27
|
+
elif hasattr(stream, "detach"):
|
|
28
|
+
return io.TextIOWrapper(
|
|
29
|
+
stream.detach(), # type: ignore[union-attr]
|
|
30
|
+
encoding="utf-8",
|
|
31
|
+
errors="replace",
|
|
32
|
+
)
|
|
33
|
+
return stream
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if sys.platform == "win32":
|
|
37
|
+
sys.stdout = _configure_stream(sys.stdout) # type: ignore[assignment]
|
|
38
|
+
sys.stderr = _configure_stream(sys.stderr) # type: ignore[assignment]
|
|
39
|
+
sys.stdin = _configure_stream(sys.stdin) # type: ignore[assignment]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def configure_encoding() -> None:
|
|
43
|
+
"""
|
|
44
|
+
Configure stdout/stderr/stdin for UTF-8 encoding on Windows.
|
|
45
|
+
|
|
46
|
+
This is automatically called when importing from common,
|
|
47
|
+
but can be called manually for scripts that don't import common.
|
|
48
|
+
|
|
49
|
+
Safe to call multiple times.
|
|
50
|
+
"""
|
|
51
|
+
global sys
|
|
52
|
+
if sys.platform == "win32":
|
|
53
|
+
sys.stdout = _configure_stream(sys.stdout) # type: ignore[assignment]
|
|
54
|
+
sys.stderr = _configure_stream(sys.stderr) # type: ignore[assignment]
|
|
55
|
+
sys.stdin = _configure_stream(sys.stdin) # type: ignore[assignment]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
from .paths import (
|
|
59
|
+
DIR_WORKFLOW,
|
|
60
|
+
DIR_WORKSPACE,
|
|
61
|
+
DIR_TASKS,
|
|
62
|
+
DIR_ARCHIVE,
|
|
63
|
+
DIR_SPEC,
|
|
64
|
+
DIR_SCRIPTS,
|
|
65
|
+
FILE_DEVELOPER,
|
|
66
|
+
FILE_CURRENT_TASK,
|
|
67
|
+
FILE_TASK_JSON,
|
|
68
|
+
FILE_JOURNAL_PREFIX,
|
|
69
|
+
get_repo_root,
|
|
70
|
+
get_developer,
|
|
71
|
+
check_developer,
|
|
72
|
+
get_tasks_dir,
|
|
73
|
+
get_workspace_dir,
|
|
74
|
+
get_active_journal_file,
|
|
75
|
+
count_lines,
|
|
76
|
+
get_current_task,
|
|
77
|
+
get_current_task_abs,
|
|
78
|
+
normalize_task_ref,
|
|
79
|
+
resolve_task_ref,
|
|
80
|
+
set_current_task,
|
|
81
|
+
clear_current_task,
|
|
82
|
+
has_current_task,
|
|
83
|
+
generate_task_date_prefix,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
from .active_task import (
|
|
87
|
+
ActiveTask,
|
|
88
|
+
clear_active_task,
|
|
89
|
+
resolve_active_task,
|
|
90
|
+
resolve_context_key,
|
|
91
|
+
set_active_task,
|
|
92
|
+
)
|