icex-dsh-memory 0.2.3 → 0.2.4

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 (3) hide show
  1. package/client.js +23 -3
  2. package/index.js +11 -4
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -23,6 +23,7 @@ window.__ModuleLoader__.load({
23
23
  'settings.scope.project': 'Project',
24
24
  'settings.dir.label': 'Working directory',
25
25
  'settings.dir.placeholder': '/Users/me/codes/project',
26
+ 'settings.dir.hint': 'Absolute path, or start with ~/ . The file is <dir>/.dsh/memory/MEMORY.md.',
26
27
  'settings.dir.load': 'Load',
27
28
  'settings.loading': 'Loading…',
28
29
  'settings.saving': 'Saving…',
@@ -43,6 +44,7 @@ window.__ModuleLoader__.load({
43
44
  'settings.scope.global': '全局',
44
45
  'settings.scope.project': '项目',
45
46
  'settings.dir.label': '工作目录',
47
+ 'settings.dir.hint': '绝对路径,可用 ~/ 开头。文件是 <目录>/.dsh/memory/MEMORY.md。',
46
48
  'settings.dir.placeholder': '/Users/me/codes/project',
47
49
  'settings.dir.load': '读取',
48
50
  'settings.loading': '读取中…',
@@ -98,7 +100,13 @@ window.__ModuleLoader__.load({
98
100
  function MemoryPanel(props) {
99
101
  const t = translator(props.t)
100
102
  const [scope, setScope] = useState('global')
101
- const [dir, setDir] = useState('')
103
+ const [dir, setDir] = useState(function () {
104
+ try {
105
+ return window.localStorage.getItem('icex-memory.projectDir') ?? ''
106
+ } catch (error) {
107
+ return ''
108
+ }
109
+ })
102
110
  const [text, setText] = useState('')
103
111
  const [path, setPath] = useState('')
104
112
  const [entries, setEntries] = useState(0)
@@ -112,9 +120,20 @@ window.__ModuleLoader__.load({
112
120
  }
113
121
 
114
122
  async function load() {
123
+ if (scope === 'project' && dir.trim() === '') {
124
+ setMessage(null)
125
+ return
126
+ }
115
127
  setBusy(true)
116
128
  setMessage(null)
117
129
  try {
130
+ if (scope === 'project') {
131
+ try {
132
+ window.localStorage.setItem('icex-memory.projectDir', dir.trim())
133
+ } catch (error) {
134
+ // A blocked localStorage only costs the remembered directory.
135
+ }
136
+ }
118
137
  const response = await fetch(endpoint(), { credentials: 'same-origin' })
119
138
  const body = await response.json()
120
139
  if (body.ok !== true) throw new Error(body.error ?? response.status)
@@ -186,7 +205,7 @@ window.__ModuleLoader__.load({
186
205
  setDir(event.target.value)
187
206
  },
188
207
  onKeyDown: function (event) {
189
- if (event.key === 'Enter') void load()
208
+ if (event.key === 'Enter' && event.currentTarget.value.trim() !== '') void load()
190
209
  },
191
210
  }),
192
211
  h('button', {
@@ -196,7 +215,8 @@ window.__ModuleLoader__.load({
196
215
  onClick: function () {
197
216
  void load()
198
217
  },
199
- }, t('settings.dir.load')))
218
+ }, t('settings.dir.load')),
219
+ h('div', { className: 'icex-memory-hint' }, t('settings.dir.hint')))
200
220
  : null,
201
221
  h('textarea', {
202
222
  className: 'icex-memory-text',
package/index.js CHANGED
@@ -429,12 +429,19 @@ function jsonResponse(body, status = 200) {
429
429
  }
430
430
 
431
431
  /** Resolve the store file named by the editor's query string. */
432
+ /** Expand a leading ~/ so the settings page can take a home-relative path. */
433
+ function expandHome(dir) {
434
+ if (dir === '~') return homedir()
435
+ if (dir.startsWith('~/')) return join(homedir(), dir.slice(2))
436
+ return dir
437
+ }
438
+
432
439
  function editorTarget(params) {
433
440
  if (params.get('scope') !== 'project') return { scope: 'global', file: GLOBAL_FILE }
434
- const dir = params.get('dir') ?? ''
435
- if (!dir.startsWith('/')) return { scope: 'project', error: 'project scope needs an absolute directory' }
436
- if (!existsSync(dir)) return { scope: 'project', error: 'directory does not exist' }
437
- return { scope: 'project', file: projectFile(dir) }
441
+ const dir = expandHome(String(params.get('dir') ?? '').trim())
442
+ if (!dir.startsWith('/')) return { scope: 'project', error: 'project scope needs an absolute directory (a leading ~/ works)' }
443
+ if (!existsSync(dir)) return { scope: 'project', error: 'directory does not exist: ' + dir }
444
+ return { scope: 'project', dir, file: projectFile(dir) }
438
445
  }
439
446
 
440
447
  /** GET reads a store, POST replaces it; both are owner-only by the route registry. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icex-dsh-memory",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "description": "Cross-session memory for DeepSeek Harness: a budgeted MEMORY.md digest injected once per session, plus one memory tool with provenance back to the producing session.",
6
6
  "exports": {