Skip to content

Commit a4f4b1a

Browse files
committed
new option to add text instructions
1 parent 6e97e3c commit a4f4b1a

File tree

2 files changed

+88
-15
lines changed

2 files changed

+88
-15
lines changed

templates/index.jinja

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<div class="relative mb-8">
111111
<div class="w-full h-full absolute inset-0 bg-gray-900 rounded-xl translate-y-2 translate-x-2"></div>
112112
<div class="rounded-xl relative z-20 p-8 border-[3px] border-gray-900 bg-[#E6F2FF]">
113-
<form method="post" class="flex flex-col md:flex-row gap-4">
113+
<form method="post" class="flex flex-col md:flex-row gap-4" onsubmit="prepareFormSubmit(event)">
114114
<div class="relative flex-1">
115115
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0 z-10"></div>
116116
<input
@@ -132,20 +132,49 @@
132132
Generate Dockerfile
133133
</button>
134134
</div>
135+
<input type="hidden" name="additional_instructions_hidden" id="additional_instructions_hidden" value="">
135136
</form>
136137

137-
<!-- Example repositories section -->
138-
<div class="mt-6">
139-
<p class="text-gray-700 mb-3 font-medium">Try these example repositories:</p>
140-
<div class="flex flex-wrap gap-2">
141-
<button onclick="submitExample('https://github.com/cyclotruc/gitingest')"
142-
class="px-4 py-2 bg-[#E6F2FF] hover:bg-[#5A9BF5] text-gray-900 rounded transition-colors duration-200 border-[3px] border-gray-900 relative hover:-translate-y-px hover:-translate-x-px text-sm font-medium">
143-
Gitingest
144-
</button>
145-
<button onclick="submitExample('https://github.com/cyclotruc/gitcontainer')"
146-
class="px-4 py-2 bg-[#E6F2FF] hover:bg-[#5A9BF5] text-gray-900 rounded transition-colors duration-200 border-[3px] border-gray-900 relative hover:-translate-y-px hover:-translate-x-px text-sm font-medium">
147-
Gitcontainer
148-
</button>
138+
<!-- Examples and Additional instructions row -->
139+
<div class="mt-6 flex flex-col md:flex-row md:justify-between md:items-start gap-4">
140+
<!-- Example repositories section -->
141+
<div class="flex-1">
142+
<p class="text-gray-700 mb-3 font-medium">Try these example repositories:</p>
143+
<div class="flex flex-wrap gap-2">
144+
<button onclick="submitExample('https://github.com/cyclotruc/gitingest')"
145+
class="px-4 py-2 bg-[#E6F2FF] hover:bg-[#5A9BF5] text-gray-900 rounded transition-colors duration-200 border-[3px] border-gray-900 relative hover:-translate-y-px hover:-translate-x-px text-sm font-medium">
146+
Gitingest
147+
</button>
148+
<button onclick="submitExample('https://github.com/cyclotruc/gitcontainer')"
149+
class="px-4 py-2 bg-[#E6F2FF] hover:bg-[#5A9BF5] text-gray-900 rounded transition-colors duration-200 border-[3px] border-gray-900 relative hover:-translate-y-px hover:-translate-x-px text-sm font-medium">
150+
Gitcontainer
151+
</button>
152+
</div>
153+
</div>
154+
155+
<!-- Additional instructions checkbox -->
156+
<div class="flex-shrink-0 self-start md:self-center">
157+
<div class="flex items-center">
158+
<input type="checkbox"
159+
id="show_instructions"
160+
onchange="toggleInstructions()"
161+
class="w-4 h-4 text-[#5A9BF5] bg-gray-100 border-gray-300 rounded focus:ring-[#5A9BF5] focus:ring-2">
162+
<label for="show_instructions" class="ml-2 text-gray-700 font-medium">Additional instructions</label>
163+
</div>
164+
</div>
165+
</div>
166+
167+
<!-- Additional instructions textarea (spans full width) -->
168+
<div id="instructions_container" class="hidden mt-4">
169+
<div class="relative">
170+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0 z-10"></div>
171+
<textarea
172+
id="additional_instructions"
173+
name="additional_instructions"
174+
placeholder="e.g., Use Alpine Linux, include specific tools, optimize for production, etc."
175+
rows="3"
176+
class="border-[3px] w-full relative z-20 border-gray-900 placeholder-gray-600 text-sm font-medium focus:outline-none py-3 px-4 rounded resize-none"
177+
></textarea>
149178
</div>
150179
</div>
151180
</div>
@@ -349,6 +378,38 @@
349378
// input.form.submit();
350379
}
351380
381+
// Toggle additional instructions visibility
382+
function toggleInstructions() {
383+
const checkbox = document.getElementById('show_instructions');
384+
const container = document.getElementById('instructions_container');
385+
386+
if (checkbox.checked) {
387+
container.classList.remove('hidden');
388+
container.classList.add('block');
389+
} else {
390+
container.classList.add('hidden');
391+
container.classList.remove('block');
392+
// Clear the textarea when hiding
393+
document.getElementById('additional_instructions').value = '';
394+
}
395+
}
396+
397+
// Prepare form submission by copying additional instructions to hidden input
398+
function prepareFormSubmit(event) {
399+
const checkbox = document.getElementById('show_instructions');
400+
const instructionsTextarea = document.getElementById('additional_instructions');
401+
const hiddenInput = document.getElementById('additional_instructions_hidden');
402+
403+
if (checkbox.checked && instructionsTextarea.value.trim()) {
404+
hiddenInput.value = instructionsTextarea.value.trim();
405+
} else {
406+
hiddenInput.value = '';
407+
}
408+
409+
// Allow form to submit normally
410+
return true;
411+
}
412+
352413
// Monaco Editor setup
353414
let dockerfileEditor = null;
354415
let composeEditor = null;

