Skip to content

Commit aba53e2

Browse files
committed
Add IoP cookbooks and agent guidance installation
- Introduced new cookbooks for building IoP applications, including general workflows, healthcare workflows, and production settings. - Added a comprehensive guide for registering components in IoP applications. - Created a guide for healthcare AI-assisted coding, emphasizing the use of native IRIS components. - Implemented a production change workflow to manage changes in existing IRIS productions. - Added a validation skill for IoP applications, including unit tests and migration checks. - Enhanced CLI with an option to install agent guidance, allowing users to set up IoP guides and skills easily. - Developed unit tests for the new agent guidance functionality and ensured proper package data declarations.
1 parent 4ff7ea7 commit aba53e2

52 files changed

Lines changed: 2423 additions & 1659 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
### Added
10+
- Add `iop --install-agent-guidance` to install version-matched IoP guidance,
11+
skills, and offline cookbooks into existing application repositories for
12+
Codex, Claude Code, and Gemini CLI.
13+
- Add portable `build-iop-app` and `validate-iop-app` Agent Skills that can also
14+
be installed directly from the framework repository.
15+
- Preserve existing project instructions through idempotent managed blocks,
16+
with agent selection, conflict preflight, and explicit forced refresh support.
17+
18+
### Changed
19+
- Make the packaged Agent Skill references the source of truth for IoP
20+
cookbooks and related AI guidance; MkDocs pages include them using the same
21+
snippet pattern as the changelog.
22+
823
## [4.1.0] - 2026-07-16
924
### Changed
1025
- Move remote debugging support to the optional `debug` extra. Install

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ include LICENSE
33
include AGENTS.md
44
include mkdocs.yml
55
recursive-include docs *.md
6+
recursive-include src/iop/ai *.md

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ Welcome to **Interoperability On Python (IoP)**, a production-stable Python-firs
1111
Documentation can be found [here](https://grongierisc.github.io/interoperability-embedded-python/).
1212
For prompt-driven workflows, see [AI-assisted coding with IoP](https://grongierisc.github.io/interoperability-embedded-python/ai-coding/).
1313
For task-oriented examples, see the [IoP cookbooks](https://grongierisc.github.io/interoperability-embedded-python/cookbooks/).
14-
For application repositories, start from the [reusable AGENTS.md template](https://grongierisc.github.io/interoperability-embedded-python/agents-template/).
14+
For any application repository, install version-matched agent guidance, skills,
15+
and offline cookbooks with:
16+
17+
```bash
18+
iop --install-agent-guidance
19+
```
20+
21+
See [IoP Agent Guidance And Skills](https://grongierisc.github.io/interoperability-embedded-python/agent-guidance/)
22+
for Codex, Claude Code, Gemini CLI, and direct Agent Skills installation.
1523

1624
## Example
1725

docs/agent-guidance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--8<-- "src/iop/ai/skills/build-iop-app/references/agent-guidance.md"

docs/agents-template.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Reusable AGENTS.md For IoP Projects
22

3-
Copy this template into the root of an application repository as `AGENTS.md`.
4-
Keep it generic. Put project-specific details in the project README or in a
5-
short project brief section.
3+
Prefer `iop --install-agent-guidance` to configure Codex, Claude Code, Gemini
4+
CLI, portable skills, and offline cookbooks together. Copy this fallback
5+
template into an application repository as `AGENTS.md` only when the installer
6+
cannot be used. Keep it generic and put project-specific details in the project
7+
README or a short project brief section.
68

79
````md
810
# Agent Guide

docs/ai-coding.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
Use this guide when you want to vibe code with IoP while still getting
44
production-shaped, reviewable Python interoperability code.
55

6+
## Install Project Guidance
7+
8+
IoP can install version-matched guidance, Agent Skills, and offline cookbooks in
9+
any application repository, whether or not it uses the IoP template:
10+
11+
```bash
12+
iop --install-agent-guidance
13+
```
14+
15+
This configures Codex, Claude Code, and Gemini CLI by default. See
16+
[IoP Agent Guidance And Skills](agent-guidance.md) for agent selection, updates,
17+
conflict handling, and direct installation from GitHub.
18+
619
## Start Here
720

821
Ask the tool to read the project guidance before it writes code:
@@ -29,9 +42,9 @@ Show the migration and verification commands.
2942

3043
The IoP framework repository root `AGENTS.md` is for framework source
3144
development, not application guidance. For your own IoP application repository,
32-
copy the
33-
[reusable AGENTS.md template](agents-template.md) into the project root and
34-
adapt it to the local production. For healthcare projects, also read
45+
prefer `iop --install-agent-guidance`; the
46+
[reusable AGENTS.md template](agents-template.md) remains available for manual
47+
setup. For healthcare projects, also read
3548
[Healthcare AI-assisted coding](healthcare-ai-coding.md).
3649

3750
## Cookbooks

docs/command-line.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,34 @@ The CLI uses these terms consistently:
7171
- `unbind` or `unregister`: remove an IOP-generated IRIS proxy class binding.
7272
This does not delete Python source files or production items.
7373
74+
## install agent guidance
75+
76+
Install version-matched IoP project guidance, Agent Skills, and offline
77+
cookbooks without connecting to IRIS:
78+
79+
```bash
80+
iop --install-agent-guidance
81+
```
82+
83+
The current directory and all supported agents are the defaults. Select clients
84+
or another project directory explicitly when needed:
85+
86+
```bash
87+
iop --install-agent-guidance /path/to/project --agent codex
88+
iop --install-agent-guidance --agent claude --agent gemini
89+
```
90+
91+
The command preserves content outside its marked blocks in root instruction
92+
files. It refuses to replace changed IoP-managed assets unless explicitly
93+
requested:
94+
95+
```bash
96+
iop --install-agent-guidance --force-agent-guidance
97+
```
98+
99+
See [IoP Agent Guidance And Skills](agent-guidance.md) for the installed layout
100+
and direct skill installation.
101+
74102
## help
75103
76104
The help command display the help and the default production name.
Lines changed: 1 addition & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1 @@
1-
# Cookbook: Add A BusinessOperation
2-
3-
## When To Use This
4-
5-
Use this cookbook when a production needs an outbound side-effect boundary:
6-
calling an API, writing a file, submitting FHIR, storing data, or wrapping a
7-
technical operation behind a production message.
8-
9-
## Files You Will Touch
10-
11-
- the operation module, such as `bo.py` or `operations.py`
12-
- the message module, such as `msg.py` or `messages.py`
13-
- `settings.py`
14-
- the fastest relevant test or sample payload
15-
16-
## Prompt To Give Your Agent
17-
18-
```text
19-
Add a new IoP BusinessOperation to this project.
20-
21-
Business goal:
22-
<describe what the operation receives, validates, logs, transforms, or sends>
23-
24-
Implementation requirements:
25-
- Reuse existing message classes if they already fit.
26-
- If a new message is needed, define it as a Message dataclass unless there is
27-
a specific need for PersistentMessage.
28-
- Implement a fallback on_message(self, request) for simple operations, or route
29-
by message type with typed one-argument methods or the @handler decorator.
30-
- Return a response message or the original request when that matches the flow.
31-
- Use self.log_info(), self.log_warning(), or self.log_error() for component
32-
logging.
33-
- Do not add startup work to __init__(); use on_init() only if startup work is
34-
required.
35-
- Update settings.py so the operation is added to the Production graph.
36-
- Add or update the fastest relevant test.
37-
- Show the exact verification command.
38-
```
39-
40-
## Expected Implementation
41-
42-
A simple operation can use `on_message()`:
43-
44-
```python
45-
from iop import BusinessOperation
46-
47-
from messages import OrderRequest, OrderResponse
48-
49-
50-
class OrderOperation(BusinessOperation):
51-
def on_message(self, request: OrderRequest) -> OrderResponse:
52-
self.log_info(f"Processing order {request.order_id}")
53-
return OrderResponse(order_id=request.order_id, status="accepted")
54-
```
55-
56-
When one operation handles multiple message types, prefer typed one-argument
57-
methods or the `@handler` decorator:
58-
59-
```python
60-
from iop import BusinessOperation, handler
61-
62-
from messages import CancelOrder, OrderRequest, OrderResponse
63-
64-
65-
class OrderOperation(BusinessOperation):
66-
def on_message(self, request):
67-
self.log_warning(f"Unhandled message {type(request).__name__}")
68-
return request
69-
70-
def submit_order(self, request: OrderRequest) -> OrderResponse:
71-
self.log_info(f"Submitting order {request.order_id}")
72-
return OrderResponse(order_id=request.order_id, status="accepted")
73-
74-
@handler(CancelOrder)
75-
def cancel_order(self, request):
76-
self.log_info(f"Cancelling order {request.order_id}")
77-
return request
78-
```
79-
80-
IoP dispatches to:
81-
82-
- a method decorated with `@handler(MessageType)` first
83-
- a typed one-argument method such as `submit_order(self, request: OrderRequest)`
84-
- `on_message(self, request)` as the fallback
85-
86-
The production graph should register the operation:
87-
88-
```python
89-
operation = prod.operation("OrderOperation", OrderOperation)
90-
```
91-
92-
If another component sends to the operation, declare a `target()` setting on the
93-
sender and connect it:
94-
95-
```python
96-
process = prod.process("OrderProcess", OrderProcess)
97-
process.connect(OrderProcess.Orders, operation)
98-
```
99-
100-
## Migration Command
101-
102-
```bash
103-
iop --migrate settings.py --dry-run
104-
iop --migrate settings.py
105-
```
106-
107-
## Verification
108-
109-
Use the fastest local test first:
110-
111-
```bash
112-
python -m pytest
113-
```
114-
115-
If there is no existing test suite, ask the agent to add a small test for the
116-
pure Python transformation or validation logic.
117-
118-
## Common Mistakes
119-
120-
- Creating an operation but not adding it to `settings.py`.
121-
- Calling another production component as a normal Python object.
122-
- Hiding connection names in strings instead of using `target()` and
123-
`prod.connect(...)`.
124-
- Using `PersistentMessage` when a regular `Message` dataclass is enough.
125-
- Adding multiple handlers for the same message type without making the
126-
intended precedence explicit.
1+
--8<-- "src/iop/ai/skills/build-iop-app/references/cookbooks/add-business-operation.md"
Lines changed: 1 addition & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1 @@
1-
# Cookbook: Add A BusinessProcess
2-
3-
## When To Use This
4-
5-
Use this cookbook when a production needs routing, orchestration, decision
6-
logic, enrichment, or coordination between services and operations.
7-
8-
Business Processes should not own external side effects directly when a
9-
Business Operation is the better boundary. Keep the process focused on deciding
10-
what happens next and sending messages to downstream targets.
11-
12-
## Files You Will Touch
13-
14-
- the process module, such as `bp.py` or `processes.py`
15-
- the message module, such as `msg.py` or `messages.py`
16-
- operation modules only when downstream behavior is missing
17-
- `settings.py`
18-
- tests or sample payloads for routing decisions
19-
20-
## Prompt To Give Your Agent
21-
22-
```text
23-
Add a new IoP BusinessProcess to this project.
24-
25-
Business goal:
26-
<describe the routing, orchestration, enrichment, or decision logic>
27-
28-
Implementation requirements:
29-
- Reuse existing message classes if they already fit.
30-
- Declare outbound routes with target() attributes on the process class.
31-
- Route messages with send_request_sync(), send_request_async(), or direct
32-
response behavior according to the existing project pattern.
33-
- Use on_message(self, request) for simple processes, or route by message type
34-
with typed one-argument methods or the @handler decorator.
35-
- Keep external API calls, database writes, file writes, and FHIR submission in
36-
BusinessOperation classes.
37-
- Do not add startup work to __init__(); use on_init() only if startup work is
38-
required.
39-
- Update settings.py so the process is added to the Production graph and its
40-
targets are connected.
41-
- Add or update tests for routing decisions.
42-
- Show the exact migration and verification commands.
43-
```
44-
45-
## Expected Implementation
46-
47-
A process declares outbound targets and sends messages to them:
48-
49-
```python
50-
from iop import BusinessProcess, Message, handler, target
51-
52-
from messages import OrderRequest, OrderResponse, RejectedOrder
53-
54-
55-
class OrderProcess(BusinessProcess):
56-
Accepted = target()
57-
Rejected = target()
58-
59-
def on_message(self, request):
60-
self.log_warning(f"Unhandled message {type(request).__name__}")
61-
return request
62-
63-
def route_order(self, request: OrderRequest):
64-
if not request.order_id:
65-
return self.send_request_sync(self.Rejected, RejectedOrder(reason="missing id"))
66-
67-
return self.send_request_sync(self.Accepted, request)
68-
69-
@handler(RejectedOrder)
70-
def route_rejected(self, request):
71-
self.log_info(request.reason)
72-
return request
73-
```
74-
75-
IoP dispatches to:
76-
77-
- a method decorated with `@handler(MessageType)` first
78-
- a typed one-argument method such as `route_order(self, request: OrderRequest)`
79-
- `on_message(self, request)` as the fallback
80-
81-
Wire the process in `settings.py`:
82-
83-
```python
84-
process = prod.process("OrderProcess", OrderProcess)
85-
accepted = prod.operation("AcceptedOperation", AcceptedOperation)
86-
rejected = prod.operation("RejectedOperation", RejectedOperation)
87-
88-
process.connect(OrderProcess.Accepted, accepted)
89-
process.connect(OrderProcess.Rejected, rejected)
90-
```
91-
92-
## Migration Command
93-
94-
```bash
95-
iop --migrate settings.py --dry-run
96-
iop --migrate settings.py
97-
```
98-
99-
## Verification
100-
101-
- Unit-test the routing decision with representative messages.
102-
- Dry-run migration shows the process and all target settings.
103-
- The production graph contains every expected process edge.
104-
- Runtime trace shows messages passing from service to process to operation.
105-
106-
## Common Mistakes
107-
108-
- Putting external API calls or database writes directly in the process.
109-
- Forgetting `target()` declarations for outbound routes.
110-
- Returning raw dictionaries instead of message objects when the downstream
111-
component expects IoP messages.
112-
- Adding multiple handlers for the same message type without making the
113-
intended precedence explicit.
114-
- Calling a downstream component directly instead of sending a production
115-
message through a target.
1+
--8<-- "src/iop/ai/skills/build-iop-app/references/cookbooks/add-business-process.md"

0 commit comments

Comments
 (0)