mockpit 2.0.0 → 3.1.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 (90) hide show
  1. package/README.md +59 -223
  2. package/bin/demoData.js +2 -2
  3. package/bin/initDesign.js +17 -22
  4. package/bin/mockpit.js +626 -216
  5. package/bin/poster.js +434 -0
  6. package/dist/mcp/server.js +127 -29
  7. package/dist/server/answerAdditions.d.ts +7 -0
  8. package/dist/server/answerAdditions.js +76 -0
  9. package/dist/server/apiViews.d.ts +627 -385
  10. package/dist/server/apiViews.js +198 -81
  11. package/dist/server/app.d.ts +7 -2
  12. package/dist/server/app.js +3514 -984
  13. package/dist/server/appIcon.js +15 -5
  14. package/dist/server/appIconPng.js +3 -3
  15. package/dist/server/askNudges.js +1 -1
  16. package/dist/server/cdnInline.d.ts +8 -0
  17. package/dist/server/cdnInline.js +640 -0
  18. package/dist/server/codeWorker.js +2 -2
  19. package/dist/server/contrast.d.ts +4 -0
  20. package/dist/server/contrast.js +157 -0
  21. package/dist/server/decisionList.d.ts +48 -0
  22. package/dist/server/decisionList.js +340 -0
  23. package/dist/server/decisions.d.ts +4 -4
  24. package/dist/server/decisions.js +9 -9
  25. package/dist/server/designGuide.d.ts +14 -7
  26. package/dist/server/designGuide.js +314 -88
  27. package/dist/server/embeds.d.ts +3 -1
  28. package/dist/server/embeds.js +31 -6
  29. package/dist/server/eventLog.d.ts +2 -2
  30. package/dist/server/eventLog.js +11 -11
  31. package/dist/server/events.d.ts +15 -6
  32. package/dist/server/feedbackBatch.d.ts +39 -13
  33. package/dist/server/feedbackBatch.js +129 -47
  34. package/dist/server/fills.d.ts +4 -0
  35. package/dist/server/fills.js +55 -1
  36. package/dist/server/guidance.d.ts +1 -1
  37. package/dist/server/guidance.js +2 -2
  38. package/dist/server/handoff.d.ts +4 -1
  39. package/dist/server/handoff.js +8 -2
  40. package/dist/server/icons.js +1 -1
  41. package/dist/server/index.js +39 -10
  42. package/dist/server/jump.d.ts +21 -0
  43. package/dist/server/jump.js +175 -0
  44. package/dist/server/kits.d.ts +2 -2
  45. package/dist/server/kits.js +54 -1
  46. package/dist/server/knobs.d.ts +3 -3
  47. package/dist/server/knobs.js +6 -6
  48. package/dist/server/mcpHttp.d.ts +7 -1
  49. package/dist/server/mcpHttp.js +29 -12
  50. package/dist/server/mcpSpec.d.ts +27 -27
  51. package/dist/server/mcpSpec.js +196 -56
  52. package/dist/server/parts.js +9 -1
  53. package/dist/server/run.d.ts +1 -1
  54. package/dist/server/run.js +47 -17
  55. package/dist/server/runApi.d.ts +3 -3
  56. package/dist/server/runApi.js +34 -21
  57. package/dist/server/sqlStore.d.ts +148 -103
  58. package/dist/server/sqlStore.js +1052 -181
  59. package/dist/server/standings.d.ts +25 -0
  60. package/dist/server/standings.js +113 -0
  61. package/dist/server/surfacePage.d.ts +8 -9
  62. package/dist/server/surfacePage.js +423 -100
  63. package/dist/server/system.d.ts +234 -0
  64. package/dist/server/system.js +1508 -0
  65. package/dist/server/systemChecks.d.ts +15 -0
  66. package/dist/server/systemChecks.js +224 -0
  67. package/dist/server/systemSpecimen.d.ts +2 -0
  68. package/dist/server/systemSpecimen.js +49 -0
  69. package/dist/server/themes.d.ts +9 -7
  70. package/dist/server/themes.js +43 -90
  71. package/dist/server/types.d.ts +266 -93
  72. package/dist/server/types.js +76 -79
  73. package/extensions/mockpit.js +89 -72
  74. package/guide/AGENT_SETUP.md +15 -1
  75. package/guide/packs/design-craft.md +2 -3
  76. package/guide/packs/foundations.md +35 -0
  77. package/guide/topics/asks.md +108 -63
  78. package/guide/topics/feedback.md +129 -120
  79. package/guide/topics/html.md +18 -25
  80. package/guide/topics/http.md +43 -41
  81. package/guide/topics/knobs.md +7 -10
  82. package/guide/topics/scripts.md +22 -33
  83. package/guide/topics/surfaces.md +39 -48
  84. package/guide/topics/system.md +157 -0
  85. package/opencode/mockpit.js +120 -0
  86. package/opencode/package.json +8 -0
  87. package/package.json +15 -14
  88. package/skills/launch-video/SKILL.md +11 -11
  89. package/skills/mockpit/SKILL.md +33 -26
  90. package/viewer/dist/index.html +10 -9
