@kadaliao/dsh-bots 0.4.0 → 0.6.1

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/client.js CHANGED
@@ -500,6 +500,7 @@ window.__ModuleLoader__.load({
500
500
  eyeOff: (s = 14) => svg(s, ['M3 3l18 18', 'M10.6 5.1A10.7 10.7 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.2 4.1', 'M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a10 10 0 0 0 5.4-1.6', 'M9.9 9.9a3 3 0 0 0 4.2 4.2']),
501
501
  team: (s = 14) => svg(s, ['M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z', 'M2.5 20a6.5 6.5 0 0 1 13 0', 'M16 4.3a3.5 3.5 0 0 1 0 6.4', 'M18 14.2a6.5 6.5 0 0 1 3.5 5.8']),
502
502
  layers: (s = 14) => svg(s, ['M12 3l9 5-9 5-9-5 9-5z', 'M3 13l9 5 9-5']),
503
+ folder: (s = 14) => svg(s, ['M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z']),
503
504
  github: (s = 14) => svg(s, ['M9 19c-4 1.5-4-2-6-2.5', 'M15 21v-3.5a3 3 0 0 0-.8-2.3c2.8-.3 5.8-1.4 5.8-6.2a4.8 4.8 0 0 0-1.3-3.3 4.5 4.5 0 0 0-.1-3.3s-1-.3-3.4 1.3a11.6 11.6 0 0 0-6 0C6.8 2.1 5.8 2.4 5.8 2.4a4.5 4.5 0 0 0-.1 3.3A4.8 4.8 0 0 0 4.4 9c0 4.8 3 5.9 5.8 6.2a3 3 0 0 0-.8 2.3V21']),
504
505
  wand: (s = 14) => svg(s, ['M4 20l11-11', 'M13 7l4 4', 'M18 3v4', 'M16 5h4', 'M8 3v2', 'M7 4h2']),
505
506
  chevron: (s = 12) => svg(s, ['M6 9l6 6 6-6']),
@@ -1157,7 +1158,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
1157
1158
  : h(
1158
1159
  'span',
1159
1160
  { style: { fontSize: TINY, color: C.faint, display: 'inline-flex', alignItems: 'center', gap: 6 } },
1160
- m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, t('viaChannel', { app: channelName(m.via), who: str(m.who) || t('you') })) : null,
1161
+ m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, t('viaChannel', { app: channelName(m.via, t), who: str(m.who) || t('you') })) : null,
1161
1162
  m.to !== botId && to.kind === 'bot' ? `${t('toName', { name: to.name })} · ${time}` : time,
1162
1163
  ),
1163
1164
  h('div', { style: { maxWidth: '78%', padding: '8px 12px', borderRadius: '14px 14px 4px 14px', background: C.label, color: '#fff', fontSize: FONT } }, h(Clamp, { t, text: m.text, lines: 14, light: true })),
@@ -1180,7 +1181,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
1180
1181
  from.kind === 'bot' ? h('span', { style: { color: C.faint } }, `@${from.bot.handle}`) : null,
1181
1182
  m.to !== 'user' && to.kind === 'bot' && m.to !== botId ? h('span', { style: { color: C.faint } }, `→ ${to.name}`) : null,
1182
1183
  h('span', { style: { color: C.faint } }, time),
1183
- m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, title: t('sentToChannel', { app: channelName(m.via) }), 'data-dsh-bots-via': m.via }, `→ ${channelName(m.via)}`) : null,
1184
+ m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, title: t('sentToChannel', { app: channelName(m.via, t) }), 'data-dsh-bots-via': m.via }, `→ ${channelName(m.via, t)}`) : null,
1184
1185
  ),
1185
1186
  h('div', { style: { padding: '8px 12px', borderRadius: '4px 14px 14px 14px', background: C.layer2, border: `1px solid ${C.border1}`, fontSize: FONT, minWidth: 0 } }, h(Clamp, { t, text: m.text, lines: 24 })),
1186
1187
  h(LinkCards, { t, text: m.text }),
@@ -1874,7 +1875,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
1874
1875
  h('span', { style: { color: C.faint, display: 'inline-flex' } }, Icon.arrow(11)),
1875
1876
  h('span', { style: { fontWeight: 600 } }, to.name),
1876
1877
  h(Badge, { color: m.kind === 'dm' ? C.label : m.kind === 'system' ? C.warn : C.muted }, t(`kind_${m.kind}`) || m.kind),
1877
- m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, m.from === 'user' && m.who ? `${channelName(m.via)} · ${str(m.who)}` : channelName(m.via)) : null,
1878
+ m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, m.from === 'user' && m.who ? `${channelName(m.via, t)} · ${str(m.who)}` : channelName(m.via, t)) : null,
1878
1879
  h('span', { style: { marginLeft: 'auto', color: C.faint, fontSize: TINY }, title: fmtDate(toMs(m.at)) }, fmtAgo(t, m.at)),
1879
1880
  ),
1880
1881
  h(Clamp, { t, text: m.text, lines: 3, style: { fontSize: SMALL, color: C.muted } }),
@@ -2310,10 +2311,60 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2310
2311
  }
2311
2312
 
2312
2313
  const skillSource = (s) => (s?.source === 'dsh' || s?.source === 'import' ? s.source : 'own');
2314
+ /** How many skills a bot keeps, and how many of them may be on at once (from the host; lib/store.mjs). */
2315
+ const skillLimits = () => ({ max: Number(store.state?.limits?.skills) || 200, on: Number(store.state?.limits?.skillsOn) || 50 });
2316
+ const onCount = (skills) => skills.filter((s) => s.enabled !== false).length;
2317
+ /** A skill linked to a folder on this machine (its origin is a path, not a URL): read live, never copied. */
2318
+ const isLocalSkill = (s) => s?.source === 'import' && typeof s.origin === 'string' && s.origin !== '' && !/^https?:\/\//i.test(s.origin);
2313
2319
  const SOURCE_COLOR = { dsh: '#2563eb', import: '#475569', own: '#16a34a' };
