feat: Add bundles and allow for basic FastAPI session interaction #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #4
This adds "bundles", bundles group policies together which clients can opt in to.
Universal policies (those with no bundles) always run. The client also includes a new option,
--bundlewhich makes the client request the activation of those policies.For example you might have a project in which you use
uvand instead of interacting withpiporpython:agent-policies/src/devleaps/policies/example/main.py
Lines 48 to 68 in 6e7c071
But not all your projects might be using
uv, which would make this policy complicated for regular Python projects. With the new feature, you can put theuvpolicies under a bundle, like so:agent-policies/src/devleaps/policies/example/main.py
Line 78 in 6e7c071
And run the client with
--bundle uvto enable that rule. You can add as many rules and middleware as you like on one bundle.In addition, this PR adds a small wrapper around FastAPI's session mechanism. Events from Claude Code and Cursor both have a session-id, this is used more or less as a session cookie. That way, you can make policies that enable only when certain actions have or have not occurred for earlier steps. As a simple example, one could make a policy that disallows git commit without first running tests.