# Docok és gotchák

A store docjai és gotchái (`doc://<id>`, `gotcha://<id>`) helyben szerkesztendők, soha nem `sed`-del: az érintett részen kívül minden bájt marad.

- Doc: `tkt doc append` (egy sor vagy tétel: a tábla vagy lista végére), `tkt doc section set|append`, `tkt doc replace`.
- Gotcha: törzs `tkt gotcha edit <id> --file uj.md`, egy szakasz `tkt gotcha section set|append`; a severity változását minden parancs kiírja.
- Minden doc és gotcha kapjon `--description`-t: a hivatkozás pointerként is hozza.
- Ki hivatkozik rá: `tkt doc refs <id>` (`tkt gotcha refs` is): minden fajta; a `via` a módja: saját ref, `affects`, `mention` (`not bound`, ha semmi nem köti), örökölt `group:<id>`/`epic:<id>`, `appliesTo`, vagy `derived via SG-2` (milestone vagy release, tagon át); mind: `tkt gotcha list --refs`.

## Részletek

**doc append:** hatókör `--section H` (lásd **Szakaszok**) vagy az egész doc; üres sor nélkül jön, `--new-block` üres sort tesz elé. Csak táblasorból (`| … |`) álló szöveg a hatókör utolsó táblája alá kerül akkor is, ha lista követi; `--table N` másikat választ; rossz oszlopszám vagy tábla: `ERR_TABLE_INVALID`, nem ír. `--after "<szöveg>"` az egyetlen tartalmazó sor után szúr. A frontmatter bájtra marad, kivéve a `timestamp`-et: ha van, a törzset módosító `tkt doc append|replace`, `tkt doc section set|append` és `tkt gotcha edit|section` a mostani időre állítja, UTC-ben. **doc replace:** pontos, egyszer előforduló szöveget cserél (`--old`, `--new` / `--new-file`; `--new ""` töröl); 0: `ERR_TEXT_NO_MATCH`, több: `ERR_TEXT_AMBIGUOUS`. `--text` és `--file` kizárja egymást; backtickes Markdownhoz `--file -` heredoccal.

**Szakaszok:** a `--section H`, a `tkt doc section set|append` és a `tkt gotcha section set|append` a teljes címsort bármely szinten (H2-H6) megtalálja, mint a `tkt doc get` `--anchor`-ja; a `### H` egy szintet tart, a `## H (2)` a második `## H`. A szakasz a következő azonos vagy magasabb szintű címsorig tart. Két szinten ugyanaz a cím: `ERR_BODY_SECTION_AMBIGUOUS`; rövid alak (`10.2`): `ERR_BODY_SECTION_MISSING`; mindkettő a pontos alakokat sorolja, nem ír. Csak a sehol nem létező címsor jön létre, a végén, a `#`-ek szintjén (alapból `##`).

**new / edit:** meglévő id `ERR_ID_DUPLICATE`, hacsak nincs `--force` (`tkt doc new --force` mindent felülír; `tkt gotcha new --force` a törzset cseréli, a meg nem adott mezőket megtartja). Az `edit` csak a megadott mezőket írja, `''` törli; severity változásnál `severity critical → warn`. A doc `--description`-je (300 karakter) kifutó keretnél a `summary`; a `tkt doctor` jelzi a hibás útvonalat (`ERR_APPLIES_TO_INVALID`) és az ismeretlen csoportot.

**Csoport:** törzs `tkt group section set|append`, egészben `tkt group edit <id> --file torzs.md`; a `tkt group get --raw` az egész fájl; a `tkt group edit` a horgonyt mezőnként fésüli (`--no-repo-anchor` töröl), `--body` / `--file` a teljes törzset cseréli; `tkt group delete` nem üreset csak `--force`-szal. A `_group.md`-t ne kézzel.

**get:** a sima `tkt doc get <id>`, `tkt gotcha get <id>` és `tkt group get <id>` a fejléc és a metaadatai után a teljes törzset betű szerint írja ki: markupot nem értelmez (a `[x]` marad), nem tördel. Csoportnál ez a leírás minden szakasza; a `--raw`-val a frontmatter is jön.

- A `tkt doc new|edit` és a `tkt gotcha new|edit` metaadatai: `--type` (docnál `concept`, `howto`, `reference`, `decision`, `plan`), `--title`, `--description`, `--tag`, `--timestamp`, `--applies-path`, `--applies-keyword`, `--applies-group`. `tkt gotcha edit --json`: `severityChange` `{from, to}` vagy null.
- A `tkt doc get` és a `tkt gotcha get` `Referenced by` blokkja fajtánként ötöt nevez meg, a többit `+N more` és a refs parancs jelzi; a `--json` `referencedBy`-a a teljes lista, mint a refs parancs `--json`-ja (`shownAs`, `unbound`, `derived` is).

## Parancsok ezen az oldalon

