oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package fakeclaude
2
3import (
4 "regexp"
5 "strconv"
6 "strings"
7)
8
9// markdownSample is a coordinator reply in the shape the conversation
10// streams most: a bold opening line, a bold-led bullet list and a
11// numbered list, with a task link and inline code.
12const markdownSample = "**Yes. This is the right shape for it.** The invoice total is counted twice when delivery is added.\n\nTwo people see it:\n\n- **Guest:** sees the total on the basket page.\n- **Customer:** sees it again on the receipt.\n\nWhat I'd do, in [Fix the invoice total](/tasks/tks6kwzzdngr):\n\n1. **Owner of the fix:** Engineering, on the checkout repository.\n2. **One complete change:** the total, the receipt and `go test ./checkout/...` for both.\n3. **Review:** an independent check before it merges."
13
14// pasteSample is a reply with two things to paste: a command, with the
15// characters a copy must keep (<, &, quotes, a tab, trailing spaces), and
16// a prompt, which wraps.
17const pasteSample = "Run this in a terminal:\n\n```bash\ngo test ./internal/checkout/... -run 'TestTotal' > out.txt && echo \"a < b\"\t \n```\n\nThen paste this prompt into the review:\n\n```prompt\nCheck that the invoice total counts delivery once, & say which test shows it. Keep the receipt as it is.\n```"
18
19// markdownWord asks for markdownSample as the reply ("replymd"), for a
20// long reply of it repeated ("replymd:long"), or for pasteSample
21// ("replymd:paste").
22var markdownWord = regexp.MustCompile(`\breplymd(:long|:paste)?\b`)
23
24func markdownReply(newest string) (string, bool) {
25 m := markdownWord.FindStringSubmatch(newest)
26 if m == nil {
27 return "", false
28 }
29 if m[1] == "" {
30 return markdownSample, true
31 }
32 if m[1] == ":paste" {
33 return pasteSample, true
34 }
35 parts := make([]string, 30)
36 for i := range parts {
37 parts[i] = "## Part " + strconv.Itoa(i+1) + "\n\n" + markdownSample
38 }
39 return strings.Join(parts, "\n\n"), true
40}
41
42// chunksWord streams the reply in that many deltas ("chunks:<n>",
43// three without it).
44var chunksWord = regexp.MustCompile(`\bchunks:([0-9]+)`)
45
46func chunkCount(newest string) int {
47 if m := chunksWord.FindStringSubmatch(newest); m != nil {
48 if n, err := strconv.Atoi(m[1]); err == nil && n > 0 {
49 return n
50 }
51 }
52 return 3
53}
54