@powerhousedao/knowledge-note 1.0.0 → 1.0.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 (56) hide show
  1. package/dist/editors/health-report-editor/editor.d.ts.map +1 -1
  2. package/dist/editors/health-report-editor/editor.js +100 -17
  3. package/dist/editors/knowledge-note-editor/editor.d.ts.map +1 -1
  4. package/dist/editors/knowledge-note-editor/editor.js +12 -3
  5. package/dist/editors/knowledge-vault/components/DriveExplorer.d.ts.map +1 -1
  6. package/dist/editors/knowledge-vault/components/GettingStarted.js +26 -7
  7. package/dist/editors/knowledge-vault/components/GraphView.d.ts +1 -1
  8. package/dist/editors/knowledge-vault/components/GraphView.d.ts.map +1 -1
  9. package/dist/editors/knowledge-vault/components/GraphView.js +1 -1
  10. package/dist/editors/knowledge-vault/components/HealthDashboard.d.ts.map +1 -1
  11. package/dist/editors/knowledge-vault/components/HealthDashboard.js +16 -4
  12. package/dist/editors/knowledge-vault/hooks/use-drive-init.d.ts.map +1 -1
  13. package/dist/editors/knowledge-vault/hooks/use-drive-init.js +78 -62
  14. package/dist/editors/moc-editor/editor.d.ts.map +1 -1
  15. package/dist/editors/moc-editor/editor.js +13 -4
  16. package/dist/editors/tension-editor/editor.d.ts.map +1 -1
  17. package/dist/editors/tension-editor/editor.js +60 -9
  18. package/dist/package.json +45 -1
  19. package/dist/processors/factory.d.ts.map +1 -1
  20. package/dist/processors/factory.js +4 -1
  21. package/dist/processors/graph-indexer/index.d.ts.map +1 -1
  22. package/dist/processors/graph-indexer/query.d.ts.map +1 -1
  23. package/dist/processors/graph-indexer/query.js +2 -1
  24. package/dist/processors/methodology-indexer/factory.d.ts +4 -0
  25. package/dist/processors/methodology-indexer/factory.d.ts.map +1 -0
  26. package/dist/processors/methodology-indexer/factory.js +23 -0
  27. package/dist/processors/methodology-indexer/index.d.ts +11 -0
  28. package/dist/processors/methodology-indexer/index.d.ts.map +1 -0
  29. package/dist/processors/methodology-indexer/index.js +116 -0
  30. package/dist/processors/methodology-indexer/migrations.d.ts +4 -0
  31. package/dist/processors/methodology-indexer/migrations.d.ts.map +1 -0
  32. package/dist/processors/methodology-indexer/migrations.js +39 -0
  33. package/dist/processors/methodology-indexer/query.d.ts +35 -0
  34. package/dist/processors/methodology-indexer/query.d.ts.map +1 -0
  35. package/dist/processors/methodology-indexer/query.js +114 -0
  36. package/dist/processors/methodology-indexer/schema.d.ts +22 -0
  37. package/dist/processors/methodology-indexer/schema.d.ts.map +1 -0
  38. package/dist/processors/methodology-indexer/schema.js +1 -0
  39. package/dist/style.css +15 -0
  40. package/dist/subgraphs/index.d.ts +1 -0
  41. package/dist/subgraphs/index.d.ts.map +1 -1
  42. package/dist/subgraphs/index.js +1 -0
  43. package/dist/subgraphs/knowledge-graph/subgraph.d.ts.map +1 -1
  44. package/dist/subgraphs/knowledge-graph/subgraph.js +45 -15
  45. package/dist/subgraphs/methodology/index.d.ts +2 -0
  46. package/dist/subgraphs/methodology/index.d.ts.map +1 -0
  47. package/dist/subgraphs/methodology/index.js +1 -0
  48. package/dist/subgraphs/methodology/subgraph.d.ts +47 -0
  49. package/dist/subgraphs/methodology/subgraph.d.ts.map +1 -0
  50. package/dist/subgraphs/methodology/subgraph.js +100 -0
  51. package/dist/tests/processor/graph-indexer.test.js +8 -2
  52. package/dist/tests/unit/knowledge-note-reducers.test.js +4 -1
  53. package/dist/tests/unit/lifecycle-state-machine.test.js +16 -4
  54. package/dist/tests/unit/moc-reducers.test.js +1 -1
  55. package/dist/tests/unit/pipeline-queue-reducers.test.js +10 -2
  56. package/package.json +45 -1
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useCallback } from "react";
3
3
  import { generateId } from "document-model/core";
4
4
  import { DocumentToolbar } from "@powerhousedao/design-system/connect";
5
+ import { setSelectedNode, useDocumentsInSelectedDrive, } from "@powerhousedao/reactor-browser";
5
6
  import { useSelectedMocDocument, actions, } from "@powerhousedao/knowledge-note/document-models/moc";
6
7
  import { TOOLBAR_CLASS } from "../shared/theme-context.js";
7
8
  const TIERS = ["HUB", "DOMAIN", "TOPIC"];
