@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
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Plugin config loader for `.claude/hit-em-with-the-docs.json`.
3
+ *
4
+ * The runtime (`@theglitchking/claude-plugin-runtime`) owns the
5
+ * `updatePolicy` field. This module reads the same file and adds the
6
+ * 2.3.0 `vault` block for knowledge-base configuration. Missing or
7
+ * malformed files fall back to defaults — never throws.
8
+ */
9
+ import { z } from 'zod';
10
+ export declare const DEFAULT_VAULT_ROOT = ".documentation/knowledge-base/";
11
+ export declare const DEFAULT_PLAYBOOK_GLOBS: string[];
12
+ export declare const DEFAULT_AUDIT_WINDOW_DAYS = 90;
13
+ /**
14
+ * Schema for `.claude/hit-em-with-the-docs.json`. Every field is optional
15
+ * with a sensible default. The runtime's `updatePolicy` is preserved via
16
+ * `.passthrough()`.
17
+ */
18
+ declare const vaultConfigSchema: z.ZodDefault<z.ZodObject<{
19
+ root: z.ZodDefault<z.ZodString>;
20
+ playbook_paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
21
+ audit_window_days: z.ZodDefault<z.ZodNumber>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ root: string;
24
+ playbook_paths: string[];
25
+ audit_window_days: number;
26
+ }, {
27
+ root?: string | undefined;
28
+ playbook_paths?: string[] | undefined;
29
+ audit_window_days?: number | undefined;
30
+ }>>;
31
+ declare const pluginConfigSchema: z.ZodObject<{
32
+ vault: z.ZodDefault<z.ZodObject<{
33
+ root: z.ZodDefault<z.ZodString>;
34
+ playbook_paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
35
+ audit_window_days: z.ZodDefault<z.ZodNumber>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ root: string;
38
+ playbook_paths: string[];
39
+ audit_window_days: number;
40
+ }, {
41
+ root?: string | undefined;
42
+ playbook_paths?: string[] | undefined;
43
+ audit_window_days?: number | undefined;
44
+ }>>;
45
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
46
+ vault: z.ZodDefault<z.ZodObject<{
47
+ root: z.ZodDefault<z.ZodString>;
48
+ playbook_paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
49
+ audit_window_days: z.ZodDefault<z.ZodNumber>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ root: string;
52
+ playbook_paths: string[];
53
+ audit_window_days: number;
54
+ }, {
55
+ root?: string | undefined;
56
+ playbook_paths?: string[] | undefined;
57
+ audit_window_days?: number | undefined;
58
+ }>>;
59
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
60
+ vault: z.ZodDefault<z.ZodObject<{
61
+ root: z.ZodDefault<z.ZodString>;
62
+ playbook_paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
63
+ audit_window_days: z.ZodDefault<z.ZodNumber>;
64
+ }, "strip", z.ZodTypeAny, {
65
+ root: string;
66
+ playbook_paths: string[];
67
+ audit_window_days: number;
68
+ }, {
69
+ root?: string | undefined;
70
+ playbook_paths?: string[] | undefined;
71
+ audit_window_days?: number | undefined;
72
+ }>>;
73
+ }, z.ZodTypeAny, "passthrough">>;
74
+ export type VaultConfig = z.infer<typeof vaultConfigSchema>;
75
+ export type PluginConfig = z.infer<typeof pluginConfigSchema>;
76
+ /**
77
+ * Load the plugin config for a project, applying defaults. Never throws —
78
+ * missing file, malformed JSON, and invalid shapes all fall through to
79
+ * defaults. Pass `projectRoot` (defaults to `process.cwd()`) to control
80
+ * which directory to read from.
81
+ */
82
+ export declare function loadPluginConfig(projectRoot?: string): Promise<PluginConfig>;
83
+ /**
84
+ * Synchronous variant — used in test setup where async loading is awkward.
85
+ * Same fail-open behavior.
86
+ */
87
+ export declare function loadPluginConfigSync(projectRoot?: string): PluginConfig;
88
+ /**
89
+ * Resolve the vault root for a project, applying config + defaults.
90
+ * The returned path is absolute.
91
+ */
92
+ export declare function resolveVaultRoot(projectRoot: string, config: PluginConfig): string;
93
+ /**
94
+ * Resolve playbook scan globs relative to project root, as absolute glob
95
+ * patterns. Returned globs are suitable for `glob` library consumption.
96
+ */
97
+ export declare function resolvePlaybookGlobs(projectRoot: string, config: PluginConfig): string[];
98
+ export {};
99
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,mCAAmC,CAAC;AACnE,eAAO,MAAM,sBAAsB,UAA6B,CAAC;AACjE,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;GAIG;AACH,QAAA,MAAM,iBAAiB;;;;;;;;;;;;GAMT,CAAC;AAEf,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAIR,CAAC;AAEjB,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAkBlF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CAoBvE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAElF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,YAAY,GACnB,MAAM,EAAE,CAEV"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Plugin config loader for `.claude/hit-em-with-the-docs.json`.
3
+ *
4
+ * The runtime (`@theglitchking/claude-plugin-runtime`) owns the
5
+ * `updatePolicy` field. This module reads the same file and adds the
6
+ * 2.3.0 `vault` block for knowledge-base configuration. Missing or
7
+ * malformed files fall back to defaults — never throws.
8
+ */
9
+ import { readFile } from 'fs/promises';
10
+ import { join, resolve } from 'path';
11
+ import { z } from 'zod';
12
+ export const DEFAULT_VAULT_ROOT = '.documentation/knowledge-base/';
13
+ export const DEFAULT_PLAYBOOK_GLOBS = ['.documentation/**/*.md'];
14
+ export const DEFAULT_AUDIT_WINDOW_DAYS = 90;
15
+ /**
16
+ * Schema for `.claude/hit-em-with-the-docs.json`. Every field is optional
17
+ * with a sensible default. The runtime's `updatePolicy` is preserved via
18
+ * `.passthrough()`.
19
+ */
20
+ const vaultConfigSchema = z
21
+ .object({
22
+ root: z.string().default(DEFAULT_VAULT_ROOT),
23
+ playbook_paths: z.array(z.string()).default(DEFAULT_PLAYBOOK_GLOBS),
24
+ audit_window_days: z.number().int().positive().default(DEFAULT_AUDIT_WINDOW_DAYS),
25
+ })
26
+ .default({});
27
+ const pluginConfigSchema = z
28
+ .object({
29
+ vault: vaultConfigSchema,
30
+ })
31
+ .passthrough();
32
+ const CONFIG_FILENAME = '.claude/hit-em-with-the-docs.json';
33
+ /**
34
+ * Load the plugin config for a project, applying defaults. Never throws —
35
+ * missing file, malformed JSON, and invalid shapes all fall through to
36
+ * defaults. Pass `projectRoot` (defaults to `process.cwd()`) to control
37
+ * which directory to read from.
38
+ */
39
+ export async function loadPluginConfig(projectRoot) {
40
+ const root = projectRoot ?? process.cwd();
41
+ const configPath = resolve(root, CONFIG_FILENAME);
42
+ let raw;
43
+ try {
44
+ const contents = await readFile(configPath, 'utf-8');
45
+ raw = JSON.parse(contents);
46
+ }
47
+ catch {
48
+ raw = {};
49
+ }
50
+ const parsed = pluginConfigSchema.safeParse(raw);
51
+ if (parsed.success) {
52
+ return parsed.data;
53
+ }
54
+ // Malformed config — return defaults rather than crash.
55
+ return pluginConfigSchema.parse({});
56
+ }
57
+ /**
58
+ * Synchronous variant — used in test setup where async loading is awkward.
59
+ * Same fail-open behavior.
60
+ */
61
+ export function loadPluginConfigSync(projectRoot) {
62
+ const root = projectRoot ?? process.cwd();
63
+ const configPath = resolve(root, CONFIG_FILENAME);
64
+ let raw;
65
+ try {
66
+ // Lazy require to avoid hoisting an fs dep when this code path isn't used.
67
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
68
+ const { readFileSync } = require('fs');
69
+ const contents = readFileSync(configPath, 'utf-8');
70
+ raw = JSON.parse(contents);
71
+ }
72
+ catch {
73
+ raw = {};
74
+ }
75
+ const parsed = pluginConfigSchema.safeParse(raw);
76
+ if (parsed.success) {
77
+ return parsed.data;
78
+ }
79
+ return pluginConfigSchema.parse({});
80
+ }
81
+ /**
82
+ * Resolve the vault root for a project, applying config + defaults.
83
+ * The returned path is absolute.
84
+ */
85
+ export function resolveVaultRoot(projectRoot, config) {
86
+ return resolve(projectRoot, config.vault.root);
87
+ }
88
+ /**
89
+ * Resolve playbook scan globs relative to project root, as absolute glob
90
+ * patterns. Returned globs are suitable for `glob` library consumption.
91
+ */
92
+ export function resolvePlaybookGlobs(projectRoot, config) {
93
+ return config.vault.playbook_paths.map((p) => join(projectRoot, p));
94
+ }
95
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;;;GA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0",
4
4
  "description": "Self-managing documentation system with hierarchical structure, intelligent automation, pattern discovery, and agent orchestration",
