@jetrabbits/agentic 0.3.3 → 0.5.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 (94) hide show
  1. package/AGENTS.md +8 -0
  2. package/CHANGELOG.md +18 -0
  3. package/Makefile +26 -5
  4. package/README.md +25 -6
  5. package/agentic +801 -66
  6. package/areas/devops/ci-cd/workflows/onboard-repo.md +29 -0
  7. package/areas/devops/ci-cd/workflows/pipeline-debug.md +26 -0
  8. package/areas/devops/ci-cd/workflows/release-pipeline.md +53 -0
  9. package/areas/devops/database-ops/workflows/backup-verify.md +27 -0
  10. package/areas/devops/database-ops/workflows/db-incident.md +30 -0
  11. package/areas/devops/devsecops/workflows/policy-onboard.md +34 -0
  12. package/areas/devops/devsecops/workflows/security-scan-pipeline.md +33 -0
  13. package/areas/devops/infrastructure/workflows/destroy-environment.md +31 -0
  14. package/areas/devops/infrastructure/workflows/drift-remediation.md +29 -0
  15. package/areas/devops/infrastructure/workflows/module-development.md +32 -0
  16. package/areas/devops/infrastructure/workflows/provision-environment.md +29 -0
  17. package/areas/devops/kubernetes/workflows/cluster-bootstrap.md +36 -0
  18. package/areas/devops/kubernetes/workflows/debug-workload.md +29 -0
  19. package/areas/devops/kubernetes/workflows/onboard-service.md +35 -0
  20. package/areas/devops/kubernetes/workflows/upgrade-cluster.md +30 -0
  21. package/areas/devops/networking/workflows/onboard-ingress.md +27 -0
  22. package/areas/devops/networking/workflows/service-mesh-onboard.md +27 -0
  23. package/areas/devops/observability/workflows/alert-investigation.md +29 -0
  24. package/areas/devops/observability/workflows/observability-stack-setup.md +33 -0
  25. package/areas/devops/observability/workflows/onboard-service-monitoring.md +31 -0
  26. package/areas/devops/sre/workflows/incident-response.md +48 -0
  27. package/areas/devops/sre/workflows/postmortem.md +32 -0
  28. package/areas/devops/sre/workflows/slo-review.md +35 -1
  29. package/areas/software/backend/workflows/add-migration.md +33 -0
  30. package/areas/software/backend/workflows/create-endpoint.md +40 -0
  31. package/areas/software/backend/workflows/debug-issue.md +31 -0
  32. package/areas/software/backend/workflows/develop-epic.md +37 -0
  33. package/areas/software/backend/workflows/develop-feature.md +44 -0
  34. package/areas/software/backend/workflows/refactor-module.md +35 -0
  35. package/areas/software/backend/workflows/test-feature.md +30 -0
  36. package/areas/software/data-engineering/workflows/backfill-data.md +25 -0
  37. package/areas/software/data-engineering/workflows/data-quality-incident.md +31 -0
  38. package/areas/software/data-engineering/workflows/lineage-trace.md +25 -0
  39. package/areas/software/data-engineering/workflows/new-model.md +30 -0
  40. package/areas/software/data-engineering/workflows/schema-migration.md +29 -0
  41. package/areas/software/frontend/workflows/a11y-fix.md +30 -0
  42. package/areas/software/frontend/workflows/bundle-analyze.md +28 -0
  43. package/areas/software/frontend/workflows/release-prep.md +33 -0
  44. package/areas/software/frontend/workflows/scaffold-component.md +32 -0
  45. package/areas/software/frontend/workflows/visual-regression.md +32 -0
  46. package/areas/software/full-stack/workflows/backend-project-full-cycle.md +47 -2
  47. package/areas/software/full-stack/workflows/debug-issue.md +29 -0
  48. package/areas/software/full-stack/workflows/develop-feature.md +38 -0
  49. package/areas/software/full-stack/workflows/feature-implementation-flow.md +38 -0
  50. package/areas/software/full-stack/workflows/testing-ci-pipeline.md +30 -0
  51. package/areas/software/general/workflows/code-review-workflow.md +31 -0
  52. package/areas/software/general/workflows/development-cycle-workflow.md +38 -0
  53. package/areas/software/general/workflows/project-setup-workflow.md +38 -0
  54. package/areas/software/mlops/workflows/champion-challenger.md +29 -0
  55. package/areas/software/mlops/workflows/deploy-endpoint.md +30 -0
  56. package/areas/software/mlops/workflows/evaluate-model.md +28 -0
  57. package/areas/software/mlops/workflows/model-incident.md +29 -0
  58. package/areas/software/mlops/workflows/train-experiment.md +25 -0
  59. package/areas/software/mobile/workflows/crash-triage.md +28 -0
  60. package/areas/software/mobile/workflows/device-testing.md +27 -0
  61. package/areas/software/mobile/workflows/ota-update.md +25 -0
  62. package/areas/software/mobile/workflows/release-build.md +30 -0
  63. package/areas/software/mobile/workflows/store-submission.md +29 -0
  64. package/areas/software/platform/workflows/cost-audit.md +28 -0
  65. package/areas/software/platform/workflows/deploy-production.md +30 -0
  66. package/areas/software/platform/workflows/drift-check.md +29 -0
  67. package/areas/software/platform/workflows/incident-response.md +33 -0
  68. package/areas/software/platform/workflows/provision-env.md +36 -0
  69. package/areas/software/qa/workflows/flakiness-investigation.md +30 -0
  70. package/areas/software/qa/workflows/performance-audit.md +29 -0
  71. package/areas/software/qa/workflows/regression-suite.md +28 -0
  72. package/areas/software/qa/workflows/smoke-test.md +31 -0
  73. package/areas/software/qa/workflows/test-coverage-report.md +28 -0
  74. package/areas/software/security/workflows/compliance-report.md +27 -0
  75. package/areas/software/security/workflows/pen-test-sim.md +28 -0
  76. package/areas/software/security/workflows/secret-rotation.md +33 -2
  77. package/areas/software/security/workflows/security-scan.md +29 -0
  78. package/areas/software/security/workflows/threat-model-review.md +30 -0
  79. package/docs/agentic-usage.md +19 -2
  80. package/docs/catalog.schema.json +5 -1
  81. package/docs/mcp/README.md +28 -0
  82. package/docs/opencode_setup.md +21 -1
  83. package/docs/site/README.md +15 -1
  84. package/docs/site/app.js +68 -0
  85. package/docs/site/catalog.json +74 -1
  86. package/docs/site/index.html +5 -1
  87. package/docs/site/styles.css +52 -4
  88. package/extensions/opencode/opencode.json +0 -1
  89. package/extensions/opencode/profiles/githubcopilot/opencode.json +87 -0
  90. package/extensions/opencode/profiles/openai/opencode.json +100 -0
  91. package/package.json +1 -1
  92. package/scripts/build_docs_catalog.py +13 -1
  93. package/scripts/sync_workflow_diagrams.py +199 -0
  94. package/extensions/opencode/plugins/sound-notification.ts +0 -13
