dsh-prompt-customizer 0.1.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/README.md +107 -0
- package/README.zh-CN.md +107 -0
- package/client/client.js +896 -0
- package/client/client.js.map +1 -0
- package/cordis.patch.yml +9 -0
- package/lib/client.js +344 -0
- package/lib/index.js +140 -0
- package/lib/schema.js +27 -0
- package/package.json +61 -0
- package/src/client/PresetsTab.tsx +184 -0
- package/src/client/SectionsTab.tsx +207 -0
- package/src/client/ToolsTab.tsx +62 -0
- package/src/client/index.ts +117 -0
- package/src/client/locales.ts +81 -0
- package/src/client/styles.ts +36 -0
- package/src/client/types.ts +41 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Locale dictionaries for the prompt-customizer panel. */
|
|
2
|
+
export const DICT = {
|
|
3
|
+
zh: {
|
|
4
|
+
nav: '提示词定制',
|
|
5
|
+
loading: '加载中…',
|
|
6
|
+
unavailable: '当前环境未启用本命名空间。',
|
|
7
|
+
tabsSections: '提示词',
|
|
8
|
+
tabsTools: '工具',
|
|
9
|
+
tabsPresets: '预设',
|
|
10
|
+
refresh: '刷新',
|
|
11
|
+
blockedOff: '未屏蔽',
|
|
12
|
+
blockedOn: '已屏蔽',
|
|
13
|
+
replaced: '已替换',
|
|
14
|
+
replace: '替换',
|
|
15
|
+
clearReplace: '清除替换',
|
|
16
|
+
injectNew: '注入新段',
|
|
17
|
+
name: '名称',
|
|
18
|
+
order: '顺序',
|
|
19
|
+
text: '文本',
|
|
20
|
+
add: '添加',
|
|
21
|
+
hiddenOff: '可见',
|
|
22
|
+
hiddenOn: '已隐藏',
|
|
23
|
+
includeMode: '白名单模式:仅保留勾选项',
|
|
24
|
+
excludeMode: '黑名单模式:勾选 = 隐藏',
|
|
25
|
+
empty: '(空)',
|
|
26
|
+
dynamic: '<动态生成>',
|
|
27
|
+
drag: '拖动排序',
|
|
28
|
+
moveUp: '上移',
|
|
29
|
+
moveDown: '下移',
|
|
30
|
+
savePreset: '保存当前为预设',
|
|
31
|
+
presetName: '预设名称',
|
|
32
|
+
save: '保存',
|
|
33
|
+
importPreset: '导入预设',
|
|
34
|
+
import: '导入',
|
|
35
|
+
apply: '应用',
|
|
36
|
+
export: '导出',
|
|
37
|
+
delete: '删除',
|
|
38
|
+
active: '使用中',
|
|
39
|
+
preset: '预设',
|
|
40
|
+
},
|
|
41
|
+
en: {
|
|
42
|
+
nav: 'Prompt Customizer',
|
|
43
|
+
loading: 'Loading…',
|
|
44
|
+
unavailable: 'Namespace unavailable in this environment.',
|
|
45
|
+
tabsSections: 'Sections',
|
|
46
|
+
tabsTools: 'Tools',
|
|
47
|
+
tabsPresets: 'Presets',
|
|
48
|
+
refresh: 'Refresh',
|
|
49
|
+
blockedOff: 'Active',
|
|
50
|
+
blockedOn: 'Blocked',
|
|
51
|
+
replaced: 'Replaced',
|
|
52
|
+
replace: 'Replace',
|
|
53
|
+
clearReplace: 'Clear',
|
|
54
|
+
injectNew: 'Inject section',
|
|
55
|
+
name: 'Name',
|
|
56
|
+
order: 'Order',
|
|
57
|
+
text: 'Text',
|
|
58
|
+
add: 'Add',
|
|
59
|
+
hiddenOff: 'Visible',
|
|
60
|
+
hiddenOn: 'Hidden',
|
|
61
|
+
includeMode: 'Whitelist: keep only checked',
|
|
62
|
+
excludeMode: 'Blacklist: check to hide',
|
|
63
|
+
empty: '(empty)',
|
|
64
|
+
dynamic: '<dynamic>',
|
|
65
|
+
drag: 'Drag to reorder',
|
|
66
|
+
moveUp: 'Move up',
|
|
67
|
+
moveDown: 'Move down',
|
|
68
|
+
savePreset: 'Save current as preset',
|
|
69
|
+
presetName: 'Preset name',
|
|
70
|
+
save: 'Save',
|
|
71
|
+
importPreset: 'Import preset',
|
|
72
|
+
import: 'Import',
|
|
73
|
+
apply: 'Apply',
|
|
74
|
+
export: 'Export',
|
|
75
|
+
delete: 'Delete',
|
|
76
|
+
active: 'Active',
|
|
77
|
+
preset: 'Preset',
|
|
78
|
+
},
|
|
79
|
+
} as const
|
|
80
|
+
|
|
81
|
+
export type Translate = (key: string) => string
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Inline styles shared by the prompt-customizer panel components. */
|
|
2
|
+
export const s = (() => {
|
|
3
|
+
const flex = { display: 'flex', alignItems: 'center' }
|
|
4
|
+
return {
|
|
5
|
+
root: { fontFamily: 'inherit', fontSize: 13, lineHeight: 1.5 },
|
|
6
|
+
bar: { ...flex, gap: 6, marginBottom: 8, flexWrap: 'wrap' },
|
|
7
|
+
tab: { padding: '4px 10px', border: '1px solid rgba(128,128,128,.35)', borderRadius: 6, background: 'transparent', cursor: 'pointer', color: 'inherit', opacity: 0.75 },
|
|
8
|
+
tabActive: { padding: '4px 10px', border: '1px solid rgba(128,128,128,.7)', borderRadius: 6, background: 'rgba(128,128,128,.18)', cursor: 'pointer', color: 'inherit' },
|
|
9
|
+
refresh: { marginLeft: 'auto', padding: '4px 10px', border: '1px solid rgba(128,128,128,.35)', borderRadius: 6, background: 'transparent', cursor: 'pointer', color: 'inherit' },
|
|
10
|
+
list: { display: 'flex', flexDirection: 'column', gap: 6 },
|
|
11
|
+
row: { ...flex, gap: 8, padding: '6px 8px', border: '1px solid rgba(128,128,128,.2)', borderRadius: 8, background: 'rgba(128,128,128,.06)' },
|
|
12
|
+
switchWrap: { ...flex, gap: 6, minWidth: 90 },
|
|
13
|
+
rowBody: { flex: 1, minWidth: 0 },
|
|
14
|
+
rowTitle: { ...flex, gap: 6, alignItems: 'baseline', flexWrap: 'wrap' },
|
|
15
|
+
code: { fontFamily: 'monospace', fontSize: 12, wordBreak: 'break-all' },
|
|
16
|
+
orderTag: { color: 'rgba(128,128,128,.8)', fontSize: 11 },
|
|
17
|
+
preview: { color: 'rgba(128,128,128,.85)', fontSize: 12, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
|
18
|
+
badgeOk: { color: '#3fb950', fontSize: 11, border: '1px solid rgba(63,185,80,.5)', borderRadius: 999, padding: '0 6px' },
|
|
19
|
+
badgeBlocked: { color: '#f85149', fontSize: 11, border: '1px solid rgba(248,81,73,.5)', borderRadius: 999, padding: '0 6px' },
|
|
20
|
+
badgeReplaced: { color: '#d29922', fontSize: 11, border: '1px solid rgba(210,153,34,.5)', borderRadius: 999, padding: '0 6px' },
|
|
21
|
+
mini: { padding: '3px 8px', border: '1px solid rgba(128,128,128,.35)', borderRadius: 6, background: 'transparent', cursor: 'pointer', color: 'inherit', whiteSpace: 'nowrap' },
|
|
22
|
+
arrowCol: { display: 'flex', flexDirection: 'column', gap: 2 },
|
|
23
|
+
arrow: { padding: '0 6px', border: '1px solid rgba(128,128,128,.3)', borderRadius: 4, background: 'transparent', cursor: 'pointer', color: 'inherit', fontSize: 11, lineHeight: 1.4, opacity: 0.8 },
|
|
24
|
+
rowDragging: { opacity: 0.4 },
|
|
25
|
+
rowDropAbove: { boxShadow: '0 -2px 0 0 #58a6ff' },
|
|
26
|
+
rowDropBelow: { boxShadow: '0 2px 0 0 #58a6ff' },
|
|
27
|
+
dragHandle: { cursor: 'grab', color: 'rgba(128,128,128,.7)', fontSize: 13, padding: '0 2px', userSelect: 'none' },
|
|
28
|
+
injectBox: { marginTop: 10, padding: '8px', border: '1px dashed rgba(128,128,128,.4)', borderRadius: 8, display: 'flex', flexDirection: 'column', gap: 6 },
|
|
29
|
+
injectRow: { ...flex, gap: 6 },
|
|
30
|
+
editBox: { display: 'flex', flexDirection: 'column', gap: 6, marginTop: 4 },
|
|
31
|
+
editInput: { padding: '6px', border: '1px solid rgba(128,128,128,.35)', borderRadius: 6, background: 'transparent', color: 'inherit', fontFamily: 'inherit', fontSize: 12, resize: 'vertical', width: '100%', boxSizing: 'border-box' },
|
|
32
|
+
input: { padding: '4px 6px', border: '1px solid rgba(128,128,128,.35)', borderRadius: 6, background: 'transparent', color: 'inherit' },
|
|
33
|
+
muted: { color: 'rgba(128,128,128,.75)', fontSize: 12 },
|
|
34
|
+
error: { color: '#f85149', fontSize: 12, marginBottom: 6 },
|
|
35
|
+
}
|
|
36
|
+
})()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Shared types for the prompt-customizer client panel. */
|
|
2
|
+
|
|
3
|
+
/** The settings scope used to read/write the namespace config. */
|
|
4
|
+
export interface SettingsScope {
|
|
5
|
+
getSnapshot(): { status: string; value?: unknown; revision: number; writable: boolean }
|
|
6
|
+
subscribe(callback: () => void): () => void
|
|
7
|
+
set(field: string, value: unknown): void
|
|
8
|
+
unset(field: string): void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Inventory payload from the host route. */
|
|
12
|
+
export interface Inventory {
|
|
13
|
+
sections: Array<{ name: string; order: number; text?: string; active: boolean; replaced: boolean }>
|
|
14
|
+
tools: Array<{ name: string; description?: string; hidden: boolean }>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The resolved config object (namespace value). */
|
|
18
|
+
export interface Config {
|
|
19
|
+
sections?: string[]
|
|
20
|
+
replace?: Record<string, string>
|
|
21
|
+
inject?: Array<{ name: string; order: number; text: string }>
|
|
22
|
+
tools?: { exclude?: string[]; include?: string[] }
|
|
23
|
+
presets?: Preset[]
|
|
24
|
+
activePreset?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A complete customization snapshot that can be saved / applied / exported. */
|
|
28
|
+
export interface Preset {
|
|
29
|
+
id: string
|
|
30
|
+
name: string
|
|
31
|
+
data: PresetData
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The customization fields a preset captures (full snapshot). */
|
|
35
|
+
export interface PresetData {
|
|
36
|
+
sections?: string[]
|
|
37
|
+
replace?: Record<string, string>
|
|
38
|
+
/** Relative order: each section records the section it should follow. */
|
|
39
|
+
order?: Array<{ name: string; after?: string; text: string }>
|
|
40
|
+
tools?: { exclude?: string[]; include?: string[] }
|
|
41
|
+
}
|