-
Notifications
You must be signed in to change notification settings - Fork 9
Teach agents to file, type, and template new plans #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
engine/app/controllers/coplan/api/v1/plan_types_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| module CoPlan | ||
| module Api | ||
| module V1 | ||
| # Read-only catalog of plan types. Agents fetch this before creating a | ||
| # plan to pick the most specific type and read its template — the | ||
| # template ships here in full because the whole point is that the | ||
| # agent structures its draft against it before writing any content. | ||
| class PlanTypesController < BaseController | ||
| def index | ||
| types = PlanType.order(:name) | ||
| render json: types.map { |pt| | ||
| { | ||
| id: pt.id, | ||
| name: pt.name, | ||
| description: pt.description, | ||
| default_tags: pt.default_tags, | ||
| template_content: pt.template_content | ||
| } | ||
| } | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| require "rails_helper" | ||
|
|
||
| RSpec.describe "Api::V1::PlanTypes", type: :request do | ||
| let(:alice) { create(:coplan_user, :admin) } | ||
| let(:alice_token) { create(:api_token, user: alice, raw_token: "test-token-alice") } | ||
| let(:headers) { { "Authorization" => "Bearer test-token-alice" } } | ||
|
|
||
| before do | ||
| alice_token # ensure token exists | ||
| end | ||
|
|
||
| it "requires auth" do | ||
| get api_v1_plan_types_path | ||
| expect(response).to have_http_status(:unauthorized) | ||
| end | ||
|
|
||
| it "returns every plan type with its template and default tags, sorted by name" do | ||
| create(:plan_type, name: "RFC", description: "Request for comments", default_tags: ["rfc"], template_content: "# RFC\n\n## Problem\n\n## Proposal") | ||
| create(:plan_type, name: "Design Doc", description: "For design documents") | ||
|
|
||
| get api_v1_plan_types_path, headers: headers | ||
|
|
||
| expect(response).to have_http_status(:success) | ||
| types = JSON.parse(response.body) | ||
| expect(types.map { |t| t["name"] }).to eq(["Design Doc", "RFC"]) | ||
|
|
||
| rfc = types.last | ||
| expect(rfc["description"]).to eq("Request for comments") | ||
| expect(rfc["default_tags"]).to eq(["rfc"]) | ||
| expect(rfc["template_content"]).to include("## Proposal") | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Good catch — fixed in 114c1ed.
Plans::Createnow emitsplan_createdviaActiveRecord.after_all_transactions_commit, so a rollback of the wrapping create-and-file transaction no longer leaks the event (outside a transaction it still fires immediately). Covered by new specs: a rolled-back create emits nothing, a successful filed create emits exactly once.