Skip to content

Commit dc7efb8

Browse files
Shenanigans to make the release to typeagent work
2 parents d493e11 + d43c157 commit dc7efb8

File tree

6 files changed

+135
-11
lines changed

6 files changed

+135
-11
lines changed

.github/workflows/release-py.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
defaults:
1818
run:
1919
shell: bash
20-
working-directory: python/ta # your project subdir
20+
working-directory: . # your project subdir
2121
steps:
2222
- uses: actions/checkout@v4
2323

@@ -41,7 +41,7 @@ jobs:
4141
uses: actions/upload-artifact@v4
4242
with:
4343
name: dist
44-
path: python/ta/dist/
44+
path: dist/
4545

4646
publish:
4747
needs: build

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Never run git commands that many any changes. (`git status` and `git diff` are f
1414

1515
When moving, copying or deleting files, use the git commands: `git mv`, `git cp`, `git rm`
1616

17-
When the working directory is ~/TypeAgent/python/ta/:
17+
When the working directory is ~/typeagent-py:
1818

1919
- Don't use '!' on the command line, it's some bash magic (even inside single quotes)
2020
- Activate `.venv`: make venv; source .venv/bin/activate

TADA.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Talk at PyBay is on Sat, Oct 18 in SF
77
- Design and implement high-level API to support ingestion and querying
88
- Unify Podcast and VTT ingestion (use shared message and metadata classes)?
99
- Code structure (do podcasts and transcripts need to be under typeagent?)?
10-
- Move to typeagent-py repo
11-
- Rename PyPI package name to typeagent
1210
- Distinguish between release deps and build/dev deps?
1311

1412
### Specifically for VTT import:
@@ -124,6 +122,6 @@ this summer and its API.
124122
4. Links
125123
126124
- To PyPI project
127-
- To GitHub (typeagent-py or TypeAgent/python/ta?)
125+
- To GitHub (microsoft/typeagent-py)
128126
- To docs
129127

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ requires = ["setuptools>=67", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "typeagent-py"
7-
version = "0.1.8"
6+
name = "typeagent"
7+
version = "0.2.4"
88
description = "TypeAgent implements an agentic memory framework."
99
readme = { file = "README.md", content-type = "text/markdown" }
1010
authors = [
@@ -40,7 +40,7 @@ dependencies = [
4040
]
4141

4242
[project.urls]
43-
Homepage = "https://github.com/microsoft/TypeAgent/tree/main/python/ta"
43+
Homepage = "https://github.com/microsoft/TypeAgent/tree/main"
4444

4545
[tool.setuptools]
4646
# Needed so setuptools doesn't complain about testdata.

tools/release.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def main():
172172
3. Create a git tag "vX.Y.Z-py"
173173
4. Push the tags to trigger the release workflow
174174
175-
The script must be run from the python/ta directory.
175+
The script must be run from the repository root.
176176
""",
177177
)
178178

@@ -191,7 +191,7 @@ def main():
191191
for file_name in expected_files:
192192
if not (current_dir / file_name).exists():
193193
print(
194-
f"Error: {file_name} not found. Please run this script from the python/ta directory.",
194+
f"Error: {file_name} not found. Please run this script from the repository root.",
195195
file=sys.stderr,
196196
)
197197
return 1

tools/rewrite-patches.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/usr/bin/env python3
2+
"""Rewrite git patches to strip python/ta/ prefix from all paths.
3+
4+
This tool is used to migrate commits from the TypeAgent monorepo to the
5+
standalone python/ta repository. It takes git format-patch output files
6+
and rewrites all path references to remove the python/ta/ prefix.
7+
8+
Usage:
9+
# Generate patches in the TypeAgent repo
10+
git format-patch <since>..HEAD --output-directory=/tmp/patches -- python/ta/
11+
12+
# Rewrite the patches
13+
python3 tools/rewrite-patches.py /tmp/patches/*.patch
14+
15+
# Apply in the new repo
16+
cd /path/to/new-repo
17+
git am /tmp/patches/*.patch
18+
"""
19+
20+
import re
21+
import sys
22+
from pathlib import Path
23+
24+
25+
def rewrite_patch(patch_content: str) -> str:
26+
"""Rewrite paths in a git patch to strip python/ta/ prefix.
27+
28+
Args:
29+
patch_content: The content of a git format-patch output file
30+
31+
Returns:
32+
The rewritten patch content with python/ta/ stripped from all paths
33+
"""
34+
lines = patch_content.split('\n')
35+
output = []
36+
37+
for line in lines:
38+
# Handle diff headers (e.g., "diff --git a/python/ta/foo.py b/python/ta/foo.py")
39+
if line.startswith('diff --git '):
40+
line = line.replace(' a/python/ta/', ' a/')
41+
line = line.replace(' b/python/ta/', ' b/')
42+
43+
# Handle file path headers in unified diff format
44+
elif line.startswith('--- '):
45+
if line.startswith('--- a/python/ta/'):
46+
line = line.replace('--- a/python/ta/', '--- a/')
47+
elif line == '--- /dev/null':
48+
pass # Leave /dev/null unchanged
49+
50+
elif line.startswith('+++ '):
51+
if line.startswith('+++ b/python/ta/'):
52+
line = line.replace('+++ b/python/ta/', '+++ b/')
53+
elif line == '+++ /dev/null':
54+
pass # Leave /dev/null unchanged
55+
56+
# Handle rename/copy operations
57+
elif line.startswith('rename from '):
58+
line = line.replace('rename from python/ta/', 'rename from ')
59+
elif line.startswith('rename to '):
60+
line = line.replace('rename to python/ta/', 'rename to ')
61+
elif line.startswith('copy from '):
62+
line = line.replace('copy from python/ta/', 'copy from ')
63+
elif line.startswith('copy to '):
64+
line = line.replace('copy to python/ta/', 'copy to ')
65+
66+
# Handle similarity index for renames (no path changes needed)
67+
# Handle index lines (no path changes needed)
68+
# Handle new/deleted file mode (no path changes needed)
69+
70+
output.append(line)
71+
72+
return '\n'.join(output)
73+
74+
75+
def main():
76+
"""Main entry point for the patch rewriter."""
77+
if len(sys.argv) < 2:
78+
print("Usage: rewrite-patches.py <patch-file> [patch-file ...]", file=sys.stderr)
79+
print("\nRewrite git format-patch files to strip python/ta/ prefix from paths.", file=sys.stderr)
80+
print("\nExample:", file=sys.stderr)
81+
print(" git format-patch abc123..HEAD --output-directory=/tmp/patches -- python/ta/", file=sys.stderr)
82+
print(" python3 tools/rewrite-patches.py /tmp/patches/*.patch", file=sys.stderr)
83+
sys.exit(1)
84+
85+
patch_files = sys.argv[1:]
86+
success_count = 0
87+
error_count = 0
88+
89+
for patch_file in patch_files:
90+
try:
91+
path = Path(patch_file)
92+
if not path.exists():
93+
print(f"Error: File not found: {patch_file}", file=sys.stderr)
94+
error_count += 1
95+
continue
96+
97+
if not path.is_file():
98+
print(f"Error: Not a file: {patch_file}", file=sys.stderr)
99+
error_count += 1
100+
continue
101+
102+
# Read the original patch
103+
content = path.read_text(encoding='utf-8')
104+
105+
# Rewrite paths
106+
rewritten = rewrite_patch(content)
107+
108+
# Write back to the same file
109+
path.write_text(rewritten, encoding='utf-8')
110+
111+
print(f"✓ Rewrote {patch_file}")
112+
success_count += 1
113+
114+
except Exception as e:
115+
print(f"Error processing {patch_file}: {e}", file=sys.stderr)
116+
error_count += 1
117+
118+
# Print summary
119+
print(f"\nProcessed {success_count + error_count} files: {success_count} successful, {error_count} errors")
120+
121+
if error_count > 0:
122+
sys.exit(1)
123+
124+
125+
if __name__ == '__main__':
126+
main()

0 commit comments

Comments
 (0)