@warlock.js/grimoire 5.58.0 → 5.59.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 (71) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/esm/apps/check-apps.mjs +11 -5
  3. package/esm/apps/check-apps.mjs.map +1 -1
  4. package/esm/book/build.d.mts.map +1 -1
  5. package/esm/book/build.mjs.map +1 -1
  6. package/esm/bookmap/build.d.mts.map +1 -1
  7. package/esm/bookmap/build.mjs +5 -3
  8. package/esm/bookmap/build.mjs.map +1 -1
  9. package/esm/bookmap/steps.mjs +34 -3
  10. package/esm/bookmap/steps.mjs.map +1 -1
  11. package/esm/contracts/adapter.d.mts +22 -1
  12. package/esm/contracts/adapter.d.mts.map +1 -1
  13. package/esm/contracts/scry.d.mts +26 -6
  14. package/esm/contracts/scry.d.mts.map +1 -1
  15. package/esm/contracts/snapshot.d.mts +3 -1
  16. package/esm/contracts/snapshot.d.mts.map +1 -1
  17. package/esm/devtools/data.mjs +23 -3
  18. package/esm/devtools/data.mjs.map +1 -1
  19. package/esm/devtools/feature-map.mjs +149 -0
  20. package/esm/devtools/feature-map.mjs.map +1 -0
  21. package/esm/devtools/index.d.mts +2 -2
  22. package/esm/devtools/index.mjs +30 -9
  23. package/esm/devtools/index.mjs.map +1 -1
  24. package/esm/devtools/product-map.d.mts.map +1 -1
  25. package/esm/devtools/product-map.mjs +82 -7
  26. package/esm/devtools/product-map.mjs.map +1 -1
  27. package/esm/devtools/site.d.mts +43 -1
  28. package/esm/devtools/site.d.mts.map +1 -1
  29. package/esm/devtools/site.mjs +111 -15
  30. package/esm/devtools/site.mjs.map +1 -1
  31. package/esm/devtools/snapshot-source.mjs +15 -2
  32. package/esm/devtools/snapshot-source.mjs.map +1 -1
  33. package/esm/index.d.mts +3 -3
  34. package/esm/ownership/index.d.mts.map +1 -1
  35. package/esm/ownership/index.mjs +60 -1
  36. package/esm/ownership/index.mjs.map +1 -1
  37. package/esm/scry/compact.mjs +2 -1
  38. package/esm/scry/compact.mjs.map +1 -1
  39. package/esm/scry/format.d.mts.map +1 -1
  40. package/esm/scry/format.mjs +12 -1
  41. package/esm/scry/format.mjs.map +1 -1
  42. package/esm/scry/query.d.mts.map +1 -1
  43. package/esm/scry/query.mjs +147 -23
  44. package/esm/scry/query.mjs.map +1 -1
  45. package/esm/test-results/index.d.mts.map +1 -1
  46. package/esm/test-results/index.mjs.map +1 -1
  47. package/esm/warlock/actions.mjs +15 -7
  48. package/esm/warlock/actions.mjs.map +1 -1
  49. package/esm/warlock/adapter.d.mts.map +1 -1
  50. package/esm/warlock/adapter.mjs +36 -2
  51. package/esm/warlock/adapter.mjs.map +1 -1
  52. package/esm/warlock/commands.mjs +7 -2
  53. package/esm/warlock/commands.mjs.map +1 -1
  54. package/esm/warlock/logo.mjs +12 -0
  55. package/esm/warlock/logo.mjs.map +1 -0
  56. package/esm/warlock/mcp-tools.mjs +6 -6
  57. package/esm/warlock/mcp-tools.mjs.map +1 -1
  58. package/esm/workspace/cache.mjs +194 -0
  59. package/esm/workspace/cache.mjs.map +1 -0
  60. package/esm/workspace/index.d.mts.map +1 -1
  61. package/esm/workspace/index.mjs +3 -1
  62. package/esm/workspace/index.mjs.map +1 -1
  63. package/llms-full.txt +32 -9
  64. package/package.json +3 -3
  65. package/skills/record-a-change/SKILL.md +2 -0
  66. package/skills/use-the-grimoire/SKILL.md +30 -9
  67. package/ui/grimoire-static.js +57 -6
  68. package/ui/grimoire-view.js +1289 -310
  69. package/ui/grimoire.css +583 -2
  70. package/ui/product-map.css +157 -8
  71. package/ui/product-map.js +507 -59
