-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement build pipeline — doc/code generation + deployer (#8, #9, #10) #32
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
Empty file.
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,88 @@ | ||
| import json | ||
| import logging | ||
| import re | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| # Directories and patterns that LLM-generated files must never target. | ||
| _BLOCKED_PATH_PREFIXES = ( | ||
| ".github/", | ||
| ".git/", | ||
| ".env", | ||
| ".gradient/", | ||
| ) | ||
|
|
||
| _BLOCKED_EXACT_FILES = { | ||
| ".env", | ||
| ".gitignore", | ||
| "Dockerfile", | ||
| } | ||
|
|
||
|
|
||
| def parse_json_response(content: str, default: dict) -> dict: | ||
| """Parse an LLM response that should contain JSON. | ||
|
|
||
| Strips markdown fences, attempts ``json.loads``, and falls back to | ||
| extracting the first ``{...}`` block via regex. On total failure | ||
| the *default* dict is returned with the raw response attached under | ||
| the ``raw_response`` key. | ||
| """ | ||
| content = content.strip() | ||
| if content.startswith("```"): | ||
| content = re.sub(r"^```(?:json)?\n?", "", content) | ||
| content = re.sub(r"\n?```$", "", content) | ||
|
|
||
| try: | ||
| return json.loads(content) | ||
| except json.JSONDecodeError: | ||
| json_match = re.search(r"\{[\s\S]*\}", content) | ||
| if json_match: | ||
| try: | ||
| return json.loads(json_match.group()) | ||
| except json.JSONDecodeError: | ||
| logger.warning( | ||
| "Failed to parse extracted JSON block (length=%d)", | ||
| len(json_match.group()), | ||
| ) | ||
|
|
||
| logger.warning( | ||
| "Returning default for unparseable LLM response (length=%d)", | ||
| len(content), | ||
| ) | ||
| result = dict(default) | ||
| result["raw_response"] = content[:500] | ||
| return result | ||
|
|
||
|
|
||
| def slugify(value: object, *, max_length: int = 0, fallback: str = "vibedeploy-app") -> str: | ||
| """Convert *value* to a URL/repo-safe slug. | ||
|
|
||
| * Non-alphanumeric characters (except hyphens) are removed. | ||
| * Whitespace and underscores become single hyphens. | ||
| * Consecutive hyphens are collapsed. | ||
| * If *max_length* > 0 the slug is truncated and trailing hyphens | ||
| are stripped. | ||
| """ | ||
| text = str(value) if value else "" | ||
| clean = re.sub(r"[^a-zA-Z0-9\s-]", "", text).strip().lower() | ||
| clean = re.sub(r"[\s_]+", "-", clean) | ||
| clean = re.sub(r"-+", "-", clean) | ||
| if max_length > 0: | ||
| clean = clean[:max_length].strip("-") | ||
| return clean or fallback | ||
|
|
||
|
|
||
| def is_safe_file_path(path: str) -> bool: | ||
| """Return ``True`` when *path* is safe to write to a generated repo. | ||
|
|
||
| Blocks sensitive directories (``.github/``, ``.git/``) and files | ||
| (``.env``, ``Dockerfile``) that could be exploited via prompt | ||
| injection. | ||
| """ | ||
| normalized = path.lstrip("/") | ||
| if normalized in _BLOCKED_EXACT_FILES: | ||
| return False | ||
| for prefix in _BLOCKED_PATH_PREFIXES: | ||
| if normalized.startswith(prefix): | ||
| return False | ||
| return True | ||
|
Comment on lines
+75
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 민감 경로 차단이
🤖 Prompt for AI Agents |
||
Oops, something went wrong.
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.
최상위 JSON이 객체가 아닐 때 호출부가 바로 깨집니다.
json.loads()는 리스트나 문자열도 정상 파싱으로 반환하는데, 여기서는 타입 검증 없이 그대로 돌려줍니다. 이 유틸을 쓰는agent/nodes/code_generator.py와agent/nodes/doc_generator.py는 곧바로.get()을 호출하므로, 모델이[]나"..."같은 유효한 JSON을 내보내면AttributeError가 납니다. 객체가 아닐 때는default로 폴백해야 합니다.🤖 Prompt for AI Agents