@@ -60,5 +60,34 @@ quality-gates:
60
60
  - **Output:** `finding_report.md`; PR review comments
61
61
  - **Done when:** report published; PR status set per findings
62
62
 
63
+ ## Agent Interaction Diagram
64
+
65
+ <!-- agent-diagram:start -->
66
+ ```mermaid
67
+ flowchart TD
68
+ start(["Start /security-scan"])
69
+ role_1["developer"]
70
+ role_2["qa"]
71
+ role_3["team-lead"]
72
+ step_1["1. SAST Scan"]
73
+ step_2["2. Dependency Audit"]
74
+ step_3["3. Secret Scanning"]
75
+ step_4["4. Infrastructure Scan"]
76
+ step_5["5. Synthesize & Report"]
77
+ exit(["No unaddressed Critical findings + report saved = scan complete."])
78
+ start --> step_1
79
+ step_1 --> step_2
80
+ step_2 --> step_3
81
+ step_3 --> step_4
82
+ step_4 --> step_5
83
+ step_5 --> exit
84
+ role_1 -. owns .-> step_1
85
+ role_1 -. owns .-> step_2
86
+ role_2 -. owns .-> step_3
87
+ role_1 -. owns .-> step_4
88
+ role_3 -. owns .-> step_5
89
+ ```
90
+ <!-- agent-diagram:end -->
91
+
63
92
  ## Exit
