diff --git a/OPENCODE-MCP.md b/OPENCODE-MCP.md index ad549aa..554b593 100644 --- a/OPENCODE-MCP.md +++ b/OPENCODE-MCP.md @@ -75,7 +75,7 @@ EOF - `add_memory` - `create_skill` -**First session**: The AI will ask you for your project identifier (recommended: your git remote origin URL like `https://github.com/username/repo`). This ensures your project conventions and memories are consistent across machines. If you don't know your git remote, run `git remote get-url origin` in your project directory. If you need to initialize a git repo or set up AI Skills, search for the "Project Setup Guide" skill. +**Project identifier**: The AI will use its own shell access to determine the project's git remote (e.g., `git remote get-url origin`). This identifier scopes conventions and memories and ensures consistency across machines. If the directory isn't a git repo, you may need to provide a unique identifier manually. ## Troubleshooting diff --git a/USAGE.md b/USAGE.md index 0cf72c9..fab1b31 100644 --- a/USAGE.md +++ b/USAGE.md @@ -251,19 +251,20 @@ decisions = resp.json()["entries"] ### Starting a New Session -1. **Define your project identifier** - we recommend using git remote origin for consistency across machines: - ```python - # Option A: Auto-detect (recommended) - agent template does this automatically - project = get_project_identifier() # returns git remote origin if available, else env var, else dir name - - # Option B: Explicit project identifier (stable across machines) - PROJECT = "git@github.com:username/repo.git" # or "https://github.com/username/repo" - - # Option C: Use environment variable - # export PROJECT="git@github.com:username/repo.git" - ``` +The AI should determine the project identifier at the start of each session. **Recommended approach:** Use the git remote origin URL as a stable identifier that follows you across machines. - **Why git remote?** If you work on the same repository from multiple machines (different file paths), using the git remote as the project identifier ensures your conventions and memories follow you. The same repo gets the same context regardless of where you clone it. +```python +# Detecting the git remote (the AI would use its shell tool) +import subprocess +try: + project = subprocess.check_output(["git", "remote", "get-url", "origin"]).decode().strip() +except: + project = "fallback-identifier" # or ask user +``` + +This ensures that if you work on the same repository from multiple machines (different file paths), the project context remains consistent. The same repo uses the same identifier everywhere. + +If the directory isn't a git repository, the AI should ask the user for a unique project identifier or fall back to a configured environment variable. 2. **Load past memories** (optional but helpful): ```python