|
1 | 1 | # Agent Instructions |
2 | 2 |
|
3 | | -For fresh Windows PC onboarding, follow `AGENT_INSTALL.md` first. |
4 | | - |
5 | | -## Project Shape |
6 | | - |
7 | | -- `server.py` is the host-side stdio MCP server used by Codex. |
8 | | -- `vw_listener.py` runs inside Vectorworks 2024/2025 and listens on TCP `127.0.0.1:9877` by default. Generated launchers normally run it with `VW_MCP_MODE=dialog`, the only pure-Python mode currently safe for real `vs.*` API calls. Background and Windows timer modes are transport-only diagnostics. |
9 | | -- `native_bridge/` is the long-term native Vectorworks SDK bridge scaffold. It is planned, not compiled, and not wired into `.mcp.json` by default. |
10 | | -- `native_bridge/HANDLER_MATRIX.md` is the handler-by-handler implementation map for the native SDK bridge. |
11 | | -- `native_bridge/mock/mock_bridge.py` is a no-SDK contract harness for host/native protocol compatibility. |
12 | | -- `native_bridge/src/` contains SDK-agnostic native source scaffold files. They are not a standalone build and intentionally avoid Vectorworks SDK includes. |
13 | | -- `scripts/run-mcp-server.ps1` is the self-bootstrapping MCP entrypoint. It creates `.venv`, installs `requirements.txt`, then launches `server.py`. |
14 | | -- `scripts/register-claude-code.ps1` is the primary Windows setup command. It is idempotent: it refreshes dependencies, generates `vw_start_listener_2024.py` plus the stable `vw_load_listener_2024.py` Vectorworks loader, can copy the loader text to the clipboard, and updates the `vectorworks` MCP server entry. |
15 | | -- `scripts/copy-vectorworks-loader.ps1` is the first-class Vectorworks handoff helper. Use it whenever the user or an agent is unsure what to paste into Vectorworks. |
16 | | -- `plugins/vectorworks/bin/vectorworksctl` is the stable RADAR-style helper. |
17 | | - Prefer `py -3 .\plugins\vectorworks\bin\vectorworksctl agent-install --repo-path $PWD --json` |
18 | | - for fresh-PC setup and `py -3 .\plugins\vectorworks\bin\vectorworksctl doctor --repo-path $PWD --json` |
19 | | - for diagnosis. |
20 | | -- `plugins/vectorworks/` is the Codex plugin. Keep its manifest, skills, scripts, and `.mcp.json` aligned with the repo scripts. |
21 | | - |
22 | | -## Windows Baseline |
23 | | - |
24 | | -- Target environment is Windows 11 PowerShell. |
25 | | -- Prefer `powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ...` for setup scripts. |
26 | | -- Prefer `py -3` for ad-hoc Python checks, but setup scripts should use the repo-local `.venv` after bootstrap. |
27 | | -- Do not assume `python` points to a real interpreter; on Windows it can be a Microsoft Store alias. |
28 | | - |
29 | | -## Bootstrap |
30 | | - |
31 | | -Use this when an agent is pointed at a fresh checkout and only the connector is |
32 | | -being installed: |
33 | | - |
34 | | -```powershell |
35 | | -powershell -ExecutionPolicy Bypass -File .\scripts\bootstrap-agent.ps1 -Verify |
36 | | -``` |
37 | | - |
38 | | -Use this when the bundled plugin helper is available: |
39 | | - |
40 | | -```powershell |
41 | | -py -3 .\plugins\vectorworks\bin\vectorworksctl agent-install --repo-path $PWD --json |
42 | | -``` |
43 | | - |
44 | | -Equivalent Codex-specific command: |
45 | | - |
46 | | -```powershell |
47 | | -powershell -ExecutionPolicy Bypass -File .\scripts\bootstrap-claude-code.ps1 -Verify |
48 | | -``` |
49 | | - |
50 | | -This does not require Vectorworks. It should create/update: |
51 | | - |
52 | | -- `.venv\` |
53 | | -- `vw_start_listener_2024.py` with `os.environ["VW_MCP_MODE"] = "dialog"` |
54 | | -- `vw_load_listener_2024.py`, the stable script/menu loader to paste into Vectorworks |
55 | | -- clipboard contents set to that stable loader script when the desktop clipboard is available |
56 | | -- project `.mcp.json` |
57 | | -- user `~\.claude.json` when the `claude` CLI is not available |
58 | | - |
59 | | -For Codex plugin workflow, use: |
60 | | - |
61 | | -```powershell |
62 | | -claude --plugin-dir C:\path\to\vectorworks-mcp\plugins\vectorworks |
63 | | -``` |
64 | | - |
65 | | -Plugin skills are namespaced as `/vectorworks:setup`, `/vectorworks:ping`, |
66 | | -`/vectorworks:diagnose`, and `/vectorworks:work`. |
67 | | - |
68 | | -If the generated launcher does not set `VW_MCP_MODE=dialog`, rerun |
69 | | -`scripts\register-claude-code.ps1` or `scripts\bootstrap-claude-code.ps1`. |
70 | | - |
71 | | -## Bridge Modes |
72 | | - |
73 | | -| Mode | Use | CAD/API handlers | |
74 | | -|------|-----|------------------| |
75 | | -| Python `dialog` | Current safe fallback agent session | Allowed | |
76 | | -| Python `foreground` | Legacy diagnostic only; can block the UI | Must reject | |
77 | | -| Python `background` | Transport diagnostics only | Must reject | |
78 | | -| Python `win_timer` | Transport diagnostics only | Must reject | |
79 | | -| Native SDK bridge | Long-term non-modal target | Not available until compiled and installed | |
80 | | - |
81 | | -Do not route users to `background` or `win_timer` for real Vectorworks work. |
82 | | -Host tools whose `TOOL_SAFETY` entry has `requires_cad_preflight: true` |
83 | | -auto-block when bridge status is missing or reports `cad_api_safe: false` / |
84 | | -`transport_only: true`; treat that block as authoritative and fix the listener |
85 | | -before retrying CAD work. |
86 | | -Do not claim native non-modal support is installed unless a compiled bridge has |
87 | | -been built from the Vectorworks SDK and smoke-tested in Vectorworks. |
88 | | -Keep the native handler matrix in sync whenever `vw_listener.py` adds, removes, |
89 | | -or renames a handler. |
90 | | - |
91 | | -## Safe Verification |
92 | | - |
93 | | -Run these before handing work back: |
94 | | - |
95 | | -```powershell |
96 | | -.\.venv\Scripts\python.exe -m py_compile server.py vw_listener.py vw_start_listener_2024.py vw_load_listener_2024.py |
97 | | -.\.venv\Scripts\python.exe -m unittest discover -v |
98 | | -powershell -ExecutionPolicy Bypass -File .\scripts\verify-no-vectorworks.ps1 |
99 | | -``` |
100 | | - |
101 | | -For fast diagnosis during setup or while Vectorworks is open, prefer the |
102 | | -structured helper: |
103 | | - |
104 | | -```powershell |
105 | | -py -3 .\plugins\vectorworks\bin\vectorworksctl doctor --repo-path $PWD --json |
106 | | -``` |
107 | | - |
108 | | -Lower-level fallback: |
109 | | - |
110 | | -```powershell |
111 | | -powershell -ExecutionPolicy Bypass -File .\scripts\doctor-vectorworks-mcp.ps1 |
112 | | -``` |
113 | | - |
114 | | -Native SDK bridge readiness is separate and advisory unless the user is |
115 | | -specifically working on the native bridge: |
116 | | - |
117 | | -```powershell |
118 | | -powershell -ExecutionPolicy Bypass -File .\scripts\check-native-bridge-prereqs.ps1 -Advisory |
119 | | -powershell -ExecutionPolicy Bypass -File .\scripts\doctor-native-bridge.ps1 -Json |
120 | | -``` |
121 | | - |
122 | | -For native bridge implementation work, prefer the native doctor's JSON |
123 | | -`nextCommand` and `nextCommandReason`, but use |
124 | | -`scripts\invoke-native-bridge-next.ps1 -Json` as the first execution loop. It |
125 | | -reads and validates `nextCommandSpec`, blocks on missing safety flags / |
126 | | -allow-flags, reports `status`, `missingAllowFlags`, `safetyBlocks`, and |
127 | | -`validationErrors`, runs executable/arguments as an array, and reruns the native |
128 | | -doctor when `rerunDoctorAfter` is true. Treat `invalid_spec` as a hard stop and |
129 | | -only pass missing allow switches after explicit user review. The manual sequence |
130 | | -below is only a |
131 | | -fallback/reference: |
132 | | - |
133 | | -```powershell |
134 | | -powershell -ExecutionPolicy Bypass -File .\scripts\bootstrap-native-bridge.ps1 -InstallVisualStudioBuildTools -DownloadSdk -CloneSdkExamples -PrepareSource |
135 | | -powershell -ExecutionPolicy Bypass -File .\scripts\prepare-native-bridge-source.ps1 -CloneSdkExamples |
136 | | -powershell -ExecutionPolicy Bypass -File .\scripts\build-native-bridge.ps1 |
137 | | -powershell -ExecutionPolicy Bypass -File .\scripts\copy-native-bridge-scaffold.ps1 |
138 | | -powershell -ExecutionPolicy Bypass -File .\scripts\wire-native-bridge-project.ps1 |
139 | | -powershell -ExecutionPolicy Bypass -File .\scripts\build-native-bridge.ps1 |
140 | | -powershell -ExecutionPolicy Bypass -File .\scripts\doctor-native-bridge.ps1 -BuiltArtifact C:\path\to\VectorworksMCPBridge.vwlibrary -Install -WhatIf |
141 | | -powershell -ExecutionPolicy Bypass -File .\scripts\doctor-native-bridge.ps1 -BuiltArtifact C:\path\to\VectorworksMCPBridge.vwlibrary -Install |
142 | | -# Restart Vectorworks, enable/load the native bridge plug-in, then prove phase-0 stop/release first. |
143 | | -powershell -ExecutionPolicy Bypass -File .\scripts\smoke-native-bridge.ps1 -Phase 0 -Stop -Json |
144 | | -``` |
145 | | - |
146 | | -The installer flags are opt-in because they can download large SDK files and |
147 | | -launch the Visual Studio Build Tools installer. |
148 | | -If `check-native-bridge-prereqs.ps1 -Json` reports `sdkArchiveCandidates`, pass |
149 | | -the candidate through `-SdkArchivePath` so setup reuses the downloaded SDK ZIP |
150 | | -instead of downloading it again. |
151 | | -After phase 0 passes, load the native bridge again before running the default |
152 | | -phase-1 read smoke. Do not run the default native smoke against the copied |
153 | | -transport scaffold; it is only valid after real SDK CAD handlers are wired. |
154 | | - |
155 | | -If `.venv` does not exist yet, run: |
156 | | - |
157 | | -```powershell |
158 | | -powershell -ExecutionPolicy Bypass -File .\scripts\run-mcp-server.ps1 -SetupOnly |
159 | | -``` |
160 | | - |
161 | | -## Vectorworks Handoff |
162 | | - |
163 | | -End-to-end tests require the user to open Vectorworks. Do not claim full end-to-end success unless these have happened: |
164 | | - |
165 | | -- Vectorworks 2024/2025 is open. |
166 | | -- The generated `vw_load_listener_2024.py` has been copied with `scripts\copy-vectorworks-loader.ps1`, then pasted into Resource Manager or installed as a Plug-in Manager menu command. It should run the current `vw_start_listener_2024.py` from disk and open a `VW MCP Listener` dialog; leave that dialog open while the agent controls Vectorworks, then stop/close it for manual work. |
167 | | -- Codex has been restarted after MCP registration. |
168 | | -- `/mcp` shows `vectorworks`. |
169 | | -- First tool call is `vw_ping`; do not treat listener startup as fully proven until this works. |
170 | | -- Before real CAD work, prefer `vw_preflight_for_cad` when available. If it blocks, do not call CAD handlers. |
171 | | - |
172 | | -If port `9877` is busy: |
173 | | - |
174 | | -- call `vw_stop_listener` if MCP is reachable, or |
175 | | -- create `C:\Users\<user>\.vectorworks-mcp\STOP`, or |
176 | | -- restart Vectorworks. |
177 | | - |
178 | | -## Safety |
179 | | - |
180 | | -- `vw_run_script` executes trusted Python inside Vectorworks. Ask before using it for destructive document changes. |
181 | | -- Avoid changing user/global MCP configs by hand unless the setup script path is broken. If hand-editing is necessary, back up `~\.claude.json` first. |
182 | | -- Preserve the TCP length-prefixed JSON protocol tests; they are the main no-Vectorworks safety net. |
| 3 | +This repository is the lightweight Codex companion for |
| 4 | +`BhaveshY/vectorworks-mcp`. |
| 5 | + |
| 6 | +Runtime support is strictly native Windows 11 with local Vectorworks 2024/2025. |
| 7 | +Do not add macOS, Linux, WSL, container, Wine, or remote-host fallbacks. |
| 8 | + |
| 9 | +- Do not vendor `server.py`, `vw_listener.py`, native bridge sources, tests, or |
| 10 | + Python dependencies here; keep them in the companion runtime. |
| 11 | +- Keep `plugins/vectorworks/scripts/resolve-vectorworks-mcp-repo.ps1` aligned |
| 12 | + with the companion contract version and required features. |
| 13 | +- Keep repository cloning and listener generation in explicit setup flows. |
| 14 | + Normal MCP startup must fail fast on a missing/stale checkout and should use |
| 15 | + the companion runner's already-prepared dependency cache. |
| 16 | +- Prefer `vw_agent_context` for low-latency planning and bounded context. |
| 17 | +- Require CAD-safe preflight and live capabilities before writes. |
| 18 | +- Preserve confirmation gates and unknown-commit-state handling. |
| 19 | +- Validate all skills, the plugin manifest, Python helper syntax, and |
| 20 | + PowerShell parseability before handoff. |
0 commit comments