64
93
  No unaddressed Critical findings + report saved = scan complete.
@@ -58,5 +58,35 @@ quality-gates:
58
58
  - **Output:** `.security/threat-models/threat-model-<feature>.md` — DFD + STRIDE table + mitigations
59
59
  - **Done when:** all Required findings have assigned controls; document complete
60
60
 
61
+ ## Agent Interaction Diagram
62
+
63
+ <!-- agent-diagram:start -->
64
+ ```mermaid
65
+ flowchart TD
66
+ start(["Start /threat-model-review"])
67
+ role_1["team-lead"]
68
+ role_2["developer"]
69
+ role_3["qa"]
70
+ step_1["1. Parse Feature"]
71
+ step_2["2. Data Flow Diagram"]
72
+ step_3["3. STRIDE Analysis"]
73
+ step_4["4. Prioritize"]
74
+ step_5["5. Generate Mitigations"]
75
+ exit(["Published threat model + Required mitigations assigned = secure implementat..."])
76
+ start --> step_1
77
+ step_1 --> step_2
78
+ step_2 --> step_3
79
+ step_3 --> step_4
80
+ step_4 --> step_5
81
+ step_5 --> exit
82
+ role_1 -. owns .-> step_1
83
+ role_2 -. owns .-> step_2
84
+ role_1 -. owns .-> step_3
85
+ role_3 -. owns .-> step_3
86
+ role_1 -. owns .-> step_4
87
+ role_2 -. owns .-> step_5
88
+ ```
89
+ <!-- agent-diagram:end -->
90
+
61
91
  ## Exit
62
92
  Published threat model + Required mitigations assigned = secure implementation can proceed.
@@ -90,7 +90,16 @@ agentic install \
90
90
  --specializations software.general,software.backend
91
91
  ```
92
92
 
93
- After install, `agentic` writes `.agentic.json` in the target project. It records copied/generated files and their hashes. A later install rerun updates only manifest-managed files and skips files changed by the user. Generated guidance is written to root `AGENTS.md` for most agents and to `.opencode/AGENTS.md` when OpenCode is selected; multi-target installs that include OpenCode and another agent write both files.
93
+ After install, `agentic` writes `.agentic.json` in the target project. It records copied/generated files and their hashes. A later install rerun updates only manifest-managed files and skips files changed by the user. Generated guidance is always written to root `AGENTS.md`; when OpenCode is selected, `agentic` also writes `.opencode/AGENTS.md`.
94
+
95
+ When Codex is selected, `agentic` creates or updates the project-local `.codex/config.toml` with Codex memories enabled:
96
+
97
+ ```toml
98
+ [features]
99
+ memories = true
100
+ ```
101
+
102
+ This config file follows the same manifest-managed safeguards as other generated project files.
94
103
 
95
104
  After the project files are generated, `agentic` starts timestamped operational logging and mirrors install output to a temporary log file such as:
96
105
 
@@ -137,6 +146,8 @@ TUI uses `fzf` for interactive selection. If `fzf` is missing, `agentic` can:
137
146
 
138
147
  `--install-fzf` only affects `self-install`. If auto-install fails, self-install still completes.
139
148
 
149
+ The CLI supports the system bash 3.2 shipped with macOS and does not require installing a newer bash.
150
+
140
151
  Manual install examples:
141
152
 
142
153
  Linux:
@@ -163,7 +174,7 @@ scoop install fzf
163
174
 
164
175
  ## OpenCode optional plugins
165
176
 
166
- When `opencode` is selected, interactive installs ask whether to enable Telegram notifications and `agent-model-mapper`. The answer is stored globally in:
177
+ When `opencode` is selected, interactive installs ask whether to enable `Telegram Notifications` and `Agent Model Mapping`. These are readable menu labels for the stable internal ids `telegram-notification` and `agent-model-mapper`. The answer is stored globally in:
167
178
 
168
179
  ```text
