git-repokit 0.9.10__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 (174) hide show
  1. git_repokit-0.9.10.dist-info/METADATA +422 -0
  2. git_repokit-0.9.10.dist-info/RECORD +174 -0
  3. git_repokit-0.9.10.dist-info/WHEEL +5 -0
  4. git_repokit-0.9.10.dist-info/entry_points.txt +2 -0
  5. git_repokit-0.9.10.dist-info/licenses/LICENSE +9 -0
  6. git_repokit-0.9.10.dist-info/top_level.txt +1 -0
  7. repokit/__init__.py +8 -0
  8. repokit/__main__.py +12 -0
  9. repokit/__version__.py +4 -0
  10. repokit/_vendor/__init__.py +0 -0
  11. repokit/_vendor/ailib/__init__.py +1 -0
  12. repokit/_vendor/ailib/analyzer.py +177 -0
  13. repokit/_vendor/ailib/backend.py +95 -0
  14. repokit/_vendor/ailib/cache.py +97 -0
  15. repokit/_vendor/ailib/parsers.py +52 -0
  16. repokit/_vendor/ailib/transports/__init__.py +16 -0
  17. repokit/_vendor/ailib/transports/cli.py +312 -0
  18. repokit/_vendor/ailib/transports/openai_compat.py +383 -0
  19. repokit/_vendor/ailib/transports/prompt_file.py +41 -0
  20. repokit/_vendor/ailib/types.py +224 -0
  21. repokit/auth_integration.py +244 -0
  22. repokit/badges.py +183 -0
  23. repokit/branch_utils.py +364 -0
  24. repokit/cli.py +2997 -0
  25. repokit/common_kit.py +202 -0
  26. repokit/config.py +686 -0
  27. repokit/defaults.py +220 -0
  28. repokit/directory_analyzer.py +1244 -0
  29. repokit/directory_profiles.py +423 -0
  30. repokit/git_config.py +370 -0
  31. repokit/github_create.py +142 -0
  32. repokit/github_setup.py +248 -0
  33. repokit/guardrails.py +707 -0
  34. repokit/history_cleaner.py +449 -0
  35. repokit/history_protection.py +434 -0
  36. repokit/hooks/pre-commit-guardrails +122 -0
  37. repokit/hooks/pre-commit-template +28 -0
  38. repokit/layers.py +510 -0
  39. repokit/licenses/0bsd.txt +14 -0
  40. repokit/licenses/LICENSES.md +27 -0
  41. repokit/licenses/__init__.py +142 -0
  42. repokit/licenses/agpl-3.0.txt +661 -0
  43. repokit/licenses/all-rights-reserved.txt +10 -0
  44. repokit/licenses/apache-2.0.txt +201 -0
  45. repokit/licenses/bsd-2-clause.txt +24 -0
  46. repokit/licenses/bsd-3-clause.txt +28 -0
  47. repokit/licenses/bsl-1.0.txt +23 -0
  48. repokit/licenses/cc-by-4.0.txt +395 -0
  49. repokit/licenses/cc-by-sa-4.0.txt +427 -0
  50. repokit/licenses/cc0-1.0.txt +121 -0
  51. repokit/licenses/epl-2.0.txt +277 -0
  52. repokit/licenses/gpl-2.0.txt +339 -0
  53. repokit/licenses/gpl-3.0.txt +674 -0
  54. repokit/licenses/isc.txt +15 -0
  55. repokit/licenses/lgpl-2.1.txt +504 -0
  56. repokit/licenses/lgpl-3.0.txt +165 -0
  57. repokit/licenses/mit.txt +21 -0
  58. repokit/licenses/mpl-2.0.txt +373 -0
  59. repokit/licenses/unlicense.txt +24 -0
  60. repokit/readme_blocks.py +112 -0
  61. repokit/remote_integration.py +627 -0
  62. repokit/repo_manager.py +2796 -0
  63. repokit/template_engine.py +391 -0
  64. repokit/templates/ai/claude/CLAUDE-nested.md.template +25 -0
  65. repokit/templates/ai/claude/CLAUDE.md.template +98 -0
  66. repokit/templates/ai/claude/instructions/step1_context_rebuilder.md +33 -0
  67. repokit/templates/ai/claude/instructions/step2_dev_workflow_process.md +67 -0
  68. repokit/templates/ai/claude/instructions/step3_context_bridge.md +52 -0
  69. repokit/templates/common/CHANGELOG.md.template +15 -0
  70. repokit/templates/common/CONTRIBUTING.md.template +31 -0
  71. repokit/templates/common/README.md.template +30 -0
  72. repokit/templates/common/gitattributes.template +17 -0
  73. repokit/templates/common/gitignore.template +141 -0
  74. repokit/templates/extras/FUNDING.yml.template +13 -0
  75. repokit/templates/extras/ROADMAP.md.template +17 -0
  76. repokit/templates/extras/dependabot.yml.template +22 -0
  77. repokit/templates/extras/one-offs-README.md.template +28 -0
  78. repokit/templates/extras/platform-support.md.template +11 -0
  79. repokit/templates/extras/pull_request_template.md.template +25 -0
  80. repokit/templates/extras/release-template.md.template +34 -0
  81. repokit/templates/extras/settings.json.template +11 -0
  82. repokit/templates/extras/stale.yml.template +14 -0
  83. repokit/templates/github/CODEOWNERS.template +11 -0
  84. repokit/templates/github/ISSUE_TEMPLATE/bug-report.md.template +29 -0
  85. repokit/templates/github/ISSUE_TEMPLATE/feature-request.md.template +19 -0
  86. repokit/templates/github/issues/notes.md.template +18 -0
  87. repokit/templates/github/issues/roadmap.md.template +15 -0
  88. repokit/templates/hooks/pre-commit.template +64 -0
  89. repokit/templates/layers/archetypes/any/claude-plugin/.claude-plugin/marketplace.json +20 -0
  90. repokit/templates/layers/archetypes/any/claude-plugin/plugin/.claude-plugin/plugin.json +15 -0
  91. repokit/templates/layers/archetypes/any/claude-plugin/plugin/README.md +28 -0
  92. repokit/templates/layers/archetypes/c-cpp/cmake-app/.github/workflows/ci-c-cpp.yml +24 -0
  93. repokit/templates/layers/archetypes/c-cpp/cmake-app/.repokit-common.toml.rkappend +4 -0
  94. repokit/templates/layers/archetypes/c-cpp/cmake-app/.vscode/launch.json +29 -0
  95. repokit/templates/layers/archetypes/c-cpp/cmake-app/.vscode/tasks.json +26 -0
  96. repokit/templates/layers/archetypes/c-cpp/cmake-app/CMakeLists.txt +47 -0
  97. repokit/templates/layers/archetypes/c-cpp/cmake-app/CMakePresets.json +23 -0
  98. repokit/templates/layers/archetypes/c-cpp/cmake-app/cmake/GenerateStamp.cmake +45 -0
  99. repokit/templates/layers/archetypes/c-cpp/cmake-app/src/main.cpp +27 -0
  100. repokit/templates/layers/archetypes/c-cpp/cmake-app/tests/test_version.cpp +20 -0
  101. repokit/templates/layers/archetypes/c-cpp/cmake-app/vcpkg.json +5 -0
  102. repokit/templates/layers/archetypes/c-cpp/minimal/.vscode/launch.json +27 -0
  103. repokit/templates/layers/archetypes/c-cpp/minimal/Makefile +10 -0
  104. repokit/templates/layers/archetypes/c-cpp/minimal/build.bat +7 -0
  105. repokit/templates/layers/archetypes/c-cpp/minimal/src/__RK_SNAKE__.c +26 -0
  106. repokit/templates/layers/archetypes/c-cpp/msbuild/.vscode/launch.json +17 -0
  107. repokit/templates/layers/archetypes/c-cpp/msbuild/.vscode/tasks.json +20 -0
  108. repokit/templates/layers/archetypes/c-cpp/msbuild/__RK_PROJECT__.sln +19 -0
  109. repokit/templates/layers/archetypes/c-cpp/msbuild/__RK_PROJECT__.vcxproj +41 -0
  110. repokit/templates/layers/archetypes/c-cpp/msbuild/src/main.cpp +26 -0
  111. repokit/templates/layers/archetypes/js-ts/claude-plugin/.repokit-common.toml +28 -0
  112. repokit/templates/layers/archetypes/js-ts/claude-plugin/.vscode/launch.json +34 -0
  113. repokit/templates/layers/archetypes/js-ts/claude-plugin/plugin/hooks/hooks.json +15 -0
  114. repokit/templates/layers/archetypes/js-ts/claude-plugin/plugin/hooks/scripts/session-start.mjs +23 -0
  115. repokit/templates/layers/archetypes/js-ts/claude-plugin/plugin/tests/manifest.test.js +30 -0
  116. repokit/templates/layers/archetypes/js-ts/node/.repokit-common.toml.rkappend +6 -0
  117. repokit/templates/layers/archetypes/js-ts/node/package.json +13 -0
  118. repokit/templates/layers/archetypes/js-ts/node-package/.github/workflows/release.yml +39 -0
  119. repokit/templates/layers/archetypes/js-ts/node-package/package.json +32 -0
  120. repokit/templates/layers/archetypes/js-ts/node-package/src/index.ts +13 -0
  121. repokit/templates/layers/archetypes/js-ts/node-package/tests/index.test.ts +11 -0
  122. repokit/templates/layers/archetypes/js-ts/script/.vscode/launch.json +34 -0
  123. repokit/templates/layers/archetypes/js-ts/script/__RK_PROJECT__.js +37 -0
  124. repokit/templates/layers/archetypes/js-ts/script/tests/version.test.js +26 -0
  125. repokit/templates/layers/archetypes/js-ts/ts/package.json +18 -0
  126. repokit/templates/layers/archetypes/js-ts/ts/tsconfig.json +15 -0
  127. repokit/templates/layers/archetypes/python/claude-plugin/.github/workflows/ci-python.yml +44 -0
  128. repokit/templates/layers/archetypes/python/claude-plugin/.repokit-common.toml +21 -0
  129. repokit/templates/layers/archetypes/python/claude-plugin/.vscode/launch.json +33 -0
  130. repokit/templates/layers/archetypes/python/claude-plugin/VERSION +1 -0
  131. repokit/templates/layers/archetypes/python/claude-plugin/plugin/hooks/hooks.json +15 -0
  132. repokit/templates/layers/archetypes/python/claude-plugin/plugin/hooks/scripts/run-hook.mjs +42 -0
  133. repokit/templates/layers/archetypes/python/claude-plugin/plugin/hooks/scripts/session_start.py +31 -0
  134. repokit/templates/layers/archetypes/python/claude-plugin/plugin/tests/test_manifest.py +42 -0
  135. repokit/templates/layers/archetypes/python/pypi/.github/workflows/release.yml +63 -0
  136. repokit/templates/layers/archetypes/python/pypi/.vscode/launch.json +43 -0
  137. repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/__init__.py +5 -0
  138. repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/__main__.py +6 -0
  139. repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/_version.py +96 -0
  140. repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/cli.py +18 -0
  141. repokit/templates/layers/archetypes/python/pypi/pyproject.toml +71 -0
  142. repokit/templates/layers/archetypes/python/pypi/tests/conftest.py +11 -0
  143. repokit/templates/layers/archetypes/python/pypi/tests/test_version.py +50 -0
  144. repokit/templates/layers/archetypes/python/script/.github/workflows/ci-python.yml +43 -0
  145. repokit/templates/layers/archetypes/python/script/.repokit-common.toml +14 -0
  146. repokit/templates/layers/archetypes/python/script/.vscode/launch.json +33 -0
  147. repokit/templates/layers/archetypes/python/script/VERSION +1 -0
  148. repokit/templates/layers/archetypes/python/script/__RK_PROJECT__.py +40 -0
  149. repokit/templates/layers/archetypes/python/script/tests/test_version.py +25 -0
  150. repokit/templates/layers/archetypes/python/setuppy/requirements.txt +8 -0
  151. repokit/templates/layers/archetypes/python/setuppy/setup.py +23 -0
  152. repokit/templates/layers/languages/c-cpp/.gitignore.rkappend +20 -0
  153. repokit/templates/layers/languages/c-cpp/.repokit-common.toml +7 -0
  154. repokit/templates/layers/languages/c-cpp/include/__RK_SNAKE__/version.h +20 -0
  155. repokit/templates/layers/languages/c-cpp/src/app.rc +25 -0
  156. repokit/templates/layers/languages/js-ts/.editorconfig +15 -0
  157. repokit/templates/layers/languages/js-ts/.github/workflows/ci-js-ts.yml +41 -0
  158. repokit/templates/layers/languages/js-ts/.gitignore.rkappend +13 -0
  159. repokit/templates/layers/languages/js-ts/.repokit-common.toml +19 -0
  160. repokit/templates/layers/languages/js-ts/.vscode/launch.json +24 -0
  161. repokit/templates/layers/languages/js-ts/VERSION +1 -0
  162. repokit/templates/layers/languages/python/.github/workflows/ci-python.yml +76 -0
  163. repokit/templates/layers/languages/python/.gitignore.rkappend +15 -0
  164. repokit/templates/layers/languages/python/.vscode/launch.json +33 -0
  165. repokit/templates/layers/manifest.toml +302 -0
  166. repokit/templates/vault/CLAUDE.md +29 -0
  167. repokit/templates/vault/claude/_maps/MOC-project.md +15 -0
  168. repokit/templates/vault/claude/_oracle/backlinks.md +3 -0
  169. repokit/templates/vault/claude/_oracle/concepts.md +12 -0
  170. repokit/templates/vault/claude/_oracle/manifest.md +10 -0
  171. repokit/templates/vault/claude/_todo/ACTIVE-WORK.md +18 -0
  172. repokit/templates/vault/claude/_todo/OPEN-LOOPS.md +14 -0
  173. repokit/utils.py +316 -0
  174. repokit/vault.py +248 -0
