@dybai/dsh-editor 0.5.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/index.js CHANGED
@@ -7,20 +7,25 @@
7
7
  * Remote marker on the prototype make the Typert Gateway's conservative SRC
8
8
  * discovery claim `dshEditor/writeFile`, `dshEditor/getModePreferences`,
9
9
  * `dshEditor/setModePreferences`, `dshEditor/getKeymap`,
10
- * `dshEditor/setKeymap`, `dshEditor/getSettings` and
11
- * `dshEditor/setSettings`, so no generated Typert artifacts are needed.
10
+ * `dshEditor/setKeymap`, `dshEditor/getSettings`,
11
+ * `dshEditor/setSettings` and `dshEditor/appendLogs` (the client log
12
+ * channel's flush endpoint), so no generated Typert artifacts are needed.
12
13
  *
13
14
  * Deliberately imports no `@deepseek-ai/*` package: every capability comes
14
- * from the Cordis context (`fs`, `sandboxPolicy`, `sessions`, `storage`), so
15
- * the bundle loads under any profile node_modules layout. The service bodies
16
- * live in `host/write-service.js` and `host/preferences-service.js` and are
17
- * composed here onto one prototype that carries all five Remote markers.
15
+ * from the Cordis context (`fs`, `sandboxPolicy`, `sessions`, `storage`),
16
+ * so the bundle loads under any profile node_modules layout. The service
17
+ * bodies live in `host/write-service.js`, `host/preferences-service.js` and
18
+ * `host/log-service.js` and are composed here onto one prototype that
19
+ * carries all eight Remote markers; the log service's exporter is also
20
+ * registered on `ctx.logger` inside the effect so this plugin's own Host
21
+ * records persist through the same chain.
18
22
  *
19
23
  * @module @dybai/dsh-editor
20
24
  */
21
25
 
22
26
  import { createFileService } from './host/write-service.js';
23
27
  import { createPreferencesService } from './host/preferences-service.js';
28
+ import { createLogService } from './host/log-service.js';
24
29
 
25
30
  /** Cordis service key and wire namespace of the editor Host service. */
26
31
  const SERVICE_KEY = 'dshEditor';
@@ -105,6 +110,10 @@ function resolveKvFacet(storage) {
105
110
  * @returns the effect disposer cordis owns.
106
111
  */
107
112
  export function apply(ctx) {
113
+ // Named Host logger for this plugin's own records. A context without a
114
+ // logger degrades silently — the iron rule: logging must never break apply.
115
+ const hostLog = typeof ctx.logger === 'function' ? ctx.logger('dsh-editor') : null;
116
+ hostLog?.info('lifecycle', 'host apply begin');
108
117
  const fs = ctx.get('fs');
109
118
  if (fs === undefined || typeof fs.resolve !== 'function' || typeof fs.writeText !== 'function') {
110
119
  throw new Error('dsh-editor: the Host filesystem service with resolve/writeText is unavailable');
@@ -121,7 +130,22 @@ export function apply(ctx) {
121
130
 
122
131
  const files = createFileService(fs, sandboxPolicy, sessions);
123
132
  const preferences = createPreferencesService({ kv, now: Date.now });
124
- // One wire service: exactly the seven Remote-marked methods on one
133
+ // Same shared KV facet, its own unit (opened per-descriptor): the
134
+ // persistent log store behind `appendLogs` and the ctx.logger exporter.
135
+ // Rotation anomalies are plugin-observable events, so their `warn` routes
136
+ // through the named logger and persists (spec §7.2 打点); the module's own
137
+ // failures stay on `report.error` → console only (spec §8: they must never
138
+ // re-enter the channel — the exporter's re-entrancy guard keeps the warn
139
+ // routing loop-safe).
140
+ const logService = createLogService({
141
+ kv,
142
+ now: Date.now,
143
+ report: {
144
+ warn: (msg) => (hostLog !== null ? hostLog.warn('logs', msg) : console.warn('[dsh-editor]', msg)),
145
+ error: console.error.bind(console)
146
+ }
147
+ });
148
+ // One wire service: exactly the eight Remote-marked methods on one
125
149
  // prototype, each delegating to its factory's closure.
126
150
  const service = Object.create({
127
151
  writeFile: files.writeFile,
@@ -130,7 +154,8 @@ export function apply(ctx) {
130
154
  getKeymap: preferences.getKeymap,
131
155
  setKeymap: preferences.setKeymap,
132
156
  getSettings: preferences.getSettings,
133
- setSettings: preferences.setSettings
157
+ setSettings: preferences.setSettings,
158
+ appendLogs: (entries) => logService.appendEntries(entries)
134
159
  });
135
160
  const prototype = Object.getPrototypeOf(service);
136
161
  const markerKey = remoteMarkerKey(ctx);
@@ -163,20 +188,32 @@ export function apply(ctx) {
163
188
  Object.freeze({
164
189
  method: 'setSettings',
165
190
  invocation: Object.freeze({ kind: 'direct' })
191
+ }),
192
+ Object.freeze({
193
+ method: 'appendLogs',
194
+ invocation: Object.freeze({ kind: 'direct' })
166
195
  })
167
196
  ])
168
197
  })
169
198
  });
170
199
  service.typertRemote = Object.freeze({ service, serviceKey: SERVICE_KEY, namespace: SERVICE_KEY });
171
200
 
172
- return ctx.effect(() => {
201
+ const effect = ctx.effect(() => {
173
202
  const disposeProvide = ctx.provide(SERVICE_KEY, service);
203
+ // Funnel this plugin's own named Host logger records into the same
204
+ // persistent store. cordis's `exporter()` registers via `ctx.effect`
205
+ // and returns a bare callable effect disposer (no `.dispose`); the
206
+ // fiber owns that registration, so disposal covers exporter removal.
207
+ ctx.logger.exporter(logService.createExporter({ loggerName: 'dsh-editor' }));
174
208
  return () => {
175
209
  disposeProvide();
176
- // Release the KV unit so a fiber restart never trips the storage
210
+ // Release the KV units so a fiber restart never trips the storage
177
211
  // contract's "same unit opened twice" rejection; failure here must
178
212
  // not break disposal.
179
213
  preferences.close().catch(() => {});
214
+ logService.close().catch(() => {});
180
215
  };
181
216
  }, 'dsh-editor: workspace file-write and preference services');
217
+ hostLog?.info('lifecycle', 'host apply complete');
218
+ return effect;
182
219
  }
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "File editor",
4
- "description": "Makes text files in the side pane editable: open a file, edit it in place, and save back to disk with Ctrl+S (rebindable from the status-bar keyboard icon), with stale-version conflict prompts and reload; external modifications and deletions are detected and surfaced."
4
+ "description": "Makes text files in the side pane editable: open a file, edit it in place, and save back to disk with Ctrl+S (rebindable from the status-bar keyboard icon), jump to a line with Ctrl+G, with stale-version conflict prompts and reload; external modifications and deletions are detected and surfaced."
5
5
  },
6
6
  "action": {
7
7
  "save": "Save",
@@ -54,16 +54,26 @@
54
54
  "save": "Save",
55
55
  "saveAll": "Save all",
56
56
  "deleteLines": "Delete lines",
57
+ "gotoLine": "Go to line",
57
58
  "record": "Record",
58
59
  "recording": "Press the new combo… (Esc to cancel)",
59
60
  "reset": "Restore defaults",
60
- "resetTitle": "Restore the default keys (Ctrl+S / Ctrl+Shift+S / Ctrl+D)",
61
+ "resetTitle": "Restore the default keys (Ctrl+S / Ctrl+Shift+S / Ctrl+D / Ctrl+G)",
61
62
  "duplicate": "That combo is already used by another action; pick another one.",
62
63
  "reserved": "This combination is reserved by the browser (e.g. close/new tab) and cannot be recorded",
63
64
  "reservedHint": "Browser-reserved combos (Ctrl/⌘+W, T, N, Q, …) cannot be recorded",
64
65
  "writeFailed": "Failed to save shortcuts",
65
66
  "conflict": "Shortcuts changed elsewhere; reloaded, please retry."
66
67
  },
68
+ "goto": {
69
+ "title": "Go to line",
70
+ "context": "Ln {line} of {max}",
71
+ "placeholder": "Line (1–{max})",
72
+ "jump": "Go",
73
+ "jumpTitle": "Jump to the entered line (Enter)",
74
+ "invalid": "Enter a line between 1 and {max}",
75
+ "loading": "Loading the file…"
76
+ },
67
77
  "external": {
68
78
  "modified": "The file was modified externally. Reload it?",
69
79
  "deleted": "The file was deleted externally. Close this tab?",
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "文件编辑器",
4
- "description": "让分栏里的文本文件可以直接编辑:打开文件就地修改并保存到磁盘(Ctrl+S,可在状态栏键盘图标中改键),带版本冲突提示与重新加载;文件被外部修改或删除时主动提示。"
4
+ "description": "让分栏里的文本文件可以直接编辑:打开文件就地修改并保存到磁盘(Ctrl+S,可在状态栏键盘图标中改键),Ctrl+G 跳转到指定行,带版本冲突提示与重新加载;文件被外部修改或删除时主动提示。"
5
5
  },
6
6
  "action": {
7
7
  "save": "保存",
@@ -54,16 +54,26 @@
54
54
  "save": "保存",
55
55
  "saveAll": "保存全部",
56
56
  "deleteLines": "删行",
57
+ "gotoLine": "跳转到行",
57
58
  "record": "录制",
58
59
  "recording": "按下新组合…(Esc 取消)",
59
60
  "reset": "恢复默认",
60
- "resetTitle": "把三个动作的键位恢复为默认(Ctrl+S / Ctrl+Shift+S / Ctrl+D)",
61
+ "resetTitle": "把四个动作的键位恢复为默认(Ctrl+S / Ctrl+Shift+S / Ctrl+D / Ctrl+G)",
61
62
  "duplicate": "该组合已被其他动作占用,请换一个组合。",
62
63
  "reserved": "该组合被浏览器保留(如关闭/新建标签页),无法录制",
63
64
  "reservedHint": "浏览器保留组合(Ctrl/⌘+W、T、N、Q 等)无法录制",
64
65
  "writeFailed": "保存快捷键失败",
65
66
  "conflict": "快捷键已被其他位置修改,已重新读取,请重试。"
66
67
  },
68
+ "goto": {
69
+ "title": "跳转到行",
70
+ "context": "当前 {line} 行 · 共 {max} 行",
71
+ "placeholder": "行号(1–{max})",
72
+ "jump": "跳转",
73
+ "jumpTitle": "跳转到输入的行(Enter)",
74
+ "invalid": "请输入 1–{max} 之间的行号",
75
+ "loading": "正在加载文件…"
76
+ },
67
77
  "external": {
68
78
  "modified": "文件已被外部修改。是否重新加载?",
69
79
  "deleted": "文件已被外部删除。是否关闭页签?",
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dybai/dsh-editor",
3
- "version": "0.5.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "test": "node --test src/**/*.test.js host/**/*.test.js",
6
+ "test": "node --test index.test.js src/**/*.test.js host/**/*.test.js",
7
7
  "build": "node scripts/build.mjs"
8
8
  },
9
9
  "description": "Edit workspace text files in place: an extension tab type takes over session file addresses with a save/reload editor backed by a Host file-write service",
@@ -17,6 +17,8 @@
17
17
  "index.js",
18
18
  "host/write-service.js",
19
19
  "host/preferences-service.js",
20
+ "host/log-service.js",
21
+ "host/log-serialize.js",
20
22
  "client.js",
21
23
  "cordis.patch.yml",
22
24
  "locale/en.json",