169
180
  ~/.config/agentic/opencode-plugins.json
@@ -171,6 +182,12 @@ When `opencode` is selected, interactive installs ask whether to enable Telegram
171
182
 
172
183
  Non-interactive installs create a disabled config when no config exists. Interactive installs ask for Telegram `botToken` and `chatId` when `telegram-notification` is selected. Those credentials are written to the target project `.agentic.json` under `settings.opencode_plugins.telegram`, not to `~/.config/agentic/opencode-plugins.json`. Treat `.agentic.json` as plaintext secret-bearing project config when Telegram is enabled and do not commit it to public repositories. When enabled, `agent-model-mapper` runs during interactive `agentic install`/`agentic tui`, uses `fzf` as a dropdown picker when available, and writes `.opencode/opencode.json` only after a Confirm action. OpenCode startup does not load a mapper runtime plugin or prompt for model mapping.
173
184
 
185
+ OpenCode model profiles are stored in `extensions/opencode/profiles` and appear in the same optional OpenCode selection menu as the plugin choices. The built-in choices are `OpenAI Model Profile` and `GitHub Copilot Model Profile`; non-interactive installs can choose them with `AGENTIC_OPENCODE_PROFILE=openai` or `AGENTIC_OPENCODE_PROFILE=githubcopilot`. Users can add local profiles under `$HOME/.config/agentic/opencode/profiles/<profile-id>/opencode.json`; for example, `DT/opencode.json` appears as `DT profile` and `GH/opencode.json` appears as `GH profile`. Profile selection merges agent model mappings into `.opencode/opencode.json`, then MCP configuration is merged afterward.
186
+
187
+ OpenCode MCP config uses top-level `mcp`, not `mcpServers`. Agentic migrates legacy OpenCode `mcpServers` entries into `mcp` during install. Codex continues to use `.codex/config.toml` with `[mcp_servers.*]` sections.
188
+
189
+ For selected Kubernetes and Docker MCP integrations, `agentic` performs non-fatal local checks after config generation: `kubectl version` for Kubernetes and `docker mcp --version` for Docker MCP. Failed checks appear as warnings in the final install report with official setup links. Docker MCP server entries are generated under the server name `docker`.
190
+
174
191
  ## Context7
175
192
 
176
193
  For `opencode`, `codex`, `claude`, `cursor`, `gemini`, `kilocode`, and `antigravity`, interactive installs ask whether to add Context7 MCP configuration. If enabled, a follow-up menu chooses either keyless mode or entering `CONTEXT7_API_KEY`. The selected key is written to all selected target configs for the current project. Most targets use project-level files, while `antigravity` is written to the global user path `~/.gemini/antigravity/mcp_config.json`.
@@ -44,7 +44,8 @@
44
44
  "uses_skills",
45
45
  "quality_gates",
46
46
  "examples",
47
- "skill_refs"
47
+ "skill_refs",
48
+ "workflow_diagram"
48
49
  ],
49
50
  "properties": {
50
51
  "trigger": {
@@ -104,6 +105,9 @@
104
105
  "type": "string"
105
106
  }
106
107
  },
