@respeak/recap 0.5.1 → 0.5.2

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 (42) hide show
  1. package/dist/src/ai/gemini.d.ts +4 -3
  2. package/dist/src/ai/gemini.js +10 -8
  3. package/dist/src/ai/gemini.js.map +1 -1
  4. package/dist/src/ai/models.d.ts +61 -0
  5. package/dist/src/ai/models.js +27 -0
  6. package/dist/src/ai/models.js.map +1 -0
  7. package/dist/src/ai/pipeline.js +6 -4
  8. package/dist/src/ai/pipeline.js.map +1 -1
  9. package/dist/src/analyze/index.js +3 -2
  10. package/dist/src/analyze/index.js.map +1 -1
  11. package/dist/src/index.js +10 -6
  12. package/dist/src/index.js.map +1 -1
  13. package/dist/src/produce/docs-generator.d.ts +1 -1
  14. package/dist/src/produce/docs-generator.js +3 -2
  15. package/dist/src/produce/docs-generator.js.map +1 -1
  16. package/dist/src/produce/index.js +1 -1
  17. package/dist/src/produce/index.js.map +1 -1
  18. package/dist/src/produce/translate.js +5 -4
  19. package/dist/src/produce/translate.js.map +1 -1
  20. package/dist/src/record/action-translator.d.ts +1 -1
  21. package/dist/src/record/action-translator.js +2 -1
  22. package/dist/src/record/action-translator.js.map +1 -1
  23. package/dist/src/record/browser-session.d.ts +1 -1
  24. package/dist/src/record/browser-session.js.map +1 -1
  25. package/dist/src/record/index.js +1 -1
  26. package/dist/src/record/index.js.map +1 -1
  27. package/dist/src/sync/client.d.ts +5 -0
  28. package/dist/src/sync/client.js +4 -0
  29. package/dist/src/sync/client.js.map +1 -1
  30. package/dist/src/sync/diff.d.ts +16 -1
  31. package/dist/src/sync/diff.js +72 -3
  32. package/dist/src/sync/diff.js.map +1 -1
  33. package/dist/src/sync/index.js +57 -28
  34. package/dist/src/sync/index.js.map +1 -1
  35. package/dist/src/sync/payload.d.ts +27 -1
  36. package/dist/src/sync/payload.js +32 -3
  37. package/dist/src/sync/payload.js.map +1 -1
  38. package/dist/src/sync/structure.d.ts +17 -0
  39. package/dist/src/sync/structure.js +97 -0
  40. package/dist/src/sync/structure.js.map +1 -0
  41. package/package.json +2 -1
  42. package/skill/SKILL.md +29 -4
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Structural comparison of two editor documents (Tiptap JSON). Plain text alone
3
+ * misses everything that only lives in the structure: a code block's language,
4
+ * link targets, bold/italic, heading levels, callout types, image sources.
5
+ */
6
+ export interface StructureOptions {
7
+ /** Set when the remote image URLs are unknown and `src` can't be compared. */
8
+ ignoreImageSrc?: boolean;
9
+ }
10
+ /**
11
+ * Describe the first difference between two documents, or null when they are
12
+ * equivalent. Representation noise is ignored: key order, null attributes,
13
+ * empty content/marks, mark order and how a run of text is split into nodes.
14
+ */
15
+ export declare function firstStructureDiff(local: unknown, remote: unknown, options?: StructureOptions): string | null;
16
+ /** Visible text of a document, for showing where two versions diverge. */
17
+ export declare function docText(doc: unknown): string;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Structural comparison of two editor documents (Tiptap JSON). Plain text alone
3
+ * misses everything that only lives in the structure: a code block's language,
4
+ * link targets, bold/italic, heading levels, callout types, image sources.
5
+ */
6
+ /**
7
+ * Describe the first difference between two documents, or null when they are
8
+ * equivalent. Representation noise is ignored: key order, null attributes,
9
+ * empty content/marks, mark order and how a run of text is split into nodes.
10
+ */
11
+ export function firstStructureDiff(local, remote, options = {}) {
12
+ return compare(normalize(local, options), normalize(remote, options));
13
+ }
14
+ /** Visible text of a document, for showing where two versions diverge. */
15
+ export function docText(doc) {
16
+ const out = [];
17
+ const walk = (node) => {
18
+ if (node?.text)
19
+ out.push(node.text);
20
+ for (const child of node?.content ?? [])
21
+ walk(child);
22
+ };
23
+ walk(doc);
24
+ return out.join(" ");
25
+ }
26
+ function cleanAttrs(attrs) {
27
+ return Object.fromEntries(Object.entries(attrs ?? {})
28
+ .filter(([, v]) => v !== null && v !== undefined)
29
+ .sort(([a], [b]) => (a < b ? -1 : 1)));
30
+ }
31
+ function normalize(node, options) {
32
+ const attrs = cleanAttrs(node?.attrs);
33
+ if (options.ignoreImageSrc && node?.type === "image")
34
+ delete attrs.src;
35
+ const content = [];
36
+ for (const raw of node?.content ?? []) {
37
+ const child = normalize(raw, options);
38
+ const prev = content[content.length - 1];
39
+ if (child.type === "text" && prev?.type === "text" && same(child.marks, prev.marks)) {
40
+ prev.text += child.text;
41
+ }
42
+ else {
43
+ content.push(child);
44
+ }
45
+ }
46
+ return {
47
+ type: node?.type ?? "",
48
+ text: node?.text ?? "",
49
+ attrs,
50
+ marks: (node?.marks ?? []).map((m) => JSON.stringify([m.type, cleanAttrs(m.attrs)])).sort(),
51
+ content,
52
+ };
53
+ }
54
+ function compare(local, remote) {
55
+ if (local.type !== remote.type)
56
+ return `block type: remote=${remote.type}, local=${local.type}`;
57
+ for (const key of [...new Set([...Object.keys(local.attrs), ...Object.keys(remote.attrs)])].sort()) {
58
+ if (!same(local.attrs[key], remote.attrs[key])) {
59
+ return `${local.type} ${key}: remote=${show(remote.attrs[key])}, local=${show(local.attrs[key])}`;
60
+ }
61
+ }
62
+ if (local.text !== remote.text) {
63
+ return `text: remote=${show(clip(remote.text))}, local=${show(clip(local.text))}`;
64
+ }
65
+ if (!same(local.marks, remote.marks)) {
66
+ return `formatting of ${show(clip(local.text))}: remote=${marks(remote)}, local=${marks(local)}`;
67
+ }
68
+ for (let i = 0; i < Math.min(local.content.length, remote.content.length); i++) {
69
+ const found = compare(local.content[i], remote.content[i]);
70
+ if (found)
71
+ return found;
72
+ }
73
+ if (local.content.length !== remote.content.length) {
74
+ return `${local.type} children: remote=${remote.content.length}, local=${local.content.length}`;
75
+ }
76
+ return null;
77
+ }
78
+ function same(a, b) {
79
+ return JSON.stringify(a) === JSON.stringify(b);
80
+ }
81
+ function show(v) {
82
+ return v === undefined ? "none" : JSON.stringify(v);
83
+ }
84
+ function clip(s) {
85
+ return s.length > 40 ? `${s.slice(0, 40)}…` : s;
86
+ }
87
+ function marks(node) {
88
+ if (node.marks.length === 0)
89
+ return "none";
90
+ return node.marks
91
+ .map((m) => {
92
+ const [type, attrs] = JSON.parse(m);
93
+ return Object.keys(attrs).length > 0 ? `${type}${JSON.stringify(attrs)}` : type;
94
+ })
95
+ .join("+");
96
+ }
97
+ //# sourceMappingURL=structure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structure.js","sourceRoot":"","sources":["../../../src/sync/structure.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAc,EACd,MAAe,EACf,UAA4B,EAAE;IAE9B,OAAO,OAAO,CAAC,SAAS,CAAC,KAAgB,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,MAAiB,EAAE,OAAO,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,OAAO,CAAC,GAAY;IAClC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,CAAC,IAAgC,EAAE,EAAE;QAChD,IAAI,IAAI,EAAE,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,OAAO,IAAI,EAAE;YAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC;IACF,IAAI,CAAC,GAAc,CAAC,CAAC;IACrB,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,UAAU,CAAC,KAAiD;IACnE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC;SAChD,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC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CAAC;IAC3C,OAAO,IAAI,CAAC,KAAK;SACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAsC,CAAC;QACzE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClF,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@respeak/recap",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Generate documentation from product videos",
5
5
  "bin": {
6
6
  "recap": "./dist/src/index.js"
@@ -15,6 +15,7 @@
15
15
  "exports": {
16
16
  ".": "./dist/src/ai/pipeline.js",
17
17
  "./ai": "./dist/src/ai/gemini.js",
18
+ "./models": "./dist/src/ai/models.js",
18
19
  "./markdown": "./dist/src/markdown/markdown-to-tiptap.js",
19
20
  "./prompts": "./dist/src/ai/prompts.js",
20
21
  "./analyze": "./dist/src/analyze/index.js",
package/skill/SKILL.md CHANGED
@@ -32,11 +32,20 @@ The target defaults to `https://docs.respeak.io`. For local dev, add
32
32
  npx @respeak/recap diff ./docs
33
33
  ```
34
34
 
35
- Reports structural drift, per-article content changes (with the file path),
36
- unresolved cross-links, media differences, and project-metadata changes. A clean
37
- repo prints **"Local and remote are IN SYNC."** — trust it as a pre-push gate.
35
+ Reports, with the file path where there is one:
38
36
 
39
- - `--verbose` prints the exact text that changed for each article.
37
+ - chapters and articles missing on either side, and changed titles,
38
+ descriptions, groups, keywords and translations
39
+ - changed **text** (`content differs`)
40
+ - same text but changed **formatting** (`formatting differs`): code-block
41
+ language, link targets, bold/italic, heading levels, callout types, images
42
+ - changed chapter bodies (`_index.md`)
43
+ - a different **order** of chapters or articles
44
+ - unresolved cross-links, media differences, project metadata
45
+
46
+ A clean repo prints **"Local and remote are IN SYNC."** — trust it as a pre-push gate.
47
+
48
+ - `--verbose` prints the exact text that changed.
40
49
  - `--exit-code` exits `1` when drift is found (use this to gate automation).
41
50
 
42
51
  **2. Publish — declarative, mutates the project:**
@@ -50,6 +59,16 @@ and any remote image no longer in local `media/`, is DELETED on the server.** Al
50
59
  `push --dry-run` is identical to `diff`. Push prints a summary including an
51
60
  `images:` line so you can confirm media uploaded.
52
61
 
62
+ ⚠️ **`push` publishes the files on disk, not a commit.** Uncommitted edits in the
63
+ docs folder go live too, including another person's or session's. Run
64
+ `git status <docsDir>` first; if there are edits that are not yours to publish,
65
+ push from a clean checkout (e.g. a separate git worktree). The reverse also
66
+ holds: pushing an older checkout undoes whatever was published since, so treat
67
+ every `diff` line you did not cause as a reason to stop.
68
+
69
+ **3. Verify:** run `diff` again after the push. It must report IN SYNC, or only
70
+ the differences you deliberately did not push.
71
+
53
72
  ### Granular / additive push
54
73
 
55
74
  When you only changed part of the docs, or your local folder is a partial copy,
@@ -73,6 +92,12 @@ payload are left alone. Cross-links still resolve against the full doc set, so a
73
92
  scoped push won't break links to pages it didn't send. A selector that matches
74
93
  nothing in `sync.json` fails loudly.
75
94
 
95
+ Order always follows `sync.json` (chapters by `order`, articles by array
96
+ position), also on a scoped push: every item keeps its place in the whole
97
+ project. If you insert a new chapter or article in the middle, follow up with a
98
+ push that includes the items after it, because a scoped push does not renumber
99
+ what it does not send. `diff` reports it if you forget.
100
+
76
101
  To remove something from the server (the additive counterpart to `--only`):
77
102
 
78
103
  ```bash