@tobisk/codesafari 1.0.0 → 1.0.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.
- package/README.md +173 -0
- package/dist/cli.js +22 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/export.js +6 -0
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/gitignore.d.ts +8 -0
- package/dist/commands/gitignore.js +31 -0
- package/dist/commands/gitignore.js.map +1 -0
- package/dist/commands/insert.d.ts +49 -0
- package/dist/commands/insert.js +279 -0
- package/dist/commands/insert.js.map +1 -0
- package/dist/commands/validate.js +1 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/content/frontmatter.js +9 -1
- package/dist/content/frontmatter.js.map +1 -1
- package/dist/content/loadContent.d.ts +9 -1
- package/dist/content/loadContent.js +87 -1
- package/dist/content/loadContent.js.map +1 -1
- package/dist/ignore/ignore.d.ts +1 -0
- package/dist/ignore/ignore.js +54 -2
- package/dist/ignore/ignore.js.map +1 -1
- package/dist/manifest/build.js +21 -12
- package/dist/manifest/build.js.map +1 -1
- package/dist/model/types.d.ts +26 -0
- package/package.json +13 -10
- package/skills/README.md +53 -0
- package/skills/authoring-code-safaris/SKILL.md +411 -0
- package/viewer-dist/assets/abnfDiagram-XWFEHMT6-C79KnTw8.js +1 -0
- package/viewer-dist/assets/arc-l-ZAXPJO.js +1 -0
- package/viewer-dist/assets/architecture-WOLXFQ4H-BgLy9Yqp.js +1 -0
- package/viewer-dist/assets/architectureDiagram-CSQXQB3N-TJ9cXrHq.js +36 -0
- package/viewer-dist/assets/blockDiagram-BEDRHYPZ-By3kvess.js +140 -0
- package/viewer-dist/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
- package/viewer-dist/assets/c4Diagram-M2UUVUY5-CEeFbn5F.js +38 -0
- package/viewer-dist/assets/chunk-2Q5K7J3B-DKYFIUDS.js +1 -0
- package/viewer-dist/assets/chunk-3BJB4PZV-D3hUDXSk.js +1 -0
- package/viewer-dist/assets/chunk-3GCGMST5-C9FeQipv.js +1 -0
- package/viewer-dist/assets/{chunk-5VM5RSS4-BEPuob2j.js → chunk-5VM5RSS4-CdmEoR_J.js} +2 -2
- package/viewer-dist/assets/chunk-7U7NFRK5-CTLlozLY.js +88 -0
- package/viewer-dist/assets/chunk-CNRTWJTD-Ccr1NK1L.js +1 -0
- package/viewer-dist/assets/chunk-D5HYT7QG-Bj30JPRv.js +1 -0
- package/viewer-dist/assets/chunk-EBZ3SEQC-Sk8u_9ep.js +2 -0
- package/viewer-dist/assets/chunk-JWPE2WC7-COMTgl4A.js +1 -0
- package/viewer-dist/assets/chunk-KTR4FSNJ-WfEV-uOS.js +1 -0
- package/viewer-dist/assets/chunk-VN5WK6U6-C6BzLJ3g.js +213 -0
- package/viewer-dist/assets/chunk-XXDRQBXY-B_jRWCc3.js +1 -0
- package/viewer-dist/assets/classDiagram-v2-IZLYA2OM-CMUybpF2.js +217 -0
- package/viewer-dist/assets/cose-bilkent-JH36ORCC-BPaMzy85.js +1 -0
- package/viewer-dist/assets/cynefin-EF2NZ3EQ-DWzUaEWi.js +1 -0
- package/viewer-dist/assets/cynefinDiagram-NJNITYFG-C8QaCQXp.js +62 -0
- package/viewer-dist/assets/cytoscape.esm-DTfjcSDB.js +321 -0
- package/viewer-dist/assets/dagre-KIHZ2IZ3-BOPsr9LQ.js +4 -0
- package/viewer-dist/assets/defaultLocale-DeDIAtVl.js +1 -0
- package/viewer-dist/assets/diagram-7YQZDPLS-mYVjZ8Lx.js +41 -0
- package/viewer-dist/assets/diagram-QBROCOUO-DvI2mJSr.js +200 -0
- package/viewer-dist/assets/diagram-RJJCUUZO-CUPJGu2H.js +30 -0
- package/viewer-dist/assets/diagram-WERXNKYE-LcjJC6e6.js +24 -0
- package/viewer-dist/assets/diagram-YHHI257C-CcytRL3C.js +3 -0
- package/viewer-dist/assets/diagram-YR4HJLHV-DSNAvpUg.js +24 -0
- package/viewer-dist/assets/ebnfDiagram-N527522P-DCRtXms7.js +1 -0
- package/viewer-dist/assets/elk-O5DQBFGD-DMI6Zpvy.js +27 -0
- package/viewer-dist/assets/erDiagram-GT5GOJPG-D1F-hqWB.js +99 -0
- package/viewer-dist/assets/eventmodeling-K75KTNOO-4qs67wAF.js +1 -0
- package/viewer-dist/assets/flowDiagram-JAYNFW54-7bC7dhfH.js +1 -0
- package/viewer-dist/assets/ganttDiagram-3PRQTZWP-c3vw-KzJ.js +292 -0
- package/viewer-dist/assets/gitGraph-VSP46ZUC-CFMJazMp.js +1 -0
- package/viewer-dist/assets/gitGraphDiagram-VXDFKS5L-CXwZYVtU.js +106 -0
- package/viewer-dist/assets/graphlib-7nQ5Ng6P.js +1 -0
- package/viewer-dist/assets/grid-E2QIVN74-ryRc6Wgk.js +1 -0
- package/viewer-dist/assets/index-BLTUQmtP.css +1 -0
- package/viewer-dist/assets/index-LgGsGSUh.js +398 -0
- package/viewer-dist/assets/info-OHQRW6UA-rYwbZW6Y.js +1 -0
- package/viewer-dist/assets/infoDiagram-ATMJ4U3S-qX5Cid2q.js +2 -0
- package/viewer-dist/assets/init-C-OQMol4.js +1 -0
- package/viewer-dist/assets/ishikawaDiagram-S3EKX5GW-CSUJfCgm.js +70 -0
- package/viewer-dist/assets/journeyDiagram-POQNLL5X--_T-gdww.js +139 -0
- package/viewer-dist/assets/kanban-definition-BH5XI6FM-BsWjihcO.js +89 -0
- package/viewer-dist/assets/katex-CePi8B18.js +257 -0
- package/viewer-dist/assets/linear-BjnGGdIE.js +1 -0
- package/viewer-dist/assets/mermaid-parser.core-D9IKLdIu.js +141 -0
- package/viewer-dist/assets/mindmap-definition-WVAN44T4-vxwY3Xnu.js +98 -0
- package/viewer-dist/assets/ordinal-BDEzSJ7C.js +1 -0
- package/viewer-dist/assets/packet-JDAUHWVQ-CEegYGRn.js +1 -0
- package/viewer-dist/assets/pegDiagram-D4NLKWP3-8tSu4Jqx.js +1 -0
- package/viewer-dist/assets/pie-XZMESJXO-exj595wL.js +1 -0
- package/viewer-dist/assets/pieDiagram-36ENHN4W-CNY-FqqW.js +39 -0
- package/viewer-dist/assets/quadrantDiagram-ZQUDMS73-CqGaRuIP.js +7 -0
- package/viewer-dist/assets/radar-ABXABTNO-CmxHfKAF.js +1 -0
- package/viewer-dist/assets/railroad-I3PHUGI6-DXY0-ZL-.js +1 -0
- package/viewer-dist/assets/railroad-abnf-LNEFI6M7-v-M60bY5.js +1 -0
- package/viewer-dist/assets/railroad-ebnf-DWYD2UWJ-C7Ubri5u.js +1 -0
- package/viewer-dist/assets/railroad-peg-JR7BVNR7-DpAM4Usk.js +1 -0
- package/viewer-dist/assets/railroadDiagram-JIZHGYPL-D6LbsW-D.js +1 -0
- package/viewer-dist/assets/render-VIF2ZAQL-B9RjOjNU.js +2 -0
- package/viewer-dist/assets/requirementDiagram-AXW2TVFA-FxNR3nZg.js +84 -0
- package/viewer-dist/assets/sankeyDiagram-FBCJTAIF-pSJfgdmf.js +40 -0
- package/viewer-dist/assets/sequenceDiagram-3LA2ROMG-R5T9FB-U.js +169 -0
- package/viewer-dist/assets/sizeCapture-2Q2CQKSF-BuZ6aVhF.js +1 -0
- package/viewer-dist/assets/stateDiagram-v2-XZFR63ZJ-y2ApNDME.js +291 -0
- package/viewer-dist/assets/swimlanes-YQL5WMAO-Dqbpsu6u.js +1 -0
- package/viewer-dist/assets/swimlanesDiagram-BA3ZWDFA-iEZapiU_.js +8 -0
- package/viewer-dist/assets/timeline-definition-7Z437IG3-DAxdChcP.js +120 -0
- package/viewer-dist/assets/treeView-D4JQ5SDB-DE5B8wLE.js +1 -0
- package/viewer-dist/assets/treemap-SAJKECNS-fnWCJ5Gb.js +1 -0
- package/viewer-dist/assets/usecaseDiagram-RDK6N6HP-bXXWy_jN.js +328 -0
- package/viewer-dist/assets/vennDiagram-SHRQU5PJ-CjOBjqdM.js +34 -0
- package/viewer-dist/assets/wardley-7MLQ67FV-COzPZ67W.js +1 -0
- package/viewer-dist/assets/wardleyDiagram-F3OXNVQS-BjHoJgg7.js +78 -0
- package/viewer-dist/assets/xychartDiagram-GDYJKCDI-CwJZcH_5.js +7 -0
- package/viewer-dist/index.html +2 -2
- package/viewer-dist/assets/abnfDiagram-VRR7QNED-D3fx4JHm.js +0 -1
- package/viewer-dist/assets/arc-CDTQlIOl.js +0 -1
- package/viewer-dist/assets/architectureDiagram-ZJ3FMSHR-Bc-C9AOz.js +0 -36
- package/viewer-dist/assets/blockDiagram-677ZJIJ3-ZChUq7oC.js +0 -132
- package/viewer-dist/assets/c4Diagram-LMCZKHZV-Bh84Wvzw.js +0 -10
- package/viewer-dist/assets/channel-c5yLhzg_.js +0 -1
- package/viewer-dist/assets/chunk-2Q5K7J3B-BL2GPise.js +0 -1
- package/viewer-dist/assets/chunk-32BRIVSS-C8J4_0PY.js +0 -1
- package/viewer-dist/assets/chunk-EX3LRPZG-C8dshNGY.js +0 -231
- package/viewer-dist/assets/chunk-JWPE2WC7-DB3UPcb9.js +0 -1
- package/viewer-dist/assets/chunk-MOJQB5TN-CoW82BtI.js +0 -88
- package/viewer-dist/assets/chunk-RYQCIY6F-BSkOviuC.js +0 -1
- package/viewer-dist/assets/chunk-V7JOEXUC-C3uhoOMH.js +0 -206
- package/viewer-dist/assets/chunk-VR4S4FIN-IAlLBWOE.js +0 -1
- package/viewer-dist/assets/chunk-XXDRQBXY-BZ2dkDjb.js +0 -1
- package/viewer-dist/assets/classDiagram-OUVF2IWQ-t57CRPeZ.js +0 -1
- package/viewer-dist/assets/classDiagram-v2-EOCWNBFH-t57CRPeZ.js +0 -1
- package/viewer-dist/assets/cose-bilkent-JH36ORCC-qThT2S0A.js +0 -1
- package/viewer-dist/assets/cynefin-VYW2F7L2-DMuuSzID.js +0 -178
- package/viewer-dist/assets/cynefinDiagram-TSTJHNR4-58B-tzsV.js +0 -62
- package/viewer-dist/assets/cytoscape.esm-CUqq0XTU.js +0 -331
- package/viewer-dist/assets/dagre-VKFMJZFB-DD2dvjEA.js +0 -4
- package/viewer-dist/assets/defaultLocale-DX6XiGOO.js +0 -1
- package/viewer-dist/assets/diagram-FQU43EPY-BwhXWJOe.js +0 -3
- package/viewer-dist/assets/diagram-G47NLZAW-Bvw3coaF.js +0 -24
- package/viewer-dist/assets/diagram-NH7WQ7WH-Cug3_TDj.js +0 -24
- package/viewer-dist/assets/diagram-OA4YK3LP-COuB13FS.js +0 -30
- package/viewer-dist/assets/diagram-WEI45ONY-Cs9bIVJ-.js +0 -41
- package/viewer-dist/assets/ebnfDiagram-CCIWWBDH-DNxW5fFn.js +0 -1
- package/viewer-dist/assets/erDiagram-Q63AITRT-CoxCZQYq.js +0 -85
- package/viewer-dist/assets/flowDiagram-23GEKE2U-DDOkOM11.js +0 -156
- package/viewer-dist/assets/ganttDiagram-NO4QXBWP-BMIv-Vup.js +0 -292
- package/viewer-dist/assets/gitGraphDiagram-IHSO6WYX-CaYRI7Ti.js +0 -106
- package/viewer-dist/assets/graph-C2PyVmSI.js +0 -1
- package/viewer-dist/assets/index-DPa56qLF.js +0 -430
- package/viewer-dist/assets/index-sJB3TFqL.css +0 -1
- package/viewer-dist/assets/infoDiagram-FWYZ7A6U-CG1-XeBO.js +0 -2
- package/viewer-dist/assets/init-Gi6I4Gst.js +0 -1
- package/viewer-dist/assets/ishikawaDiagram-FXEZZL3T-BAaIgDfG.js +0 -70
- package/viewer-dist/assets/journeyDiagram-5HDEW3XC-oPpLTcMj.js +0 -139
- package/viewer-dist/assets/kanban-definition-HUTT4EX6-wplcQi9I.js +0 -89
- package/viewer-dist/assets/katex-C5jXJg4s.js +0 -257
- package/viewer-dist/assets/layout-HEHzrzvT.js +0 -1
- package/viewer-dist/assets/linear-3o0ZqjSV.js +0 -1
- package/viewer-dist/assets/map-BQHxRNoK.js +0 -1
- package/viewer-dist/assets/mindmap-definition-LN4V7U3C-FkdX9xoS.js +0 -96
- package/viewer-dist/assets/ordinal-Cboi1Yqb.js +0 -1
- package/viewer-dist/assets/pegDiagram-2B236MQR-UcxUgXaX.js +0 -1
- package/viewer-dist/assets/pieDiagram-ENE6RG2P-BEujiO1u.js +0 -39
- package/viewer-dist/assets/quadrantDiagram-ABIIQ3AL-BsWx4RNa.js +0 -7
- package/viewer-dist/assets/railroadDiagram-RFXS5EU6-CaiR8155.js +0 -1
- package/viewer-dist/assets/requirementDiagram-TGXJPOKE-B7WepZjB.js +0 -84
- package/viewer-dist/assets/sankeyDiagram-HTMAVEWB-D2ys-GcR.js +0 -40
- package/viewer-dist/assets/sequenceDiagram-DBY2YBRQ-BCx5Lqm4.js +0 -162
- package/viewer-dist/assets/sizeCapture-X5ZJPWSS-CdyWDUKU.js +0 -1
- package/viewer-dist/assets/stateDiagram-2N3HPSRC-CKjHd02p.js +0 -1
- package/viewer-dist/assets/stateDiagram-v2-6OUMAXLB-oQDdTlVJ.js +0 -1
- package/viewer-dist/assets/swimlanes-5IMT3BWC-wE7K0Eo8.js +0 -2
- package/viewer-dist/assets/swimlanesDiagram-G3AALYLV-Axc7yQiy.js +0 -8
- package/viewer-dist/assets/timeline-definition-FHXFAJF6-B9iZKy9Y.js +0 -120
- package/viewer-dist/assets/vennDiagram-L72KCM5P-CIMukQYN.js +0 -34
- package/viewer-dist/assets/wardleyDiagram-EHGQE667-JZnnBRHP.js +0 -78
- package/viewer-dist/assets/xychartDiagram-FW5EYKEG-BphHZiLL.js +0 -7
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: authoring-code-safaris
|
|
3
|
+
description: Author a CodeSafari (`.tour/` Markdown plus inline `@tour` source comments) for a codebase so newcomers can be guided through it. Use when asked to create, extend, or fix code tours, a code safari, onboarding walkthroughs anchored to real code, `.tour/index.md`, components, glossary concepts, or `@tour` comments — including "tour this repo", "add a safari for auth", or "document the data layer as a walkthrough".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Authoring Code Safaris
|
|
7
|
+
|
|
8
|
+
You are adding **CodeSafari** content to a codebase. CodeSafari
|
|
9
|
+
(`@tobisk/codesafari`) reads a `.tour/` folder plus `@tour` comments in the
|
|
10
|
+
source and serves them as an offline, IDE-like guided tour site.
|
|
11
|
+
|
|
12
|
+
Your job is to produce **content**, not to modify the tool. Never change
|
|
13
|
+
application logic to make a tour nicer; the tour bends to the code.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 0. Ask first — before writing anything
|
|
18
|
+
|
|
19
|
+
Read enough of the repo to form an opinion, then ask the user a **single
|
|
20
|
+
batched round** of questions. Propose your own answers so the user can just
|
|
21
|
+
confirm. Do not start authoring until this round is answered.
|
|
22
|
+
|
|
23
|
+
Ask about:
|
|
24
|
+
|
|
25
|
+
1. **Audience** — new hires joining the team? external contributors? both?
|
|
26
|
+
(Changes how much domain context the glossary must carry.)
|
|
27
|
+
2. **The tour list you propose** — show the concrete list you derived in §4
|
|
28
|
+
("I plan: Authentication, Data layer, HTTP API, Billing. Add/remove?").
|
|
29
|
+
3. **The component list you propose** — the §3 breakdown.
|
|
30
|
+
4. **Scope of code** — any packages, generated dirs, or vendored trees to leave
|
|
31
|
+
out of the safari entirely (these become `.codesafariignore` entries).
|
|
32
|
+
5. **Unknowns you could not answer from the code** — why a surprising design
|
|
33
|
+
exists, which of two similar paths is the blessed one, what is deprecated.
|
|
34
|
+
These are the parts of a tour you cannot invent, so collect them here.
|
|
35
|
+
|
|
36
|
+
If the user is unavailable (non-interactive run), write your assumptions into
|
|
37
|
+
the top of `.tour/index.md` as a short "Assumptions" note and continue.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 1. The four content kinds — keep them distinct
|
|
42
|
+
|
|
43
|
+
CodeSafari has four kinds of authored content. Newcomers to the format blur
|
|
44
|
+
them; don't.
|
|
45
|
+
|
|
46
|
+
| Kind | Answers | Shape | Lives in |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| **Glossary concept** | "What does this *word* mean?" | A paragraph or two. No navigation. | `.tour/glossary/**/*.md` |
|
|
49
|
+
| **Component** | "What is this *part of the system* and where does it live?" | A static page with links into the code. | `.tour/components/*.md` |
|
|
50
|
+
| **Tour (CodeSafari)** | "How does this *flow* actually work, step by step?" | An intro page + ordered `@tour` steps in the source. | `.tour/tours/**/*.md` + `@tour` comments |
|
|
51
|
+
| **Doc page** | "Explain this *idea* properly, at length." | Long-form prose, nested in folders. Not anchored to code. | `.tour/docs/**/*.md` |
|
|
52
|
+
|
|
53
|
+
Decision rule when you are unsure which one a piece of writing is:
|
|
54
|
+
|
|
55
|
+
- If it defines vocabulary the reader needs *while reading something else* →
|
|
56
|
+
**glossary**. Signal: you keep wanting to explain the same word in three
|
|
57
|
+
places. Write it once and link it: `[dot-aware ordering](glossary:dot-aware-ordering)`.
|
|
58
|
+
- If it describes a *place* — a directory, module, service, package — that the
|
|
59
|
+
reader will return to → **component**.
|
|
60
|
+
- If it describes a *journey through time* — a request, a login, a job being
|
|
61
|
+
processed → **tour**.
|
|
62
|
+
- If it needs *more than a couple of paragraphs* and isn't tied to specific
|
|
63
|
+
lines of code — a design rationale, a protocol, a threat model, a migration
|
|
64
|
+
history → **doc page**. Signal: a glossary entry that keeps growing headings.
|
|
65
|
+
|
|
66
|
+
A concept is never a tour. "JWT" is a glossary entry; "How a login request
|
|
67
|
+
becomes a session" is a tour. A component is never a tour either: "Auth
|
|
68
|
+
service" is a component; the login flow *through* it is the tour. And a doc page
|
|
69
|
+
is never a tour: "Why we chose opaque tokens over JWTs" is a doc; the code path
|
|
70
|
+
that mints one is a tour.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 2. `.tour/index.md` — the project summary
|
|
75
|
+
|
|
76
|
+
`index.md` is the landing page and the only global config. Write it **first**,
|
|
77
|
+
after the question round. It sets the frame everything else hangs off.
|
|
78
|
+
|
|
79
|
+
~~~markdown
|
|
80
|
+
---
|
|
81
|
+
title: Acme Platform
|
|
82
|
+
description: One sentence a stranger could repeat back correctly.
|
|
83
|
+
defaultSnippetLines: 20
|
|
84
|
+
repositoryUrl: https://github.com/acme/platform # optional
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
Two to four short paragraphs: what the product does, the runtime shape
|
|
88
|
+
(monolith? services? worker + web?), and the one or two design decisions that
|
|
89
|
+
explain the rest of the codebase.
|
|
90
|
+
|
|
91
|
+
```mermaid
|
|
92
|
+
flowchart LR
|
|
93
|
+
A[Browser] --> B[HTTP API]
|
|
94
|
+
B --> C[Domain services]
|
|
95
|
+
C --> D[(Postgres)]
|
|
96
|
+
C --> E[Job queue]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Where to start
|
|
100
|
+
|
|
101
|
+
- **Authentication** — how a request proves who it is.
|
|
102
|
+
- **Data layer** — how domain objects reach and leave the database.
|
|
103
|
+
~~~
|
|
104
|
+
|
|
105
|
+
Rules:
|
|
106
|
+
|
|
107
|
+
- `description` is one sentence, no marketing.
|
|
108
|
+
- Include exactly one high-level `mermaid` diagram of the runtime topology.
|
|
109
|
+
Diagrams render locally and offline; never link an external image service.
|
|
110
|
+
- End with a **"Where to start"** list naming the tours in reading order. This
|
|
111
|
+
is the single most useful thing on the page.
|
|
112
|
+
- `defaultSnippetLines` (typically 15–25) is the fallback highlight size when a
|
|
113
|
+
step does not sit in front of a class/function/block.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 3. Choosing which components to show
|
|
118
|
+
|
|
119
|
+
Components are the map. Aim for **5–12**. Fewer and the map is useless; more
|
|
120
|
+
and it is a directory listing.
|
|
121
|
+
|
|
122
|
+
Include a component when **all** of these hold:
|
|
123
|
+
|
|
124
|
+
- It has a **name the team actually says out loud** ("the ingest worker", not
|
|
125
|
+
"utils").
|
|
126
|
+
- A reader could be **assigned a ticket** scoped to it.
|
|
127
|
+
- It owns a **coherent responsibility**, not just a folder that exists.
|
|
128
|
+
|
|
129
|
+
Exclude:
|
|
130
|
+
|
|
131
|
+
- Leaf utility/helper/type-only directories.
|
|
132
|
+
- Generated code, migrations, vendored dependencies, build output.
|
|
133
|
+
- Anything you would describe as "and various other files".
|
|
134
|
+
|
|
135
|
+
Derive candidates from, in order of reliability: top-level source directories,
|
|
136
|
+
package/workspace boundaries, deployable units (services, workers, CLIs), and
|
|
137
|
+
finally the module clusters you observe from import graphs. Prefer the
|
|
138
|
+
project's own vocabulary over an invented taxonomy.
|
|
139
|
+
|
|
140
|
+
Each component page:
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
---
|
|
144
|
+
slug: auth-service # kebab-case, stable, referenced by tours
|
|
145
|
+
title: Auth Service
|
|
146
|
+
summary: Issues and verifies sessions. # one line, shown in listings
|
|
147
|
+
order: 20 # 10, 20, 30… leaves room to insert
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
What it is responsible for, and — just as usefully — what it is *not*.
|
|
151
|
+
|
|
152
|
+
- [`src/auth/session.ts`](src/auth/session.ts) — issuing and refreshing sessions.
|
|
153
|
+
- [`src/auth/middleware.ts`](src/auth/middleware.ts) — the guard applied per route.
|
|
154
|
+
|
|
155
|
+
Sessions are opaque [session tokens](glossary:session-token), not JWTs; see the
|
|
156
|
+
[Authentication](#) tour for the full flow.
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Link to real files with project-relative Markdown links. Verify every path
|
|
160
|
+
exists before you write it.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 4. Choosing which CodeSafaris to generate
|
|
165
|
+
|
|
166
|
+
Tours are for **major features and concepts** — the flows a newcomer must
|
|
167
|
+
understand before they can safely change anything.
|
|
168
|
+
|
|
169
|
+
### Baseline for any codebase with a server
|
|
170
|
+
|
|
171
|
+
Unless the repo genuinely lacks the concern, always produce:
|
|
172
|
+
|
|
173
|
+
1. **Authentication & authorization** — how an incoming request acquires an
|
|
174
|
+
identity, where that identity is checked, and what happens when it fails.
|
|
175
|
+
Start at the entry point (middleware/guard), not at the user model.
|
|
176
|
+
2. **The data layer** — how a domain object is read and written: schema or
|
|
177
|
+
model definition → repository/query layer → transaction boundaries →
|
|
178
|
+
migrations. Show one complete round trip, not a catalogue of tables.
|
|
179
|
+
3. **The API surface** — almost always worth it: route registration →
|
|
180
|
+
validation → handler → domain call → serialized response. Trace *one*
|
|
181
|
+
representative endpoint end to end rather than surveying many.
|
|
182
|
+
|
|
183
|
+
### Then the feature tours
|
|
184
|
+
|
|
185
|
+
Add one tour per **major feature or core concept** the product is actually
|
|
186
|
+
about — the things named on a roadmap: billing, ingestion pipeline, search
|
|
187
|
+
indexing, permissions model, real-time updates, the rendering pipeline.
|
|
188
|
+
|
|
189
|
+
Test a candidate tour against these:
|
|
190
|
+
|
|
191
|
+
- Can it be told as an **ordered sequence** with a beginning and an end?
|
|
192
|
+
- Does it cross **more than one component**? (Single-file flows are usually a
|
|
193
|
+
component page plus callouts, not a tour.)
|
|
194
|
+
- Would a new hire's **first week be worse** without it?
|
|
195
|
+
|
|
196
|
+
Do not generate tours for: build tooling, test setup, formatting config,
|
|
197
|
+
CI, or "misc utilities". Mention those in `index.md` if at all.
|
|
198
|
+
|
|
199
|
+
**Sizing.** 8–20 steps per tour. Under 5 steps, fold it into a component page.
|
|
200
|
+
Over ~25, split it (e.g. "Login" and "Session refresh" instead of one "Auth").
|
|
201
|
+
Total: aim for 3–7 tours in a normal repo. Every tour you write must be one
|
|
202
|
+
someone will finish.
|
|
203
|
+
|
|
204
|
+
### Tour entry page
|
|
205
|
+
|
|
206
|
+
```markdown
|
|
207
|
+
---
|
|
208
|
+
slug: authentication
|
|
209
|
+
title: How a request proves who it is
|
|
210
|
+
components: [auth-service, http-api] # slugs from .tour/components
|
|
211
|
+
order: 1 # reading order on the landing page
|
|
212
|
+
defaultSnippetLines: 25 # optional override
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
Follow one authenticated request from the edge middleware down to the loaded
|
|
216
|
+
user, then look at the two ways it can fail.
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Give tours **action titles** ("How a manifest is built"), not noun labels
|
|
220
|
+
("Manifest"). The noun label belongs to the component.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 5. Writing the steps (`@tour` comments)
|
|
225
|
+
|
|
226
|
+
Steps live in the source, next to the code they describe, so they move with it.
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
// @tour authentication:10 The edge guard
|
|
230
|
+
// Every request passes through here first. The guard reads the
|
|
231
|
+
// [session token](glossary:session-token) cookie and, on success, attaches the
|
|
232
|
+
// resolved user to the request before any handler runs.
|
|
233
|
+
export function requireSession(req, res, next) { /* ... */ }
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
- Header line: `@tour <tour-slug>:<order> <Step title>`.
|
|
237
|
+
- Everything after it in the **same continuous comment block** is the step
|
|
238
|
+
body — full Markdown, including `glossary:` links and ```` ```mermaid ````
|
|
239
|
+
blocks.
|
|
240
|
+
- **Ordering is dot-aware**, not decimal: `12.2` sorts before `12.10`. Number
|
|
241
|
+
steps `10, 20, 30…` so later insertions land as `15` or `12.5` with no
|
|
242
|
+
renumbering.
|
|
243
|
+
- The **highlight range** is chosen by what directly follows the comment: a
|
|
244
|
+
class highlights the whole class; a function/method highlights that
|
|
245
|
+
function; another block highlights the block; otherwise the comment plus
|
|
246
|
+
`defaultSnippetLines` lines. So **place the comment directly above the
|
|
247
|
+
construct you want shown** — a blank line or a stray import in between
|
|
248
|
+
changes what the reader sees.
|
|
249
|
+
|
|
250
|
+
Non-navigable annotations use `@tour comment`:
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
// @tour comment Not thread-safe
|
|
254
|
+
// This cache is intentionally per-process; see the data layer tour.
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
A callout is scoped to the nearest step **above** it in the same file. A
|
|
258
|
+
callout placed before every step in a file applies file-wide.
|
|
259
|
+
|
|
260
|
+
### Inserting the comments — use `codesafari insert`
|
|
261
|
+
|
|
262
|
+
Do **not** write a helper script to place these comments, and do not compute
|
|
263
|
+
line numbers and edit by offset. Placement is subtle enough that the CLI does
|
|
264
|
+
it for you:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npx @tobisk/codesafari insert steps.json --dry-run # resolve and report
|
|
268
|
+
npx @tobisk/codesafari insert steps.json # apply
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
`steps.json` is an array; `match` is the real anchor and `line` is only a hint:
|
|
272
|
+
|
|
273
|
+
```json
|
|
274
|
+
[
|
|
275
|
+
{
|
|
276
|
+
"file": "src/auth/middleware.ts",
|
|
277
|
+
"line": 42,
|
|
278
|
+
"match": "export function requireSession",
|
|
279
|
+
"tour": "authentication",
|
|
280
|
+
"order": "10",
|
|
281
|
+
"title": "The edge guard",
|
|
282
|
+
"body": [
|
|
283
|
+
"Every request passes through here first.",
|
|
284
|
+
"On success it attaches the resolved user before any handler runs."
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"file": "src/auth/cache.ts",
|
|
289
|
+
"match": "const cache = new Map",
|
|
290
|
+
"tour": "comment",
|
|
291
|
+
"title": "Not thread-safe"
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Each body array element is a separate Markdown paragraph. Use `"tour":
|
|
297
|
+
"comment"` for a callout (omit `order`).
|
|
298
|
+
|
|
299
|
+
The command handles what hand-editing gets wrong:
|
|
300
|
+
|
|
301
|
+
- Picks `//` or `#` from the file type, and refuses file types it doesn't know
|
|
302
|
+
rather than guessing.
|
|
303
|
+
- Verifies `match` is on the anchor line; if the line hint has drifted it
|
|
304
|
+
searches nearby and requires a **unique** hit. Ambiguous or missing anchors
|
|
305
|
+
are reported, never guessed.
|
|
306
|
+
- Places the block **above preceding doc comments and attributes**, with a
|
|
307
|
+
blank line after. This matters: consecutive `//`/`#` lines merge into one
|
|
308
|
+
comment block and only the first line is read as the `@tour` header — and a
|
|
309
|
+
Rust `#[derive(...)]` counts as a `#` comment to the scanner. It stays
|
|
310
|
+
*below* decorators (`@app.route`), which are code, so the `def`/`class`
|
|
311
|
+
underneath stays the resolved anchor.
|
|
312
|
+
- Applies bottom-up per file, so earlier anchors don't drift.
|
|
313
|
+
- Is **all-or-nothing**: if any entry fails to resolve, no file is written.
|
|
314
|
+
- Is **idempotent**: an entry whose header is already in the file is skipped,
|
|
315
|
+
so fixing a spec and re-running cannot duplicate comments.
|
|
316
|
+
|
|
317
|
+
Write the whole tour as one spec and apply it in one run. If it reports
|
|
318
|
+
problems, fix the spec and re-run — that is safe by design.
|
|
319
|
+
|
|
320
|
+
### Step prose style
|
|
321
|
+
|
|
322
|
+
- Write what the reader **cannot** see in the code: why, trade-offs, what
|
|
323
|
+
breaks, which alternative was rejected. Never narrate the syntax.
|
|
324
|
+
- 2–5 sentences. If a step needs more, it is two steps.
|
|
325
|
+
- First step of a tour sets the scene; last step says where the flow ends and
|
|
326
|
+
what to read next.
|
|
327
|
+
- Link vocabulary to the glossary instead of re-explaining it.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 6. Glossary
|
|
332
|
+
|
|
333
|
+
One file may hold many concepts, one per `##` heading; the slug is derived
|
|
334
|
+
from the heading. Link with `[Label](glossary:the-slug)`.
|
|
335
|
+
|
|
336
|
+
```markdown
|
|
337
|
+
## Session token
|
|
338
|
+
|
|
339
|
+
An opaque, random 32-byte value stored in Redis and mapped to a user id.
|
|
340
|
+
Deliberately not a JWT: revocation must be immediate, so the check hits the
|
|
341
|
+
store on every request. See [`src/auth/session.ts`](src/auth/session.ts).
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Write an entry for any term that is **domain-specific, internally invented, or
|
|
345
|
+
used in a non-standard way**. Skip industry-standard terms unless this codebase
|
|
346
|
+
means something unusual by them.
|
|
347
|
+
|
|
348
|
+
When an entry outgrows two paragraphs, move the body to a doc page and leave the
|
|
349
|
+
glossary entry as a one-line definition plus a `doc:` link.
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## 6b. Doc pages
|
|
354
|
+
|
|
355
|
+
For prose that needs room: design rationale, protocols, threat models, "how our
|
|
356
|
+
caching actually works". Drop a Markdown file under `.tour/docs/` — no
|
|
357
|
+
frontmatter required. **Folders are the navigation structure**, recursively, and
|
|
358
|
+
a folder's `index.md` is that folder's own page.
|
|
359
|
+
|
|
360
|
+
```
|
|
361
|
+
.tour/docs/
|
|
362
|
+
index.md # Docs landing page
|
|
363
|
+
caching/
|
|
364
|
+
index.md # the "Caching" section page
|
|
365
|
+
invalidation.md # nested beneath it
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Optional frontmatter: `title` (defaults to the leading `# Heading`, then the
|
|
369
|
+
file name), `navTitle` (shorter tree label), `order` (sort among siblings).
|
|
370
|
+
|
|
371
|
+
Link from anywhere — a step body, a component, a glossary entry, another doc —
|
|
372
|
+
with the `doc:` scheme, using the path under `.tour/docs/` without the extension:
|
|
373
|
+
|
|
374
|
+
```markdown
|
|
375
|
+
See [cache invalidation](doc:caching/invalidation).
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Keep doc pages out of step bodies' critical path: a step should stand alone and
|
|
379
|
+
*offer* the doc as a deeper read, not require it.
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 7. Verify before you report done
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
npx @tobisk/codesafari validate # frontmatter, dangling links, unresolved steps, diagrams
|
|
387
|
+
npx @tobisk/codesafari dev # optional: view it at http://localhost:4317
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
`validate` must pass with zero errors. Then check by hand:
|
|
391
|
+
|
|
392
|
+
- Every `slug` referenced in a tour's `components:` exists.
|
|
393
|
+
- Every `glossary:` and `doc:` link resolves.
|
|
394
|
+
- Every file path linked from Markdown exists.
|
|
395
|
+
- Every tour has a step `1`-equivalent and reads in order.
|
|
396
|
+
- No tour references a file excluded by `.gitignore` / `.codesafariignore`.
|
|
397
|
+
|
|
398
|
+
Report to the user: the tours and components you created, the questions you had
|
|
399
|
+
to assume answers to, and anything you deliberately left untoured.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Working agreements
|
|
404
|
+
|
|
405
|
+
- Read the code before writing about it. A confidently wrong tour is worse than
|
|
406
|
+
no tour.
|
|
407
|
+
- Prefer fewer, finished tours over broad coverage.
|
|
408
|
+
- Reuse the repo's own naming. If the team says "workspace", never write
|
|
409
|
+
"tenant".
|
|
410
|
+
- Keep `.tour/` Markdown and `@tour` comments consistent in voice: direct,
|
|
411
|
+
second person, present tense.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./chunk-7U7NFRK5-CTLlozLY.js";import{t as r}from"./chunk-JWPE2WC7-COMTgl4A.js";import{Qn as i,tr as a}from"./index-LgGsGSUh.js";import{m as o,t as s}from"./mermaid-parser.core-D9IKLdIu.js";var c=o().RailroadAbnf.parser.LangiumParser,l=a(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=a(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=a(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=a(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=a(e=>{switch(e.$type){case`AbnfStringLiteral`:case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=a(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=a(e=>{r(e,n),e.title&&n.setTitle(e.title),e.rules.map(e=>n.addRule(m(e)))},`populateDb`),g={parser:{parse:a(e=>{n.clear(),i.debug(`[ABNF Parser] Starting Langium parse`);let t=c.parse(e);if(t.lexerErrors.length>0||t.parserErrors.length>0)throw new s(t);let r=t.value;i.debug(`[ABNF Parser] Parsed rules:`,r.rules.length),h(r),i.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:n}},db:n,renderer:t,styles:e};export{g as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$t as e,Bt as t,Gt as n,Ht as r,Jt as i,Qt as a,Ut as o,Vt as s,Wt as c,Xt as l,Yt as u,Zt as d,en as f,qt as p}from"./index-LgGsGSUh.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,o,s,c){var l=e-n,u=t-r,d=(c?s:-s)/a(l*l+u*u),f=d*u,p=-d*l,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=o-s,w=m*_-g*h,T=(x<0?-1:1)*a(i(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(o/C-1),y11:D*(o/C-1)}}function x(){var i=m,x=h,S=f(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var t,f,m=+i.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-p,_=T.apply(this,arguments)-p,v=s(_-g),k=_>g;if(D||=t=O(),h<m&&(f=h,h=m,m=f),!(h>1e-12))D.moveTo(0,0);else if(v>e-1e-12)D.moveTo(h*n(g),h*d(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*n(_),m*d(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):a(m*m+h*h)),R=u(s(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*d(I)),W=o(L/h*d(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*n(A),K=h*d(A),q=m*n(N),J=m*d(N);if(R>1e-12){var Y=h*n(j),X=h*d(j),Z=m*n(M),Q=m*d(M),$;if(v<l){if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/d(r((ee*ne+te*re)/(a(ee*ee+te*te)*a(ne*ne+re*re)))/2),ae=a($[0]*$[0]+$[1]*$[1]);z=u(R,(m-ae)/(ie-1)),B=u(R,(h-ae)/(ie+1))}else z=B=0}}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,c(V.y01,V.x01),c(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,c(V.y01,V.x01),c(V.y11,V.x11),!k),D.arc(0,0,h,c(V.cy+V.y11,V.cx+V.x11),c(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,c(H.y11,H.x11),c(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,c(V.y01,V.x01),c(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,c(V.y01,V.x01),c(V.y11,V.x11),!k),D.arc(0,0,m,c(V.cy+V.y11,V.cx+V.x11),c(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,c(H.y11,H.x11),c(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),t)return D=null,t+``||null}return k.centroid=function(){var e=(+i.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-l/2;return[n(t)*e,d(t)*e]},k.innerRadius=function(e){return arguments.length?(i=typeof e==`function`?e:f(+e),k):i},k.outerRadius=function(e){return arguments.length?(x=typeof e==`function`?e:f(+e),k):x},k.cornerRadius=function(e){return arguments.length?(S=typeof e==`function`?e:f(+e),k):S},k.padRadius=function(e){return arguments.length?(C=e==null?null:typeof e==`function`?e:f(+e),k):C},k.startAngle=function(e){return arguments.length?(w=typeof e==`function`?e:f(+e),k):w},k.endAngle=function(e){return arguments.length?(T=typeof e==`function`?e:f(+e),k):T},k.padAngle=function(e){return arguments.length?(E=typeof e==`function`?e:f(+e),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{M as createArchitectureServices}from"./mermaid-parser.core-D9IKLdIu.js";
|