@theglitchking/hit-em-with-the-docs 2.1.1 → 2.3.0

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.
Files changed (112) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +5 -0
  4. package/commands/audit-facts.md +25 -0
  5. package/commands/cite.md +17 -0
  6. package/commands/extract-facts.md +66 -0
  7. package/commands/find-citers.md +16 -0
  8. package/commands/help.md +86 -0
  9. package/commands/migrate-incident.md +18 -0
  10. package/dist/action/core/audit/auditor.d.ts +14 -0
  11. package/dist/action/core/audit/auditor.d.ts.map +1 -1
  12. package/dist/action/core/domains/classifier.d.ts +15 -1
  13. package/dist/action/core/domains/classifier.d.ts.map +1 -1
  14. package/dist/action/core/knowledge-base/audit.d.ts +67 -0
  15. package/dist/action/core/knowledge-base/audit.d.ts.map +1 -0
  16. package/dist/action/core/knowledge-base/cite.d.ts +41 -0
  17. package/dist/action/core/knowledge-base/cite.d.ts.map +1 -0
  18. package/dist/action/core/knowledge-base/citers.d.ts +119 -0
  19. package/dist/action/core/knowledge-base/citers.d.ts.map +1 -0
  20. package/dist/action/core/knowledge-base/extract.d.ts +61 -0
  21. package/dist/action/core/knowledge-base/extract.d.ts.map +1 -0
  22. package/dist/action/core/knowledge-base/migrate.d.ts +33 -0
  23. package/dist/action/core/knowledge-base/migrate.d.ts.map +1 -0
  24. package/dist/action/core/maintain/orchestrator.d.ts.map +1 -1
  25. package/dist/action/core/metadata/errors.d.ts +62 -0
  26. package/dist/action/core/metadata/errors.d.ts.map +1 -0
  27. package/dist/action/core/metadata/schema.d.ts +810 -49
  28. package/dist/action/core/metadata/schema.d.ts.map +1 -1
  29. package/dist/action/generators/facts-index.d.ts +27 -0
  30. package/dist/action/generators/facts-index.d.ts.map +1 -0
  31. package/dist/action/generators/incidents-index.d.ts +21 -0
  32. package/dist/action/generators/incidents-index.d.ts.map +1 -0
  33. package/dist/action/generators/symptoms-index.d.ts +20 -0
  34. package/dist/action/generators/symptoms-index.d.ts.map +1 -0
  35. package/dist/action/generators/table.d.ts +8 -0
  36. package/dist/action/generators/table.d.ts.map +1 -0
  37. package/dist/action/index.d.ts +7 -0
  38. package/dist/action/index.d.ts.map +1 -1
  39. package/dist/action/index.js +4 -4
  40. package/dist/action/utils/config.d.ts +99 -0
  41. package/dist/action/utils/config.d.ts.map +1 -0
  42. package/dist/cli/index.js +248 -1
  43. package/dist/cli/index.js.map +1 -1
  44. package/dist/core/audit/auditor.d.ts +14 -0
  45. package/dist/core/audit/auditor.d.ts.map +1 -1
  46. package/dist/core/audit/auditor.js +19 -3
  47. package/dist/core/audit/auditor.js.map +1 -1
  48. package/dist/core/domains/classifier.d.ts +15 -1
  49. package/dist/core/domains/classifier.d.ts.map +1 -1
  50. package/dist/core/domains/classifier.js +100 -1
  51. package/dist/core/domains/classifier.js.map +1 -1
  52. package/dist/core/knowledge-base/audit.d.ts +67 -0
  53. package/dist/core/knowledge-base/audit.d.ts.map +1 -0
  54. package/dist/core/knowledge-base/audit.js +158 -0
  55. package/dist/core/knowledge-base/audit.js.map +1 -0
  56. package/dist/core/knowledge-base/cite.d.ts +41 -0
  57. package/dist/core/knowledge-base/cite.d.ts.map +1 -0
  58. package/dist/core/knowledge-base/cite.js +82 -0
  59. package/dist/core/knowledge-base/cite.js.map +1 -0
  60. package/dist/core/knowledge-base/citers.d.ts +119 -0
  61. package/dist/core/knowledge-base/citers.d.ts.map +1 -0
  62. package/dist/core/knowledge-base/citers.js +249 -0
  63. package/dist/core/knowledge-base/citers.js.map +1 -0
  64. package/dist/core/knowledge-base/extract.d.ts +61 -0
  65. package/dist/core/knowledge-base/extract.d.ts.map +1 -0
  66. package/dist/core/knowledge-base/extract.js +132 -0
  67. package/dist/core/knowledge-base/extract.js.map +1 -0
  68. package/dist/core/knowledge-base/migrate.d.ts +33 -0
  69. package/dist/core/knowledge-base/migrate.d.ts.map +1 -0
  70. package/dist/core/knowledge-base/migrate.js +112 -0
  71. package/dist/core/knowledge-base/migrate.js.map +1 -0
  72. package/dist/core/maintain/orchestrator.d.ts.map +1 -1
  73. package/dist/core/maintain/orchestrator.js +48 -1
  74. package/dist/core/maintain/orchestrator.js.map +1 -1
  75. package/dist/core/metadata/errors.d.ts +62 -0
  76. package/dist/core/metadata/errors.d.ts.map +1 -0
  77. package/dist/core/metadata/errors.js +95 -0
  78. package/dist/core/metadata/errors.js.map +1 -0
  79. package/dist/core/metadata/schema.d.ts +806 -45
  80. package/dist/core/metadata/schema.d.ts.map +1 -1
  81. package/dist/core/metadata/schema.js +472 -42
  82. package/dist/core/metadata/schema.js.map +1 -1
  83. package/dist/generators/facts-index.d.ts +27 -0
  84. package/dist/generators/facts-index.d.ts.map +1 -0
  85. package/dist/generators/facts-index.js +111 -0
  86. package/dist/generators/facts-index.js.map +1 -0
  87. package/dist/generators/incidents-index.d.ts +21 -0
  88. package/dist/generators/incidents-index.d.ts.map +1 -0
  89. package/dist/generators/incidents-index.js +79 -0
  90. package/dist/generators/incidents-index.js.map +1 -0
  91. package/dist/generators/symptoms-index.d.ts +20 -0
  92. package/dist/generators/symptoms-index.d.ts.map +1 -0
  93. package/dist/generators/symptoms-index.js +123 -0
  94. package/dist/generators/symptoms-index.js.map +1 -0
  95. package/dist/generators/table.d.ts +8 -0
  96. package/dist/generators/table.d.ts.map +1 -0
  97. package/dist/generators/table.js +23 -0
  98. package/dist/generators/table.js.map +1 -0
  99. package/dist/index.d.ts +7 -0
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +8 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/utils/config.d.ts +99 -0
  104. package/dist/utils/config.d.ts.map +1 -0
  105. package/dist/utils/config.js +95 -0
  106. package/dist/utils/config.js.map +1 -0
  107. package/package.json +1 -1
  108. package/templates/knowledge-base/README.md +31 -0
  109. package/templates/knowledge-base/fact.template.md +44 -0
  110. package/templates/knowledge-base/incident-facts.template.md +31 -0
  111. package/templates/knowledge-base/incident-narrative.template.md +50 -0
  112. package/templates/knowledge-base/playbook-symptoms.template.md +74 -0
