brainiac-fizzy 0.0.38 → 0.0.39
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60b4756af9b9f1335e112cc739d5c035f8c93ed535356398d763f917348ccf41
|
|
4
|
+
data.tar.gz: e4a275e05e713999788e05b004ce268ab0eccc09a8ddc964d55480d6c04e15ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 279fb38ec1cab40daf7d326c41235c6e2f8d57ef4c390263360ae9ae876e6d810bbde945fc1bd98f5a415e2c679b75eef07f17df560c2b0440441edc33e3a201
|
|
7
|
+
data.tar.gz: 7eb192d8fca880504c1e0a4d8621a4a30d3c18c91c202117eb6e2395df4278ad84da9f2fa2a5009d7bdc7ee8b396cda9f169e2688dceeea11fe7f7e22f939f1d
|
|
@@ -25,6 +25,10 @@ def prefetch_card_context(card_number, repo_path:, agent_name: nil)
|
|
|
25
25
|
Brainiac::Plugins::Fizzy::Helpers.prefetch_card_context(card_number, repo_path: repo_path, agent_name: agent_name)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def prefetch_followup_context(card_number, repo_path:, agent_name: nil)
|
|
29
|
+
Brainiac::Plugins::Fizzy::Helpers.prefetch_followup_context(card_number, repo_path: repo_path, agent_name: agent_name)
|
|
30
|
+
end
|
|
31
|
+
|
|
28
32
|
def tag_names(tags)
|
|
29
33
|
Brainiac::Plugins::Fizzy::Helpers.tag_names(tags)
|
|
30
34
|
end
|
|
@@ -164,8 +168,8 @@ DEFAULT_COLUMN_IDS = {
|
|
|
164
168
|
# Render planning mode prompt — identical to render_prompt but inserts the planning
|
|
165
169
|
# instructions between PROMPT_CORE and the channel rules. This was originally defined
|
|
166
170
|
# in brainiac core's planning.rb but belongs here after the fizzy extraction.
|
|
167
|
-
def render_planning_prompt(situation_template, vars = {}, brain_context: "", card_context: "",
|
|
168
|
-
channel: :fizzy, board_key: nil)
|
|
171
|
+
def render_planning_prompt(situation_template, vars = {}, brain_context: "", card_context: "", comment_history: "",
|
|
172
|
+
agent_name: AI_AGENT_NAME, channel: :fizzy, board_key: nil)
|
|
169
173
|
plans_dir = Brainiac::Plugins::Fizzy::Planning::PLANS_DIR
|
|
170
174
|
plan_file = File.join(plans_dir, "card-#{vars["CARD_ID"]}-plan.md")
|
|
171
175
|
|
|
@@ -178,6 +182,10 @@ def render_planning_prompt(situation_template, vars = {}, brain_context: "", car
|
|
|
178
182
|
result += plugin_prompt || CHANNEL_PROMPTS.fetch(channel, "")
|
|
179
183
|
result += situation_template
|
|
180
184
|
|
|
185
|
+
# Comment history (for follow-up scenarios): placed AFTER the triggering comment
|
|
186
|
+
# so the agent sees the current request first, then can reference history as needed
|
|
187
|
+
result += comment_history unless comment_history.empty?
|
|
188
|
+
|
|
181
189
|
# Pre-post comment check (same as render_prompt — use plugin-registered lookup)
|
|
182
190
|
plugin_pre_post = Brainiac.channel_pre_post_checks[channel]
|
|
183
191
|
result += plugin_pre_post if plugin_pre_post
|
|
@@ -780,46 +780,58 @@ def build_followup_prompt(ctx, card_number, card_tags, work_dir)
|
|
|
780
780
|
if planning_info
|
|
781
781
|
build_planning_followup_prompt(ctx, card_number, planning_info[:card_id], work_dir)
|
|
782
782
|
elsif work_dir != ctx.project_config["repo_path"]
|
|
783
|
+
# Use split context for follow-ups: card details at top, comment history AFTER triggering comment
|
|
784
|
+
followup_ctx = prefetch_followup_context(card_number, repo_path: work_dir, agent_name: ctx.agent_name)
|
|
783
785
|
render_prompt(PROMPT_FOLLOWUP_WORKTREE,
|
|
784
786
|
ctx.comment_vars.merge("CARD_NUMBER" => card_number, "CARD_ID" => card_number),
|
|
785
787
|
brain_context: build_brain_context(
|
|
786
788
|
agent_name: ctx.agent_name, card_number: card_number,
|
|
787
789
|
project_key: ctx.project_key, comment_body: ctx.plain_text, source: :fizzy
|
|
788
790
|
),
|
|
789
|
-
card_context:
|
|
791
|
+
card_context: followup_ctx[:card_details],
|
|
792
|
+
comment_history: followup_ctx[:comment_history],
|
|
790
793
|
agent_name: ctx.agent_name)
|
|
791
794
|
else
|
|
795
|
+
# Use split context for follow-ups: card details at top, comment history AFTER triggering comment
|
|
796
|
+
followup_ctx = prefetch_followup_context(card_number, repo_path: ctx.project_config["repo_path"],
|
|
797
|
+
agent_name: ctx.agent_name)
|
|
792
798
|
render_prompt(PROMPT_FOLLOWUP_NO_WORKTREE,
|
|
793
799
|
ctx.comment_vars.merge("CARD_INTERNAL_ID" => ctx.card_internal_id, "CARD_ID" => ctx.card_internal_id),
|
|
794
800
|
brain_context: build_brain_context(
|
|
795
801
|
agent_name: ctx.agent_name, project_key: ctx.project_key,
|
|
796
802
|
comment_body: ctx.plain_text, source: :fizzy
|
|
797
803
|
),
|
|
798
|
-
card_context:
|
|
799
|
-
|
|
804
|
+
card_context: followup_ctx[:card_details],
|
|
805
|
+
comment_history: followup_ctx[:comment_history],
|
|
800
806
|
agent_name: ctx.agent_name)
|
|
801
807
|
end
|
|
802
808
|
end
|
|
803
809
|
|
|
804
810
|
def build_planning_followup_prompt(ctx, card_number, card_id, work_dir)
|
|
805
811
|
if work_dir == ctx.project_config["repo_path"]
|
|
812
|
+
# Use split context for follow-ups: card details at top, comment history AFTER triggering comment
|
|
813
|
+
followup_ctx = prefetch_followup_context(card_number, repo_path: ctx.project_config["repo_path"],
|
|
814
|
+
agent_name: ctx.agent_name)
|
|
806
815
|
render_planning_prompt(PROMPT_FOLLOWUP_NO_WORKTREE,
|
|
807
816
|
ctx.comment_vars.merge("CARD_INTERNAL_ID" => ctx.card_internal_id, "CARD_ID" => card_id),
|
|
808
817
|
brain_context: build_brain_context(
|
|
809
818
|
agent_name: ctx.agent_name, project_key: ctx.project_key,
|
|
810
819
|
comment_body: ctx.plain_text, source: :fizzy
|
|
811
820
|
),
|
|
812
|
-
card_context:
|
|
813
|
-
|
|
821
|
+
card_context: followup_ctx[:card_details],
|
|
822
|
+
comment_history: followup_ctx[:comment_history],
|
|
814
823
|
agent_name: ctx.agent_name)
|
|
815
824
|
else
|
|
825
|
+
# Use split context for follow-ups: card details at top, comment history AFTER triggering comment
|
|
826
|
+
followup_ctx = prefetch_followup_context(card_number, repo_path: work_dir, agent_name: ctx.agent_name)
|
|
816
827
|
render_planning_prompt(PROMPT_FOLLOWUP_WORKTREE,
|
|
817
828
|
ctx.comment_vars.merge("CARD_NUMBER" => card_number, "CARD_ID" => card_id),
|
|
818
829
|
brain_context: build_brain_context(
|
|
819
830
|
agent_name: ctx.agent_name, card_number: card_number,
|
|
820
831
|
project_key: ctx.project_key, comment_body: ctx.plain_text, source: :fizzy
|
|
821
832
|
),
|
|
822
|
-
card_context:
|
|
833
|
+
card_context: followup_ctx[:card_details],
|
|
834
|
+
comment_history: followup_ctx[:comment_history],
|
|
823
835
|
agent_name: ctx.agent_name)
|
|
824
836
|
end
|
|
825
837
|
end
|
|
@@ -60,6 +60,35 @@ module Brainiac
|
|
|
60
60
|
context
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
# Split card context for follow-up scenarios:
|
|
64
|
+
# - Returns card_details (title + body) separately from comment_history
|
|
65
|
+
# - This allows placing the triggering comment BEFORE historical comments
|
|
66
|
+
# so agents focus on the current request, not the full card history
|
|
67
|
+
# - Uses fewer comments (5 instead of 15) since the agent has memory
|
|
68
|
+
def prefetch_followup_context(card_number, repo_path:, agent_name: nil)
|
|
69
|
+
env = fizzy_env_for(agent_name || AI_AGENT_NAME)
|
|
70
|
+
card_details = fetch_card_details(card_number, repo_path: repo_path, env: env)
|
|
71
|
+
# Fewer comments for follow-ups — agent has memory from prior sessions
|
|
72
|
+
card_comments = fetch_card_comments(card_number, repo_path: repo_path, env: env, limit: 5)
|
|
73
|
+
|
|
74
|
+
details_context = card_details.empty? ? "" : "## Card Details\n#{card_details}\n\n"
|
|
75
|
+
|
|
76
|
+
# Format comment history as secondary reference (placed after triggering comment)
|
|
77
|
+
history_context = ""
|
|
78
|
+
unless card_comments.empty?
|
|
79
|
+
history_context = <<~HISTORY
|
|
80
|
+
|
|
81
|
+
## Recent Comment History (for reference)
|
|
82
|
+
These are the last few comments on the card. Your PRIMARY focus is the triggering comment above,
|
|
83
|
+
but you can reference this history if needed for context.
|
|
84
|
+
|
|
85
|
+
#{card_comments}
|
|
86
|
+
HISTORY
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
{ card_details: details_context, comment_history: history_context }
|
|
90
|
+
end
|
|
91
|
+
|
|
63
92
|
# Normalize Fizzy tags from webhook hashes ({ "name" => "deploy" })
|
|
64
93
|
# or API strings ("deploy") into a lowercase name list.
|
|
65
94
|
def tag_names(tags)
|
|
@@ -105,12 +134,12 @@ module Brainiac
|
|
|
105
134
|
""
|
|
106
135
|
end
|
|
107
136
|
|
|
108
|
-
def fetch_card_comments(card_number, repo_path:, env:)
|
|
137
|
+
def fetch_card_comments(card_number, repo_path:, env:, limit: 15)
|
|
109
138
|
output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, "--all", chdir: repo_path, env: env)
|
|
110
139
|
comments = JSON.parse(output)["data"] || []
|
|
111
140
|
return "" if comments.empty?
|
|
112
141
|
|
|
113
|
-
comments.last(
|
|
142
|
+
comments.last(limit).map do |c|
|
|
114
143
|
body = c.dig("body", "plain_text") || ""
|
|
115
144
|
body = "#{body[0..500]}..." if body.length > 500
|
|
116
145
|
"**#{c.dig("creator", "name")}** (#{c["id"]}):\n#{body}"
|
|
@@ -78,31 +78,40 @@ module Brainiac
|
|
|
78
78
|
PROMPT
|
|
79
79
|
|
|
80
80
|
FOLLOWUP_WORKTREE = <<~'PROMPT'
|
|
81
|
-
|
|
82
|
-
You are in the existing worktree for this card.
|
|
81
|
+
## ⚠️ CURRENT REQUEST — This is what you need to address NOW
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
**New comment from {{COMMENT_CREATOR}}** on Fizzy card #{{CARD_NUMBER}} (comment ID: {{COMMENT_ID}}):
|
|
85
84
|
"""
|
|
86
85
|
{{COMMENT_BODY}}
|
|
87
86
|
"""
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
**Your task:** This comment is your PRIMARY focus. What the user says HERE takes priority.
|
|
89
|
+
- If you were given a multi-step task and this comment clarifies/modifies one step, apply the clarification AND still complete the other steps
|
|
90
|
+
- If the user asks a new question, answer that question — don't summarize prior work
|
|
91
|
+
- If the user requests a specific change, make that change
|
|
92
|
+
- Check your memory file for context on what's already been discussed/decided
|
|
93
|
+
|
|
94
|
+
You are in the existing worktree for this card. If you've already addressed what's being asked in a previous session, reply confirming it's done.
|
|
91
95
|
|
|
92
96
|
**Response destination: Post your response as a comment on Fizzy card #{{CARD_NUMBER}}.**
|
|
93
97
|
Do NOT post comments on the GitHub PR — this conversation is happening on the card.
|
|
94
98
|
PROMPT
|
|
95
99
|
|
|
96
100
|
FOLLOWUP_NO_WORKTREE = <<~PROMPT
|
|
97
|
-
|
|
101
|
+
## ⚠️ CURRENT REQUEST — This is what you need to address NOW
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
**New comment from {{COMMENT_CREATOR}}** on Fizzy card (internal_id: "{{CARD_INTERNAL_ID}}") (comment ID: {{COMMENT_ID}}):
|
|
100
104
|
"""
|
|
101
105
|
{{COMMENT_BODY}}
|
|
102
106
|
"""
|
|
103
107
|
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
**Your task:** This comment is your PRIMARY focus. What the user says HERE takes priority.
|
|
109
|
+
- If you were given a multi-step task and this comment clarifies/modifies one step, apply the clarification AND still complete the other steps
|
|
110
|
+
- If the user asks a new question, answer that question — don't summarize prior work
|
|
111
|
+
- If the user requests a specific change, make that change
|
|
112
|
+
- Check your memory file for context on what's already been discussed/decided
|
|
113
|
+
|
|
114
|
+
If you've already addressed what's being asked, reply confirming it's done.
|
|
106
115
|
PROMPT
|
|
107
116
|
|
|
108
117
|
MENTION = <<~PROMPT
|