@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,174 +1,174 @@
1
- // SEC-14-05: verify kit/file-manifest.json against actual file contents.
2
- // Called by syncTo() in install path, before any write — refuses to project
3
- // a tampered kit. Opt-out via KIT_MCP_SKIP_MANIFEST_CHECK=1 (warn on stderr).
4
- //
5
- // Manifest format (kit/file-manifest.json):
6
- // { version, timestamp, files: { "<rel-to-kitRoot>": "<sha256-hex>", ... } }
7
- //
8
- // Returns:
9
- // { ok: true } when all listed files exist + match.
10
- // { ok: true, skipped: true } when KIT_MCP_SKIP_MANIFEST_CHECK=1.
11
- // { ok: false, reason, mismatches, missing } otherwise.
12
-
13
- import path from 'node:path';
14
- import fs from 'node:fs/promises';
15
- import crypto from 'node:crypto';
16
-
17
- // PERF-17-01: parallelize SHA256 hashing in batches of 16. Same pattern
18
- // as Phase 88.01 sync.js. Hardcoded — env override is overengineering
19
- // for verifyManifest (single hot path, not user-facing latency budget).
20
- const BATCH_SIZE = 16;
21
-
22
- // PERF-17-01: in-memory cache for verifyManifest. Same pattern as kit.js
23
- // listKit cache (PERF-01). Watch triggers (file save → re-sync) call this
24
- // back-to-back; the 2nd+ call within TTL hits cache and returns <5ms.
25
- //
26
- // Caching rules:
27
- // - Only cache ok=true results. mismatches/missing → recompute every call
28
- // so devs see fixes immediately (don't punish them for the slow path).
29
- // - Bypass via KIT_MCP_VERIFY_NO_CACHE=1 (test isolation + emergency dev escape).
30
- // - Cache key is kitRoot — different roots are independent entries.
31
- const VERIFY_CACHE_TTL_MS = 30_000;
32
- const verifyManifestCache = new Map(); // kitRoot -> { value, ts }
33
- const NO_CACHE_ENV = 'KIT_MCP_VERIFY_NO_CACHE';
34
-
35
- /**
36
- * Test/emergency helper — clears the cache. Exported for unit tests.
37
- * Production code should never need this; use the env var instead.
38
- */
39
- export function clearVerifyManifestCache() { verifyManifestCache.clear(); }
40
-
41
- const SKIP_ENV = 'KIT_MCP_SKIP_MANIFEST_CHECK';
42
-
43
- /**
44
- * SEC-14-05: verify kit/file-manifest.json against actual file contents.
45
- * PERF-17-01: hashes in Promise.all batches of 16 (was sequential pre-v1.17).
46
- * Called by syncTo() in install path before any write — refuses to project a tampered kit.
47
- * @param {string} kitRoot - absolute path to kit/ directory.
48
- * @returns {Promise<{ok: boolean, skipped?: boolean, reason?: string, mismatches?: Array, missing?: string[]}>}
49
- */
50
- export async function verifyManifest(kitRoot) {
51
- if (process.env[SKIP_ENV] === '1') {
52
- process.stderr.write(
53
- '[kit-mcp] WARNING: ' + SKIP_ENV + '=1 set — skipping kit/file-manifest.json verification (dev mode).\n'
54
- );
55
- return { ok: true, skipped: true };
56
- }
57
-
58
- // PERF-17-01: cache hit — repeated calls within TTL skip the I/O + hashing.
59
- // Bypass via KIT_MCP_VERIFY_NO_CACHE=1 (tests + dev emergency escape).
60
- if (process.env[NO_CACHE_ENV] !== '1') {
61
- const cached = verifyManifestCache.get(kitRoot);
62
- if (cached && Date.now() - cached.ts < VERIFY_CACHE_TTL_MS) {
63
- return cached.value;
64
- }
65
- }
66
-
67
- const manifestPath = path.join(kitRoot, 'file-manifest.json');
68
- let manifest;
69
- try {
70
- const raw = await fs.readFile(manifestPath, 'utf8');
71
- manifest = JSON.parse(raw);
72
- } catch (e) {
73
- return {
74
- ok: false,
75
- reason: 'kit manifest unreadable at ' + manifestPath + ': ' + e.message,
76
- mismatches: [],
77
- missing: [],
78
- };
79
- }
80
-
81
- if (!manifest.files || typeof manifest.files !== 'object') {
82
- return {
83
- ok: false,
84
- reason: "kit manifest malformed at " + manifestPath + ": missing 'files' object",
85
- mismatches: [],
86
- missing: [],
87
- };
88
- }
89
-
90
- const mismatches = [];
91
- const missing = [];
92
-
93
- const entries = Object.entries(manifest.files);
94
-
95
- // Per-file check — returns { rel, status: 'ok'|'mismatch'|'missing', expected?, actual? }.
96
- // Pure function (no side effects on shared arrays) so Promise.all in batches
97
- // is safe — caller aggregates after each batch resolves.
98
- const checkOne = async ([rel, expected]) => {
99
- const abs = path.join(kitRoot, rel);
100
- let buf;
101
- try {
102
- buf = await fs.readFile(abs);
103
- } catch {
104
- return { rel, status: 'missing' };
105
- }
106
- // Normalize CRLF→LF before hashing so manifest is platform-stable.
107
- // git checkout converts EOL on Windows but Linux CI checks out LF —
108
- // hashing raw bytes would diverge across platforms. (PRESERVED from v1.15)
109
- const normalized = Buffer.from(buf.toString('binary').replace(/\r\n/g, '\n'), 'binary');
110
- const actual = crypto.createHash('sha256').update(normalized).digest('hex');
111
- if (actual !== expected) {
112
- return { rel, status: 'mismatch', expected, actual };
113
- }
114
- return { rel, status: 'ok' };
115
- };
116
-
117
- // Sequential batches — within a batch, Promise.all parallelizes hashing;
118
- // between batches, await bounds max-in-flight at BATCH_SIZE (defensive
119
- // against fd ulimit on large kits). Order of completion within a batch
120
- // doesn't matter — aggregator below is order-independent.
121
- for (let i = 0; i < entries.length; i += BATCH_SIZE) {
122
- const slice = entries.slice(i, i + BATCH_SIZE);
123
- const results = await Promise.all(slice.map(checkOne));
124
- for (const r of results) {
125
- if (r.status === 'mismatch') {
126
- mismatches.push({ path: r.rel, expected: r.expected.slice(0, 16), actual: r.actual.slice(0, 16) });
127
- } else if (r.status === 'missing') {
128
- missing.push(r.rel);
129
- }
130
- }
131
- }
132
-
133
- if (mismatches.length === 0 && missing.length === 0) {
134
- const result = { ok: true };
135
- // PERF-17-01: cache only ok=true. Mismatch/missing always recompute
136
- // so dev fixing a tampered file sees the next sync recover immediately.
137
- if (process.env[NO_CACHE_ENV] !== '1') {
138
- verifyManifestCache.set(kitRoot, { value: result, ts: Date.now() });
139
- }
140
- return result;
141
- }
142
-
143
- // Build a concise reason — first 3 mismatches, plus counts.
144
- const sample = mismatches
145
- .slice(0, 3)
146
- .map((m) => m.path + ' (expected ' + m.expected + ', got ' + m.actual + ')')
147
- .join('; ');
148
- const missingSample = missing.slice(0, 3).join(', ');
149
- const reasonParts = [];
150
- if (mismatches.length > 0) {
151
- reasonParts.push(
152
- mismatches.length +
153
- ' file(s) tampered: ' +
154
- sample +
155
- (mismatches.length > 3 ? ', +' + (mismatches.length - 3) + ' more' : '')
156
- );
157
- }
158
- if (missing.length > 0) {
159
- reasonParts.push(
160
- missing.length +
161
- ' file(s) missing: ' +
162
- missingSample +
163
- (missing.length > 3 ? ', +' + (missing.length - 3) + ' more' : '')
164
- );
165
- }
166
- reasonParts.push('set ' + SKIP_ENV + '=1 to bypass (dev only)');
167
-
168
- return {
169
- ok: false,
170
- reason: 'kit manifest mismatch — ' + reasonParts.join('; '),
171
- mismatches,
172
- missing,
173
- };
174
- }
1
+ // SEC-14-05: verify kit/file-manifest.json against actual file contents.
2
+ // Called by syncTo() in install path, before any write — refuses to project
3
+ // a tampered kit. Opt-out via KIT_MCP_SKIP_MANIFEST_CHECK=1 (warn on stderr).
4
+ //
5
+ // Manifest format (kit/file-manifest.json):
6
+ // { version, timestamp, files: { "<rel-to-kitRoot>": "<sha256-hex>", ... } }
7
+ //
8
+ // Returns:
9
+ // { ok: true } when all listed files exist + match.
10
+ // { ok: true, skipped: true } when KIT_MCP_SKIP_MANIFEST_CHECK=1.
11
+ // { ok: false, reason, mismatches, missing } otherwise.
12
+
13
+ import path from 'node:path';
14
+ import fs from 'node:fs/promises';
15
+ import crypto from 'node:crypto';
16
+
17
+ // PERF-17-01: parallelize SHA256 hashing in batches of 16. Same pattern
18
+ // as Phase 88.01 sync.js. Hardcoded — env override is overengineering
19
+ // for verifyManifest (single hot path, not user-facing latency budget).
20
+ const BATCH_SIZE = 16;
21
+
22
+ // PERF-17-01: in-memory cache for verifyManifest. Same pattern as kit.js
23
+ // listKit cache (PERF-01). Watch triggers (file save → re-sync) call this
24
+ // back-to-back; the 2nd+ call within TTL hits cache and returns <5ms.
25
+ //
26
+ // Caching rules:
27
+ // - Only cache ok=true results. mismatches/missing → recompute every call
28
+ // so devs see fixes immediately (don't punish them for the slow path).
29
+ // - Bypass via KIT_MCP_VERIFY_NO_CACHE=1 (test isolation + emergency dev escape).
30
+ // - Cache key is kitRoot — different roots are independent entries.
31
+ const VERIFY_CACHE_TTL_MS = 30_000;
32
+ const verifyManifestCache = new Map(); // kitRoot -> { value, ts }
33
+ const NO_CACHE_ENV = 'KIT_MCP_VERIFY_NO_CACHE';
34
+
35
+ /**
36
+ * Test/emergency helper — clears the cache. Exported for unit tests.
37
+ * Production code should never need this; use the env var instead.
38
+ */
39
+ export function clearVerifyManifestCache() { verifyManifestCache.clear(); }
40
+
41
+ const SKIP_ENV = 'KIT_MCP_SKIP_MANIFEST_CHECK';
42
+
43
+ /**
44
+ * SEC-14-05: verify kit/file-manifest.json against actual file contents.
45
+ * PERF-17-01: hashes in Promise.all batches of 16 (was sequential pre-v1.17).
46
+ * Called by syncTo() in install path before any write — refuses to project a tampered kit.
47
+ * @param {string} kitRoot - absolute path to kit/ directory.
48
+ * @returns {Promise<{ok: boolean, skipped?: boolean, reason?: string, mismatches?: Array, missing?: string[]}>}
49
+ */
50
+ export async function verifyManifest(kitRoot) {
51
+ if (process.env[SKIP_ENV] === '1') {
52
+ process.stderr.write(
53
+ '[kit-mcp] WARNING: ' + SKIP_ENV + '=1 set — skipping kit/file-manifest.json verification (dev mode).\n'
54
+ );
55
+ return { ok: true, skipped: true };
56
+ }
57
+
58
+ // PERF-17-01: cache hit — repeated calls within TTL skip the I/O + hashing.
59
+ // Bypass via KIT_MCP_VERIFY_NO_CACHE=1 (tests + dev emergency escape).
60
+ if (process.env[NO_CACHE_ENV] !== '1') {
61
+ const cached = verifyManifestCache.get(kitRoot);
62
+ if (cached && Date.now() - cached.ts < VERIFY_CACHE_TTL_MS) {
63
+ return cached.value;
64
+ }
65
+ }
66
+
67
+ const manifestPath = path.join(kitRoot, 'file-manifest.json');
68
+ let manifest;
69
+ try {
70
+ const raw = await fs.readFile(manifestPath, 'utf8');
71
+ manifest = JSON.parse(raw);
72
+ } catch (e) {
73
+ return {
74
+ ok: false,
75
+ reason: 'kit manifest unreadable at ' + manifestPath + ': ' + e.message,
76
+ mismatches: [],
77
+ missing: [],
78
+ };
79
+ }
80
+
81
+ if (!manifest.files || typeof manifest.files !== 'object') {
82
+ return {
83
+ ok: false,
84
+ reason: "kit manifest malformed at " + manifestPath + ": missing 'files' object",
85
+ mismatches: [],
86
+ missing: [],
87
+ };
88
+ }
89
+
90
+ const mismatches = [];
91
+ const missing = [];
92
+
93
+ const entries = Object.entries(manifest.files);
94
+
95
+ // Per-file check — returns { rel, status: 'ok'|'mismatch'|'missing', expected?, actual? }.
96
+ // Pure function (no side effects on shared arrays) so Promise.all in batches
97
+ // is safe — caller aggregates after each batch resolves.
98
+ const checkOne = async ([rel, expected]) => {
99
+ const abs = path.join(kitRoot, rel);
100
+ let buf;
101
+ try {
102
+ buf = await fs.readFile(abs);
103
+ } catch {
104
+ return { rel, status: 'missing' };
105
+ }
106
+ // Normalize CRLF→LF before hashing so manifest is platform-stable.
107
+ // git checkout converts EOL on Windows but Linux CI checks out LF —
108
+ // hashing raw bytes would diverge across platforms. (PRESERVED from v1.15)
109
+ const normalized = Buffer.from(buf.toString('binary').replace(/\r\n/g, '\n'), 'binary');
110
+ const actual = crypto.createHash('sha256').update(normalized).digest('hex');
111
+ if (actual !== expected) {
112
+ return { rel, status: 'mismatch', expected, actual };
113
+ }
114
+ return { rel, status: 'ok' };
115
+ };
116
+
117
+ // Sequential batches — within a batch, Promise.all parallelizes hashing;
118
+ // between batches, await bounds max-in-flight at BATCH_SIZE (defensive
119
+ // against fd ulimit on large kits). Order of completion within a batch
120
+ // doesn't matter — aggregator below is order-independent.
121
+ for (let i = 0; i < entries.length; i += BATCH_SIZE) {
122
+ const slice = entries.slice(i, i + BATCH_SIZE);
123
+ const results = await Promise.all(slice.map(checkOne));
124
+ for (const r of results) {
125
+ if (r.status === 'mismatch') {
126
+ mismatches.push({ path: r.rel, expected: r.expected.slice(0, 16), actual: r.actual.slice(0, 16) });
127
+ } else if (r.status === 'missing') {
128
+ missing.push(r.rel);
129
+ }
130
+ }
131
+ }
132
+
133
+ if (mismatches.length === 0 && missing.length === 0) {
134
+ const result = { ok: true };
135
+ // PERF-17-01: cache only ok=true. Mismatch/missing always recompute
136
+ // so dev fixing a tampered file sees the next sync recover immediately.
137
+ if (process.env[NO_CACHE_ENV] !== '1') {
138
+ verifyManifestCache.set(kitRoot, { value: result, ts: Date.now() });
139
+ }
140
+ return result;
141
+ }
142
+
143
+ // Build a concise reason — first 3 mismatches, plus counts.
144
+ const sample = mismatches
145
+ .slice(0, 3)
146
+ .map((m) => m.path + ' (expected ' + m.expected + ', got ' + m.actual + ')')
147
+ .join('; ');
148
+ const missingSample = missing.slice(0, 3).join(', ');
149
+ const reasonParts = [];
150
+ if (mismatches.length > 0) {
151
+ reasonParts.push(
152
+ mismatches.length +
153
+ ' file(s) tampered: ' +
154
+ sample +
155
+ (mismatches.length > 3 ? ', +' + (mismatches.length - 3) + ' more' : '')
156
+ );
157
+ }
158
+ if (missing.length > 0) {
159
+ reasonParts.push(
160
+ missing.length +
161
+ ' file(s) missing: ' +
162
+ missingSample +
163
+ (missing.length > 3 ? ', +' + (missing.length - 3) + ' more' : '')
164
+ );
165
+ }
166
+ reasonParts.push('set ' + SKIP_ENV + '=1 to bypass (dev only)');
167
+
168
+ return {
169
+ ok: false,
170
+ reason: 'kit manifest mismatch — ' + reasonParts.join('; '),
171
+ mismatches,
172
+ missing,
173
+ };
174
+ }