pi-weave 0.1.7 → 0.1.9

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 (98) hide show
  1. package/README.md +123 -37
  2. package/package.json +17 -5
  3. package/skills/weave-notepad/SKILL.md +13 -4
  4. package/src/core/cache/workspace.ts +466 -0
  5. package/src/core/concurrency.ts +36 -0
  6. package/src/core/frontmatter.ts +270 -23
  7. package/src/core/git.ts +19 -0
  8. package/src/core/graph/build.ts +97 -5
  9. package/src/core/graph/current.ts +41 -28
  10. package/src/core/graph/mentions.ts +170 -0
  11. package/src/core/graph/model.ts +39 -0
  12. package/src/core/graph/wikilinks.ts +5 -1
  13. package/src/core/index.ts +14 -0
  14. package/src/core/openInEditor.ts +69 -0
  15. package/src/core/paths.ts +7 -0
  16. package/src/core/sessions.ts +929 -0
  17. package/src/core/summaries.ts +1 -19
  18. package/src/core/types.ts +40 -0
  19. package/src/core/vault.ts +739 -57
  20. package/src/core/view/cluster.ts +262 -0
  21. package/src/core/view/detail.ts +118 -0
  22. package/src/core/view/focus.ts +109 -0
  23. package/src/core/view/health.ts +156 -0
  24. package/src/core/view/index.ts +15 -0
  25. package/src/core/view/links.ts +105 -0
  26. package/src/core/view/time.ts +47 -0
  27. package/src/core/view/tree.ts +269 -0
  28. package/src/core/view/types.ts +39 -0
  29. package/src/core/workspace.ts +3 -3
  30. package/src/pi/index.ts +248 -48
  31. package/src/pi/sessionScan.ts +104 -0
  32. package/src/pi/summarize.ts +24 -4
  33. package/src/pi/tools/noteTool.ts +13 -4
  34. package/src/pi/viewer/tui/branding.ts +8 -7
  35. package/src/pi/viewer/tui/explorer.ts +5 -3
  36. package/src/pi/viewer/tui/model.ts +46 -667
  37. package/src/pi/viewer/tui/openNote.ts +7 -56
  38. package/src/pi/viewer/tui/surface/explore.ts +4 -2
  39. package/src/pi/viewer/web/run.ts +331 -0
  40. package/src/web/client/api.dom.ts +40 -0
  41. package/src/web/client/api.ts +472 -0
  42. package/src/web/client/bootstrap.ts +58 -0
  43. package/src/web/client/context/context.model.ts +313 -0
  44. package/src/web/client/dist/app.js +764 -0
  45. package/src/web/client/graph/Graph.tsx +209 -0
  46. package/src/web/client/graph/column.model.ts +372 -0
  47. package/src/web/client/graph/dynamics.ts +176 -0
  48. package/src/web/client/graph/graph.model.ts +546 -0
  49. package/src/web/client/graph/positions.ts +380 -0
  50. package/src/web/client/graph/project.ts +153 -0
  51. package/src/web/client/graph/renderer.dom.ts +52 -0
  52. package/src/web/client/graph/renderer.ts +339 -0
  53. package/src/web/client/graph/scheme.ts +44 -0
  54. package/src/web/client/live.model.ts +275 -0
  55. package/src/web/client/live.ts +151 -0
  56. package/src/web/client/main.tsx +27 -0
  57. package/src/web/client/note/Editor.tsx +102 -0
  58. package/src/web/client/note/Note.tsx +113 -0
  59. package/src/web/client/note/editor.controller.ts +151 -0
  60. package/src/web/client/note/editor.model.ts +636 -0
  61. package/src/web/client/note/note.model.ts +738 -0
  62. package/src/web/client/search/SearchPalette.tsx +105 -0
  63. package/src/web/client/search/search.model.ts +588 -0
  64. package/src/web/client/search/search.ts +107 -0
  65. package/src/web/client/selection.storage.ts +69 -0
  66. package/src/web/client/shell/Columns.tsx +161 -0
  67. package/src/web/client/shell/ContextRail.tsx +87 -0
  68. package/src/web/client/shell/Divider.tsx +44 -0
  69. package/src/web/client/shell/FocusTrap.tsx +56 -0
  70. package/src/web/client/shell/Header.tsx +64 -0
  71. package/src/web/client/shell/HelpOverlay.tsx +70 -0
  72. package/src/web/client/shell/Shell.tsx +210 -0
  73. package/src/web/client/shell/StatusBar.tsx +28 -0
  74. package/src/web/client/shell/cssvars.ts +70 -0
  75. package/src/web/client/shell/drag.model.ts +170 -0
  76. package/src/web/client/shell/focus.model.ts +100 -0
  77. package/src/web/client/shell/keys.model.ts +453 -0
  78. package/src/web/client/shell/keys.ts +59 -0
  79. package/src/web/client/shell/layout.model.ts +526 -0
  80. package/src/web/client/shell/shell.model.ts +333 -0
  81. package/src/web/client/shell/theme.ts +490 -0
  82. package/src/web/client/shell/viewport.ts +29 -0
  83. package/src/web/client/state.ts +89 -0
  84. package/src/web/client/tree/Tree.tsx +141 -0
  85. package/src/web/client/tree/tree.model.ts +674 -0
  86. package/src/web/client/workspace.ts +278 -0
  87. package/src/web/server/page.ts +258 -0
  88. package/src/web/server/routes.ts +987 -0
  89. package/src/web/server/security.ts +361 -0
  90. package/src/web/server/server.ts +275 -0
  91. package/src/web/server/sse.ts +321 -0
  92. package/src/web/server/watcher.ts +507 -0
  93. package/src/web/shared/graph.ts +213 -0
  94. package/src/web/shared/layout.ts +314 -0
  95. package/src/web/shared/logo.ts +11 -0
  96. package/src/web/shared/metrics.ts +136 -0
  97. package/src/web/shared/view.ts +200 -0
  98. package/src/web/shared/wire.ts +358 -0
