Skip to content

Commit 5582643

Browse files
committed
refactor(agent-setup): move tooling into .agents
1 parent a7b3e5e commit 5582643

11 files changed

Lines changed: 57 additions & 218 deletions

File tree

.agents/AGENTS.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ langfuse-python/
3636
├─ langfuse/langchain/ # LangChain integration
3737
├─ tests/ # Test suite
3838
├─ static/ # Test fixtures and sample content
39-
├─ scripts/ # Repo scripts
4039
└─ .agents/ # Canonical shared agent instructions and config
4140
```
4241

@@ -65,10 +64,10 @@ High-signal entry points:
6564

6665
## Build, Test, and Development Commands
6766

68-
- Agent environment bootstrap: `bash scripts/codex/setup.sh`
69-
- Install dependencies: `poetry install --all-extras`
70-
- Sync generated agent shims: `python3 scripts/agents/sync-agent-shims.py`
71-
- Verify generated agent shims: `python3 scripts/agents/sync-agent-shims.py --check`
67+
- Agent environment bootstrap: `bash .agents/scripts/codex/setup.sh`
68+
- Install dependencies: `bash .agents/scripts/install.sh --all-extras`
69+
- Sync generated agent shims: `python3 .agents/scripts/sync-agent-shims.py`
70+
- Verify generated agent shims: `python3 .agents/scripts/sync-agent-shims.py --check`
7271
- Install pre-commit hooks: `poetry run pre-commit install`
7372
- Run all tests: `poetry run pytest -s -v --log-cli-level=INFO`
7473
- Run tests in parallel: `poetry run pytest -s -v --log-cli-level=INFO -n auto`
@@ -88,7 +87,7 @@ Minimum verification matrix:
8887
| `langfuse/api/**` | verify source update path from main repo + `poetry run ruff format .` + targeted API tests |
8988
| Integration modules (`langfuse/openai.py`, `langfuse/langchain/**`) | targeted tests for the touched integration + lint + latest official provider docs review if behavior or API usage changed |
9089
| Test-only changes | targeted pytest coverage for the updated tests |
91-
| Agent setup files (`.agents/**`, `scripts/agents/**`, `scripts/codex/**`) | `python3 scripts/agents/sync-agent-shims.py` + `python3 scripts/agents/sync-agent-shims.py --check` + `poetry run pytest tests/test_sync_agent_shims.py` |
90+
| Agent setup files (`.agents/**`) | `python3 .agents/scripts/sync-agent-shims.py` + `python3 .agents/scripts/sync-agent-shims.py --check` |
9291

9392
CI notes:
9493

@@ -202,7 +201,9 @@ Update flow:
202201
- Shared agent/tool config lives in `.agents/config.json`.
203202
- Shared agent setup documentation lives in `.agents/README.md`.
204203
- Shared skills live under `.agents/skills/`.
205-
- `python3 scripts/agents/sync-agent-shims.py` regenerates tool-specific config
204+
- `.agents/scripts/` is the home for repo-owned agent bootstrap and sync
205+
tooling.
206+
- `python3 .agents/scripts/sync-agent-shims.py` regenerates tool-specific config
206207
shims for Claude, Cursor, VS Code, Codex, and shared MCP discovery files.
207208
- Tool-specific directories such as `.claude/`, `.cursor/`, `.codex/`, and
208209
`.vscode/` remain because those tools discover project settings from fixed

.agents/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ or `.vscode/`.
1212
- `AGENTS.md`: canonical shared root instructions
1313
- `config.json`: shared bootstrap and MCP configuration used to generate
1414
tool-specific shims
15+
- `scripts/`: shared bootstrap and sync helpers for agent tooling
1516
- `skills/`: shared, tool-neutral implementation guidance for recurring
1617
workflows
1718

@@ -30,7 +31,7 @@ Current shape:
3031
```json
3132
{
3233
"shared": {
33-
"setupScript": "bash scripts/codex/setup.sh",
34+
"setupScript": "bash .agents/scripts/codex/setup.sh",
3435
"devCommand": "poetry run bash",
3536
"devTerminalDescription": "Interactive development shell inside the Poetry environment"
3637
},
@@ -59,7 +60,7 @@ Current shape:
5960

6061
## How Shims Are Generated
6162

62-
`scripts/agents/sync-agent-shims.py` reads `.agents/config.json` and writes the
63+
`.agents/scripts/sync-agent-shims.py` reads `.agents/config.json` and writes the
6364
tool discovery files that those products require.
6465

6566
Generated local artifacts:
@@ -99,15 +100,16 @@ Do not edit generated shim files by hand. Edit the canonical files in
99100
After editing `.agents/config.json` or `.agents/skills/**`:
100101

101102
1. Run `python3 scripts/agents/sync-agent-shims.py`
102-
2. Run `python3 scripts/agents/sync-agent-shims.py --check`
103-
3. Run `poetry run pytest tests/test_sync_agent_shims.py`
104-
4. Verify you did not stage generated files under `.claude/skills/` or any of
103+
2. Run `python3 .agents/scripts/sync-agent-shims.py --check`
104+
3. Verify you did not stage generated files under `.claude/skills/` or any of
105105
the generated MCP/runtime config paths
106-
5. Update `.agents/AGENTS.md` or `CONTRIBUTING.md` if the shared workflow
106+
4. Update `.agents/AGENTS.md` or `CONTRIBUTING.md` if the shared workflow
107107
materially changed
108108

109-
`bash scripts/postinstall.sh` runs the sync/check flow as a convenience helper,
110-
and `bash scripts/codex/setup.sh` uses it during agent environment bootstrap.
109+
`bash .agents/scripts/install.sh --all-extras` is the canonical repo install
110+
flow and wires `poetry install` to `bash .agents/scripts/postinstall.sh`.
111+
`bash .agents/scripts/codex/setup.sh` uses the same path during agent
112+
environment bootstrap.
111113

112114
## Adding Shared Skills
113115

@@ -121,7 +123,7 @@ Use them for durable, reusable guidance such as:
121123

122124
Do not use skills for one-off notes or tool runtime configuration.
123125

124-
`python3 scripts/agents/sync-agent-shims.py` projects shared skills into
126+
`python3 .agents/scripts/sync-agent-shims.py` projects shared skills into
125127
`.claude/skills/` so Claude can discover the same repo-owned skills.
126128

127129
For the skill authoring workflow, see [skills/README.md](skills/README.md).

.agents/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"shared": {
3-
"setupScript": "bash scripts/codex/setup.sh",
3+
"setupScript": "bash .agents/scripts/codex/setup.sh",
44
"devCommand": "poetry run bash",
55
"devTerminalDescription": "Interactive development shell inside the Poetry environment"
66
},
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ set -euo pipefail
44

55
poetry config virtualenvs.create true --local
66
poetry config virtualenvs.in-project true --local
7-
poetry install --all-extras
87

9-
bash scripts/postinstall.sh
8+
bash .agents/scripts/install.sh --all-extras

.agents/scripts/install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
poetry install "$@"
6+
7+
bash .agents/scripts/postinstall.sh

.agents/scripts/postinstall.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [[ ! -f ".agents/scripts/sync-agent-shims.py" ]]; then
6+
echo "Skipping agent shim sync: .agents/scripts/sync-agent-shims.py is not present in this install context."
7+
exit 0
8+
fi
9+
10+
python3 .agents/scripts/sync-agent-shims.py
11+
python3 .agents/scripts/sync-agent-shims.py --check
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ def print_error(message: str) -> None:
186186
print(message, file=sys.stderr)
187187

188188

189+
def is_writable(path: Path) -> bool:
190+
target = path if path.exists() else path.parent
191+
return os.access(target, os.W_OK)
192+
193+
189194
def sync_file_outputs(
190195
file_outputs: list[dict[str, Any]], check_mode: bool
191196
) -> tuple[bool, list[str]]:
@@ -198,6 +203,9 @@ def sync_file_outputs(
198203
optional: bool = output.get("optional", False)
199204

200205
if check_mode:
206+
if optional and not is_writable(path):
207+
warnings.append(f"Skipping optional config check: {path}")
208+
continue
201209
try:
202210
current = path.read_text(encoding="utf-8")
203211
except FileNotFoundError:
@@ -206,7 +214,7 @@ def sync_file_outputs(
206214
continue
207215
has_mismatch = True
208216
print_error(
209-
f'Missing generated config: {path}. Run "python3 scripts/agents/sync-agent-shims.py".'
217+
f'Missing generated config: {path}. Run "python3 .agents/scripts/sync-agent-shims.py".'
210218
)
211219
continue
212220

@@ -240,7 +248,7 @@ def sync_symlink_outputs(
240248
if not is_matching_symlink(path, target):
241249
has_mismatch = True
242250
print_error(
243-
f'Out of sync symlink: {path}. Run "python3 scripts/agents/sync-agent-shims.py".'
251+
f'Out of sync symlink: {path}. Run "python3 .agents/scripts/sync-agent-shims.py".'
244252
)
245253
continue
246254

.github/workflows/ci.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ jobs:
2929
uses: actions/setup-python@v4
3030
with:
3131
python-version: "3.13"
32-
- name: Verify agent shim generation
33-
run: |
34-
python3 scripts/agents/sync-agent-shims.py
35-
python3 scripts/agents/sync-agent-shims.py --check
3632
- name: Install poetry
3733
uses: abatilo/actions-poetry@v2
3834
- name: Setup a local virtual environment
@@ -52,7 +48,7 @@ jobs:
5248
restore-keys: |
5349
mypy-
5450
- name: Install dependencies
55-
run: poetry install --only=main,dev
51+
run: bash .agents/scripts/install.sh --only=main,dev
5652
- name: Run mypy type checking
5753
run: poetry run mypy langfuse --no-error-summary
5854

@@ -189,7 +185,7 @@ jobs:
189185
venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
190186
191187
- name: Install the project dependencies
192-
run: poetry install --all-extras
188+
run: bash .agents/scripts/install.sh --all-extras
193189

194190
- name: Run the automated tests
195191
run: |

CONTRIBUTING.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ poetry self add poetry-dotenv-plugin
1111
### Install dependencies
1212

1313
```
14-
poetry install --all-extras
14+
bash .agents/scripts/install.sh --all-extras
1515
```
1616

1717
### Shared Agent Setup
@@ -45,15 +45,14 @@ and MCP/bootstrap configuration.
4545
- Tool-specific skill projections generated locally and not committed:
4646
- `.claude/skills/*`
4747
- Shared bootstrap for agent environments:
48-
- `bash scripts/codex/setup.sh`
48+
- `bash .agents/scripts/codex/setup.sh`
4949

5050
When you change the shared agent setup:
5151

5252
1. Edit `.agents/config.json` or `.agents/skills/**`
53-
2. Run `python3 scripts/agents/sync-agent-shims.py`
54-
3. Run `python3 scripts/agents/sync-agent-shims.py --check`
55-
4. Run `poetry run pytest tests/test_sync_agent_shims.py`
56-
5. Do not commit the generated MCP config files or runtime shims
53+
2. Run `python3 .agents/scripts/sync-agent-shims.py`
54+
3. Run `python3 .agents/scripts/sync-agent-shims.py --check`
55+
4. Do not commit the generated MCP config files or runtime shims
5756

5857
### Add Pre-commit
5958

@@ -125,7 +124,7 @@ Note: The generated SDK reference is currently work in progress.
125124
The SDK reference is generated via pdoc. You need to have all extra dependencies installed to generate the reference.
126125

127126
```sh
128-
poetry install --all-extras
127+
bash .agents/scripts/install.sh --all-extras
129128
```
130129

131130
To update the reference, run the following command:

scripts/postinstall.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)