@luanpdd/kit-mcp 1.34.0 → 1.36.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 (118) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +2 -2
  3. package/bin/mcp.js +6 -6
  4. package/bin/ui.js +74 -74
  5. package/gates/ai-prompt-stability.md +120 -120
  6. package/gates/budget-description.md +68 -68
  7. package/gates/confidence.md +29 -29
  8. package/gates/dependency-check.md +33 -33
  9. package/gates/dept-cycle-prevention.md +179 -179
  10. package/gates/golden-signals-coverage.md +133 -133
  11. package/gates/legacy-refactor-safety.md +178 -178
  12. package/gates/multi-tenant-rls-coverage.md +102 -102
  13. package/gates/no-personal-uuid.md +72 -72
  14. package/gates/obs-agents-mcp-supabase.md +86 -86
  15. package/gates/obs-skills-frontmatter.md +76 -76
  16. package/gates/observability-coverage.md +151 -151
  17. package/gates/omm-no-regression.md +83 -83
  18. package/gates/postmortem-template-required.md +127 -127
  19. package/gates/prr-checklist-coverage.md +128 -128
  20. package/gates/regression.md +32 -32
  21. package/gates/release-pipeline-policy.md +132 -132
  22. package/gates/secrets-scan.md +33 -33
  23. package/gates/service-role-not-in-user-facing.md +113 -113
  24. package/gates/skill-must-include.md +71 -71
  25. package/gates/sync-idempotent.md +62 -62
  26. package/gates/verify-phase-goal.md +34 -34
  27. package/kit/agents/designer-ui.md +216 -216
  28. package/kit/agents/workflow-generator.md +537 -0
  29. package/kit/commands/adicionar-backlog.md +1 -1
  30. package/kit/commands/adicionar-fase.md +1 -1
  31. package/kit/commands/adicionar-tarefa.md +1 -1
  32. package/kit/commands/auditar-observabilidade.md +103 -103
  33. package/kit/commands/auditar-toil.md +129 -129
  34. package/kit/commands/caracterizar-prompt.md +195 -195
  35. package/kit/commands/criar-workflow.md +158 -0
  36. package/kit/commands/definir-perfil.md +1 -1
  37. package/kit/commands/definir-slo.md +108 -108
  38. package/kit/commands/fio.md +1 -1
  39. package/kit/commands/golden-signals.md +142 -142
  40. package/kit/commands/instrumentar-fase.md +200 -200
  41. package/kit/commands/investigar-producao.md +162 -162
  42. package/kit/commands/observabilidade.md +118 -118
  43. package/kit/commands/postmortem.md +179 -179
  44. package/kit/commands/prr.md +205 -205
  45. package/kit/commands/publicar-rapido.md +207 -207
  46. package/kit/commands/risk-budget.md +220 -220
  47. package/kit/commands/sre.md +230 -230
  48. package/kit/file-manifest.json +5 -2
  49. package/kit/framework/references/output-style.md +22 -22
  50. package/kit/hooks/post-apply-migration.js +199 -199
  51. package/kit/hooks/sidecar-tool-publisher.js +210 -210
  52. package/kit/skills/_shared-dados-distribuidos/glossary.md +224 -224
  53. package/kit/skills/_shared-legacy/glossary.md +389 -389
  54. package/kit/skills/_shared-multi-tenant/glossary.md +186 -186
  55. package/kit/skills/_shared-observability/glossary.md +396 -396
  56. package/kit/skills/_shared-sre/glossary.md +712 -712
  57. package/kit/skills/_shared-supabase/glossary.md +234 -234
  58. package/kit/skills/blameless-postmortems/SKILL.md +340 -340
  59. package/kit/skills/burn-rate-alerting/SKILL.md +258 -258
  60. package/kit/skills/cascading-failures/SKILL.md +311 -311
  61. package/kit/skills/core-analysis-loop/SKILL.md +352 -352
  62. package/kit/skills/distributed-tracing/SKILL.md +362 -362
  63. package/kit/skills/dynamic-workflow-authoring/SKILL.md +327 -0
  64. package/kit/skills/eliminating-toil/SKILL.md +243 -243
  65. package/kit/skills/event-based-slos/SKILL.md +296 -296
  66. package/kit/skills/four-golden-signals/SKILL.md +314 -314
  67. package/kit/skills/hermetic-builds/SKILL.md +323 -323
  68. package/kit/skills/legacy-monster-methods/SKILL.md +444 -444
  69. package/kit/skills/llm-as-dependency/SKILL.md +436 -436
  70. package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -396
  71. package/kit/skills/observability-driven-development/SKILL.md +315 -315
  72. package/kit/skills/observability-maturity-model/SKILL.md +222 -222
  73. package/kit/skills/opentelemetry-standard/SKILL.md +351 -351
  74. package/kit/skills/production-readiness-review/SKILL.md +305 -305
  75. package/kit/skills/release-engineering/SKILL.md +367 -367
  76. package/kit/skills/retry-strategies/SKILL.md +372 -372
  77. package/kit/skills/sre-risk-management/SKILL.md +221 -221
  78. package/kit/skills/structured-events/SKILL.md +265 -265
  79. package/kit/skills/supabase-cron-queues/SKILL.md +275 -275
  80. package/kit/skills/supabase-database-functions/SKILL.md +332 -332
  81. package/kit/skills/supabase-declarative-schema/SKILL.md +183 -183
  82. package/kit/skills/supabase-pgvector-rag/SKILL.md +253 -253
  83. package/kit/skills/supabase-postgres-style/SKILL.md +138 -138
  84. package/kit/skills/supabase-storage/SKILL.md +234 -234
  85. package/kit/skills/telemetry-pipelines/SKILL.md +259 -259
  86. package/kit/skills/telemetry-sampling/SKILL.md +256 -256
  87. package/kit/skills/ui-anti-padroes-ia/SKILL.md +261 -261
  88. package/kit/skills/ui-contexto-produto/SKILL.md +248 -248
  89. package/kit/skills/ui-cor-estrategia/SKILL.md +213 -213
  90. package/kit/skills/ui-critica-auditoria/SKILL.md +260 -260
  91. package/kit/skills/ui-motion-funcional/SKILL.md +264 -264
  92. package/kit/skills/ui-ritmo-espacial/SKILL.md +259 -259
  93. package/kit/skills/ui-tipografia/SKILL.md +211 -211
  94. package/package.json +1 -1
  95. package/src/cli/index.js +1114 -1114
  96. package/src/cli/render.js +194 -194
  97. package/src/cli/upgrade-check.js +135 -135
  98. package/src/core/error-redaction.js +76 -76
  99. package/src/core/failures.js +153 -153
  100. package/src/core/gate-runner.js +205 -205
  101. package/src/core/gates.js +82 -82
  102. package/src/core/logger.js +170 -170
  103. package/src/core/manifest-verify.js +174 -174
  104. package/src/core/metrics.js +268 -268
  105. package/src/core/notify.js +60 -60
  106. package/src/core/path-safety.js +141 -141
  107. package/src/core/replays.js +120 -120
  108. package/src/core/ui.js +185 -185
  109. package/src/mcp-server/install.js +149 -149
  110. package/src/mcp-server/roots.js +124 -124
  111. package/src/ui/auto-spawn.js +113 -113
  112. package/src/ui/browser.js +78 -78
  113. package/src/ui/client.js +130 -130
  114. package/src/ui/events.js +65 -65
  115. package/src/ui/lockfile.js +191 -191
  116. package/src/ui/port.js +67 -67
  117. package/src/ui/server.js +547 -547
  118. package/src/ui/wrapper.js +129 -129
