kiwimatecoder 0.1.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 (104) hide show
  1. kiwimatecoder/__init__.py +8 -0
  2. kiwimatecoder/__main__.py +12 -0
  3. kiwimatecoder/acp/__init__.py +13 -0
  4. kiwimatecoder/acp/protocol.py +115 -0
  5. kiwimatecoder/acp/server.py +823 -0
  6. kiwimatecoder/acp/stdio.py +32 -0
  7. kiwimatecoder/agent.py +1162 -0
  8. kiwimatecoder/ai.py +68 -0
  9. kiwimatecoder/audit.py +65 -0
  10. kiwimatecoder/browser.py +261 -0
  11. kiwimatecoder/catalog.py +445 -0
  12. kiwimatecoder/checkpoints.py +103 -0
  13. kiwimatecoder/client.py +820 -0
  14. kiwimatecoder/clipboard.py +99 -0
  15. kiwimatecoder/commands.py +6757 -0
  16. kiwimatecoder/config.py +5335 -0
  17. kiwimatecoder/diagnostics.py +295 -0
  18. kiwimatecoder/documents.py +299 -0
  19. kiwimatecoder/evals/__init__.py +39 -0
  20. kiwimatecoder/evals/cases.py +230 -0
  21. kiwimatecoder/evals/render.py +46 -0
  22. kiwimatecoder/evals/runner.py +319 -0
  23. kiwimatecoder/events.py +95 -0
  24. kiwimatecoder/forge.py +172 -0
  25. kiwimatecoder/git.py +164 -0
  26. kiwimatecoder/headless.py +255 -0
  27. kiwimatecoder/hooks.py +170 -0
  28. kiwimatecoder/hunks.py +260 -0
  29. kiwimatecoder/i18n.py +368 -0
  30. kiwimatecoder/images.py +195 -0
  31. kiwimatecoder/index/__init__.py +14 -0
  32. kiwimatecoder/index/builder.py +376 -0
  33. kiwimatecoder/index/embeddings.py +151 -0
  34. kiwimatecoder/index/search.py +247 -0
  35. kiwimatecoder/index/store.py +251 -0
  36. kiwimatecoder/instructions.py +83 -0
  37. kiwimatecoder/jobs.py +594 -0
  38. kiwimatecoder/lsp/__init__.py +56 -0
  39. kiwimatecoder/lsp/client.py +548 -0
  40. kiwimatecoder/lsp/manager.py +353 -0
  41. kiwimatecoder/lsp/protocol.py +79 -0
  42. kiwimatecoder/main.py +4258 -0
  43. kiwimatecoder/mcp/__init__.py +45 -0
  44. kiwimatecoder/mcp/client.py +385 -0
  45. kiwimatecoder/mcp/errors.py +7 -0
  46. kiwimatecoder/mcp/manager.py +253 -0
  47. kiwimatecoder/mcp/protocol.py +132 -0
  48. kiwimatecoder/media.py +904 -0
  49. kiwimatecoder/memory.py +141 -0
  50. kiwimatecoder/network.py +112 -0
  51. kiwimatecoder/notify.py +139 -0
  52. kiwimatecoder/permissions.py +171 -0
  53. kiwimatecoder/pickers.py +417 -0
  54. kiwimatecoder/plugins.py +245 -0
  55. kiwimatecoder/pricing.py +167 -0
  56. kiwimatecoder/prompts.py +213 -0
  57. kiwimatecoder/providers.py +342 -0
  58. kiwimatecoder/redaction.py +66 -0
  59. kiwimatecoder/remote.py +294 -0
  60. kiwimatecoder/repl.py +1388 -0
  61. kiwimatecoder/routing.py +65 -0
  62. kiwimatecoder/sandbox.py +169 -0
  63. kiwimatecoder/sdk.py +146 -0
  64. kiwimatecoder/session.py +574 -0
  65. kiwimatecoder/share.py +386 -0
  66. kiwimatecoder/shell.py +660 -0
  67. kiwimatecoder/skills.py +138 -0
  68. kiwimatecoder/sync.py +513 -0
  69. kiwimatecoder/team.py +249 -0
  70. kiwimatecoder/telemetry.py +392 -0
  71. kiwimatecoder/templates.py +108 -0
  72. kiwimatecoder/tools/__init__.py +190 -0
  73. kiwimatecoder/tools/ask.py +62 -0
  74. kiwimatecoder/tools/base.py +69 -0
  75. kiwimatecoder/tools/browser.py +261 -0
  76. kiwimatecoder/tools/edit_file.py +143 -0
  77. kiwimatecoder/tools/forge.py +207 -0
  78. kiwimatecoder/tools/git.py +158 -0
  79. kiwimatecoder/tools/image.py +300 -0
  80. kiwimatecoder/tools/io.py +346 -0
  81. kiwimatecoder/tools/list_dir.py +67 -0
  82. kiwimatecoder/tools/lsp.py +254 -0
  83. kiwimatecoder/tools/memory.py +115 -0
  84. kiwimatecoder/tools/paths.py +234 -0
  85. kiwimatecoder/tools/read_file.py +113 -0
  86. kiwimatecoder/tools/registry.py +91 -0
  87. kiwimatecoder/tools/run_bash.py +189 -0
  88. kiwimatecoder/tools/search.py +224 -0
  89. kiwimatecoder/tools/selection.py +108 -0
  90. kiwimatecoder/tools/shell.py +158 -0
  91. kiwimatecoder/tools/skill.py +46 -0
  92. kiwimatecoder/tools/task.py +61 -0
  93. kiwimatecoder/tools/todo.py +77 -0
  94. kiwimatecoder/tools/web.py +146 -0
  95. kiwimatecoder/tools/write_file.py +83 -0
  96. kiwimatecoder/ui.py +189 -0
  97. kiwimatecoder/updater.py +502 -0
  98. kiwimatecoder/web.py +499 -0
  99. kiwimatecoder-0.1.0.dist-info/METADATA +2016 -0
  100. kiwimatecoder-0.1.0.dist-info/RECORD +104 -0
  101. kiwimatecoder-0.1.0.dist-info/WHEEL +5 -0
  102. kiwimatecoder-0.1.0.dist-info/entry_points.txt +2 -0
  103. kiwimatecoder-0.1.0.dist-info/licenses/LICENSE +21 -0
  104. kiwimatecoder-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,99 @@
