From 4bb39622b936eb7ea6aac4ba690c3038788e5988 Mon Sep 17 00:00:00 2001 From: Konstantin Vyatkin Date: Tue, 7 Apr 2026 00:31:39 +0200 Subject: [PATCH 1/3] fix: add module docstrings to molt.star files for buildifier compliance Starlark files require a module docstring as their first statement per the buildifier module-docstring rule. Adds docstrings to all fixture molt.star files and to the init command's generated template. Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/module/config.go | 3 ++- .../bare_python_repo_with_uv_deps/molt.star | 2 ++ .../conflicting_owned_fields/molt.star | 2 ++ .../core_structured_file_primitives/molt.star | 2 ++ .../core_tasks_with_triggers/molt.star | 2 ++ tests/fixtures/drifted_owned_fields/molt.star | 2 ++ .../go_lint_vscode_component/molt.star | 2 ++ .../opaque_root_with_python_child/molt.star | 2 ++ .../upgraded_template_v1_to_v2/molt.star | 2 ++ .../uv_workspace_with_nested_root/molt.star | 2 ++ .../__snapshots__/integration_test.snap | 20 +++++++++++++++++++ 11 files changed, 40 insertions(+), 1 deletion(-) diff --git a/internal/module/config.go b/internal/module/config.go index 9305d72..85b1416 100644 --- a/internal/module/config.go +++ b/internal/module/config.go @@ -67,7 +67,8 @@ func InitRepository(root string) (string, error) { } content := fmt.Sprintf( - "python = use(%q)\n\nroot = python.python_project(\n name = %q,\n path = \".\",\n version = %q,\n requires_python = %q,\n)\n", + "\"\"\"Moltark configuration for %s.\"\"\"\n\npython = use(%q)\n\nroot = python.python_project(\n name = %q,\n path = \".\",\n version = %q,\n requires_python = %q,\n)\n", + name, model.ModuleSourcePython, name, version, diff --git a/tests/fixtures/bare_python_repo_with_uv_deps/molt.star b/tests/fixtures/bare_python_repo_with_uv_deps/molt.star index b77176e..ec6ae6a 100644 --- a/tests/fixtures/bare_python_repo_with_uv_deps/molt.star +++ b/tests/fixtures/bare_python_repo_with_uv_deps/molt.star @@ -1,3 +1,5 @@ +"""A bare Python project with uv dependency management.""" + python = use("moltark/python") python.python_project( diff --git a/tests/fixtures/conflicting_owned_fields/molt.star b/tests/fixtures/conflicting_owned_fields/molt.star index 05708a3..2b71f5e 100644 --- a/tests/fixtures/conflicting_owned_fields/molt.star +++ b/tests/fixtures/conflicting_owned_fields/molt.star @@ -1,3 +1,5 @@ +"""A Python project with conflicting owned field values.""" + python = use("moltark/python") python.python_project( diff --git a/tests/fixtures/core_structured_file_primitives/molt.star b/tests/fixtures/core_structured_file_primitives/molt.star index 83dc107..a5cf578 100644 --- a/tests/fixtures/core_structured_file_primitives/molt.star +++ b/tests/fixtures/core_structured_file_primitives/molt.star @@ -1,3 +1,5 @@ +"""A workspace managing structured JSON, TOML, and YAML files.""" + core = use("moltark/core") repo = core.project( diff --git a/tests/fixtures/core_tasks_with_triggers/molt.star b/tests/fixtures/core_tasks_with_triggers/molt.star index 0456bbc..7468f5d 100644 --- a/tests/fixtures/core_tasks_with_triggers/molt.star +++ b/tests/fixtures/core_tasks_with_triggers/molt.star @@ -1,3 +1,5 @@ +"""A uv workspace with tasks, triggers, and bootstrap requirements.""" + python = use("moltark/python") uv = use("astral/uv") core = use("moltark/core") diff --git a/tests/fixtures/drifted_owned_fields/molt.star b/tests/fixtures/drifted_owned_fields/molt.star index b77176e..7ecdbc5 100644 --- a/tests/fixtures/drifted_owned_fields/molt.star +++ b/tests/fixtures/drifted_owned_fields/molt.star @@ -1,3 +1,5 @@ +"""A Python project with drifted owned field values.""" + python = use("moltark/python") python.python_project( diff --git a/tests/fixtures/go_lint_vscode_component/molt.star b/tests/fixtures/go_lint_vscode_component/molt.star index efcc5d9..0ef5506 100644 --- a/tests/fixtures/go_lint_vscode_component/molt.star +++ b/tests/fixtures/go_lint_vscode_component/molt.star @@ -1,3 +1,5 @@ +"""A Go project with linting, VS Code integration, and fact-driven config.""" + core = use("moltark/core") app = core.project( diff --git a/tests/fixtures/opaque_root_with_python_child/molt.star b/tests/fixtures/opaque_root_with_python_child/molt.star index 92c2c6a..7c1399c 100644 --- a/tests/fixtures/opaque_root_with_python_child/molt.star +++ b/tests/fixtures/opaque_root_with_python_child/molt.star @@ -1,3 +1,5 @@ +"""A workspace with an opaque root and a nested Python child project.""" + core = use("moltark/core") python = use("moltark/python") diff --git a/tests/fixtures/upgraded_template_v1_to_v2/molt.star b/tests/fixtures/upgraded_template_v1_to_v2/molt.star index b77176e..1d9c408 100644 --- a/tests/fixtures/upgraded_template_v1_to_v2/molt.star +++ b/tests/fixtures/upgraded_template_v1_to_v2/molt.star @@ -1,3 +1,5 @@ +"""A Python project upgraded from template v1 to v2.""" + python = use("moltark/python") python.python_project( diff --git a/tests/fixtures/uv_workspace_with_nested_root/molt.star b/tests/fixtures/uv_workspace_with_nested_root/molt.star index 967cb82..cfd2c9a 100644 --- a/tests/fixtures/uv_workspace_with_nested_root/molt.star +++ b/tests/fixtures/uv_workspace_with_nested_root/molt.star @@ -1,3 +1,5 @@ +"""A uv workspace with a nested root and multiple integration packages.""" + python = use("moltark/python") uv = use("astral/uv") diff --git a/tests/integration/__snapshots__/integration_test.snap b/tests/integration/__snapshots__/integration_test.snap index 4b05d8b..0a843a5 100755 --- a/tests/integration/__snapshots__/integration_test.snap +++ b/tests/integration/__snapshots__/integration_test.snap @@ -67,6 +67,8 @@ stderr: /-/-/-/ == molt.star == +"""Moltark configuration for demo.""" + python = use("moltark/python") root = python.python_project( @@ -213,6 +215,8 @@ stderr: /-/-/-/ == molt.star == +"""A bare Python project with uv dependency management.""" + python = use("moltark/python") python.python_project( @@ -340,6 +344,8 @@ stderr: /-/-/-/ == molt.star == +"""A Python project with drifted owned field values.""" + python = use("moltark/python") python.python_project( @@ -460,6 +466,8 @@ stderr: /-/-/-/ == molt.star == +"""A Python project with conflicting owned field values.""" + python = use("moltark/python") python.python_project( @@ -601,6 +609,8 @@ stderr: /-/-/-/ == molt.star == +"""A Python project upgraded from template v1 to v2.""" + python = use("moltark/python") python.python_project( @@ -1992,6 +2002,8 @@ stderr: /-/-/-/ == molt.star == +"""A uv workspace with a nested root and multiple integration packages.""" + python = use("moltark/python") uv = use("astral/uv") @@ -3532,6 +3544,8 @@ stderr: /-/-/-/ == molt.star == +"""A uv workspace with tasks, triggers, and bootstrap requirements.""" + python = use("moltark/python") uv = use("astral/uv") core = use("moltark/core") @@ -4553,6 +4567,8 @@ stderr: /-/-/-/ == molt.star == +"""A Go project with linting, VS Code integration, and fact-driven config.""" + core = use("moltark/core") app = core.project( @@ -5263,6 +5279,8 @@ stderr: /-/-/-/ == molt.star == +"""A workspace with an opaque root and a nested Python child project.""" + core = use("moltark/core") python = use("moltark/python") @@ -5948,6 +5966,8 @@ stderr: /-/-/-/ == molt.star == +"""A workspace managing structured JSON, TOML, and YAML files.""" + core = use("moltark/core") repo = core.project( From 9c2e939d74bc15cbcb576d2677847a2abdebfae6 Mon Sep 17 00:00:00 2001 From: Konstantin Vyatkin Date: Tue, 7 Apr 2026 00:44:57 +0200 Subject: [PATCH 2/3] fix: break long fmt.Sprintf template into multi-line concatenation Improves readability of the molt.star template in InitRepository. Addresses: https://github.com/ophidiarium/moltark/pull/16#discussion_r3042037319 Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/module/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/module/config.go b/internal/module/config.go index 85b1416..04e0afd 100644 --- a/internal/module/config.go +++ b/internal/module/config.go @@ -67,7 +67,14 @@ func InitRepository(root string) (string, error) { } content := fmt.Sprintf( - "\"\"\"Moltark configuration for %s.\"\"\"\n\npython = use(%q)\n\nroot = python.python_project(\n name = %q,\n path = \".\",\n version = %q,\n requires_python = %q,\n)\n", + "\"\"\"Moltark configuration for %s.\"\"\"\n\n"+ + "python = use(%q)\n\n"+ + "root = python.python_project(\n"+ + " name = %q,\n"+ + " path = \".\",\n"+ + " version = %q,\n"+ + " requires_python = %q,\n"+ + ")\n", name, model.ModuleSourcePython, name, From c4eb6e82ce22e8c4976c50ba7dd840e15da562ec Mon Sep 17 00:00:00 2001 From: Konstantin Vyatkin Date: Tue, 7 Apr 2026 00:46:08 +0200 Subject: [PATCH 3/3] fix: escape project name in generated molt.star docstring The name variable (from filepath.Base or pyproject.toml) is interpolated into a triple-quoted Starlark string. Use strconv.Quote to backslash-escape special characters so quotes or backslashes in directory names don't produce broken Starlark output. Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/module/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/module/config.go b/internal/module/config.go index 04e0afd..a59ee4f 100644 --- a/internal/module/config.go +++ b/internal/module/config.go @@ -5,6 +5,7 @@ import ( "hash/fnv" "os" "path/filepath" + "strconv" "strings" "github.com/ophidiarium/moltark/internal/filefmt" @@ -66,6 +67,7 @@ func InitRepository(root string) (string, error) { } } + escapedName := strings.TrimSuffix(strings.TrimPrefix(strconv.Quote(name), "\""), "\"") content := fmt.Sprintf( "\"\"\"Moltark configuration for %s.\"\"\"\n\n"+ "python = use(%q)\n\n"+ @@ -75,7 +77,7 @@ func InitRepository(root string) (string, error) { " version = %q,\n"+ " requires_python = %q,\n"+ ")\n", - name, + escapedName, model.ModuleSourcePython, name, version,