tools/create_container.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async def create_container_tool(
1515
gitingest_tree: str,
1616
gitingest_content: str,
1717
project_name: Optional[str] = None,
18+
additional_instructions: Optional[str] = None,
1819
max_context_chars: int = 50000, # Limit to stay within context window
1920
websocket: Optional[Any] = None # WebSocket connection for streaming
2021
) -> Dict[str, Any]:
@@ -26,6 +27,7 @@ async def create_container_tool(
2627
gitingest_tree (str): Directory tree from gitingest
2728
gitingest_content (str): Full content from gitingest
2829
project_name (str, optional): Name of the project for the container
30+
additional_instructions (str, optional): Additional instructions for the Dockerfile generation
2931
max_context_chars (int): Maximum characters to send in context
3032
websocket (Any, optional): WebSocket connection for streaming
3133
@@ -46,6 +48,10 @@ async def create_container_tool(
4648
truncated_content = gitingest_content[:max_context_chars] + "\n\n... [Content truncated due to length] ..."
4749

4850
# Create the prompt for Dockerfile generation
51+
additional_instructions_section = ""
52+
if additional_instructions and additional_instructions.strip():
53+
additional_instructions_section = f"\n\nADDITIONAL INSTRUCTIONS:\n{additional_instructions.strip()}"
54+
4955
prompt = f"""Based on the following repository analysis, generate a comprehensive and production-ready Dockerfile.
5056
5157
PROJECT SUMMARY:
@@ -55,7 +61,7 @@ async def create_container_tool(
5561
{gitingest_tree}
5662
5763
SOURCE CODE CONTEXT:
58-
{truncated_content}
64+
{truncated_content}{additional_instructions_section}
5965
6066
Please generate a Dockerfile that:
6167
1. Uses appropriate base images for the detected technology stack
@@ -214,6 +220,7 @@ def run_create_container(
214220
gitingest_tree: str,
215221
gitingest_content: str,
216222
project_name: Optional[str] = None,
223+
additional_instructions: Optional[str] = None,
217224
websocket: Optional[Any] = None
218225
) -> Dict[str, Any]:
219226
"""
@@ -224,13 +231,14 @@ def run_create_container(
224231
gitingest_tree (str): Directory tree from gitingest
225232
gitingest_content (str): Full content from gitingest
226233
project_name (str, optional): Name of the project
234+
additional_instructions (str, optional): Additional instructions for Dockerfile generation
227235
websocket (Any, optional): WebSocket connection for streaming
228236
229237
Returns:
230238
Dict[str, Any]: Dictionary containing generated Dockerfile and metadata
231239
"""
232240
return asyncio.run(create_container_tool(
233-
gitingest_summary, gitingest_tree, gitingest_content, project_name, websocket=websocket
241+
gitingest_summary, gitingest_tree, gitingest_content, project_name, additional_instructions, websocket=websocket
234242
))
235243

236244

@@ -258,6 +266,10 @@ def run_create_container(
258266
"project_name": {
259267
"type": "string",
260268
"description": "Optional name for the project/container"
269+
},
270+
"additional_instructions": {
271+
"type": "string",
272+
"description": "Optional additional instructions for customizing the Dockerfile generation"
261273
}
262274
},
263275
"required": ["gitingest_summary", "gitingest_tree", "gitingest_content"]

0 commit comments

Comments
 (0)