1
+ """Clipboard helpers: pick a platform tool and read/write text safely.
2
+
3
+ The helpers never raise from :func:`read_clipboard`/:func:`write_clipboard`;
4
+ they return ``(ok, text_or_error)`` so tools can surface a friendly message.
5
+ Commands run without a shell, with a short timeout, and are selected from the
6
+ platform's standard tools (``pbcopy``/``pbpaste`` on macOS, ``wl-clipboard`` or
7
+ ``xclip`` on Linux, PowerShell on Windows).
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import shutil
13
+ import subprocess
14
+ import sys
15
+
16
+ TIMEOUT_SECONDS = 10.0
17
+
18
+ # (executable, argv) candidates per action, in preference order.
19
+ _LINUX_READ = (
20
+ ("wl-paste", ["wl-paste"]),
21
+ ("xclip", ["xclip", "-selection", "clipboard", "-o"]),
22
+ )
23
+ _LINUX_WRITE = (
24
+ ("wl-copy", ["wl-copy"]),
25
+ ("xclip", ["xclip", "-selection", "clipboard", "-i"]),
26
+ )
27
+
28
+
29
+ def clipboard_command(action: str, platform: str | None = None) -> list[str] | None:
30
+ """Return the argv that reads or writes the clipboard, or None if absent.
31
+
32
+ ``action`` is ``"read"`` or ``"write"``. ``platform`` overrides
33
+ ``sys.platform`` for testing.
34
+ """
35
+ if action not in {"read", "write"}:
36
+ raise ValueError("Clipboard action must be 'read' or 'write'.")
37
+ system = (platform or sys.platform).lower()
38
+ if system == "darwin":
39
+ tool = "pbpaste" if action == "read" else "pbcopy"
40
+ return [tool] if shutil.which(tool) else None
41
+ if system.startswith("linux"):
42
+ for candidate, argv in _LINUX_READ if action == "read" else _LINUX_WRITE:
43
+ if shutil.which(candidate):
44
+ return list(argv)
45
+ return None
46
+ if system.startswith("win"):
47
+ command = "Get-Clipboard" if action == "read" else "Set-Clipboard"
48
+ executable = shutil.which("powershell") or shutil.which("pwsh")
49
+ return [executable, "-command", command] if executable else None
50
+ return None
51
+
52
+
53
+ def _missing_message() -> str:
54
+ return (
55
+ "No clipboard tool found. Install one: pbpaste/pbcopy (macOS), "
56
+ "wl-clipboard or xclip (Linux), or use PowerShell (Windows)."
57
+ )
58
+
59
+
60
+ def _run(args: list[str], *, input_text: str | None = None) -> tuple[bool, str]:
61
+ try:
62
+ proc = subprocess.run(
63
+ args,
64
+ input=input_text,
65
+ capture_output=True,
66
+ text=True,
67
+ timeout=TIMEOUT_SECONDS,
68
+ check=False,
69
+ )
70
+ except FileNotFoundError:
71
+ return False, f"Clipboard tool '{args[0]}' is not installed."
72
+ except subprocess.TimeoutExpired:
73
+ return False, f"Clipboard tool '{args[0]}' timed out after {TIMEOUT_SECONDS:g}s."
74
+ except OSError as exc:
75
+ return False, f"Clipboard tool '{args[0]}' failed: {exc}"
76
+ if proc.returncode != 0:
77
+ detail = (proc.stderr or "").strip()
78
+ message = f"Clipboard tool '{args[0]}' exited with code {proc.returncode}"
79
+ return False, f"{message}: {detail}" if detail else f"{message}."
80
+ return True, proc.stdout or ""
81
+
82
+
83
+ def read_clipboard() -> tuple[bool, str]:
84
+ """Read the clipboard. Returns ``(ok, text_or_error_message)``."""
85
+ command = clipboard_command("read")
86
+ if command is None:
87
+ return False, _missing_message()
88
+ return _run(command)
89
+
90
+
91
+ def write_clipboard(text: str) -> tuple[bool, str]:
92
+ """Write ``text`` to the clipboard. Never raises."""
93
+ command = clipboard_command("write")
94
+ if command is None:
95
+ return False, _missing_message()
96
+ ok, output = _run(command, input_text=str(text))
97
+ if not ok:
98
+ return False, output
99
+ return True, f"Copied {len(str(text))} character(s) to the clipboard."