5
5
  "type": "module",
6
6
  "main": "dist/cli/index.js",
@@ -0,0 +1,31 @@
1
+ # Knowledge-base templates
2
+
3
+ LLM-referenceable templates for authoring the four knowledge-base primitives
4
+ shipped in 2.3.0. Each template shows the full required + commonly-optional
5
+ frontmatter, the validation rules in comments, and a body skeleton with
6
+ conventional sections.
7
+
8
+ | Template | When to use |
9
+ |---|---|
10
+ | `fact.template.md` | A single citable claim with verify command. Lives at `<vault-root>/facts/<id>.md`. |
11
+ | `incident-narrative.template.md` | An immutable postmortem. Lives at `<vault-root>/incidents/<YYYY-MM-DD-slug>/narrative.md`. |
12
+ | `incident-facts.template.md` | The bridge linking an incident to the facts it produced. Lives at `<vault-root>/incidents/<YYYY-MM-DD-slug>/facts.md`. |
13
+ | `playbook-symptoms.template.md` | A snippet showing how to enrich an EXISTING playbook with a `symptoms:` block. Not a tier on its own. |
14
+
15
+ ## For LLMs
16
+
17
+ These templates are the canonical reference when creating new knowledge-base
18
+ articles. The frontmatter shows every field the validator looks for. Comments
19
+ inline (where the YAML allows) explain enums, constraints, and what counts
20
+ as required vs. optional.
21
+
22
+ When asked to create a new fact / incident / playbook entry:
23
+
24
+ 1. Read the corresponding template.
25
+ 2. Replace every `<placeholder>` with concrete content.
26
+ 3. Run `hewtd audit --strict` on the parent directory to confirm validity.
27
+
28
+ ## Validation reference
29
+
30
+ See `docs/knowledge-base-primitives.md` (in the plugin repo) for the full
31
+ schema reference, the list of error codes, and worked examples.
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: <Short human-readable claim — e.g. "Alloy reads env only at entrypoint">
3
+ tier: fact
4
+ domains:
5
+ - <domain-1>
6
+ # - <domain-2> # optional additional domains
7
+ status: active # one of: draft | active | deprecated | archived | weakened
8
+ last_updated: YYYY-MM-DD
9
+ id: <kebab-case-slug> # MUST match the filename without `.md`
10
+ confidence: high # one of: high | medium | low | hypothesis
11
+ last_verified: YYYY-MM-DD # the date a human (or `hewtd audit-facts --run-verify`) confirmed the claim
12
+ verify_command: | # OPTIONAL but strongly recommended — a single shell command that proves the claim
13
+ <one-line command, e.g. `docker exec alloy printenv VAULT_TOKEN | head -c 10`>
14
+ # For multi-line scripts, start with a shebang:
15
+ # verify_command: |
16
+ # #!/usr/bin/env bash
17
+ # set -euo pipefail
18
+ # <command 1>
19
+ # <command 2>
20
+ working_dir: <vault-root>/facts/ # OPTIONAL — CWD for verify_command; defaults to the facts dir if omitted
21
+ provenance: # REQUIRED — at least one entry; where this fact came from
22
+ - <incidents/YYYY-MM-DD-incident-slug/> # or a source path, or a postmortem reference
23
+ sources: # OPTIONAL — code/config paths that embody this fact
24
+ - <repo-relative/path/to/file>
25
+ tags:
26
+ - <tag-1>
27
+ - <tag-2>
28
+ invalidated_by: # OPTIONAL — conditions under which this fact would no longer hold
29
+ - <free-text condition>
30
+ ---
31
+
32
+ # <Same as title>
33
+
34
+ ## Claim
35
+ <One paragraph stating the atomic claim. One claim per fact. If you find yourself writing "and also...", split it into two facts.>
36
+
37
+ ## How to verify
38
+ <How a human can confirm this claim — the prose explanation. The shell command in `verify_command:` is the machine-runnable version.>
39
+
40
+ ## Consequences
41
+ <What this means in practice. What workflows it affects. Why a reader should care.>
42
+
43
+ ## See also
44
+ <Optional cross-links to related facts, incidents, or runbooks.>
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: Facts from YYYY-MM-DD <incident-slug>
3
+ tier: incident-facts
4
+ domains:
5
+ - incidents
6
+ status: active # active | archived
7
+ last_updated: YYYY-MM-DD
8
+ incident_id: YYYY-MM-DD-<kebab-slug> # MUST match the parent folder name AND the sibling narrative.md's id
9
+ produced: # REQUIRED — array, may be EMPTY if the incident produced no new facts
10
+ - <fact-id-1>
11
+ - <fact-id-2>
12
+ strengthened: # OPTIONAL — facts whose confidence increased because of this incident
13
+ - <fact-id-a>
14
+ weakened: # OPTIONAL — facts whose confidence decreased
15
+ - <fact-id-b>
16
+ ---
17
+
18
+ # Facts from YYYY-MM-DD <incident-slug>
19
+
20
+ ## Produced
21
+ <One line per produced fact, with a short justification tying it to the incident evidence.>
22
+ - `<fact-id-1>` — <one-sentence justification: what during the incident proved this fact>
23
+ - `<fact-id-2>` — <one-sentence justification>
24
+
25
+ ## Strengthened
26
+ <For each strengthened fact, one line on what new evidence raised confidence.>
27
+ - `<fact-id-a>` — <reason confidence increased>
28
+
29
+ ## Weakened
30
+ <For each weakened fact, one line on what evidence contradicts it.>
31
+ - `<fact-id-b>` — <reason confidence decreased>
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: <Human-readable incident title — e.g. "Vault Down on Auth-Staging">
3
+ tier: incident-narrative
4
+ domains:
5
+ - incidents
6
+ - <additional-domain> # e.g. observability, security
7
+ status: active # active | resolved | archived
8
+ last_updated: YYYY-MM-DD
9
+ id: YYYY-MM-DD-<kebab-slug> # MUST match the parent folder name (e.g. 2026-05-14-vault-alloy-stuck)
10
+ date: YYYY-MM-DD # the date the incident occurred
11
+ severity: high # one of: low | medium | high | critical
12
+ resolution_status: resolved # one of: resolved | partial | open | planned
13
+ components: # REQUIRED — at least one component affected
14
+ - <system-1>
15
+ - <system-2>
16
+ tags:
17
+ - <tag-1>
18
+ - <tag-2>
19
+ ---
20
+
21
+ # <Same as title>
22
+
23
+ ## Summary
24
+ <One-paragraph TL;DR of what happened and how it was resolved.>
25
+
26
+ ## Timeline
27
+ - HH:MM — <event 1>
28
+ - HH:MM — <event 2>
29
+ - HH:MM — <event 3>
30
+ - HH:MM — <resolution event>
31
+
32
+ ## Root Cause
33
+ <The actual cause. Be specific. If unknown, say "Unknown — see Open Questions".>
34
+
35
+ ## Impact
36
+ <Who/what was affected. Duration. Severity rationale. Was customer-facing? Was data lost?>
37
+
38
+ ## Resolution
39
+ <How it was fixed. The exact action taken.>
40
+
41
+ ## Lessons Learned
42
+ - <Lesson 1 — short, actionable>
43
+ - <Lesson 2>
44
+
45
+ ## Open Questions
46
+ - <Anything unresolved that needs follow-up>
47
+
48
+ ## See also
49
+ - `facts.md` — facts produced/strengthened/weakened by this incident
50
+ - <Optional links to related incidents or runbooks>
@@ -0,0 +1,74 @@
1
+ # Playbook with symptoms — frontmatter snippet
2
+
3
+ > This is NOT a standalone tier — it's a snippet showing how to enrich an
4
+ > EXISTING playbook (any tier: guide, admin, reference, etc.) with a
5
+ > `symptoms:` block. The plugin scans configured playbook paths, extracts
6
+ > symptoms blocks, and generates `<vault-root>/symptoms/INDEX.md`.
7
+
8
+ ## Where this goes
9
+
10
+ Drop the `symptoms:` block into the frontmatter of an existing markdown file.
11
+ Keep the file's existing `tier:`, `domains:`, `status:`, etc. unchanged. Only
12
+ the `symptoms:` field is being added.
13
+
14
+ ## Frontmatter snippet
15
+
16
+ ```yaml
17
+ ---
18
+ title: <existing title, unchanged>
19
+ tier: <existing tier — typically guide or admin for runbooks>
20
+ domains:
21
+ - <existing domain>
22
+ status: active
23
+ last_updated: YYYY-MM-DD
24
+ version: 1.0.0 # required for non-lifecycle tiers
25
+
26
+ # ↓↓↓ The new bit ↓↓↓
27
+ symptoms:
28
+ # 1. Exact alert name (e.g. from Grafana, Prometheus AlertManager).
29
+ # Matched character-for-character.
30
+ - alert_name: "<exact alert name as it arrives from the alerting system>"
31
+ severity: critical # one of: low | medium | high | critical
32
+ target: "#<anchor-in-this-file>" # the heading the playbook step lives under
33
+ cites: # REQUIRED — array of fact ids the playbook depends on
34
+ - <fact-id-1>
35
+ - <fact-id-2>
36
+
37
+ # 2. User phrase (free-form support requests). Fuzzy substring match (lowercased).
38
+ - user_phrase:
39
+ - "<phrase 1>"
40
+ - "<phrase 2>"
41
+ severity: medium
42
+ target: "#<same-or-different-anchor>"
43
+ cites:
44
+ - <fact-id-1>
45
+
46
+ # 3. Error pattern (log lines, stack traces). Regex match.
47
+ - error_pattern: "<JavaScript-style regex, escaped as needed>"
48
+ severity: high
49
+ target: "#<anchor>"
50
+ cites:
51
+ - <fact-id-3>
52
+ ---
53
+ ```
54
+
55
+ ## What `cites:` does
56
+
57
+ `cites:` binds playbook steps to facts. When a fact changes (e.g. its
58
+ `confidence:` drops, or it's marked `invalidated_by:` something), the
59
+ plugin can flag every playbook that cites it as potentially stale. This is
60
+ the load-bearing field for drift detection.
61
+
62
+ If you cite a fact id that doesn't exist, `hewtd audit --strict` will emit
63
+ a `PLAYBOOK_SYMPTOM_DANGLING_CITE` error.
64
+
65
+ ## Tip: use `hewtd cite <fact-id>` to insert
66
+
67
+ You don't have to write the citation by hand. Inside a playbook file:
68
+
69
+ ```bash
70
+ hewtd cite <fact-id> --file <path-to-this-playbook>
71
+ ```
72
+
73
+ This inserts a properly-formatted entry into the nearest `symptoms:` block,
74
+ creating one if it doesn't exist. (`hewtd cite` ships in 2.3.0 PR3.)