@fooksky/lodestar 0.2.5 → 0.2.6

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.js +53 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fooksky/lodestar",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/client.js CHANGED
@@ -18,6 +18,42 @@ window.__ModuleLoader__.load({
18
18
  delegation: 'Subagents and workflow', questions: 'User questions', todos: 'Task progress',
19
19
  web: 'Web search and fetch', present: 'File delivery', pluginManagement: 'Plugin management',
20
20
  };
21
+ const groups = [
22
+ { zh: '基础环境', en: 'Environment', keys: ['context', 'files', 'terminal', 'compaction'] },
23
+ { zh: '执行与协作', en: 'Execution and collaboration', keys: ['planning', 'goals', 'delegation', 'questions', 'todos'] },
24
+ { zh: '信息与交付', en: 'Information and delivery', keys: ['skills', 'web', 'present'] },
25
+ { zh: '扩展管理', en: 'Extensions', keys: ['scheduling', 'pluginManagement'] },
26
+ ];
27
+ // Scoped styles use the same semantic tokens and control dimensions as DSH.
28
+ const styles = `
29
+ .lodestar-config { width: 100%; max-width: 720px; color: var(--dsw-alias-label-primary); font: 14px/1.6 var(--dsw-font-family); }
30
+ .lodestar-config * { box-sizing: border-box; }
31
+ .lodestar-config p { margin: 0; }
32
+ .lodestar-config .lodestar-intro { color: var(--dsw-alias-label-tertiary); font-size: 13px; margin-bottom: 24px; max-width: 68ch; }
33
+ .lodestar-config .lodestar-group { border: 0; padding: 0; margin: 0 0 24px; min-width: 0; }
34
+ .lodestar-config .lodestar-group legend { padding: 0 0 8px; font-size: 15px; font-weight: 600; }
35
+ .lodestar-config .lodestar-row { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; gap: 24px; min-height: 48px; padding: 10px 0; border-bottom: 1px solid var(--dsw-alias-border-l1); cursor: pointer; overflow-wrap: anywhere; }
36
+ .lodestar-config .lodestar-row:has(input:disabled) { cursor: default; }
37
+ .lodestar-config .lodestar-switch { appearance: none; position: relative; flex: 0 0 36px; width: 36px; height: 20px; margin: 0; border: 0; border-radius: 999px; background: var(--dsw-alias-border-l3); cursor: inherit; }
38
+ .lodestar-config .lodestar-switch::before { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--dsw-alias-switch-thumb); transition: transform .15s; }
39
+ .lodestar-config .lodestar-switch:checked { background: var(--dsw-alias-brand-primary); }
40
+ .lodestar-config .lodestar-switch:checked::before { transform: translateX(16px); background: var(--dsw-alias-label-primary-inverted); }
41
+ .lodestar-config .lodestar-switch:disabled { opacity: .5; }
42
+ .lodestar-config .lodestar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 16px; border-top: 1px solid var(--dsw-alias-border-l2); }
43
+ .lodestar-config .lodestar-button { min-height: 36px; padding: 6px 14px; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-md); background: transparent; color: var(--dsw-alias-label-primary); font: inherit; cursor: pointer; }
44
+ .lodestar-config .lodestar-primary { background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-inverted); border-color: transparent; }
45
+ .lodestar-config .lodestar-reset { margin-inline-start: auto; }
46
+ .lodestar-config .lodestar-button:disabled { opacity: .4; cursor: default; }
47
+ .lodestar-config :is(input, button):focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary); outline-offset: 3px; }
48
+ .lodestar-config .lodestar-message { font-size: 13px; color: var(--dsw-alias-label-secondary); margin-bottom: 12px; overflow-wrap: anywhere; }
49
+ .lodestar-config .lodestar-error { color: var(--dsw-alias-state-error-primary); }
50
+ @media (hover: hover) {
51
+ .lodestar-config .lodestar-button:not(:disabled):hover { background: var(--dsw-alias-interactive-bg-hover); }
52
+ .lodestar-config .lodestar-primary:not(:disabled):hover { background: var(--dsw-alias-button-primary-hover); }
53
+ }
54
+ @media (max-width: 400px) { .lodestar-config .lodestar-reset { margin-inline-start: 0; } }
55
+ @media (prefers-reduced-motion: reduce) { .lodestar-config .lodestar-switch::before { transition: none; } }
56
+ `;
21
57
  const strings = {
22
58
  zh: { title: '预设能力', summary: '选择开发工作流可使用的能力。',
23
59
  intro: '保存后供新会话使用;已有会话保留原装配。开关仅控制此预设。',
@@ -64,28 +100,30 @@ window.__ModuleLoader__.load({
64
100
  setMessage({ error: true, text: error.message });
65
101
  } finally { setBusy(false); }
66
102
  }
67
- return h('form', { onSubmit: save, style: { maxWidth: '48rem', display: 'grid', gap: '1rem' } },
68
- h('p', null, t.intro),
69
- !state.writable && h('p', null, t.readonly),
70
- h('fieldset', { disabled: !editable, style: { border: 0, margin: 0, padding: 0, display: 'grid', gap: '.75rem' } },
71
- h('legend', { style: { fontWeight: 600, marginBottom: '.75rem' } }, t.title),
72
- ...Object.keys(labels).map(key => h('label', { key, style: { display: 'flex', alignItems: 'center', gap: '.75rem', minHeight: '2rem' } },
73
- h('input', { type: 'checkbox', checked: values[key], onChange: event => {
103
+ return h('form', { onSubmit: save, className: 'lodestar-config', 'aria-label': t.title, 'aria-busy': busy },
104
+ h('style', null, styles),
105
+ h('p', { className: 'lodestar-intro' }, t.intro),
106
+ !state.writable && h('p', { className: 'lodestar-message' }, t.readonly),
107
+ ...groups.map(group => h('fieldset', { key: group.en, disabled: !editable, className: 'lodestar-group' },
108
+ h('legend', null, zh ? group.zh : group.en),
109
+ ...group.keys.map(key => h('label', { key, className: 'lodestar-row' },
110
+ h('input', { type: 'checkbox', role: 'switch', className: 'lodestar-switch', checked: values[key], onChange: event => {
74
111
  const next = draft ?? begin();
75
112
  setDraft({ ...next, reset: false, values: { ...next.values, [key]: event.target.checked } });
76
113
  setMessage(null);
77
- } }), (zh ? labels : enLabels)[key]))),
78
- draft?.reset && h('p', { role: 'status' }, t.resetHint),
79
- message && h('p', { role: message.error ? 'alert' : 'status' }, message.text),
80
- h('div', { style: { display: 'flex', gap: '.75rem', flexWrap: 'wrap' } },
81
- h('button', { type: 'submit', disabled: !editable || !draft }, busy ? t.saving : t.save),
82
- h('button', { type: 'button', disabled: !editable, onClick: () => {
114
+ } }), (zh ? labels : enLabels)[key])))),
115
+ draft?.reset && h('p', { role: 'status', className: 'lodestar-message' }, t.resetHint),
116
+ message && h('p', { role: message.error ? 'alert' : 'status',
117
+ className: `lodestar-message${message.error ? ' lodestar-error' : ''}` }, message.text),
118
+ h('div', { className: 'lodestar-actions' },
119
+ h('button', { type: 'submit', className: 'lodestar-button lodestar-primary', disabled: !editable || !draft }, busy ? t.saving : t.save),
120
+ draft && h('button', { type: 'button', className: 'lodestar-button', disabled: busy, onClick: () => { setDraft(null); setMessage(null); } }, t.cancel),
121
+ h('button', { type: 'button', className: 'lodestar-button lodestar-reset', disabled: !editable, onClick: () => {
83
122
  const base = state.base?.capabilities ?? {};
84
123
  setDraft({ ...(draft ?? begin()), reset: true,
85
124
  values: Object.fromEntries(Object.keys(labels).map(key => [key, base[key] ?? true])) });
86
125
  setMessage(null);
87
- } }, t.reset),
88
- draft && h('button', { type: 'button', disabled: busy, onClick: () => { setDraft(null); setMessage(null); } }, t.cancel)));
126
+ } }, t.reset)));
89
127
  }
90
128
  ctx.effect(() => ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
91
129
  name: 'plugins.row.config', key: '@fooksky/lodestar#dev-workflow-preset',