repokit/common_kit.py ADDED
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ git-repokit-common in a project git-repokit creates.
4
+
5
+ git-repokit-common holds the hooks and tools (version sync, private-content
6
+ checks, test gating) that projects use; git-repokit's part is to put a copy
7
+ in the project and set it up. Nothing here writes a hook itself: the hooks
8
+ come from repokit-common's own install-hooks.sh.
9
+
10
+ The copy is vendored as a git subtree at scripts/repokit-common/, the layout
11
+ the hooks look for first (/create-project, Phase 3).
12
+ """
13
+
14
+ import os
15
+ import re
16
+ import shutil
17
+ import subprocess
18
+ import sys
19
+ from typing import Dict, List, Optional, Tuple
20
+
21
+ DEFAULT_URL = "https://github.com/DazzleTools/git-repokit-common.git"
22
+ DEFAULT_REF = "main"
23
+ PREFIX = "scripts/repokit-common"
24
+
25
+ # REPOKIT_COMMON_SOURCE overrides the URL (a local path works); "off" skips
26
+ # vendoring. The test suite uses both so it never reaches the network.
27
+ SOURCE_ENV = "REPOKIT_COMMON_SOURCE"
28
+
29
+ # repokit-common's built-in private branches (hooks/lib.sh); a project whose
30
+ # private branch is not among them must list it in private-branches.
31
+ REPOKIT_COMMON_PRIVATE_BRANCHES = ["local", "private", "feature/*", "feat/*",
32
+ "prototype/*", "experiment/*", "spike/*"]
33
+
34
+
35
+ def _git(args: List[str], cwd: str) -> Tuple[int, str]:
36
+ result = subprocess.run(["git"] + args, cwd=cwd, capture_output=True, text=True,
37
+ encoding="utf-8", errors="replace")
38
+ return result.returncode, (result.stdout + result.stderr).strip()
39
+
40
+
41
+ def source(config: Dict) -> Optional[Tuple[str, str]]:
42
+ """(url, ref) to vendor from, or None when vendoring is switched off."""
43
+ settings = config.get("repokit_common") or {}
44
+ url = os.environ.get(SOURCE_ENV) or settings.get("url") or DEFAULT_URL
45
+ if url.strip().lower() == "off":
46
+ return None
47
+ return url, settings.get("ref") or DEFAULT_REF
48
+
49
+
50
+ def vendor(repo_root: str, url: str, ref: str) -> Optional[str]:
51
+ """Add repokit-common at scripts/repokit-common/ as a squashed subtree.
52
+
53
+ Needs a clean tree and at least one commit. The two commits git subtree
54
+ makes are not signed (git builds them with plumbing); git-repokit does not
55
+ rewrite them -- the next steps say how. Returns None or the failure.
56
+ """
57
+ if os.path.exists(os.path.join(repo_root, PREFIX)):
58
+ return f"{PREFIX} already exists"
59
+ if os.path.isdir(url):
60
+ url = os.path.abspath(url)
61
+ rc, out = _git(["subtree", "add", f"--prefix={PREFIX}", url, ref, "--squash"], repo_root)
62
+ if rc == 0:
63
+ return None
64
+ # A failure midway (Windows' path limit on a deep project directory, a
65
+ # lost connection) leaves what git read into the index and part of the
66
+ # checkout behind; take it back out so the project's first commit is not
67
+ # made of, or refused for, half of repokit-common.
68
+ prefix = os.path.join(repo_root, PREFIX)
69
+ if os.path.exists(prefix):
70
+ _git(["reset", "-q", "--", PREFIX], repo_root)
71
+ target = prefix
72
+ if sys.platform == "win32" and not prefix.startswith("\\\\?\\"):
73
+ target = "\\\\?\\" + os.path.abspath(prefix)
74
+ shutil.rmtree(target, ignore_errors=True)
75
+ return out or "git subtree add failed"
76
+
77
+
78
+ def find_sh() -> Optional[str]:
79
+ """The POSIX shell to run install-hooks.sh with.
80
+
81
+ On Windows, Git for Windows' own sh (next to git), never a `bash` found
82
+ on PATH -- that can be WSL's, which would see a different filesystem.
83
+ """
84
+ if sys.platform == "win32":
85
+ rc, exec_path = _git(["--exec-path"], os.getcwd())
86
+ if rc == 0 and exec_path:
87
+ # <git>/mingw64/libexec/git-core -> <git>/bin/sh.exe
88
+ git_root = os.path.normpath(os.path.join(exec_path.strip(), "..", "..", ".."))
89
+ candidate = os.path.join(git_root, "bin", "sh.exe")
90
+ if os.path.isfile(candidate):
91
+ return candidate
92
+ return shutil.which("sh")
93
+
94
+
95
+ def install_hooks(repo_root: str) -> Optional[str]:
96
+ """Run the vendored install-hooks.sh. Returns None or the failure."""
97
+ script = os.path.join(repo_root, PREFIX, "install-hooks.sh")
98
+ if not os.path.isfile(script):
99
+ return f"{PREFIX}/install-hooks.sh not found"
100
+ sh = find_sh()
101
+ if not sh:
102
+ return "no POSIX shell (sh) found to run install-hooks.sh"
103
+ result = subprocess.run([sh, f"{PREFIX}/install-hooks.sh"], cwd=repo_root,
104
+ capture_output=True, text=True, encoding="utf-8", errors="replace")
105
+ if result.returncode != 0:
106
+ return (result.stdout + result.stderr).strip() or "install-hooks.sh failed"
107
+ return None
108
+
109
+
110
+ def private_branch_settings(private_branch: Optional[str], private_paths: List[str]) -> Dict[str, List[str]]:
111
+ """Settings that make repokit-common's pre-commit guard the private-branch model.
112
+
113
+ private-patterns: the paths git-repokit's own guard protected (literal
114
+ prefixes; repokit-common adds them to its built-in list).
115
+ private-branches: only when the private branch is not one of
116
+ repokit-common's defaults; the setting replaces the list, so the defaults
117
+ are listed too.
118
+ """
119
+ settings: Dict[str, List[str]] = {}
120
+ if private_paths:
121
+ settings["private-patterns"] = sorted(dict.fromkeys(private_paths))
122
+ if private_branch and private_branch not in REPOKIT_COMMON_PRIVATE_BRANCHES:
123
+ settings["private-branches"] = REPOKIT_COMMON_PRIVATE_BRANCHES + [private_branch]
124
+ return settings
125
+
126
+
127
+ def _toml_list(values: List[str]) -> str:
128
+ return "[" + ", ".join('"' + v.replace("\\", "\\\\").replace('"', '\\"') + '"' for v in values) + "]"
129
+
130
+
131
+ _TABLE_HEADER = re.compile(r"^[ \t]*\[[ \t]*tool[ \t]*\.[ \t]*\"?repokit-common\"?[ \t]*\][ \t]*\r?\n", re.MULTILINE)
132
+
133
+
134
+ def _merge_into_table(text: str, settings: Dict[str, List[str]]) -> Optional[str]:
135
+ """Add the keys the existing [tool.repokit-common] table lacks, right after
136
+ its header; a key already present is never overwritten. Returns the new
137
+ text, or None when nothing was missing."""
138
+ header = _TABLE_HEADER.search(text)
139
+ if not header:
140
+ return None
141
+ rest = text[header.end():]
142
+ next_table = re.search(r"^[ \t]*\[", rest, re.MULTILINE) # the table ends at the next header
143
+ table = rest[: next_table.start()] if next_table else rest
144
+ missing = [key for key in settings
145
+ if not re.search(rf"^[ \t]*{re.escape(key)}[ \t]*=", table, re.MULTILINE)]
146
+ if not missing:
147
+ return None
148
+ nl = "\r\n" if "\r\n" in text else "\n"
149
+ lines = "".join(f"{key} = {_toml_list(settings[key])}{nl}" for key in missing)
150
+ return text[: header.end()] + lines + rest
151
+
152
+
153
+ def write_settings(repo_root: str, settings: Dict[str, List[str]]) -> Optional[str]:
154
+ """Write [tool.repokit-common] settings; returns the file written, or None.
155
+
156
+ pyproject.toml when the project has one (the table is added, or the keys
157
+ it lacks are merged into the table it has), else .repokit-common.toml
158
+ (created with the header repokit-common requires, or merged the same way).
159
+ A key already present is never overwritten: a code-type layer may ship
160
+ the file with its own version-source, and the private-branch settings go
161
+ in beside it rather than being dropped.
162
+ """
163
+ if not settings:
164
+ return None
165
+ lines = [f"{key} = {_toml_list(values)}" for key, values in settings.items()]
166
+ body = "[tool.repokit-common]\n" + "\n".join(lines) + "\n"
167
+
168
+ pyproject = os.path.join(repo_root, "pyproject.toml")
169
+ if os.path.isfile(pyproject):
170
+ with open(pyproject, encoding="utf-8", newline="") as f:
171
+ text = f.read()
172
+ if _TABLE_HEADER.search(text):
173
+ merged = _merge_into_table(text, settings)
174
+ if merged is None:
175
+ return None
176
+ with open(pyproject, "w", encoding="utf-8", newline="") as f:
177
+ f.write(merged)
178
+ return "pyproject.toml"
179
+ with open(pyproject, "a", encoding="utf-8") as f:
180
+ f.write(("\n" if text and not text.endswith("\n") else "") + "\n" + body)
181
+ return "pyproject.toml"
182
+
183
+ path = os.path.join(repo_root, ".repokit-common.toml")
184
+ if os.path.exists(path):
185
+ with open(path, encoding="utf-8", newline="") as f:
186
+ text = f.read()
187
+ merged = _merge_into_table(text, settings)
188
+ if merged is None:
189
+ return None
190
+ with open(path, "w", encoding="utf-8", newline="") as f:
191
+ f.write(merged)
192
+ return ".repokit-common.toml"
193
+ with open(path, "w", encoding="utf-8") as f:
194
+ f.write("# Settings for the vendored git-repokit-common hooks and tools\n" + body)
195
+ return ".repokit-common.toml"
196
+
197
+
198
+ RESIGN_HINT = (
199
+ "git subtree made two unsigned commits for scripts/repokit-common/. If this\n"
200
+ "repository signs its commits, re-sign them before pushing (see the\n"
201
+ "/create-project skill, Phase 3), or leave them unsigned."
202
+ )