n2b 0.5.0 → 0.5.1
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 +4 -4
- data/lib/n2b/jira_client.rb +69 -69
- data/lib/n2b/llm/ollama.rb +1 -1
- data/lib/n2b/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58ed8c5277d383ecd58f83b79a90e2328161c1cb45dfa70551facef28641d3f1
|
4
|
+
data.tar.gz: 109d222d1867e76458a6b720c2afe3196c37fcab0648773d0311157c04c63086
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c623f7a497b81bec3edf136d18d4ef2f64578bf347334e91dec4feaf01a43dc0deb374d5da74aa0e513b669f55315a835b7c36588e82221dde8d62c8a7728746
|
7
|
+
data.tar.gz: d4687399cf5e2e9d62fca484616bbd48d9c74b03f6c5266e31362978efb44ea4c13fa44708c5097704c9ca63e0616693b016eb79aa97da2bf664f6e18ff7d431
|
data/lib/n2b/jira_client.rb
CHANGED
@@ -111,6 +111,75 @@ module N2B
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
def extract_requirements_from_description(description_string)
|
115
|
+
extracted_lines = []
|
116
|
+
in_requirements_section = false
|
117
|
+
|
118
|
+
# Headers that trigger requirement extraction. Case-insensitive.
|
119
|
+
# Jira often uses h1, h2, etc. for headers, or bold text.
|
120
|
+
# We'll look for lines that *start* with these, possibly after Jira's header markup like "hN. "
|
121
|
+
# Or common text like "Acceptance Criteria:", "Requirements:"
|
122
|
+
# Also include comment-specific implementation keywords
|
123
|
+
requirement_headers_regex = /^(h[1-6]\.\s*)?(Requirements|Acceptance Criteria|Tasks|Key Deliverables|Scope|User Stories|Implementation|Testing|Technical|Additional|Clarification|Comment \d+)/i
|
124
|
+
|
125
|
+
# Regex to identify common list item markers
|
126
|
+
_list_item_regex = /^\s*[\*\-\+]\s+/ # Unused but kept for potential future use
|
127
|
+
# Regex for lines that look like section headers (to stop capturing)
|
128
|
+
# This is a simple heuristic: a line with a few words, ending with a colon, or Jira hN. style
|
129
|
+
section_break_regex = /^(h[1-6]\.\s*)?\w+(\s+\w+){0,3}:?\s*$/i
|
130
|
+
|
131
|
+
|
132
|
+
description_string.to_s.each_line do |line| # Handle nil description_string
|
133
|
+
stripped_line = line.strip
|
134
|
+
|
135
|
+
if stripped_line.match?(requirement_headers_regex)
|
136
|
+
in_requirements_section = true
|
137
|
+
# Add the header itself to the extracted content if desired, or just use it as a trigger
|
138
|
+
# For now, let's add the line to give context.
|
139
|
+
extracted_lines << stripped_line
|
140
|
+
next # Move to the next line
|
141
|
+
end
|
142
|
+
|
143
|
+
if in_requirements_section
|
144
|
+
# If we encounter another significant header, stop capturing this section
|
145
|
+
# (unless it's another requirements header, which is fine)
|
146
|
+
if stripped_line.match?(section_break_regex) && !stripped_line.match?(requirement_headers_regex)
|
147
|
+
# Check if this new header is one of the requirement types. If so, continue.
|
148
|
+
# Otherwise, break. This logic is simplified: if it's any other header, stop.
|
149
|
+
is_another_req_header = false # Placeholder for more complex logic if needed
|
150
|
+
requirement_headers_regex.match(stripped_line) { is_another_req_header = true }
|
151
|
+
|
152
|
+
unless is_another_req_header
|
153
|
+
in_requirements_section = false # Stop capturing
|
154
|
+
# Potentially add a separator if concatenating multiple distinct sections later
|
155
|
+
# extracted_lines << "---"
|
156
|
+
next # Don't include this new non-req header in current section
|
157
|
+
else
|
158
|
+
# It's another requirement-related header, so add it and continue
|
159
|
+
extracted_lines << stripped_line
|
160
|
+
next
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Capture list items or general text within the section
|
165
|
+
# For now, we are quite inclusive of lines within a detected section.
|
166
|
+
# We could be more strict and only take list_item_regex lines,
|
167
|
+
# but often text paragraphs under a heading are relevant too.
|
168
|
+
extracted_lines << stripped_line unless stripped_line.empty?
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
if extracted_lines.empty?
|
173
|
+
# Fallback: return the entire description if no specific sections found
|
174
|
+
return description_string.to_s.strip # Handle nil and strip
|
175
|
+
else
|
176
|
+
# Join extracted lines and clean up excessive newlines
|
177
|
+
# Replace 3+ newlines with 2, and 2+ newlines with 2 (effectively max 2 newlines)
|
178
|
+
# Also, strip leading/trailing whitespace from the final result.
|
179
|
+
return extracted_lines.join("\n").gsub(/\n{3,}/, "\n\n").gsub(/\n{2,}/, "\n\n").strip
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
114
183
|
private
|
115
184
|
|
116
185
|
def process_ticket_data(ticket_data, comments_data)
|
@@ -327,75 +396,6 @@ module N2B
|
|
327
396
|
end
|
328
397
|
end
|
329
398
|
|
330
|
-
def extract_requirements_from_description(description_string)
|
331
|
-
extracted_lines = []
|
332
|
-
in_requirements_section = false
|
333
|
-
|
334
|
-
# Headers that trigger requirement extraction. Case-insensitive.
|
335
|
-
# Jira often uses h1, h2, etc. for headers, or bold text.
|
336
|
-
# We'll look for lines that *start* with these, possibly after Jira's header markup like "hN. "
|
337
|
-
# Or common text like "Acceptance Criteria:", "Requirements:"
|
338
|
-
# Also include comment-specific implementation keywords
|
339
|
-
requirement_headers_regex = /^(h[1-6]\.\s*)?(Requirements|Acceptance Criteria|Tasks|Key Deliverables|Scope|User Stories|Implementation|Testing|Technical|Additional|Clarification|Comment \d+)/i
|
340
|
-
|
341
|
-
# Regex to identify common list item markers
|
342
|
-
_list_item_regex = /^\s*[\*\-\+]\s+/ # Unused but kept for potential future use
|
343
|
-
# Regex for lines that look like section headers (to stop capturing)
|
344
|
-
# This is a simple heuristic: a line with a few words, ending with a colon, or Jira hN. style
|
345
|
-
section_break_regex = /^(h[1-6]\.\s*)?\w+(\s+\w+){0,3}:?\s*$/i
|
346
|
-
|
347
|
-
|
348
|
-
description_string.to_s.each_line do |line| # Handle nil description_string
|
349
|
-
stripped_line = line.strip
|
350
|
-
|
351
|
-
if stripped_line.match?(requirement_headers_regex)
|
352
|
-
in_requirements_section = true
|
353
|
-
# Add the header itself to the extracted content if desired, or just use it as a trigger
|
354
|
-
# For now, let's add the line to give context.
|
355
|
-
extracted_lines << stripped_line
|
356
|
-
next # Move to the next line
|
357
|
-
end
|
358
|
-
|
359
|
-
if in_requirements_section
|
360
|
-
# If we encounter another significant header, stop capturing this section
|
361
|
-
# (unless it's another requirements header, which is fine)
|
362
|
-
if stripped_line.match?(section_break_regex) && !stripped_line.match?(requirement_headers_regex)
|
363
|
-
# Check if this new header is one of the requirement types. If so, continue.
|
364
|
-
# Otherwise, break. This logic is simplified: if it's any other header, stop.
|
365
|
-
is_another_req_header = false # Placeholder for more complex logic if needed
|
366
|
-
requirement_headers_regex.match(stripped_line) { is_another_req_header = true }
|
367
|
-
|
368
|
-
unless is_another_req_header
|
369
|
-
in_requirements_section = false # Stop capturing
|
370
|
-
# Potentially add a separator if concatenating multiple distinct sections later
|
371
|
-
# extracted_lines << "---"
|
372
|
-
next # Don't include this new non-req header in current section
|
373
|
-
else
|
374
|
-
# It's another requirement-related header, so add it and continue
|
375
|
-
extracted_lines << stripped_line
|
376
|
-
next
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
# Capture list items or general text within the section
|
381
|
-
# For now, we are quite inclusive of lines within a detected section.
|
382
|
-
# We could be more strict and only take list_item_regex lines,
|
383
|
-
# but often text paragraphs under a heading are relevant too.
|
384
|
-
extracted_lines << stripped_line unless stripped_line.empty?
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
if extracted_lines.empty?
|
389
|
-
# Fallback: return the entire description if no specific sections found
|
390
|
-
return description_string.to_s.strip # Handle nil and strip
|
391
|
-
else
|
392
|
-
# Join extracted lines and clean up excessive newlines
|
393
|
-
# Replace 3+ newlines with 2, and 2+ newlines with 2 (effectively max 2 newlines)
|
394
|
-
# Also, strip leading/trailing whitespace from the final result.
|
395
|
-
return extracted_lines.join("\n").gsub(/\n{3,}/, "\n\n").gsub(/\n{2,}/, "\n\n").strip
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
399
|
private
|
400
400
|
|
401
401
|
def format_comment_as_adf(comment_data)
|
data/lib/n2b/llm/ollama.rb
CHANGED
@@ -88,7 +88,7 @@ module N2M
|
|
88
88
|
# The prompt_content for diff analysis should instruct the LLM to return JSON.
|
89
89
|
# For Ollama, you can also try adding "format": "json" to the request if the model supports it.
|
90
90
|
request_body = {
|
91
|
-
"model" =>
|
91
|
+
"model" => get_model_name,
|
92
92
|
"messages" => [
|
93
93
|
{
|
94
94
|
"role" => "user",
|
data/lib/n2b/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: n2b
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Nothegger
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
55
|
description: A tool to convert natural language instructions to bash commands using
|
56
|
-
Claude API or OpenAI's GPT. also is
|
56
|
+
Claude API or OpenAI's GPT. also is a quick helper in the console to provide ruby
|
57
57
|
code snippets and explanations or debug exceptions.
|
58
58
|
email:
|
59
59
|
- stefan@kaproblem.com
|