@6starlong/dsh-disk-cleanup 0.0.0-stage → 0.4.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.
package/lib/cleanup.js ADDED
@@ -0,0 +1,207 @@
1
+ /**
2
+ * 临时目录的清理:scratch 的过期条目,以及残留的空目录。
3
+ *
4
+ * 只删 scratch 自己的条目:临时文件都是「写完就不再需要」的一次性产物,
5
+ * 删掉不会影响工作区里的项目。
6
+ * 空目录清理只认「目录为空」,不猜是谁留下的,也不删有内容的目录。
7
+ * @module dsh-disk-cleanup/cleanup
8
+ */
9
+ import { lstat, readdir, rm, rmdir, stat } from 'node:fs/promises'
10
+ import { join } from 'node:path'
11
+
12
+ /** 一天有多少毫秒。 */
13
+ const DAY_MS = 24 * 60 * 60 * 1000
14
+
15
+ /** 启动之后自动清理的最小间隔。 */
16
+ export const CLEANUP_INTERVAL_MS = 6 * 60 * 60 * 1000
17
+
18
+ /**
19
+ * 算出某个时刻的过期分界线。
20
+ *
21
+ * 用「条目自己的最后修改时间」判断,不用访问时间:Windows 默认关闭最后访问时间的
22
+ * 更新,读过的文件会一直显示成很久没动过。
23
+ * @param {number} maxAgeDays - 保留天数。
24
+ * @param {number} [now] - 参照时刻(毫秒)。
25
+ * @returns {number} 早于这个时刻的条目该删。
26
+ */
27
+ export function cutoffTime(maxAgeDays, now = Date.now()) {
28
+ return now - maxAgeDays * DAY_MS
29
+ }
30
+
31
+ /**
32
+ * 列出目录下的直接条目(不看内容)。
33
+ * @param {string} dir - 目录绝对路径。
34
+ * @returns {Promise<Array<{name: string, path: string, directory: boolean, mtimeMs: number}>>} 条目列表。
35
+ */
36
+ async function listEntries(dir) {
37
+ const names = await readdir(dir)
38
+ const entries = []
39
+ for (const name of names) {
40
+ const path = join(dir, name)
41
+ try {
42
+ const info = await stat(path)
43
+ entries.push({ name, path, directory: info.isDirectory(), mtimeMs: info.mtimeMs })
44
+ } catch {
45
+ /* 单个条目读不到就跳过,不影响整批 */
46
+ }
47
+ }
48
+ return entries
49
+ }
50
+
51
+ /**
52
+ * 清掉 scratch 目录里超过保留期的条目。
53
+ *
54
+ * 只删顶层条目,且只删「条目本身最后一次改动早于分界线」的:目录里某个子文件
55
+ * 刚被写过,目录的修改时间会一并刷新,正在用的工作目录不会被误删。
56
+ * 单个条目删不掉(Windows 上文件被别的进程占着)就跳过,不中断整批。
57
+ * @param {object} options - 清理输入。
58
+ * @param {string} options.dir - scratch 目录。
59
+ * @param {number} options.maxAgeDays - 保留天数。
60
+ * @param {boolean} [options.dryRun] - 只统计不删除。
61
+ * @param {number} [options.now] - 参照时刻(毫秒),测试用。
62
+ * @returns {Promise<{removed: number, failed: number, kept: number}>} 统计结果;目录不存在时全为 0。
63
+ */
64
+ export async function cleanScratch({ dir, maxAgeDays, dryRun = false, now = Date.now() }) {
65
+ const result = { removed: 0, failed: 0, kept: 0 }
66
+ if (typeof dir !== 'string' || dir === '') return result
67
+ let entries
68
+ try {
69
+ entries = await listEntries(dir)
70
+ } catch (error) {
71
+ // 目录不存在是常态(还没人写过临时文件),其余错误要知道,否则清理会静默失效。
72
+ if (error?.code === 'ENOENT') return result
73
+ result.failed += 1
74
+ return result
75
+ }
76
+ const cutoff = cutoffTime(maxAgeDays, now)
77
+ for (const entry of entries) {
78
+ if (entry.mtimeMs >= cutoff) {
79
+ result.kept += 1
80
+ continue
81
+ }
82
+ if (dryRun) {
83
+ result.removed += 1
84
+ continue
85
+ }
86
+ try {
87
+ await rm(entry.path, { recursive: true, force: true })
88
+ result.removed += 1
89
+ } catch {
90
+ result.failed += 1
91
+ }
92
+ }
93
+ return result
94
+ }
95
+
96
+ /**
97
+ * 建一个「按间隔节流」的执行器:调用 execute 时,距离上次真正执行不足间隔就跳过。
98
+ *
99
+ * 不用常驻定时器:插件每次加载先跑一次,之后由调用方的周期触发兜底,
100
+ * 进程重启也只会重新跑一次,不会因为错过时间点堆起补偿。
101
+ * @param {number} intervalMs - 最小间隔(毫秒)。
102
+ * @returns {(run: () => Promise<unknown>) => Promise<boolean>} 执行器;真的执行了返回 true。
103
+ */
104
+ export function throttled(intervalMs) {
105
+ let last = 0
106
+ let running = false
107
+ return async (run) => {
108
+ if (running) return false
109
+ const now = Date.now()
110
+ if (last !== 0 && now - last < intervalMs) return false
111
+ running = true
112
+ last = now
113
+ try {
114
+ await run()
115
+ return true
116
+ } finally {
117
+ running = false
118
+ }
119
+ }
120
+ }
121
+
122
+ /**
123
+ * 清掉目录下的空目录,只删「一个条目都没有」的目录。
124
+ *
125
+ * recursive 为真时自底向上:空的子目录先删,父目录因此变空后一并删;
126
+ * 为假时只看直接子目录,不往里走。两种都不删 dir 本身。
127
+ * 用 rmdir 而不是 rm:目录此刻若被写入了内容,rmdir 会失败,不会连内容一起删。
128
+ * @param {object} options - 清理输入。
129
+ * @param {string} options.dir - 待清理的目录根。
130
+ * @param {boolean} [options.recursive] - 是否递归进子目录。
131
+ * @param {boolean} [options.dryRun] - 只统计不删除。
132
+ * @returns {Promise<{removed: number, failed: number, kept: number}>} 统计结果;目录不存在时全为 0。
133
+ */
134
+ export async function cleanEmptyDirs({ dir, recursive = false, dryRun = false }) {
135
+ const result = { removed: 0, failed: 0, kept: 0 }
136
+ if (typeof dir !== 'string' || dir === '') return result
137
+ await pruneChildren(dir, recursive, dryRun, result)
138
+ return result
139
+ }
140
+
141
+ /**
142
+ * 删掉 dir 下所有空的子目录,返回 dir 清理后是否也空了。
143
+ *
144
+ * 返回值一路往上传,dryRun 下也能算出「子目录删掉后父目录跟着变空」的连锁,
145
+ * 而不是只看目录此刻的内容。
146
+ * @param {string} dir - 当前层目录。
147
+ * @param {boolean} recursive - 是否继续往子目录里走。
148
+ * @param {boolean} dryRun - 只统计不删除。
149
+ * @param {{removed: number, failed: number, kept: number}} result - 累计统计。
150
+ * @returns {Promise<boolean>} dir 清理后是否为空;读不到时按非空处理。
151
+ */
152
+ async function pruneChildren(dir, recursive, dryRun, result) {
153
+ let names
154
+ try {
155
+ names = await readdir(dir)
156
+ } catch (error) {
157
+ if (error?.code !== 'ENOENT') result.failed += 1
158
+ return false
159
+ }
160
+ let hasContent = false
161
+ for (const name of names) {
162
+ const target = join(dir, name)
163
+ let info
164
+ try {
165
+ info = await lstat(target)
166
+ } catch {
167
+ hasContent = true
168
+ continue
169
+ }
170
+ // 符号链接和 junction 不进也不删,否则会递归到别的目录树里。
171
+ if (!info.isDirectory() || info.isSymbolicLink()) {
172
+ hasContent = true
173
+ continue
174
+ }
175
+ let empty
176
+ if (recursive) {
177
+ empty = await pruneChildren(target, true, dryRun, result)
178
+ } else {
179
+ let left
180
+ try {
181
+ left = await readdir(target)
182
+ empty = left.length === 0
183
+ } catch {
184
+ hasContent = true
185
+ result.kept += 1
186
+ continue
187
+ }
188
+ }
189
+ if (!empty) {
190
+ hasContent = true
191
+ result.kept += 1
192
+ continue
193
+ }
194
+ if (dryRun) {
195
+ result.removed += 1
196
+ continue
197
+ }
198
+ try {
199
+ await rmdir(target)
200
+ result.removed += 1
201
+ } catch {
202
+ result.failed += 1
203
+ hasContent = true
204
+ }
205
+ }
206
+ return !hasContent
207
+ }
package/lib/client.js ADDED
@@ -0,0 +1,194 @@
1
+ // 由 scripts/build.mjs 生成,不要手改。
2
+ window.__ModuleLoader__.load({
3
+ id: "@6starlong/dsh-disk-cleanup",
4
+ factory: function (require) {
5
+ var module = { exports: {} };
6
+ var exports = module.exports;
7
+ // ---- index.jsx ----
8
+ /**
9
+ * dsh-disk-cleanup 的浏览器半边:「过期清理」配置卡片。
10
+ *
11
+ * 宿主按 schema 自动生成的表单只有字段、没有说明与文案,所以宿主侧关掉自动表单
12
+ * (见 lib/index.js 的 settings.configure),由本文件在 plugins.bundle.config 槽里
13
+ * 渲染一张自己的卡片。
14
+ *
15
+ * 槽位 key 与配置表单的命名空间都用包名:宿主按包名判断插件详情页要不要出配置区,
16
+ * 也按同名的 profile 条目读配置。
17
+ *
18
+ * 这张卡片只碰 autoCleanup(是否自动清理)与 cleanupMaxAgeDays(保留天数)两个
19
+ * volatile 字段,其余字段仍走 cordis.patch.yml。
20
+ *
21
+ * @module dsh-disk-cleanup/client
22
+ */
23
+ const { Switch, SettingsForm, SettingsFormModel, settingsNumberField, SettingsValueField } = require("@deepseek-ai/dsh-client-ui-primitives")
24
+ const { jsx, jsxs } = require("react/jsx-runtime")
25
+ /*
26
+ * 客户端插件的身份(name / inject)由入口在 factory 里挂到 module.exports 上:
27
+ * 宿主 ModuleLoader 读的就是这个导出对象,闭包产物里不能写 export。
28
+ */
29
+
30
+ /** 包名:既是 plugins.bundle.config 的槽位 key,也是配置表单的命名空间。 */
31
+ const PLUGIN_PACKAGE = '@6starlong/dsh-disk-cleanup'
32
+ /** 本地化命名空间。 */
33
+ const NS = 'settings.diskCleanup'
34
+
35
+ /** 保留天数默认值,与 lib/config.js 的 schema 默认值保持一致;输入框留空时置灰显示。 */
36
+ const DEFAULT_MAX_AGE_DAYS = '3'
37
+
38
+ /** 卡片里最小的必要样式:开关行左右排布、说明文字弱化。 */
39
+ const STYLE = {
40
+ row: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '12px' },
41
+ label: { fontWeight: 600 },
42
+ hint: { margin: '4px 0 12px', opacity: 0.7, fontSize: '12px' },
43
+ }
44
+
45
+ /** 文案。宿主界面是中文,随宿主语言只给一份中文。 */
46
+ const MESSAGES = {
47
+ zh: {
48
+ title: '过期清理',
49
+ description: '自动清理过期临时文件、请求图片缓存与无主附件残留,并清掉残留空目录。',
50
+ on: '开启后按保留天数清理临时文件与图片缓存,回收无主原件,并清掉残留空目录。',
51
+ off: '关闭后不再自动清理。',
52
+ maxAge: '保留天数',
53
+ maxAgeHint: '临时文件和图片缓存,超过这个天数没改动就清掉;原始图片只有确认没有引用时才会删。',
54
+ invalid: '请填一个正整数,或留空使用默认值。',
55
+ overridden: '已覆盖',
56
+ reset: '恢复默认',
57
+ save: '保存',
58
+ saving: '保存中…',
59
+ saveFailed: '宿主没有接受这些值,已保留以便重试。',
60
+ readonly: '当前配置为只读,无法修改。',
61
+ unavailable: '该插件当前未加载,暂时无法配置。',
62
+ },
63
+ }
64
+
65
+ /**
66
+ * 布尔字段:开关写 'true' / 'false' 文本,再由 parse 变成真正的布尔值。
67
+ * @param {string} field - 字段名。
68
+ * @returns {object} 字段转换规则。
69
+ */
70
+ function booleanField(field) {
71
+ return {
72
+ field,
73
+ format: value => String(value !== false),
74
+ parse: text => ({ kind: 'set', value: text === 'true' }),
75
+ }
76
+ }
77
+
78
+ /**
79
+ * 表单外框的文案。
80
+ * @param {(key: string) => string} t - 翻译函数。
81
+ * @returns {object} SettingsForm 需要的标签。
82
+ */
83
+ function formLabels(t) {
84
+ return {
85
+ unavailable: t('unavailable'),
86
+ readOnly: t('readonly'),
87
+ saveFailed: t('saveFailed'),
88
+ save: t('save'),
89
+ saving: t('saving'),
90
+ }
91
+ }
92
+
93
+ /**
94
+ * 设置卡片。槽位注入 hooks.cleanupCard 与表单动作,形状与 dsh-rewind 的卡片一致。
95
+ * @param {object} props - 槽位注入的属性。
96
+ * @returns {object | null} 卡片元素;摘要视图不出内容。
97
+ */
98
+ function CleanupCard(props) {
99
+ const { t, useCleanupCard } = props
100
+ const state = useCleanupCard(snapshot => snapshot)
101
+ if (props.view === 'summary') return null
102
+ const disabled = !state.writable || state.saving
103
+ const enabled = state.enabled.text === 'true'
104
+ return jsxs(SettingsForm, {
105
+ labels: formLabels(t),
106
+ state,
107
+ onSave: props.save,
108
+ onDiscard: props.discard,
109
+ children: [
110
+ jsxs('div', {
111
+ style: STYLE.row,
112
+ children: [
113
+ jsx('span', { style: STYLE.label, children: t('title') }),
114
+ jsx(Switch, {
115
+ checked: enabled,
116
+ label: t('title'),
117
+ disabled,
118
+ onChange: next => { props.edit('autoCleanup', String(next)) },
119
+ }),
120
+ ],
121
+ }, 'toggle'),
122
+ jsx('p', { style: STYLE.hint, children: t(enabled ? 'on' : 'off') }, 'hint'),
123
+ jsx(SettingsValueField, {
124
+ id: 'plugin-config-disk-cleanup-maxage',
125
+ label: t('maxAge'),
126
+ hint: t('maxAgeHint'),
127
+ overriddenLabel: t('overridden'),
128
+ resetLabel: t('reset'),
129
+ invalidLabel: t('invalid'),
130
+ numeric: true,
131
+ placeholder: DEFAULT_MAX_AGE_DAYS,
132
+ disabled,
133
+ ...state.maxAgeDays,
134
+ onEdit: text => { props.edit('cleanupMaxAgeDays', text) },
135
+ onReset: () => { props.resetField('cleanupMaxAgeDays') },
136
+ }, 'maxage'),
137
+ ],
138
+ })
139
+ }
140
+
141
+ /**
142
+ * 表单模型与卡片状态的接线。
143
+ */
144
+ class CleanupCardController {
145
+ /** @param {object} scope - 宿主该条目的配置表单。 */
146
+ constructor(scope) {
147
+ this.form = new SettingsFormModel(scope, [
148
+ booleanField('autoCleanup'),
149
+ settingsNumberField('cleanupMaxAgeDays'),
150
+ ])
151
+ this.store = this.form.bind(() => ({
152
+ ...this.form.shell(),
153
+ enabled: this.form.field('autoCleanup'),
154
+ maxAgeDays: this.form.field('cleanupMaxAgeDays'),
155
+ }))
156
+ }
157
+
158
+ /** @returns {object} 槽位注入的 hooks 与动作。 */
159
+ inject() {
160
+ return { hooks: { cleanupCard: this.store }, ...this.form.actions() }
161
+ }
162
+
163
+ dispose() {
164
+ this.form.dispose()
165
+ }
166
+ }
167
+
168
+ /**
169
+ * 客户端插件入口。
170
+ * @param {object} ctx - 客户端根上下文。
171
+ */
172
+ function apply(ctx) {
173
+ ctx.effect(() => ctx.locale.register(NS, MESSAGES), 'dsh-disk-cleanup 文案')
174
+ const t = ctx.locale.bind(NS)
175
+ const card = new CleanupCardController(ctx.configForms.get(PLUGIN_PACKAGE))
176
+ ctx.effect(() => () => {
177
+ try {
178
+ card.dispose()
179
+ } catch { /* 宿主回收表单服务后,表单已经自己关掉了 */ }
180
+ }, 'dsh-disk-cleanup 表单')
181
+ ctx.effect(() => ctx.configForms.whileServed([PLUGIN_PACKAGE], () => ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
182
+ name: 'plugins.bundle.config',
183
+ key: PLUGIN_PACKAGE,
184
+ locale: NS,
185
+ inject: () => card.inject(),
186
+ }, CleanupCard))), 'dsh-disk-cleanup 卡片')
187
+ }
188
+
189
+ module.exports.name = '@6starlong/dsh-disk-cleanup'
190
+ module.exports.inject = ['slots', 'locale', 'configForms']
191
+ module.exports.apply = apply
192
+ return module.exports;
193
+ },
194
+ });
package/lib/config.js ADDED
@@ -0,0 +1,117 @@
1
+ /**
2
+ * 配置字段、默认值与归一化。
3
+ *
4
+ * 默认值手写一份,schema 只负责设置页表单:包解析不到时 schema 是空壳,
5
+ * 配置就全靠这份手写默认值,两处不一致会让人以为改坏了。
6
+ * @module dsh-disk-cleanup/config
7
+ */
8
+ import { z } from './schema.js'
9
+
10
+ /** 保留天数下限。 */
11
+ export const MAX_AGE_MIN = 1
12
+ /** 保留天数上限。 */
13
+ export const MAX_AGE_MAX = 365
14
+
15
+ /**
16
+ * 配置 schema,宿主用它渲染设置页表单。
17
+ * 标了 volatile 的字段改完立即生效,不必重载插件。
18
+ */
19
+ export const Config = z.object({
20
+ enabled: z.boolean().default(true).description('启用插件:注入临时目录、补齐写权限、注入系统提示'),
21
+ scratchDir: z.string().default('').description('scratch 目录;留空用 <DSH_HOME>/cache/scratch'),
22
+ injectShellTemp: z.boolean().default(true).description('把 pwsh / bash 的 TMP / TEMP / TMPDIR 指向 scratch'),
23
+ grantProcessWrite: z.boolean().default(true).description('Windows 上给 scratch 补访问控制项,让受限子进程也能写'),
24
+ promptSection: z.boolean().default(true).description('往系统提示里加一段临时文件落点说明'),
25
+ autoCleanup: z.boolean().default(true).volatile().description('加载时与之后定期清掉过期临时文件、请求图片缓存、零引用原件与残留空目录'),
26
+ cleanupMaxAgeDays: z.number().step(1).min(MAX_AGE_MIN).max(MAX_AGE_MAX).default(3).volatile()
27
+ .description('保留天数:临时文件和图片缓存,超过这个天数没改动就清掉;原始图片只有确认没有引用时才会删。'),
28
+ })
29
+
30
+ /**
31
+ * 默认配置。
32
+ *
33
+ * 从 schema 推出来,不另抄一份:两处各写一遍迟早会走样。
34
+ * 标了 volatile 的字段被 schema 包成取值代理,这里统一解成普通值。
35
+ */
36
+ export const DEFAULT_CONFIG = fallbackDefaults()
37
+
38
+ /**
39
+ * 默认值。
40
+ *
41
+ * 拿得到 schema 就从 schema 取,取不到(插件被单独安装、找不到平台包)就用这份
42
+ * 手写值兜底,两边的取值必须一致,测试会盯着。
43
+ * @returns {Readonly<object>} 默认配置。
44
+ */
45
+ function fallbackDefaults() {
46
+ const fromSchema = Config({})
47
+ const schemaReady = fromSchema !== null && typeof fromSchema === 'object'
48
+ && Object.keys(fromSchema).length > 0
49
+ return Object.freeze(schemaReady ? normalize(fromSchema) : {
50
+ enabled: true,
51
+ scratchDir: '',
52
+ injectShellTemp: true,
53
+ grantProcessWrite: true,
54
+ promptSection: true,
55
+ autoCleanup: true,
56
+ cleanupMaxAgeDays: 3,
57
+ })
58
+ }
59
+
60
+ /**
61
+ * 把 schema 解析结果里的 volatile 代理解成普通值。
62
+ * @param {object} input - Schema 解析结果。
63
+ * @returns {object} 全为普通值的配置。
64
+ */
65
+ function normalize(input) {
66
+ const plain = (value) => {
67
+ if (!isVolatile(value)) return value
68
+ try {
69
+ return Reflect.apply(value.get, value, [])
70
+ } catch {
71
+ return undefined
72
+ }
73
+ }
74
+ return Object.fromEntries(Object.entries(input).map(([key, value]) => [key, plain(value)]))
75
+ }
76
+
77
+ /**
78
+ * 判断是不是 volatile 代理。
79
+ * @param {unknown} value - 待判断的值。
80
+ * @returns {boolean} 是代理时为 true。
81
+ */
82
+ function isVolatile(value) {
83
+ // volatile 值的形状是「只有一个 get 的普通对象」,没有 set / watch。
84
+ return value !== null && typeof value === 'object' && typeof value.get === 'function'
85
+ && Object.getOwnPropertyNames(value).join() === 'get'
86
+ }
87
+
88
+ /**
89
+ * 把用户配置合并到默认值上,并做最小校验。
90
+ *
91
+ * 这里再归一一次而不只依赖 schema:cordis.patch.yml 里的 config 是手写的,
92
+ * 类型写错时应当退化到默认值,而不是整条插件启动失败。
93
+ * @param {unknown} raw - cordis.patch.yml 或设置页给出的 config。
94
+ * @returns {typeof DEFAULT_CONFIG} 归一化后的配置。
95
+ */
96
+ export function resolveConfig(raw) {
97
+ // cordis 把 volatile 字段以取值代理传入,先解成普通值再校验。
98
+ const input = raw !== null && typeof raw === 'object' && !Array.isArray(raw) ? normalize(raw) : {}
99
+ const bool = (value, fallback) => (typeof value === 'boolean' ? value : fallback)
100
+ const text = (value, fallback) => (typeof value === 'string' ? value : fallback)
101
+ // 数字与数字字符串都收:设置页写回的是数字,手写 YAML 里写成 "7" 也很常见。
102
+ const requested = typeof input.cleanupMaxAgeDays === 'string' && input.cleanupMaxAgeDays.trim() !== ''
103
+ ? Number(input.cleanupMaxAgeDays.trim())
104
+ : input.cleanupMaxAgeDays
105
+ const days = Number.isFinite(requested)
106
+ ? Math.min(MAX_AGE_MAX, Math.max(MAX_AGE_MIN, Math.round(requested)))
107
+ : DEFAULT_CONFIG.cleanupMaxAgeDays
108
+ return {
109
+ enabled: bool(input.enabled, DEFAULT_CONFIG.enabled),
110
+ scratchDir: text(input.scratchDir, DEFAULT_CONFIG.scratchDir).trim(),
111
+ injectShellTemp: bool(input.injectShellTemp, DEFAULT_CONFIG.injectShellTemp),
112
+ grantProcessWrite: bool(input.grantProcessWrite, DEFAULT_CONFIG.grantProcessWrite),
113
+ promptSection: bool(input.promptSection, DEFAULT_CONFIG.promptSection),
114
+ autoCleanup: bool(input.autoCleanup, DEFAULT_CONFIG.autoCleanup),
115
+ cleanupMaxAgeDays: days,
116
+ }
117
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { Context } from '@deepseek-ai/cordis'
2
+
3
+
4
+ /** 插件配置(与 `cordis.patch.yml` 里的 config 一致,全部可省略)。 */
5
+ export interface Config {
6
+ /** 关掉整个插件。默认 true。 */
7
+ enabled?: boolean
8
+ /** 自定义 scratch 目录;空串表示用 `<DSH_HOME>/cache/scratch`。 */
9
+ scratchDir?: string
10
+ /** 让 pwsh / bash 的 TMP / TEMP / TMPDIR 指向 scratch。默认 true。 */
11
+ injectShellTemp?: boolean
12
+ /** Windows 上给 scratch 补访问控制项,让受限子进程也能写。默认 true。 */
13
+ grantProcessWrite?: boolean
14
+ /** 往系统提示里加一段说明。默认 true。 */
15
+ promptSection?: boolean
16
+ /** 加载时与之后定期清掉过期临时文件、请求图片缓存、零引用原件与残留空目录。默认 true。 */
17
+ autoCleanup?: boolean
18
+ /** 保留天数,范围 1–365。临时文件和图片缓存,超过这个天数没改动就清掉;原始图片只有确认没有引用时才会删。默认 3。 */
19
+ cleanupMaxAgeDays?: number
20
+ }
21
+
22
+ /** Cordis 插件身份。 */
23
+ export declare const name: string
24
+ /** 必需服务。 */
25
+ export declare const inject: readonly string[]
26
+ /** 配置 schema:宿主用它渲染设置页表单。 */
27
+ export declare const Config: unknown
28
+ /**
29
+ * 插件入口。
30
+ * @param ctx - 宿主上下文。
31
+ * @param config - 插件配置。
32
+ */
33
+ export declare function apply(ctx: Context, config?: Config): void