@restregular/dsh-powerup 0.19.16 → 0.19.18

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 (3) hide show
  1. package/README.md +30 -1
  2. package/client.js +189 -144
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -577,10 +577,39 @@ returned as the cleanup), so a toggle cannot leave stale registrations behind.
577
577
 
578
578
  ## Development
579
579
 
580
+ The client source lives in `src/`, one module per feature; the shipped
581
+ `client.js` is generated by concatenating those modules into a single classic
582
+ script (the host merges every client bundle into one script realm, so the
583
+ artifact must stay self-contained).
584
+
580
585
  ```bash
581
- npm test
586
+ node scripts/build.mjs # concatenate src/ -> client.js
587
+ node scripts/build.mjs --check # fail when client.js is stale (runs before tests)
588
+ pnpm test # build check + full test suite
582
589
  ```
583
590
 
591
+ ### Source layout
592
+
593
+ | Path | Contents |
594
+ |---|---|
595
+ | `src/prelude/` | IIFE wrapper, runtime shims, plugin constants, module exports |
596
+ | `src/i18n/` | zh/en dictionaries and translator wiring |
597
+ | `src/stores/` | settings, workspace prompts, mask rules (cache + subscription) |
598
+ | `src/features/<name>/` | one directory per feature (launcher, context-menu, progress, quick-replies, plugin-update, direct-ask, ...) |
599
+ | `src/ui/` | shared icons, styles, toast, popover placement, markdown renderer, Power-Up page |
600
+ | `src/core/` | cross-feature installers (style injection) |
601
+ | `src/apply.js` | `PREINSTALL` steps + the `REGISTRY` table that registers every host slot |
602
+
603
+ ### Adding a feature
604
+
605
+ 1. Create `src/features/<name>/` with the feature's code (it shares the
606
+ factory scope — do not redeclare existing top-level names).
607
+ 2. Add one entry to `REGISTRY` in `src/apply.js` (slot, options, component,
608
+ label; use `inject` for services that may arrive late).
609
+ 3. Add styles to `src/styles/10-css.js`, dictionary keys to `src/i18n/10-dict.js`,
610
+ and exports used by tests to `src/prelude/90-exports.js`.
611
+ 4. `node scripts/build.mjs && pnpm test`.
612
+
584
613
  `node test/smoke.mjs` loads the real Client module with React/browser doubles,
585
614
  applies it to a fake slot context, and checks registrations, icons, helpers,
586
615
  theme tokens, the step-reference copy path, the stop-reason mapping, the Host
package/client.js CHANGED
@@ -98,7 +98,7 @@
98
98
  const requirementCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
99
99
  /** Fallback bucket when the hero cannot resolve an owning workspace yet. */
100
100
  const UNSCOPED_WORKSPACE = '__unscoped__';
101
- const VERSION = '0.19.15';
101
+ const VERSION = '0.19.18';
102
102
  const MENU_GAP = 8;
103
103
  const MENU_WIDTH = 248;
104
104
  /** Reference scheme understood by the Host's `powerup_step_read` tool. */
@@ -12564,171 +12564,216 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12564
12564
  }
12565
12565
 
12566
12566
  // ------------------------------------------------------------------
12567
- // Plugin body
12567
+ // Plugin body: one registry drives every slot registration.
12568
+ //
12569
+ // To add a feature: create src/features/<name>/, then add ONE entry to
12570
+ // REGISTRY below (plus its exports in prelude/90-exports.js when tests
12571
+ // need them). Registration order in REGISTRY is also install order.
12568
12572
  // ------------------------------------------------------------------
