-
Notifications
You must be signed in to change notification settings - Fork 8
fix(update): skip the framework's own source repo in mapify _update (#462) #463
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||
|
|
||||||
| from __future__ import annotations | ||||||
|
|
||||||
| import tomllib | ||||||
| from dataclasses import dataclass, replace | ||||||
| from datetime import UTC, datetime | ||||||
| from enum import StrEnum | ||||||
|
|
@@ -45,6 +46,33 @@ | |||||
| LOCK_TIMEOUT_SECONDS = 0.0 | ||||||
| REFRESH_BARRIER_TIMEOUT_SECONDS = 0.0 | ||||||
|
|
||||||
| FRAMEWORK_SOURCE_REPO_MESSAGE = ( | ||||||
| "This project is the mapify-cli source repository; its provider trees are " | ||||||
| "rendered from src/mapify_cli/templates_src/ by `make render-templates` " | ||||||
| "and are never installed by the updater." | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def is_framework_source_repo(project_path: Path) -> bool: | ||||||
| """Return True when ``project_path`` is the mapify-cli source repository. | ||||||
|
|
||||||
| The framework repo's generated trees (``.claude/``, ``.codex/``, | ||||||
| ``.agents/``, ``.map/scripts/``) are fence-free renders of | ||||||
| ``src/mapify_cli/templates_src/``. Running the provider refresh there | ||||||
| re-installs the shipped templates with fences and ``MAP-MANAGED`` headers | ||||||
| over 100+ tracked files and leaves a ``.bak`` beside each (#462). | ||||||
| """ | ||||||
| project_path = Path(project_path) | ||||||
| if not (project_path / "src" / "mapify_cli" / "templates_src").is_dir(): | ||||||
| return False | ||||||
| try: | ||||||
| with (project_path / "pyproject.toml").open("rb") as handle: | ||||||
| pyproject = tomllib.load(handle) | ||||||
| except (OSError, tomllib.TOMLDecodeError): | ||||||
|
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Handle non-UTF-8
Proposed fix- except (OSError, tomllib.TOMLDecodeError):
+ except (OSError, UnicodeDecodeError, tomllib.TOMLDecodeError):
return False📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| return False | ||||||
| project = pyproject.get("project") | ||||||
| return isinstance(project, dict) and project.get("name") == "mapify-cli" | ||||||
|
|
||||||
|
|
||||||
| class UpdateMode(StrEnum): | ||||||
| """Whether an update check was initiated by a skill or explicitly by a user.""" | ||||||
|
|
@@ -714,6 +742,17 @@ def check_and_update( | |||||
|
|
||||||
| completed_result: UpdateResult | None = None | ||||||
| try: | ||||||
| if is_framework_source_repo(project_path): | ||||||
| # Intent: the framework repo is never an install target. Its | ||||||
| # generated trees are the rendered source of truth (#462). | ||||||
| if mode is UpdateMode.AUTOMATIC: | ||||||
| return UpdateResult( | ||||||
| UpdateStatus.SKIPPED, | ||||||
| current_version, | ||||||
| message=FRAMEWORK_SOURCE_REPO_MESSAGE, | ||||||
| ) | ||||||
| return _error(current_version, FRAMEWORK_SOURCE_REPO_MESSAGE) | ||||||
|
|
||||||
| if ( | ||||||
| mode is UpdateMode.AUTOMATIC | ||||||
| and not load_map_config(project_path).updates_auto | ||||||
|
|
||||||
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Document the manual source-repository result.
This text documents only automatic preflight behavior. In the same repository,
/map-upgradeand$map-upgradereturn an actionableerrorthat directsmake render-templates; this differs from the existing source/editable-install guidance. Add this case to the manual workflow section.As per coding guidelines: when changing user-facing behavior, update
docs/USAGE.mdwith workflows and CLI usage.🤖 Prompt for AI Agents
Source: Coding guidelines