@@ -1,170 +1,170 @@
1
- // src/core/logger.js — JSONL append-only logger with date-based rotation.
2
- //
3
- // Phase 158 (v1.28): every MCP tool invocation is appended to
4
- // ~/.kit-mcp/logs/kit-mcp-YYYY-MM-DD.log
5
- // as a single JSON line per event. Files are rotated by calendar day; on the
6
- // first write of a new day, old files past the retention horizon are deleted.
7
- //
8
- // Discipline:
9
- // - Async fire-and-forget — must never block the MCP request handler.
10
- // - File-only — never writes to stdout (MCP spec) and stderr only on
11
- // last-resort init failure.
12
- // - Cross-platform — uses os.homedir(), path.join, never POSIX-only ops.
13
- //
14
- // Retention is read from KIT_MCP_LOG_RETENTION_DAYS (integer, default 7).
15
- // Set to 0 to disable rotation/cleanup entirely (keep forever).
16
-
17
- import fs from 'node:fs';
18
- import path from 'node:path';
19
- import os from 'node:os';
20
-
21
- const LOG_DIR = process.env.KIT_MCP_LOG_DIR
22
- || path.join(os.homedir(), '.kit-mcp', 'logs');
23
-
24
- function retentionDays() {
25
- const raw = process.env.KIT_MCP_LOG_RETENTION_DAYS;
26
- if (raw === undefined || raw === '') return 7;
27
- const n = parseInt(raw, 10);
28
- return Number.isFinite(n) && n >= 0 ? n : 7;
29
- }
30
-
31
- function todayStamp(d = new Date()) {
32
- // YYYY-MM-DD in local time. Rotation key — must stay stable within a day.
33
- const y = d.getFullYear();
34
- const m = String(d.getMonth() + 1).padStart(2, '0');
35
- const day = String(d.getDate()).padStart(2, '0');
36
- return `${y}-${m}-${day}`;
37
- }
38
-
39
- export function currentLogPath() {
40
- return path.join(LOG_DIR, `kit-mcp-${todayStamp()}.log`);
41
- }
42
-
43
- export function logDir() {
44
- return LOG_DIR;
45
- }
46
-
47
- let initDone = false;
48
- let initFailed = false;
49
-
50
- function ensureDir() {
51
- if (initDone) return !initFailed;
52
- initDone = true;
53
- try {
54
- fs.mkdirSync(LOG_DIR, { recursive: true });
55
- return true;
56
- } catch (e) {
57
- initFailed = true;
58
- // Last-resort signal to operator; stderr is allowed (stdout would corrupt
59
- // the MCP transport).
60
- try { console.error(`[kit-mcp logger] failed to create ${LOG_DIR}: ${e.message}`); } catch { /* noop */ }
61
- return false;
62
- }
63
- }
64
-
65
- let lastRotationCheck = '';
66
-
67
- function rotateIfNeeded() {
68
- const today = todayStamp();
69
- if (lastRotationCheck === today) return;
70
- lastRotationCheck = today;
71
-
72
- const keep = retentionDays();
73
- if (keep === 0) return; // keep forever
74
-
75
- try {
76
- const entries = fs.readdirSync(LOG_DIR);
77
- const cutoff = new Date();
78
- cutoff.setDate(cutoff.getDate() - keep);
79
- const cutoffStamp = todayStamp(cutoff);
80
- for (const name of entries) {
81
- const m = name.match(/^kit-mcp-(\d{4}-\d{2}-\d{2})\.log$/);
82
- if (!m) continue;
83
- if (m[1] < cutoffStamp) {
84
- try { fs.unlinkSync(path.join(LOG_DIR, name)); } catch { /* swallow */ }
85
- }
86
- }
87
- } catch { /* swallow */ }
88
- }
89
-
90
- // logEvent(event) — append one JSON line. Synchronous write to a file handle
91
- // is cheap (~µs) and avoids losing events if the process exits right after.
92
- // All fields except `ts` are caller-supplied; we add `ts` ISO 8601.
93
- export function logEvent(event) {
94
- if (!ensureDir()) return;
95
- rotateIfNeeded();
96
- const enriched = { ts: new Date().toISOString(), pid: process.pid, ...event };
97
- try {
98
- fs.appendFileSync(currentLogPath(), JSON.stringify(enriched) + '\n', 'utf8');
99
- } catch { /* swallow — logging must never break the caller */ }
100
- }
101
-
102
- // listLogs() — returns absolute paths of available log files, most recent first.
103
- export function listLogs() {
104
- if (!ensureDir()) return [];
105
- try {
106
- return fs.readdirSync(LOG_DIR)
107
- .filter((n) => /^kit-mcp-\d{4}-\d{2}-\d{2}\.log$/.test(n))
108
- .sort((a, b) => b.localeCompare(a))
109
- .map((n) => path.join(LOG_DIR, n));
110
- } catch {
111
- return [];
112
- }
113
- }
114
-
115
- // tailLogs({lines, follow, onLine}) — reads the last N lines across files,
116
- // optionally tailing forever (writes to onLine as new lines arrive). Returns
117
- // a `stop()` function when follow=true; otherwise resolves after initial read.
118
- export function tailLogs({ lines = 50, follow = false, onLine } = {}) {
119
- if (!onLine) throw new Error('tailLogs requires onLine callback');
120
-
121
- const files = listLogs();
122
- // Walk from oldest-relevant forward to collect last N lines. Approximation:
123
- // read latest file, if it has < N lines, also read the previous one, etc.
124
- const collected = [];
125
- for (const file of files) {
126
- try {
127
- const content = fs.readFileSync(file, 'utf8');
128
- const fileLines = content.split('\n').filter(Boolean);
129
- collected.unshift(...fileLines);
130
- } catch { /* skip unreadable */ }
131
- if (collected.length >= lines) break;
132
- }
133
- const tail = collected.slice(-lines);
134
- for (const line of tail) onLine(line);
135
-
136
- if (!follow) return { stop: () => {} };
137
-
138
- // Naive follow: poll the current-day file every 250ms for new bytes.
139
- let offset = 0;
140
- try {
141
- const cur = currentLogPath();
142
- if (fs.existsSync(cur)) offset = fs.statSync(cur).size;
143
- } catch { /* ignore */ }
144
- let stopped = false;
145
- const interval = setInterval(() => {
146
- if (stopped) return;
147
- try {
148
- const cur = currentLogPath();
149
- if (!fs.existsSync(cur)) return;
150
- const stat = fs.statSync(cur);
151
- if (stat.size <= offset) return;
152
- const fd = fs.openSync(cur, 'r');
153
- const buf = Buffer.alloc(stat.size - offset);
154
- fs.readSync(fd, buf, 0, buf.length, offset);
155
- fs.closeSync(fd);
156
- offset = stat.size;
157
- const text = buf.toString('utf8');
158
- for (const line of text.split('\n')) {
159
- if (line) onLine(line);
160
- }
161
- } catch { /* swallow */ }
162
- }, 250);
163
-
164
- return {
165
- stop: () => {
166
- stopped = true;
167
- clearInterval(interval);
168
- },
169
- };
170
- }
1
+ // src/core/logger.js — JSONL append-only logger with date-based rotation.
2
+ //
3
+ // Phase 158 (v1.28): every MCP tool invocation is appended to
4
+ // ~/.kit-mcp/logs/kit-mcp-YYYY-MM-DD.log
5
+ // as a single JSON line per event. Files are rotated by calendar day; on the
6
+ // first write of a new day, old files past the retention horizon are deleted.
7
+ //
8
+ // Discipline:
9
+ // - Async fire-and-forget — must never block the MCP request handler.
10
+ // - File-only — never writes to stdout (MCP spec) and stderr only on
11
+ // last-resort init failure.
12
+ // - Cross-platform — uses os.homedir(), path.join, never POSIX-only ops.
13
+ //
14
+ // Retention is read from KIT_MCP_LOG_RETENTION_DAYS (integer, default 7).
15
+ // Set to 0 to disable rotation/cleanup entirely (keep forever).
16
+
17
+ import fs from 'node:fs';
18
+ import path from 'node:path';
19
+ import os from 'node:os';
20
+
21
+ const LOG_DIR = process.env.KIT_MCP_LOG_DIR
22
+ || path.join(os.homedir(), '.kit-mcp', 'logs');
23
+
24
+ function retentionDays() {
25
+ const raw = process.env.KIT_MCP_LOG_RETENTION_DAYS;
26
+ if (raw === undefined || raw === '') return 7;
27
+ const n = parseInt(raw, 10);
28
+ return Number.isFinite(n) && n >= 0 ? n : 7;
29
+ }
30
+
31
+ function todayStamp(d = new Date()) {
32
+ // YYYY-MM-DD in local time. Rotation key — must stay stable within a day.
33
+ const y = d.getFullYear();
34
+ const m = String(d.getMonth() + 1).padStart(2, '0');
35
+ const day = String(d.getDate()).padStart(2, '0');
36
+ return `${y}-${m}-${day}`;
37
+ }
38
+
39
+ export function currentLogPath() {
40
+ return path.join(LOG_DIR, `kit-mcp-${todayStamp()}.log`);
41
+ }
42
+
43
+ export function logDir() {
44
+ return LOG_DIR;
45
+ }
46
+
47
+ let initDone = false;
48
+ let initFailed = false;
49
+
50
+ function ensureDir() {
51
+ if (initDone) return !initFailed;
52
+ initDone = true;
53
+ try {
54
+ fs.mkdirSync(LOG_DIR, { recursive: true });
55
+ return true;
56
+ } catch (e) {
57
+ initFailed = true;
58
+ // Last-resort signal to operator; stderr is allowed (stdout would corrupt
59
+ // the MCP transport).
60
+ try { console.error(`[kit-mcp logger] failed to create ${LOG_DIR}: ${e.message}`); } catch { /* noop */ }
61
+ return false;
62
+ }
63
+ }
64
+
65
+ let lastRotationCheck = '';
66
+
67
+ function rotateIfNeeded() {
68
+ const today = todayStamp();
69
+ if (lastRotationCheck === today) return;
70
+ lastRotationCheck = today;
71
+
72
+ const keep = retentionDays();
73
+ if (keep === 0) return; // keep forever
74
+
75
+ try {
76
+ const entries = fs.readdirSync(LOG_DIR);
77
+ const cutoff = new Date();
78
+ cutoff.setDate(cutoff.getDate() - keep);
79
+ const cutoffStamp = todayStamp(cutoff);
80
+ for (const name of entries) {
81
+ const m = name.match(/^kit-mcp-(\d{4}-\d{2}-\d{2})\.log$/);
82
+ if (!m) continue;
83
+ if (m[1] < cutoffStamp) {
84
+ try { fs.unlinkSync(path.join(LOG_DIR, name)); } catch { /* swallow */ }
85
+ }
86
+ }
87
+ } catch { /* swallow */ }
88
+ }
89
+
90
+ // logEvent(event) — append one JSON line. Synchronous write to a file handle
91
+ // is cheap (~µs) and avoids losing events if the process exits right after.
92
+ // All fields except `ts` are caller-supplied; we add `ts` ISO 8601.
93
+ export function logEvent(event) {
94
+ if (!ensureDir()) return;
95
+ rotateIfNeeded();
96
+ const enriched = { ts: new Date().toISOString(), pid: process.pid, ...event };
97
+ try {
98
+ fs.appendFileSync(currentLogPath(), JSON.stringify(enriched) + '\n', 'utf8');
99
+ } catch { /* swallow — logging must never break the caller */ }
100
+ }
101
+
102
+ // listLogs() — returns absolute paths of available log files, most recent first.
103
+ export function listLogs() {
104
+ if (!ensureDir()) return [];
105
+ try {
106
+ return fs.readdirSync(LOG_DIR)
107
+ .filter((n) => /^kit-mcp-\d{4}-\d{2}-\d{2}\.log$/.test(n))
108
+ .sort((a, b) => b.localeCompare(a))
109
+ .map((n) => path.join(LOG_DIR, n));
110
+ } catch {
111
+ return [];
112
+ }
113
+ }
114
+
115
+ // tailLogs({lines, follow, onLine}) — reads the last N lines across files,
116
+ // optionally tailing forever (writes to onLine as new lines arrive). Returns
117
+ // a `stop()` function when follow=true; otherwise resolves after initial read.
118
+ export function tailLogs({ lines = 50, follow = false, onLine } = {}) {
119
+ if (!onLine) throw new Error('tailLogs requires onLine callback');
120
+
121
+ const files = listLogs();
122
+ // Walk from oldest-relevant forward to collect last N lines. Approximation:
123
+ // read latest file, if it has < N lines, also read the previous one, etc.
124
+ const collected = [];
125
+ for (const file of files) {
126
+ try {
127
+ const content = fs.readFileSync(file, 'utf8');
128
+ const fileLines = content.split('\n').filter(Boolean);
129
+ collected.unshift(...fileLines);
130
+ } catch { /* skip unreadable */ }
131
+ if (collected.length >= lines) break;
132
+ }
133
+ const tail = collected.slice(-lines);
134
+ for (const line of tail) onLine(line);
135
+
136
+ if (!follow) return { stop: () => {} };
137
+
138
+ // Naive follow: poll the current-day file every 250ms for new bytes.
139
+ let offset = 0;
140
+ try {
141
+ const cur = currentLogPath();
142
+ if (fs.existsSync(cur)) offset = fs.statSync(cur).size;
143
+ } catch { /* ignore */ }
144
+ let stopped = false;
145
+ const interval = setInterval(() => {
146
+ if (stopped) return;
147
+ try {
148
+ const cur = currentLogPath();
149
+ if (!fs.existsSync(cur)) return;
150
+ const stat = fs.statSync(cur);
151
+ if (stat.size <= offset) return;
152
+ const fd = fs.openSync(cur, 'r');
153
+ const buf = Buffer.alloc(stat.size - offset);
154
+ fs.readSync(fd, buf, 0, buf.length, offset);
155
+ fs.closeSync(fd);
156
+ offset = stat.size;
157
+ const text = buf.toString('utf8');
158
+ for (const line of text.split('\n')) {
159
+ if (line) onLine(line);
160
+ }
161
+ } catch { /* swallow */ }
162
+ }, 250);
163
+
164
+ return {
165
+ stop: () => {
166
+ stopped = true;
167
+ clearInterval(interval);
168
+ },
169
+ };
170
+ }