@@ -16,6 +17,7 @@ function ts() {
16
17
  export default function Editor() {
17
18
  const [document, dispatch] = useSelectedMocDocument();
18
19
  const state = document.state.global;
20
+ const allDocs = useDocumentsInSelectedDrive();
19
21
  const [newQuestion, setNewQuestion] = useState("");
20
22
  const [newIdeaRef, setNewIdeaRef] = useState("");
21
23
  const [newIdeaPhrase, setNewIdeaPhrase] = useState("");
@@ -47,10 +49,17 @@ export default function Editor() {
47
49
  } })] }), _jsxs("div", { className: "grid grid-cols-2 gap-6", children: [_jsxs("div", { className: "rounded-xl p-6", style: {
48
50
  backgroundColor: "var(--bai-surface)",
49
51
  border: "1px solid var(--bai-border)",
50
- }, children: [_jsxs("h3", { className: "mb-3 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: ["Core Ideas (", (state.coreIdeas ?? []).length, ")"] }), _jsxs("div", { className: "space-y-2", children: [(state.coreIdeas ?? []).map((idea) => (_jsxs("div", { className: "group flex items-start gap-2 rounded-lg px-3 py-2", style: {
51
- backgroundColor: "var(--bai-bg)",
52
- boxShadow: "0 0 0 1px var(--bai-ring)",
53
- }, children: [_jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: "text-xs", style: { color: "var(--bai-text-secondary)" }, children: idea.contextPhrase }), _jsx("p", { className: "text-[10px] font-mono mt-0.5", style: { color: "var(--bai-text-faint)" }, children: idea.noteRef?.slice(0, 12) })] }), _jsx("button", { type: "button", onClick: () => dispatch(actions.removeCoreIdea({ id: idea.id })), className: "opacity-0 hover:text-red-400 group-hover:opacity-100", style: { color: "var(--bai-text-faint)" }, children: "\u00D7" })] }, idea.id))), _jsxs("form", { className: "flex gap-2", onSubmit: (e) => {
52
+ }, children: [_jsxs("h3", { className: "mb-3 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: ["Core Ideas (", (state.coreIdeas ?? []).length, ")"] }), _jsxs("div", { className: "space-y-2", children: [(state.coreIdeas ?? []).map((idea) => {
53
+ const linkedDoc = (allDocs ?? []).find((d) => d.header.id === idea.noteRef);
54
+ const noteTitle = linkedDoc
55
+ ? (linkedDoc.state.global.title ?? linkedDoc.header.name)
56
+ : null;
57
+ return (_jsxs("div", { className: "group flex items-start gap-2 rounded-lg px-3 py-2", style: {
58
+ backgroundColor: "var(--bai-bg)",
59
+ boxShadow: "0 0 0 1px var(--bai-ring)",
60
+ }, children: [_jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: "text-xs", style: { color: "var(--bai-text-secondary)" }, children: idea.contextPhrase }), idea.noteRef &&
61
+ (noteTitle ? (_jsxs("button", { type: "button", onClick: () => setSelectedNode(idea.noteRef), className: "mt-0.5 text-[10px] text-left truncate max-w-full transition-colors hover:underline", style: { color: "var(--bai-accent)" }, title: `Open note: ${noteTitle}`, children: [noteTitle, _jsxs("svg", { className: "ml-1 inline h-2.5 w-2.5", style: { color: "var(--bai-text-faint)" }, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }), _jsx("path", { d: "M15 3h6v6" }), _jsx("path", { d: "M10 14L21 3" })] })] })) : (_jsx("p", { className: "text-[10px] font-mono mt-0.5", style: { color: "var(--bai-text-faint)" }, children: idea.noteRef.slice(0, 12) })))] }), _jsx("button", { type: "button", onClick: () => dispatch(actions.removeCoreIdea({ id: idea.id })), className: "opacity-0 hover:text-red-400 group-hover:opacity-100", style: { color: "var(--bai-text-faint)" }, children: "\u00D7" })] }, idea.id));
62
+ }), _jsxs("form", { className: "flex gap-2", onSubmit: (e) => {
54
63
  e.preventDefault();
55
64
  if (!newIdeaRef.trim() || !newIdeaPhrase.trim())
56
65
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/tension-editor/editor.tsx"],"names":[],"mappings":"AAsBA,MAAM,CAAC,OAAO,UAAU,MAAM,4CA+H7B"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/tension-editor/editor.tsx"],"names":[],"mappings":"AAsBA,MAAM,CAAC,OAAO,UAAU,MAAM,4CAyO7B"}
@@ -24,28 +24,79 @@ export default function Editor() {
24
24
  const involvedNotes = (state.involvedRefs ?? []).map((ref) => {
25
25
  const doc = (allDocs ?? []).find((d) => d.header.id === ref);
26
26
  const title = doc
27
- ? (doc.state.global.title ?? doc.header.name)
27
+ ? (doc.state.global
28
+ .title ?? doc.header.name)
28
29
  : ref.slice(0, 12);
29
30
  return { ref, title, exists: !!doc };
30
31
  });
31
- return (_jsx("div", { className: "min-h-screen", style: { backgroundColor: "var(--bai-bg)", color: "var(--bai-text)" }, children: _jsxs("div", { className: "mx-auto max-w-3xl", children: [_jsx(DocumentToolbar, { className: TOOLBAR_CLASS }), _jsxs("div", { className: "p-6 space-y-6", children: [_jsxs("div", { className: "rounded-xl p-6", style: { backgroundColor: "var(--bai-surface)", border: "1px solid var(--bai-border)" }, children: [_jsxs("div", { className: "flex items-center gap-3 mb-3", children: [_jsx("span", { className: `rounded-full border px-3 py-1 text-xs font-semibold ${STATUS_COLORS[state.status ?? "OPEN"]}`, children: state.status }), state.observedBy && (_jsxs("span", { className: "text-xs", style: { color: "var(--bai-text-faint)" }, children: ["by ", state.observedBy] })), state.observedAt && (_jsx("span", { className: "text-xs", style: { color: "var(--bai-text-faint)" }, children: new Date(state.observedAt).toLocaleDateString() }))] }), _jsx("h1", { className: "text-xl font-bold", style: { color: "var(--bai-text)" }, children: state.title }), state.description && (_jsx("p", { className: "mt-2 text-sm", style: { color: "var(--bai-text-tertiary)" }, children: state.description }))] }), state.content && (_jsxs("div", { className: "rounded-xl p-6", style: { backgroundColor: "var(--bai-surface)", border: "1px solid var(--bai-border)" }, children: [_jsx("h3", { className: "mb-2 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: "Analysis" }), _jsx("div", { className: "rounded-lg px-4 py-3", style: { backgroundColor: "var(--bai-deep)", border: "1px solid var(--bai-border)" }, children: _jsx("pre", { className: "whitespace-pre-wrap text-sm leading-relaxed", style: { color: "var(--bai-text-secondary)" }, children: state.content }) })] })), _jsxs("div", { className: "rounded-xl p-6", style: { backgroundColor: "var(--bai-surface)", border: "1px solid var(--bai-border)" }, children: [_jsxs("h3", { className: "mb-3 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: ["Involved Notes (", involvedNotes.length, ")"] }), _jsx("div", { className: "space-y-2", children: involvedNotes.map((note) => (_jsxs("div", { className: "flex items-center gap-3 rounded-lg px-4 py-3", style: { backgroundColor: "var(--bai-bg)", border: "1px solid var(--bai-border)" }, children: [_jsx("span", { className: "h-2 w-2 shrink-0 rounded-full bg-red-400" }), note.exists ? (_jsx("button", { type: "button", onClick: () => setSelectedNode(note.ref), className: "flex-1 text-left text-xs transition-colors truncate", style: { color: "var(--bai-accent)" }, children: note.title })) : (_jsx("span", { className: "flex-1 text-xs font-mono truncate", style: { color: "var(--bai-text-faint)" }, children: note.ref }))] }, note.ref))) })] }), state.resolution && (_jsxs("div", { className: "rounded-xl p-6", style: { backgroundColor: "var(--bai-surface)", border: "1px solid var(--bai-border)" }, children: [_jsx("h3", { className: "mb-2 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: "Resolution" }), _jsx("p", { className: "text-sm leading-relaxed", style: { color: "var(--bai-text-secondary)" }, children: state.resolution }), state.resolvedAt && (_jsxs("p", { className: "mt-2 text-[10px]", style: { color: "var(--bai-text-faint)" }, children: ["Resolved ", new Date(state.resolvedAt).toLocaleString()] }))] })), state.status === "OPEN" && (_jsxs("div", { className: "flex gap-3", children: [_jsx("button", { type: "button", onClick: () => {
32
+ return (_jsx("div", { className: "min-h-screen", style: { backgroundColor: "var(--bai-bg)", color: "var(--bai-text)" }, children: _jsxs("div", { className: "mx-auto max-w-3xl", children: [_jsx(DocumentToolbar, { className: TOOLBAR_CLASS }), _jsxs("div", { className: "p-6 space-y-6", children: [_jsxs("div", { className: "rounded-xl p-6", style: {
33
+ backgroundColor: "var(--bai-surface)",
34
+ border: "1px solid var(--bai-border)",
35
+ }, children: [_jsxs("div", { className: "flex items-center gap-3 mb-3", children: [_jsx("span", { className: `rounded-full border px-3 py-1 text-xs font-semibold ${STATUS_COLORS[state.status ?? "OPEN"]}`, children: state.status }), state.observedBy && (_jsxs("span", { className: "text-xs", style: { color: "var(--bai-text-faint)" }, children: ["by ", state.observedBy] })), state.observedAt && (_jsx("span", { className: "text-xs", style: { color: "var(--bai-text-faint)" }, children: new Date(state.observedAt).toLocaleDateString() }))] }), _jsx("h1", { className: "text-xl font-bold", style: { color: "var(--bai-text)" }, children: state.title }), state.description && (_jsx("p", { className: "mt-2 text-sm", style: { color: "var(--bai-text-tertiary)" }, children: state.description }))] }), state.content && (_jsxs("div", { className: "rounded-xl p-6", style: {
36
+ backgroundColor: "var(--bai-surface)",
37
+ border: "1px solid var(--bai-border)",
38
+ }, children: [_jsx("h3", { className: "mb-2 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: "Analysis" }), _jsx("div", { className: "rounded-lg px-4 py-3", style: {
39
+ backgroundColor: "var(--bai-deep)",
40
+ border: "1px solid var(--bai-border)",
41
+ }, children: _jsx("pre", { className: "whitespace-pre-wrap text-sm leading-relaxed", style: { color: "var(--bai-text-secondary)" }, children: state.content }) })] })), _jsxs("div", { className: "rounded-xl p-6", style: {
42
+ backgroundColor: "var(--bai-surface)",
43
+ border: "1px solid var(--bai-border)",
44
+ }, children: [_jsxs("h3", { className: "mb-3 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: ["Involved Notes (", involvedNotes.length, ")"] }), _jsx("div", { className: "space-y-2", children: involvedNotes.map((note) => (_jsxs("div", { className: "flex items-center gap-3 rounded-lg px-4 py-3", style: {
45
+ backgroundColor: "var(--bai-bg)",
46
+ border: "1px solid var(--bai-border)",
47
+ }, children: [_jsx("span", { className: "h-2 w-2 shrink-0 rounded-full bg-red-400" }), note.exists ? (_jsx("button", { type: "button", onClick: () => setSelectedNode(note.ref), className: "flex-1 text-left text-xs transition-colors truncate", style: { color: "var(--bai-accent)" }, children: note.title })) : (_jsx("span", { className: "flex-1 text-xs font-mono truncate", style: { color: "var(--bai-text-faint)" }, children: note.ref }))] }, note.ref))) })] }), state.resolution && (_jsxs("div", { className: "rounded-xl p-6", style: {
48
+ backgroundColor: "var(--bai-surface)",
49
+ border: "1px solid var(--bai-border)",
50
+ }, children: [_jsx("h3", { className: "mb-2 text-xs font-semibold uppercase tracking-wider", style: { color: "var(--bai-text-muted)" }, children: "Resolution" }), _jsx("p", { className: "text-sm leading-relaxed", style: { color: "var(--bai-text-secondary)" }, children: state.resolution }), state.resolvedAt && (_jsxs("p", { className: "mt-2 text-[10px]", style: { color: "var(--bai-text-faint)" }, children: ["Resolved ", new Date(state.resolvedAt).toLocaleString()] }))] })), state.status === "OPEN" && (_jsxs("div", { className: "flex gap-3", children: [_jsx("button", { type: "button", onClick: () => {
32
51
  const resolution = prompt("How was this resolved? (one side is correct)");
33
52
  if (resolution)
34
53
  dispatch(actions.resolveTension({ resolution, resolvedAt: ts() }));
35
- }, className: "rounded-lg px-4 py-2 text-sm font-medium", style: { backgroundColor: "var(--bai-accent)", color: "var(--bai-accent-text)" }, children: "Resolve" }), _jsx("button", { type: "button", onClick: () => {
54
+ }, className: "rounded-lg px-4 py-2 text-sm font-medium", style: {
55
+ backgroundColor: "var(--bai-accent)",
56
+ color: "var(--bai-accent-text)",
57
+ }, children: "Resolve" }), _jsx("button", { type: "button", onClick: () => {
36
58
  const resolution = prompt("Why is this tension apparent, not real?");
37
59
  if (resolution)
38
60
  dispatch(actions.dissolveTension({ resolution, resolvedAt: ts() }));
39
- }, className: "rounded-lg px-4 py-2 text-sm font-medium", style: { backgroundColor: "var(--bai-hover)", color: "var(--bai-text-secondary)" }, children: "Dissolve" })] }))] })] }) }));
61
+ }, className: "rounded-lg px-4 py-2 text-sm font-medium", style: {
62
+ backgroundColor: "var(--bai-hover)",
63
+ color: "var(--bai-text-secondary)",
64
+ }, children: "Dissolve" })] }))] })] }) }));
40
65
  }
