kaiten-cli 0.3.3__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.
- kaiten_cli/__init__.py +5 -0
- kaiten_cli/__main__.py +9 -0
- kaiten_cli/agent_gateway.py +577 -0
- kaiten_cli/app.py +1636 -0
- kaiten_cli/completion.py +570 -0
- kaiten_cli/discovery.py +39 -0
- kaiten_cli/errors.py +79 -0
- kaiten_cli/i18n.py +92 -0
- kaiten_cli/locales/ru.json +2967 -0
- kaiten_cli/localized_click.py +160 -0
- kaiten_cli/models.py +202 -0
- kaiten_cli/profiles.py +316 -0
- kaiten_cli/registry/__init__.py +260 -0
- kaiten_cli/registry/addons.py +392 -0
- kaiten_cli/registry/audit_and_analytics.py +451 -0
- kaiten_cli/registry/automation_schema.py +44 -0
- kaiten_cli/registry/automation_schemas.json +7417 -0
- kaiten_cli/registry/automations.py +342 -0
- kaiten_cli/registry/base.py +62 -0
- kaiten_cli/registry/blockers.py +320 -0
- kaiten_cli/registry/boards.py +520 -0
- kaiten_cli/registry/card_relations.py +376 -0
- kaiten_cli/registry/card_types.py +363 -0
- kaiten_cli/registry/cards.py +1329 -0
- kaiten_cli/registry/charts.py +539 -0
- kaiten_cli/registry/checklists.py +600 -0
- kaiten_cli/registry/columns.py +558 -0
- kaiten_cli/registry/comments.py +224 -0
- kaiten_cli/registry/custom_directories.py +980 -0
- kaiten_cli/registry/custom_properties.py +1460 -0
- kaiten_cli/registry/dashboards.py +564 -0
- kaiten_cli/registry/documents.py +761 -0
- kaiten_cli/registry/external_links.py +128 -0
- kaiten_cli/registry/files.py +738 -0
- kaiten_cli/registry/github_addon.py +613 -0
- kaiten_cli/registry/iterations.py +397 -0
- kaiten_cli/registry/lanes.py +205 -0
- kaiten_cli/registry/live_contracts.py +361 -0
- kaiten_cli/registry/members.py +336 -0
- kaiten_cli/registry/module_docs.py +108 -0
- kaiten_cli/registry/projects.py +369 -0
- kaiten_cli/registry/query.py +129 -0
- kaiten_cli/registry/restrictions.py +249 -0
- kaiten_cli/registry/roles_and_groups.py +1102 -0
- kaiten_cli/registry/scim.py +263 -0
- kaiten_cli/registry/service_desk.py +1270 -0
- kaiten_cli/registry/snapshot.py +187 -0
- kaiten_cli/registry/spaces.py +272 -0
- kaiten_cli/registry/subscribers.py +168 -0
- kaiten_cli/registry/tags.py +193 -0
- kaiten_cli/registry/time_logs.py +353 -0
- kaiten_cli/registry/tree.py +352 -0
- kaiten_cli/registry/utilities.py +287 -0
- kaiten_cli/registry/webhooks.py +265 -0
- kaiten_cli/runtime/__init__.py +1 -0
- kaiten_cli/runtime/automation_validation.py +115 -0
- kaiten_cli/runtime/behaviors.py +787 -0
- kaiten_cli/runtime/cache.py +733 -0
- kaiten_cli/runtime/client.py +387 -0
- kaiten_cli/runtime/endpoints.py +59 -0
- kaiten_cli/runtime/executor.py +269 -0
- kaiten_cli/runtime/fs_security.py +168 -0
- kaiten_cli/runtime/input.py +310 -0
- kaiten_cli/runtime/output.py +59 -0
- kaiten_cli/runtime/public_validation.py +35 -0
- kaiten_cli/runtime/snapshot_build.py +527 -0
- kaiten_cli/runtime/snapshot_common.py +363 -0
- kaiten_cli/runtime/snapshot_query.py +306 -0
- kaiten_cli/runtime/snapshot_store.py +1192 -0
- kaiten_cli/runtime/snapshots.py +62 -0
- kaiten_cli/runtime/sqlite_errors.py +23 -0
- kaiten_cli/runtime/support/__init__.py +1 -0
- kaiten_cli/runtime/support/addons.py +953 -0
- kaiten_cli/runtime/support/audit.py +70 -0
- kaiten_cli/runtime/support/batch.py +234 -0
- kaiten_cli/runtime/support/card_move_url.py +213 -0
- kaiten_cli/runtime/support/cards.py +174 -0
- kaiten_cli/runtime/support/checklists.py +21 -0
- kaiten_cli/runtime/support/company_users.py +117 -0
- kaiten_cli/runtime/support/dashboards.py +35 -0
- kaiten_cli/runtime/support/documents.py +175 -0
- kaiten_cli/runtime/support/files.py +561 -0
- kaiten_cli/runtime/support/markdown_export.py +525 -0
- kaiten_cli/runtime/support/pagination.py +167 -0
- kaiten_cli/runtime/support/projects.py +66 -0
- kaiten_cli/runtime/support/relations.py +86 -0
- kaiten_cli/runtime/support/restrictions.py +62 -0
- kaiten_cli/runtime/support/spaces.py +20 -0
- kaiten_cli/runtime/support/time_logs.py +61 -0
- kaiten_cli/runtime/support/tree.py +140 -0
- kaiten_cli/runtime/support/tree_sharing.py +447 -0
- kaiten_cli/runtime/trace.py +500 -0
- kaiten_cli/runtime/transforms.py +128 -0
- kaiten_cli/schema_docs.py +22 -0
- kaiten_cli/update_check.py +519 -0
- kaiten_cli-0.3.3.dist-info/METADATA +1110 -0
- kaiten_cli-0.3.3.dist-info/RECORD +99 -0
- kaiten_cli-0.3.3.dist-info/WHEEL +4 -0
- kaiten_cli-0.3.3.dist-info/entry_points.txt +3 -0
kaiten_cli/i18n.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Explicit, invocation-scoped localization of CLI-owned text.
|
|
2
|
+
|
|
3
|
+
English source templates are stable message identifiers (gettext convention).
|
|
4
|
+
Only call sites and typed metadata opt in; API data is never traversed.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from contextlib import contextmanager
|
|
11
|
+
from contextvars import ContextVar
|
|
12
|
+
from functools import lru_cache
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Any, Iterator
|
|
15
|
+
|
|
16
|
+
LOCALES = ("en", "ru")
|
|
17
|
+
LOCALE_ENV = "KAITEN_CLI_LOCALE"
|
|
18
|
+
_locale: ContextVar[str] = ContextVar("kaiten_locale", default="en")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_locale() -> str:
|
|
22
|
+
return _locale.get()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@contextmanager
|
|
26
|
+
def use_locale(locale: str) -> Iterator[None]:
|
|
27
|
+
if locale not in LOCALES:
|
|
28
|
+
raise ValueError(f"Unsupported locale: {locale}. Expected ru or en.")
|
|
29
|
+
token = _locale.set(locale)
|
|
30
|
+
try:
|
|
31
|
+
yield
|
|
32
|
+
finally:
|
|
33
|
+
_locale.reset(token)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@lru_cache(maxsize=1)
|
|
37
|
+
def catalog() -> dict[str, str]:
|
|
38
|
+
return json.loads(Path(__file__).with_name("locales").joinpath("ru.json").read_text("utf-8"))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def translate(message: str, *, locale: str | None = None) -> str:
|
|
42
|
+
return catalog().get(message, message) if (locale or get_locale()) == "ru" else message
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def tr(message: str, **values: Any) -> str:
|
|
46
|
+
template = translate(message)
|
|
47
|
+
return template.format(**values) if values else template
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def localize_schema(schema: dict[str, Any] | bool) -> dict[str, Any] | bool:
|
|
51
|
+
"""Copy a JSON schema, translating prose only, never defaults/enums/patterns."""
|
|
52
|
+
if isinstance(schema, bool):
|
|
53
|
+
return schema
|
|
54
|
+
result = dict(schema)
|
|
55
|
+
for key in ("title", "description"):
|
|
56
|
+
if isinstance(result.get(key), str):
|
|
57
|
+
result[key] = tr(result[key])
|
|
58
|
+
for key in ("properties", "$defs", "definitions", "patternProperties"):
|
|
59
|
+
if isinstance(result.get(key), dict):
|
|
60
|
+
result[key] = {k: localize_schema(v) for k, v in result[key].items()}
|
|
61
|
+
for key in ("items", "additionalProperties", "not", "if", "then", "else", "contains"):
|
|
62
|
+
if isinstance(result.get(key), dict):
|
|
63
|
+
result[key] = localize_schema(result[key])
|
|
64
|
+
for key in ("allOf", "anyOf", "oneOf", "prefixItems"):
|
|
65
|
+
if isinstance(result.get(key), list):
|
|
66
|
+
result[key] = [localize_schema(v) for v in result[key]]
|
|
67
|
+
return result
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def localize_description(payload: dict[str, Any]) -> dict[str, Any]:
|
|
71
|
+
"""Localize the discovery contract, not an arbitrary response dictionary."""
|
|
72
|
+
result = dict(payload)
|
|
73
|
+
result["description"] = tr(result["description"])
|
|
74
|
+
if "usage_notes" in result:
|
|
75
|
+
result["usage_notes"] = [tr(note) for note in result["usage_notes"]]
|
|
76
|
+
if "arguments" in result:
|
|
77
|
+
result["arguments"] = [
|
|
78
|
+
dict(arg, description=tr(arg["description"])) for arg in result["arguments"]
|
|
79
|
+
]
|
|
80
|
+
if "input_schema" in result:
|
|
81
|
+
result["input_schema"] = localize_schema(result["input_schema"])
|
|
82
|
+
if "cache_guidance" in result:
|
|
83
|
+
guidance = dict(result["cache_guidance"])
|
|
84
|
+
for key in ("guidance", "refresh_hint", "off_hint", "readwrite_hint"):
|
|
85
|
+
if key in guidance:
|
|
86
|
+
guidance[key] = tr(guidance[key])
|
|
87
|
+
result["cache_guidance"] = guidance
|
|
88
|
+
if "live_contract" in result:
|
|
89
|
+
result["live_contract"] = dict(
|
|
90
|
+
result["live_contract"], note=tr(result["live_contract"]["note"])
|
|
91
|
+
)
|
|
92
|
+
return result
|