@skillre/dsh-plugin-sticky-wall 0.6.0 → 0.8.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.
package/lib/transport.js CHANGED
@@ -45,22 +45,33 @@ const layoutSchema = z
45
45
  /**
46
46
  * The clear rectangle the Client reserves around the wall's centrepiece.
47
47
  *
48
+ * The half-extents describe its SIZE and `x`/`y` its POSITION in world space: the
49
+ * centrepiece is a screen-space overlay, so on a panned or zoomed wall the patch
50
+ * of world it covers is not the origin. Omitting the position means the origin,
51
+ * which is where a freshly framed wall puts the field.
52
+ *
48
53
  * Bounds are NOT enforced here for the same reason the layout's are not: the
49
54
  * store normalizes with `normalizeReserve`, which caps an absurd value instead of
50
55
  * erroring, so a deeply zoomed-out wall still gets a wall. Non-finite values are
51
56
  * refused, because there is no sensible clamp for NaN.
52
57
  */
53
58
  const reserveSchema = z
54
- .object({ halfWidth: z.number().finite(), halfHeight: z.number().finite() })
59
+ .object({
60
+ x: z.number().finite().optional(),
61
+ y: z.number().finite().optional(),
62
+ halfWidth: z.number().finite(),
63
+ halfHeight: z.number().finite(),
64
+ })
55
65
  .strict();