108
+ "workflow_diagram": {
109
+ "type": "string"
110
+ },
107
111
  "examples": {
108
112
  "type": "object",
109
113
  "required": [
@@ -0,0 +1,28 @@
1
+ # Agentic MCP server selection
2
+
3
+ `agentic tui` includes a dedicated `Select MCP servers to enable:` step after target agent platform selection. The fzf flow supports multi-select with Space or Tab, Enter to confirm, Esc to skip, and a `None / skip` entry for users who do not want MCP configuration generated for the current install.
4
+
5
+ The MCP menu is driven by the CLI MCP registry rather than hardcoded UI rows. The registry tracks each server's id, display title, description, security level, default disabled state, and generated config block.
6
+
7
+ Supported registry ids:
8
+
9
+ | id | Description | Security |
10
+ | --- | --- | --- |
11
+ | `opencode-docs` | OpenCode docs MCP | safe |
12
+ | `playwright` | Browser automation via Playwright MCP | sensitive |
13
+ | `kubernetes` | Kubernetes pods/logs/exec management | dangerous |
14
+ | `youtube-transcript` | YouTube transcript extraction | safe |
15
+ | `docker-mcp` | Docker MCP Gateway | dangerous |
16
+ | `context7` | Fresh library documentation | safe |
17
+ | `mempalace` | Persistent project memory | sensitive |
18
+ | `anydb` | Database access MCP | dangerous |
19
+
20
+ For non-interactive installs, set `AGENTIC_ENABLE_MCPS` to a comma-separated list of registry ids. Dangerous MCPs require explicit confirmation before config is written. In non-interactive installs, set `AGENTIC_CONFIRM_DANGEROUS_MCP=1` to enable selected dangerous MCPs; otherwise agentic skips them and reports a warning.
21
+
22
+ OpenCode config generation writes current OpenCode-compatible top-level `mcp` entries, not legacy `mcpServers`. Re-running agentic preserves existing unknown fields, preserves an existing `$schema`, updates only the selected MCP entries, and migrates any existing OpenCode `mcpServers` entries into `mcp` before removing the invalid legacy key.
23
+
24
+ Codex config generation remains TOML-based and writes `[mcp_servers.<name>]` sections in `.codex/config.toml`.
25
+
26
+ When `kubernetes` is selected, `agentic` checks whether `kubectl version` succeeds. If it does not, install continues and the final report warns with the official kubectl setup guide: <https://kubernetes.io/docs/tasks/tools/>.
27
+
28
+ When `docker-mcp` is selected, generated MCP server names use `docker` instead of the older `MCP_DOCKER`. `agentic` checks whether `docker mcp --version` succeeds. If it does not, install continues and the final report warns with Docker setup links: <https://docs.docker.com/get-started/get-docker/> and <https://docs.docker.com/ai/mcp-catalog-and-toolkit/>.
@@ -33,7 +33,7 @@ When `agentic` installs the OpenCode extension, it configures optional plugins i
33
33
  ~/.config/agentic/opencode-plugins.json
34
34
  ```
35
35
 
36
- Telegram notifications and agent model mapping are opt-in. Interactive `agentic install` and `agentic tui` ask for OpenCode plugin selection whenever `opencode` is selected; the answer rewrites this config. During manifest-based upgrade/re-install sync, existing plugin settings are kept so automated refreshes do not open prompts. If the config is absent or a plugin is disabled, the plugin returns no hooks and OpenCode continues without that behavior.
36
+ Telegram notifications and agent model mapping are opt-in. Interactive `agentic install` and `agentic tui` ask for OpenCode plugin selection whenever `opencode` is selected. The menu uses readable labels (`Telegram Notifications` and `Agent Model Mapping`) while keeping the stored internal ids `telegram-notification` and `agent-model-mapper`. The answer rewrites this config. During manifest-based upgrade/re-install sync, existing plugin settings are kept so automated refreshes do not open prompts. If the config is absent or a plugin is disabled, the plugin returns no hooks and OpenCode continues without that behavior.
37
37
 
38
38
  When `telegram-notification` is selected interactively, `agentic` asks for `botToken` and `chatId` and stores them in the target project's `.agentic.json`:
39
39
 
@@ -48,5 +48,25 @@ Non-interactive `agentic install` defaults optional plugins to disabled when no
48
48
 
49
49
  `agent-model-mapper` reads roles from target `.opencode/agents/*.md` and discovers model names from `~/.config/opencode/opencode.json`, then adds models from active providers in `~/.local/share/opencode/auth.json` using non-deprecated entries in `~/.cache/opencode/models.json`. When enabled, interactive `agentic install`/`agentic tui` prompts for a main and fallback model per role, using `fzf` as a dropdown picker when available, and writes `.opencode/opencode.json` only after a Confirm action. OpenCode startup never opens `fzf` or waits for model input because no mapper runtime plugin is shipped or registered.
50
50
 
51
+ Agentic also ships reusable OpenCode model profiles in:
52
+
53
+ ```text
54
+ extensions/opencode/profiles/
55
+ ```
56
+
57
+ The current profiles are `OpenAI Model Profile` (`openai/opencode.json`) and `GitHub Copilot Model Profile` (`githubcopilot/opencode.json`). They appear in the same optional OpenCode selection menu as the plugin choices. Selecting one merges its agent model mapping into `.opencode/opencode.json`; later MCP configuration is merged on top, so profile selection does not block future MCP sections.
58
+
59
+ Users can add local OpenCode profiles in:
60
+
61
+ ```text
62
+ $HOME/.config/agentic/opencode/profiles/<profile-id>/opencode.json
63
+ ```
64
+
65
+ Local profiles appear below the bundled profiles in the optional OpenCode plugin menu using the label `<profile-id> profile`. For example, `$HOME/.config/agentic/opencode/profiles/DT/opencode.json` appears as `DT profile`, and `$HOME/.config/agentic/opencode/profiles/GH/opencode.json` appears as `GH profile`.
66
+
67
+ Selecting `none` applies no model profile and does not copy the baseline `extensions/opencode/opencode.json` just for profile selection. If OpenCode MCPs, Telegram notifications, or agent model mapping are selected, `agentic` may still create or update `.opencode/opencode.json` for those explicit options.
68
+
69
+ For MCP servers, OpenCode uses top-level `mcp` entries. Agentic migrates legacy `mcpServers` in OpenCode configs to `mcp` and removes the invalid key.
70
+
51
71
  For OpenCode targets, `agentic` writes generated operating guidance to `.opencode/AGENTS.md`. If OpenCode is installed
52
72
  alongside another agent target, root `AGENTS.md` is generated as well for the non-OpenCode target.
@@ -17,11 +17,13 @@ For this repo we keep it lightweight and dependency-minimal:
17
17
  - site is static HTML/CSS/JS
18
18
  - markdown rendering via `marked` CDN
19
19
  - full-text search via `lunr` CDN
20
+ - workflow diagrams rendered via `mermaid` CDN
20
21
 
21
22
  ## Run locally
22
23
 
23
24
  ```bash
24
- python3 scripts/build_docs_catalog.py --output docs/site/catalog.json --validate
25
+ make sync-diagrams
26
+ make build
25
27
  python3 -m http.server 8000
26
28
  # open http://localhost:8000/docs/site/
27
29
  ```
@@ -31,7 +33,9 @@ python3 -m http.server 8000
31
33
  - Left menu grouped by area.
32
34
  - Full-text search by trigger/name/description/examples.
33
35
  - Language switcher: EN only / RU only / EN+RU.
36
+ - Light and dark themes, with light as the default and the selected theme saved in the browser.
34
37
  - Workflow page with quality gates and source paths.
38
+ - Generated Mermaid agent interaction diagrams for workflows.
35
39
 
36
40
 
37
41
  ## GitHub Pages
@@ -42,3 +46,13 @@ This site can be published from GitHub Pages via Actions workflow (`.github/work
42
46
  ## Workflow mapping
43
47
 
44
48
  Prompt-to-workflow mapping is command-based: `/workflow-file-name` in prompt text links to `workflows/<workflow-file-name>.md` in the same area.
49
+
50
+ ## Workflow diagrams
51
+
52
+ Workflow diagrams are generated into `areas/**/workflows/*.md` between `agent-diagram` markers:
53
+
54
+ ```bash
55
+ make sync-diagrams
56
+ ```
57
+
58
+ The catalog builder extracts those Mermaid blocks into `workflow_diagram`, and the static site renders them after Markdown parsing.
package/docs/site/app.js CHANGED
@@ -2,11 +2,16 @@ let catalog;
2
2
  let current = null;
3
3
  let idx;
4
4
  let docs = [];
5
+ let activeTheme = 'light';
5
6
 
6
7
  const menuEl = document.getElementById('menu');
7
8
  const contentEl = document.getElementById('content');
8
9
  const searchEl = document.getElementById('search');
9
10
  const langEl = document.getElementById('language');
11
+ const themeToggleEl = document.getElementById('theme-toggle');
12
+
13
+ applyTheme(getStoredTheme());
14
+ configureMermaid();
10
15
 
11
16
  init();
12
17
 
@@ -91,6 +96,8 @@ ${wf.description || ''}
91
96
  ## Roles
92
97
  ${(wf.roles || []).map((r) => `<span class="chip">${r}</span>`).join(' ')}
93
98
 
99
+ ${wf.workflow_diagram ? `## Agent Interaction Diagram\n\n\`\`\`mermaid\n${escapeFence(wf.workflow_diagram)}\n\`\`\`` : ''}
100
+
94
101
  ## Quality gates
95
102
  ${(wf.quality_gates || []).map((q) => `- ${q}`).join('\n') || '- —'}
96
103
 
@@ -106,12 +113,66 @@ ${examples || '_No examples_'}
106
113
  `;
107
114
 
108
115
  contentEl.innerHTML = marked.parse(md);
116
+ renderMermaidBlocks();
117
+ }
118
+
119
+ function getStoredTheme() {
120
+ try {
121
+ const theme = window.localStorage.getItem('docs-site-theme');
122
+ return theme === 'dark' ? 'dark' : 'light';
123
+ } catch {
124
+ return 'light';
125
+ }
126
+ }
127
+
128
+ function storeTheme(theme) {
129
+ try {
130
+ window.localStorage.setItem('docs-site-theme', theme);
131
+ } catch {
132
+ // localStorage can be unavailable in private or restricted browser modes.
133
+ }
134
+ }
135
+
136
+ function applyTheme(theme) {
137
+ activeTheme = theme === 'dark' ? 'dark' : 'light';
138
+ document.documentElement.dataset.theme = activeTheme;
139
+ if (!themeToggleEl) return;
140
+ const isDark = activeTheme === 'dark';
141
+ themeToggleEl.setAttribute('aria-pressed', String(isDark));
142
+ themeToggleEl.textContent = isDark ? 'Light' : 'Dark';
143
+ }
144
+
145
+ function configureMermaid() {
146
+ if (!window.mermaid) return;
147
+ window.mermaid.initialize({
148
+ startOnLoad: false,
149
+ securityLevel: 'strict',
150
+ theme: activeTheme === 'dark' ? 'dark' : 'default',
151
+ });
109
152
  }
110
153
 
111
154
  function escapeFence(s) {
112
155
  return (s || '').replace(/```/g, '\\\`\\\`\\\`');
113
156
  }
114
157
 
158
+ async function renderMermaidBlocks() {
159
+ const blocks = [...contentEl.querySelectorAll('code.language-mermaid')];
160
+ if (!blocks.length) return;
161
+
162
+ const nodes = blocks.map((block) => {
163
+ const diagram = document.createElement('div');
164
+ diagram.className = 'mermaid';
165
+ diagram.textContent = block.textContent;
166
+ block.parentElement.replaceWith(diagram);
167
+ return diagram;
168
+ });
169
+
170
+ if (window.mermaid) {
171
+ configureMermaid();
172
+ await window.mermaid.run({ nodes });
173
+ }
174
+ }
175
+
115
176
  searchEl.addEventListener('input', () => {
116
177
  const q = searchEl.value.trim();
117
178
  if (!q) {
@@ -125,3 +186,10 @@ searchEl.addEventListener('input', () => {
125
186
  langEl.addEventListener('change', () => {
126
187
  if (current) renderWorkflow(current.id);
127
188
  });
189
+
190
+ themeToggleEl.addEventListener('click', () => {
191
+ const nextTheme = activeTheme === 'dark' ? 'light' : 'dark';
192
+ applyTheme(nextTheme);
193
+ storeTheme(nextTheme);
194
+ if (current) renderWorkflow(current.id);
195
+ });