tng 0.4.7 → 0.4.9
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 +291 -321
- data/Rakefile +8 -0
- data/bin/tng +292 -17
- data/binaries/go-ui-darwin-amd64 +0 -0
- data/binaries/go-ui-darwin-arm64 +0 -0
- data/binaries/go-ui-linux-amd64 +0 -0
- data/binaries/go-ui-linux-arm64 +0 -0
- data/binaries/tng-darwin-arm64.bundle +0 -0
- data/binaries/tng-darwin-x86_64.bundle +0 -0
- data/binaries/tng-linux-arm64.so +0 -0
- data/binaries/tng-linux-x86_64.so +0 -0
- data/binaries/tng.bundle +0 -0
- data/lib/generators/tng/install_generator.rb +1 -0
- data/lib/tng/services/direct_generation.rb +31 -2
- data/lib/tng/services/test_generator.rb +72 -8
- data/lib/tng/ui/go_ui_session.rb +78 -4
- data/lib/tng/ui/json_session.rb +18 -0
- data/lib/tng/version.rb +1 -1
- metadata +2 -2
data/lib/tng/ui/go_ui_session.rb
CHANGED
|
@@ -256,6 +256,37 @@ module Tng
|
|
|
256
256
|
puts "Trace results error: #{e.message}"
|
|
257
257
|
end
|
|
258
258
|
|
|
259
|
+
# Show X-Ray visualization results
|
|
260
|
+
# @param xray_result [Hash] X-Ray result with mermaid_code
|
|
261
|
+
# @param method_info [Hash] Optional method info for context
|
|
262
|
+
def show_xray_results(xray_result, method_info = {})
|
|
263
|
+
data = {
|
|
264
|
+
mermaid_code: xray_result[:mermaid_code] || xray_result["mermaid_code"] || "",
|
|
265
|
+
explanation: xray_result[:explanation] || xray_result["explanation"] || "Logic flow visualization generated by TNG.",
|
|
266
|
+
method_name: method_info[:name] || method_info["name"] || "",
|
|
267
|
+
class_name: method_info[:class_name] || method_info["class_name"] || ""
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
# Silently copy to clipboard for mermaid.live
|
|
271
|
+
mermaid_code = data[:mermaid_code]
|
|
272
|
+
if RUBY_PLATFORM.include?("darwin")
|
|
273
|
+
IO.popen("pbcopy", "w") { |io| io.print mermaid_code } rescue nil
|
|
274
|
+
elsif RUBY_PLATFORM.include?("linux")
|
|
275
|
+
IO.popen("xclip -selection clipboard", "w") { |io| io.print mermaid_code } rescue nil
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
input_path = _create_temp_file("go_ui_xray", ".json")
|
|
279
|
+
File.write(input_path, JSON.generate(data))
|
|
280
|
+
|
|
281
|
+
begin
|
|
282
|
+
system(@binary_path, "xray-results", "--file", input_path)
|
|
283
|
+
rescue StandardError => e
|
|
284
|
+
puts "X-Ray results error: #{e.message}"
|
|
285
|
+
ensure
|
|
286
|
+
_cleanup_temp_file(input_path)
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
259
290
|
# Show clone detection results
|
|
260
291
|
# @param file_path [String] Original file path analyzed
|
|
261
292
|
# @param results [Hash] Clone detection results { matches: [...] }
|
|
@@ -272,6 +303,35 @@ module Tng
|
|
|
272
303
|
_cleanup_temp_file(input_path)
|
|
273
304
|
end
|
|
274
305
|
|
|
306
|
+
def show_dead_code_results(file_path, results_json)
|
|
307
|
+
parsed = JSON.parse(results_json)
|
|
308
|
+
|
|
309
|
+
# Rust returns {"file": "...", "dead_code": [...]}
|
|
310
|
+
issues = parsed["dead_code"] || []
|
|
311
|
+
|
|
312
|
+
data = {
|
|
313
|
+
file: file_path,
|
|
314
|
+
dead_code: issues.map do |issue|
|
|
315
|
+
{
|
|
316
|
+
type: issue["type"],
|
|
317
|
+
line: issue["line"],
|
|
318
|
+
message: issue["message"],
|
|
319
|
+
code: issue["code"]
|
|
320
|
+
}
|
|
321
|
+
end
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
input_path = _create_temp_file("go_ui_dead_code", ".json")
|
|
325
|
+
File.write(input_path, JSON.generate(data))
|
|
326
|
+
|
|
327
|
+
system(@binary_path, "deadcode", "--file", input_path)
|
|
328
|
+
rescue StandardError => e
|
|
329
|
+
puts "Dead code results error: #{e.message}"
|
|
330
|
+
ensure
|
|
331
|
+
_cleanup_temp_file(input_path)
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
|
|
275
335
|
# Show authentication error
|
|
276
336
|
# @param message [String] Error message to display
|
|
277
337
|
def show_auth_error(message = "Authentication failed")
|
|
@@ -346,7 +406,9 @@ module Tng
|
|
|
346
406
|
{ cmd: "bundle exec tng --file=FILE --method=METHOD", desc: "Direct test generation" },
|
|
347
407
|
{ cmd: "bundle exec tng --file=FILE --method=METHOD --audit", desc: "Direct audit mode" },
|
|
348
408
|
{ cmd: "bundle exec tng --file=FILE --method=METHOD --trace", desc: "Symbolic trace mode" },
|
|
349
|
-
{ cmd: "bundle exec tng --file=FILE --clones", desc: "Check for code duplicates" }
|
|
409
|
+
{ cmd: "bundle exec tng --file=FILE --clones", desc: "Check for code duplicates" },
|
|
410
|
+
{ cmd: "bundle exec tng --file=FILE --deadcode", desc: "Run dead code detection" },
|
|
411
|
+
{ cmd: "bundle exec tng --file=FILE --method=METHOD --xray", desc: "X-Ray visualization" }
|
|
350
412
|
],
|
|
351
413
|
features: [
|
|
352
414
|
"Controllers, Models, Services",
|
|
@@ -355,6 +417,8 @@ module Tng
|
|
|
355
417
|
"Code audit for issues & behaviors",
|
|
356
418
|
"Symbolic execution traces",
|
|
357
419
|
"Duplicate code detection (Clones)",
|
|
420
|
+
"Dead code detection (Rust-powered)",
|
|
421
|
+
"X-Ray Logic Flow Visualization",
|
|
358
422
|
"Searchable method lists"
|
|
359
423
|
],
|
|
360
424
|
options: [
|
|
@@ -364,15 +428,19 @@ module Tng
|
|
|
364
428
|
{ flag: "--audit", desc: "Run audit mode instead of test generation" },
|
|
365
429
|
{ flag: "--trace", desc: "Run symbolic trace mode" },
|
|
366
430
|
{ flag: "--clones", desc: "Run clone detection mode" },
|
|
367
|
-
{ flag: "--level=1|2|all", desc: "Set clone detection level (default: all)" }
|
|
431
|
+
{ flag: "--level=1|2|3|all", desc: "Set clone detection level (default: all)" },
|
|
432
|
+
{ flag: "--deadcode", desc: "Run dead code detection" },
|
|
433
|
+
{ flag: "--xray", desc: "Generate X-Ray visualization" }
|
|
368
434
|
],
|
|
369
435
|
how_to: [
|
|
370
436
|
"Run 'bundle exec tng' for interactive mode",
|
|
371
437
|
"Run 'tng [file] --clones' for duplicate detection",
|
|
438
|
+
"Run 'tng [file] --deadcode' for dead code analysis",
|
|
439
|
+
"Run 'tng [file] [method] --xray' for visualization",
|
|
372
440
|
"Select Controller, Model, or Service to start",
|
|
373
441
|
"Choose a method to generate/audit or select 'Check Duplicates'"
|
|
374
442
|
],
|
|
375
|
-
footer: "
|
|
443
|
+
footer: ""
|
|
376
444
|
}
|
|
377
445
|
|
|
378
446
|
system(@binary_path, "help-box", "--version", version, "--data", JSON.generate(help_data))
|
|
@@ -478,8 +546,14 @@ module Tng
|
|
|
478
546
|
File.expand_path("binaries/#{binary_name}", Dir.pwd)
|
|
479
547
|
]
|
|
480
548
|
|
|
549
|
+
# puts "DEBUG: Searching for binary #{binary_name} in:"
|
|
550
|
+
# binary_paths.each { |p| puts " - #{p}" }
|
|
551
|
+
|
|
481
552
|
binary_paths.each do |path|
|
|
482
|
-
|
|
553
|
+
if File.exist?(path) && File.executable?(path)
|
|
554
|
+
# puts "DEBUG: Found binary at #{path}"
|
|
555
|
+
return path
|
|
556
|
+
end
|
|
483
557
|
end
|
|
484
558
|
|
|
485
559
|
raise "go-ui binary not found. Searched: #{binary_paths.join(", ")}"
|
data/lib/tng/ui/json_session.rb
CHANGED
|
@@ -96,6 +96,20 @@ module Tng
|
|
|
96
96
|
emit_event("clones", { file_path: file_path, matches: results[:matches] })
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
def show_trace_results(trace_file_path)
|
|
100
|
+
trace_json = JSON.parse(File.read(trace_file_path))
|
|
101
|
+
emit_event("result", trace_json)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def show_dead_code_results(file_path, results_json)
|
|
105
|
+
parsed = JSON.parse(results_json)
|
|
106
|
+
emit_event("dead_code", parsed)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def show_xray_results(xray_result, method_info = {})
|
|
110
|
+
emit_event("result", xray_result.merge(method_info: method_info))
|
|
111
|
+
end
|
|
112
|
+
|
|
99
113
|
def show_test_results(title, passed, failed, errors, total, results = [])
|
|
100
114
|
emit_event("test_results", {
|
|
101
115
|
title: title,
|
|
@@ -107,6 +121,10 @@ module Tng
|
|
|
107
121
|
})
|
|
108
122
|
end
|
|
109
123
|
|
|
124
|
+
def show_generation_result(result)
|
|
125
|
+
emit_event("result", result)
|
|
126
|
+
end
|
|
127
|
+
|
|
110
128
|
# ------------------------------------------------------------------
|
|
111
129
|
# Errors & Warnings
|
|
112
130
|
# ------------------------------------------------------------------
|
data/lib/tng/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tng
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ralucab
|
|
@@ -222,7 +222,7 @@ post_install_message: "┌ TNG ────────────────
|
|
|
222
222
|
\ │\n│ • bundle exec
|
|
223
223
|
tng --help - Show help information │\n│ │\n│
|
|
224
224
|
\ \U0001F4A1 Generate tests for individual methods with precision │\n└────────────────────────────────────────────────────────────
|
|
225
|
-
v0.4.
|
|
225
|
+
v0.4.9 ┘\n"
|
|
226
226
|
rdoc_options: []
|
|
227
227
|
require_paths:
|
|
228
228
|
- lib
|