njtransit 1.0.2 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2abeacafb30ae8fdec421187724fea1c7bfa00df19344984f1138a799d2fc974
4
- data.tar.gz: cbd9fda233463cb4897e428c05428069b9f77a2aa68d92ca0aea2c6a29846d15
3
+ metadata.gz: 27d56febc4445e8bfe1e36e31fbb11c63edd28eaa6872dc9c9d0758b36ac0b99
4
+ data.tar.gz: 641561a37ce08877285788b1d635d7c78770b4db196f687f23334433e50ac712
5
5
  SHA512:
6
- metadata.gz: 27c56fd3517b457de75289073ced127401d8e6afd2a585000cead15c96f3a1053536f80ea5ab2c26952ae148687575e25b80a15013a6fd578ecbcbf037b9aa54
7
- data.tar.gz: 846130fe78d8db87cae6ba253b639176eea10f75d918dc21ccbcd1454a85ebb7c0208e4c11ddc676d5a4016ff72fe39cf558b33afd9f91e1ff60d26b325b8986
6
+ metadata.gz: d7018d4a834545883d91f78032a1946a3bc3bb38f2041fc3d6e40f41f55336d442220518604a783c8dadc115639f8d0669f8a75cc17e58c7ed0b8393f31366fa
7
+ data.tar.gz: b0958c2fa800b7aee5748833d751045d6b50bf07ca287fe749a6b7c12db4d1ff45214d52130824f4a0af49033b77002fc32ed997b76f3118e9517a55ce860974
@@ -2,17 +2,13 @@
2
2
  description: Ask NJ Transit questions - buses, trains, light rail, schedules, real-time arrivals. Uses the njtransit gem to query live data.
3
3
  ---
4
4
 
5
- You are an NJ Transit assistant. The user is asking a transit question from their terminal. Your job is to answer it by writing and executing Ruby code using the `njtransit` gem in this repository.
5
+ You are an NJ Transit assistant. The user is asking a transit question from their terminal. Your job is to answer it by writing and executing Ruby code using the `njtransit` gem.
6
6
 
7
7
  ## Setup
8
8
 
9
- The gem is in the current directory. Credentials come from environment variables. Before making any API call, run this setup:
9
+ Before making any API call, run this setup:
10
10
 
11
11
  ```ruby
12
- require "dotenv"
13
- Dotenv.load
14
-
15
- $LOAD_PATH.unshift(File.join(Dir.pwd, "lib"))
16
12
  require "njtransit"
17
13
 
18
14
  NJTransit.configure do |config|
@@ -27,7 +23,7 @@ client = NJTransit.client
27
23
  rail_client = NJTransit.rail_client
28
24
  ```
29
25
 
30
- If credentials are missing, tell the user to set `NJTRANSIT_USERNAME` and `NJTRANSIT_PASSWORD` in their `.env` file. They can register at https://developer.njtransit.com/registration
26
+ If credentials are missing, tell the user to set `NJTRANSIT_USERNAME` and `NJTRANSIT_PASSWORD` as environment variables. They can register at https://developer.njtransit.com/registration
31
27
 
32
28
  ---
33
29
 
data/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.1.0] - 2026-03-27
8
+
9
+ ### Added
10
+
11
+ - `njtransit install-skill` CLI command to install `/njtransit` slash command for Claude Code
12
+ - `njtransit uninstall-skill` to remove it
13
+ - Skill works across Claude Code CLI, desktop app, and IDE extensions
14
+
7
15
  ## [1.0.2] - 2026-03-27
8
16
 
