Skip to content

Commit bc061b0

Browse files
authored
feat: add generation metadata to pyproject.toml (#584)
* feat: add generation metadata to pyproject.toml (R12) Store generation metadata in [tool.agent-starter-pack] section so CLI commands can understand project context. This enables: - enhance command to know original config - extract command to know what to strip - upgrade command to re-template old version for diffing - recommend command to suggest based on current setup - Any generated project to work as a remote template Metadata includes: - Remote template fields: name, description, base_template, agent_directory - Generation context: generated_at, asp_version, deployment_target, session_type, cicd_runner, include_data_ingestion, datastore, frontend_type Includes end-to-end validation tests that create projects, extract metadata, recreate using only metadata, and verify identical scaffolding. * fix: address review feedback for generation metadata - Improve _compare_scaffolding_files to iterate through all SCAFFOLDING_PATTERNS and compare file contents - Use TOML parsing for pyproject.toml comparison instead of line-by-line - Simplify data_ingestion Jinja2 template using | lower filter - Use conditional import pattern for datetime.UTC to support Python 3.10+ instead of globally ignoring UP017 lint rule * refactor: always include all metadata fields with 'none' for unset values Make metadata more consistent and predictable by always including all fields. Fields that are not applicable use 'none' as the value instead of being omitted. This simplifies parsing in CLI commands.
1 parent f268a7f commit bc061b0

File tree

3 files changed

+626
-0
lines changed

3 files changed

+626
-0
lines changed

agent_starter_pack/base_template/pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,21 @@ asyncio_default_fixture_loop_scope = "function"
103103

104104
[tool.hatch.build.targets.wheel]
105105
packages = ["{{cookiecutter.agent_directory}}","frontend"]
106+
107+
[tool.agent-starter-pack]
108+
# Generation metadata - enables CLI commands to understand project context
109+
# These fields allow any generated project to work as a remote template
110+
name = "{{cookiecutter.project_name}}"
111+
description = "{{cookiecutter.agent_description}}"
112+
base_template = "{{cookiecutter.agent_name}}"
113+
agent_directory = "{{cookiecutter.agent_directory}}"
114+
115+
# Generation context
116+
generated_at = "{{cookiecutter.generated_at}}"
117+
asp_version = "{{cookiecutter.package_version}}"
118+
deployment_target = "{{cookiecutter.deployment_target}}"
119+
session_type = "{{cookiecutter.session_type or 'none'}}"
120+
cicd_runner = "{{cookiecutter.cicd_runner}}"
121+
include_data_ingestion = {{ cookiecutter.data_ingestion | lower }}
122+
datastore = "{{cookiecutter.datastore_type or 'none'}}"
123+
frontend_type = "{{cookiecutter.frontend_type}}"

agent_starter_pack/cli/utils/template.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@
2222
import sys
2323
import tempfile
2424
from dataclasses import dataclass
25+
from datetime import datetime
2526
from typing import Any
2627

28+
if sys.version_info >= (3, 11):
29+
from datetime import UTC
30+
else:
31+
from datetime import timezone
32+
33+
UTC = timezone.utc # noqa: UP017 - Required for Python 3.10 compatibility
34+
2735
import yaml
2836
from cookiecutter.main import cookiecutter
2937
from rich.console import Console
@@ -1022,6 +1030,7 @@ def get_agent_directory(
10221030
"project_name": project_name,
10231031
"agent_name": agent_name,
10241032
"package_version": get_current_version(),
1033+
"generated_at": datetime.now(tz=UTC).isoformat(),
10251034
"agent_description": template_config.get("description", ""),
10261035
"example_question": template_config.get("example_question", "").ljust(
10271036
61

0 commit comments

Comments
 (0)