Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
defaults:
run:
shell: bash
working-directory: python/ta # your project subdir
working-directory: . # your project subdir
steps:
- uses: actions/checkout@v4

Expand All @@ -41,7 +41,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: dist
path: python/ta/dist/
path: dist/

publish:
needs: build
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Never run git commands that many any changes. (`git status` and `git diff` are f

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

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

- Don't use '!' on the command line, it's some bash magic (even inside single quotes)
- Activate `.venv`: make venv; source .venv/bin/activate
Expand Down
4 changes: 1 addition & 3 deletions TADA.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Talk at PyBay is on Sat, Oct 18 in SF
- Design and implement high-level API to support ingestion and querying
- Unify Podcast and VTT ingestion (use shared message and metadata classes)?
- Code structure (do podcasts and transcripts need to be under typeagent?)?
- Move to typeagent-py repo
- Rename PyPI package name to typeagent
- Distinguish between release deps and build/dev deps?

### Specifically for VTT import:
Expand Down Expand Up @@ -124,6 +122,6 @@ this summer and its API.
4. Links

- To PyPI project
- To GitHub (typeagent-py or TypeAgent/python/ta?)
- To GitHub (microsoft/typeagent-py)
- To docs

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ requires = ["setuptools>=67", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "typeagent-py"
version = "0.1.8"
name = "typeagent"
version = "0.2.4"
description = "TypeAgent implements an agentic memory framework."
readme = { file = "README.md", content-type = "text/markdown" }
authors = [
Expand Down Expand Up @@ -40,7 +40,7 @@ dependencies = [
]

[project.urls]
Homepage = "https://github.com/microsoft/TypeAgent/tree/main/python/ta"
Homepage = "https://github.com/microsoft/TypeAgent/tree/main"

[tool.setuptools]
# Needed so setuptools doesn't complain about testdata.
Expand Down
4 changes: 2 additions & 2 deletions tools/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def main():
3. Create a git tag "vX.Y.Z-py"
4. Push the tags to trigger the release workflow

The script must be run from the python/ta directory.
The script must be run from the repository root.
""",
)

Expand All @@ -191,7 +191,7 @@ def main():
for file_name in expected_files:
if not (current_dir / file_name).exists():
print(
f"Error: {file_name} not found. Please run this script from the python/ta directory.",
f"Error: {file_name} not found. Please run this script from the repository root.",
file=sys.stderr,
)
return 1
Expand Down
126 changes: 126 additions & 0 deletions tools/rewrite-patches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/usr/bin/env python3
"""Rewrite git patches to strip python/ta/ prefix from all paths.

This tool is used to migrate commits from the TypeAgent monorepo to the
standalone python/ta repository. It takes git format-patch output files
and rewrites all path references to remove the python/ta/ prefix.

Usage:
# Generate patches in the TypeAgent repo
git format-patch <since>..HEAD --output-directory=/tmp/patches -- python/ta/

# Rewrite the patches
python3 tools/rewrite-patches.py /tmp/patches/*.patch

# Apply in the new repo
cd /path/to/new-repo
git am /tmp/patches/*.patch
"""

import re
import sys
from pathlib import Path


def rewrite_patch(patch_content: str) -> str:
"""Rewrite paths in a git patch to strip python/ta/ prefix.

Args:
patch_content: The content of a git format-patch output file

Returns:
The rewritten patch content with python/ta/ stripped from all paths
"""
lines = patch_content.split('\n')
output = []

for line in lines:
# Handle diff headers (e.g., "diff --git a/python/ta/foo.py b/python/ta/foo.py")
if line.startswith('diff --git '):
line = line.replace(' a/python/ta/', ' a/')
line = line.replace(' b/python/ta/', ' b/')

# Handle file path headers in unified diff format
elif line.startswith('--- '):
if line.startswith('--- a/python/ta/'):
line = line.replace('--- a/python/ta/', '--- a/')
elif line == '--- /dev/null':
pass # Leave /dev/null unchanged

elif line.startswith('+++ '):
if line.startswith('+++ b/python/ta/'):
line = line.replace('+++ b/python/ta/', '+++ b/')
elif line == '+++ /dev/null':
pass # Leave /dev/null unchanged

# Handle rename/copy operations
elif line.startswith('rename from '):
line = line.replace('rename from python/ta/', 'rename from ')
elif line.startswith('rename to '):
line = line.replace('rename to python/ta/', 'rename to ')
elif line.startswith('copy from '):
line = line.replace('copy from python/ta/', 'copy from ')
elif line.startswith('copy to '):
line = line.replace('copy to python/ta/', 'copy to ')

# Handle similarity index for renames (no path changes needed)
# Handle index lines (no path changes needed)
# Handle new/deleted file mode (no path changes needed)

output.append(line)

return '\n'.join(output)


def main():
"""Main entry point for the patch rewriter."""
if len(sys.argv) < 2:
print("Usage: rewrite-patches.py <patch-file> [patch-file ...]", file=sys.stderr)
print("\nRewrite git format-patch files to strip python/ta/ prefix from paths.", file=sys.stderr)
print("\nExample:", file=sys.stderr)
print(" git format-patch abc123..HEAD --output-directory=/tmp/patches -- python/ta/", file=sys.stderr)
print(" python3 tools/rewrite-patches.py /tmp/patches/*.patch", file=sys.stderr)
sys.exit(1)

patch_files = sys.argv[1:]
success_count = 0
error_count = 0

for patch_file in patch_files:
try:
path = Path(patch_file)
if not path.exists():
print(f"Error: File not found: {patch_file}", file=sys.stderr)
error_count += 1
continue

if not path.is_file():
print(f"Error: Not a file: {patch_file}", file=sys.stderr)
error_count += 1
continue

# Read the original patch
content = path.read_text(encoding='utf-8')

# Rewrite paths
rewritten = rewrite_patch(content)

# Write back to the same file
path.write_text(rewritten, encoding='utf-8')

print(f"✓ Rewrote {patch_file}")
success_count += 1

except Exception as e:
print(f"Error processing {patch_file}: {e}", file=sys.stderr)
error_count += 1

# Print summary
print(f"\nProcessed {success_count + error_count} files: {success_count} successful, {error_count} errors")

if error_count > 0:
sys.exit(1)


if __name__ == '__main__':
main()
Loading