dsh-global-todo 0.12.11 → 0.12.12
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/CHANGELOG.md +15 -0
- package/lib/index.js +1 -1
- package/lib/routes.js +43 -0
- package/lib/settings.js +23 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [0.12.12] — 2026-10-21
|
|
2
|
+
|
|
3
|
+
Three more silent coercions, found by reading the settings path instead of the tests.
|
|
4
|
+
|
|
5
|
+
- **A Windows workspace exemption only covered its exact path.** `isExemptWorkspace` tested
|
|
6
|
+
`${root}/`, so `C:\dev` matched itself but not `C:\dev\sub` — an exemption that looks
|
|
7
|
+
configured and silently asks conversations it should skip. Separators are now normalized and
|
|
8
|
+
the check is case-insensitive on Windows only.
|
|
9
|
+
- **`POST /settings` no longer coerces the wrong type.** The settings store is written for a
|
|
10
|
+
hand-edited file, where `autoCollect: "true"` becoming `false` and an unknown field being
|
|
11
|
+
ignored are reasonable; over HTTP they are typos that look successful. Booleans, arrays, the
|
|
12
|
+
token and the ingest sources are now type-checked, and an unknown key is `400` naming it.
|
|
13
|
+
- **A fractional minute is refused** (`{idleMinutes: 30.5}` used to fall back to the default with
|
|
14
|
+
a 200). Same rule as every other out-of-range value.
|
|
15
|
+
|
|
1
16
|
## [0.12.11] — 2026-10-21
|
|
2
17
|
|
|
3
18
|
One more silent fallback, found while re-reading the settings path.
|
package/lib/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import { createStore, resolveStorePath } from './store.js'
|
|
|
37
37
|
import { createTools } from './tools.js'
|
|
38
38
|
|
|
39
39
|
/** Must equal `package.json`'s version; `npm run check` enforces that. */
|
|
40
|
-
export const VERSION = '0.12.
|
|
40
|
+
export const VERSION = '0.12.12'
|
|
41
41
|
|
|
42
42
|
/** Plugin id. Also the Loader row id in `cordis.patch.yml`. */
|
|
43
43
|
export const name = 'dsh-global-todo'
|
package/lib/routes.js
CHANGED
|
@@ -28,6 +28,7 @@ import path from 'node:path'
|
|
|
28
28
|
import { TodoError, asTodoError } from './errors.js'
|
|
29
29
|
import { MAX_INGEST_ITEMS } from './ingest.js'
|
|
30
30
|
import { fromMarkdown, toMarkdown } from './markdown.js'
|
|
31
|
+
import { INGEST_SOURCES } from './settings.js'
|
|
31
32
|
import { weeklyReport } from './report.js'
|
|
32
33
|
|
|
33
34
|
/** Route prefix. The client appends this to the document base. */
|
|
@@ -535,6 +536,7 @@ export function createRoutes(deps) {
|
|
|
535
536
|
// The settings store clamps silently, which is right for a hand-edited file and wrong
|
|
536
537
|
// for an API: `{idleMinutes: -5}` answering 200-but-5 hides the rejected intent. A
|
|
537
538
|
// provided value outside its range is reported instead.
|
|
539
|
+
assertSettingsShape(body ?? {})
|
|
538
540
|
assertSettingsRange(body ?? {})
|
|
539
541
|
const next = await deps.settings.update(body ?? {})
|
|
540
542
|
return {
|
|
@@ -735,6 +737,47 @@ export function createRoutes(deps) {
|
|
|
735
737
|
]
|
|
736
738
|
}
|
|
737
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Types the settings route insists on, because the store coerces instead of rejecting.
|
|
742
|
+
*
|
|
743
|
+
* \`normalizeSettings\` is written for a hand-edited file: \`autoCollect: "true"\` becomes
|
|
744
|
+
* false, an unknown source is dropped, a typo silently changes nothing. That is the right
|
|
745
|
+
* behaviour when reading a file and the wrong behaviour for a request.
|
|
746
|
+
*
|
|
747
|
+
* @param {Record<string, unknown>} body
|
|
748
|
+
*/
|
|
749
|
+
function assertSettingsShape(body) {
|
|
750
|
+
const known = ['autoCollect', 'idleMinutes', 'cooldownMinutes', 'exemptWorkspaces', 'ingestEnabled', 'ingestSources', 'ingestConfirmBelow', 'ingestToken', 'remindersEnabled', 'reminderLeadMinutes']
|
|
751
|
+
for (const key of Object.keys(body)) {
|
|
752
|
+
if (!known.includes(key)) {
|
|
753
|
+
throw new TodoError('invalid-body', '未知的设置项 ' + key + ';可写的是 ' + known.join(' / '))
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
for (const field of ['autoCollect', 'ingestEnabled', 'remindersEnabled']) {
|
|
757
|
+
const value = body[field]
|
|
758
|
+
if (value !== undefined && typeof value !== 'boolean') {
|
|
759
|
+
throw new TodoError('invalid-body', field + ' 必须是 true / false,收到 ' + JSON.stringify(value))
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (body.ingestToken !== undefined && typeof body.ingestToken !== 'string') {
|
|
763
|
+
throw new TodoError('invalid-body', 'ingestToken 必须是字符串')
|
|
764
|
+
}
|
|
765
|
+
if (body.exemptWorkspaces !== undefined) {
|
|
766
|
+
if (!Array.isArray(body.exemptWorkspaces) || body.exemptWorkspaces.some((entry) => typeof entry !== 'string')) {
|
|
767
|
+
throw new TodoError('invalid-body', 'exemptWorkspaces 必须是字符串数组')
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
if (body.ingestSources !== undefined) {
|
|
771
|
+
if (!Array.isArray(body.ingestSources)) {
|
|
772
|
+
throw new TodoError('invalid-body', 'ingestSources 必须是数组')
|
|
773
|
+
}
|
|
774
|
+
const bad = body.ingestSources.filter((entry) => typeof entry !== 'string' || !INGEST_SOURCES.includes(entry))
|
|
775
|
+
if (bad.length > 0) {
|
|
776
|
+
throw new TodoError('invalid-body', 'ingestSources 只能是 ' + INGEST_SOURCES.join(' / ') + ',收到 ' + bad.join(', '))
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
738
781
|
/**
|
|
739
782
|
* Ranges the settings route refuses, mirroring the clamps in `normalizeSettings`.
|
|
740
783
|
*
|
package/lib/settings.js
CHANGED
|
@@ -145,12 +145,31 @@ export function normalizeSettings(raw) {
|
|
|
145
145
|
* @param {string[]} exemptWorkspaces
|
|
146
146
|
* @returns {boolean}
|
|
147
147
|
*/
|
|
148
|
+
/**
|
|
149
|
+
* One separator for comparisons, whatever the platform wrote.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} value
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
function normalizeSeparators(value) {
|
|
155
|
+
return value.replace(/\\/g, '/')
|
|
156
|
+
}
|
|
148
157
|
export function isExemptWorkspace(sessionDir, exemptWorkspaces) {
|
|
149
158
|
if (typeof sessionDir !== 'string' || sessionDir === '') return false
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
)
|
|
159
|
+
// Compare on one separator: a Windows exemption of `C:\\dev` has to cover `C:\\dev\\sub`,
|
|
160
|
+
// and the old `${root}/` test made that false there while the exact match still worked —
|
|
161
|
+
// a half-working exemption is worse than none, because it looks configured.
|
|
162
|
+
const dir = normalizeSeparators(sessionDir).replace(/\/+$/, '')
|
|
163
|
+
const inWindows = process.platform === 'win32'
|
|
164
|
+
return (Array.isArray(exemptWorkspaces) ? exemptWorkspaces : []).some((root) => {
|
|
165
|
+
if (typeof root !== 'string' || root === '') return false
|
|
166
|
+
const base = normalizeSeparators(root).replace(/\/+$/, '')
|
|
167
|
+
const same = inWindows ? dir.toLowerCase() === base.toLowerCase() : dir === base
|
|
168
|
+
const inside = inWindows
|
|
169
|
+
? dir.toLowerCase().startsWith(`${base.toLowerCase()}/`)
|
|
170
|
+
: dir.startsWith(`${base}/`)
|
|
171
|
+
return same || inside
|
|
172
|
+
})
|
|
154
173
|
}
|
|
155
174
|
|
|
156
175
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-global-todo",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.12",
|
|
4
4
|
"icon": "./docs/icon.svg",
|
|
5
5
|
"description": "Cross-session todo list for DeepSeek Harness: one JSON file a person and an agent both write to, with step plans that ship as a numbered hand-off, session read-back, and a human confirmation before an agent's \"done\" counts.",
|
|
6
6
|
"type": "module",
|