41
- function CreateForm({ dispatch }) {
66
+ function CreateForm({ dispatch, }) {
42
67
  const [title, setTitle] = useState("");
43
68
  const [desc, setDesc] = useState("");
44
69
  const [content, setContent] = useState("");
45
70
  const [observer, setObserver] = useState("");
46
71
  const INPUT = "w-full rounded-lg px-3 py-2 text-sm outline-none focus:border-[#cba6f7]/50";
47
- return (_jsx("div", { className: "min-h-screen", style: { backgroundColor: "var(--bai-bg)", color: "var(--bai-text)" }, children: _jsxs("div", { className: "mx-auto max-w-2xl", children: [_jsx(DocumentToolbar, { className: TOOLBAR_CLASS }), _jsx("div", { className: "p-6", children: _jsxs("div", { className: "rounded-xl p-8 space-y-4", style: { backgroundColor: "var(--bai-surface)", border: "1px solid var(--bai-border)" }, children: [_jsx("h2", { className: "text-lg font-bold", style: { color: "var(--bai-text)" }, children: "Identify Tension" }), _jsx("p", { className: "text-xs", style: { color: "var(--bai-text-muted)" }, children: "Record a contradiction between two or more claims in the vault" }), _jsx("input", { type: "text", value: title, onChange: (e) => setTitle(e.target.value), placeholder: "What's the contradiction? (e.g., 'vault as tool vs vault as cognitive infrastructure')", className: INPUT, style: { backgroundColor: "var(--bai-bg)", color: "var(--bai-text-secondary)", border: "1px solid var(--bai-border)" } }), _jsx("input", { type: "text", value: desc, onChange: (e) => setDesc(e.target.value), placeholder: "Brief summary of the conflict", className: INPUT, style: { backgroundColor: "var(--bai-bg)", color: "var(--bai-text-secondary)", border: "1px solid var(--bai-border)" } }), _jsx("textarea", { value: content, onChange: (e) => setContent(e.target.value), placeholder: "Full analysis of the contradiction \u2014 why it matters, what's at stake...", rows: 6, className: INPUT, style: { backgroundColor: "var(--bai-deep)", color: "var(--bai-text-secondary)", border: "1px solid var(--bai-border)" } }), _jsx("input", { type: "text", value: observer, onChange: (e) => setObserver(e.target.value), placeholder: "Observed by (optional)", className: INPUT, style: { backgroundColor: "var(--bai-bg)", color: "var(--bai-text-secondary)", border: "1px solid var(--bai-border)" } }), _jsx("button", { type: "button", disabled: !title.trim() || !desc.trim(), onClick: () => dispatch(actions.createTension({
48
- title, description: desc, content: content || undefined,
49
- involvedRefs: [], observedAt: ts(), observedBy: observer || undefined,
50
- })), className: "rounded-lg px-4 py-2 text-sm font-medium hover:opacity-80 disabled:opacity-40", style: { backgroundColor: "var(--bai-accent)", color: "var(--bai-accent-text)" }, children: "Create Tension" })] }) })] }) }));
72
+ return (_jsx("div", { className: "min-h-screen", style: { backgroundColor: "var(--bai-bg)", color: "var(--bai-text)" }, children: _jsxs("div", { className: "mx-auto max-w-2xl", children: [_jsx(DocumentToolbar, { className: TOOLBAR_CLASS }), _jsx("div", { className: "p-6", children: _jsxs("div", { className: "rounded-xl p-8 space-y-4", style: {
73
+ backgroundColor: "var(--bai-surface)",
74
+ border: "1px solid var(--bai-border)",
75
+ }, children: [_jsx("h2", { className: "text-lg font-bold", style: { color: "var(--bai-text)" }, children: "Identify Tension" }), _jsx("p", { className: "text-xs", style: { color: "var(--bai-text-muted)" }, children: "Record a contradiction between two or more claims in the vault" }), _jsx("input", { type: "text", value: title, onChange: (e) => setTitle(e.target.value), placeholder: "What's the contradiction? (e.g., 'vault as tool vs vault as cognitive infrastructure')", className: INPUT, style: {
76
+ backgroundColor: "var(--bai-bg)",
77
+ color: "var(--bai-text-secondary)",
78
+ border: "1px solid var(--bai-border)",
79
+ } }), _jsx("input", { type: "text", value: desc, onChange: (e) => setDesc(e.target.value), placeholder: "Brief summary of the conflict", className: INPUT, style: {
80
+ backgroundColor: "var(--bai-bg)",
81
+ color: "var(--bai-text-secondary)",
82
+ border: "1px solid var(--bai-border)",
83
+ } }), _jsx("textarea", { value: content, onChange: (e) => setContent(e.target.value), placeholder: "Full analysis of the contradiction \u2014 why it matters, what's at stake...", rows: 6, className: INPUT, style: {
84
+ backgroundColor: "var(--bai-deep)",
85
+ color: "var(--bai-text-secondary)",
86
+ border: "1px solid var(--bai-border)",
87
+ } }), _jsx("input", { type: "text", value: observer, onChange: (e) => setObserver(e.target.value), placeholder: "Observed by (optional)", className: INPUT, style: {
88
+ backgroundColor: "var(--bai-bg)",
89
+ color: "var(--bai-text-secondary)",
90
+ border: "1px solid var(--bai-border)",
91
+ } }), _jsx("button", { type: "button", disabled: !title.trim() || !desc.trim(), onClick: () => dispatch(actions.createTension({
92
+ title,
93
+ description: desc,
94
+ content: content || undefined,
95
+ involvedRefs: [],
96
+ observedAt: ts(),
97
+ observedBy: observer || undefined,
98
+ })), className: "rounded-lg px-4 py-2 text-sm font-medium hover:opacity-80 disabled:opacity-40", style: {
99
+ backgroundColor: "var(--bai-accent)",
100
+ color: "var(--bai-accent-text)",
101
+ }, children: "Create Tension" })] }) })] }) }));
51
102
  }
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/knowledge-note",
3
3
  "description": "Knowledge Note document model package for Powerhouse",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [
@@ -23,6 +23,50 @@
23
23
  "types": "./dist/editors/index.d.ts",
24
24
  "import": "./dist/editors/index.js"
25
25
  },
26
+ "./document-models/derivation": {
27
+ "types": "./dist/document-models/derivation/index.d.ts",
28
+ "import": "./dist/document-models/derivation/index.js"
29
+ },
30
+ "./document-models/health-report": {
31
+ "types": "./dist/document-models/health-report/index.d.ts",
32
+ "import": "./dist/document-models/health-report/index.js"
33
+ },
34
+ "./document-models/knowledge-graph": {
35
+ "types": "./dist/document-models/knowledge-graph/index.d.ts",
36
+ "import": "./dist/document-models/knowledge-graph/index.js"
37
+ },
38
+ "./document-models/knowledge-note": {
39
+ "types": "./dist/document-models/knowledge-note/index.d.ts",
40
+ "import": "./dist/document-models/knowledge-note/index.js"
41
+ },
42
+ "./document-models/moc": {
43
+ "types": "./dist/document-models/moc/index.d.ts",
44
+ "import": "./dist/document-models/moc/index.js"
45
+ },
46
+ "./document-models/observation": {
47
+ "types": "./dist/document-models/observation/index.d.ts",
48
+ "import": "./dist/document-models/observation/index.js"
49
+ },
50
+ "./document-models/pipeline-queue": {
51
+ "types": "./dist/document-models/pipeline-queue/index.d.ts",
52
+ "import": "./dist/document-models/pipeline-queue/index.js"
53
+ },
54
+ "./document-models/research-claim": {
55
+ "types": "./dist/document-models/research-claim/index.d.ts",
56
+ "import": "./dist/document-models/research-claim/index.js"
57
+ },
58
+ "./document-models/source": {
59
+ "types": "./dist/document-models/source/index.d.ts",
60
+ "import": "./dist/document-models/source/index.js"
61
+ },
62
+ "./document-models/tension": {
63
+ "types": "./dist/document-models/tension/index.d.ts",
64
+ "import": "./dist/document-models/tension/index.js"
65
+ },
66
+ "./document-models/vault-config": {
67
+ "types": "./dist/document-models/vault-config/index.d.ts",
68
+ "import": "./dist/document-models/vault-config/index.js"
69
+ },
26
70
  "./document-models/*": {
27
71
  "types": "./dist/document-models/*/index.d.ts",
28
72
  "import": "./dist/document-models/*/index.js"
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../processors/factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,MAa7C,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAUxE,CAAC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../processors/factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,MAgB7C,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAUxE,CAAC"}
@@ -2,11 +2,14 @@
2
2
  * This file aggregates all processor factories
3
3
  */
4
4
  import { graphIndexerProcessorFactory } from "./graph-indexer/factory.js";
5
+ import { methodologyIndexerProcessorFactory } from "./methodology-indexer/factory.js";
5
6
  export const processorFactory = (module) => {
6
7
  console.log(`[processorFactory] Initializing with processorApp: ${module.processorApp}`);
7
8
  const factories = [];
8
- // Register graph indexer for both connect and switchboard
9
+ // Register graph indexer (watches bai/knowledge-note)
9
10
  factories.push(graphIndexerProcessorFactory(module));
11
+ // Register methodology indexer (watches bai/research-claim)
12
+ factories.push(methodologyIndexerProcessorFactory(module));
10
13
  console.log(`[processorFactory] Loaded ${factories.length} factories`);
11
14
  // Return the inner function that will be called for each drive
12
15
  return async (driveHeader) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/graph-indexer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,qBAAa,qBAAsB,SAAQ,qBAAqB,CAAC,EAAE,CAAC;WAClD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAItC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,YAAY,CACzB,UAAU,EAAE,oBAAoB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC;IAsGV,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;YAUrB,UAAU;CAoBzB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/graph-indexer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,qBAAa,qBAAsB,SAAQ,qBAAqB,CAAC,EAAE,CAAC;WAClD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAItC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,YAAY,CACzB,UAAU,EAAE,oBAAoB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC;IAqGV,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;YAUrB,UAAU;CAoBzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../processors/graph-indexer/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,EAAwB,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,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,MAAM,mBAAe,OAAO,CAAC,eAAe,EAAE,CAAC;6BAgBzC,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;+BASrC,OAAO,CAClC,KAAK,CAAC;QACJ,CAAC,EAAE,eAAe,CAAC;QACnB,CAAC,EAAE,eAAe,CAAC;QACnB,YAAY,EAAE,eAAe,CAAC;KAC/B,CAAC,CACH;eAuDgB,OAAO,CAAC,eAAe,EAAE,CAAC;EA6D9C"}
@@ -163,7 +163,8 @@ export function createGraphQuery(db) {
163
163
  const aId = sources[i];
164
164
  const bId = sources[j];
165
165
  // Check if A→B or B→A exists
166
- if (!edgeSet.has(`${aId}->${bId}`) && !edgeSet.has(`${bId}->${aId}`)) {
166
+ if (!edgeSet.has(`${aId}->${bId}`) &&
167
+ !edgeSet.has(`${bId}->${aId}`)) {
167
168
  const a = nodeMap.get(aId);
168
169
  const b = nodeMap.get(bId);
169
170
  if (a && b) {
@@ -0,0 +1,4 @@
1
+ import type { ProcessorRecord, IProcessorHostModule } from "@powerhousedao/reactor-browser";
2
+ import type { PHDocumentHeader } from "document-model";
3
+ export declare const methodologyIndexerProcessorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
4
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,eAAO,MAAM,kCAAkC,GAC5C,QAAQ,oBAAoB,MACtB,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAgC/D,CAAC"}
@@ -0,0 +1,23 @@
1
+ import {} from "@powerhousedao/shared/processors";
2
+ import { MethodologyIndexerProcessor } from "./index.js";
3
+ export const methodologyIndexerProcessorFactory = (module) => async (driveHeader) => {
4
+ const namespace = MethodologyIndexerProcessor.getNamespace(driveHeader.id);
5
+ console.log(`[MethodologyIndexer] Factory called for drive: ${driveHeader.id}, namespace: ${namespace}`);
6
+ const store = await module.relationalDb.createNamespace(namespace);
7
+ const filter = {
8
+ branch: ["main"],
9
+ documentId: ["*"],
10
+ documentType: ["bai/research-claim", "powerhouse/document-drive"],
11
+ scope: ["global"],
12
+ };
13
+ const processor = new MethodologyIndexerProcessor(namespace, filter, store);
14
+ await processor.initAndUpgrade();
15
+ console.log(`[MethodologyIndexer] Processor created for drive: ${driveHeader.id}`);
16
+ return [
17
+ {
18
+ processor,
19
+ filter,
20
+ startFrom: "beginning",
21
+ },
22
+ ];
23
+ };
@@ -0,0 +1,11 @@
1
+ import { RelationalDbProcessor } from "@powerhousedao/shared/processors";
2
+ import type { OperationWithContext } from "@powerhousedao/shared/document-model";
3
+ import type { MethodologyDB } from "./schema.js";
4
+ export declare class MethodologyIndexerProcessor extends RelationalDbProcessor<MethodologyDB> {
5
+ static getNamespace(driveId: string): string;
6
+ initAndUpgrade(): Promise<void>;
7
+ onOperations(operations: OperationWithContext[]): Promise<void>;
8
+ onDisconnect(): Promise<void>;
9
+ private deleteClaim;
10
+ }
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,qBAAa,2BAA4B,SAAQ,qBAAqB,CAAC,aAAa,CAAC;WACnE,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAItC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,YAAY,CACzB,UAAU,EAAE,oBAAoB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC;IAsGV,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;YAYrB,WAAW;CAkB1B"}
@@ -0,0 +1,116 @@
1
+ import { RelationalDbProcessor } from "@powerhousedao/shared/processors";
2
+ import { up } from "./migrations.js";
3
+ export class MethodologyIndexerProcessor extends RelationalDbProcessor {
4
+ static getNamespace(driveId) {
5
+ return super.getNamespace(driveId);
6
+ }
7
+ async initAndUpgrade() {
8
+ await up(this.relationalDb);
9
+ }
10
+ async onOperations(operations) {
11
+ if (operations.length === 0)
12
+ return;
13
+ const lastByDocument = new Map();
14
+ for (const entry of operations) {
15
+ const { operation, context } = entry;
16
+ const documentId = context.documentId;
17
+ // Handle deletion from drive
18
+ if (context.documentType === "powerhouse/document-drive" &&
19
+ operation.action.type === "DELETE_NODE") {
20
+ const deleteInput = operation.action.input;
21
+ await this.deleteClaim(deleteInput.id);
22
+ lastByDocument.delete(deleteInput.id);
23
+ continue;
24
+ }
25
+ // Only process research-claim documents
26
+ if (context.documentType !== "bai/research-claim")
27
+ continue;
28
+ if (context.resultingState) {
29
+ lastByDocument.set(documentId, entry);
30
+ }
31
+ }
32
+ for (const [documentId, entry] of lastByDocument) {
33
+ try {
34
+ const stateJson = entry.context.resultingState;
35
+ if (!stateJson)
36
+ continue;
37
+ const parsed = JSON.parse(stateJson);
38
+ const global = (parsed.global ?? parsed);
39
+ const now = new Date().toISOString();
40
+ // Upsert claim
41
+ const topics = global.topics ?? [];
42
+ const methodology = global.methodology ?? [];
43
+ await this.relationalDb
44
+ .insertInto("methodology_claims")
45
+ .values({
46
+ id: documentId,
47
+ document_id: documentId,
48
+ title: global.title ?? null,
49
+ description: global.description ?? null,
50
+ kind: global.kind ?? null,
51
+ topics: JSON.stringify(topics),
52
+ methodology: JSON.stringify(methodology),
53
+ updated_at: now,
54
+ })
55
+ .onConflict((oc) => oc.column("document_id").doUpdateSet({
56
+ title: global.title ?? null,
57
+ description: global.description ?? null,
58
+ kind: global.kind ?? null,
59
+ topics: JSON.stringify(topics),
60
+ methodology: JSON.stringify(methodology),
61
+ updated_at: now,
62
+ }))
63
+ .execute();
64
+ // Reconcile connections
65
+ await this.relationalDb
66
+ .deleteFrom("methodology_connections")
67
+ .where("source_document_id", "=", documentId)
68
+ .execute();
69
+ const connections = global.connections ?? [];
70
+ if (connections.length > 0) {
71
+ await this.relationalDb
72
+ .insertInto("methodology_connections")
73
+ .values(connections.map((conn) => ({
74
+ id: conn.id ??
75
+ `${documentId}-${conn.targetRef}`,
76
+ source_document_id: documentId,
77
+ target_ref: conn.targetRef ?? "",
78
+ context_phrase: conn.contextPhrase ?? null,
79
+ updated_at: now,
80
+ })))
81
+ .execute();
82
+ }
83
+ console.log(`[MethodologyIndexer] Reconciled ${documentId}: ${connections.length} connections`);
84
+ }
85
+ catch (err) {
86
+ console.error(`[MethodologyIndexer] Error reconciling ${documentId}:`, err);
87
+ }
88
+ }
89
+ }
90
+ async onDisconnect() {
91
+ try {
92
+ await this.relationalDb.deleteFrom("methodology_connections").execute();
93
+ await this.relationalDb.deleteFrom("methodology_claims").execute();
94
+ console.log(`[MethodologyIndexer] Cleaned up namespace: ${this.namespace}`);
95
+ }
96
+ catch (err) {
97
+ console.error(`[MethodologyIndexer] Error cleaning up:`, err);
98
+ }
99
+ }
100
+ async deleteClaim(documentId) {
101
+ try {
102
+ await this.relationalDb
103
+ .deleteFrom("methodology_connections")
104
+ .where("source_document_id", "=", documentId)
105
+ .execute();
106
+ await this.relationalDb
107
+ .deleteFrom("methodology_claims")
108
+ .where("document_id", "=", documentId)
109
+ .execute();
110
+ console.log(`[MethodologyIndexer] Deleted claim ${documentId}`);
111
+ }
112
+ catch (err) {
113
+ console.error(`[MethodologyIndexer] Error deleting claim ${documentId}:`, err);
114
+ }
115
+ }
116
+ }
@@ -0,0 +1,4 @@
1
+ import type { IRelationalDb } from "@powerhousedao/shared/processors";
2
+ export declare function up(db: IRelationalDb<any>): Promise<void>;
3
+ export declare function down(db: IRelationalDb<any>): Promise<void>;
4
+ //# sourceMappingURL=migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,wBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC9D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE"}
@@ -0,0 +1,39 @@
1
+ export async function up(db) {
2
+ await db.schema
3
+ .createTable("methodology_claims")
4
+ .addColumn("id", "varchar(255)", (col) => col.primaryKey())
5
+ .addColumn("document_id", "varchar(255)", (col) => col.notNull().unique())
6
+ .addColumn("title", "varchar(1024)")
7
+ .addColumn("description", "text")
8
+ .addColumn("kind", "varchar(100)")
9
+ .addColumn("topics", "text") // JSON array as string
10
+ .addColumn("methodology", "text") // JSON array as string
11
+ .addColumn("updated_at", "varchar(50)", (col) => col.notNull())
12
+ .ifNotExists()
13
+ .execute();
14
+ await db.schema
15
+ .createTable("methodology_connections")
16
+ .addColumn("id", "varchar(255)", (col) => col.primaryKey())
17
+ .addColumn("source_document_id", "varchar(255)", (col) => col.notNull())
18
+ .addColumn("target_ref", "varchar(255)", (col) => col.notNull())
19
+ .addColumn("context_phrase", "text")
20
+ .addColumn("updated_at", "varchar(50)", (col) => col.notNull())
21
+ .ifNotExists()
22
+ .execute();
23
+ await db.schema
24
+ .createIndex("idx_methodology_claims_kind")
25
+ .on("methodology_claims")
26
+ .column("kind")
27
+ .ifNotExists()
28
+ .execute();
29
+ await db.schema
30
+ .createIndex("idx_methodology_connections_source")
31
+ .on("methodology_connections")
32
+ .column("source_document_id")
33
+ .ifNotExists()
34
+ .execute();
35
+ }
36
+ export async function down(db) {
37
+ await db.schema.dropTable("methodology_connections").ifExists().execute();
38
+ await db.schema.dropTable("methodology_claims").ifExists().execute();
39
+ }
@@ -0,0 +1,35 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { MethodologyDB } from "./schema.js";
3
+ export interface ClaimResult {
4
+ id: string;
5
+ documentId: string;
6
+ title: string | null;
7
+ description: string | null;
8
+ kind: string | null;
9
+ topics: string[];
10
+ methodology: string[];
11
+ updatedAt: string;
12
+ }
13
+ export interface ConnectionResult {
14
+ id: string;
15
+ sourceDocumentId: string;
16
+ targetRef: string;
17
+ contextPhrase: string | null;
18
+ updatedAt: string;
19
+ }
20
+ export declare function createMethodologyQuery(db: Kysely<MethodologyDB>): {
21
+ allClaims(): Promise<ClaimResult[]>;
22
+ claimCount(): Promise<number>;
23
+ claimByDocumentId(documentId: string): Promise<ClaimResult | undefined>;
24
+ claimsByKind(kind: string): Promise<ClaimResult[]>;
25
+ searchClaims(query: string, limit?: number): Promise<ClaimResult[]>;
26
+ claimsByTopic(topic: string): Promise<ClaimResult[]>;
27
+ connectionsFrom(documentId: string): Promise<ConnectionResult[]>;
28
+ connectionsTo(targetRef: string): Promise<ConnectionResult[]>;
29
+ stats(): Promise<{
30
+ claimCount: number;
31
+ connectionCount: number;
32
+ kindDistribution: Record<string, number>;
33
+ }>;
34
+ };
35
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../processors/methodology-indexer/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,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