@@ -11,6 +11,7 @@
11
11
  import { createHash } from "node:crypto";
12
12
  import * as fs from "node:fs/promises";
13
13
  import { join } from "node:path";
14
+ import { mapWithConcurrency } from "./concurrency";
14
15
  import { parseFrontMatter, quoteField, unquoteField } from "./frontmatter";
15
16
  import { listFiles } from "./git";
16
17
  import { repoKnowledgeDir } from "./paths";
@@ -179,25 +180,6 @@ export function hashContent(content: string | Buffer): string {
179
180
  return createHash("sha1").update(content).digest("hex");
180
181
  }
181
182
 
182
- async function mapWithConcurrency<T, R>(
183
- items: readonly T[],
184
- concurrency: number,
185
- fn: (item: T, index: number) => Promise<R>,
186
- shouldStop?: () => boolean,
187
- ): Promise<R[]> {
188
- const results: R[] = new Array(items.length);
189
- let next = 0;
190
- async function worker(): Promise<void> {
191
- while (next < items.length) {
192
- if (shouldStop?.()) return;
193
- const i = next++;
194
- results[i] = await fn(items[i] as T, i);
195
- }
196
- }
197
- await Promise.all(Array.from({ length: Math.max(1, concurrency) }, worker));
198
- return results;
199
- }
200
-
201
183
  /**
202
184
  * Run the deep scan: summarize tracked source files into summary sidecars.
203
185
  * Incremental (content-hash skip) and failure-tolerant per file.
package/src/core/types.ts CHANGED
@@ -22,11 +22,51 @@ export interface NoteMeta {
22
22
  source: NoteSource;
23
23
  }
24
24
 
25
+ /**
26
+ * The verbatim lines of a note's front-matter block, in file order, without
27
+ * the enclosing `---` fences.
28
+ *
29
+ * This is how pi-weave keeps front matter **lossless**. `NoteMeta` names the
30
+ * five fields the engine understands; a vault is a directory of files a human
31
+ * also edits, so real notes carry keys the engine has never heard of —
32
+ * Obsidian's `aliases`, `cssclass`, `publish`, whatever the user invented last
33
+ * Tuesday. Modelling those as parsed values would mean re-emitting them, and
34
+ * re-emitting a value the parser only half-understands is how formatting (and
35
+ * then content) gets destroyed.
36
+ *
37
+ * So they are not parsed at all: the raw lines are carried through, and
38
+ * `serializeNote` replays them, substituting a freshly rendered line only for
39
+ * the keys `NoteMeta` actually owns. Unknown keys — including ones using
40
+ * syntax the subset parser cannot represent, such as block lists or folded
41
+ * scalars — come back out byte-identical, in their original order.
42
+ *
43
+ * Deliberately `readonly string[]` rather than a parsed record: a second
44
+ * representation of a line is a second thing that can disagree with the file.
45
+ * The key of a line is derived with the same rule the parser uses, at the one
46
+ * place that needs it.
47
+ */
48
+ export type NoteFrontMatter = readonly string[];
49
+
25
50
  /** A vault note: metadata plus its Markdown body. */
26
51
  export interface Note extends NoteMeta {
27
52
  /** File-name slug (no extension). Stable identity of the note. */
28
53
  slug: string;
29
54
  body: string;
55
+ /**
56
+ * The note's front-matter block as it appeared on disk, so a read → write
57
+ * round trip preserves keys outside {@link NoteMeta} (see
58
+ * {@link NoteFrontMatter}).
59
+ *
60
+ * Optional because a `Note` need not have come from a file: graph fixtures
61
+ * and in-memory projections construct one directly. Absent means "no layout
62
+ * to preserve", and `serializeNote` then emits the canonical five fields.
63
+ *
64
+ * Not carried on {@link NoteSummary}, and deliberately not on the wire: the
65
+ * browser never needs to see a user's unknown keys in order for them to
66
+ * survive, because every write path re-reads the file it is about to
67
+ * overwrite.
68
+ */
69
+ frontMatter?: NoteFrontMatter;
30
70
  }
31
71
 
32
72
  /** Summary of one note for list/search output. */