@@ -28,26 +28,75 @@ function grimoireStaticApi(data) {
28
28
  const text = (params.get("q") ?? "").trim().toLowerCase();
29
29
  const limit = Number(params.get("limit")) || 20;
30
30
  const hits = [];
31
+ const wordsOf = (value) =>
32
+ value
33
+ .toLowerCase()
34
+ .split(/[^a-z0-9]+/)
35
+ .filter(Boolean);
36
+ const tokens = wordsOf(text);
31
37
  for (const item of data.search) {
32
38
  const id = item.id.toLowerCase();
33
39
  const detail = (item.detail ?? "").toLowerCase();
34
- const score =
40
+ const written = item.type === "feature" || item.type === "flow";
41
+ const body = written && item.text ? wordsOf(item.text) : [];
42
+ // Written text matches whole words (a short token must equal a word), so "5" finds AC-5 and not AC-15.
43
+ const inBody =
44
+ tokens.length > 0 &&
45
+ body.length > 0 &&
46
+ tokens.every((token) =>
47
+ body.some((word) => (token.length >= 3 ? word.startsWith(token) : word === token)),
48
+ );
49
+ let score =
35
50
  id === text
36
51
  ? 4
37
52
  : id.startsWith(text)
38
53
  ? 3
39
54
  : id.includes(text)
40
55
  ? 2
41
- : detail.includes(text)
56
+ : detail.includes(text) || inBody
42
57
  ? 1
43
58
  : 0;
44
- if (text && score) hits.push({ ...item, score });
59
+ // Written content ranks above files and exports of the same match.
60
+ if (text && score && written) score += 2;
61
+ if (text && score) hits.push({ ...item, text: undefined, score });
45
62
  }
46
63
  hits.sort((left, right) => right.score - left.score || left.id.localeCompare(right.id));
64
+ // Features and flows keep a share of the limit, so files never push them out; the list is grouped by type.
65
+ const order = [
66
+ "feature",
67
+ "flow",
68
+ "block",
69
+ "page",
70
+ "screen",
71
+ "route",
72
+ "mail",
73
+ "job",
74
+ "file",
75
+ "export",
76
+ "task",
77
+ ];
78
+ const writtenHits = hits
79
+ .filter((hit) => hit.type === "feature" || hit.type === "flow")
80
+ .slice(0, Math.max(1, Math.ceil(limit * 0.75)));
81
+ const chosen = new Set(writtenHits);
82
+ for (const hit of hits) {
83
+ if (chosen.size >= limit) break;
84
+ chosen.add(hit);
85
+ }
86
+ const counts = {};
87
+ for (const hit of hits) counts[hit.type] = (counts[hit.type] ?? 0) + 1;
47
88
  return {
48
89
  type: "search",
49
90
  text,
50
- hits: hits.slice(0, limit),
91
+ counts,
92
+ hits: [...chosen]
93
+ .sort(
94
+ (left, right) =>
95
+ order.indexOf(left.type) - order.indexOf(right.type) ||
96
+ right.score - left.score ||
97
+ left.id.localeCompare(right.id),
98
+ )
99
+ .map(({ text: _text, ...hit }) => hit),
51
100
  routes: data.routes.summary?.routes ?? "cached",
52
101
  notes: [],
53
102
  };
@@ -80,8 +129,10 @@ function grimoireStaticContext(data, root, rerender) {
80
129
  if (value == null) continue;
81
130
  if (key === "class") node.setAttribute("class", value);
82
131
  else if (key === "text") node.textContent = value;
83
- else if (key.startsWith("on")) node.addEventListener(key.slice(2), value);
84
- else node.setAttribute(key, value);
132
+ else if (/^on[a-z]+$/i.test(key)) {
133
+ // Only a real function becomes a listener; a string `on*` attribute is never set (it would be script).
134
+ if (typeof value === "function") node.addEventListener(key.slice(2).toLowerCase(), value);
135
+ } else node.setAttribute(key, value);
85
136
  }
86
137
  };
87
138
  const build = (node, attrs, children) => {