maybridge 0.1.0__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.
- maybridge-0.1.0/LICENSE +21 -0
- maybridge-0.1.0/PKG-INFO +48 -0
- maybridge-0.1.0/README.md +34 -0
- maybridge-0.1.0/agents_bridge.py +298 -0
- maybridge-0.1.0/maybridge.egg-info/PKG-INFO +48 -0
- maybridge-0.1.0/maybridge.egg-info/SOURCES.txt +9 -0
- maybridge-0.1.0/maybridge.egg-info/dependency_links.txt +1 -0
- maybridge-0.1.0/maybridge.egg-info/entry_points.txt +3 -0
- maybridge-0.1.0/maybridge.egg-info/top_level.txt +1 -0
- maybridge-0.1.0/pyproject.toml +20 -0
- maybridge-0.1.0/setup.cfg +4 -0
maybridge-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MayBridge contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
maybridge-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maybridge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Share AGENTS.md and .agents/skills with Claude Code: creates CLAUDE.md and syncs skills. Dry-run by default, stdlib only.
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: AGENTS.md,claude-code,skills,agents
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# MayBridge
|
|
16
|
+
|
|
17
|
+
Use one set of agent instructions and skills across coding agents.
|
|
18
|
+
|
|
19
|
+
Many repos keep their guidance in `AGENTS.md` and `.agents/skills/`. Claude Code reads `CLAUDE.md` and `.claude/skills/`. MayBridge connects the two, so you maintain one copy and both tools see it.
|
|
20
|
+
|
|
21
|
+
- Creates `CLAUDE.md` containing `@AGENTS.md` if none exists.
|
|
22
|
+
- Copies each skill from `.agents/skills/` into `.claude/skills/`.
|
|
23
|
+
- `--check` reports drift (missing, extra, or changed files) and exits 1, so it works in CI.
|
|
24
|
+
- Standard library only. Python 3.8+. No network access.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
pip install maybridge
|
|
29
|
+
|
|
30
|
+
## Use
|
|
31
|
+
|
|
32
|
+
maybridge # dry run in the current repo: shows what would change
|
|
33
|
+
maybridge --trust # apply the changes
|
|
34
|
+
maybridge path/to/repo --check
|
|
35
|
+
|
|
36
|
+
Options: `--dry-run`, `--check`, `--trust`, `--force`.
|
|
37
|
+
|
|
38
|
+
## Safety
|
|
39
|
+
|
|
40
|
+
- The default is a dry run. Writing needs `--trust`, because skills and AGENTS.md are instructions your agent will follow. Review them first.
|
|
41
|
+
- It never follows symlinks or junctions, in the source or the destination, and writes stay inside the repo.
|
|
42
|
+
- A differing skill that already exists is not overwritten. `--force` moves the old copy to `.claude/skills/.agents-bridge-backup/` first.
|
|
43
|
+
|
|
44
|
+
## Status
|
|
45
|
+
|
|
46
|
+
Alpha (0.1.0). Tested on Windows. Linux and macOS reports are welcome, especially for symlink edge cases.
|
|
47
|
+
|
|
48
|
+
Licensed under MIT.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# MayBridge
|
|
2
|
+
|
|
3
|
+
Use one set of agent instructions and skills across coding agents.
|
|
4
|
+
|
|
5
|
+
Many repos keep their guidance in `AGENTS.md` and `.agents/skills/`. Claude Code reads `CLAUDE.md` and `.claude/skills/`. MayBridge connects the two, so you maintain one copy and both tools see it.
|
|
6
|
+
|
|
7
|
+
- Creates `CLAUDE.md` containing `@AGENTS.md` if none exists.
|
|
8
|
+
- Copies each skill from `.agents/skills/` into `.claude/skills/`.
|
|
9
|
+
- `--check` reports drift (missing, extra, or changed files) and exits 1, so it works in CI.
|
|
10
|
+
- Standard library only. Python 3.8+. No network access.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
pip install maybridge
|
|
15
|
+
|
|
16
|
+
## Use
|
|
17
|
+
|
|
18
|
+
maybridge # dry run in the current repo: shows what would change
|
|
19
|
+
maybridge --trust # apply the changes
|
|
20
|
+
maybridge path/to/repo --check
|
|
21
|
+
|
|
22
|
+
Options: `--dry-run`, `--check`, `--trust`, `--force`.
|
|
23
|
+
|
|
24
|
+
## Safety
|
|
25
|
+
|
|
26
|
+
- The default is a dry run. Writing needs `--trust`, because skills and AGENTS.md are instructions your agent will follow. Review them first.
|
|
27
|
+
- It never follows symlinks or junctions, in the source or the destination, and writes stay inside the repo.
|
|
28
|
+
- A differing skill that already exists is not overwritten. `--force` moves the old copy to `.claude/skills/.agents-bridge-backup/` first.
|
|
29
|
+
|
|
30
|
+
## Status
|
|
31
|
+
|
|
32
|
+
Alpha (0.1.0). Tested on Windows. Linux and macOS reports are welcome, especially for symlink edge cases.
|
|
33
|
+
|
|
34
|
+
Licensed under MIT.
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""agents-bridge: make a repo using AGENTS.md + .agents/skills work with Claude Code.
|
|
3
|
+
|
|
4
|
+
Claude Code reads CLAUDE.md and .claude/skills; other agents read AGENTS.md and .agents/skills.
|
|
5
|
+
This copies AGENTS.md -> CLAUDE.md (an '@AGENTS.md' import stub) and
|
|
6
|
+
.agents/skills/<n>/ -> .claude/skills/<n>/.
|
|
7
|
+
|
|
8
|
+
SECURITY MODEL
|
|
9
|
+
Skills and AGENTS.md are *instructions that Claude Code will follow*. Syncing them promotes
|
|
10
|
+
repo content to a trusted location, so:
|
|
11
|
+
* default is a dry run; writing requires --trust (you vouch for the repo content);
|
|
12
|
+
* symlinks/junctions/special files are never followed or copied (source or destination);
|
|
13
|
+
* every write is confined to the repo root (resolved paths are verified);
|
|
14
|
+
* an existing, different .claude/skills/<n> is NEVER deleted unless --force, and even then it
|
|
15
|
+
is moved to .claude/skills/.agents-bridge-backup/ first;
|
|
16
|
+
* size limits (files, bytes) bound what is copied.
|
|
17
|
+
* all-or-nothing per skill: a skill containing any unsafe entry is skipped entirely (no partial install);
|
|
18
|
+
if installing an update fails after the old copy was backed up, the old copy is restored.
|
|
19
|
+
Limitation: no defence against a hostile process that concurrently rewrites the repo tree during the
|
|
20
|
+
run (anyone who can do that can already write .claude/skills directly); checks are re-verified at use.
|
|
21
|
+
Usage: agents_bridge.py [repo] [--check] [--dry-run] [--trust] [--force]
|
|
22
|
+
--check exit 1 if anything is out of sync/unsafe (never writes). Exit 2: conflicts/refusals.
|
|
23
|
+
"""
|
|
24
|
+
import sys, os, stat, shutil, hashlib, time, re
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
MAX_FILES, MAX_FILE_BYTES, MAX_TOTAL_BYTES = 500, 1 << 20, 20 << 20
|
|
28
|
+
BACKUP = ".agents-bridge-backup"
|
|
29
|
+
|
|
30
|
+
def is_link(p):
|
|
31
|
+
try:
|
|
32
|
+
st = os.lstat(p)
|
|
33
|
+
except OSError:
|
|
34
|
+
return False
|
|
35
|
+
if stat.S_ISLNK(st.st_mode):
|
|
36
|
+
return True
|
|
37
|
+
return bool(getattr(st, "st_file_attributes", 0) & 0x400) # Windows reparse point/junction
|
|
38
|
+
|
|
39
|
+
BADCHARS = ':' + chr(92) + '*?"<>|'
|
|
40
|
+
RESERVED = re.compile(r"^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$", re.I)
|
|
41
|
+
|
|
42
|
+
def bad_name(n):
|
|
43
|
+
"""Names unsafe on some platform: ':' (NTFS ADS), reserved device names, trailing dot/space, control chars."""
|
|
44
|
+
return (not n or n in (".", "..") or any(c in n for c in BADCHARS) or n[-1] in ". "
|
|
45
|
+
or bool(RESERVED.match(n)) or any(ord(c) < 32 for c in n))
|
|
46
|
+
|
|
47
|
+
def multi_link(p):
|
|
48
|
+
"""True for a hard-linked file (st_nlink > 1): its content may live outside the repo."""
|
|
49
|
+
try:
|
|
50
|
+
return os.lstat(p).st_nlink > 1
|
|
51
|
+
except OSError:
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
def has_import(text):
|
|
55
|
+
"""True only for a real '@AGENTS.md' import: not inside an HTML comment, fenced block or inline code."""
|
|
56
|
+
text = re.sub(r"<!--.*?(-->|\Z)", "", text, flags=re.S)
|
|
57
|
+
text = re.sub(r"(?ms)^[ ]{0,3}(`{3,}|~{3,}).*?(^[ ]{0,3}\1[`~]*[ ]*$|\Z)", "", text)
|
|
58
|
+
text = re.sub(r"`[^`\n]*`", "", text)
|
|
59
|
+
return re.search(r"(?m)(?:^|[ \t])@AGENTS\.md(?![\w./-])", text) is not None
|
|
60
|
+
|
|
61
|
+
def read_text_regular(p):
|
|
62
|
+
"""Read a small regular file without ever blocking on a FIFO/device (lstat gate + O_NONBLOCK)."""
|
|
63
|
+
st = os.lstat(p)
|
|
64
|
+
if not stat.S_ISREG(st.st_mode):
|
|
65
|
+
raise OSError(f"{p}: not a regular file")
|
|
66
|
+
flags = os.O_RDONLY | getattr(os, "O_BINARY", 0) | getattr(os, "O_NOFOLLOW", 0) | getattr(os, "O_NONBLOCK", 0)
|
|
67
|
+
fd = os.open(p, flags)
|
|
68
|
+
try:
|
|
69
|
+
fs = os.fstat(fd)
|
|
70
|
+
if not stat.S_ISREG(fs.st_mode) or fs.st_size > MAX_FILE_BYTES:
|
|
71
|
+
raise OSError(f"{p}: not a regular file or too large")
|
|
72
|
+
with os.fdopen(fd, "rb", closefd=False) as f:
|
|
73
|
+
return f.read(MAX_FILE_BYTES + 1).decode("utf-8", "replace")
|
|
74
|
+
finally:
|
|
75
|
+
os.close(fd)
|
|
76
|
+
|
|
77
|
+
def safe_read(p):
|
|
78
|
+
"""Read a regular, non-link, single-link file; re-verify identity on the open descriptor (anti-TOCTOU)."""
|
|
79
|
+
pre = os.lstat(p)
|
|
80
|
+
flags = os.O_RDONLY | getattr(os, "O_BINARY", 0) | getattr(os, "O_NOFOLLOW", 0)
|
|
81
|
+
fd = os.open(p, flags)
|
|
82
|
+
try:
|
|
83
|
+
st = os.fstat(fd)
|
|
84
|
+
if not stat.S_ISREG(st.st_mode) or st.st_nlink > 1 or is_link(p) or \
|
|
85
|
+
(pre.st_ino, pre.st_dev) != (st.st_ino, st.st_dev) or st.st_size > MAX_FILE_BYTES:
|
|
86
|
+
raise OSError(f"{p}: changed or unsafe while reading")
|
|
87
|
+
with os.fdopen(fd, "rb", closefd=False) as f:
|
|
88
|
+
return f.read(MAX_FILE_BYTES + 1)
|
|
89
|
+
finally:
|
|
90
|
+
os.close(fd)
|
|
91
|
+
|
|
92
|
+
def manifest(d):
|
|
93
|
+
"""Return ({relpath: sha256}, problems). Symlinks/special files/oversize are problems, not data."""
|
|
94
|
+
files, probs, total = {}, [], 0
|
|
95
|
+
if is_link(d):
|
|
96
|
+
return files, [f"{d.name}: is a link"]
|
|
97
|
+
for root, dirs, fs in os.walk(d, followlinks=False):
|
|
98
|
+
r = Path(root)
|
|
99
|
+
for n in list(dirs):
|
|
100
|
+
if bad_name(n):
|
|
101
|
+
probs.append(f"{(r / n).relative_to(d).as_posix()}: unsafe dir name (skipped)"); dirs.remove(n); continue
|
|
102
|
+
if is_link(r / n):
|
|
103
|
+
probs.append(f"{(r / n).relative_to(d).as_posix()}: link (skipped)"); dirs.remove(n)
|
|
104
|
+
for n in sorted(fs):
|
|
105
|
+
p = r / n; rel = p.relative_to(d).as_posix()
|
|
106
|
+
st = os.lstat(p)
|
|
107
|
+
if is_link(p) or not stat.S_ISREG(st.st_mode):
|
|
108
|
+
probs.append(f"{rel}: link/special file (skipped)"); continue
|
|
109
|
+
if st.st_nlink > 1:
|
|
110
|
+
probs.append(f"{rel}: hard link (skipped)"); continue
|
|
111
|
+
if any(bad_name(x) for x in rel.split("/")):
|
|
112
|
+
probs.append(f"{rel}: unsafe file name (skipped)"); continue
|
|
113
|
+
if st.st_size > MAX_FILE_BYTES:
|
|
114
|
+
probs.append(f"{rel}: larger than {MAX_FILE_BYTES} bytes"); continue
|
|
115
|
+
total += st.st_size
|
|
116
|
+
if total > MAX_TOTAL_BYTES:
|
|
117
|
+
probs.append(f"total size exceeds {MAX_TOTAL_BYTES} bytes"); return files, probs
|
|
118
|
+
try:
|
|
119
|
+
files[rel] = hashlib.sha256(safe_read(p)).hexdigest()
|
|
120
|
+
except OSError as e:
|
|
121
|
+
probs.append(f"{rel}: {e}")
|
|
122
|
+
if len(files) > MAX_FILES:
|
|
123
|
+
probs.append(f"more than {MAX_FILES} files"); break
|
|
124
|
+
return files, probs
|
|
125
|
+
|
|
126
|
+
def inside(root, p):
|
|
127
|
+
try:
|
|
128
|
+
Path(os.path.realpath(p)).relative_to(os.path.realpath(root)); return True
|
|
129
|
+
except ValueError:
|
|
130
|
+
return False
|
|
131
|
+
|
|
132
|
+
def plan(repo):
|
|
133
|
+
"""Return (actions, problems). action = (kind, name, src, dst). Pure: no writes."""
|
|
134
|
+
repo = Path(repo); acts, probs = [], []
|
|
135
|
+
ag, cl = repo / "AGENTS.md", repo / "CLAUDE.md"
|
|
136
|
+
if ag.is_file() and not is_link(ag) and not multi_link(ag):
|
|
137
|
+
if is_link(cl):
|
|
138
|
+
probs.append("CLAUDE.md is a link: refusing")
|
|
139
|
+
elif not os.path.lexists(cl):
|
|
140
|
+
acts.append(("create", "CLAUDE.md", None, cl))
|
|
141
|
+
else:
|
|
142
|
+
try:
|
|
143
|
+
if not has_import(read_text_regular(cl)):
|
|
144
|
+
probs.append("CLAUDE.md exists but does not import @AGENTS.md (left untouched)")
|
|
145
|
+
except OSError as e:
|
|
146
|
+
probs.append(f"CLAUDE.md unreadable or special file: {e}")
|
|
147
|
+
elif os.path.lexists(ag):
|
|
148
|
+
probs.append("AGENTS.md is a link/hard link/special file: ignored")
|
|
149
|
+
src, dst = repo / ".agents" / "skills", repo / ".claude" / "skills"
|
|
150
|
+
if is_link(repo / ".agents") or is_link(src):
|
|
151
|
+
return acts, probs + [".agents or .agents/skills is a link: refusing"]
|
|
152
|
+
if not src.is_dir():
|
|
153
|
+
if os.path.lexists(src):
|
|
154
|
+
probs.append(".agents/skills is not a directory: ignored")
|
|
155
|
+
return acts, probs
|
|
156
|
+
if is_link(repo / ".claude") or is_link(dst) or not inside(repo, dst.parent):
|
|
157
|
+
return acts, probs + [".claude or .claude/skills is a link/outside repo: refusing"]
|
|
158
|
+
for q in (repo / ".claude", dst):
|
|
159
|
+
if os.path.lexists(q) and not is_link(q) and not q.is_dir():
|
|
160
|
+
return acts, probs + [f"{q.relative_to(repo).as_posix()} exists but is not a directory: refusing"]
|
|
161
|
+
seen = {}
|
|
162
|
+
for s in sorted(src.iterdir()):
|
|
163
|
+
if is_link(s): # includes dangling links, which is_dir() would hide
|
|
164
|
+
probs.append(f"skill {s.name}: link (skipped)"); continue
|
|
165
|
+
if not s.is_dir():
|
|
166
|
+
continue
|
|
167
|
+
k = s.name.casefold()
|
|
168
|
+
if k in seen:
|
|
169
|
+
probs.append(f"skill {s.name}: name collides with {seen[k]} on case-insensitive systems (skipped)"); continue
|
|
170
|
+
seen[k] = s.name
|
|
171
|
+
if bad_name(s.name):
|
|
172
|
+
probs.append(f"skill {s.name}: unsafe name (skipped)"); continue
|
|
173
|
+
if is_link(s):
|
|
174
|
+
probs.append(f"skill {s.name}: link (skipped)"); continue
|
|
175
|
+
sk = s / "SKILL.md"
|
|
176
|
+
if is_link(sk) or (os.path.lexists(sk) and not sk.is_file()):
|
|
177
|
+
probs.append(f"skill {s.name}: SKILL.md is a link/special file (skipped)"); continue
|
|
178
|
+
if not sk.is_file():
|
|
179
|
+
continue
|
|
180
|
+
sm, sp = manifest(s)
|
|
181
|
+
if sp: # all-or-nothing: a skill with any unsafe content is never partially installed
|
|
182
|
+
probs += [f"skill {s.name}: {x}" for x in sp]
|
|
183
|
+
probs.append(f"skill {s.name}: not installed (unsafe content)"); continue
|
|
184
|
+
t = dst / s.name
|
|
185
|
+
if is_link(t) or not inside(repo, t):
|
|
186
|
+
probs.append(f"skill {s.name}: destination is a link/outside repo (refusing)"); continue
|
|
187
|
+
if os.path.lexists(t):
|
|
188
|
+
tm, tp = manifest(t)
|
|
189
|
+
if tp:
|
|
190
|
+
probs += [f"skill {s.name} (dest): {x}" for x in tp]
|
|
191
|
+
if tm == sm and not tp:
|
|
192
|
+
continue
|
|
193
|
+
acts.append(("update", s.name, s, t))
|
|
194
|
+
else:
|
|
195
|
+
acts.append(("add", s.name, s, t))
|
|
196
|
+
return acts, probs
|
|
197
|
+
|
|
198
|
+
def apply(repo, acts, force=False):
|
|
199
|
+
"""Execute actions. Returns (done, conflicts)."""
|
|
200
|
+
repo = Path(repo); done, conflicts = [], []
|
|
201
|
+
for kind, name, s, t in acts:
|
|
202
|
+
if kind == "create":
|
|
203
|
+
try:
|
|
204
|
+
with open(t, "x", encoding="utf-8") as f: # O_EXCL: never follows/overwrites
|
|
205
|
+
f.write("@AGENTS.md\n")
|
|
206
|
+
done.append("create CLAUDE.md")
|
|
207
|
+
except OSError:
|
|
208
|
+
conflicts.append("refused: CLAUDE.md appeared or is not creatable")
|
|
209
|
+
continue
|
|
210
|
+
if kind == "update" and not force:
|
|
211
|
+
conflicts.append(f"conflict: .claude/skills/{name} differs; not overwritten (use --force; old copy is backed up)")
|
|
212
|
+
continue
|
|
213
|
+
if any(is_link(x) for x in (repo / ".claude", t.parent, t, repo / ".agents", s.parent)):
|
|
214
|
+
conflicts.append(f"refused: {name}: link appeared"); continue
|
|
215
|
+
try:
|
|
216
|
+
t.parent.mkdir(parents=True, exist_ok=True)
|
|
217
|
+
except OSError as e:
|
|
218
|
+
conflicts.append(f"refused: {name}: cannot create {t.parent.name}: {e}"); continue
|
|
219
|
+
if not inside(repo, t.parent) or is_link(t.parent):
|
|
220
|
+
conflicts.append(f"refused: {name} escapes repo"); continue
|
|
221
|
+
tmp = t.parent / f".{name}.agents-bridge-tmp"
|
|
222
|
+
if os.path.lexists(tmp):
|
|
223
|
+
conflicts.append(f"refused: stale temp {tmp.name} present"); continue
|
|
224
|
+
sm, sp = manifest(s)
|
|
225
|
+
if sp:
|
|
226
|
+
conflicts.append(f"refused: {name}: unsafe content, not installed"); continue
|
|
227
|
+
try:
|
|
228
|
+
os.mkdir(tmp) # fails if anything (incl. a dangling link) is already there
|
|
229
|
+
except OSError as e:
|
|
230
|
+
conflicts.append(f"refused: {name}: cannot create temp dir: {e}"); continue
|
|
231
|
+
if is_link(tmp) or not inside(repo, tmp):
|
|
232
|
+
shutil.rmtree(tmp, ignore_errors=True); conflicts.append(f"refused: {name}: temp dir escapes repo"); continue
|
|
233
|
+
bk = None
|
|
234
|
+
try:
|
|
235
|
+
for rel in sm: # copy only vetted regular files, never links; verify identity while reading
|
|
236
|
+
d = tmp / rel; d.parent.mkdir(parents=True, exist_ok=True)
|
|
237
|
+
data = safe_read(s / rel)
|
|
238
|
+
if hashlib.sha256(data).hexdigest() != sm[rel]:
|
|
239
|
+
raise OSError(f"{rel}: changed during sync")
|
|
240
|
+
if not inside(repo, d.parent) or is_link(d.parent):
|
|
241
|
+
raise OSError(f"{rel}: destination escapes repo")
|
|
242
|
+
with open(d, "xb") as f:
|
|
243
|
+
f.write(data)
|
|
244
|
+
if kind == "update":
|
|
245
|
+
b = t.parent / BACKUP
|
|
246
|
+
if is_link(b):
|
|
247
|
+
conflicts.append(f"refused: {BACKUP} is a link"); continue
|
|
248
|
+
b.mkdir(exist_ok=True)
|
|
249
|
+
if not inside(repo, b):
|
|
250
|
+
conflicts.append(f"refused: {BACKUP} escapes repo"); continue
|
|
251
|
+
bk = b / f"{name}-{time.strftime('%Y%m%d%H%M%S')}-{time.time_ns()}"
|
|
252
|
+
if os.path.lexists(bk):
|
|
253
|
+
conflicts.append("refused: backup name exists"); bk = None; continue
|
|
254
|
+
os.replace(t, bk)
|
|
255
|
+
if os.path.lexists(t):
|
|
256
|
+
raise OSError("destination appeared")
|
|
257
|
+
os.replace(tmp, t)
|
|
258
|
+
except OSError as e:
|
|
259
|
+
msg = f"refused: {name}: {e}"
|
|
260
|
+
if bk is not None and not os.path.lexists(t) and os.path.lexists(bk):
|
|
261
|
+
try:
|
|
262
|
+
os.replace(bk, t); msg += " (previous copy restored)"
|
|
263
|
+
except OSError as e2:
|
|
264
|
+
msg += f" (RESTORE FAILED, previous copy is at {bk}: {e2})"
|
|
265
|
+
conflicts.append(msg); continue
|
|
266
|
+
finally:
|
|
267
|
+
if os.path.lexists(tmp) and not is_link(tmp): shutil.rmtree(tmp, ignore_errors=True)
|
|
268
|
+
done.append(f"{kind} skill {name}")
|
|
269
|
+
return done, conflicts
|
|
270
|
+
|
|
271
|
+
def run(repo, dry=True, force=False):
|
|
272
|
+
"""Library entry. dry=True by default (safe). Returns list of action strings."""
|
|
273
|
+
acts, probs = plan(repo)
|
|
274
|
+
if dry:
|
|
275
|
+
return [f"{k} {'skill ' + n if k != 'create' else n}" for k, n, _, _ in acts]
|
|
276
|
+
done, conflicts = apply(repo, acts, force)
|
|
277
|
+
return done
|
|
278
|
+
|
|
279
|
+
def main(argv=None):
|
|
280
|
+
argv = sys.argv[1:] if argv is None else argv
|
|
281
|
+
a = [x for x in argv if not x.startswith("--")]
|
|
282
|
+
flags = {x for x in argv if x.startswith("--")}
|
|
283
|
+
repo = a[0] if a else "."
|
|
284
|
+
chk = "--check" in flags
|
|
285
|
+
acts, probs = plan(repo)
|
|
286
|
+
labels = [f"{k} {'skill ' + n if k != 'create' else n}" for k, n, _, _ in acts]
|
|
287
|
+
if chk or "--trust" not in flags or "--dry-run" in flags:
|
|
288
|
+
print("\n".join(labels + [f"warning: {p}" for p in probs]) or "in sync")
|
|
289
|
+
if not chk and acts and "--trust" not in flags:
|
|
290
|
+
print("dry run. Skills/AGENTS.md are instructions Claude Code will follow; "
|
|
291
|
+
"re-run with --trust after reviewing the repo content.")
|
|
292
|
+
sys.exit((1 if (acts or probs) else 0) if chk else 0)
|
|
293
|
+
done, conflicts = apply(repo, acts, "--force" in flags)
|
|
294
|
+
print("\n".join(done + conflicts + [f"warning: {p}" for p in probs]) or "in sync")
|
|
295
|
+
sys.exit(2 if (conflicts or probs) else 0)
|
|
296
|
+
|
|
297
|
+
if __name__ == "__main__":
|
|
298
|
+
main()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maybridge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Share AGENTS.md and .agents/skills with Claude Code: creates CLAUDE.md and syncs skills. Dry-run by default, stdlib only.
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: AGENTS.md,claude-code,skills,agents
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# MayBridge
|
|
16
|
+
|
|
17
|
+
Use one set of agent instructions and skills across coding agents.
|
|
18
|
+
|
|
19
|
+
Many repos keep their guidance in `AGENTS.md` and `.agents/skills/`. Claude Code reads `CLAUDE.md` and `.claude/skills/`. MayBridge connects the two, so you maintain one copy and both tools see it.
|
|
20
|
+
|
|
21
|
+
- Creates `CLAUDE.md` containing `@AGENTS.md` if none exists.
|
|
22
|
+
- Copies each skill from `.agents/skills/` into `.claude/skills/`.
|
|
23
|
+
- `--check` reports drift (missing, extra, or changed files) and exits 1, so it works in CI.
|
|
24
|
+
- Standard library only. Python 3.8+. No network access.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
pip install maybridge
|
|
29
|
+
|
|
30
|
+
## Use
|
|
31
|
+
|
|
32
|
+
maybridge # dry run in the current repo: shows what would change
|
|
33
|
+
maybridge --trust # apply the changes
|
|
34
|
+
maybridge path/to/repo --check
|
|
35
|
+
|
|
36
|
+
Options: `--dry-run`, `--check`, `--trust`, `--force`.
|
|
37
|
+
|
|
38
|
+
## Safety
|
|
39
|
+
|
|
40
|
+
- The default is a dry run. Writing needs `--trust`, because skills and AGENTS.md are instructions your agent will follow. Review them first.
|
|
41
|
+
- It never follows symlinks or junctions, in the source or the destination, and writes stay inside the repo.
|
|
42
|
+
- A differing skill that already exists is not overwritten. `--force` moves the old copy to `.claude/skills/.agents-bridge-backup/` first.
|
|
43
|
+
|
|
44
|
+
## Status
|
|
45
|
+
|
|
46
|
+
Alpha (0.1.0). Tested on Windows. Linux and macOS reports are welcome, especially for symlink edge cases.
|
|
47
|
+
|
|
48
|
+
Licensed under MIT.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agents_bridge
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "maybridge"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Share AGENTS.md and .agents/skills with Claude Code: creates CLAUDE.md and syncs skills. Dry-run by default, stdlib only."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
keywords = ["AGENTS.md", "claude-code", "skills", "agents"]
|
|
12
|
+
classifiers = ["Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3"]
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
maybridge = "agents_bridge:main"
|
|
17
|
+
agents-bridge = "agents_bridge:main"
|
|
18
|
+
|
|
19
|
+
[tool.setuptools]
|
|
20
|
+
py-modules = ["agents_bridge"]
|