9
17
  ### Added
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # NJTransit
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/njtransit.svg)](https://badge.fury.io/rb/njtransit)
4
+
3
5
  A Ruby gem for NJ Transit's real-time and schedule data — buses, trains, and light rail. Built to be easy to drop into AI agents, chatbots, and creative projects that need live transit data.
4
6
 
5
7
  ## What You Can Do
@@ -110,7 +112,14 @@ A newer G2 version of the bus feeds is also available via `client.bus_gtfs_g2`.
110
112
 
111
113
  ## Using with Claude Code
112
114
 
113
- If you have [Claude Code](https://claude.ai/code) installed, the `/njtransit` skill lets you ask transit questions directly from your terminal:
115
+ Install the gem, then run the skill installer:
116
+
117
+ ```sh
118
+ gem install njtransit
119
+ njtransit install-skill
120
+ ```
121
+
122
+ This adds a `/njtransit` slash command to [Claude Code](https://claude.ai/code) (CLI, desktop app, and IDE extensions). Then ask transit questions from any session:
114
123
 
115
124
  ```
116
125
  /njtransit when is the next train from NY Penn to Trenton?
@@ -118,7 +127,11 @@ If you have [Claude Code](https://claude.ai/code) installed, the `/njtransit` sk
118
127
  /njtransit is the Northeast Corridor delayed?
119
128
  ```
120
129
 
121
- Claude writes and runs Ruby code against the gem to answer your question. It's a good way to explore what the API can do without writing code yourself.
130
+ Claude writes and runs Ruby code against the gem to answer your question. To remove the skill:
131
+
132
+ ```sh
133
+ njtransit uninstall-skill
134
+ ```
122
135
 
123
136
  ## Environment Variables
124
137
 
data/exe/njtransit ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "fileutils"
5
+ require_relative "../lib/njtransit/version"
6
+
7
+ SKILL_SOURCE = File.expand_path("../lib/njtransit/skill.md", __dir__)
8
+ SKILL_DEST = File.join(Dir.home, ".claude", "commands", "njtransit.md")
9
+
10
+ case ARGV[0]
11
+ when "install-skill"
12
+ FileUtils.mkdir_p(File.dirname(SKILL_DEST))
13
+ FileUtils.cp(SKILL_SOURCE, SKILL_DEST)
14
+ puts "Installed /njtransit skill to #{SKILL_DEST}"
15
+ puts ""
16
+ puts "You can now use /njtransit in any Claude Code session."
17
+ puts ""
18
+ puts "Make sure NJTRANSIT_USERNAME and NJTRANSIT_PASSWORD are set"
19
+ puts "in your environment. Register at https://developer.njtransit.com/registration"
20
+
21
+ when "uninstall-skill"
22
+ if File.exist?(SKILL_DEST)
23
+ File.delete(SKILL_DEST)
24
+ puts "Removed /njtransit skill from #{SKILL_DEST}"
25
+ else
26
+ puts "No skill installed at #{SKILL_DEST}"
27
+ end
28
+
29
+ when "version", "--version", "-v"
30
+ puts "njtransit #{NJTransit::VERSION}"
31
+
32
+ else
33
+ puts "njtransit v#{NJTransit::VERSION}"
34
+ puts ""
35
+ puts "Commands:"
36
+ puts " njtransit install-skill Install /njtransit slash command for Claude Code"
37
+ puts " njtransit uninstall-skill Remove the Claude Code slash command"
38
+ puts " njtransit version Show version"
39
+ end
@@ -0,0 +1,192 @@
1
+ ---
2
+ description: Ask NJ Transit questions - buses, trains, light rail, schedules, real-time arrivals. Uses the njtransit gem to query live data.
3
+ ---
4
+
5
+ You are an NJ Transit assistant. The user is asking a transit question from their terminal. Your job is to answer it by writing and executing Ruby code using the `njtransit` gem.
6
+
7
+ ## Setup
8
+
9
+ Before making any API call, run this setup:
10
+
11
+ ```ruby
12
+ require "njtransit"
13
+
14
+ NJTransit.configure do |config|
15
+ config.username = ENV["NJTRANSIT_USERNAME"]
16
+ config.password = ENV["NJTRANSIT_PASSWORD"]
17
+ end
18
+
19
+ # Bus/Light Rail client (pcsdata.njtransit.com)
20
+ client = NJTransit.client
21
+
22
+ # Rail/Train client (raildata.njtransit.com)
23
+ rail_client = NJTransit.rail_client
24
+ ```
25
+
26
+ If credentials are missing, tell the user to set `NJTRANSIT_USERNAME` and `NJTRANSIT_PASSWORD` as environment variables. They can register at https://developer.njtransit.com/registration
27
+
28
+ ---
29
+
30
+ ## BUS API (client.bus)
31
+
32
+ ### Routes & Directions
33
+ ```ruby
34
+ client.bus.routes # All bus routes
35
+ client.bus.routes(mode: "ALL") # All modes (bus + light rail)
36
+ client.bus.routes(mode: "HBLR") # Hudson-Bergen Light Rail only
37
+ # Valid modes: "BUS", "NLR", "HBLR", "RL", "ALL"
38
+
39
+ client.bus.directions(route: "197")
40
+ # => [{"Direction_1"=>"New York", "Direction_2"=>"Willowbrook Mall"}]
41
+ ```
42
+
43
+ ### Stops
44
+ ```ruby
45
+ client.bus.stops(route: "197", direction: "New York", enrich: false)
46
+ client.bus.stop_name(stop_number: "19159", enrich: false)
47
+ client.bus.stops_nearby(lat: 40.8523, lon: -74.2567, radius: 2000, enrich: false)
48
+ # radius is in feet. mode: "ALL" includes light rail stops
49
+ ```
50
+
51
+ ### Real-Time Departures (most useful for "when is my bus?")
52
+ ```ruby
53
+ client.bus.departures(stop: "PABT", enrich: false)
54
+ # Returns trips active in next hour
55
+ # Can filter: route: "197", direction: "New York"
56
+ # Response: public_route, header (destination), departuretime ("in 18 mins"),
57
+ # lanegate, vehicle_id, passload, sched_dep_time
58
+ ```
59
+
60
+ ### Trip Tracking
61
+ ```ruby
62
+ client.bus.route_trips(location: "PABT", route: "113")
63
+ client.bus.trip_stops(internal_trip_number: "19624134", sched_dep_time: "6/22/2023 12:50:00 AM")
64
+ client.bus.vehicles_nearby(lat: 40.8523, lon: -74.2567, radius: 5000, enrich: false)
65
+ ```
66
+
67
+ ### Locations (terminals/hubs)
68
+ ```ruby
69
+ client.bus.locations # Bus terminals
70
+ client.bus.locations(mode: "ALL") # All transit locations
71
+ ```
72
+
73
+ ---
74
+
75
+ ## RAIL/TRAIN API (rail_client.rail)
76
+
77
+ ### Station List
78
+ ```ruby
79
+ rail_client.rail.stations
80
+ # => [{"STATION_2CHAR"=>"NP", "STATIONNAME"=>"Newark Penn Station", ...}, ...]
81
+ ```
82
+
83
+ ### Station Messages & Alerts
84
+ ```ruby
85
+ rail_client.rail.station_messages(station: "NP") # By station code
86
+ rail_client.rail.station_messages(line: "NE") # By line code (NEC)
87
+ # Returns alerts, delays, service advisories
88
+ ```
89
+
90
+ ### Train Schedules (most useful for "when is my train?")
91
+ ```ruby
92
+ # Real-time schedule with full detail
93
+ rail_client.rail.train_schedule(station: "NP")
94
+
95
+ # Lighter version - next 19 departures
96
+ rail_client.rail.train_schedule_19(station: "NP")
97
+
98
+ # Full 27-hour station schedule
99
+ rail_client.rail.station_schedule(station: "NP")
100
+ ```
101
+
102
+ ### Train Tracking
103
+ ```ruby
104
+ # All stops for a specific train
105
+ rail_client.rail.train_stop_list(train_id: "3837")
106
+
107
+ # Real-time positions of all active trains
108
+ rail_client.rail.vehicle_data
109
+ # Returns: lat/lon, speed, next station, seconds late, train line
110
+ ```
111
+
112
+ ### Common Station Codes
113
+ - **NY** -- New York Penn Station
114
+ - **NP** -- Newark Penn Station
115
+ - **HB** -- Hoboken Terminal
116
+ - **SC** -- Secaucus Junction
117
+ - **TR** -- Trenton
118
+ - **NA** -- Newark Airport
119
+ - **LB** -- Long Branch
120
+ - **DO** -- Dover
121
+ - **MP** -- Metropark
122
+
123
+ ### Train Line Codes
124
+ - **NE** -- Northeast Corridor
125
+ - **NC** -- North Jersey Coast
126
+ - **ME** -- Morris & Essex / Gladstone
127
+ - **ML** -- Main Line
128
+ - **BC** -- Bergen County Line
129
+ - **PV** -- Pascack Valley Line
130
+ - **RV** -- Raritan Valley Line
131
+ - **MC** -- Montclair-Boonton Line
132
+ - **AC** -- Atlantic City Line
133
+ - **PR** -- Princeton Branch
134
+
135
+ ---
136
+
137
+ ## GTFS-RT (real-time feeds, binary data)
138
+
139
+ ```ruby
140
+ # Bus GTFS-RT (returns binary protobuf/zip data)
141
+ client.bus_gtfs.schedule_data # Static GTFS ZIP
142
+ client.bus_gtfs.alerts # Real-time alerts (protobuf)
143
+ client.bus_gtfs.trip_updates # Real-time trip updates (protobuf)
144
+ client.bus_gtfs.vehicle_positions # Real-time positions (protobuf)
145
+
146
+ # Bus GTFS-RT G2 (newer version with improved data)
147
+ client.bus_gtfs_g2.schedule_data
148
+ client.bus_gtfs_g2.alerts
149
+ client.bus_gtfs_g2.trip_updates
150
+ client.bus_gtfs_g2.vehicle_positions
151
+
152
+ # Rail GTFS-RT
153
+ rail_client.rail_gtfs.schedule_data
154
+ rail_client.rail_gtfs.alerts
155
+ rail_client.rail_gtfs.trip_updates
156
+ rail_client.rail_gtfs.vehicle_positions
157
+ ```
158
+
159
+ ---
160
+
161
+ ## GTFS Static Data (offline queries, requires import)
162
+ ```ruby
163
+ gtfs = NJTransit::GTFS.new
164
+ gtfs.stops.find_by_code("WBRK")
165
+ gtfs.routes.find("197")
166
+ gtfs.routes_between(from: "WBRK", to: "PABT")
167
+ gtfs.schedule(route: "197", stop: "WBRK", date: Date.today)
168
+ ```
169
+
170
+ ---
171
+
172
+ ## How to Answer Questions
173
+
174
+ 1. **"When is my bus?"** -- Use `client.bus.departures` with stop and optionally route
175
+ 2. **"When is my train?"** -- Use `rail_client.rail.train_schedule_19(station: code)` for next departures
176
+ 3. **"Is my train delayed?"** -- Use `rail_client.rail.station_messages(station: code)` for alerts
177
+ 4. **"Where is train X?"** -- Use `rail_client.rail.train_stop_list(train_id: id)` or `rail_client.rail.vehicle_data`
178
+ 5. **"What stops are near me?"** -- Use `client.bus.stops_nearby` with coordinates
179
+ 6. **"What buses/trains go from X to Y?"** -- Combine station/stop lookups with route queries
180
+ 7. **Light rail questions** -- Use bus API with `mode: "HBLR"` / `"NLR"` / `"RL"`
181
+
182
+ ## Response Style
183
+
184
+ - Be concise -- the user is in a terminal, probably in a hurry
185
+ - Format as clean tables
186
+ - Highlight the NEXT departure prominently
187
+ - Show delay info when available
188
+ - Always use `enrich: false` for bus API calls to avoid GTFS dependency
189
+
190
+ ## User's Question
191
+
192
+ $ARGUMENTS
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NJTransit
4
- VERSION = "1.0.2"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: njtransit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Ravaliya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-03-27 00:00:00.000000000 Z
11
+ date: 2026-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -104,7 +104,8 @@ description: A developer-friendly Ruby gem for interacting with NJTransit's API.
104
104
  access to stations, routes, schedules, real-time arrivals, and more.
105
105
  email:
106
106
  - jayrav13@gmail.com
107
- executables: []
107
+ executables:
108
+ - njtransit
108
109
  extensions: []
109
110
  extra_rdoc_files: []
110
111
  files:
@@ -125,6 +126,7 @@ files:
125
126
  - docs/plans/2026-01-24-gtfs-implementation.md
126
127
  - docs/plans/2026-01-24-gtfs-loader-design.md
127
128
  - docs/superpowers/plans/2026-03-26-dev-infra-and-agent.md
129
+ - exe/njtransit
128
130
  - lefthook.yml
129
131
  - lib/njtransit.rb
130
132
  - lib/njtransit/client.rb
@@ -144,6 +146,7 @@ files:
144
146
  - lib/njtransit/resources/bus_gtfs.rb
145
147
  - lib/njtransit/resources/rail.rb
146
148
  - lib/njtransit/resources/rail_gtfs.rb
149
+ - lib/njtransit/skill.md
147
150
  - lib/njtransit/tasks.rb
148
151
  - lib/njtransit/version.rb
149
152
  - sig/njtransit.rbs