tramway 3.0.4.1 → 3.0.4.2
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/README.md +2 -2
- data/docs/AGENTS.md +1 -1
- data/lib/generators/tramway/install/install_generator.rb +15 -77
- 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: 6df450ba2be14dca796231458310c25cbbc33d51d39de0bbeb7af4d8c0fadba1
|
|
4
|
+
data.tar.gz: 26ded3945beb84b04c0ea7c7916a3a8b1bc9beb14e7df7886a8add7d1bebb983
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 350d5eaf8eb2aadc8b458bc9834340ee34efe36ce4dbec2960214331b89e6979329b1c61c607b7cf64b595fb7c81e62959144d78708755c2e8964872f0f89dd2
|
|
7
|
+
data.tar.gz: 1d7215149e091f8b967fbee6471d68a77c90f57294022f66327626e300759ad31f01d4e30e019c1a17f571e7adba9f09f404089f0960bd129fc1c4918f0c86b7
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Tramway
|
|
2
2
|
Unite Ruby on Rails brilliance. Streamline development with Tramway.
|
|
3
3
|
|
|
4
|
-
Tramway ships with full CRUD (index, show, create, update, destroy) out of the box
|
|
5
|
-
that
|
|
4
|
+
Tramway ships with full CRUD (index, show, create, update, destroy) out of the box. Its install generator also adds a
|
|
5
|
+
Codex instruction that points agents to the Tramway skill for Tramway-native code generation.
|
|
6
6
|
|
|
7
7
|
[](https://rubygems.org/gems/tramway)
|
|
8
8
|
[](https://github.com/Purple-Magic/tramway/actions/workflows/test.yml)
|
data/docs/AGENTS.md
CHANGED
|
@@ -32,7 +32,7 @@ Generated code should:
|
|
|
32
32
|
bin/rails g tramway:install
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
- The install generator appends missing gems, copies Tailwind safelist config, ensures `app/assets/tailwind/application.css` imports Tailwind, and
|
|
35
|
+
- The install generator appends missing gems, copies Tailwind safelist config, ensures `app/assets/tailwind/application.css` imports Tailwind, and adds a Codex instruction to use or install `tramway-skill`.
|
|
36
36
|
|
|
37
37
|
---
|
|
38
38
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rails/generators'
|
|
4
4
|
require 'fileutils'
|
|
5
|
-
require 'net/http'
|
|
6
5
|
|
|
7
6
|
module Tramway
|
|
8
7
|
module Generators
|
|
@@ -86,50 +85,9 @@ module Tramway
|
|
|
86
85
|
@agents_file_path ||= File.join(destination_root, 'AGENTS.md')
|
|
87
86
|
end
|
|
88
87
|
|
|
89
|
-
def
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def agents_template_url
|
|
94
|
-
'https://raw.githubusercontent.com/Purple-Magic/tramway-skill/refs/heads/main/skills/tramway-skill/agents/tramway.md'
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def agents_template_body
|
|
98
|
-
return @agents_template_body if defined?(@agents_template_body)
|
|
99
|
-
|
|
100
|
-
uri = URI.parse(agents_template_url)
|
|
101
|
-
response = Net::HTTP.get_response(uri)
|
|
102
|
-
body = response.body.to_s
|
|
103
|
-
body = body.dup.force_encoding(Encoding::UTF_8)
|
|
104
|
-
@agents_template_body = sanitize_agents_template_body(
|
|
105
|
-
body.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: '')
|
|
106
|
-
)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def sanitize_agents_template_body(content)
|
|
110
|
-
stripped_content = content.strip
|
|
111
|
-
section_pattern = /\A#{Regexp.escape(agents_section_start)}\s*\n?(.*?)\n?#{Regexp.escape(agents_section_end)}\s*\z/m # rubocop:disable Layout/LineLength
|
|
112
|
-
match = stripped_content.match(section_pattern)
|
|
113
|
-
|
|
114
|
-
return stripped_content unless match
|
|
115
|
-
|
|
116
|
-
match[1].to_s.strip
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def agents_section_start
|
|
120
|
-
'## Start of Tramway AGENTS.md'
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def agents_section_end
|
|
124
|
-
'## End of Tramway AGENTS.md'
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def agents_template
|
|
128
|
-
@agents_template ||= [agents_section_start, agents_template_body.rstrip, agents_section_end].join("\n")
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def agents_section_present?(content)
|
|
132
|
-
content.include?(agents_section_start) && content.include?(agents_section_end)
|
|
88
|
+
def codex_agents_instruction
|
|
89
|
+
'If you are Codex, use the tramway-skill skill for Tramway/Rails work in this project. ' \
|
|
90
|
+
'If tramway-skill is not installed, install it from https://github.com/Purple-Magic/tramway-skill/.'
|
|
133
91
|
end
|
|
134
92
|
|
|
135
93
|
def create_tailwind_config
|
|
@@ -170,9 +128,9 @@ module Tramway
|
|
|
170
128
|
line[/^\s*/] || ' '
|
|
171
129
|
end
|
|
172
130
|
|
|
173
|
-
def
|
|
131
|
+
def append_codex_agents_instruction(content)
|
|
174
132
|
separator = agents_separator(content)
|
|
175
|
-
"#{content}#{separator}#{
|
|
133
|
+
"#{content}#{separator}#{codex_agents_instruction}\n"
|
|
176
134
|
end
|
|
177
135
|
|
|
178
136
|
def agents_separator(content)
|
|
@@ -181,15 +139,6 @@ module Tramway
|
|
|
181
139
|
content.end_with?("\n") ? "\n" : "\n\n"
|
|
182
140
|
end
|
|
183
141
|
|
|
184
|
-
def replace_agents_section(content)
|
|
185
|
-
return insert_agents_template(content) unless agents_section_present?(content)
|
|
186
|
-
|
|
187
|
-
content.sub(
|
|
188
|
-
/#{Regexp.escape(agents_section_start)}.*?#{Regexp.escape(agents_section_end)}/m,
|
|
189
|
-
agents_template
|
|
190
|
-
)
|
|
191
|
-
end
|
|
192
|
-
|
|
193
142
|
# rubocop:disable Metrics/MethodLength
|
|
194
143
|
def append_missing_imports(content)
|
|
195
144
|
missing_imports = stimulus_controller_imports.reject { |line| content.include?(line) }
|
|
@@ -226,6 +175,12 @@ module Tramway
|
|
|
226
175
|
updated << insertion
|
|
227
176
|
updated
|
|
228
177
|
end
|
|
178
|
+
|
|
179
|
+
def with_agents_update_fallback
|
|
180
|
+
yield
|
|
181
|
+
rescue StandardError => e
|
|
182
|
+
say_status(:warning, "Skipping AGENTS.md update: #{e.message}")
|
|
183
|
+
end
|
|
229
184
|
end
|
|
230
185
|
# rubocop:enable Metrics/ModuleLength
|
|
231
186
|
|
|
@@ -236,36 +191,19 @@ module Tramway
|
|
|
236
191
|
|
|
237
192
|
desc 'Installs Tramway dependencies and Tailwind safelist configuration.'
|
|
238
193
|
|
|
239
|
-
# rubocop:disable Metrics/MethodLength
|
|
240
194
|
def ensure_agents_file
|
|
241
195
|
with_agents_update_fallback do
|
|
242
|
-
|
|
243
|
-
say_status(:info, "Skipping AGENTS.md update because #{project_tramway_agents_path} exists.")
|
|
244
|
-
return
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
say_status(
|
|
248
|
-
:info,
|
|
249
|
-
"Tramway will replace the content between \"#{agents_section_start}\" and " \
|
|
250
|
-
"\"#{agents_section_end}\" in AGENTS.md."
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
return create_file(agents_file_path, "#{agents_template}\n") unless File.exist?(agents_file_path)
|
|
196
|
+
return create_file(agents_file_path, "#{codex_agents_instruction}\n") unless File.exist?(agents_file_path)
|
|
254
197
|
|
|
255
198
|
content = File.read(agents_file_path)
|
|
256
|
-
|
|
199
|
+
return if content.include?(codex_agents_instruction)
|
|
200
|
+
|
|
201
|
+
updated = append_codex_agents_instruction(content)
|
|
257
202
|
return if updated == content
|
|
258
203
|
|
|
259
204
|
File.write(agents_file_path, updated, mode: 'w:UTF-8')
|
|
260
205
|
end
|
|
261
206
|
end
|
|
262
|
-
# rubocop:enable Metrics/MethodLength
|
|
263
|
-
|
|
264
|
-
def with_agents_update_fallback
|
|
265
|
-
yield
|
|
266
|
-
rescue StandardError => e
|
|
267
|
-
say_status(:warning, "Skipping AGENTS.md update: #{e.message}")
|
|
268
|
-
end
|
|
269
207
|
|
|
270
208
|
def ensure_dependencies
|
|
271
209
|
missing_dependencies = gem_dependencies.reject do |dependency|
|
data/lib/tramway/version.rb
CHANGED