Skip to content

Commit 2e7a665

Browse files
authored
Add Struct Prompt Module and Enhance Devcontainer and CI Configurations (#39)
**Overview** This PR introduces a new prompt module for the Struct tool and updates several configurations to enhance development and automation workflows. **Changes** - **New Additions**: - Added `.github/prompts/struct.prompt.md` to define prompt usage for Struct assistant. - Introduced multiple YAML sub-structs in `struct_module/contribs/github/prompts/` including `generic.yaml`, `react-form.yaml`, `security-api.yaml`, and `struct.yaml`. - Added a comprehensive `README.md` to `struct_module/contribs/` documenting all available sub-structs. - **Configuration Updates**: - Enhanced `.devcontainer/devcontainer.json`: - Removed redundant comments. - Added features for pre-commit, Go Task runner, and shfmt. - Updated mount configurations for improved local development support. - Updated GitHub Actions: - Upgraded `setup-python` in `pre-commit.yaml` from `v5.3.0` to `v5.5.0`. - Improved `release-drafter.yaml` with new checkout step, depth, and version. - Updated `.struct.yaml` to include the new `github/prompts/struct` struct. **Justification** These updates streamline development with enhanced tooling support and prompt-driven Struct generation, while improving CI/CD workflows and environment consistency. **Impact** - Improved developer experience in containerized environments. - Enhanced maintainability and modularity through prompt-based Structs. - Better release management with enriched automation in workflows.
1 parent 4fde6b2 commit 2e7a665

10 files changed

Lines changed: 493 additions & 19 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2-
// README at: https://github.com/devcontainers/templates/tree/main/src/python
31
{
42
"name": "Struct devcontainer",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
63
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
74
"features": {
8-
5+
"ghcr.io/gvatsal60/dev-container-features/pre-commit": {},
6+
"ghcr.io/eitsupi/devcontainer-features/go-task:latest": {},
7+
"ghcr.io/devcontainers-extra/features/shfmt:1" : {}
98
},
10-
11-
// Features to add to the dev container. More info: https://containers.dev/features.
12-
// "features": {},
13-
14-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
15-
// "forwardPorts": [],
16-
17-
// Use 'postCreateCommand' to run commands after the container is created.
189
"postCreateCommand": "bash ./scripts/devcontainer_start.sh",
19-
20-
// Configure tool-specific properties.
2110
"customizations": {
2211
"vscode": {
2312
"extensions": [
@@ -35,7 +24,8 @@
3524
]
3625
}
3726
},
38-
39-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
40-
"remoteUser": "root"
27+
"mounts": [
28+
"type=bind,source=${localWorkspaceFolder},target=/work",
29+
"type=bind,source=/home/${localEnv:USER}/.ssh,target=/home/vscode/.ssh,readonly"
30+
]
4131
}

.github/prompts/struct.prompt.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Struct Assistant
2+
3+
## Role
4+
5+
You are an expert assistant that generates valid `.struct.yaml` files for the [STRUCT tool](https://github.com/httpdss/struct), which automates project structure generation from YAML configuration.
6+
7+
## Defining the `.struct.yaml` file
8+
9+
this file has 3 main keys: `structures`, `folders`, and `variables`.
10+
11+
### Defining structures
12+
13+
The `structures` key is used to define files that are created. Each file path should have a reference to the content it needs to put on the file or the content of the file itself.
14+
For referencing the content of a file, you can use the `file:` key with the path to the file. this can also be a remote https file.
15+
The content of the file can be defined using the `content:` key with a pipe notation (`|`) for multiline content.
16+
17+
```yaml
18+
structures:
19+
- path/to/file.txt:
20+
content: |
21+
This is the content of the file.
22+
- path/to/remote/file.txt:
23+
file: https://example.com/file.txt
24+
```
25+
26+
### Defining folders
27+
28+
The `folders` key is used to define folders that are created. Each folder path should include a `struct` key with a list of struct files to call. Optionally, you can define the value of a variable using the `with:` key.
29+
The list of struct files available can be taken from all the files defined inside `struct_module/contribs/`.
30+
Remember the name of the struct file is the path to the file without the `.yaml` extension.
31+
Read from the struct file to kown the variables that can be used.
32+
33+
```yaml
34+
folders:
35+
- ./path/to/folder/:
36+
struct:
37+
- terraform/module
38+
with:
39+
variable_name: value
40+
- ./:
41+
struct:
42+
- github/prompts/struct
43+
```
44+
45+
### Defining variables
46+
47+
The `variables` key is used to define variables that can be used in the struct files. Each variable should have a description, type, and optional default value.
48+
49+
```yaml
50+
variables:
51+
- variable_name:
52+
description: Description of the variable
53+
type: string
54+
default: default_value
55+
```
56+
57+
## Important notes
58+
59+
- Follow the JSON Schema definition provided in the references.
60+
- Use valid keys: `structures`, `folders`, and `variables`.
61+
- if you want to define files, use the `structures:` key, and a list of file paths that are created. each file path should have a content key.
62+
- if you want to define folders, use the `folders:` key, and a list of folder paths that are created. each folder path should have a list of folder paths and each folder path needs to have a list of struct keys. also if you want to define the value of a variable then you should use the `with:` key.
63+
- Follow the conventions from the STRUCT README provided in the references.
64+
- Include content blocks under `content:` using pipe notation (`|`) when needed.
65+
- Use `permissions`, `skip`, or `skip_if_exists` if specified. This is used only for the `structures` key.
66+
- Use `file:` to reference the content of a file or `content:` to define the content of the file.
67+
- Use `struct:` to define the list of struct files to call for a folder.
68+
- Optionally, use Jinja2 custom filters such as `| latest_release`, `| default_branch`, or `| slugify`.
69+
70+
## Output
71+
72+
Only output the YAML content, no explanation or prose.
73+
74+
## Example usage
75+
76+
- Create a project template for a Python CLI tool
77+
- Generate a Terraform module with `terraform/module` sub-struct
78+
- Using interactive variables for author/project name
79+
80+
If unsure of a value, use sensible defaults or define a variable.
81+
82+
Always return YAML that is syntactically correct and validated against the provided schema.
83+
84+
## References
85+
86+
- [STRUCT json schema](https://raw.githubusercontent.com/httpdss/struct/refs/heads/main/struct-schema.json)
87+
- [STRUCT README](https://raw.githubusercontent.com/httpdss/struct/refs/heads/main/README.md)

.github/workflows/pre-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4.2.2
14-
- uses: actions/setup-python@v5.3.0
14+
- uses: actions/setup-python@v5.5.0
1515
- uses: pre-commit/action@v3.0.1

.github/workflows/release-drafter.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ jobs:
1212
contents: write
1313
pull-requests: write
1414
steps:
15-
- uses: release-drafter/release-drafter@v6
15+
- name: Checkout
16+
uses: actions/checkout@v4.2.2
17+
with:
18+
fetch-depth: 0
19+
- uses: release-drafter/release-drafter@v6.1.0
1620
id: release-drafter
1721
with:
1822
config-name: release-drafter.yml
23+
publish: false
24+
prerelease: false
1925
env:
2026
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.struct.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
folders:
22
- ./:
33
struct:
4+
- github/prompts/struct
45
- github/workflows/pre-commit
56
- github/workflows/release-drafter

0 commit comments

Comments
 (0)