56
66
  const requestSchema = z.discriminatedUnion('action', [
57
67
  z.object({ action: z.literal('list'), includeArchived: z.boolean().optional(), sort: sortSchema.optional() }).strict(),
68
+ z.object({ action: z.literal('revision') }).strict(),
58
69
  z
59
70
  .object({
60
71
  action: z.literal('create'),
61
72
  note: z
62
73
  .object({
63
- body: z.string().min(1).max(LIMITS.body),
74
+ body: z.string().max(LIMITS.body),
64
75
  title: z.string().max(LIMITS.title).optional(),
65
76
  tags: z.array(z.string().max(LIMITS.tag)).max(LIMITS.tags).optional(),
66
77
  color: colorSchema.optional(),
@@ -79,7 +90,10 @@ const requestSchema = z.discriminatedUnion('action', [
79
90
  id: idSchema,
80
91
  patch: z
81
92
  .object({
82
- body: z.string().min(1).max(LIMITS.body).optional(),
93
+ // An empty body is accepted on update: clearing the editor and saving
94
+ // must work instead of trapping the user in a validation error. Create
95
+ // still requires text, which the store enforces.
96
+ body: z.string().max(LIMITS.body).optional(),
83
97
  title: z.string().max(LIMITS.title).optional(),
84
98
  tags: z.array(z.string().max(LIMITS.tag)).max(LIMITS.tags).optional(),
85
99
  color: colorSchema.optional(),
@@ -115,7 +129,14 @@ function correlation(body) {
115
129
  async function dispatch(actions, request) {
116
130
  switch (request.action) {
117
131
  case 'list':
118
- return { notes: actions.list(request.includeArchived, request.sort) };
132
+ return {
133
+ notes: actions.list(request.includeArchived, request.sort),
134
+ revision: actions.revisionOf(),
135
+ notesDir: actions.notesDir,
136
+ domain: { name: 'sticky-wall', version: 2 },
137
+ };
138
+ case 'revision':
139
+ return { revision: actions.revisionOf() };
119
140
  case 'create':
120
141
  return { action: 'create', changed: [await actions.create(request.note, undefined, { centreReserve: request.centreReserve })], removed: [] };
121
142
  case 'update':
package/lib/types.d.ts CHANGED
@@ -11,13 +11,42 @@ export declare const ENDPOINT = "skillre-sticky-wall/execute";
11
11
  /** Sidebar panel id, main panel key, and locale namespace. */
12
12
  export declare const PANEL_ID = "skillre-sticky-wall";
13
13
  export declare const LOCALE_NAMESPACE = "skillreStickyWall";
14
- /** Storage domain name; the per-record layout gives one file per note. */
15
- export declare const DOMAIN_NAME = "skillre_sticky_wall";
16
- export declare const DOMAIN_VERSION = 1;
14
+ /**
15
+ * LEGACY storage-domain identity, kept only so the one-time migration can still
16
+ * open the JSON domain a 0.7.x install left behind.
17
+ *
18
+ * 0.8.0 moved the notes onto real `.md` files under the notes directory, so
19
+ * nothing else reads this any more. Removing it would strand an existing user's
20
+ * wall in a format the plugin can no longer name, so it stays until the
21
+ * migration is retired.
22
+ */
23
+ export declare const LEGACY_DOMAIN_NAME = "skillre_sticky_wall";
24
+ export declare const LEGACY_DOMAIN_VERSION = 1;
25
+ /** The private directory, under the DSH home, that holds one `.md` per note. */
26
+ export declare const NOTES_DIR_NAME = "sticky-notes";
27
+ /** Every note file carries this suffix; the id alone is the basename. */
28
+ export declare const NOTE_FILE_SUFFIX = ".md";
29
+ /** Marker written once, after a successful migration, beside the notes. */
30
+ export declare const MIGRATION_MARKER = "migration.json";
31
+ /**
32
+ * The frontmatter schema generation this build writes.
33
+ *
34
+ * `schema:` is a forward-compatibility marker, not a migration trigger: a file
35
+ * written by a NEWER build parses with its known keys and keeps the rest in
36
+ * `extra` rather than being silently rewritten.
37
+ */
38
+ export declare const FRONTMATTER_SCHEMA = 1;
17
39
  /** Hard limits, enforced on both halves so a bad payload never reaches storage. */
18
40
  export declare const LIMITS: Readonly<{
19
- /** One note's body, in characters. */
20
- body: 4000;
41
+ /**
42
+ * One note's body, in characters.
43
+ *
44
+ * 0.8.0 lifted the old 4000-character cap, because the body now lives in a
45
+ * plain `.md` file rather than a JSON record and a note is allowed to be a
46
+ * real document. This is a resource guard against a pathological file, not a
47
+ * product limit: at 200k characters a note is a short book.
48
+ */
49
+ body: 200000;
21
50
  /** One note's title, in characters. */
22
51
  title: 120;
23
52
  /** A note's free-form tag list. */
@@ -28,6 +57,10 @@ export declare const LIMITS: Readonly<{
28
57
  notes: 400;
29
58
  /** Note ids accepted in one request. */
30
59
  bulk: 200;
60
+ /** One note file's size on disk, in bytes; larger files are refused unread. */
61
+ fileBytes: number;
62
+ /** Newest notes the agent `list` action returns. */
63
+ listLimit: 50;
31
64
  }>;
32
65
  /** Pastel note colors the wall offers; the Client renders them as literal hex. */
33
66
  export declare const COLORS: readonly ["yellow", "pink", "green", "blue", "purple", "orange"];
@@ -66,8 +99,37 @@ export declare const CENTRE_RESERVE: Readonly<{
66
99
  halfWidth: 330;
67
100
  halfHeight: 136;
68
101
  }>;
69
- /** Half-extents of a clear rectangle around the wall's centrepiece. */
102
+ /**
103
+ * A clear rectangle around the wall's centrepiece, in WORLD pixels.
104
+ *
105
+ * The size is fixed, but the POSITION is not, and that distinction is the whole
106
+ * point. The centrepiece is a screen-space overlay: it stays at the middle of
107
+ * the viewport while the paper pans and zooms underneath it, so the patch of
108
+ * world it covers moves with the camera even though the patch keeps its size.
109
+ *
110
+ * A reserve that only carried half-extents therefore described the wrong place
111
+ * as soon as the camera moved: the Host kept the world ORIGIN clear while the
112
+ * field sat somewhere else, and a note captured from the field was placed —
113
+ * and then revealed — directly behind it. `x`/`y` are that missing position;
114
+ * they default to the origin, which is exactly where a freshly framed wall puts
115
+ * the field.
116
+ */
70
117
  export interface CentreReserve {
118
+ /** World x of the reserve's centre; defaults to the origin. */
119
+ x?: number | undefined;
120
+ /** World y of the reserve's centre; defaults to the origin. */
121
+ y?: number | undefined;
122
+ /** Half-width in world pixels. */
123
+ halfWidth: number;
124
+ /** Half-height in world pixels. */
125
+ halfHeight: number;
126
+ }
127
+ /** A reserve with its position resolved: what the geometry actually works on. */
128
+ export interface ReserveRect {
129
+ /** World x of the reserve's centre. */
130
+ x: number;
131
+ /** World y of the reserve's centre. */
132
+ y: number;
71
133
  /** Half-width in world pixels. */
72
134
  halfWidth: number;
73
135
  /** Half-height in world pixels. */
@@ -100,7 +162,7 @@ export interface NoteLayout {
100
162
  }
101
163
  /** One sticky note as stored and as sent over the wire. */
102
164
  export interface Note {
103
- /** Stable id; `crypto.randomUUID()` for locally created notes. */
165
+ /** Stable id; `crypto.randomUUID()` for locally created notes. Also the file's basename. */
104
166
  id: string;
105
167
  /** Optional short heading; the body alone is enough for a quick capture. */
106
168
  title: string;
@@ -120,21 +182,69 @@ export interface Note {
120
182
  updatedAt: string;
121
183
  /** Free-canvas placement, or `null` for a note the user never positioned. */
122
184
  layout: NoteLayout | null;
185
+ /**
186
+ * Why this note's frontmatter could not be read, when it could not.
187
+ *
188
+ * A note with a broken frontmatter block is NOT dropped and NOT rejected: the
189
+ * body still renders and the card keeps default attributes, with this message
190
+ * carried so the wall can flag it. Losing a user's note because they (or the
191
+ * model) mangled a YAML line would be far worse than showing it with the
192
+ * wrong color — this is the fail-soft contract the storage domain used to
193
+ * provide through `invalidRecords: 'backup-and-skip'`.
194
+ */
195
+ metaError?: string | undefined;
196
+ /**
197
+ * Frontmatter keys this build does not understand, preserved verbatim.
198
+ *
199
+ * A newer build may add keys, or the user may hand-add their own (a `due:`
200
+ * date, a link). Rewriting the file without them would silently destroy that
201
+ * data, so they are carried through every read/write cycle untouched.
202
+ */
203
+ extra?: Readonly<Record<string, string>> | undefined;
123
204
  }
124
205
  /** The complete wall state a Client renders. */
125
206
  export interface WallSnapshot {
126
207
  notes: Note[];
208
+ /**
209
+ * Monotonic change counter.
210
+ *
211
+ * The Client cannot be pushed to (the Connection envelope has no
212
+ * server-initiated variant), so it polls. This is what makes a poll cheap and
213
+ * SAFE: an unchanged revision means the caller must not touch component state
214
+ * at all, which is what stops a background refresh from interrupting someone
215
+ * mid-composition in the editor.
216
+ */
217
+ revision: number;
218
+ /** Absolute directory the notes live in, so the UI can reveal/copy it. */
219
+ notesDir: string;
127
220
  /** Schema marker so a Client never renders an unknown future shape. */
128
221
  domain: {
129
222
  name: string;
130
223
  version: number;
131
224
  };
132
225
  }
226
+ /** Everything the agent-side `read` action returns for one note. */
227
+ export interface NoteDocument {
228
+ note: Note;
229
+ /** Absolute path of the backing `.md` file, for native `read`/`edit`. */
230
+ path: string;
231
+ }
133
232
  /** Request kinds accepted by the Host endpoint. */
134
233
  export type WallRequest = {
135
234
  action: 'list';
136
235
  includeArchived?: boolean;
137
236
  sort?: NoteSort;
237
+ }
238
+ /**
239
+ * The cheap poll.
240
+ *
241
+ * The wall refreshes while visible, and a refresh that re-sends every note
242
+ * body just to learn that nothing changed would dominate the channel. This
243
+ * action returns the revision and the note count only; the Client refetches
244
+ * the wall solely when the number it gets back differs from what it holds.
245
+ */
246
+ | {
247
+ action: 'revision';
138
248
  } | {
139
249
  action: 'create';
140
250
  note: NoteInput;
package/lib/types.js CHANGED
@@ -11,13 +11,42 @@ export const ENDPOINT = 'skillre-sticky-wall/execute';
11
11
  /** Sidebar panel id, main panel key, and locale namespace. */
12
12
  export const PANEL_ID = 'skillre-sticky-wall';
13
13
  export const LOCALE_NAMESPACE = 'skillreStickyWall';
14
- /** Storage domain name; the per-record layout gives one file per note. */
15
- export const DOMAIN_NAME = 'skillre_sticky_wall';
16
- export const DOMAIN_VERSION = 1;
14
+ /**
15
+ * LEGACY storage-domain identity, kept only so the one-time migration can still
16
+ * open the JSON domain a 0.7.x install left behind.
17
+ *
18
+ * 0.8.0 moved the notes onto real `.md` files under the notes directory, so
19
+ * nothing else reads this any more. Removing it would strand an existing user's
20
+ * wall in a format the plugin can no longer name, so it stays until the
21
+ * migration is retired.
22
+ */
23
+ export const LEGACY_DOMAIN_NAME = 'skillre_sticky_wall';
24
+ export const LEGACY_DOMAIN_VERSION = 1;
25
+ /** The private directory, under the DSH home, that holds one `.md` per note. */
26
+ export const NOTES_DIR_NAME = 'sticky-notes';
27
+ /** Every note file carries this suffix; the id alone is the basename. */
28
+ export const NOTE_FILE_SUFFIX = '.md';
29
+ /** Marker written once, after a successful migration, beside the notes. */
30
+ export const MIGRATION_MARKER = 'migration.json';
31
+ /**
32
+ * The frontmatter schema generation this build writes.
33
+ *
34
+ * `schema:` is a forward-compatibility marker, not a migration trigger: a file
35
+ * written by a NEWER build parses with its known keys and keeps the rest in
36
+ * `extra` rather than being silently rewritten.
37
+ */
38
+ export const FRONTMATTER_SCHEMA = 1;
17
39
  /** Hard limits, enforced on both halves so a bad payload never reaches storage. */
18
40
  export const LIMITS = Object.freeze({
19
- /** One note's body, in characters. */
20
- body: 4000,
41
+ /**
42
+ * One note's body, in characters.
43
+ *
44
+ * 0.8.0 lifted the old 4000-character cap, because the body now lives in a
45
+ * plain `.md` file rather than a JSON record and a note is allowed to be a
46
+ * real document. This is a resource guard against a pathological file, not a
47
+ * product limit: at 200k characters a note is a short book.
48
+ */
49
+ body: 200_000,
21
50
  /** One note's title, in characters. */
22
51
  title: 120,
23
52
  /** A note's free-form tag list. */
@@ -28,6 +57,10 @@ export const LIMITS = Object.freeze({
28
57
  notes: 400,
29
58
  /** Note ids accepted in one request. */
30
59
  bulk: 200,
60
+ /** One note file's size on disk, in bytes; larger files are refused unread. */
61
+ fileBytes: 4 * 1024 * 1024,
62
+ /** Newest notes the agent `list` action returns. */
63
+ listLimit: 50,
31
64
  });
32
65
  /** Pastel note colors the wall offers; the Client renders them as literal hex. */
33
66
  export const COLORS = Object.freeze([
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Sticky Wall",
4
- "description": "A free-canvas note board in the DSH sidebar: drag cards into place, tidy them, and write Markdown.",
4
+ "description": "A sticky-note wall in the DSH sidebar where every note is a real Markdown file you can drag, tidy and open anywhere.",
5
5
  "detail": "docs/DETAIL.md"
6
6
  }
7
7
  }
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "便签墙",
4
- "description": "DSH 侧栏便签墙:随手记灵感与临时工作,拖动摆放、自动整理,正文支持 Markdown。",
4
+ "description": "DSH 侧栏便签墙:每张便签都是一个真正的 Markdown 文件,随手记录、拖动摆放、一键整理。",
5
5
  "detail": "docs/DETAIL.zh.md"
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillre/dsh-plugin-sticky-wall",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "便签墙:DSH 侧栏的自由画布便签板,可拖动摆放、一键整理,正文按 Markdown 渲染",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",
@@ -37,11 +37,11 @@
37
37
  "docs/DETAIL.zh.md",
38
38
  "docs/preview.svg",
39
39
  "docs/preview.zh.svg",
40
- "docs/PREVIEW.md",
41
40
  "README.md",
42
41
  "README.en.md",
43
42
  "UNINSTALL.md",
44
- "LICENSE"
43
+ "LICENSE",
44
+ "!docs/PREVIEW.md"
45
45
  ],
46
46
  "publishConfig": {
47
47
  "access": "public"
package/docs/PREVIEW.md DELETED
@@ -1,39 +0,0 @@
1
- # 预览图画板
2
-
3
- 详情页的预览图以**飞书画板**为编辑源,`docs/preview*.svg` 是它的导出快照。
4
- 本文件记录两种语言各自对应的画板,供 `node scripts/preview.mjs push|pull` 使用。
5
-
6
- > 状态:当前 `docs/preview.svg` 与 `docs/preview.zh.svg` 由手写 SVG 直接绘制,
7
- > 尚未回填到飞书画板。下表的 token 为空即表示「尚未建板」;建板后用 `push` 上传,
8
- > 再把文档 URL 与 token 填回来,此后改图走 `pull` / `push` 往返。
9
-
10
- | 语言 | 文档 | 画板 token |
11
- |---|---|---|
12
- | `en` | (待建:飞书文档 URL) | (待建:whiteboard token) |
13
- | `zh` | (待建:飞书文档 URL) | (待建:whiteboard token) |
14
-
15
- ## 操作
16
-
17
- ```sh
18
- # 把本地 SVG 推上画板(整板重建)
19
- node scripts/preview.mjs push --lang zh
20
-
21
- # 从画板导出 SVG 覆盖本地文件
22
- node scripts/preview.mjs pull --lang zh
23
-
24
- # 离线校验(npm run check 会自动调用)
25
- node scripts/preview.mjs check
26
- ```
27
-
28
- ## 画面约定
29
-
30
- 两张图必须同构,只换语言:
31
-
32
- 1. **主体**:深色画布上散落 7–9 张大小、角度不同的便签卡(六色柔和底色之一),
33
- 卡片之间刻意不排成网格 —— 这正是「自由画布」与旧版瀑布流的区别。
34
- 2. **机制**:卡内正文展示 Markdown 的真实渲染结果 —— 标题、粗体、列表、
35
- 代码块、复选清单各出现一次,说明「正文即 Markdown」。
36
- 3. **界面**:左侧栏入口、顶部搜索框与筛选 chip、画布左下角悬浮缩放控件。
37
- 4. **细节**:置顶卡的左侧色条与星标;一张卡带拖拽提示(虚线框或光标)。
38
-
39
- 规则见 fleet 的 `docs/display-contract.md`。