- [`tkt doc new`](/docs/reference/commands/knowledge.md#tkt-doc-new): Create a managed doc (an existing one only with --force), with optional metadata
- [`tkt doc edit`](/docs/reference/commands/knowledge.md#tkt-doc-edit): Change a doc's metadata (type, title, description, tags, appliesTo); the body stays
- [`tkt doc delete`](/docs/reference/commands/knowledge.md#tkt-doc-delete): Delete a managed doc
- [`tkt doc append`](/docs/reference/commands/knowledge.md#tkt-doc-append): Append to the doc (or a section at any heading level)
- [`tkt doc replace`](/docs/reference/commands/knowledge.md#tkt-doc-replace): Replace one exact, unique text in the doc (e.g. its status line)
- [`tkt doc get`](/docs/reference/commands/knowledge.md#tkt-doc-get): Show a managed doc, or with --anchor the table rows / section a ref with that anchor delivers
- [`tkt doc list`](/docs/reference/commands/knowledge.md#tkt-doc-list): List all managed docs
- [`tkt doc refs`](/docs/reference/commands/knowledge.md#tkt-doc-refs): List the tickets and groups that reference a doc, and how (contextRef, requiredReading, mention, inherited from a group:\<id\> or epic:\<id\>, or its appliesTo matches them: appliesTo:group:\<id\>, appliesTo:keyword:\<k\>, appliesTo:path:\<glob\>), with the sections they name
- [`tkt doc section set`](/docs/reference/commands/knowledge.md#tkt-doc-section-set): Replace a section's content, up to the next heading of the same or a higher level (heading kept; created at the end only when the heading exists nowhere)
- [`tkt doc section append`](/docs/reference/commands/knowledge.md#tkt-doc-section-append): Append to a section at any heading level (= `doc append --section`; created at the end only when the heading exists nowhere)
- [`tkt gotcha new`](/docs/reference/commands/knowledge.md#tkt-gotcha-new): Create a managed gotcha (an existing one only with --force), with optional metadata
- [`tkt gotcha edit`](/docs/reference/commands/knowledge.md#tkt-gotcha-edit): Change a gotcha's body (--body / --file), severity or metadata; only the fields given change
- [`tkt gotcha delete`](/docs/reference/commands/knowledge.md#tkt-gotcha-delete): Delete a managed gotcha
- [`tkt gotcha get`](/docs/reference/commands/knowledge.md#tkt-gotcha-get): Show a managed gotcha, or with --anchor the section / table rows a ref with that anchor delivers
- [`tkt gotcha list`](/docs/reference/commands/knowledge.md#tkt-gotcha-list): List all managed gotchas
- [`tkt gotcha refs`](/docs/reference/commands/knowledge.md#tkt-gotcha-refs): List who references or inherits a gotcha: the groups that name it (requiredReading, contextRef), the tickets under them (group:\<id\>), an epic's children (epic:\<id\>), and the tickets that name it themselves (contextRef, mention) or that its appliesTo matches (appliesTo:group:\<id\>, appliesTo:keyword:\<k\>, appliesTo:path:\<glob\>)
- [`tkt gotcha section set`](/docs/reference/commands/knowledge.md#tkt-gotcha-section-set): Replace a section's content, up to the next heading of the same or a higher level (heading kept; created at the end only when the heading exists nowhere)
- [`tkt gotcha section append`](/docs/reference/commands/knowledge.md#tkt-gotcha-section-append): Append after the section's last line, at any heading level (no blank line unless --new-block; created at the end only when the heading exists nowhere)
- [`tkt group section set`](/docs/reference/commands/setup.md#tkt-group-section-set): Replace a section's content (heading kept; empty content clears it)
- [`tkt group section append`](/docs/reference/commands/setup.md#tkt-group-section-append): Append content after the section's last line (no blank line unless --new-block)
- [`tkt group edit`](/docs/reference/commands/setup.md#tkt-group-edit): Edit a group (partial update)
- [`tkt group get`](/docs/reference/commands/setup.md#tkt-group-get): Show a group: its header, then the descriptor body (overview and every section) verbatim
- [`tkt group list`](/docs/reference/commands/setup.md#tkt-group-list): List all groups
- [`tkt group delete`](/docs/reference/commands/setup.md#tkt-group-delete): Delete a group

## Kapcsolódó

- Hibakód · 422: [`ERR_TABLE_INVALID`](/docs/reference/errors.md#ERR_TABLE_INVALID): doc append: no such table, or a row's cell count differs
- Hibakód · 422: [`ERR_TEXT_NO_MATCH`](/docs/reference/errors.md#ERR_TEXT_NO_MATCH): The --old text is not in the target
- Hibakód · 422: [`ERR_TEXT_AMBIGUOUS`](/docs/reference/errors.md#ERR_TEXT_AMBIGUOUS): The --old text occurs more than once
- Hibakód · 422: [`ERR_APPLIES_TO_INVALID`](/docs/reference/errors.md#ERR_APPLIES_TO_INVALID): A doc or gotcha appliesTo path is not a usable repo glob (doctor only)
