gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commiteb7aeeb9eb7aeeb9mission brief 016mreeb7aeeb9/lib/mdview.hl

5.5 KB

  1. // lib/mdview.hl — THE MARKDOWN READ VIEW FOR LLM READERS (ticket #6, mission 014; CONCEPT.md "Data
  2. // formats": a Markdown read view for LLM readers). The ticket GET endpoints answer
  3. // `Accept: text/markdown` with a compact Markdown document instead of JSON (lib/api-helpers.hl
  4. // `wantsMarkdown`, `markdownReply`); JSON stays the default and is unchanged. Statics only.
  5. //
  6. // one ticket → # <project> #<n>: <subject>
  7. // state · opened (by) · updated · formerly · URL
  8. // the summary as written (it IS Markdown)
  9. // ## History — one `### <seq> · <when> · <author> <what>` per event, its text below
  10. // a list → # Tickets (<filters>): <count>
  11. // one line per ticket: `- <project> #<n> [<state>] <subject> · updated <when> · <url>`
  12. // Texts are embedded as written (they are Markdown already), so a text's own headings sit
  13. // inside the document — readers should take the `### <seq> ·` lines as the event boundaries.
  14. import { publicUrl } from './users.hl'
  15. static NL = "
  16. "
  17. // one line: line breaks and runs of spaces become one space
  18. static oneLine = (s) => {
  19. if (s == null) { return '' }
  20. parts = []
  21. for (w of ('' + s).replaceAll(NL, ' ').split(' ')) { if (w != '') { parts.push(w) } }
  22. return parts.join(' ')
  23. }
  24. // `> ` in front of every line (a previous summary inside an edit event)
  25. static quoted = (s) => {
  26. out = []
  27. for (l of ('' + s).split(NL)) { out.push(l == '' ? '>' : '> ' + l) }
  28. return out.join(NL)
  29. }
  30. static ticketLine = (row) => {
  31. return '- ' + row.project + ' ' + row.ref + ' [' + row.state + '] ' + oneLine(row.subject) + ' · updated ' + row.updated + ' · ' + publicUrl + row.href + relationTail(row)
  32. }
  33. // ---- relations (ticket #4, mission 017) --------------------------------------------------------
  34. // one ticket's document gets "Parent:", "Children (k of n done):", "Blocked by:", "Blocks:"
  35. // blocks under its URL; a list line gets ` · parent … · children n, k done · blocked by … · blocks …`
  36. static refName = (r) => { return r.project + ' ' + r.ref }
  37. static refLine = (r) => { return '- ' + refName(r) + ' [' + r.state + '] ' + oneLine(r.subject) + ' · ' + publicUrl + r.href }
  38. static confirmedOf = (refs) => {
  39. let n = 0
  40. for (r of refs) { if (r.state == 'done') { n = n + 1 } }
  41. return n
  42. }
  43. static relationTail = (row) => {
  44. parts = []
  45. if (row.parent != null) { parts.push('parent ' + refName(row.parent)) }
  46. total = row.children.length
  47. if (total > 0) { parts.push('children ' + total + (row.allChildrenConfirmed ? ', all done' : ', ' + confirmedOf(row.children) + ' done')) }
  48. if (row.blockedBy.length > 0) {
  49. bs = []
  50. for (r of row.blockedBy) { bs.push(refName(r) + ' [' + r.state + ']') }
  51. parts.push('blocked by ' + bs.join(', '))
  52. }
  53. if (row.blocks.length > 0) {
  54. bs = []
  55. for (r of row.blocks) { bs.push(refName(r)) }
  56. parts.push('blocks ' + bs.join(', '))
  57. }
  58. return parts.length == 0 ? '' : ' · ' + parts.join(' · ')
  59. }
  60. static relationLines = (t) => {
  61. lines = []
  62. if (t.parent != null) {
  63. lines.push('')
  64. lines.push('Parent: ' + refName(t.parent) + ' [' + t.parent.state + '] ' + oneLine(t.parent.subject) + ' · ' + publicUrl + t.parent.href)
  65. }
  66. total = t.children.length
  67. if (total > 0) {
  68. lines.push('')
  69. lines.push('Children (' + (t.allChildrenConfirmed ? 'all ' + total + ' done' : confirmedOf(t.children) + ' of ' + total + ' done') + '):')
  70. for (r of t.children) { lines.push(refLine(r)) }
  71. }
  72. if (t.blockedBy.length > 0) {
  73. lines.push('')
  74. lines.push('Blocked by:')
  75. for (r of t.blockedBy) { lines.push(refLine(r)) }
  76. }
  77. if (t.blocks.length > 0) {
  78. lines.push('')
  79. lines.push('Blocks:')
  80. for (r of t.blocks) { lines.push(refLine(r)) }
  81. }
  82. return lines
  83. }
  84. // a list: { tickets } (rows, as the JSON answer) + a label of its filters ('' = all)
  85. static listDocument = (rows, filters) => {
  86. lines = []
  87. lines.push('# Tickets' + (filters != '' ? ' (' + filters + ')' : '') + ': ' + rows.length)
  88. lines.push('')
  89. for (r of rows) { lines.push(ticketLine(r)) }
  90. return lines.join(NL) + NL
  91. }
  92. static eventHeadline = (e) => {
  93. let what = e.label
  94. if (e.kind == 'state') { what = 'changed the state: ' + (e.from != '' ? e.from : '?') + ' → ' + e.to }
  95. if (e.kind == 'edit') {
  96. parts = []
  97. if (e.subjectChanged) { parts.push('subject') }
  98. if (e.summaryChanged) { parts.push('summary') }
  99. what = 'edited the ' + parts.join(' and ')
  100. }
  101. return '### ' + e.seq + ' · ' + e.when + ' · ' + oneLine(e.author) + ' ' + what
  102. }
  103. // one ticket: { ticket (row), events (rows, oldest first) } as the JSON answer
  104. static ticketDocument = (data) => {
  105. t = data.ticket
  106. let opener = ''
  107. for (e of data.events) { if (e.kind == 'created' && opener == '') { opener = oneLine(e.author) } }
  108. lines = []
  109. lines.push('# ' + t.project + ' ' + t.ref + ': ' + oneLine(t.subject))
  110. lines.push('')
  111. let meta = 'state: ' + t.state + ' · opened ' + t.created + (opener != '' ? ' by ' + opener : '') + ' · updated ' + t.updated
  112. if (t.hasOld) { meta = meta + ' · formerly ' + t.oldRef }
  113. lines.push(meta)
  114. lines.push(publicUrl + t.href)
  115. for (l of relationLines(t)) { lines.push(l) }
  116. lines.push('')
  117. lines.push(t.summary != '' ? t.summary : '(no summary)')
  118. lines.push('')
  119. lines.push('## History')
  120. for (e of data.events) {
  121. lines.push('')
  122. lines.push(eventHeadline(e))
  123. if (e.kind == 'edit') {
  124. if (e.subjectChanged) {
  125. lines.push('')
  126. lines.push('Subject before: ' + oneLine(e.oldSubject))
  127. }
  128. if (e.summaryChanged) {
  129. lines.push('')
  130. lines.push('Summary before:')
  131. lines.push('')
  132. lines.push(e.oldSummary != '' ? quoted(e.oldSummary) : '> (empty)')
  133. }
  134. }
  135. if (e.hasText) {
  136. lines.push('')
  137. lines.push(e.text)
  138. }
  139. }
  140. return lines.join(NL) + NL
  141. }

