tramway 2.1.2.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/AGENTS.md +4 -0
- data/lib/generators/tramway/install/install_generator.rb +43 -12
- data/lib/tramway/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92a090294d94e95de5522b38fd15210388522bdcdd31844fd47d091b7b208011
|
|
4
|
+
data.tar.gz: 06c9928adff35d27dd6bcc92c99fdee5e9d48f7753186309baa46d5999505d8d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 790773b5ff343ca1eb92629215e39f722a1c4638133ca44960a317ad1b9e7805107ba1beed6cc1c597585314e3fe78027fabc8f266515e9aabded6b721f4bde7
|
|
7
|
+
data.tar.gz: e0d6ef70d2a1769736343a1104dbdade1aec992e52e604453f495b094f28fd8287dba0d62d52fb063905b9d9c6fa46c28feb65b29f743ab96640a502979d6ba2
|
data/docs/AGENTS.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
## Start of Tramway AGENTS.md
|
|
2
|
+
|
|
1
3
|
# AGENTS.md: Tramway Code Generation Standards
|
|
2
4
|
|
|
3
5
|
This document guides AI-assisted code generation for Rails applications built with **Tramway**. It is designed for founders, designers, PMs, and engineers who rely on AI tools (ChatGPT/Copilot/etc.) to build maintainable Rails code that fits Tramway’s conventions without a senior engineer reworking everything.
|
|
@@ -160,3 +162,5 @@ end
|
|
|
160
162
|
- [ ] Controller actions are concise with guard clauses.
|
|
161
163
|
- [ ] Reusable UI is a ViewComponent using Tailwind utilities and accessible semantics.
|
|
162
164
|
- [ ] Tailwind safelist covers dynamic classes.
|
|
165
|
+
|
|
166
|
+
## End of Tramway AGENTS.md
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rails/generators'
|
|
4
4
|
require 'fileutils'
|
|
5
|
+
require 'net/http'
|
|
5
6
|
|
|
6
7
|
module Tramway
|
|
7
8
|
module Generators
|
|
@@ -49,16 +50,32 @@ module Tramway
|
|
|
49
50
|
@agents_file_path ||= File.join(destination_root, 'AGENTS.md')
|
|
50
51
|
end
|
|
51
52
|
|
|
52
|
-
def
|
|
53
|
-
|
|
53
|
+
def agents_template_url
|
|
54
|
+
'https://raw.githubusercontent.com/TrinityMonsters/tramway/refs/heads/main/docs/AGENTS.md'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def agents_template_body
|
|
58
|
+
return @agents_template_body if defined?(@agents_template_body)
|
|
59
|
+
|
|
60
|
+
uri = URI.parse(agents_template_url)
|
|
61
|
+
response = Net::HTTP.get_response(uri)
|
|
62
|
+
@agents_template_body = response.body.to_s
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def agents_section_start
|
|
66
|
+
'## Start of Tramway AGENTS.md'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def agents_section_end
|
|
70
|
+
'## End of Tramway AGENTS.md'
|
|
54
71
|
end
|
|
55
72
|
|
|
56
73
|
def agents_template
|
|
57
|
-
@agents_template ||=
|
|
74
|
+
@agents_template ||= [agents_section_start, agents_template_body.rstrip, agents_section_end].join("\n")
|
|
58
75
|
end
|
|
59
76
|
|
|
60
|
-
def
|
|
61
|
-
|
|
77
|
+
def agents_section_present?(content)
|
|
78
|
+
content.include?(agents_section_start) && content.include?(agents_section_end)
|
|
62
79
|
end
|
|
63
80
|
|
|
64
81
|
def create_tailwind_config
|
|
@@ -99,11 +116,9 @@ module Tramway
|
|
|
99
116
|
line[/^\s*/] || ' '
|
|
100
117
|
end
|
|
101
118
|
|
|
102
|
-
def
|
|
119
|
+
def insert_agents_template(content)
|
|
103
120
|
separator = agents_separator(content)
|
|
104
|
-
|
|
105
|
-
file.write("#{separator}#{agents_template}")
|
|
106
|
-
end
|
|
121
|
+
"#{content}#{separator}#{agents_template}"
|
|
107
122
|
end
|
|
108
123
|
|
|
109
124
|
def agents_separator(content)
|
|
@@ -111,6 +126,15 @@ module Tramway
|
|
|
111
126
|
|
|
112
127
|
content.end_with?("\n") ? "\n" : "\n\n"
|
|
113
128
|
end
|
|
129
|
+
|
|
130
|
+
def replace_agents_section(content)
|
|
131
|
+
return insert_agents_template(content) unless agents_section_present?(content)
|
|
132
|
+
|
|
133
|
+
content.sub(
|
|
134
|
+
/#{Regexp.escape(agents_section_start)}.*?#{Regexp.escape(agents_section_end)}/m,
|
|
135
|
+
agents_template
|
|
136
|
+
)
|
|
137
|
+
end
|
|
114
138
|
end
|
|
115
139
|
|
|
116
140
|
# Running `rails generate tramway:install` will invoke this generator
|
|
@@ -121,12 +145,19 @@ module Tramway
|
|
|
121
145
|
desc 'Installs Tramway dependencies and Tailwind safelist configuration.'
|
|
122
146
|
|
|
123
147
|
def ensure_agents_file
|
|
124
|
-
|
|
148
|
+
say_status(
|
|
149
|
+
:info,
|
|
150
|
+
"Tramway will replace the content between \"#{agents_section_start}\" and " \
|
|
151
|
+
"\"#{agents_section_end}\" in AGENTS.md."
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
return create_file(agents_file_path, "#{agents_template}\n") unless File.exist?(agents_file_path)
|
|
125
155
|
|
|
126
156
|
content = File.read(agents_file_path)
|
|
127
|
-
|
|
157
|
+
updated = replace_agents_section(content)
|
|
158
|
+
return if updated == content
|
|
128
159
|
|
|
129
|
-
|
|
160
|
+
File.write(agents_file_path, updated)
|
|
130
161
|
end
|
|
131
162
|
|
|
132
163
|
def ensure_dependencies
|
data/lib/tramway/version.rb
CHANGED