pi-revit 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +167 -0
- package/CHANGELOG.md +465 -430
- package/README.md +604 -548
- package/bin/pi-revit.js +9 -9
- package/docs/architecture.md +271 -0
- package/docs/evaluation.md +434 -0
- package/docs/invariants.json +147 -0
- package/extensions/pi-revit/completion-monitor.ts +55 -0
- package/extensions/pi-revit/contracts.ts +146 -0
- package/extensions/pi-revit/discovery.ts +93 -0
- package/extensions/pi-revit/index.ts +342 -255
- package/extensions/pi-revit/instance-router.ts +86 -86
- package/extensions/pi-revit/platform-prompt.ts +40 -0
- package/extensions/pi-revit/scope-monitor.ts +114 -0
- package/extensions/pi-revit/script-library.ts +144 -144
- package/extensions/pi-revit/tool-catalog.ts +113 -14
- package/extensions/pi-revit/tool-documentation.ts +72 -0
- package/extensions/pi-revit/tool-schema.ts +8 -0
- package/package.json +8 -2
- package/scripts/build.ps1 +9 -9
- package/scripts/check-sdk.ps1 +66 -66
- package/scripts/check-tool-documentation.mjs +287 -0
- package/scripts/deploy.ps1 +16 -16
- package/scripts/generate-contracts.mjs +80 -0
- package/scripts/lib/platform.mjs +226 -0
- package/scripts/test-extension.mjs +15 -0
- package/skills/pi-revit/SKILL.md +30 -218
- package/skills/pi-revit/contracts.generated.json +3524 -0
- package/skills/pi-revit/references/execution-rules.md +41 -0
- package/skills/pi-revit/references/model-audit-export.md +38 -27
- package/skills/pi-revit/references/operation-recovery.md +33 -0
- package/skills/pi-revit/references/room-documentation.md +37 -26
- package/skills/pi-revit/references/tool-index.md +89 -0
- package/skills/pi-revit/references/tools/capture_view.md +62 -0
- package/skills/pi-revit/references/tools/change_element_types.md +65 -0
- package/skills/pi-revit/references/tools/create_tags.md +85 -0
- package/skills/pi-revit/references/tools/delete_elements.md +66 -0
- package/skills/pi-revit/references/tools/execute_csharp.md +81 -0
- package/skills/pi-revit/references/tools/export_documents.md +75 -0
- package/skills/pi-revit/references/tools/find_revit_tools.md +96 -0
- package/skills/pi-revit/references/tools/get_element_details.md +66 -0
- package/skills/pi-revit/references/tools/get_element_relationships.md +61 -0
- package/skills/pi-revit/references/tools/get_element_types.md +67 -0
- package/skills/pi-revit/references/tools/get_elements.md +87 -0
- package/skills/pi-revit/references/tools/get_linked_elements.md +79 -0
- package/skills/pi-revit/references/tools/get_linked_models.md +57 -0
- package/skills/pi-revit/references/tools/get_model_coordinates.md +64 -0
- package/skills/pi-revit/references/tools/get_model_health.md +53 -0
- package/skills/pi-revit/references/tools/get_model_overview.md +57 -0
- package/skills/pi-revit/references/tools/get_revit_operation.md +54 -0
- package/skills/pi-revit/references/tools/get_schedule_fields.md +62 -0
- package/skills/pi-revit/references/tools/get_schedules.md +71 -0
- package/skills/pi-revit/references/tools/manage_element_sets.md +92 -0
- package/skills/pi-revit/references/tools/manage_revit_instances.md +63 -0
- package/skills/pi-revit/references/tools/manage_revit_scripts.md +109 -0
- package/skills/pi-revit/references/tools/manage_schedules.md +90 -0
- package/skills/pi-revit/references/tools/manage_selection.md +66 -0
- package/skills/pi-revit/references/tools/manage_sheet_placements.md +82 -0
- package/skills/pi-revit/references/tools/manage_sheets.md +71 -0
- package/skills/pi-revit/references/tools/manage_views.md +95 -0
- package/skills/pi-revit/references/tools/measure_geometry.md +71 -0
- package/skills/pi-revit/references/tools/open_view.md +59 -0
- package/skills/pi-revit/references/tools/ping.md +41 -0
- package/skills/pi-revit/references/tools/query_spatial_elements.md +74 -0
- package/skills/pi-revit/references/tools/read_revit_result.md +53 -0
- package/skills/pi-revit/references/tools/search_api_docs.md +65 -0
- package/skills/pi-revit/references/tools/set_parameters.md +75 -0
- package/skills/pi-revit/references/tools/summarize_elements.md +64 -0
- package/skills/pi-revit/references/tools/transform_elements.md +79 -0
- package/skills/pi-revit/references/visual-verification.md +36 -0
- package/skills/pi-revit/tool-manifest.json +338 -0
- package/src/Revit/BridgeServer.cs +93 -87
- package/src/Revit/OperationStore.cs +178 -178
- package/src/Revit/ToolRegistry.cs +88 -57
- package/src/Revit/Tools/CaptureView.cs +10 -2
- package/src/Revit/Tools/ChangeElementTypes.cs +74 -60
- package/src/Revit/Tools/ChangeSet.cs +39 -0
- package/src/Revit/Tools/CreateTags.cs +107 -95
- package/src/Revit/Tools/DeleteElements.cs +53 -44
- package/src/Revit/Tools/DocumentGuard.cs +74 -64
- package/src/Revit/Tools/ElementNames.cs +103 -0
- package/src/Revit/Tools/ElementQueryScope.cs +27 -27
- package/src/Revit/Tools/ElementTraits.cs +53 -0
- package/src/Revit/Tools/ExecuteCsharp.cs +54 -45
- package/src/Revit/Tools/ExportDocuments.cs +129 -121
- package/src/Revit/Tools/GetElementDetails.cs +37 -41
- package/src/Revit/Tools/GetElementRelationships.cs +82 -76
- package/src/Revit/Tools/GetElementTypes.cs +8 -0
- package/src/Revit/Tools/GetElements.cs +75 -86
- package/src/Revit/Tools/GetLinkedElements.cs +89 -82
- package/src/Revit/Tools/GetLinkedModels.cs +73 -66
- package/src/Revit/Tools/GetModelCoordinates.cs +56 -49
- package/src/Revit/Tools/GetModelHealth.cs +7 -0
- package/src/Revit/Tools/GetModelOverview.cs +185 -158
- package/src/Revit/Tools/GetScheduleFields.cs +44 -37
- package/src/Revit/Tools/GetSchedules.cs +96 -89
- package/src/Revit/Tools/InheritedState.Summary.cs +57 -0
- package/src/Revit/Tools/InheritedState.cs +144 -0
- package/src/Revit/Tools/ManageElementSets.cs +114 -106
- package/src/Revit/Tools/ManageSchedules.cs +174 -164
- package/src/Revit/Tools/ManageSelection.cs +45 -37
- package/src/Revit/Tools/ManageSheetPlacements.cs +113 -97
- package/src/Revit/Tools/ManageSheets.cs +72 -63
- package/src/Revit/Tools/ManageViews.cs +115 -100
- package/src/Revit/Tools/MeasureGeometry.cs +60 -54
- package/src/Revit/Tools/ModelChanges.cs +154 -0
- package/src/Revit/Tools/ModelEditBatch.cs +105 -102
- package/src/Revit/Tools/ModelEditInputs.cs +49 -49
- package/src/Revit/Tools/OpenView.cs +9 -2
- package/src/Revit/Tools/ParameterResolver.cs +94 -0
- package/src/Revit/Tools/QuerySpatialElements.cs +70 -63
- package/src/Revit/Tools/SearchApiDocs.cs +72 -4
- package/src/Revit/Tools/SetParameters.cs +60 -79
- package/src/Revit/Tools/SpatialBounds.cs +30 -30
- package/src/Revit/Tools/SummarizeElements.cs +94 -87
- package/src/Revit/Tools/ToolContract.cs +48 -0
- package/src/Revit/Tools/ToolSupport.cs +5 -1
- package/src/Revit/Tools/TransformElements.cs +72 -57
- package/workspace/AGENTS.md +26 -20
package/AGENTS.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Contributing to PI-Revit
|
|
2
|
+
|
|
3
|
+
This file guides agents changing **this source repository**. Start with
|
|
4
|
+
[the architecture](docs/architecture.md) for resource ownership and discovery,
|
|
5
|
+
and [evaluation](docs/evaluation.md) for evidence and validation limits.
|
|
6
|
+
Follow the user's requested scope; an investigation does not authorize implementation,
|
|
7
|
+
and a source change does not by itself authorize installation, deployment, publication,
|
|
8
|
+
or changes to a live Revit model.
|
|
9
|
+
|
|
10
|
+
## Two different AGENTS files
|
|
11
|
+
|
|
12
|
+
- **This file:** contributor instructions, repository structure, and checks.
|
|
13
|
+
- **[workspace/AGENTS.md](workspace/AGENTS.md):** template copied into the user's
|
|
14
|
+
Revit working folder by setup. It owns model output locations and local session
|
|
15
|
+
conventions. It is not the contributor guide or the complete tool manual.
|
|
16
|
+
|
|
17
|
+
Pi's global/project instruction scope is separate from resource type. A skill is
|
|
18
|
+
a task-specific entry with optional references; a tool is executable behavior;
|
|
19
|
+
a package distributes them. Do not turn every manual into a separate skill or
|
|
20
|
+
copy all operational guidance into workspace instructions.
|
|
21
|
+
|
|
22
|
+
## Where a change belongs
|
|
23
|
+
|
|
24
|
+
Fix a class of problem where every present and future resource inherits the fix: in a
|
|
25
|
+
shared mechanism, in declared metadata, or in the platform section. A sentence in one
|
|
26
|
+
manual is never the only fix. Each rule has one owner.
|
|
27
|
+
|
|
28
|
+
| Change | Primary owner | Update alongside it |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| Revit operation, inputs, outputs, effects | `src/Revit/Tools/<Tool>.cs` | `ToolRegistry.cs`, manual, focused C# tests |
|
|
31
|
+
| A tool's contract: keywords, limits with alternatives, verification | the tool's `Keywords`/`Limits`/`Verification` (bridge) or `extensions/pi-revit/contracts.ts` (native) | `npm run generate:contracts`; discovery corpus entries |
|
|
32
|
+
| Parameter lookup by name, BuiltInParameter or GUID | `src/Revit/Tools/ParameterResolver.cs`, the only resolver | element-query tests; never `LookupParameter` in a tool |
|
|
33
|
+
| Special or system-owned objects (revision schedules, templates, groups, design options) | `src/Revit/Tools/ElementTraits.cs` | element-traits tests; flag or count, never mix silently |
|
|
34
|
+
| State an object inherits when created from an existing one (duplicate, copy, mirror, retype) | `src/Revit/Tools/InheritedState.cs` (reading) and `InheritedState.Summary.cs` (pure summary) | derived-state tests; the gate requires it wherever a tool duplicates, copies or retypes |
|
|
35
|
+
| Assigning a name or sheet number; name collisions | `src/Revit/Tools/ElementNames.cs`, the only place a tool assigns them | the gate rejects any other `Name`/`SheetNumber` assignment |
|
|
36
|
+
| What a call changed in the model (`model_changes`) | `src/Revit/Tools/ModelChanges.cs` and `ChangeSet.cs`, attached once by the dispatcher in `BridgeServer.cs` | derived-state tests; never report changes per tool |
|
|
37
|
+
| Shared document identity/transaction rules | `src/Revit/Tools/DocumentGuard.cs`, `ModelEditBatch.cs`, related helpers | guard/transaction tests; execution and recovery references |
|
|
38
|
+
| HTTP, queueing, receipt retention | `src/Revit/BridgeServer.cs`, `CommandQueue.cs`, `OperationStore.cs` | receipt/result tests and recovery reference |
|
|
39
|
+
| Cross-cutting protocol (capability, scope/completion, evidence, identity, language) | `extensions/pi-revit/platform-prompt.ts`, stated once for all tools | platform tests; never repeat it per tool or per manual |
|
|
40
|
+
| Completion/loop steering | `extensions/pi-revit/completion-monitor.ts` (metadata-driven) | platform tests; the `modify-*` evaluation scenarios |
|
|
41
|
+
| Objects that predate the request; per-request created-object ledger | `extensions/pi-revit/scope-monitor.ts` (reads `model_changes` and `name_collision`) | scope-monitor tests; the `modify-name-collision` scenario |
|
|
42
|
+
| Pi registration, result presentation, retries | `extensions/pi-revit/index.ts`, `tool-schema.ts` | extension tests and affected manuals |
|
|
43
|
+
| Instance routing | `extensions/pi-revit/instance-router.ts` | instance-router tests and instance manual |
|
|
44
|
+
| Discovery matching and ranking | `extensions/pi-revit/discovery.ts`, `tool-catalog.ts` | `tests/discovery/corpus.json` (recall gate) and catalogue tests |
|
|
45
|
+
| Documentation index, groups, guidance resources | `skills/pi-revit/tool-manifest.json` | regenerate; corpus entry for each new workflow |
|
|
46
|
+
| A "never" or "must" rule | `docs/invariants.json` plus an `<!-- inv:<id> -->` tag on the sentence | a code test, or, only for agent intent, an `agent-eval` scenario |
|
|
47
|
+
| Agent behavior worth measuring | `tests/agent-eval/scenarios.json` | invariants it protects; live runs on a disposable fixture |
|
|
48
|
+
| Reusable script library | `extensions/pi-revit/script-library.ts` | script-library tests and manual |
|
|
49
|
+
| Cross-tool operating rule | `skills/pi-revit/references/` | short entry link only if needed on every task |
|
|
50
|
+
| One public tool's usage | hand-written part of `skills/pi-revit/references/tools/<public_name>.md` | executable examples; the Contract block is generated |
|
|
51
|
+
| A multi-tool task recipe | workflow reference under `skills/pi-revit/references/` | manifest guidance entry, corpus entry and task-based evaluation |
|
|
52
|
+
| Revit subject knowledge | a scoped future `skills/revit-<subject>/SKILL.md` and references | official Autodesk sources and version; discovered automatically; add corpus and routing evaluation |
|
|
53
|
+
| API signatures | existing `search_api_docs` implementation and live version's documentation | search tests; do not maintain a parallel copied API catalogue |
|
|
54
|
+
| Installation or output-folder convention | `scripts/`, `bin/pi-revit.js`, `workspace/AGENTS.md` | README and installer tests |
|
|
55
|
+
|
|
56
|
+
Generated artifacts are never edited by hand: `skills/pi-revit/contracts.generated.json`,
|
|
57
|
+
each manual's `Contract (generated)` block and the tool-index tables. Change the code or
|
|
58
|
+
manifest and run `npm run generate:contracts`; `npm run test:docs` fails when they are stale.
|
|
59
|
+
|
|
60
|
+
Tool vocabulary is English. There are no per-language rules: the model translates a
|
|
61
|
+
request into English search words, replies in the user's language, and reads localized
|
|
62
|
+
Revit names from results. Prefer exact identities (BuiltInParameter, GUID) over display names.
|
|
63
|
+
|
|
64
|
+
The future subject library is an extension point, not an already implemented
|
|
65
|
+
library. Keep one package until independent ownership or releases justify another.
|
|
66
|
+
Names in the table are repository-relative paths, not files to create indiscriminately.
|
|
67
|
+
|
|
68
|
+
## Adding or changing a public tool
|
|
69
|
+
|
|
70
|
+
1. Decide whether it belongs in the Revit bridge or the Pi extension. A bridge
|
|
71
|
+
`ITool` implements metadata/schema and execution, and is registered in
|
|
72
|
+
`src/Revit/ToolRegistry.cs`. Set `Write`, `Effects`, `RequiresDocument` and tier to
|
|
73
|
+
match real behavior. `write: false` does not mean no UI/file effects. Tools with
|
|
74
|
+
`RequiresDocument: false` run off the API thread with no Revit context; do not
|
|
75
|
+
access the Revit API there.
|
|
76
|
+
2. Declare the contract. `Keywords` holds at least 3 English task words, outcome words
|
|
77
|
+
and synonyms. Every `Limits` entry names what the tool does not cover and an
|
|
78
|
+
alternative: another `tool`, `api` members (checked against the installed
|
|
79
|
+
RevitAPI.xml), a `user` action, or `revit_unsupported` with its evidence. A tool
|
|
80
|
+
that writes or has effects declares `Verification`. Prompt guidelines hold only
|
|
81
|
+
tool-specific facts; identity, manual location, capability and completion rules
|
|
82
|
+
live once in the platform section.
|
|
83
|
+
3. Use the shared primitives: `ParameterResolver` for any parameter reference,
|
|
84
|
+
`ElementTraits` for special objects, `ModelEditBatch` for edits, `InheritedState` for
|
|
85
|
+
anything created from an existing object, and `ElementNames` for names and sheet numbers.
|
|
86
|
+
The dispatcher reports `model_changes` for every write tool; do not add a private variant. Preserve enforced
|
|
87
|
+
safeguards. The public bridge contract is the class schema plus registry-added
|
|
88
|
+
`expected_document_id` and extension-added `_operation_id`. Never weaken identity
|
|
89
|
+
guards or receipt routing to make an example pass.
|
|
90
|
+
4. Add the manifest entry (name, source, group, summary) and a manual under
|
|
91
|
+
`references/tools/`. Run `npm run generate:contracts`, which writes the manual's
|
|
92
|
+
Contract block and the tool index. Write the hand part against the final schema
|
|
93
|
+
and actual execution: purpose/preconditions, action differences, effects/identity,
|
|
94
|
+
units/coordinates, result interpretation, recovery and verification. Include at
|
|
95
|
+
least one valid JSON input example and a source pointer. Label example IDs as
|
|
96
|
+
placeholders to discover. A native tool also needs its `NATIVE_CONTRACTS` entry; the
|
|
97
|
+
manifest's native entries reserve its name against bridge descriptors.
|
|
98
|
+
5. Add at least 5 English task phrasings to `tests/discovery/corpus.json`. Register
|
|
99
|
+
any new "never" or "must" rule in `docs/invariants.json` with its test. Add or extend
|
|
100
|
+
an `agent-eval` scenario when the tool changes what the agent can do.
|
|
101
|
+
6. Update `documentation_revision` whenever guidance changes. Compatibility with a
|
|
102
|
+
bridge is the per-tool contract hash (input schema and effects, without wording).
|
|
103
|
+
Do not bump the package release or redeploy unless part of the task.
|
|
104
|
+
7. Run the checks below. Include defaults, rejected inputs, state transitions,
|
|
105
|
+
partial/rollback results and caller-visible outcomes where meaningful. Update the
|
|
106
|
+
README/change log for user-visible behavior. Report live checks separately from
|
|
107
|
+
offline checks.
|
|
108
|
+
|
|
109
|
+
## Maintaining skills and workflows
|
|
110
|
+
|
|
111
|
+
- Keep `skills/pi-revit/SKILL.md` a concise task router with essential cross-tool
|
|
112
|
+
rules. Put detail in linked references. Large collections of tool names do not
|
|
113
|
+
belong in its description. Tools/manuals can also be discovered without loading
|
|
114
|
+
this skill; do not assume the model will always select it.
|
|
115
|
+
- Every workflow distinguishes explanation/planning, inspection, and modification
|
|
116
|
+
or deliverable creation. Do not make an ordinary question open/edit/export a model.
|
|
117
|
+
- Add subject skills only for independently meaningful Revit tasks. Their references
|
|
118
|
+
own modeling concepts, constraints and cited Autodesk Help knowledge, while tool
|
|
119
|
+
manuals own our integration contract. Link between them; do not duplicate both.
|
|
120
|
+
- Put project-specific standards in the user's project context. Source-wide rules
|
|
121
|
+
belong here, and runtime output conventions belong in the workspace template.
|
|
122
|
+
- Keep uncertainty explicit: a supported preview can validate then roll back;
|
|
123
|
+
preview IDs are temporary; a timeout is not cancellation; a commit is not a save.
|
|
124
|
+
Link to recovery/verification instructions instead of inventing another policy.
|
|
125
|
+
|
|
126
|
+
## Validation and completion
|
|
127
|
+
|
|
128
|
+
Run these from the repository root, using Node and .NET 8 SDK or newer. Point
|
|
129
|
+
`PI_CODING_AGENT_PATH` to an installed Pi package containing its `jiti` and
|
|
130
|
+
`typebox` dependencies when they are not locally resolvable. Current extension
|
|
131
|
+
fixtures require this variable; the path below is an example, not a fixed location.
|
|
132
|
+
|
|
133
|
+
```powershell
|
|
134
|
+
$env:PI_CODING_AGENT_PATH = 'C:\path\to\node_modules\@earendil-works\pi-coding-agent'
|
|
135
|
+
npm.cmd run generate:contracts
|
|
136
|
+
npm.cmd run test:docs
|
|
137
|
+
npm.cmd run test:extension
|
|
138
|
+
dotnet run --project tests/document-identity/document-identity-tests.csproj
|
|
139
|
+
dotnet run --project tests/element-query-regressions/element-query-regressions.csproj
|
|
140
|
+
dotnet run --project tests/element-traits/element-traits-tests.csproj
|
|
141
|
+
dotnet run --project tests/derived-state/derived-state-tests.csproj
|
|
142
|
+
git diff --check
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`test:docs` checks actual registered input schemas and source-derived bridge
|
|
146
|
+
metadata without running Revit operations. It also checks that generated artifacts are
|
|
147
|
+
current, that contracts are valid with resolvable alternatives, and that the invariant
|
|
148
|
+
register and its tests agree. It enforces discovery-corpus recall, the startup prompt
|
|
149
|
+
budget and the architecture rules (no model saves, one parameter resolver, special
|
|
150
|
+
objects classified, inherited state reported for created-from-existing objects, names assigned
|
|
151
|
+
through `ElementNames`, model changes attached by the dispatcher). `test:extension` uses isolated mock
|
|
152
|
+
discovery and intercepted HTTP. Neither establishes live API behavior, successful
|
|
153
|
+
drawings, agent instruction adherence, or performance improvement.
|
|
154
|
+
|
|
155
|
+
Use the relevant existing suites for changed components: `tests/model-edit-batch`,
|
|
156
|
+
`transaction-export`, `operation-store`, `element-query-regressions`, `element-traits`, `derived-state`,
|
|
157
|
+
`linked-geometry`, `schedule-fields`, `search-engine`, and `installer` each document
|
|
158
|
+
their scope. Agent behavior is measured with `tests/agent-eval` on a disposable fixture
|
|
159
|
+
(see its README); it never runs as an incidental check. A full bridge build requires matching Revit SDK assemblies; build
|
|
160
|
+
using `scripts/build.ps1`, not deployment, when compilation alone is requested.
|
|
161
|
+
Do not install dependencies, publish a release, modify a live model or deploy an
|
|
162
|
+
add-in as an incidental documentation check.
|
|
163
|
+
|
|
164
|
+
Before completion review the diff, run appropriate checks, and explain what
|
|
165
|
+
changed, why, and what was actually tested. For model-affecting changes, include
|
|
166
|
+
live verification only when performed within the requested scope. See the
|
|
167
|
+
evaluation guide before claiming faster, cheaper, or more reliable agent behavior.
|