Branches

Latest commits

  • eb7aeeb9mission brief 016mre
  • e4c34759paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • 26efb23freport w6-events (events test)mre
  • c6bfab04mission 015: re-vendor Hybriel 0f396652 (static build), reportmre
  • b7ec5981mission brief 015mre
  • 5dc68731docker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
  • 8a460b16mission 014: Apollo's 'stream opened right after the start gets no live events' is not a tickets bug — events.mjs checks early streamsmre
  • 6309ca81mission brief 014mre
  • c1161469mission 013: GitHub pipe tables on ticket pages (lib/markdown.hl + View + CSS) and re-vendor hybriel master a832f73bmre
  • a30b5d12mission brief (w13)mre
  • b50a6f93w9 (tickets): re-vendor hybriel 9f912f3b (#146 emit in a lib static, #147) — the 12 live-push emits in lib/api.hl compile as they are; cold start (#148): tests wait TICKETS_COLD_MS for every start, deploy.sh gates browser + events and waits up to 120 s for the URL, container /tmp tmpfs + hybriel-cache volume; events-client stops at EVENTS_MAX inside a chunk; connect.mjs ports by env. bin/hybriel sha256 7421907868ac07d8a7d08296b083c6f8b20407d0e099ce4bebbf7ae053d9060a. Gates (8720–8739): browser 315/0 (+ all-cold 315/0), events 48/0 cold, connect 60/0, short-id 19/0; real-data copy old 0e8a41c vs new: 2,425 reads + 72 writes identical after masking ?v hashes, offline at, route order; event stream on the copy delivers. Not deployed.mre
  • 43be6578w9: re-vendor hybriel master edfd400a; event stream imports sseStart/sseSend/sseAlive from hl:http1 (hybriel#144), useTransport gone; tools/import.hl plain declarations. BLOCKED: hybriel-native refuses `emit client` in a static (lib/api.hl) — the server does not compile on edfd400a, gates fail at start; scratch copy without those emits: events 48/0, gate 254 ok up to the first live pushmre
  • 0e8a41caw6 (ticket #26): event stream for programs — GET /api/events (Server-Sent Events)mre
  • bb64d57cmission 012 (ticket #25 API part): every /api/projects/<x>/… route takes the project's id (12-char record id) as well as its slug, same answers byte for byte; tickets stay under their project, no global /api/tickets/<x>. gate 315/0 (old code: the 13 id checks fail), connect 60/0, live-data copy old vs new 1,484 identical, slug vs id 772 identicalmre
  • 7538b034mission 011 (ticket #25 web part): short page URLs /<slug> and /<slug>/<number>; /projects/<slug>, /projects/<slug>/<n>, /projects/<slug>/tickets/<n> and /tickets/<ref> answer 301 (current slug); slug pages moved behind hl:web's own routes after construction (they answered /__hl/* and /components/*.hl); reserved slugs refused; API paths unchanged. gate 293/0, connect 60/0, live-data copy 187/0, API old vs new: only page links differmre
  • 0369106emission 010 (code order) 4/4: README file map + import order + 'Same output' test, STATUS (entry, lessons, how to verify), LOG, report; tests/realdata-baseline.mjs + realdata-compare*.py (a cleanup answers the same on live data), tests/letcount.pymre
  • a75e0279mission 010 (code order) 3/4: let only where a variable is reassigned or re-bound in a loop body (456 lets → plain declarations; Hybriel refuses a plain declaration inside a loop on its 2nd pass). gate 249/0, connect 60/0, real-data reads identical, a 50-step write sequence (API + faces) identical to the old codemre
  • e9d5c618mission 010 (code order) 2/4: one lib/ file per topic — store.hl split into projects / tickets (+ relations) / events / tickets-helpers, util.hl shared helpers (env, storage dir, URLs, sorts, Vienna time), the function routes out of project.hl into lib/api.hl (thin; auth/filters/Accept in api-helpers.hl), invite + member-removal logic out of the faces/routes into invites.hl / tickets.hl; project.hl is the map. /login/callback gets req + the session store by reference. gate 249/0, connect 60/0, real-data reads identicalmre
  • 97e269b5mission 010 (code order) 1/4: .hl files out of the root — lib/ (store, users, connections, invites, migrate, markdown, mdview, import = ticketfile, util = localtime, jsoncheck, api-helpers = api), tools/import.hl, components/styles.hl; import paths only. gate 249/0, connect 60/0, real-data reads identicalmre
  • 38f9d10ftickets: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gate 249/0, connect 60/0mre