@@ -0,0 +1,7 @@
1
+ import type { AnswerAddition } from "./types.ts";
2
+ export declare const MAX_ANSWER_STYLE = 20000;
3
+ export declare const MAX_ANSWER_FILL = 200000;
4
+ export declare const MAX_ANSWER_ADDITIONS = 200;
5
+ export declare function checkAnswerStyle(css: string): string | null;
6
+ export declare function checkAnswerFill(html: string): string | null;
7
+ export declare function withAnswerAdditions(html: string, additions: AnswerAddition[]): string;
@@ -0,0 +1,76 @@
1
+ // What an answer brings so it can draw itself: a little style, or a new fill of one
2
+ // part. It lives on the design, so a version the user approved is never rewritten,
3
+ // and it only takes effect while its value is chosen. Values are new and never
4
+ // redefined, so everything the user has already seen keeps looking the same.
5
+ //
6
+ // String-only and runtime-agnostic, like fills.ts.
7
+ import { addFill, cssString } from "./fills.js";
8
+ export const MAX_ANSWER_STYLE = 20_000;
9
+ export const MAX_ANSWER_FILL = 200_000;
10
+ export const MAX_ANSWER_ADDITIONS = 200;
11
+ // Allowed inside a rule. The rest either escape the value's scope or do nothing there.
12
+ const NESTED_AT_RULES = new Set(["media", "supports", "container"]);
13
+ // The scope is only as good as the braces: a stray `}` would end it and put the rest
14
+ // of the style on every render, breaking the promise above.
15
+ export function checkAnswerStyle(css) {
16
+ if (css.length > MAX_ANSWER_STYLE)
17
+ return `style is over ${MAX_ANSWER_STYLE} characters`;
18
+ if (/<\/style/i.test(css))
19
+ return "style can't contain </style";
20
+ let depth = 0;
21
+ for (let i = 0; i < css.length; i++) {
22
+ const c = css[i];
23
+ if (c === "/" && css[i + 1] === "*") {
24
+ const end = css.indexOf("*/", i + 2);
25
+ if (end < 0)
26
+ return "style has an unclosed comment";
27
+ i = end + 1;
28
+ }
29
+ else if (c === '"' || c === "'") {
30
+ let j = i + 1;
31
+ while (j < css.length && css[j] !== c)
32
+ j += css[j] === "\\" ? 2 : 1;
33
+ if (j >= css.length)
34
+ return "style has an unclosed string";
35
+ i = j;
36
+ }
37
+ else if (c === "{") {
38
+ depth++;
39
+ }
40
+ else if (c === "}") {
41
+ if (--depth < 0)
42
+ return "style has a } with no {";
43
+ }
44
+ else if (c === "@") {
45
+ const name = /^[a-z-]+/i.exec(css.slice(i + 1, i + 40))?.[0].toLowerCase();
46
+ if (!name || !NESTED_AT_RULES.has(name)) {
47
+ return `style can't use @${name ?? ""}: only @media, @supports and @container`;
48
+ }
49
+ }
50
+ }
51
+ return depth === 0 ? null : "style has a { with no }";
52
+ }
53
+ // A fill sits in the document even while it isn't chosen, so anything that acts from
54
+ // there (a script, a stylesheet) would change the page for every other answer too.
55
+ export function checkAnswerFill(html) {
56
+ if (html.length > MAX_ANSWER_FILL)
57
+ return `fill is over ${MAX_ANSWER_FILL} characters`;
58
+ const acting = /<(script|style|link)\b/i.exec(html)?.[1].toLowerCase();
59
+ if (acting) {
60
+ return `a fill can't hold <${acting}>: it would act while unchosen. Use style, or html for a whole page`;
61
+ }
62
+ return null;
63
+ }
64
+ const valueSelector = (a) => `html[data-k-${a.knob.replace(/\./g, "-")}=${cssString(a.value)}]`;
65
+ // A render of any version: its html, with what answers brought laid over it.
66
+ export function withAnswerAdditions(html, additions) {
67
+ if (additions.length === 0)
68
+ return html;
69
+ let out = html;
70
+ for (const a of additions) {
71
+ if (a.fill !== undefined)
72
+ out = addFill(out, a.knob, a.value, a.fill);
73
+ }
74
+ const css = additions.flatMap((a) => a.style === undefined ? [] : [`${valueSelector(a)}{${a.style}}`]);
75
+ return css.length ? `${out}\n<style>${css.join("\n")}</style>` : out;
76
+ }