2314
- function SourceBadge({ t, source }) {
2315
- return h(Badge, { color: SOURCE_COLOR[source] ?? C.muted, 'data-dsh-bots-skill-source': source }, source === 'dsh' ? Icon.layers(10) : source === 'import' ? Icon.github(10) : Icon.edit(10), t(`src_${source}`));
2320
+ function SourceBadge({ t, source, local }) {
2321
+ return h(
2322
+ Badge,
2323
+ { color: SOURCE_COLOR[source] ?? C.muted, 'data-dsh-bots-skill-source': source },
2324
+ source === 'dsh' ? Icon.layers(10) : source === 'import' ? (local ? Icon.folder(10) : Icon.github(10)) : Icon.edit(10),
2325
+ t(local ? 'src_local' : `src_${source}`),
2326
+ );
2327
+ }
2328
+ /** The bot's skills by lower-cased name: what an import could collide with. */
2329
+ const skillsByName = (bot) => new Map((bot.skills ?? []).map((s) => [str(s.name).toLowerCase(), s]));
2330
+ /**
2331
+ * What importing a skill named like `existing` from `origin` would do:
2332
+ * 'new' adds it, 'update' refreshes the copy made from the same place, 'taken' is refused.
2333
+ */
2334
+ const importStateOf = (existing, origin) => (!existing ? 'new' : existing.source === 'import' && existing.origin && existing.origin === origin ? 'update' : 'taken');
2335
+ /** One line for what an import did: added, updated, skipped. */
2336
+ function importSummary(t, r) {
2337
+ const n = (k) => (Array.isArray(r?.[k]) ? r[k].length : 0);
2338
+ const skipped = Array.isArray(r?.skipped) ? r.skipped : [];
2339
+ const full = skipped.filter((x) => x?.reason === 'full').length;
2340
+ const lim = skillLimits();
2341
+ return [
2342
+ n('added') ? t('importedN', { n: n('added') }) : '',
2343
+ n('off') ? t('offN', { n: n('off'), max: lim.on }) : '',
2344
+ n('updated') ? t('updatedN', { n: n('updated') }) : '',
2345
+ skipped.length - full ? t('skippedN', { n: skipped.length - full }) : '',
2346
+ full ? t('fullN', { n: full, max: lim.max }) : '',
2347
+ ]
2348
+ .filter(Boolean)
2349
+ .join(' ');
2350
+ }
2351
+ /** Run an import and report it; resolves to the rows that failed, or null when nothing came back. */
2352
+ function runImport(t, toast, botId, items) {
2353
+ return postJson('skills/import', { botId, items }).then((r) => {
2354
+ const bad = Array.isArray(r?.failed) ? r.failed : [];
2355
+ const text = importSummary(t, r);
2356
+ if (r?.ok && text) {
2357
+ toast(text);
2358
+ void refreshState();
2359
+ } else if (!bad.length) toast(r?.reason || t('importFailed'), 'error');
2360
+ return { failed: bad, done: Boolean(r?.ok && text) };
2361
+ });
2316
2362
  }
2363
+ /** The label and tick of a picker row, by what importing it would do. */
2364
+ const importRowProps = (t, state, files) => ({
2365
+ disabled: state === 'taken',
2366
+ meta: state === 'taken' ? t('nameTaken') : state === 'update' ? t('reimport') : t('nFiles', { n: files ?? 0 }),
2367
+ });
2317
2368
  /** A search box with a magnifier. */
2318
2369
  const SearchBox = ({ value, onChange, placeholder, style, ...rest }) =>
2319
2370
  h(
@@ -2328,7 +2379,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2328
2379
  'label',
2329
2380
  {
2330
2381
  ...rest,
2331
- style: { display: 'flex', gap: 10, alignItems: 'flex-start', padding: '9px 12px', borderTop: `1px solid ${C.border1}`, cursor: disabled ? 'default' : 'pointer', opacity: disabled ? 0.55 : 1, background: checked ? tint(C.label, 7) : 'transparent' },
2382
+ style: { display: 'flex', flex: 'none', gap: 10, alignItems: 'flex-start', padding: '9px 12px', borderTop: `1px solid ${C.border1}`, cursor: disabled ? 'default' : 'pointer', opacity: disabled ? 0.55 : 1, background: checked ? tint(C.label, 7) : 'transparent' },
2332
2383
  },
2333
2384
  h('input', { type: 'checkbox', checked: Boolean(checked) || Boolean(disabled), disabled, onChange: () => onToggle(), style: { marginTop: 3, accentColor: 'var(--dsw-alias-brand-primary)' } }),
2334
2385
  h(
@@ -2373,7 +2424,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2373
2424
  h(SearchBox, { value: q, onChange: setQ, placeholder: t('searchSkills', { n: (all ?? []).length }), autoFocus: true, 'data-dsh-bots-harness-search': true }),
2374
2425
  h(
2375
2426
  'div',
2376
- { 'data-dsh-bots-harness-list': true, style: { display: 'flex', flexDirection: 'column', border: `1px solid ${C.border1}`, borderRadius: 12, overflow: 'hidden', marginTop: -4, borderTop: 'none' } },
2427
+ // The list scrolls by itself, so the search box stays in view however many skills there are.
2428
+ { 'data-dsh-bots-harness-list': true, className: 'dshb-scroll', style: { display: 'flex', flexDirection: 'column', flex: '1 1 auto', minHeight: 120, border: `1px solid ${C.border1}`, borderRadius: 12, marginTop: -4, borderTop: 'none' } },
2377
2429
  all === null
2378
2430
  ? h('div', { style: { padding: 18, fontSize: SMALL, color: C.faint, textAlign: 'center', borderTop: `1px solid ${C.border1}` } }, t('loading'))
2379
2431
  : shown.length === 0
@@ -2405,7 +2457,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2405
2457
  const [sel, setSel] = useState([]);
2406
2458
  const [importing, setImporting] = useState(false);
2407
2459
  const [failed, setFailed] = useState([]);
2408
- const have = new Set((bot.skills ?? []).map((s) => s.name));
2460
+ const mine = skillsByName(bot);
2461
+ const stateOf = (s) => importStateOf(mine.get(str(s.name).toLowerCase()), listing ? `https://github.com/${listing.owner}/${listing.repo}/tree/${listing.ref}/${s.path}` : '');
2409
2462
  const browse = (spec) => {
2410
2463
  const value = str(spec).trim();
2411
2464
  if (!value) return;
@@ -2426,15 +2479,10 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2426
2479
  const doImport = () => {
2427
2480
  if (!listing || sel.length === 0) return;
2428
2481
  setImporting(true);
2429
- postJson('skills/import', { botId: bot.id, items: sel.map((path) => ({ repo: `${listing.owner}/${listing.repo}`, path })) })
2482
+ runImport(t, toast, bot.id, sel.map((path) => ({ repo: `${listing.owner}/${listing.repo}`, ref: listing.ref, path })))
2430
2483
  .then((r) => {
2431
- const bad = Array.isArray(r?.failed) ? r.failed : [];
2432
- setFailed(bad);
2433
- if (r?.ok && Array.isArray(r.added) && r.added.length) {
2434
- toast(t('importedN', { n: r.added.length }));
2435
- void refreshState();
2436
- if (bad.length === 0) onImported();
2437
- } else if (!bad.length) toast(r?.reason || t('importFailed'), 'error');
2484
+ setFailed(r.failed);
2485
+ if (r.done && r.failed.length === 0) onImported();
2438
2486
  })
2439
2487
  .finally(() => setImporting(false));
2440
2488
  };
@@ -2515,7 +2563,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2515
2563
  h('span', { style: { color: C.faint } }, t('foundSkills', { n: skills.length })),
2516
2564
  h('span', { style: { flex: 1 } }),
2517
2565
  skills.length
2518
- ? h('button', { type: 'button', className: 'dshb-link', style: { fontSize: TINY }, onClick: () => setSel(sel.length ? [] : skills.filter((s) => !have.has(s.name)).map((s) => s.path)) }, sel.length ? t('selectNone') : t('selectAll'))
2566
+ ? h('button', { type: 'button', className: 'dshb-link', style: { fontSize: TINY }, onClick: () => setSel(sel.length ? [] : skills.filter((s) => stateOf(s) === 'new').map((s) => s.path)) }, sel.length ? t('selectNone') : t('selectAll'))
2519
2567
  : null,
2520
2568
  ),
2521
2569
  h(
@@ -2527,10 +2575,9 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2527
2575
  key: s.path,
2528
2576
  'data-dsh-bots-github-skill': s.path,
2529
2577
  checked: sel.includes(s.path),
2530
- disabled: have.has(s.name),
2531
2578
  onToggle: () => setSel((x) => (x.includes(s.path) ? x.filter((p) => p !== s.path) : [...x, s.path])),
2532
2579
  title: s.name,
2533
- meta: have.has(s.name) ? t('added') : t('nFiles', { n: s.files ?? 0 }),
2580
+ ...importRowProps(t, stateOf(s), s.files),
2534
2581
  description: s.description,
2535
2582
  note: bad ? h('span', { style: { color: C.error } }, bad.reason) : null,
2536
2583
  });
@@ -2543,6 +2590,170 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2543
2590
  );
2544
2591
  }
2545
2592
 
2593
+ /** Import skill folders from this machine: one skill folder, or a folder that holds several. */
2594
+ function LocalPicker({ t, bot, catalog, env, onClose, onImported, toast }) {
2595
+ const places = useLoaded('localPlaces', 'skills/local')?.places;
2596
+ const [path, setPath] = useState('');
2597
+ const [listing, setListing] = useState(null); // {root, skills, truncated}
2598
+ const [loading, setLoading] = useState(false);
2599
+ const [error, setError] = useState('');
2600
+ const [sel, setSel] = useState([]);
2601
+ const [importing, setImporting] = useState(false);
2602
+ const [failed, setFailed] = useState([]);
2603
+ const mine = skillsByName(bot);
2604
+ const inHarness = new Set((Array.isArray(catalog?.skills) ? catalog.skills : []).map((s) => s.name));
2605
+ // A folder already linked has nothing to import again: the bot reads it live.
2606
+ const stateOf = (s) => (importStateOf(mine.get(str(s.name).toLowerCase()), s.path) === 'new' ? 'new' : mine.get(str(s.name).toLowerCase()).origin === s.path ? 'linked' : 'taken');
2607
+ const scan = (spec) => {
2608
+ const value = str(spec).trim();
2609
+ if (!value) return;
2610
+ setLoading(true);
2611
+ setError('');
2612
+ setSel([]);
2613
+ setFailed([]);
2614
+ postJson('skills/local', { path: value })
2615
+ .then((r) => {
2616
+ if (r?.ok && Array.isArray(r.skills)) {
2617
+ setListing(r);
2618
+ // One skill and nothing in its way: ready to import.
2619
+ if (r.skills.length === 1 && !mine.has(str(r.skills[0].name).toLowerCase())) setSel([r.skills[0].path]);
2620
+ } else {
2621
+ setListing(null);
2622
+ setError(r?.reason || t('localFailed'));
2623
+ }
2624
+ })
2625
+ .finally(() => setLoading(false));
2626
+ };
2627
+ const canPick = typeof env?.pickDirectory === 'function' && env.canPickDirectory?.() !== false;
2628
+ const choose = () => {
2629
+ setError('');
2630
+ Promise.resolve()
2631
+ .then(() => env.pickDirectory())
2632
+ .then(
2633
+ (p) => {
2634
+ if (typeof p !== 'string' || p === '') return;
2635
+ setPath(p);
2636
+ scan(p);
2637
+ },
2638
+ () => setError(t('pickFailed')),
2639
+ );
2640
+ };
2641
+ const doImport = () => {
2642
+ if (!listing || sel.length === 0) return;
2643
+ setImporting(true);
2644
+ runImport(t, toast, bot.id, sel.map((p) => ({ local: p })))
2645
+ .then((r) => {
2646
+ setFailed(r.failed);
2647
+ if (r.done && r.failed.length === 0) onImported();
2648
+ })
2649
+ .finally(() => setImporting(false));
2650
+ };
2651
+ const skills = listing?.skills ?? [];
2652
+ return h(
2653
+ Modal,
2654
+ {
2655
+ title: t('localPickerTitle'),
2656
+ closeLabel: t('close'),
2657
+ width: 700,
2658
+ onClose,
2659
+ footer: [
2660
+ importing ? h('span', { key: 'p', style: { flex: 1, alignSelf: 'center', display: 'inline-flex', alignItems: 'center', gap: 8, fontSize: SMALL, color: C.muted } }, h('span', { className: 'dshb-spinner' }), t('importing')) : h('span', { key: 'p', style: { flex: 1, alignSelf: 'center', fontSize: TINY, color: C.faint } }, t('localNote')),
2661
+ h(Btn, { key: 'c', onClick: onClose }, t('cancel')),
2662
+ h(Btn, { key: 'i', kind: 'primary', icon: Icon.folder(12), disabled: sel.length === 0 || importing, onClick: doImport, 'data-dsh-bots-local-import': true }, t('addN', { n: sel.length })),
2663
+ ],
2664
+ },
2665
+ h('div', { style: { fontSize: SMALL, color: C.muted, lineHeight: 1.6 } }, t('localHint')),
2666
+ h(
2667
+ 'div',
2668
+ { style: { display: 'flex', gap: 8 } },
2669
+ h(Input, {
2670
+ value: path,
2671
+ mono: true,
2672
+ autoFocus: true,
2673
+ placeholder: '~/skills/my-skill',
2674
+ 'data-dsh-bots-local-path': true,
2675
+ onChange: (e) => setPath(e.target.value),
2676
+ onKeyDown: (e) => {
2677
+ if (e.key === 'Enter' && !e.isComposing && !e.nativeEvent?.isComposing) {
2678
+ e.preventDefault();
2679
+ scan(path);
2680
+ }
2681
+ },
2682
+ }),
2683
+ canPick ? h(Btn, { icon: Icon.folder(13), disabled: loading, onClick: choose, 'data-dsh-bots-local-pick': true }, t('chooseFolder')) : null,
2684
+ h(Btn, { disabled: !path.trim() || loading, onClick: () => scan(path), 'data-dsh-bots-local-scan': true }, loading ? t('loading') : t('scan')),
2685
+ ),
2686
+ Array.isArray(places) && places.length
2687
+ ? h(
2688
+ 'div',
2689
+ { style: { display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap', fontSize: TINY, color: C.faint, marginTop: -6 } },
2690
+ t('localPlaces'),
2691
+ places.map((pl) =>
2692
+ h(
2693
+ 'button',
2694
+ {
2695
+ key: pl.path,
2696
+ type: 'button',
2697
+ className: 'dshb-chip dshb-mono',
2698
+ 'data-dsh-bots-local-place': pl.path,
2699
+ title: pl.path,
2700
+ onClick: () => {
2701
+ setPath(pl.label || pl.path);
2702
+ scan(pl.path);
2703
+ },
2704
+ },
2705
+ pl.label || pl.path,
2706
+ ),
2707
+ ),
2708
+ )
2709
+ : null,
2710
+ error ? h('div', { 'data-dsh-bots-local-error': true, style: { fontSize: SMALL, color: C.error } }, error) : null,
2711
+ listing
2712
+ ? h(
2713
+ 'div',
2714
+ { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
2715
+ h(
2716
+ 'div',
2717
+ { style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: SMALL, minWidth: 0 } },
2718
+ Icon.folder(13),
2719
+ h('span', { className: 'dshb-mono', style: { fontWeight: 600, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', direction: 'rtl' }, title: listing.root }, h('bdi', null, listing.root)),
2720
+ h('span', { style: { color: C.faint, flex: 'none' } }, t('foundSkills', { n: skills.length })),
2721
+ h('span', { style: { flex: 1 } }),
2722
+ skills.length > 1
2723
+ ? h('button', { type: 'button', className: 'dshb-link', style: { fontSize: TINY, flex: 'none' }, onClick: () => setSel(sel.length ? [] : skills.filter((s) => stateOf(s) === 'new').map((s) => s.path)) }, sel.length ? t('selectNone') : t('selectAll'))
2724
+ : null,
2725
+ ),
2726
+ skills.length === 0
2727
+ ? h('div', { style: { padding: 18, fontSize: SMALL, color: C.faint, textAlign: 'center', border: `1px dashed ${C.border1}`, borderRadius: 12 } }, t('localNone'))
2728
+ : h(
2729
+ 'div',
2730
+ { 'data-dsh-bots-local-list': true, style: { display: 'flex', flexDirection: 'column', border: `1px solid ${C.border1}`, borderRadius: 12, overflow: 'hidden', borderTop: 'none' } },
2731
+ skills.map((s) => {
2732
+ const bad = failed.find((f) => f.spec?.local === s.path);
2733
+ const state = stateOf(s);
2734
+ const rel = s.path === listing.root ? '' : str(s.path).slice(listing.root.length + 1);
2735
+ return h(PickRow, {
2736
+ key: s.path,
2737
+ 'data-dsh-bots-local-skill': s.path,
2738
+ 'data-state': state,
2739
+ checked: sel.includes(s.path),
2740
+ onToggle: () => setSel((x) => (x.includes(s.path) ? x.filter((p) => p !== s.path) : [...x, s.path])),
2741
+ title: s.name,
2742
+ disabled: state !== 'new',
2743
+ meta: state === 'linked' ? t('linked') : state === 'taken' ? t('nameTaken') : t('nFiles', { n: s.files ?? 0 }),
2744
+ description: s.description,
2745
+ note: bad ? h('span', { style: { color: C.error } }, bad.reason) : state === 'new' && inHarness.has(s.name) ? t('alsoInHarness') : rel && rel !== s.name ? h('span', { className: 'dshb-mono' }, rel) : null,
2746
+ });
2747
+ }),
2748
+ ),
2749
+ listing.truncated ? h('div', { style: { fontSize: TINY, color: C.faint } }, t('localTruncated')) : null,
2750
+ )
2751
+ : loading
2752
+ ? h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: SMALL, color: C.muted, padding: 8 } }, h('span', { className: 'dshb-spinner' }), t('readingFolder'))
2753
+ : null,
2754
+ );
2755
+ }
2756
+
2546
2757
  /** Describe a skill; the bot writes it (with skill-creator) in its own conversation. */
2547
2758
  function WriteSkillModal({ t, bot, onClose, onSent, toast }) {
2548
2759
  const [text, setText] = useState('');
@@ -2573,13 +2784,13 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2573
2784
  );
2574
2785
  }
2575
2786
 
2576
- function SkillsTab({ t, bot, toast, catalog, setTab }) {
2787
+ function SkillsTab({ t, bot, toast, catalog, setTab, env }) {
2577
2788
  const lang = langOf(t);
2578
2789
  const skills = Array.isArray(bot.skills) ? bot.skills : [];
2579
2790
  const [editing, setEditing] = useState(null); // {id?, name, description, content, enabled}
2580
2791
  const [confirm, setConfirm] = useState(null);
2581
2792
  const [busy, setBusy] = useState(false);
2582
- const [picker, setPicker] = useState(null); // 'harness' | 'github' | 'write'
2793
+ const [picker, setPicker] = useState(null); // 'harness' | 'github' | 'local' | 'write'
2583
2794
  const commit = (next, okText) => {
2584
2795
  setBusy(true);
2585
2796
  return saveField(t, toast, bot, { skills: next }, okText).finally(() => setBusy(false));
@@ -2588,17 +2799,38 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2588
2799
  const s = editing;
2589
2800
  if (!s || !s.name.trim()) return;
2590
2801
  const prev = skills.find((x) => x.id === s.id);
2591
- const item = { ...(prev ?? {}), id: s.id || rid('skill'), name: s.name.trim(), source: prev ? skillSource(prev) : 'own', description: s.description.trim(), content: s.content, enabled: s.enabled !== false };
2802
+ // Two skills of one name would be told apart by nothing: refuse instead of doubling.
2803
+ if (skills.some((x) => x !== prev && str(x.name).toLowerCase() === s.name.trim().toLowerCase())) {
2804
+ toast(t('skillNameTaken', { name: s.name.trim() }), 'error');
2805
+ return;
2806
+ }
2807
+ const lim = skillLimits();
2808
+ if (!prev && skills.length >= lim.max) {
2809
+ toast(t('skillsFull', { max: lim.max }), 'error');
2810
+ return;
2811
+ }
2812
+ // A new skill past the limit of skills on is kept, switched off.
2813
+ const off = !prev && s.enabled !== false && onCount(skills) >= lim.on;
2814
+ const item = { ...(prev ?? {}), id: s.id || rid('skill'), name: s.name.trim(), source: prev ? skillSource(prev) : 'own', description: s.description.trim(), content: s.content, enabled: s.enabled !== false && !off };
2592
2815
  const next = s.id ? skills.map((x) => (x.id === s.id ? item : x)) : [...skills, item];
2593
- void commit(next, t('skillSaved')).then((ok) => ok && setEditing(null));
2816
+ void commit(next, off ? `${t('skillSaved')} ${t('offN', { n: 1, max: lim.on })}` : t('skillSaved')).then((ok) => ok && setEditing(null));
2594
2817
  };
2595
2818
  const addHarness = (list) => {
2596
- const have = new Set(skills.map((x) => x.name));
2597
- const add = list.filter((x) => !have.has(x.name)).map((x) => ({ name: x.name, source: 'dsh', enabled: true, description: str(x.description) }));
2598
- void commit([...skills, ...add], t('addedN', { n: add.length })).then((ok) => ok && setPicker(null));
2819
+ const have = new Set(skills.map((x) => str(x.name).toLowerCase()));
2820
+ const lim = skillLimits();
2821
+ const fresh = list.filter((x) => !have.has(str(x.name).toLowerCase()));
2822
+ if (skills.length + fresh.length > lim.max) {
2823
+ toast(t('skillsRoom', { max: lim.max, n: Math.max(0, lim.max - skills.length) }), 'error');
2824
+ return;
2825
+ }
2826
+ // Past the limit of skills on, the rest come in switched off.
2827
+ const room = Math.max(0, lim.on - onCount(skills));
2828
+ const add = fresh.map((x, i) => ({ name: x.name, source: 'dsh', enabled: i < room, description: str(x.description) }));
2829
+ const off = add.length - Math.min(room, add.length);
2830
+ void commit([...skills, ...add], off ? `${t('addedN', { n: add.length })} ${t('offN', { n: off, max: lim.on })}` : t('addedN', { n: add.length })).then((ok) => ok && setPicker(null));
2599
2831
  };
2600
- const counts = { dsh: 0, import: 0, own: 0 };
2601
- for (const s of skills) counts[skillSource(s)] += 1;
2832
+ const counts = { dsh: 0, import: 0, local: 0, own: 0 };
2833
+ for (const s of skills) counts[isLocalSkill(s) ? 'local' : skillSource(s)] += 1;
2602
2834
  return h(
2603
2835
  'div',
2604
2836
  { className: 'dshb-scroll', style: { flex: 1, padding: '20px 24px 28px' } },
@@ -2610,6 +2842,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2610
2842
  { 'data-dsh-bots-skill-actions': true, style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
2611
2843
  h(Btn, { kind: 'primary', icon: Icon.layers(13), onClick: () => setPicker('harness'), 'data-dsh-bots-add-harness': true }, t('addFromHarness')),
2612
2844
  h(Btn, { icon: Icon.github(13), onClick: () => setPicker('github'), 'data-dsh-bots-add-github': true }, t('importGithub')),
2845
+ h(Btn, { icon: Icon.folder(13), onClick: () => setPicker('local'), 'data-dsh-bots-add-local': true }, t('importLocal')),
2613
2846
  h(Btn, { icon: Icon.wand(13), onClick: () => setPicker('write'), 'data-dsh-bots-add-write': true }, t('letBotWrite')),
2614
2847
  h('span', { style: { flex: 1 } }),
2615
2848
  editing ? null : h('button', { type: 'button', className: 'dshb-link', style: { fontSize: SMALL, color: C.muted }, onClick: () => setEditing({ name: '', description: '', content: '', enabled: true }), 'data-dsh-bots-add-skill': true }, t('writeByHand')),
@@ -2619,7 +2852,14 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2619
2852
  {
2620
2853
  title: t('botSkills', { n: skills.length }),
2621
2854
  hint: t('skillsHint2', { name: bot.name }),
2622
- right: skills.length ? h('span', { style: { fontSize: TINY, color: C.faint } }, t('skillMix', counts)) : null,
2855
+ right: skills.length
2856
+ ? h(
2857
+ 'span',
2858
+ { style: { fontSize: TINY, color: C.faint } },
2859
+ `${t('skillMix', counts)} · `,
2860
+ h('span', { 'data-dsh-bots-skills-on': onCount(skills), style: onCount(skills) >= skillLimits().on ? { color: C.warn, fontWeight: 600 } : null }, t('skillsOnOf', { n: onCount(skills), max: skillLimits().on })),
2861
+ )
2862
+ : null,
2623
2863
  },
2624
2864
  editing ? h(SkillEditor, { t, skill: editing, onChange: setEditing, onCancel: () => setEditing(null), onSave: saveSkill, busy }) : null,
2625
2865
  skills.length === 0 && !editing
@@ -2636,8 +2876,16 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2636
2876
  'div',
2637
2877
  { style: { display: 'flex', alignItems: 'center', gap: 8 } },
2638
2878
  h('span', { className: 'dshb-mono', style: { fontWeight: 650, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: s.name }, s.name),
2639
- h(SourceBadge, { t, source: src }),
2640
- h(Switch, { on: s.enabled !== false, disabled: busy, title: s.enabled !== false ? t('disable') : t('enable'), onChange: (on) => void commit(skills.map((x) => (x === s ? { ...x, enabled: on } : x))) }),
2879
+ h(SourceBadge, { t, source: src, local: isLocalSkill(s) }),
2880
+ h(Switch, {
2881
+ on: s.enabled !== false,
2882
+ disabled: busy,
2883
+ title: s.enabled !== false ? t('disable') : t('enable'),
2884
+ onChange: (on) => {
2885
+ if (on && onCount(skills) >= skillLimits().on) return void toast(t('tooManyOn', { max: skillLimits().on }), 'error');
2886
+ void commit(skills.map((x) => (x === s ? { ...x, enabled: on } : x)));
2887
+ },
2888
+ }),
2641
2889
  ),
2642
2890
  h('div', { className: 'dshb-clamp2', style: { fontSize: SMALL, color: C.muted, minHeight: 37, lineHeight: 1.5 }, title: s.description }, s.description || h('i', { style: { color: C.faint } }, t('noDescription'))),
2643
2891
  h(
@@ -2646,9 +2894,11 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2646
2894
  src === 'dsh'
2647
2895
  ? h('span', { style: { fontSize: TINY, color: C.faint, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, t('harnessManaged'))
2648
2896
  : src === 'import'
2649
- ? h('span', { style: { flex: 1, minWidth: 0, overflow: 'hidden' } }, s.origin ? h(ExtLink, { href: s.origin, title: s.origin }, str(s.origin).replace(/^https:\/\/github\.com\//, '').split('/').slice(0, 2).join('/')) : null)
2897
+ ? isLocalSkill(s)
2898
+ ? h('span', { className: 'dshb-mono', 'data-dsh-bots-skill-origin': s.origin, 'data-missing': s.missing ? true : undefined, style: { fontSize: TINY, color: s.missing ? C.error : C.faint, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: s.missing ? `${t('folderMissing')} ${s.origin}` : `${t('linkedHint')} ${s.origin}` }, s.missing ? t('folderMissing') : str(s.origin).split(/[\\/]/).filter(Boolean).slice(-2).join('/'))
2899
+ : h('span', { style: { flex: 1, minWidth: 0, overflow: 'hidden' } }, s.origin ? h(ExtLink, { href: s.origin, title: s.origin }, str(s.origin).replace(/^https:\/\/github\.com\//, '').split('/').slice(0, 2).join('/')) : null)
2650
2900
  : h('span', { style: { fontSize: TINY, color: C.faint, flex: 1 } }, t('chars', { n: str(s.content).length })),
2651
- src === 'dsh' ? null : h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.edit(12), title: t('edit'), onClick: () => setEditing({ ...s, description: str(s.description), content: str(s.content) }) }),
2901
+ src === 'dsh' || isLocalSkill(s) ? null : h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.edit(12), title: t('edit'), onClick: () => setEditing({ ...s, description: str(s.description), content: str(s.content) }) }),
2652
2902
  h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.trash(12), title: t('remove'), className: 'dshb-btn dshb-btn-sm dshb-btn-icon dshb-btn-ghost dshb-btn-danger', onClick: () => setConfirm(s) }),
2653
2903
  ),
2654
2904
  );
@@ -2658,6 +2908,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
2658
2908
  ),
2659
2909
  picker === 'harness' ? h(HarnessPicker, { t, bot, busy, onClose: () => setPicker(null), onAdd: addHarness }) : null,
2660
2910
  picker === 'github' ? h(GithubPicker, { t, lang, bot, catalog, toast, onClose: () => setPicker(null), onImported: () => setPicker(null) }) : null,
2911
+ picker === 'local' ? h(LocalPicker, { t, bot, catalog, env, toast, onClose: () => setPicker(null), onImported: () => setPicker(null) }) : null,
2661
2912
  picker === 'write'
2662
2913
  ? h(WriteSkillModal, {
2663
2914
  t,
@@ -3037,19 +3288,21 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3037
3288
  }
3038
3289
  return out;
3039
3290
  }
3040
- // --- chat channels (Telegram, Discord): apps people message the team from -----------------
3291
+ // --- chat channels (Telegram, Discord, Feishu, Slack): apps people message the team from --
3041
3292
 
3042
- const CHANNEL_NAMES = { telegram: 'Telegram', discord: 'Discord' };
3043
- const CHANNEL_COLORS = { telegram: '#229ED9', discord: '#5865F2' };
3044
- const channelName = (kind) => CHANNEL_NAMES[kind] ?? str(kind);
3293
+ const CHANNEL_NAMES = { telegram: 'Telegram', discord: 'Discord', slack: 'Slack', feishu: 'Feishu' };
3294
+ const CHANNEL_COLORS = { telegram: '#229ED9', discord: '#5865F2', slack: '#4a154b', feishu: '#3370ff' };
3295
+ const channelName = (kind, t) => (kind === 'feishu' && langOf(t) === 'zh' ? '飞书' : CHANNEL_NAMES[kind] ?? str(kind));
3045
3296
  const isChannelEntry = (entry) => entry?.kind === 'channel';
3297
+ /** Hint codes that read differently per chat app. */
3298
+ const KIND_HINTS = new Set(['slack_scopes', 'feishu_scopes']);
3046
3299
 
3047
3300
  /** Under a chat channel's row: whether it is connected, the pairing code, and who is paired. */
3048
3301
  function ChannelPanel({ t, bot, app, entry, view, toast }) {
3049
3302
  const [working, setWorking] = useState('');
3050
3303
  const v = view && typeof view === 'object' ? view : { state: 'connecting', paired: [] };
3051
3304
  const kind = str(v.kind || entry?.channel);
3052
- const appName = channelName(kind);
3305
+ const appName = channelName(kind, t);
3053
3306
  const handle = v.account?.username ? `@${v.account.username}` : appName;
3054
3307
  const paired = Array.isArray(v.paired) ? v.paired : [];
3055
3308
  const call = (path, body, okText) => {
@@ -3065,7 +3318,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3065
3318
  .finally(() => setWorking(''));
3066
3319
  };
3067
3320
  const state = str(v.state) || 'connecting';
3068
- const hintText = v.hint ? t(`channelHint_${v.hint}`, { app: appName }) : '';
3321
+ const hintText = v.hint ? t(KIND_HINTS.has(`${kind}_${v.hint}`) ? `channelHint_${kind}_${v.hint}` : `channelHint_${v.hint}`, { app: appName }) : '';
3069
3322
  const dot = (color) => h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: color, flex: 'none' } });
3070
3323
  const statusLine =
3071
3324
  state === 'connected'
@@ -3078,7 +3331,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3078
3331
  ? [dot(C.faint), h('span', { key: 's', style: { color: C.muted } }, t('channelOff'))]
3079
3332
  : [dot('#d97706'), h('span', { key: 's', style: { color: C.muted } }, t('channelMissing', { app: appName }))];
3080
3333
  const live = state !== 'off' && state !== 'missing';
3081
- const step = kind === 'telegram' ? t('pairStepTelegram', { handle }) : kind === 'discord' ? t('pairStepDiscord', { handle }) : t('pairStep', { handle, app: appName });
3334
+ const step = kind === 'telegram' ? t('pairStepTelegram', { handle }) : kind === 'discord' ? t('pairStepDiscord', { handle }) : kind === 'slack' ? t('pairStepSlack', { handle }) : kind === 'feishu' ? t('pairStepFeishu', { handle }) : t('pairStep', { handle, app: appName });
3082
3335
  return h(
3083
3336
  'div',
3084
3337
  { 'data-dsh-bots-channel': app.id, 'data-state': state, style: { display: 'flex', flexDirection: 'column', gap: 10, margin: '0 14px 12px 62px', padding: '10px 12px', borderRadius: 10, background: C.base, border: `1px solid ${C.border1}`, fontSize: SMALL } },
@@ -3688,7 +3941,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
3688
3941
  const counts = { skills: (bot.skills ?? []).length, apps: (bot.apps ?? []).length };
3689
3942
  let body;
3690
3943
  if (tab === 'profile') body = h(ProfileTab, { key: bot.id, t, bot, toast, catalog });
3691
- else if (tab === 'skills') body = h(SkillsTab, { key: bot.id, t, bot, toast, catalog, setTab });
3944
+ else if (tab === 'skills') body = h(SkillsTab, { key: bot.id, t, bot, toast, catalog, setTab, env });
3692
3945
  else if (tab === 'schedules') body = h(SchedulesTab, { key: bot.id, t, bot, toast, catalog });
3693
3946
  else if (tab === 'apps') body = h(AppsTab, { key: bot.id, t, bot, toast, catalog });
3694
3947
  else body = h(ChatTab, { key: bot.id, t, bot, env, toast });
@@ -4918,7 +5171,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
4918
5171
  installedApps: 'Installed apps ({n})',
4919
5172
  noApps: 'No apps yet. Add one from the gallery below.',
4920
5173
  appGallery: 'App gallery',
4921
- appGalleryHint: '{n} apps. Most are MCP servers whose tools appear to this bot only; chat apps (Telegram, Discord) let you message the team from your phone.',
5174
+ appGalleryHint: '{n} apps. Most are MCP servers whose tools appear to this bot only; chat apps (Feishu / Lark, Telegram, Slack, Discord) let you message the team from your phone.',
4922
5175
  noTemplates: 'No templates.',
4923
5176
  featured: 'Featured',
4924
5177
  allApps: 'All',
@@ -5064,6 +5317,34 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5064
5317
  importN: "Import {n}",
5065
5318
  importing: "Importing…",
5066
5319
  importedN: "Imported {n} skills.",
5320
+ updatedN: "Updated {n}.",
5321
+ skippedN: "Skipped {n}: a skill of that name is already here.",
5322
+ fullN: "Skipped {n}: a bot keeps at most {max} skills.",
5323
+ offN: "{n} came in switched off: at most {max} skills can be on at once.",
5324
+ tooManyOn: "At most {max} skills can be on at once. Switch one off first.",
5325
+ skillsFull: "A bot keeps at most {max} skills. Remove one first.",
5326
+ skillsRoom: "A bot keeps at most {max} skills; there is room for {n} more.",
5327
+ skillsOnOf: "{n}/{max} on",
5328
+ nameTaken: "Name already used",
5329
+ reimport: "Imported · import again to update",
5330
+ skillNameTaken: "This bot already has a skill named “{name}”.",
5331
+ importLocal: "Add from a folder",
5332
+ localPickerTitle: "Add skills from a local folder",
5333
+ localHint: "Pick a skill folder (one with a SKILL.md), or a folder that holds several.",
5334
+ localNote: "Linked, never copied: edit the folder and the bot uses the new version.",
5335
+ linked: "Linked",
5336
+ linkedHint: "Read from this folder each time; edit it there.",
5337
+ folderMissing: "Folder not found",
5338
+ localFailed: "Could not read that folder.",
5339
+ localNone: "No SKILL.md in this folder or the folders below it.",
5340
+ localTruncated: "The folder is large; only part of it was searched. Pick a folder closer to the skills.",
5341
+ localPlaces: "Found on this machine:",
5342
+ chooseFolder: "Choose folder…",
5343
+ pickFailed: "The folder dialog is unavailable here; type or paste the path instead.",
5344
+ scan: "Scan",
5345
+ readingFolder: "Reading the folder…",
5346
+ alsoInHarness: "A skill of this name is also installed in the Harness (see “Add from Harness”).",
5347
+ src_local: "Local",
5067
5348
  importFailed: "Import failed.",
5068
5349
  browse: "Browse",
5069
5350
  foundSkills: "{n} skills",
@@ -5083,8 +5364,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5083
5364
  letBotWrite: "Let the bot write it",
5084
5365
  writeByHand: "Write by hand",
5085
5366
  skillsHint2: "Instructions {name} loads when a task needs them.",
5086
- skillMix: "{dsh} Harness · {import} GitHub · {own} own",
5087
- noSkillsBody2: "Add skills already installed in your Harness, import a folder from GitHub, or describe one and let the bot write it.",
5367
+ skillMix: "{dsh} Harness · {import} GitHub · {local} local · {own} own",
5368
+ noSkillsBody2: "Add skills already installed in your Harness, import a folder from GitHub or from this machine, or describe one and let the bot write it.",
5088
5369
  harnessManaged: "Provided by the Harness, kept up to date",
5089
5370
  src_dsh: "Harness",
5090
5371
  src_import: "GitHub",
@@ -5119,6 +5400,17 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5119
5400
  channelHint_intent: 'Turn on Message Content Intent: Developer Portal → your app → Bot → Privileged Gateway Intents. Then reconnect.',
5120
5401
  channelHint_conflict: 'Another program is using this bot token. Stop it, or create a separate bot for the team.',
5121
5402
  channelHint_duplicate: 'This token is already connected on another bot; one token can run in one place.',
5403
+ channelHint_app_token: 'Slack rejected the app-level token (xapp-…). In your Slack app open Basic Information → App-Level Tokens, generate one with the connections:write scope, paste it and save.',
5404
+ channelHint_app_scope: 'The app-level token lacks the connections:write scope. Generate a new one with it under Basic Information → App-Level Tokens, paste it and save.',
5405
+ channelHint_token_kind: 'The tokens are in the wrong fields: the Bot token starts with xoxb- (OAuth & Permissions), the App-level token with xapp- (Basic Information → App-Level Tokens).',
5406
+ channelHint_slack_scopes: 'The Slack app is missing permissions. Add them under OAuth & Permissions → Bot Token Scopes (or create the app from the manifest), reinstall it to the workspace, then reconnect.',
5407
+ channelHint_socket_mode: 'Socket Mode is off for this Slack app. Turn it on (your app → Socket Mode → Enable Socket Mode), then reconnect.',
5408
+ channelHint_secret: '{app} rejected the App Secret. Copy it again from the developer console (Credentials & Basic Info) and save.',
5409
+ channelHint_appId: 'Neither Feishu nor Lark knows this App ID. Copy it from the developer console (Credentials & Basic Info); it starts with cli_.',
5410
+ channelHint_disabled: '{app} says this app is disabled. Enable it in the developer console (or ask your admin), then reconnect.',
5411
+ channelHint_bot: 'Turn on the bot: developer console → Add Features → Bot, then publish a version. The long connection is already up, so you can set up Events & Callbacks now; this connects by itself once the bot is live.',
5412
+ channelHint_feishu_scopes: 'The app may not send messages. Add the permission im:message:send_as_bot (Permissions & Scopes) and publish a version.',
5413
+ channelHint_connlimit: 'This app already has the most long connections Feishu allows (50). Stop other programs that use this App ID.',
5122
5414
  reconnect: 'Reconnect',
5123
5415
  pairedPeople: 'Paired people ({n})',
5124
5416
  nobodyPaired: 'Nobody yet. Until someone is paired, the bot answers no one in {app}.',
@@ -5127,6 +5419,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5127
5419
  unpaired: '{name} removed.',
5128
5420
  pairStepTelegram: 'From your own Telegram account, send this code to {handle}, or open the link and press Start. It works once.',
5129
5421
  pairStepDiscord: 'From your own Discord account, send this code to {handle} in a direct message. It works once.',
5422
+ pairStepFeishu: 'In Feishu, open a chat with {handle} (search for the app, or use Open in Feishu) and send this code. It works once.',
5423
+ pairStepSlack: 'From your own Slack account, open the app\'s Messages tab (or the link) and send this code. It works once.',
5130
5424
  pairStep: 'From your own {app} account, send this code to {handle}. It works once.',
5131
5425
  copy: 'Copy',
5132
5426
  copied: 'Copied.',
@@ -5400,7 +5694,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5400
5694
  installedApps: '已安装的应用({n})',
5401
5695
  noApps: '还没有应用。从下方的应用库添加一个。',
5402
5696
  appGallery: '应用库',
5403
- appGalleryHint: '共 {n} 个应用。大多是 MCP 服务器,工具只对这个 Bot 可见;聊天应用(Telegram、Discord)让你用手机给团队发消息。',
5697
+ appGalleryHint: '共 {n} 个应用。大多是 MCP 服务器,工具只对这个 Bot 可见;聊天应用(飞书、Telegram、Slack、Discord)让你用手机给团队发消息。',
5404
5698
  noTemplates: '没有模板。',
5405
5699
  featured: '推荐',
5406
5700
  allApps: '全部',
@@ -5545,6 +5839,34 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5545
5839
  importN: "导入 {n} 个",
5546
5840
  importing: "导入中…",
5547
5841
  importedN: "已导入 {n} 个技能。",
5842
+ updatedN: "已更新 {n} 个。",
5843
+ skippedN: "跳过 {n} 个:已有同名技能。",
5844
+ fullN: "跳过 {n} 个:一个 Bot 最多放 {max} 个技能。",
5845
+ offN: "其中 {n} 个先关着:最多同时开 {max} 个技能。",
5846
+ tooManyOn: "最多同时开 {max} 个技能,先关掉一个。",
5847
+ skillsFull: "一个 Bot 最多放 {max} 个技能,先删掉一个。",
5848
+ skillsRoom: "一个 Bot 最多放 {max} 个技能,还能加 {n} 个。",
5849
+ skillsOnOf: "开着 {n}/{max}",
5850
+ nameTaken: "已有同名技能",
5851
+ reimport: "已导入 · 再次导入可更新",
5852
+ skillNameTaken: "这个 Bot 已经有名为“{name}”的技能。",
5853
+ importLocal: "从本地文件夹添加",
5854
+ localPickerTitle: "从本地文件夹添加技能",
5855
+ localHint: "选一个技能文件夹(里面有 SKILL.md),或者一个装着多个技能的文件夹。",
5856
+ localNote: "只引用、不复制:改了原文件夹,Bot 就用新的。",
5857
+ linked: "已引用",
5858
+ linkedHint: "每次都从这个文件夹读取,要改就改那里。",
5859
+ folderMissing: "文件夹找不到了",
5860
+ localFailed: "读取这个文件夹失败。",
5861
+ localNone: "这个文件夹和它的子文件夹里都没有 SKILL.md。",
5862
+ localTruncated: "文件夹太大,只搜索了一部分。请选离技能更近的文件夹。",
5863
+ localPlaces: "本机已有:",
5864
+ chooseFolder: "选择文件夹…",
5865
+ pickFailed: "这里打不开文件夹选择框,请直接输入或粘贴路径。",
5866
+ scan: "扫描",
5867
+ readingFolder: "正在读取文件夹…",
5868
+ alsoInHarness: "Harness 里也安装了同名技能(见“从 Harness 添加”)。",
5869
+ src_local: "本地",
5548
5870
  importFailed: "导入失败。",
5549
5871
  browse: "浏览",
5550
5872
  foundSkills: "{n} 个技能",
@@ -5564,8 +5886,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5564
5886
  letBotWrite: "让 Bot 自己写",
5565
5887
  writeByHand: "手写",
5566
5888
  skillsHint2: "{name} 在任务需要时加载的说明。",
5567
- skillMix: "Harness {dsh} · GitHub {import} · 自写 {own}",
5568
- noSkillsBody2: "添加 Harness 里已安装的技能、从 GitHub 导入,或者描述一下让 Bot 自己写。",
5889
+ skillMix: "Harness {dsh} · GitHub {import} · 本地 {local} · 自写 {own}",
5890
+ noSkillsBody2: "添加 Harness 里已安装的技能、从 GitHub 或本地文件夹导入,或者描述一下让 Bot 自己写。",
5569
5891
  harnessManaged: "由 Harness 提供,自动保持最新",
5570
5892
  src_dsh: "Harness",
5571
5893
  src_import: "GitHub",
@@ -5600,6 +5922,17 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5600
5922
  channelHint_intent: '请打开 Message Content Intent:开发者后台 → 你的应用 → Bot → Privileged Gateway Intents,然后重新连接。',
5601
5923
  channelHint_conflict: '另一个程序正在使用这个 Bot Token。请停掉它,或给团队单独建一个 Bot。',
5602
5924
  channelHint_duplicate: '这个 Token 已经在另一个 Bot 上连接了;一个 Token 只能在一处运行。',
5925
+ channelHint_app_token: 'Slack 拒绝了 App 级 Token(xapp-…)。请在 Slack 应用的 Basic Information → App-Level Tokens 里生成一个带 connections:write 权限的 Token,粘贴后保存。',
5926
+ channelHint_app_scope: 'App 级 Token 缺少 connections:write 权限。请在 Basic Information → App-Level Tokens 重新生成一个带该权限的 Token,粘贴后保存。',
5927
+ channelHint_token_kind: 'Token 填错位置了:Bot Token 以 xoxb- 开头(OAuth & Permissions 页),App 级 Token 以 xapp- 开头(Basic Information → App-Level Tokens)。',
5928
+ channelHint_slack_scopes: 'Slack 应用缺少权限。请在 OAuth & Permissions → Bot Token Scopes 里补上(或用清单重新创建应用),重新安装到工作区,然后点重新连接。',
5929
+ channelHint_socket_mode: '这个 Slack 应用没有开启 Socket Mode。请在应用的 Socket Mode 页打开 Enable Socket Mode,然后点重新连接。',
5930
+ channelHint_secret: '{app} 拒绝了这个 App Secret。请到开发者后台「凭证与基础信息」重新复制并保存。',
5931
+ channelHint_appId: '飞书和 Lark 都找不到这个 App ID。请到开发者后台「凭证与基础信息」复制,它以 cli_ 开头。',
5932
+ channelHint_disabled: '{app} 提示这个应用已停用。请在开发者后台启用(或联系管理员),然后重新连接。',
5933
+ channelHint_bot: '请开启机器人:开发者后台 →「添加应用能力」→「机器人」,然后发布版本。长连接已经在线,现在就可以去配置「事件与回调」;机器人生效后会自动连上。',
5934
+ channelHint_feishu_scopes: '应用没有发消息的权限。请在「权限管理」开通 im:message:send_as_bot 并发布版本。',
5935
+ channelHint_connlimit: '这个应用的长连接数已达飞书上限(50 个)。请停掉其他使用这个 App ID 的程序。',
5603
5936
  reconnect: '重新连接',
5604
5937
  pairedPeople: '已配对的人({n})',
5605
5938
  nobodyPaired: '还没有人。配对之前,Bot 在 {app} 里不回复任何人。',
@@ -5608,6 +5941,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5608
5941
  unpaired: '已移除 {name}。',
5609
5942
  pairStepTelegram: '用你自己的 Telegram 账号把这个配对码发给 {handle},或打开链接后点 Start。只能用一次。',
5610
5943
  pairStepDiscord: '用你自己的 Discord 账号私信 {handle},发送这个配对码。只能用一次。',
5944
+ pairStepFeishu: '在飞书里打开和 {handle} 的单聊(搜索应用名,或点「在飞书中打开」),发送这个配对码。只能用一次。',
5945
+ pairStepSlack: '用你自己的 Slack 账号打开这个应用的 Messages 标签页(或点链接),发送这个配对码。只能用一次。',
5611
5946
  pairStep: '用你自己的 {app} 账号把这个配对码发给 {handle}。只能用一次。',
5612
5947
  copy: '复制',
5613
5948
  copied: '已复制。',
@@ -5677,7 +6012,17 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
5677
6012
  return false;
5678
6013
  }
5679
6014
  };
6015
+ // The Host's own folder dialog: the desktop shell's when there is one, else the workspace service's.
6016
+ const directoryPicker = () => {
6017
+ const desktop = globalThis.__DSH_DIRECTORY_PICKER__;
6018
+ if (typeof desktop?.pick === 'function') return () => desktop.pick();
6019
+ const ws = service('uiWorkspace');
6020
+ return typeof ws?.pickDirectory === 'function' ? () => ws.pickDirectory() : null;
6021
+ };
5680
6022
  const env = {
6023
+ // Asked at use: the workspace service may come up after this client does.
6024
+ canPickDirectory: () => directoryPicker() !== null,
6025
+ pickDirectory: () => (directoryPicker() ?? (() => null))(),
5681
6026
  canOpen: () => typeof service('uiWorkspace')?.openSession === 'function',
5682
6027
  canPanel: () => typeof service('layout')?.selectPanel === 'function',
5683
6028
  /** Ensure the bot's home conversation, then show it; false on failure. */