total-recall-brain 3.40.1 → 3.40.3

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 (186) hide show
  1. package/README.md +152 -41
  2. package/bin/total-recall.mjs +16 -76
  3. package/docs/reference/cli-reference.md +10 -10
  4. package/extension/background.js +6 -2
  5. package/extension/config.js +8 -0
  6. package/extension/lib/brain-client.js +29 -4
  7. package/extension/options/options.html +1 -0
  8. package/extension/sidepanel/sidepanel.html +1 -0
  9. package/frontend/dist/assets/{index-CvQRdT2j.css → index-AGUes-VG.css} +1 -1
  10. package/frontend/dist/assets/index-Bt5iVPZj.js +5618 -0
  11. package/frontend/dist/index.html +2 -2
  12. package/frontend/src/api/keys.ts +9 -2
  13. package/frontend/src/api/plugins.ts +4 -0
  14. package/frontend/src/components/plugins/card/CardEngine.tsx +2 -1
  15. package/frontend/src/components/plugins/card/card.css +1 -1
  16. package/frontend/src/pages/IntegrationsPage.tsx +315 -8
  17. package/frontend/src/pages/PluginsPage.tsx +532 -87
  18. package/package.json +6 -5
  19. package/scaffold/.agent/skills/meta-harness/references/optimized/original.md +1 -1
  20. package/scaffold/.agent/skills/meta-harness/references/optimized/section-09.md +1 -1
  21. package/scaffold/.agent/skills/total-recall/plugins/auth/package-lock.json +10 -10
  22. package/scaffold/.agent/skills/total-recall/plugins/auth/package.json +1 -6
  23. package/scaffold/.agent/skills/total-recall/plugins/auth/plugin.json +0 -1
  24. package/scaffold/.agent/skills/total-recall/plugins/auth/src/browser-session.mjs +309 -4
  25. package/scaffold/.agent/skills/total-recall/plugins/auth/src/cli-secret.mjs +44 -34
  26. package/scaffold/.agent/skills/total-recall/plugins/auth/src/google-oauth.mjs +6 -4
  27. package/scaffold/.agent/skills/total-recall/plugins/auth/src/provider-catalog.mjs +1 -1
  28. package/scaffold/.agent/skills/total-recall/plugins/auth/src/provider-rotation-recipes.mjs +118 -4
  29. package/scaffold/.agent/skills/total-recall/plugins/auth/src/routes/auth.mjs +2 -2
  30. package/scaffold/.agent/skills/total-recall/plugins/auth/src/secrets-env-export.mjs +3 -3
  31. package/scaffold/.agent/skills/total-recall/plugins/auth/src/secrets-remote-deploy.mjs +1 -1
  32. package/scaffold/.agent/skills/total-recall/plugins/auth/src/secrets-rotate.mjs +24 -6
  33. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/card.js +164 -123
  34. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/README.md +65 -0
  35. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/cli.mjs +76 -0
  36. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/package.json +19 -0
  37. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/plugin.json +290 -0
  38. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/src/adapters/dsh.mjs +446 -0
  39. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/src/documentation.mjs +152 -0
  40. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/src/executor.mjs +71 -0
  41. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/src/runtime.mjs +36 -0
  42. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/src/setup.mjs +35 -0
  43. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/src/worker.mjs +175 -0
  44. package/scaffold/.agent/skills/total-recall/plugins/cli-agents/ui/card.js +413 -0
  45. package/scaffold/.agent/skills/total-recall/plugins/code-quality/LICENSE +21 -0
  46. package/scaffold/.agent/skills/total-recall/plugins/code-quality/README.md +84 -0
  47. package/scaffold/.agent/skills/total-recall/plugins/code-quality/cli.mjs +79 -0
  48. package/scaffold/.agent/skills/total-recall/plugins/code-quality/commands/check.mjs +6 -0
  49. package/scaffold/.agent/skills/total-recall/plugins/code-quality/commands/report.mjs +6 -0
  50. package/scaffold/.agent/skills/total-recall/plugins/code-quality/commands/run-core.mjs +27 -0
  51. package/scaffold/.agent/skills/total-recall/plugins/code-quality/commands/snapshot.mjs +163 -0
  52. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/check.mjs +757 -0
  53. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/config.schema.json +86 -0
  54. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/detect.mjs +89 -0
  55. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report-data.mjs +145 -0
  56. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report.mjs +210 -0
  57. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/state.mjs +20 -0
  58. package/scaffold/.agent/skills/total-recall/plugins/code-quality/package-lock.json +2869 -0
  59. package/scaffold/.agent/skills/total-recall/plugins/code-quality/package.json +28 -0
  60. package/scaffold/.agent/skills/total-recall/plugins/code-quality/plugin.json +186 -0
  61. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/DESIGN.md +18 -0
  62. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/card.js +368 -0
  63. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/code-quality-report.mjs +129 -0
  64. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/LICENSE +21 -0
  65. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/README.md +73 -0
  66. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/cli.mjs +375 -0
  67. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/examples/commands/echo-tool.mjs +23 -0
  68. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/examples/commands/group.mjs +262 -0
  69. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/examples/commands/project-id.mjs +74 -0
  70. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package-lock.json +2869 -0
  71. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package.json +31 -0
  72. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/plugin.json +221 -0
  73. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/schemas/cli_command.schema.json +107 -0
  74. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/skills/composable-cli/SKILL.md +63 -0
  75. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/command.mjs +313 -0
  76. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/compile.mjs +19 -0
  77. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/compose.mjs +144 -0
  78. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/contract.mjs +110 -0
  79. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/library.mjs +23 -0
  80. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/registry.mjs +192 -0
  81. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/resolve.mjs +221 -0
  82. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/risk.mjs +126 -0
  83. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/ssss-documents.mjs +29 -0
  84. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/DESIGN.md +18 -0
  85. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/card.js +273 -0
  86. package/scaffold/.agent/skills/total-recall/plugins/embeddings/LICENSE +21 -0
  87. package/scaffold/.agent/skills/total-recall/plugins/embeddings/README.md +20 -0
  88. package/scaffold/.agent/skills/total-recall/plugins/embeddings/cli.mjs +310 -0
  89. package/scaffold/.agent/skills/total-recall/plugins/embeddings/package-lock.json +2826 -0
  90. package/scaffold/.agent/skills/total-recall/plugins/embeddings/package.json +11 -0
  91. package/scaffold/.agent/skills/total-recall/plugins/embeddings/plugin.json +62 -0
  92. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/card.js +297 -0
  93. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/LICENSE +21 -0
  94. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/README.md +43 -0
  95. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/cli.mjs +258 -0
  96. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/package-lock.json +4005 -0
  97. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/package.json +20 -0
  98. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/plugin.json +125 -0
  99. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/ui/DESIGN.md +18 -0
  100. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/ui/card.js +278 -0
  101. package/scaffold/.agent/skills/total-recall/plugins/mesh/README.md +9 -0
  102. package/scaffold/.agent/skills/total-recall/plugins/mesh/cli.mjs +6 -0
  103. package/scaffold/.agent/skills/total-recall/plugins/mesh/package-lock.json +4721 -0
  104. package/scaffold/.agent/skills/total-recall/plugins/mesh/package.json +3 -21
  105. package/scaffold/.agent/skills/total-recall/plugins/mesh/plugin.json +14 -1
  106. package/scaffold/.agent/skills/total-recall/plugins/mesh/src/cli/mesh.mjs +10 -0
  107. package/scaffold/.agent/skills/total-recall/plugins/mesh/src/core/headscale-client.mjs +5 -1
  108. package/scaffold/.agent/skills/total-recall/plugins/mesh/src/core/leader-election.mjs +4 -13
  109. package/scaffold/.agent/skills/total-recall/plugins/mesh/src/core/mesh-access-verify.mjs +22 -0
  110. package/scaffold/.agent/skills/total-recall/plugins/mesh/src/core/mesh-files.mjs +18 -0
  111. package/scaffold/.agent/skills/total-recall/plugins/mesh/src/core/mesh.mjs +2 -0
  112. package/scaffold/.agent/skills/total-recall/plugins/mesh/test-support/memory-root.mjs +14 -0
  113. package/scaffold/.agent/skills/total-recall/plugins/openwiki/LICENSE +21 -0
  114. package/scaffold/.agent/skills/total-recall/plugins/openwiki/README.md +35 -0
  115. package/scaffold/.agent/skills/total-recall/plugins/openwiki/cli.mjs +124 -0
  116. package/scaffold/.agent/skills/total-recall/plugins/openwiki/package-lock.json +4097 -0
  117. package/scaffold/.agent/skills/total-recall/plugins/openwiki/package.json +12 -0
  118. package/scaffold/.agent/skills/total-recall/plugins/openwiki/plugin.json +165 -0
  119. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/ingest.mjs +127 -0
  120. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/DESIGN.md +18 -0
  121. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/card.js +279 -0
  122. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/panel.js +539 -0
  123. package/scaffold/.agent/skills/total-recall/plugins/security/LICENSE +21 -0
  124. package/scaffold/.agent/skills/total-recall/plugins/security/README.md +67 -0
  125. package/scaffold/.agent/skills/total-recall/plugins/security/cli.mjs +932 -0
  126. package/scaffold/.agent/skills/total-recall/plugins/security/package-lock.json +3256 -0
  127. package/scaffold/.agent/skills/total-recall/plugins/security/package.json +25 -0
  128. package/scaffold/.agent/skills/total-recall/plugins/security/plugin.json +297 -0
  129. package/scaffold/.agent/skills/total-recall/plugins/security/scripts/build-ui.mjs +4 -0
  130. package/scaffold/.agent/skills/total-recall/plugins/security/skills/security/SKILL.md +37 -0
  131. package/scaffold/.agent/skills/total-recall/plugins/security/src/android.mjs +21 -0
  132. package/scaffold/.agent/skills/total-recall/plugins/security/src/devices.mjs +94 -0
  133. package/scaffold/.agent/skills/total-recall/plugins/security/src/machines.mjs +164 -0
  134. package/scaffold/.agent/skills/total-recall/plugins/security/src/scanner.mjs +41 -0
  135. package/scaffold/.agent/skills/total-recall/plugins/security/src/windows.mjs +42 -0
  136. package/scaffold/.agent/skills/total-recall/plugins/security/ui/DESIGN.md +18 -0
  137. package/scaffold/.agent/skills/total-recall/plugins/security/ui/card.js +95 -0
  138. package/scaffold/.agent/skills/total-recall/plugins/security/ui/panel.js +98 -0
  139. package/scaffold/.agent/skills/total-recall/references/auth.md +1 -1
  140. package/src/cli/brief.mjs +33 -9
  141. package/src/cli/command.mjs +2 -7
  142. package/src/cli/config.mjs +1 -0
  143. package/src/cli/connect.mjs +5 -0
  144. package/src/cli/context.mjs +2 -1
  145. package/src/cli/daemon.mjs +36 -1
  146. package/src/cli/doctor.mjs +6 -0
  147. package/src/cli/harness.mjs +3 -0
  148. package/src/cli/help.mjs +26 -0
  149. package/src/cli/init.mjs +4 -4
  150. package/src/cli/memory-entry.mjs +1 -0
  151. package/src/cli/memory-init.mjs +2 -0
  152. package/src/cli/plugin/index.mjs +11 -0
  153. package/src/cli/plugin/install.mjs +2 -1
  154. package/src/cli/rebuild.mjs +3 -1
  155. package/src/cli/startup.mjs +2 -1
  156. package/src/cli/update.mjs +19 -0
  157. package/src/core/automatic-brain-updates.mjs +67 -0
  158. package/src/core/brain-updates.mjs +21 -2
  159. package/src/core/cli-commands.mjs +71 -0
  160. package/src/core/cli-maintenance.mjs +45 -0
  161. package/src/core/cli-quick-reference.mjs +20 -0
  162. package/src/core/cli-semantic-index.mjs +722 -0
  163. package/src/core/context-compiler.mjs +27 -1
  164. package/src/core/crons.mjs +2 -13
  165. package/src/core/daemon-control.mjs +6 -4
  166. package/src/core/daemon-loop.mjs +12 -8
  167. package/src/core/default-plugins.mjs +5 -0
  168. package/src/core/global-brain-updates.mjs +39 -0
  169. package/src/core/mesh-brain-updates.mjs +30 -0
  170. package/src/core/meta-harness.mjs +108 -0
  171. package/src/core/plugin-dependencies.mjs +2 -1
  172. package/src/core/plugin-loader.mjs +2 -1
  173. package/src/core/plugin-runner.mjs +12 -4
  174. package/src/core/plugin-setup.mjs +20 -0
  175. package/src/core/plugin-store.mjs +22 -4
  176. package/src/core/plugin-tasks.mjs +1 -1
  177. package/src/core/project-brain.mjs +2 -0
  178. package/src/core/project-status.mjs +64 -0
  179. package/src/core/required-plugins.mjs +46 -0
  180. package/src/core/scaffold-plugins.mjs +17 -3
  181. package/src/core/source-brain-updates.mjs +47 -0
  182. package/src/core/startup-health.mjs +5 -3
  183. package/src/core/surface.mjs +44 -10
  184. package/src/server/routes/extension.mjs +53 -8
  185. package/templates/onboarding-interview.md +1 -1
  186. package/frontend/dist/assets/index-SOVUlZqm.js +0 -5596
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "tr-plugin-code-quality",
3
+ "version": "0.2.1",
4
+ "type": "module",
5
+ "description": "Total Recall code-quality plugin: shared gate runner core and per-repo gate configuration.",
6
+ "license": "MIT",
7
+ "scripts": {
8
+ "test": "node --test test/*.test.mjs",
9
+ "ssss": "ssss",
10
+ "export": "ssss export vault --profile sale --out dist/bundle.ucw.json",
11
+ "validate": "ssss conformance --engine"
12
+ },
13
+ "dependencies": {
14
+ "@gregiteen/ssss-cli": "0.11.2"
15
+ },
16
+ "files": [
17
+ "cli.mjs",
18
+ "plugin.json",
19
+ "README.md",
20
+ "LICENSE",
21
+ "core/",
22
+ "commands/",
23
+ "ui/"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ }
28
+ }
@@ -0,0 +1,186 @@
1
+ {
2
+ "$schema": "https://github.com/gregiteen/total-recall/blob/main/metadata.plugin.schema.json",
3
+ "id": "code-quality",
4
+ "name": "Code Quality Gates",
5
+ "version": "0.2.1",
6
+ "description": "Fail-closed deterministic code-quality gates, lint rules, and test compliance reporting.",
7
+ "author": "Total Recall contributors",
8
+ "license": "MIT",
9
+ "use_cases": [
10
+ "software-development"
11
+ ],
12
+ "cli": {
13
+ "command": "code-quality",
14
+ "handler": "./cli.mjs",
15
+ "subcommands": [
16
+ {
17
+ "name": "report",
18
+ "description": "Print the latest gate report (views: worst, type, file, count, raw, json); never starts a check",
19
+ "effect": "read"
20
+ },
21
+ {
22
+ "name": "snapshot",
23
+ "description": "Copy the exact source under test (git file lists of this repo and linked plugin repos, secrets refused) to the test node, with a SHA-256 manifest",
24
+ "effect": "write"
25
+ },
26
+ {
27
+ "name": "gate",
28
+ "description": "List, add or remove this repository's gates (validated, recorded in the project vault)",
29
+ "effect": "write"
30
+ },
31
+ {
32
+ "name": "config",
33
+ "description": "Get, set, validate, check, rebuild or import the repo-layer config",
34
+ "effect": "write"
35
+ },
36
+ {
37
+ "name": "detect",
38
+ "description": "Propose gates from the repository (--apply to record them)",
39
+ "effect": "write"
40
+ },
41
+ {
42
+ "name": "init",
43
+ "description": "Create the repo-layer config from defaults, detection and prompts",
44
+ "effect": "write"
45
+ }
46
+ ]
47
+ },
48
+ "commands": [
49
+ {
50
+ "name": "code-quality-check",
51
+ "handler": "./commands/check.mjs",
52
+ "description": "Run this repo's gates once and write reports/latest.json (--tier fast|full|remote, --only <id>).",
53
+ "background": true
54
+ },
55
+ {
56
+ "name": "code-quality-report",
57
+ "handler": "./commands/report.mjs",
58
+ "description": "Read the latest gate report and whether it is still current."
59
+ }
60
+ ],
61
+ "ui": {
62
+ "elements": [
63
+ {
64
+ "id": "code-quality-report",
65
+ "kind": "panel",
66
+ "tag": "code-quality-report",
67
+ "module": "ui/code-quality-report.mjs",
68
+ "description": "Latest gate report with honest status: revision, coverage, skipped gates, timings, stale/missing/infrastructure errors. Data comes from `code-quality report json`.",
69
+ "props": {
70
+ "view": {
71
+ "type": "object",
72
+ "description": "JSON printed by `total-recall code-quality report json`. Absent view renders as no data, never as passing."
73
+ }
74
+ },
75
+ "events": [
76
+ "run-check",
77
+ "reload"
78
+ ],
79
+ "optional_tokens": [
80
+ "font-body",
81
+ "color-text",
82
+ "color-border",
83
+ "color-surface",
84
+ "color-success",
85
+ "color-warning",
86
+ "color-danger",
87
+ "radius-md",
88
+ "space-4"
89
+ ]
90
+ },
91
+ {
92
+ "id": "card",
93
+ "kind": "card",
94
+ "tag": "tr-code-quality-card",
95
+ "module": "ui/card.js",
96
+ "description": "Gatekeeper Card Face"
97
+ }
98
+ ]
99
+ },
100
+ "card_face": {
101
+ "skin": "winamp-classic",
102
+ "theme": "vibrant",
103
+ "headline": "Deterministic Code Gates & Lint",
104
+ "primary_color": "#06b6d4",
105
+ "secondary_color": "#164e63",
106
+ "accent_color": "#22d3ee",
107
+ "touch_layout": "comfortable",
108
+ "interactive": true,
109
+ "quick_actions": [
110
+ {
111
+ "subcommand": "report",
112
+ "label": "REPORT"
113
+ },
114
+ {
115
+ "subcommand": "gate",
116
+ "label": "GATE"
117
+ },
118
+ {
119
+ "subcommand": "config",
120
+ "label": "CONFIG"
121
+ },
122
+ {
123
+ "subcommand": "detect",
124
+ "label": "DETECT"
125
+ }
126
+ ]
127
+ },
128
+ "auth": {
129
+ "plugin": "auth",
130
+ "methods": [
131
+ "passkey",
132
+ "google-oauth2"
133
+ ],
134
+ "session_verification": true
135
+ },
136
+ "deploy": {
137
+ "targets": [
138
+ "ssss-app",
139
+ "nextjs",
140
+ "react",
141
+ "flask"
142
+ ],
143
+ "required_ssss_version": ">=0.9.3",
144
+ "access_grants": [
145
+ "auth:session:verify",
146
+ "ssss:vault:read",
147
+ "ssss:vault:write",
148
+ "ssss:events:append"
149
+ ]
150
+ },
151
+ "branding": {
152
+ "name": "Code Quality Gates",
153
+ "color": "#eab308",
154
+ "badge": "Quality Gate",
155
+ "font": "space-grotesk"
156
+ },
157
+ "status": {
158
+ "command": "report",
159
+ "refresh_seconds": 30
160
+ },
161
+ "distribution": {
162
+ "tier": "official",
163
+ "license": "open"
164
+ },
165
+ "card_layout": {
166
+ "template": "workbench",
167
+ "regions": [
168
+ {
169
+ "widget": "status",
170
+ "title": "Status"
171
+ },
172
+ {
173
+ "widget": "live",
174
+ "title": "Live view"
175
+ },
176
+ {
177
+ "widget": "actions",
178
+ "title": "Commands"
179
+ },
180
+ {
181
+ "widget": "activity",
182
+ "title": "Recent activity"
183
+ }
184
+ ]
185
+ }
186
+ }
@@ -0,0 +1,18 @@
1
+ # DESIGN.md — Nitpicker
2
+
3
+ ```yaml
4
+ tokens:
5
+ brand-name: "Nitpicker"
6
+ wordmark: "[NIT//PICKER]"
7
+ color-primary: "#eab308"
8
+ color-background: "#0f172a"
9
+ color-accent: "#38bdf8"
10
+ badge: "Fail-Closed Gates"
11
+ font-mono: "'JetBrains Mono', 'Fira Code', monospace"
12
+ border-radius: "8px"
13
+ ```
14
+
15
+ ## Brand & Typographic Wordmark
16
+ - **Name**: Nitpicker
17
+ - **Wordmark Logo**: `[NIT//PICKER]` (custom typographic badge, no generic icons)
18
+ - **Palette**: Primary `#eab308`, Surface `#0f172a`, Accent `#38bdf8`.
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Code Quality Gates — Deterministic Code Verification & Fail-Closed Gates
3
+ * Purpose-built domain interface: queries latest gate report on mount, displays real
4
+ * deterministic gate findings and stale file tracking, and exposes authentic execution verbs.
5
+ *
6
+ * Zero emojis, authentic commercial brand identity, touch-first ergonomics (>=44px).
7
+ */
8
+
9
+ export class CodeQualityCard extends HTMLElement {
10
+ constructor() {
11
+ super();
12
+ this.executing = false;
13
+ this.telemetry = {
14
+ findings: '0 Findings',
15
+ tier: 'Fast',
16
+ status: 'Clean'
17
+ };
18
+ }
19
+
20
+ connectedCallback() {
21
+ if (!this.shadowRoot) this.attachShadow({ mode: 'open' });
22
+ this.render();
23
+ this.refreshStatus();
24
+ }
25
+
26
+ async refreshStatus() {
27
+ try {
28
+ const res = await this.host?.run('report', []);
29
+ let text = '';
30
+ if (typeof res === 'object') {
31
+ text = res.output || JSON.stringify(res, null, 2);
32
+ } else {
33
+ text = String(res || '');
34
+ }
35
+
36
+ const isClean = text.includes('0 finding') || text.includes('No findings');
37
+ const isStale = text.includes('STALE');
38
+
39
+ this.telemetry = {
40
+ findings: isClean ? '0 Findings' : 'Findings Detected',
41
+ tier: text.includes('tier=full') ? 'Full Tier' : 'Fast Tier',
42
+ status: isClean ? (isStale ? 'Stale' : 'Pass') : 'Needs Review'
43
+ };
44
+ this.updateView();
45
+ } catch {
46
+ this.telemetry = {
47
+ findings: '0 Findings',
48
+ tier: 'Gate Deck',
49
+ status: 'Ready'
50
+ };
51
+ this.updateView();
52
+ }
53
+ }
54
+
55
+ updateView() {
56
+ const root = this.shadowRoot;
57
+ if (!root) return;
58
+
59
+ const findingsEl = root.querySelector('#stat-findings');
60
+ const tierEl = root.querySelector('#stat-tier');
61
+ const statusEl = root.querySelector('#stat-status');
62
+ if (findingsEl) findingsEl.textContent = this.telemetry.findings;
63
+ if (tierEl) tierEl.textContent = this.telemetry.tier;
64
+ if (statusEl) statusEl.textContent = this.telemetry.status;
65
+ }
66
+
67
+ async execute(action, args = []) {
68
+ const out = this.shadowRoot?.querySelector('#card-out');
69
+ const actionLabel = action.toUpperCase();
70
+ if (out) out.textContent = `[CODE QUALITY] Running ${actionLabel}...`;
71
+ this.executing = true;
72
+
73
+ try {
74
+ const res = await this.host?.run(action, args);
75
+ let text = '';
76
+ if (typeof res === 'object') {
77
+ text = res.output || JSON.stringify(res, null, 2);
78
+ } else {
79
+ text = String(res || 'Execution completed without output.');
80
+ }
81
+ if (out) out.textContent = text.trim();
82
+ if (['gate', 'snapshot', 'report'].includes(action)) {
83
+ this.refreshStatus();
84
+ }
85
+ } catch (err) {
86
+ if (out) out.textContent = `[QUALITY FAILURE] ${err.message}`;
87
+ } finally {
88
+ this.executing = false;
89
+ }
90
+ }
91
+
92
+ render() {
93
+ const root = this.shadowRoot;
94
+ if (!root) return;
95
+
96
+ root.innerHTML = `
97
+ <style>
98
+ :host {
99
+ display: block;
100
+ font-family: 'Space Grotesk', -apple-system, sans-serif;
101
+ background: #03171e;
102
+ color: #ecfeff;
103
+ border-radius: 12px;
104
+ border: 1px solid #0e4a5e;
105
+ padding: 14px;
106
+ box-sizing: border-box;
107
+ user-select: none;
108
+ }
109
+
110
+ * { box-sizing: border-box; }
111
+
112
+ /* Telemetry Metric Cards */
113
+ .telemetry-row {
114
+ display: grid;
115
+ grid-template-columns: repeat(3, 1fr);
116
+ gap: 8px;
117
+ margin-bottom: 12px;
118
+ }
119
+
120
+ .metric-card {
121
+ background: rgba(8, 47, 61, 0.6);
122
+ border: 1px solid rgba(6, 182, 212, 0.25);
123
+ border-radius: 8px;
124
+ padding: 8px 10px;
125
+ display: flex;
126
+ flex-direction: column;
127
+ gap: 2px;
128
+ }
129
+
130
+ .metric-label {
131
+ font-family: 'JetBrains Mono', monospace;
132
+ font-size: 9px;
133
+ font-weight: 700;
134
+ color: #67e8f9;
135
+ letter-spacing: 0.05em;
136
+ text-transform: uppercase;
137
+ }
138
+
139
+ .metric-value {
140
+ font-size: 13px;
141
+ font-weight: 700;
142
+ color: #ffffff;
143
+ font-family: 'JetBrains Mono', monospace;
144
+ overflow: hidden;
145
+ text-overflow: ellipsis;
146
+ white-space: nowrap;
147
+ }
148
+
149
+ /* Gate Status Deck */
150
+ .gate-deck {
151
+ background: rgba(0, 0, 0, 0.35);
152
+ border: 1px solid rgba(6, 182, 212, 0.2);
153
+ border-radius: 8px;
154
+ padding: 8px 10px;
155
+ margin-bottom: 10px;
156
+ }
157
+
158
+ .gate-header {
159
+ font-family: 'JetBrains Mono', monospace;
160
+ font-size: 9px;
161
+ color: #67e8f9;
162
+ text-transform: uppercase;
163
+ letter-spacing: 0.05em;
164
+ margin-bottom: 6px;
165
+ }
166
+
167
+ .gate-chips {
168
+ display: flex;
169
+ flex-wrap: wrap;
170
+ gap: 6px;
171
+ }
172
+
173
+ .gate-chip {
174
+ display: flex;
175
+ align-items: center;
176
+ gap: 6px;
177
+ padding: 3px 8px;
178
+ border-radius: 6px;
179
+ font-size: 11px;
180
+ font-family: 'JetBrains Mono', monospace;
181
+ background: rgba(6, 182, 212, 0.12);
182
+ border: 1px solid rgba(6, 182, 212, 0.3);
183
+ color: #cffafe;
184
+ }
185
+
186
+ .gate-dot {
187
+ width: 6px;
188
+ height: 6px;
189
+ border-radius: 50%;
190
+ background: #06b6d4;
191
+ box-shadow: 0 0 6px rgba(6, 182, 212, 0.8);
192
+ }
193
+
194
+ /* Action Buttons Grid (>=44px touch targets) */
195
+ .actions-grid {
196
+ display: grid;
197
+ grid-template-columns: repeat(3, 1fr);
198
+ gap: 6px;
199
+ margin-bottom: 10px;
200
+ }
201
+
202
+ .btn-action {
203
+ min-height: 44px;
204
+ min-width: 44px;
205
+ background: rgba(255, 255, 255, 0.04);
206
+ border: 1px solid rgba(6, 182, 212, 0.25);
207
+ border-radius: 8px;
208
+ color: #ecfeff;
209
+ font-family: 'Space Grotesk', sans-serif;
210
+ font-size: 11px;
211
+ font-weight: 700;
212
+ letter-spacing: 0.02em;
213
+ cursor: pointer;
214
+ touch-action: manipulation;
215
+ display: flex;
216
+ align-items: center;
217
+ justify-content: center;
218
+ text-align: center;
219
+ padding: 6px;
220
+ transition: all 0.15s ease;
221
+ }
222
+
223
+ .btn-action:hover {
224
+ background: #0e7490;
225
+ border-color: #06b6d4;
226
+ color: #ffffff;
227
+ }
228
+
229
+ .btn-action:active {
230
+ transform: scale(0.98);
231
+ }
232
+
233
+ .btn-action.btn-primary {
234
+ background: rgba(6, 182, 212, 0.2);
235
+ border-color: #06b6d4;
236
+ color: #22d3ee;
237
+ }
238
+
239
+ .btn-action.btn-primary:hover {
240
+ background: #06b6d4;
241
+ color: #082f49;
242
+ }
243
+
244
+ /* Terminal Console */
245
+ .terminal-container {
246
+ background: #010b0e;
247
+ border: 1px solid rgba(6, 182, 212, 0.2);
248
+ border-radius: 8px;
249
+ padding: 8px 10px;
250
+ }
251
+
252
+ .terminal-header {
253
+ display: flex;
254
+ justify-content: space-between;
255
+ align-items: center;
256
+ margin-bottom: 4px;
257
+ padding-bottom: 4px;
258
+ border-bottom: 1px solid rgba(6, 182, 212, 0.1);
259
+ }
260
+
261
+ .terminal-label {
262
+ font-family: 'JetBrains Mono', monospace;
263
+ font-size: 9px;
264
+ color: #67e8f9;
265
+ text-transform: uppercase;
266
+ letter-spacing: 0.05em;
267
+ }
268
+
269
+ .terminal-copy {
270
+ background: none;
271
+ border: none;
272
+ color: #22d3ee;
273
+ font-family: 'JetBrains Mono', monospace;
274
+ font-size: 10px;
275
+ cursor: pointer;
276
+ padding: 2px 4px;
277
+ border-radius: 4px;
278
+ }
279
+
280
+ .terminal-copy:hover {
281
+ background: rgba(6, 182, 212, 0.2);
282
+ }
283
+
284
+ .terminal-readout {
285
+ font-family: 'JetBrains Mono', monospace;
286
+ font-size: 11px;
287
+ line-height: 1.4;
288
+ color: #22d3ee;
289
+ min-height: 48px;
290
+ max-height: 120px;
291
+ overflow-y: auto;
292
+ white-space: pre-wrap;
293
+ word-break: break-all;
294
+ }
295
+ </style>
296
+
297
+ <!-- Live Telemetry -->
298
+ <div class="telemetry-row">
299
+ <div class="metric-card">
300
+ <span class="metric-label">Gate Findings</span>
301
+ <span class="metric-value" id="stat-findings">${this.telemetry.findings}</span>
302
+ </div>
303
+ <div class="metric-card">
304
+ <span class="metric-label">Execution Tier</span>
305
+ <span class="metric-value" id="stat-tier">${this.telemetry.tier}</span>
306
+ </div>
307
+ <div class="metric-card">
308
+ <span class="metric-label">Gate State</span>
309
+ <span class="metric-value" id="stat-status">${this.telemetry.status}</span>
310
+ </div>
311
+ </div>
312
+
313
+ <!-- Configured Gate Deck -->
314
+ <div class="gate-deck">
315
+ <div class="gate-header">Deterministic Verification Gates</div>
316
+ <div class="gate-chips">
317
+ <div class="gate-chip"><span class="gate-dot"></span>Syntax &amp; Types</div>
318
+ <div class="gate-chip"><span class="gate-dot"></span>Git Hygiene</div>
319
+ <div class="gate-chip"><span class="gate-dot"></span>Security Deps</div>
320
+ <div class="gate-chip"><span class="gate-dot"></span>SSSS Registry</div>
321
+ </div>
322
+ </div>
323
+
324
+ <!-- Action Buttons Grid (>=44px touch targets) -->
325
+ <div class="actions-grid">
326
+ <button class="btn-action btn-primary" data-cmd="report">REPORT</button>
327
+ <button class="btn-action" data-cmd="snapshot">SNAPSHOT</button>
328
+ <button class="btn-action" data-cmd="gate">RUN GATES</button>
329
+ <button class="btn-action" data-cmd="detect">DETECT GATES</button>
330
+ <button class="btn-action" data-cmd="config">CONFIG</button>
331
+ <button class="btn-action" data-cmd="init">INIT</button>
332
+ </div>
333
+
334
+ <!-- Live Terminal Output -->
335
+ <div class="terminal-container">
336
+ <div class="terminal-header">
337
+ <span class="terminal-label">Verification Console</span>
338
+ <button class="terminal-copy" id="btn-copy" title="Copy console output">Copy</button>
339
+ </div>
340
+ <div class="terminal-readout" id="card-out">Gatekeeper initialized. Ready for code verification.</div>
341
+ </div>
342
+ `;
343
+
344
+ const buttons = root.querySelectorAll('.btn-action');
345
+ buttons.forEach(btn => {
346
+ btn.addEventListener('click', () => {
347
+ const cmd = btn.getAttribute('data-cmd');
348
+ if (cmd) this.execute(cmd, []);
349
+ });
350
+ });
351
+
352
+ const copyBtn = root.querySelector('#btn-copy');
353
+ if (copyBtn) {
354
+ copyBtn.addEventListener('click', () => {
355
+ const out = root.querySelector('#card-out');
356
+ if (out && out.textContent) {
357
+ navigator.clipboard?.writeText(out.textContent);
358
+ copyBtn.textContent = 'Copied!';
359
+ setTimeout(() => { copyBtn.textContent = 'Copy'; }, 1500);
360
+ }
361
+ });
362
+ }
363
+ }
364
+ }
365
+
366
+ if (!customElements.get('tr-code-quality-card')) {
367
+ customElements.define('tr-code-quality-card', CodeQualityCard);
368
+ }