12569
- function apply(ctx) {
12570
- ctxRef.current = ctx;
12571
- ctx.effect(() => () => {
12572
- if (ctxRef.current === ctx) ctxRef.current = null;
12573
- }, 'dsh-powerup: client context');
12574
- bindLocale(ctx);
12575
- installStyles(ctx);
12573
+ /** Install steps that run before any slot registration. */
12574
+ const PREINSTALL = [
12575
+ { label: 'dsh-powerup: client context', run(ctx) {
12576
+ ctxRef.current = ctx;
12577
+ ctx.effect(() => () => {
12578
+ if (ctxRef.current === ctx) ctxRef.current = null;
12579
+ }, 'dsh-powerup: client context');
12580
+ } },
12581
+ { label: 'dsh-powerup: locale', run: bindLocale },
12582
+ { label: 'dsh-powerup: styles', run: installStyles },
12576
12583
  // Align the Host tool/prompt registration with this browser's switch on load.
12577
- syncQuickRepliesEnabled(settingsValue.quickReplies);
12578
- installLauncher(ctx);
12579
- installSessionSwitcher(ctx);
12580
- installLocateSession(ctx);
12581
- installScrollToTop(ctx);
12582
- installThemeToggle(ctx);
12583
- installReplyMask(ctx);
12584
-
12585
- const slots = ctx.get('slots');
12586
- if (slots === undefined || typeof slots.inject !== 'function' || typeof slots.register !== 'function') {
12587
- console.warn('[dsh-powerup] slots service missing; Power-Up UI disabled');
12588
- return;
12589
- }
12590
-
12591
- const register = (slot, options, component, label) => {
12592
- try {
12593
- ctx.effect(
12594
- () => slots.inject(slot, () => slots.register({ name: slot, ...options }, component)),
12595
- label,
12596
- );
12597
- } catch (error) {
12598
- console.warn(`[dsh-powerup] could not register ${slot}:`, error?.message ?? error);
12599
- }
12600
- };
12601
-
12602
- register('sidebar.panellist', {
12603
- id: 'powerup',
12604
- order: 30,
12605
- label: () => translateCurrent('panel.title'),
12606
- }, (props) => h(PowerUpLineIcon, { size: props?.size ?? 16 }), 'dsh-powerup: sidebar entry');
12607
-
12608
- register('main', { key: 'powerup' }, () => h(PowerUpPage, { ctx }), 'dsh-powerup: main page');
12609
-
12610
- register('shell.overlay', {
12611
- id: 'powerup-context-menu',
12612
- order: 55,
12613
- }, () => h(PowerUpOverlay, { ctx }), 'dsh-powerup: context menu');
12614
-
12615
- register('conversation.session.header.utilities', {
12616
- id: 'powerup-bridge',
12617
- order: 50,
12618
- }, PowerUpBridge, 'dsh-powerup: session bridge');
12619
-
12620
- register('conversation.session.header.utilities', {
12621
- id: 'powerup-progress',
12622
- order: 52,
12623
- }, (props) => h(ProgressControl, {
12624
- sessionId: props?.sessionId,
12625
- // The header utilities slot provides useWorkspaces as a standard
12626
- // scoped hook; forward it so the requirement modal can resolve the
12627
- // owning workspace (ctx.get('workspaces').list is Host-only).
12628
- useWorkspaces: props?.useWorkspaces,
12629
- // DSH 0.2.3 standard hooks, forwarded to the host ModelSelect we
12630
- // render inside the panel. Without them the slot entry crashes and
12631
- // this very button disappears once the panel is opened.
12632
- useMobile: props?.useMobile,
12633
- useDocumentPortal: props?.useDocumentPortal,
12634
- }), 'dsh-powerup: task progress');
12635
-
12636
- register('conversation.hero.options', {
12637
- id: 'powerup-prompts',
12638
- order: 60,
12639
- }, HeroPromptsControl, 'dsh-powerup: prompt picker');
12584
+ { label: 'dsh-powerup: quick replies sync', run: () => syncQuickRepliesEnabled(settingsValue.quickReplies) },
12585
+ { label: 'dsh-powerup: launcher', run: installLauncher },
12586
+ { label: 'dsh-powerup: session switcher', run: installSessionSwitcher },
12587
+ { label: 'dsh-powerup: locate session', run: installLocateSession },
12588
+ { label: 'dsh-powerup: scroll to top', run: installScrollToTop },
12589
+ { label: 'dsh-powerup: theme toggle', run: installThemeToggle },
12590
+ { label: 'dsh-powerup: reply mask', run: installReplyMask },
12591
+ ];
12640
12592
 
12593
+ /**
12594
+ * Every slot Power-Up registers, in one table. Shape:
12595
+ * slot — the host slot name
12596
+ * options — the entry options (id/order/label/key)
12597
+ * component — React component receiving (props) or a factory (ctx)
12598
+ * label — effect label used in logs and disposal
12599
+ * inject — optional nested-inject service(s); the entry mounts in a
12600
+ * child scope that observes the service instead of the
12601
+ * root scope, so a late-provided service still registers.
12602
+ * forward — optional list of standard slot props (useWorkspaces,
12603
+ * useMobile, useDocumentPortal) to pass through explicitly.
12604
+ */
12605
+ const REGISTRY = [
12606
+ {
12607
+ slot: 'sidebar.panellist',
12608
+ options: { id: 'powerup', order: 30, label: () => translateCurrent('panel.title') },
12609
+ component: (props) => h(PowerUpLineIcon, { size: props?.size ?? 16 }),
12610
+ label: 'dsh-powerup: sidebar entry',
12611
+ },
12612
+ {
12613
+ slot: 'main',
12614
+ options: { key: 'powerup' },
12615
+ component: (props, ctx) => h(PowerUpPage, { ctx }),
12616
+ label: 'dsh-powerup: main page',
12617
+ },
12618
+ {
12619
+ slot: 'shell.overlay',
12620
+ options: { id: 'powerup-context-menu', order: 55 },
12621
+ component: (props, ctx) => h(PowerUpOverlay, { ctx }),
12622
+ label: 'dsh-powerup: context menu',
12623
+ },
12624
+ {
12625
+ slot: 'conversation.session.header.utilities',
12626
+ options: { id: 'powerup-bridge', order: 50 },
12627
+ component: PowerUpBridge,
12628
+ label: 'dsh-powerup: session bridge',
12629
+ },
12630
+ {
12631
+ slot: 'conversation.session.header.utilities',
12632
+ options: { id: 'powerup-progress', order: 52 },
12633
+ component: (props) => h(ProgressControl, {
12634
+ sessionId: props?.sessionId,
12635
+ // The header utilities slot provides useWorkspaces as a standard
12636
+ // scoped hook; forward it so the requirement modal can resolve the
12637
+ // owning workspace (ctx.get('workspaces').list is Host-only).
12638
+ useWorkspaces: props?.useWorkspaces,
12639
+ // DSH 0.2.3 standard hooks, forwarded to the host ModelSelect we
12640
+ // render inside the panel. Without them the slot entry crashes and
12641
+ // this very button disappears once the panel is opened.
12642
+ useMobile: props?.useMobile,
12643
+ useDocumentPortal: props?.useDocumentPortal,
12644
+ }),
12645
+ label: 'dsh-powerup: task progress',
12646
+ },
12647
+ {
12648
+ slot: 'conversation.hero.options',
12649
+ options: { id: 'powerup-prompts', order: 60 },
12650
+ component: HeroPromptsControl,
12651
+ label: 'dsh-powerup: prompt picker',
12652
+ },
12641
12653
  // Session-scope composer controls. These receive sessionId/useInput/
12642
12654
  // inputActions from the host's conversation slot wiring; the t() locale
12643
12655
  // seat is provided by the slot, so we wrap to use the plugin dictionary.
12644
- register('conversation.input.right', {
12645
- id: 'powerup-dual-send',
12646
- order: 80,
12647
- }, (props) => h(DualSendButtons, {
12648
- ...props,
12649
- ctx,
12650
- t: (key, params) => translateCurrent(key, params),
12651
- }), 'dsh-powerup: dual send buttons');
12652
-
12653
- register('conversation.input.right', {
12654
- id: 'powerup-direct-ask',
12655
- order: 82,
12656
- }, (props) => h(DirectAskButton, {
12657
- ...props,
12658
- ctx,
12659
- t: (key, params) => translateCurrent(key, params),
12660
- }), 'dsh-powerup: direct ask');
12661
-
12662
- register('conversation.input.right', {
12663
- id: 'powerup-quick-replies',
12664
- order: 84,
12665
- }, (props) => h(QuickReplies, {
12666
- ...props,
12667
- ctx,
12668
- t: (key, params) => translateCurrent(key, params),
12669
- }), 'dsh-powerup: quick replies');
12670
-
12656
+ {
12657
+ slot: 'conversation.input.right',
12658
+ options: { id: 'powerup-dual-send', order: 80 },
12659
+ component: (props, ctx) => h(DualSendButtons, {
12660
+ ...props,
12661
+ ctx,
12662
+ t: (key, params) => translateCurrent(key, params),
12663
+ }),
12664
+ label: 'dsh-powerup: dual send buttons',
12665
+ },
12666
+ {
12667
+ slot: 'conversation.input.right',
12668
+ options: { id: 'powerup-direct-ask', order: 82 },
12669
+ component: (props, ctx) => h(DirectAskButton, {
12670
+ ...props,
12671
+ ctx,
12672
+ t: (key, params) => translateCurrent(key, params),
12673
+ }),
12674
+ label: 'dsh-powerup: direct ask',
12675
+ },
12676
+ {
12677
+ slot: 'conversation.input.right',
12678
+ options: { id: 'powerup-quick-replies', order: 84 },
12679
+ component: (props, ctx) => h(QuickReplies, {
12680
+ ...props,
12681
+ ctx,
12682
+ t: (key, params) => translateCurrent(key, params),
12683
+ }),
12684
+ label: 'dsh-powerup: quick replies',
12685
+ },
12671
12686
  // In an ongoing session, place the prompt picker in the bottom tool row
12672
12687
  // just after the host's permission / plan dropdowns; its popover opens
12673
12688
  // upward so it is not clipped by the screen bottom.
12674
- register('conversation.input.left', {
12675
- id: 'powerup-prompts-composer',
12676
- order: 10,
12677
- }, ComposerPromptsControl, 'dsh-powerup: composer prompt picker');
12678
-
12689
+ {
12690
+ slot: 'conversation.input.left',
12691
+ options: { id: 'powerup-prompts-composer', order: 10 },
12692
+ component: ComposerPromptsControl,
12693
+ label: 'dsh-powerup: composer prompt picker',
12694
+ },
12679
12695
  // Per-workspace Power-Up settings as a Conversation View tab, ordered
12680
12696
  // after the host's Trajectory view (order 10).
12681
- register('conversation.view', {
12682
- id: 'powerup-settings',
12683
- order: 20,
12684
- label: () => translateCurrent('mask.viewTabLabel'),
12685
- }, (props) => h(WorkspaceSettingsView, { ...props, ctx }), 'dsh-powerup: workspace settings view');
12686
-
12697
+ {
12698
+ slot: 'conversation.view',
12699
+ options: { id: 'powerup-settings', order: 20, label: () => translateCurrent('mask.viewTabLabel') },
12700
+ component: (props, ctx) => h(WorkspaceSettingsView, { ...props, ctx }),
12701
+ label: 'dsh-powerup: workspace settings view',
12702
+ },
12687
12703
  // The update control drives the built-in plugin manager through its
12688
12704
  // `remote.pluginManager` namespace. Register it in a nested inject scope
12689
12705
  // so a late-provided service is observed instead of sampled once.
12690
- if (typeof ctx.inject === 'function') {
12706
+ {
12707
+ slot: 'shell.overlay',
12708
+ options: { id: 'powerup-plugin-update', order: 56 },
12709
+ component: (scope) => h(PluginUpdateOverlay, { manager: scope.get('remote.pluginManager'), remote: scope.get('remote'), ctx: scope }),
12710
+ label: 'dsh-powerup: plugin update',
12711
+ inject: ['remote.pluginManager'],
12712
+ },
12713
+ // The stop-reason popover reads the Client jobs snapshot while the
12714
+ // built-in jobs panel owns the stop buttons. Wait for the jobs service
12715
+ // in a nested inject scope so a late-provided service still registers.
12716
+ {
12717
+ slot: 'shell.overlay',
12718
+ options: { id: 'powerup-job-stop', order: 57 },
12719
+ component: (scope) => h(JobStopOverlay, { jobs: scope.get('jobs'), ctx: scope }),
12720
+ label: 'dsh-powerup: job stop reason',
12721
+ inject: ['jobs'],
12722
+ },
12723
+ ];
12724
+
12725
+ function apply(ctx) {
12726
+ for (const step of PREINSTALL) {
12691
12727
  try {
12692
- ctx.inject(['remote.pluginManager'], (scope) => {
12693
- const manager = scope.get('remote.pluginManager');
12694
- const remote = scope.get('remote');
12695
- const childSlots = scope.get('slots');
12696
- if (manager === undefined || childSlots === undefined || typeof childSlots.register !== 'function') return;
12697
- scope.effect(
12698
- () => childSlots.inject('shell.overlay', () => childSlots.register({
12699
- name: 'shell.overlay',
12700
- id: 'powerup-plugin-update',
12701
- order: 56,
12702
- }, () => h(PluginUpdateOverlay, { manager, remote, ctx: scope }))),
12703
- 'dsh-powerup: plugin update',
12704
- );
12705
- });
12728
+ step.run(ctx);
12706
12729
  } catch (error) {
12707
- console.warn('[dsh-powerup] plugin update registration failed:', error?.message ?? error);
12730
+ console.warn(`[dsh-powerup] ${step.label} failed:`, error?.message ?? error);
12708
12731
  }
12709
12732
  }
12710
12733
 
12711
- // The stop-reason popover reads the Client jobs snapshot while the
12712
- // built-in jobs panel owns the stop buttons. Wait for the jobs service
12713
- // in a nested inject scope so a late-provided service still registers.
12714
- if (typeof ctx.inject === 'function') {
12734
+ const slots = ctx.get('slots');
12735
+ if (slots === undefined || typeof slots.inject !== 'function' || typeof slots.register !== 'function') {
12736
+ console.warn('[dsh-powerup] slots service missing; Power-Up UI disabled');
12737
+ return;
12738
+ }
12739
+
12740
+ const register = (slot, options, component, label) => {
12715
12741
  try {
12716
- ctx.inject(['jobs'], (scope) => {
12717
- const jobs = scope.get('jobs');
12718
- const childSlots = scope.get('slots');
12719
- if (jobs === undefined || childSlots === undefined || typeof childSlots.register !== 'function') return;
12720
- scope.effect(
12721
- () => childSlots.inject('shell.overlay', () => childSlots.register({
12722
- name: 'shell.overlay',
12723
- id: 'powerup-job-stop',
12724
- order: 57,
12725
- }, () => h(JobStopOverlay, { jobs, ctx: scope }))),
12726
- 'dsh-powerup: job stop reason',
12727
- );
12728
- });
12742
+ ctx.effect(
12743
+ () => slots.inject(slot, () => slots.register({ name: slot, ...options }, (props) => component(props, ctx))),
12744
+ label,
12745
+ );
12729
12746
  } catch (error) {
12730
- console.warn('[dsh-powerup] job stop registration failed:', error?.message ?? error);
12747
+ console.warn(`[dsh-powerup] could not register ${slot}:`, error?.message ?? error);
12748
+ }
12749
+ };
12750
+
12751
+ for (const entry of REGISTRY) {
12752
+ if (entry.inject !== undefined) {
12753
+ // Nested inject scope: observe the listed services instead of
12754
+ // sampling them once from the root scope.
12755
+ if (typeof ctx.inject !== 'function') {
12756
+ console.warn(`[dsh-powerup] ctx.inject missing; ${entry.label} skipped`);
12757
+ continue;
12758
+ }
12759
+ try {
12760
+ ctx.inject(entry.inject, (scope) => {
12761
+ const missing = entry.inject.some((name) => scope.get(name) === undefined);
12762
+ if (missing || typeof scope.get('slots')?.register !== 'function') return;
12763
+ scope.effect(
12764
+ () => scope.get('slots').inject(entry.slot, () => scope.get('slots').register(
12765
+ { name: entry.slot, ...entry.options },
12766
+ (props) => entry.component(scope),
12767
+ )),
12768
+ entry.label,
12769
+ );
12770
+ });
12771
+ } catch (error) {
12772
+ console.warn(`[dsh-powerup] ${entry.label} registration failed:`, error?.message ?? error);
12773
+ }
12774
+ continue;
12731
12775
  }
12776
+ register(entry.slot, entry.options, entry.component, entry.label);
12732
12777
  }
12733
12778
  }
12734
12779
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.19.16",
3
+ "version": "0.19.18",
4
4
  "description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词、旁路模型生成的结构化任务进度;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, workspace prompts, and non-blocking model-generated structured task progress — each toggled independently on the Power-Up page.",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",
@@ -16,8 +16,7 @@
16
16
  "files": [
17
17
  "index.js",
18
18
  "client.js",
19
- "cordis.patch.yml",
20
- "lib/restart.js",
19
+ "cordis.patch.yml", "lib/restart.js",
21
20
  "lib/restart-helper.cjs",
22
21
  "lib/step-reference.js",
23
22
  "lib/step-tool.js",
@@ -100,6 +99,8 @@
100
99
  "node": ">=22.13.0"
101
100
  },
102
101
  "scripts": {
102
+ "build": "node scripts/build.mjs",
103
+ "pretest": "node scripts/build.mjs --check",
103
104
  "test": "node test/smoke.mjs && node test/host.mjs && node test/progress.mjs && node test/task-resume.mjs && node test/direct-ask.mjs && node test/quick-replies.mjs && node test/system-theme.mjs"
104
105
  },
105
106
  "license": "MIT",