@@ -6,13 +6,13 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Official marketplace for hit-em-with-the-docs - Self-managing documentation system",
9
- "version": "2.1.1"
9
+ "version": "2.3.0"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "hit-em-with-the-docs",
14
14
  "description": "Self-managing documentation system with hierarchical structure, intelligent automation, pattern discovery, and agent orchestration",
15
- "version": "2.1.1",
15
+ "version": "2.3.0",
16
16
  "author": {
17
17
  "name": "TheGlitchKing"
18
18
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hit-em-with-the-docs",
3
3
  "description": "Self-managing documentation system with hierarchical structure, intelligent automation, pattern discovery, and agent orchestration",
4
- "version": "2.1.1",
4
+ "version": "2.3.0",
5
5
  "author": {
6
6
  "name": "TheGlitchKing",
7
7
  "email": "theglitchking@users.noreply.github.com"
package/README.md CHANGED
@@ -9,6 +9,11 @@
9
9
  > [!IMPORTANT]
10
10
  > You still need to remember to use this plugin when creating documentation! As projects grow, documentation needs to be created and maintained. You'll need to invoke this plugin or ask an LLM to create documentation for your features, workflows, or infrastructure. This plugin must be invoked to create, update, or maintain your docs.
11
11
 
12
+ > [!NOTE]
13
+ > **New in 2.3.0:** the knowledge-base primitives layer. Three new tiers (`fact`, `incident-narrative`, `incident-facts`) for citable atomic claims and immutable postmortems, plus an optional `symptoms:` frontmatter field on any-tier playbooks for symptom→playbook routing with `cites:` to facts. Three new deterministic indexes (`facts/INDEX.md`, `incidents/INDEX.md`, `symptoms/INDEX.md`) auto-generate on `hewtd maintain` when a vault root exists. Five new CLI commands: `find-citers`, `audit-facts [--run-verify]`, `extract-facts`, `cite`, `migrate-incident`. New `audit --strict` flag for CI gating. New `/hit-em-with-the-docs:help` slash command for LLM orientation. Four authoring templates at `templates/knowledge-base/`. Full reference: [`docs/knowledge-base-primitives.md`](./docs/knowledge-base-primitives.md). Agent guide: [`docs/LLM-GUIDE.md`](./docs/LLM-GUIDE.md).
14
+ >
15
+ > **New in 2.2.0:** the `tier` enum gains a `"plan"` value for [persistent-planning](https://github.com/TheGlitchKing/persistent-planning) lg-mode artifacts (phase / task / atom / notes documents), and the `version` and `status` fields are now conditionally relaxed for plan-tier docs (plans use lifecycle status, not semver). Existing tiers (guide / standard / example / reference / admin) are unchanged. See [`docs/plan-tier-frontmatter.md`](./docs/plan-tier-frontmatter.md) for the full reference.
16
+
12
17
  ---
13
18
 
14
19
  ## Summary
@@ -0,0 +1,25 @@
1
+ ---
2
+ description: Audit knowledge-base facts for staleness; optionally re-verify a specific fact
3
+ allowed-tools: Bash(npx:*)
4
+ argument-hint: "[fact-id-to-verify]"
5
+ ---
6
+
7
+ Arguments: $ARGUMENTS
8
+
9
+ If `$ARGUMENTS` is empty:
10
+ - Run `npx --no @theglitchking/hit-em-with-the-docs audit-facts --json` and parse the result.
11
+ - Report to the user: list of stale facts (with how many days overdue) and any unverifiable facts (malformed `last_verified`).
12
+ - For each stale fact, suggest one of three actions:
13
+ 1. Re-verify it: `/hit-em-with-the-docs:audit-facts <fact-id>`
14
+ 2. Mark it weakened (if the user knows it's no longer reliable): edit the fact's frontmatter `status: weakened`
15
+ 3. Open an incident to investigate the divergence (use `/hit-em-with-the-docs:migrate-incident` or create a new incident folder)
16
+
17
+ If `$ARGUMENTS` is a fact id:
18
+ - Run `npx --no @theglitchking/hit-em-with-the-docs audit-facts --run-verify "$ARGUMENTS" --json` and parse the result.
19
+ - If `updated` is `true`, confirm the new `last_verified` date to the user.
20
+ - If the verify command failed (`exit_code != 0`), show the stdout and stderr, then ask the user how to proceed:
21
+ - Re-run the verify command after fixing the issue
22
+ - Mark the fact weakened
23
+ - Open an incident to track the divergence
24
+
25
+ Wait for the user's decision before taking any further action.
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Insert a cites: entry for a fact into a playbook's symptoms block
3
+ allowed-tools: Bash(npx:*), Read
4
+ argument-hint: "<fact-id> <playbook-path>"
5
+ ---
6
+
7
+ Arguments: $ARGUMENTS
8
+
9
+ Parse `$ARGUMENTS` as `<fact-id> <playbook-path>`.
10
+
11
+ - If either is missing, ask the user for the missing one.
12
+ - Confirm the fact exists by running `npx --no @theglitchking/hit-em-with-the-docs find-citers <fact-id> --json` and checking `fact_exists`. If the fact doesn't exist, tell the user and stop.
13
+ - Read the playbook file to see its current `symptoms:` block (if any).
14
+ - If the playbook has multiple `symptoms:` entries, ask the user which one to add the citation to. Offer them by alert_name / user_phrase / error_pattern.
15
+ - Run `npx --no @theglitchking/hit-em-with-the-docs cite <fact-id> --file <playbook-path> --dry-run` first to show the proposed change. Get the user's confirmation.
16
+ - On confirmation, re-run without `--dry-run` to write the change.
17
+ - Suggest the user run `npx --no @theglitchking/hit-em-with-the-docs audit --strict` afterward to confirm the cited fact is valid.
@@ -0,0 +1,66 @@
1
+ ---
2
+ description: Propose 5-10 atomic facts from an incident narrative; user accepts/edits/rejects; commit accepted facts
3
+ allowed-tools: Bash(npx:*), Read
4
+ argument-hint: "<path-to-incident-folder>"
5
+ ---
6
+
7
+ Arguments: $ARGUMENTS
8
+
9
+ This is the **LLM-driven proposer** for the `hewtd extract-facts` workflow. Your job in this turn is to:
10
+
11
+ 1. **Read the incident narrative.** Open `<incident-folder>/narrative.md`. Skim the Timeline, Root Cause, Resolution, and Lessons Learned sections.
12
+ 2. **Propose 5-10 candidate facts.** Each candidate is a single atomic citable claim. Look for things like:
13
+ - "X reads/writes/depends-on Y under condition Z"
14
+ - "X fails when Y, but appears successful at the surface level"
15
+ - "X requires Y in order to Z"
16
+ - Specific timing windows, retry behaviors, exact log signatures, configuration gotchas
17
+ - Things that were SURPRISING during the incident (those make the best facts)
18
+ 3. **For each candidate, produce a FactSpec:**
19
+
20
+ ```json
21
+ {
22
+ "id": "<kebab-case-slug>",
23
+ "title": "<short human-readable claim>",
24
+ "confidence": "high | medium | low | hypothesis",
25
+ "claim": "<one-paragraph stating the atomic claim>",
26
+ "howToVerify": "<one paragraph on how to confirm it>",
27
+ "consequences": "<one paragraph on what this means in practice>",
28
+ "verifyCommand": "<optional one-line shell command that proves the claim>",
29
+ "tags": ["<tag-1>", "<tag-2>"],
30
+ "domains": ["<domain>"]
31
+ }
32
+ ```
33
+
34
+ 4. **Present the candidates to the user.** For each one, include:
35
+ - The proposed id, title, confidence
36
+ - A quote from the narrative justifying the fact
37
+ - The proposed verify_command (with caveat: it's LLM-derived, may need refinement)
38
+
39
+ 5. **Let the user accept / edit / reject each.** Don't proceed to step 6 until the user has signed off on the final list.
40
+
41
+ 6. **Commit accepted facts.** Construct a JSON array of the accepted FactSpec objects. Then run:
42
+
43
+ ```bash
44
+ npx --no @theglitchking/hit-em-with-the-docs extract-facts "<incident-folder>" --accept '<JSON-array>'
45
+ ```
46
+
47
+ The CLI is the **deterministic writer** — it writes the fact files with provenance auto-populated, and updates the incident's `facts.md` `produced:` list (idempotent).
48
+
49
+ 7. **Suggest next steps.** After commit, suggest:
50
+ - Run `npx --no @theglitchking/hit-em-with-the-docs audit --strict` to confirm the new facts validate cleanly
51
+ - Enrich relevant playbooks with `cites:` for the new facts via `/hit-em-with-the-docs:cite`
52
+
53
+ ## Quality bar for fact proposals
54
+
55
+ Reject your own first instinct if any of these are true:
56
+ - The proposed fact has "and" / "also" in the title — split into two facts
57
+ - The proposed fact restates something obvious (e.g. "Vault is a secrets manager")
58
+ - The proposed fact has no actionable consequences for future on-calls
59
+ - The proposed verify_command would require an SSH'd shell on a remote host the LLM can't reach — flag it for the user as "verify manually" rather than including in `verify_command`
60
+
61
+ ## What NOT to do
62
+
63
+ - **Do not commit facts without user sign-off.** Even if a fact looks obvious, the user accepts each one.
64
+ - **Do not fabricate provenance or sources.** The CLI auto-populates `provenance` with the incident folder path; you don't need to set it.
65
+ - **Do not propose more than 10 facts in one pass.** If the incident is rich, propose the top 10 and offer a second pass.
66
+ - **Do not start writing `<vault>/facts/*.md` directly.** Always go through the `hewtd extract-facts --accept` CLI.
@@ -0,0 +1,16 @@
1
+ ---
2
+ description: Show all playbooks and incidents that cite a given fact id
3
+ allowed-tools: Bash(npx:*)
4
+ argument-hint: "<fact-id>"
5
+ ---
6
+
7
+ Arguments: $ARGUMENTS
8
+
9
+ - If `$ARGUMENTS` is empty, ask the user which fact id to look up.
10
+ - Otherwise, run `npx --no @theglitchking/hit-em-with-the-docs find-citers "$ARGUMENTS" --json` and parse the JSON output.
11
+
12
+ Present the result to the user in a readable format:
13
+ - If `fact_exists` is `false`, tell the user the fact id wasn't found and suggest running `/hit-em-with-the-docs:audit-facts` to see all known facts.
14
+ - Otherwise, list the citers (playbook paths), incidents that produced it, and incidents that strengthened/weakened it.
15
+
16
+ If any of the playbook paths look suspicious or out of place, flag them for the user.
@@ -0,0 +1,86 @@
1
+ ---
2
+ description: Brief the LLM on hit-em-with-the-docs' surface (commands, primitives, frontmatter contract, knowledge-base workflow) and orient the user.
3
+ allowed-tools: Bash(npx:*), Read
4
+ argument-hint: "[topic]"
5
+ ---
6
+
7
+ Arguments: $ARGUMENTS
8
+
9
+ You are working in a project that uses **`@theglitchking/hit-em-with-the-docs`** (hewtd) — a self-managing documentation system. Your job in this turn is to orient the user (and yourself) on hewtd's surface and offer a next step.
10
+
11
+ ## When the user invokes this command
12
+
13
+ If `$ARGUMENTS` is empty, give a tight orientation (what hewtd does, the 5 most common workflows, the commands available). Don't dump everything — focus on what's actionable in this project's current state. End with a question: "What would you like to do?"
14
+
15
+ If `$ARGUMENTS` matches one of the topics below, focus the orientation on that topic specifically:
16
+ - `frontmatter` — explain the 22-field schema, the 9 tiers, and per-tier required fields
17
+ - `knowledge-base` / `kb` — explain the 3 KB tiers + symptoms field; point at `docs/knowledge-base-primitives.md` and `templates/knowledge-base/`
18
+ - `commands` — list every `hewtd` CLI command with a one-line purpose
19
+ - `audit` — explain `hewtd audit` + `--strict`; explain when to use each
20
+ - `integrate` — explain `hewtd integrate <file>` and when to use it
21
+ - `templates` — list available templates with paths
22
+
23
+ ## What hewtd does (the one-paragraph brief)
24
+
25
+ `hewtd` manages a `.documentation/` tree organized into 15 domains (security, devops, database, api, standards, testing, architecture, features, quickstart, procedures, workflows, agents, backups, troubleshooting, plans). Every document carries YAML frontmatter validated against a 22-field schema with 9 tiers (`guide`, `standard`, `example`, `reference`, `admin`, `plan`, `fact`, `incident-narrative`, `incident-facts`). It also generates auto-indexes, audits docs for compliance, checks links, and as of 2.3.0 manages a knowledge-base subtree at `.documentation/knowledge-base/` with citable facts, postmortem incidents, and playbook-symptom mappings.
26
+
27
+ ## The 5 most common workflows
28
+
29
+ 1. **Adding a new doc** — write the markdown with the right frontmatter, place it in the appropriate domain folder, run `hewtd maintain` to update indexes. Use `hewtd integrate <file>` if you have a raw markdown file that needs auto-classification first.
30
+ 2. **Checking doc health** — `hewtd audit` (errors + warnings) or `hewtd audit --strict` (KB-coded errors fail CI).
31
+ 3. **Creating a fact in the knowledge base (2.3.0+)** — copy `templates/knowledge-base/fact.template.md` into `<vault-root>/facts/<kebab-id>.md`, fill in required fields (`id`, `confidence`, `last_verified`, `provenance`).
32
+ 4. **Documenting an incident (2.3.0+)** — create `<vault-root>/incidents/YYYY-MM-DD-slug/` with both `narrative.md` and `facts.md` from the templates.
33
+ 5. **Enriching a playbook (2.3.0+)** — add a `symptoms:` block to a playbook's frontmatter; cite the facts the playbook depends on.
34
+
35
+ ## Commands available
36
+
37
+ CLI (via `npx --no @theglitchking/hit-em-with-the-docs <cmd>` or `hewtd <cmd>` if globally installed):
38
+
39
+ - `init` — scaffold a `.documentation/` tree
40
+ - `maintain` — full maintenance pass (sync metadata, check links, audit, generate KB indexes)
41
+ - `audit [--strict]` — compliance check
42
+ - `link-check` — internal link validation
43
+ - `metadata-sync` — backfill missing frontmatter fields
44
+ - `integrate <file>` — auto-classify and place a raw markdown file
45
+ - `discover patterns|anti-patterns|standards|dependencies` — extract conventions from source code
46
+ - `report health|audit|links` — generate detailed reports
47
+ - `list` — list all 15 domains
48
+ - `search <query>` — search documentation
49
+
50
+ Slash commands (Claude Code):
51
+ - `/hit-em-with-the-docs:status` — installed version, update policy, hook state
52
+ - `/hit-em-with-the-docs:policy [auto|nudge|off]` — get/set update policy
53
+ - `/hit-em-with-the-docs:update` — pull the latest version
54
+ - `/hit-em-with-the-docs:relink` — re-run skill linker
55
+ - `/hit-em-with-the-docs:help` — this command
56
+
57
+ ## Frontmatter contract (the short version)
58
+
59
+ **Required for every doc:** `title`, `tier`, `domains` (array, ≥1), `status`, `last_updated` (YYYY-MM-DD), `version` (semver).
60
+
61
+ **Exception — lifecycle-tracked tiers** (`plan`, `fact`, `incident-narrative`, `incident-facts`): `version` is **optional**, and `status` is free-form. These tiers have their own required-field extensions:
62
+ - `fact`: `id`, `confidence`, `last_verified`, `provenance` (≥1 entry)
63
+ - `incident-narrative`: `id`, `date`, `severity`, `resolution_status`, `components`
64
+ - `incident-facts`: `incident_id`, `produced` (may be empty)
65
+
66
+ Full reference: `docs/knowledge-base-primitives.md` and `docs/plan-tier-frontmatter.md`.
67
+
68
+ ## Templates
69
+
70
+ For knowledge-base authoring, four templates ship at `templates/knowledge-base/`:
71
+ - `fact.template.md`
72
+ - `incident-narrative.template.md`
73
+ - `incident-facts.template.md`
74
+ - `playbook-symptoms.template.md` (frontmatter snippet)
75
+
76
+ When asked to create one of these, **read the template first**, replace every `<placeholder>` with concrete content, and run `hewtd audit --strict` on the parent dir to confirm.
77
+
78
+ ## Where to find more
79
+
80
+ - **README.md** — full reference (long; use the index)
81
+ - **docs/LLM-GUIDE.md** — concise agent-facing guide (this is the cheat sheet)
82
+ - **docs/knowledge-base-primitives.md** — KB schema reference + error codes table
83
+ - **docs/plan-tier-frontmatter.md** — plan-tier reference (added in 2.2.0)
84
+ - **CHANGELOG.md** — recent changes, version history
85
+
86
+ After giving the orientation, ask the user: "What would you like to do next?" and wait. Don't speculatively run commands.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Convert a legacy flat-file incident into the 2.3.0 folder form
3
+ allowed-tools: Bash(npx:*), Read
4
+ argument-hint: "<path-to-flat-incident.md>"
5
+ ---
6
+
7
+ Arguments: $ARGUMENTS
8
+
9
+ - If `$ARGUMENTS` is empty, ask the user for the path to the flat-file incident.
10
+ - Read the flat file to understand its content and frontmatter.
11
+ - Run `npx --no @theglitchking/hit-em-with-the-docs migrate-incident "$ARGUMENTS" --dry-run` to see the proposed migration plan (target folder, narrative.md content, facts.md skeleton).
12
+ - Show the user the proposed plan:
13
+ - Where the new folder will live
14
+ - What the narrative.md frontmatter will look like (especially `severity`, `resolution_status`, `components` — these are required and may need user input if the original lacks them)
15
+ - That the facts.md will be a skeleton with empty `produced:` (the user will use `/hit-em-with-the-docs:extract-facts` after migration to populate it)
16
+ - Ask the user to confirm or adjust any defaults (especially severity / components if they look wrong).
17
+ - On confirmation, re-run without `--dry-run`. The original file is renamed to `<name>.md.migrated` for rollback safety.
18
+ - After migration, suggest the user run `/hit-em-with-the-docs:extract-facts <target-folder>` to extract atomic facts from the narrative.
@@ -1,8 +1,16 @@
1
+ import { type KbErrorCode } from '../metadata/errors.js';
1
2
  export interface AuditOptions {
2
3
  docsPath: string;
3
4
  domain?: string;
4
5
  issuesOnly?: boolean;
5
6
  silent?: boolean;
7
+ /**
8
+ * Strict mode: when true, the `audit` CLI command will exit non-zero on
9
+ * ANY error-severity issue, including the warning-only knowledge-base
10
+ * checks (e.g. FACT_VERIFY_COMMAND_MULTILINE_SHEBANG). Has no effect on
11
+ * the AuditResult itself — it's a flag the CLI inspects.
12
+ */
13
+ strict?: boolean;
6
14
  }
7
15
  export interface AuditResult {
8
16
  totalFiles: number;
@@ -19,6 +27,12 @@ export interface AuditIssue {
19
27
  message: string;
20
28
  fixable: boolean;
21
29
  suggestion?: string;
30
+ /**
31
+ * Knowledge-base error code (2.3.0+), populated when this issue came from
32
+ * a KB-specific validator (fact / incident / symptoms). Lets tooling switch
33
+ * on specific violation kinds without substring-matching the message.
34
+ */
35
+ code?: KbErrorCode;
22
36
  }
23
37
  export interface AuditStats {
24
38
  metadataCompliance: number;
@@ -1 +1 @@
1
- {"version":3,"file":"auditor.d.ts","sourceRoot":"","sources":["file:///home/tmarlette/workspace/the-glitch-kingdom/hit-em-with-the-docs/src/core/audit/auditor.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA4IpF;AA+ID;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC,CAQ3B"}
1
+ {"version":3,"file":"auditor.d.ts","sourceRoot":"","sources":["file:///home/tmarlette/workspace/the-glitch-kingdom/hit-em-with-the-docs/src/core/audit/auditor.ts"],"names":[],"mappings":"AAWA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAM5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA4IpF;AA+JD;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC,CAQ3B"}
@@ -2,8 +2,22 @@
2
2
  * Document tier classification system.
3
3
  * Classifies documents into 5 tiers based on content structure.
4
4
  */
5
- export declare const TIERS: readonly ["guide", "standard", "example", "reference", "admin"];
5
+ export declare const TIERS: readonly ["guide", "standard", "example", "reference", "admin", "plan", "fact", "incident-narrative", "incident-facts"];
6
6
  export type Tier = (typeof TIERS)[number];
7
+ /**
8
+ * Tiers that use lifecycle status (status field) instead of semver versioning.
9
+ * These tiers have `version` relaxed to optional in the MetadataSchema and
10
+ * accept tier-specific status enums in addition to (or instead of) the
11
+ * doc-tier status enum.
12
+ *
13
+ * - plan: phase/task/atom planning artifacts (added in 2.2.0)
14
+ * - fact: atomic knowledge claims, tracked via `last_verified` + confidence
15
+ * - incident-narrative: postmortem story (date-stamped, immutable)
16
+ * - incident-facts: bridge doc linking incidents to facts they produced
17
+ */
18
+ export declare const LIFECYCLE_TRACKED_TIERS: readonly ["plan", "fact", "incident-narrative", "incident-facts"];
19
+ export type LifecycleTrackedTier = (typeof LIFECYCLE_TRACKED_TIERS)[number];
20
+ export declare function isLifecycleTrackedTier(tier: unknown): tier is LifecycleTrackedTier;
7
21
  export interface TierDefinition {
8
22
  id: Tier;
9
23
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["file:///home/tmarlette/workspace/the-glitch-kingdom/hit-em-with-the-docs/src/core/domains/classifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,KAAK,iEAAkE,CAAC;AACrF,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,IAAI,EAAE,cAAc,CAgFzD,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,wBAAwB,CA+GtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,cAAc,CAE5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI,CAExD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAErD"}
1
+ {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["file:///home/tmarlette/workspace/the-glitch-kingdom/hit-em-with-the-docs/src/core/domains/classifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,KAAK,yHAUR,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,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,
5
+ * easy to unit-test with date injection. `runFactVerify()` actually
6
+ * shells out and updates `last_verified` on success.
7
+ *
8
+ * Working-dir resolution (locked in during planning):
9
+ * - Default: `<vault-root>/facts/`
10
+ * - Override: a fact's optional `working_dir:` frontmatter field
11
+ */
12
+ import type { FactRef, CiterIndex } from './citers.js';
13
+ export interface StaleFact {
14
+ id: string;
15
+ path: string;
16
+ relPath: string;
17
+ title: string;
18
+ confidence: string | undefined;
19
+ lastVerified: string;
20
+ daysSinceVerified: number;
21
+ }
22
+ export interface AuditFactsOptions {
23
+ index: CiterIndex;
24
+ /** Reference date for "now". Defaults to today. Tests inject a fixed date. */
25
+ now?: Date;
26
+ /** Stale threshold in days. Defaults to 90. */
27
+ auditWindowDays?: number;
28
+ }
29
+ export interface AuditFactsResult {
30
+ stale: StaleFact[];
31
+ /** Facts whose last_verified is malformed or absent. Reported but not "stale". */
32
+ unverifiable: FactRef[];
33
+ }
34
+ export declare function auditFacts(options: AuditFactsOptions): AuditFactsResult;
35
+ export interface RunVerifyOptions {
36
+ fact: FactRef;
37
+ /** Absolute vault root (used to compute default CWD). */
38
+ vaultRoot: string;
39
+ /** Override CWD (test seam). */
40
+ cwdOverride?: string;
41
+ /** Inject a fake date for the `last_verified` rewrite. */
42
+ now?: Date;
43
+ /** Skip the actual shell-out (test seam). Returns success without running. */
44
+ skipExec?: boolean;
45
+ }
46
+ export interface RunVerifyResult {
47
+ factId: string;
48
+ executed: boolean;
49
+ exitCode: number | null;
50
+ stdout: string;
51
+ stderr: string;
52
+ /** True iff the fact's `last_verified` was updated. */
53
+ updated: boolean;
54
+ /** YYYY-MM-DD that was written. */
55
+ newLastVerified: string | undefined;
56
+ }
57
+ /**
58
+ * Execute a fact's `verify_command` and update `last_verified` on success.
59
+ * Returns a typed result describing what happened.
60
+ *
61
+ * The verify command runs in a child shell (bash via `-c`). CWD resolution:
62
+ * 1. `cwdOverride` (test seam)
63
+ * 2. Fact's frontmatter `working_dir:` field, resolved relative to vaultRoot
64
+ * 3. `<vaultRoot>/facts/` default
65
+ */
66
+ export declare function runFactVerify(options: RunVerifyOptions): Promise<RunVerifyResult>;
67
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["file:///home/tmarlette/workspace/the-glitch-kingdom/hit-em-with-the-docs/src/core/knowledge-base/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,kFAAkF;IAClF,YAAY,EAAE,OAAO,EAAE,CAAC;CACzB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CA2CvE;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;IACjB,mCAAmC;IACnC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAuE1B"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Frontmatter mutation for `hewtd cite` (2.3.0 PR3).
3
+ *
4
+ * Inserts a `cites:` entry into the nearest `symptoms:` block in a playbook,
5
+ * or creates a new top-level `symptoms:` block if one doesn't exist.
6
+ * Idempotent: re-citing the same fact in the same symptom entry is a no-op.
7
+ *
8
+ * Round-trip safety: uses gray-matter to preserve body content. Frontmatter
9
+ * key order is preserved for keys that already existed; new keys (symptoms)
10
+ * append at the end.
11
+ */
12
+ export interface CiteOptions {
13
+ /** Absolute path to the playbook file. */
14
+ playbookPath: string;
15
+ /** Fact id to insert into the symptoms block. */
16
+ factId: string;
17
+ /**
18
+ * Optional symptom identifier — if present, adds the citation to the
19
+ * matching entry. If absent, adds to the FIRST symptoms entry (or creates
20
+ * a single placeholder symptom).
21
+ */
22
+ symptomMatch?: {
23
+ alert_name?: string;
24
+ user_phrase?: string;
25
+ error_pattern?: string;
26
+ };
27
+ /** If true, returns the proposed content without writing the file. */
28
+ dryRun?: boolean;
29
+ }
30
+ export interface CiteResult {
31
+ playbookPath: string;
32
+ factId: string;
33
+ /** What we did: inserted, already_present (no-op), or created_block. */
34
+ action: 'inserted' | 'already_present' | 'created_block';
35
+ /** Index of the symptoms entry the citation was added to. */
36
+ symptomIndex: number;
37
+ /** The full new file content. */
38
+ newContent: string;
39
+ }
40
+ export declare function cite(options: CiteOptions): Promise<CiteResult>;
41
+ //# sourceMappingURL=cite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cite.d.ts","sourceRoot":"","sources":["file:///home/tmarlette/workspace/the-glitch-kingdom/hit-em-with-the-docs/src/core/knowledge-base/cite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE;QACb,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,MAAM,EAAE,UAAU,GAAG,iBAAiB,GAAG,eAAe,CAAC;IACzD,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAWD,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA2DpE"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Citation graph walker for knowledge-base primitives (2.3.0).
3
+ *
4
+ * Builds the per-fact citation index from three source kinds:
5
+ * - Facts (`<vault>/facts/<id>.md`) — the canonical fact corpus.
6
+ * - Incident-facts bridges (`<vault>/incidents/<slug>/facts.md`) — produced /
7
+ * strengthened / weakened edges.
8
+ * - Playbooks (any file with `symptoms: [...]` frontmatter) — `cites` edges
9
+ * from each symptom entry to the facts the playbook step depends on.
10
+ *
11
+ * Used by:
12
+ * - `facts/INDEX.md` generator (PR2) — to compute citer counts per fact.
13
+ * - `hewtd find-citers <fact-id>` CLI command (PR3) — typed structure output.
14
+ * - Dangling-citation linting (future PR) — flags `cites:` pointing at
15
+ * non-existent facts.
16
+ */
17
+ export interface FactRef {
18
+ /** Fact id (from frontmatter `id:`). */
19
+ id: string;
20
+ /** Absolute path to the fact's markdown file. */
21
+ path: string;
22
+ /** Path relative to the project root (for stable, diff-friendly indexes). */
23
+ relPath: string;
24
+ /** Frontmatter title. */
25
+ title: string;
26
+ /** Confidence enum value, if present. */
27
+ confidence: string | undefined;
28
+ /** YYYY-MM-DD or null if missing/malformed. */
29
+ lastVerified: string | undefined;
30
+ /** Tags from frontmatter. */
31
+ tags: string[];
32
+ }
33
+ export interface IncidentRef {
34
+ /** Incident id (from narrative.md frontmatter `id:`). */
35
+ id: string;
36
+ /** Absolute path to the incident folder. */
37
+ folderPath: string;
38
+ /** Project-relative folder path. */
39
+ relFolderPath: string;
40
+ /** Frontmatter title from narrative.md. */
41
+ title: string;
42
+ /** YYYY-MM-DD. */
43
+ date: string | undefined;
44
+ severity: string | undefined;
45
+ resolution_status: string | undefined;
46
+ components: string[];
47
+ /** Fact ids produced by this incident (from facts.md). */
48
+ produced: string[];
49
+ strengthened: string[];
50
+ weakened: string[];
51
+ }
52
+ export interface PlaybookCitation {
53
+ /** Project-relative path to the playbook. */
54
+ relPath: string;
55
+ /** Absolute path. */
56
+ path: string;
57
+ /** Frontmatter title. */
58
+ title: string;
59
+ /** Anchor within the playbook (e.g. `#vault-down-auth-staging`). */
60
+ target: string;
61
+ /** Symptom kind that triggered the citation. */
62
+ kind: 'alert_name' | 'user_phrase' | 'error_pattern';
63
+ /** The matching key (string or array, depending on kind). */
64
+ key: string | string[];
65
+ severity: string | undefined;
66
+ }
67
+ export interface CiterIndex {
68
+ /** All discovered facts, keyed by id. */
69
+ facts: Map<string, FactRef>;
70
+ /** All discovered incident folders, keyed by id. */
71
+ incidents: Map<string, IncidentRef>;
72
+ /**
73
+ * Citation edges per fact id. A fact id appearing here may not have a
74
+ * matching entry in `facts` — that's a dangling citation, detected by
75
+ * the caller.
76
+ */
77
+ citers: Map<string, PlaybookCitation[]>;
78
+ }
79
+ /**
80
+ * Typed structure returned by `findCiters(factId)`. Matches the shape the
81
+ * `hewtd find-citers` CLI command will print and the structure documented
82
+ * in `docs/knowledge-base-primitives.md`.
83
+ */
84
+ export interface FindCitersResult {
85
+ fact_id: string;
86
+ fact_exists: boolean;
87
+ citers: string[];
88
+ incidents_produced_in: string[];
89
+ incidents_strengthened_by: string[];
90
+ incidents_weakened_by: string[];
91
+ }
92
+ export interface BuildCiterIndexOptions {
93
+ /** Absolute path to the project root. */
94
+ projectRoot: string;
95
+ /** Absolute path to the vault root (default config: <root>/.documentation/knowledge-base/). */
96
+ vaultRoot: string;
97
+ /**
98
+ * Glob patterns (absolute, project-rooted) used to scan playbooks for
99
+ * `symptoms:` frontmatter blocks. The walker filters by frontmatter
100
+ * presence — files without a `symptoms:` block are skipped quickly.
101
+ */
102
+ playbookGlobs: string[];
103
+ }
104
+ /**
105
+ * Walk the corpus and build a citer index. Designed to be cheap on no-vault
106
+ * trees: if the vault root doesn't exist, returns an empty index without
107
+ * scanning playbooks for symptoms (no point — no facts to cite).
108
+ */
109
+ export declare function buildCiterIndex(options: BuildCiterIndexOptions): Promise<CiterIndex>;
110
+ /**
111
+ * Public lookup: typed structure for one fact id. Matches the shape the
112
+ * `hewtd find-citers` CLI command prints.
113
+ */
114
+ export declare function findCitersInIndex(index: CiterIndex, factId: string): FindCitersResult;
115
+ /**
116
+ * Count distinct citers for a fact id. Used by the facts-index generator.
117
+ */
118
+ export declare function citerCount(index: CiterIndex, factId: string): number;
119
+ //# sourceMappingURL=citers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"citers.d.ts","sourceRoot":"","sources":["file:///home/tmarlette/workspace/the-glitch-kingdom/hit-em-with-the-docs/src/core/knowledge-base/citers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,MAAM,WAAW,OAA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