elliot-stack 1.0.29 → 1.0.33
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.
- package/LICENSE +21 -21
- package/README.md +5 -0
- package/bin/install.cjs +981 -950
- package/hooks/repo-search-nudge.js +32 -32
- package/package.json +1 -1
- package/skills/estack-active-learning-tutor/SKILL.md +339 -339
- package/skills/estack-better-title/SKILL.md +64 -64
- package/skills/estack-better-title/scripts/rename.sh +55 -55
- package/skills/estack-chris-voss/SKILL.md +80 -80
- package/skills/estack-chris-voss/references/elliot-notes.md +120 -120
- package/skills/estack-chris-voss/references/voss-principles.md +210 -210
- package/skills/estack-customer-discovery/SKILL.md +60 -60
- package/skills/estack-flight-planner/SKILL.md +332 -332
- package/skills/estack-flight-planner/references/config_schema.md +156 -156
- package/skills/estack-flight-planner/references/flight_history_schema.md +97 -97
- package/skills/estack-flight-planner/references/shuttle_schedules.md +98 -98
- package/skills/estack-flight-planner/scripts/check_setup.sh +89 -89
- package/skills/estack-flight-planner/scripts/fetch_flights.py +99 -99
- package/skills/estack-flight-planner/scripts/filter_flights.py +265 -265
- package/skills/estack-flight-planner/scripts/pair_shuttles.py +173 -173
- package/skills/estack-github-issue-tracker/SKILL.md +322 -322
- package/skills/estack-github-issue-tracker/bin/tracker-tools.cjs +1358 -1358
- package/skills/estack-github-issue-tracker/references/gh-cli-patterns.md +124 -124
- package/skills/estack-github-issue-tracker/references/result-file-schema.md +156 -156
- package/skills/estack-github-issue-tracker/references/tracker-schema.md +96 -96
- package/skills/estack-github-issue-tracker/tracker-template.md +58 -58
- package/skills/estack-leadership-coach/SKILL.md +235 -0
- package/skills/estack-leadership-coach/adding-references.md +280 -0
- package/skills/estack-leadership-coach/frameworks/delegation/flows/post-mortem.md +120 -0
- package/skills/estack-leadership-coach/frameworks/delegation/flows/pre-delegation.md +138 -0
- package/skills/estack-leadership-coach/frameworks/delegation/phases/1-intake.md +145 -0
- package/skills/estack-leadership-coach/frameworks/delegation/phases/2-trm-assessment.md +119 -0
- package/skills/estack-leadership-coach/frameworks/delegation/phases/3-enrollment.md +132 -0
- package/skills/estack-leadership-coach/frameworks/delegation/phases/4-build-brief.md +171 -0
- package/skills/estack-leadership-coach/frameworks/delegation/phases/5-monitoring.md +134 -0
- package/skills/estack-leadership-coach/frameworks/delegation/phases/6-reverse-delegation.md +118 -0
- package/skills/estack-leadership-coach/frameworks/delegation/phases/7-diagnose.md +200 -0
- package/skills/estack-leadership-coach/references/.source-files/deci-ryan_self-determination-theory__deci-olafsen-ryan-2017-self-determination-theory-in-work-organizations.md +1881 -0
- package/skills/estack-leadership-coach/references/.source-files/deci-ryan_self-determination-theory__gagne-deci-2005-self-determination-theory-and-work-motivation.md +2058 -0
- package/skills/estack-leadership-coach/references/.source-files/deci-ryan_self-determination-theory__selfdeterminationtheory-org-theory-overview-page.md +61 -0
- package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-3-key-insights-into-the-global-workplace-2024.md +57 -0
- package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-managers-account-for-70-percent-of-variance-in-employee-engagement-2015.md +40 -0
- package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-state-of-the-global-workplace-2026-global-data-summary.md +73 -0
- package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-state-of-the-global-workplace-2026-report-landing.md +42 -0
- package/skills/estack-leadership-coach/references/.source-files/hormozi-leila_4-stages__leila-hormozi-the-art-of-delegation-blog-post.md +91 -0
- package/skills/estack-leadership-coach/references/.source-files/oncken-wass_monkeys-hbr-1974__oncken-wass-management-time-whos-got-the-monkey-hbr-classic-1974.md +969 -0
- package/skills/estack-leadership-coach/references/.source-files/sanchez_main-street-millionaire__codie-sanchez-afford-anything-podcast-ep-565-show-notes.md +89 -0
- package/skills/estack-leadership-coach/references/.source-files/sullivan_who-not-how__dan-sullivan-impact-filter-tool-and-guide-booklet.md +565 -0
- package/skills/estack-leadership-coach/references/.source-files/van-edwards_cues__vanessa-van-edwards-lewis-howes-school-of-greatness-ep-1231-show-notes.md +122 -0
- package/skills/estack-leadership-coach/references/.source-files/van-edwards_cues__vanessa-van-edwards-roger-dooley-cues-interview.md +194 -0
- package/skills/estack-leadership-coach/references/deci-ryan_self-determination-theory.md +166 -0
- package/skills/estack-leadership-coach/references/doerr_measure-what-matters.md +154 -0
- package/skills/estack-leadership-coach/references/ferriss_4hww.md +189 -0
- package/skills/estack-leadership-coach/references/gallup_engagement-research.md +105 -0
- package/skills/estack-leadership-coach/references/gerber_e-myth-revisited.md +118 -0
- package/skills/estack-leadership-coach/references/grove_high-output-management.md +95 -0
- package/skills/estack-leadership-coach/references/hormozi-alex_followthrough.md +152 -0
- package/skills/estack-leadership-coach/references/hormozi-leila_4-stages.md +146 -0
- package/skills/estack-leadership-coach/references/oncken-wass_monkeys-hbr-1974.md +128 -0
- package/skills/estack-leadership-coach/references/sanchez_main-street-millionaire.md +196 -0
- package/skills/estack-leadership-coach/references/sullivan_who-not-how.md +137 -0
- package/skills/estack-leadership-coach/references/van-edwards_cues.md +189 -0
- package/skills/estack-migrate-claude-session-history/SKILL.md +226 -0
- package/skills/estack-migrate-claude-session-history/references/path-encoding.md +55 -0
- package/skills/estack-migrate-claude-session-history/references/troubleshooting.md +96 -0
- package/skills/estack-migrate-claude-session-history/scripts/migrate-claude-history.js +1123 -0
- package/skills/estack-migrate-claude-session-history/scripts/test-append-note.js +48 -0
- package/skills/estack-migrate-claude-session-history/scripts/test-validate-migration.py +326 -0
- package/skills/estack-migrate-claude-session-history/scripts/validate-migration.py +493 -0
- package/skills/estack-pdf-to-md/SKILL.md +180 -0
- package/skills/estack-pdf-to-md/scripts/pdf_to_md.py +596 -0
- package/skills/estack-productivity-prioritization-coach/SKILL.md +124 -0
- package/skills/estack-productivity-prioritization-coach/sources/01-tony-robbins-rpm.md +39 -0
- package/skills/estack-productivity-prioritization-coach/sources/02-justin-sung-task-prioritization.md +34 -0
- package/skills/estack-prompt-builder-coach/SKILL.md +81 -81
- package/skills/estack-prompt-builder-coach/definition-of-done-generator.md +42 -42
- package/skills/estack-prompt-builder-coach/prompt-builder.md +37 -37
- package/skills/estack-prompt-builder-coach/task-shaper.md +36 -36
- package/skills/estack-prompt-builder-coach/vague-ask-auditor.md +37 -37
- package/skills/estack-read-claude-session-history/SKILL.md +204 -204
- package/skills/estack-read-claude-session-history/references/jsonl-schema.md +126 -126
- package/skills/estack-read-claude-session-history/references/modes.md +423 -423
- package/skills/estack-read-claude-session-history/references/recipes.md +271 -271
- package/skills/estack-read-claude-session-history/scripts/lib/__init__.py +1 -1
- package/skills/estack-read-claude-session-history/scripts/lib/parser.py +460 -460
- package/skills/estack-read-claude-session-history/scripts/lib/paths.py +234 -234
- package/skills/estack-read-claude-session-history/scripts/lib/search.py +179 -179
- package/skills/estack-read-claude-session-history/scripts/lib/subagents.py +88 -88
- package/skills/estack-read-claude-session-history/scripts/lib/tools.py +144 -144
- package/skills/estack-read-claude-session-history/scripts/read_transcript.py +1776 -1776
- package/skills/estack-read-claude-session-history/scripts/tests/conftest.py +40 -40
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/README.md +20 -20
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/all-noise.jsonl +4 -4
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/basic-session.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-gaps.jsonl +9 -9
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-noise.jsonl +7 -7
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-a.jsonl +3 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-b.jsonl +3 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-waiting.jsonl +5 -5
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/interrupted.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/multi-compact.jsonl +8 -8
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/pending-user.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta/subagents/agent-aaa.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.meta.json +1 -1
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent.jsonl +4 -4
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/time-spread.jsonl +6 -6
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/timeline-day-test.jsonl +5 -5
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-zoo.jsonl +10 -10
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/truncated.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/unicode.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-advisor.jsonl +3 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-compact.jsonl +5 -5
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-thinking.jsonl +2 -2
- package/skills/estack-read-claude-session-history/scripts/tests/test_backup_roots.py +56 -56
- package/skills/estack-read-claude-session-history/scripts/tests/test_engagement.py +239 -239
- package/skills/estack-read-claude-session-history/scripts/tests/test_json_format.py +201 -201
- package/skills/estack-read-claude-session-history/scripts/tests/test_modes.py +199 -199
- package/skills/estack-read-claude-session-history/scripts/tests/test_parser.py +195 -195
- package/skills/estack-read-claude-session-history/scripts/tests/test_paths.py +133 -133
- package/skills/estack-read-claude-session-history/scripts/tests/test_search.py +78 -78
- package/skills/estack-read-claude-session-history/scripts/tests/test_subagents.py +43 -43
- package/skills/estack-read-claude-session-history/scripts/tests/test_timeline.py +179 -179
- package/skills/estack-read-claude-session-history/scripts/tests/test_timezone_and_project.py +212 -212
- package/skills/estack-read-claude-session-history/scripts/tests/test_tools.py +80 -80
- package/skills/estack-repo-search/SKILL.md +65 -65
- package/skills/estack-vscode-file-recovery/SKILL.md +188 -0
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Pair filtered flights with the best shuttle option and output a ranked
|
|
3
|
-
markdown plans table.
|
|
4
|
-
|
|
5
|
-
Inputs:
|
|
6
|
-
--flights-json JSON list from filter_flights.py (file path or "-" for stdin)
|
|
7
|
-
--shuttles-json JSON dict with "shuttles" array (see references/shuttle_schedules.md)
|
|
8
|
-
--shuttle-costs Comma-separated AIRPORT:USD list (e.g. "ORD:60,IND:30"). Each
|
|
9
|
-
airport in your shuttle config must be listed here.
|
|
10
|
-
--tz-offsets Comma-separated AIRPORT:OFFSET_MIN list relative to home/origin
|
|
11
|
-
timezone (e.g. "ORD:-60,MDW:-60"). Airports omitted assume 0
|
|
12
|
-
(same timezone as the shuttle's `departs_local` zone).
|
|
13
|
-
--min-buffer-min Min minutes between shuttle arrival at airport and flight
|
|
14
|
-
departure. Default 90 (1.5h).
|
|
15
|
-
--max-wait-min Max acceptable wait at airport. Default 240 (4h).
|
|
16
|
-
|
|
17
|
-
Output: markdown table on stdout, one row per flight, sorted by viability
|
|
18
|
-
then total cost then departure time.
|
|
19
|
-
|
|
20
|
-
Timezones: shuttle entries record departure time in the home timezone
|
|
21
|
-
(`departs_local`) and arrival time in the airport's local timezone
|
|
22
|
-
(`arrives_local`). Pass --tz-offsets so this script can compare them on a
|
|
23
|
-
single timeline for buffer math.
|
|
24
|
-
"""
|
|
25
|
-
import argparse
|
|
26
|
-
import json
|
|
27
|
-
import sys
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def parse_kv_int(csv: str, value_label: str):
|
|
31
|
-
"""Parse "KEY:VAL,KEY:VAL" into a dict[str,int]."""
|
|
32
|
-
out = {}
|
|
33
|
-
if not csv:
|
|
34
|
-
return out
|
|
35
|
-
for item in csv.split(","):
|
|
36
|
-
item = item.strip()
|
|
37
|
-
if not item:
|
|
38
|
-
continue
|
|
39
|
-
if ":" not in item:
|
|
40
|
-
print(f"ERROR: bad {value_label} entry {item!r} — expected KEY:VAL", file=sys.stderr)
|
|
41
|
-
sys.exit(2)
|
|
42
|
-
k, v = item.split(":", 1)
|
|
43
|
-
try:
|
|
44
|
-
out[k.strip()] = int(v.strip())
|
|
45
|
-
except ValueError:
|
|
46
|
-
print(f"ERROR: {value_label} {k!r} value {v!r} is not an int", file=sys.stderr)
|
|
47
|
-
sys.exit(2)
|
|
48
|
-
return out
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def hm_to_min(hm: str) -> int:
|
|
52
|
-
h, m = hm.split(":")
|
|
53
|
-
return int(h) * 60 + int(m)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def viability(buffer_min: int, min_buffer: int, max_wait: int) -> str:
|
|
57
|
-
if buffer_min < min_buffer:
|
|
58
|
-
return "TOO_TIGHT"
|
|
59
|
-
if buffer_min > max_wait:
|
|
60
|
-
return "LONG_WAIT"
|
|
61
|
-
if buffer_min < min_buffer + 30:
|
|
62
|
-
return "TIGHT"
|
|
63
|
-
if buffer_min <= min_buffer + 90:
|
|
64
|
-
return "COMFORTABLE"
|
|
65
|
-
return "GENEROUS"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
VIABILITY_RANK = {"COMFORTABLE": 0, "GENEROUS": 1, "TIGHT": 2, "LONG_WAIT": 3, "TOO_TIGHT": 4}
|
|
69
|
-
VIABILITY_NOTE = {
|
|
70
|
-
"COMFORTABLE": "Comfortable buffer",
|
|
71
|
-
"GENEROUS": "Comfortable, longer wait",
|
|
72
|
-
"TIGHT": "Tight - runs on shuttle being on time",
|
|
73
|
-
"LONG_WAIT": "Long airport wait",
|
|
74
|
-
"TOO_TIGHT": "Too tight - not viable",
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def to_home_min(time_local: str, airport: str, tz_offsets: dict) -> int:
|
|
79
|
-
"""Convert a local-airport HH:MM into home-timezone-equivalent minutes."""
|
|
80
|
-
return hm_to_min(time_local) - tz_offsets.get(airport, 0)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def best_shuttle_for_flight(flight, shuttles, min_buffer, max_wait, tz_offsets):
|
|
84
|
-
"""Pick the shuttle with the best viability score for this flight."""
|
|
85
|
-
dep_airport = flight["from"]
|
|
86
|
-
flight_dep_min = to_home_min(flight["departs"], dep_airport, tz_offsets)
|
|
87
|
-
candidates = []
|
|
88
|
-
for s in shuttles:
|
|
89
|
-
if s.get("to") != dep_airport:
|
|
90
|
-
continue
|
|
91
|
-
arr = s.get("arrives_local", "")
|
|
92
|
-
if not arr:
|
|
93
|
-
continue
|
|
94
|
-
shuttle_arr_min = to_home_min(arr, dep_airport, tz_offsets)
|
|
95
|
-
buffer = flight_dep_min - shuttle_arr_min
|
|
96
|
-
if buffer < 0:
|
|
97
|
-
continue # shuttle arrives after flight leaves
|
|
98
|
-
v = viability(buffer, min_buffer, max_wait)
|
|
99
|
-
candidates.append((VIABILITY_RANK[v], buffer, v, s))
|
|
100
|
-
if not candidates:
|
|
101
|
-
return None, None, None
|
|
102
|
-
candidates.sort(key=lambda c: c[0])
|
|
103
|
-
_, buf, v, s = candidates[0]
|
|
104
|
-
return s, buf, v
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def main() -> int:
|
|
108
|
-
p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
109
|
-
p.add_argument("--flights-json", required=True, help="Path to filter_flights.py output, or '-' for stdin")
|
|
110
|
-
p.add_argument("--shuttles-json", required=True)
|
|
111
|
-
p.add_argument("--shuttle-costs", default="",
|
|
112
|
-
help='Comma-separated "AIRPORT:USD" pairs (e.g. "ORD:60,IND:30")')
|
|
113
|
-
p.add_argument("--tz-offsets", default="",
|
|
114
|
-
help='Comma-separated "AIRPORT:OFFSET_MIN" pairs relative to home tz')
|
|
115
|
-
p.add_argument("--min-buffer-min", type=int, default=90)
|
|
116
|
-
p.add_argument("--max-wait-min", type=int, default=240)
|
|
117
|
-
args = p.parse_args()
|
|
118
|
-
|
|
119
|
-
shuttle_costs = parse_kv_int(args.shuttle_costs, "--shuttle-costs")
|
|
120
|
-
tz_offsets = parse_kv_int(args.tz_offsets, "--tz-offsets")
|
|
121
|
-
|
|
122
|
-
if args.flights_json == "-":
|
|
123
|
-
flights = json.load(sys.stdin)
|
|
124
|
-
else:
|
|
125
|
-
with open(args.flights_json, encoding="utf-8") as f:
|
|
126
|
-
flights = json.load(f)
|
|
127
|
-
|
|
128
|
-
with open(args.shuttles_json, encoding="utf-8") as f:
|
|
129
|
-
shuttles = json.load(f).get("shuttles", [])
|
|
130
|
-
|
|
131
|
-
rows = []
|
|
132
|
-
for fl in flights:
|
|
133
|
-
s, buf, v = best_shuttle_for_flight(
|
|
134
|
-
fl, shuttles, args.min_buffer_min, args.max_wait_min, tz_offsets,
|
|
135
|
-
)
|
|
136
|
-
if s is None:
|
|
137
|
-
continue
|
|
138
|
-
shuttle_cost = shuttle_costs.get(fl["from"], 0)
|
|
139
|
-
total = (fl["price"] or 0) + shuttle_cost
|
|
140
|
-
rows.append({
|
|
141
|
-
"flight": fl, "shuttle": s, "buffer_min": buf, "viability": v,
|
|
142
|
-
"shuttle_cost": shuttle_cost, "total": total,
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
# Sort: viability tier, then priority band, then total cost, then departure time
|
|
146
|
-
rows.sort(key=lambda r: (
|
|
147
|
-
VIABILITY_RANK[r["viability"]],
|
|
148
|
-
r.get("flight", {}).get("priority_band", 0),
|
|
149
|
-
r["total"],
|
|
150
|
-
r["flight"]["departs"],
|
|
151
|
-
))
|
|
152
|
-
|
|
153
|
-
if not rows:
|
|
154
|
-
print("(no viable flight+shuttle pairings)")
|
|
155
|
-
return 0
|
|
156
|
-
|
|
157
|
-
print("| # | Date | Flight | From | To | Departs | Arrives | Shuttle | Shuttle Departs | Buffer | Flight $ | Shuttle $ | **Total** | Notes |")
|
|
158
|
-
print("|---|---|---|---|---|---|---|---|---|---|---|---|---|---|")
|
|
159
|
-
for i, r in enumerate(rows, 1):
|
|
160
|
-
f = r["flight"]; s = r["shuttle"]
|
|
161
|
-
depart_label = s.get("departs_local") or s.get("departs_et") or "?"
|
|
162
|
-
print(
|
|
163
|
-
f"| {i} | {f['date']} | {f['flight']} | {f['from']} | {f['to']} | "
|
|
164
|
-
f"{f['departs']} | {f['arrives']} | {s.get('company','?')} | "
|
|
165
|
-
f"{depart_label} | {r['buffer_min']} min | "
|
|
166
|
-
f"${f['price']} | ${r['shuttle_cost']} | **${r['total']}** | "
|
|
167
|
-
f"{VIABILITY_NOTE[r['viability']]} |"
|
|
168
|
-
)
|
|
169
|
-
return 0
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if __name__ == "__main__":
|
|
173
|
-
sys.exit(main())
|
|
1
|
+
"""
|
|
2
|
+
Pair filtered flights with the best shuttle option and output a ranked
|
|
3
|
+
markdown plans table.
|
|
4
|
+
|
|
5
|
+
Inputs:
|
|
6
|
+
--flights-json JSON list from filter_flights.py (file path or "-" for stdin)
|
|
7
|
+
--shuttles-json JSON dict with "shuttles" array (see references/shuttle_schedules.md)
|
|
8
|
+
--shuttle-costs Comma-separated AIRPORT:USD list (e.g. "ORD:60,IND:30"). Each
|
|
9
|
+
airport in your shuttle config must be listed here.
|
|
10
|
+
--tz-offsets Comma-separated AIRPORT:OFFSET_MIN list relative to home/origin
|
|
11
|
+
timezone (e.g. "ORD:-60,MDW:-60"). Airports omitted assume 0
|
|
12
|
+
(same timezone as the shuttle's `departs_local` zone).
|
|
13
|
+
--min-buffer-min Min minutes between shuttle arrival at airport and flight
|
|
14
|
+
departure. Default 90 (1.5h).
|
|
15
|
+
--max-wait-min Max acceptable wait at airport. Default 240 (4h).
|
|
16
|
+
|
|
17
|
+
Output: markdown table on stdout, one row per flight, sorted by viability
|
|
18
|
+
then total cost then departure time.
|
|
19
|
+
|
|
20
|
+
Timezones: shuttle entries record departure time in the home timezone
|
|
21
|
+
(`departs_local`) and arrival time in the airport's local timezone
|
|
22
|
+
(`arrives_local`). Pass --tz-offsets so this script can compare them on a
|
|
23
|
+
single timeline for buffer math.
|
|
24
|
+
"""
|
|
25
|
+
import argparse
|
|
26
|
+
import json
|
|
27
|
+
import sys
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def parse_kv_int(csv: str, value_label: str):
|
|
31
|
+
"""Parse "KEY:VAL,KEY:VAL" into a dict[str,int]."""
|
|
32
|
+
out = {}
|
|
33
|
+
if not csv:
|
|
34
|
+
return out
|
|
35
|
+
for item in csv.split(","):
|
|
36
|
+
item = item.strip()
|
|
37
|
+
if not item:
|
|
38
|
+
continue
|
|
39
|
+
if ":" not in item:
|
|
40
|
+
print(f"ERROR: bad {value_label} entry {item!r} — expected KEY:VAL", file=sys.stderr)
|
|
41
|
+
sys.exit(2)
|
|
42
|
+
k, v = item.split(":", 1)
|
|
43
|
+
try:
|
|
44
|
+
out[k.strip()] = int(v.strip())
|
|
45
|
+
except ValueError:
|
|
46
|
+
print(f"ERROR: {value_label} {k!r} value {v!r} is not an int", file=sys.stderr)
|
|
47
|
+
sys.exit(2)
|
|
48
|
+
return out
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def hm_to_min(hm: str) -> int:
|
|
52
|
+
h, m = hm.split(":")
|
|
53
|
+
return int(h) * 60 + int(m)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def viability(buffer_min: int, min_buffer: int, max_wait: int) -> str:
|
|
57
|
+
if buffer_min < min_buffer:
|
|
58
|
+
return "TOO_TIGHT"
|
|
59
|
+
if buffer_min > max_wait:
|
|
60
|
+
return "LONG_WAIT"
|
|
61
|
+
if buffer_min < min_buffer + 30:
|
|
62
|
+
return "TIGHT"
|
|
63
|
+
if buffer_min <= min_buffer + 90:
|
|
64
|
+
return "COMFORTABLE"
|
|
65
|
+
return "GENEROUS"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
VIABILITY_RANK = {"COMFORTABLE": 0, "GENEROUS": 1, "TIGHT": 2, "LONG_WAIT": 3, "TOO_TIGHT": 4}
|
|
69
|
+
VIABILITY_NOTE = {
|
|
70
|
+
"COMFORTABLE": "Comfortable buffer",
|
|
71
|
+
"GENEROUS": "Comfortable, longer wait",
|
|
72
|
+
"TIGHT": "Tight - runs on shuttle being on time",
|
|
73
|
+
"LONG_WAIT": "Long airport wait",
|
|
74
|
+
"TOO_TIGHT": "Too tight - not viable",
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def to_home_min(time_local: str, airport: str, tz_offsets: dict) -> int:
|
|
79
|
+
"""Convert a local-airport HH:MM into home-timezone-equivalent minutes."""
|
|
80
|
+
return hm_to_min(time_local) - tz_offsets.get(airport, 0)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def best_shuttle_for_flight(flight, shuttles, min_buffer, max_wait, tz_offsets):
|
|
84
|
+
"""Pick the shuttle with the best viability score for this flight."""
|
|
85
|
+
dep_airport = flight["from"]
|
|
86
|
+
flight_dep_min = to_home_min(flight["departs"], dep_airport, tz_offsets)
|
|
87
|
+
candidates = []
|
|
88
|
+
for s in shuttles:
|
|
89
|
+
if s.get("to") != dep_airport:
|
|
90
|
+
continue
|
|
91
|
+
arr = s.get("arrives_local", "")
|
|
92
|
+
if not arr:
|
|
93
|
+
continue
|
|
94
|
+
shuttle_arr_min = to_home_min(arr, dep_airport, tz_offsets)
|
|
95
|
+
buffer = flight_dep_min - shuttle_arr_min
|
|
96
|
+
if buffer < 0:
|
|
97
|
+
continue # shuttle arrives after flight leaves
|
|
98
|
+
v = viability(buffer, min_buffer, max_wait)
|
|
99
|
+
candidates.append((VIABILITY_RANK[v], buffer, v, s))
|
|
100
|
+
if not candidates:
|
|
101
|
+
return None, None, None
|
|
102
|
+
candidates.sort(key=lambda c: c[0])
|
|
103
|
+
_, buf, v, s = candidates[0]
|
|
104
|
+
return s, buf, v
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def main() -> int:
|
|
108
|
+
p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
109
|
+
p.add_argument("--flights-json", required=True, help="Path to filter_flights.py output, or '-' for stdin")
|
|
110
|
+
p.add_argument("--shuttles-json", required=True)
|
|
111
|
+
p.add_argument("--shuttle-costs", default="",
|
|
112
|
+
help='Comma-separated "AIRPORT:USD" pairs (e.g. "ORD:60,IND:30")')
|
|
113
|
+
p.add_argument("--tz-offsets", default="",
|
|
114
|
+
help='Comma-separated "AIRPORT:OFFSET_MIN" pairs relative to home tz')
|
|
115
|
+
p.add_argument("--min-buffer-min", type=int, default=90)
|
|
116
|
+
p.add_argument("--max-wait-min", type=int, default=240)
|
|
117
|
+
args = p.parse_args()
|
|
118
|
+
|
|
119
|
+
shuttle_costs = parse_kv_int(args.shuttle_costs, "--shuttle-costs")
|
|
120
|
+
tz_offsets = parse_kv_int(args.tz_offsets, "--tz-offsets")
|
|
121
|
+
|
|
122
|
+
if args.flights_json == "-":
|
|
123
|
+
flights = json.load(sys.stdin)
|
|
124
|
+
else:
|
|
125
|
+
with open(args.flights_json, encoding="utf-8") as f:
|
|
126
|
+
flights = json.load(f)
|
|
127
|
+
|
|
128
|
+
with open(args.shuttles_json, encoding="utf-8") as f:
|
|
129
|
+
shuttles = json.load(f).get("shuttles", [])
|
|
130
|
+
|
|
131
|
+
rows = []
|
|
132
|
+
for fl in flights:
|
|
133
|
+
s, buf, v = best_shuttle_for_flight(
|
|
134
|
+
fl, shuttles, args.min_buffer_min, args.max_wait_min, tz_offsets,
|
|
135
|
+
)
|
|
136
|
+
if s is None:
|
|
137
|
+
continue
|
|
138
|
+
shuttle_cost = shuttle_costs.get(fl["from"], 0)
|
|
139
|
+
total = (fl["price"] or 0) + shuttle_cost
|
|
140
|
+
rows.append({
|
|
141
|
+
"flight": fl, "shuttle": s, "buffer_min": buf, "viability": v,
|
|
142
|
+
"shuttle_cost": shuttle_cost, "total": total,
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
# Sort: viability tier, then priority band, then total cost, then departure time
|
|
146
|
+
rows.sort(key=lambda r: (
|
|
147
|
+
VIABILITY_RANK[r["viability"]],
|
|
148
|
+
r.get("flight", {}).get("priority_band", 0),
|
|
149
|
+
r["total"],
|
|
150
|
+
r["flight"]["departs"],
|
|
151
|
+
))
|
|
152
|
+
|
|
153
|
+
if not rows:
|
|
154
|
+
print("(no viable flight+shuttle pairings)")
|
|
155
|
+
return 0
|
|
156
|
+
|
|
157
|
+
print("| # | Date | Flight | From | To | Departs | Arrives | Shuttle | Shuttle Departs | Buffer | Flight $ | Shuttle $ | **Total** | Notes |")
|
|
158
|
+
print("|---|---|---|---|---|---|---|---|---|---|---|---|---|---|")
|
|
159
|
+
for i, r in enumerate(rows, 1):
|
|
160
|
+
f = r["flight"]; s = r["shuttle"]
|
|
161
|
+
depart_label = s.get("departs_local") or s.get("departs_et") or "?"
|
|
162
|
+
print(
|
|
163
|
+
f"| {i} | {f['date']} | {f['flight']} | {f['from']} | {f['to']} | "
|
|
164
|
+
f"{f['departs']} | {f['arrives']} | {s.get('company','?')} | "
|
|
165
|
+
f"{depart_label} | {r['buffer_min']} min | "
|
|
166
|
+
f"${f['price']} | ${r['shuttle_cost']} | **${r['total']}** | "
|
|
167
|
+
f"{VIABILITY_NOTE[r['viability']]} |"
|
|
168
|
+
)
|
|
169
|
+
return 0
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if __name__ == "__main__":
|
|
173
|
+
sys.exit(main())
|