@xi4z/dsh-utils 0.0.0-stage → 0.5.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +576 -2
  3. package/client.js +2330 -0
  4. package/cordis.patch.yml +101 -0
  5. package/icon.svg +21 -0
  6. package/lib/index.d.ts +69 -0
  7. package/lib/index.js +865 -0
  8. package/lib/index.js.map +1 -0
  9. package/lib/ui-host.d.ts +96 -0
  10. package/lib/ui-host.js +970 -0
  11. package/lib/ui-host.js.map +1 -0
  12. package/locale/en.json +6 -0
  13. package/locale/zh.json +6 -0
  14. package/package.json +124 -3
  15. package/packages/approval-policy/lib/index.d.ts +297 -0
  16. package/packages/approval-policy/lib/index.js +425 -0
  17. package/packages/approval-policy/lib/index.js.map +1 -0
  18. package/packages/approval-policy/locale/en.json +6 -0
  19. package/packages/approval-policy/locale/zh.json +6 -0
  20. package/packages/notify/lib/index.d.ts +290 -0
  21. package/packages/notify/lib/index.js +915 -0
  22. package/packages/notify/lib/index.js.map +1 -0
  23. package/packages/notify/locale/en.json +6 -0
  24. package/packages/notify/locale/zh.json +6 -0
  25. package/packages/skill-panel/lib/index.d.ts +49 -0
  26. package/packages/skill-panel/lib/index.js +420 -0
  27. package/packages/skill-panel/lib/index.js.map +1 -0
  28. package/packages/skill-panel/locale/en.json +6 -0
  29. package/packages/skill-panel/locale/zh.json +6 -0
  30. package/packages/utils-agents/lib/git.d.ts +87 -0
  31. package/packages/utils-agents/lib/git.js +403 -0
  32. package/packages/utils-agents/lib/git.js.map +1 -0
  33. package/packages/utils-agents/lib/global-repo.d.ts +57 -0
  34. package/packages/utils-agents/lib/global-repo.js +301 -0
  35. package/packages/utils-agents/lib/global-repo.js.map +1 -0
  36. package/packages/utils-agents/lib/index.d.ts +80 -0
  37. package/packages/utils-agents/lib/index.js +435 -0
  38. package/packages/utils-agents/lib/index.js.map +1 -0
  39. package/packages/utils-agents/lib/legacy.d.ts +30 -0
  40. package/packages/utils-agents/lib/legacy.js +141 -0
  41. package/packages/utils-agents/lib/legacy.js.map +1 -0
  42. package/packages/utils-agents/lib/native.d.ts +74 -0
  43. package/packages/utils-agents/lib/native.js +232 -0
  44. package/packages/utils-agents/lib/native.js.map +1 -0
  45. package/packages/utils-agents/lib/presets.d.ts +34 -0
  46. package/packages/utils-agents/lib/presets.js +312 -0
  47. package/packages/utils-agents/lib/presets.js.map +1 -0
  48. package/packages/utils-agents/lib/shared.d.ts +105 -0
  49. package/packages/utils-agents/lib/shared.js +507 -0
  50. package/packages/utils-agents/lib/shared.js.map +1 -0
  51. package/packages/utils-agents/lib/update.d.ts +129 -0
  52. package/packages/utils-agents/lib/update.js +507 -0
  53. package/packages/utils-agents/lib/update.js.map +1 -0
  54. package/packages/utils-agents/lib/util.d.ts +215 -0
  55. package/packages/utils-agents/lib/util.js +475 -0
  56. package/packages/utils-agents/lib/util.js.map +1 -0
  57. package/packages/utils-agents/locale/en.json +6 -0
  58. package/packages/utils-agents/locale/zh.json +6 -0
  59. package/skills/dsh-approval-policy-config/SKILL.md +96 -0
  60. package/src/index.ts +933 -0
  61. package/src/ui-host.ts +1073 -0
@@ -0,0 +1,101 @@
1
+ # dsh-utils — bundle layer for the utility components.
2
+ #
3
+ # Everything ships in ONE package. The root package owns the patch + locale +
4
+ # icon + browser bundle (client.js) and the `utils-main` component, and the
5
+ # other four components are mounted as **subpath rows** of that same package
6
+ # (`@xi4z/dsh-utils/utils-agents`), resolved through this package's `exports`.
7
+ # A subpath row is not a package: DSH never reads its `package.json`; its display
8
+ # title comes from the exported `./<subpath>/locale/*.json`. The upside is that
9
+ # the manifest has no `@xi4z/*` dependencies at all, so the bundle installs from
10
+ # a registry, a Git URL, a packed tarball or a local directory alike.
11
+ # Because `utils-main` is a package-root row, DSH's client-module scanner also
12
+ # serves this package's client.js from it.
13
+ #
14
+ # The `packages/` directories stay as build units for tsc and for the per-package
15
+ # tests; they are not published.
16
+ #
17
+ # utils-main — the root package itself: recursive SKILL.md discovery
18
+ # in nested skill folders, plus the legacy global
19
+ # skill-repository JSON routes (their UI moved into
20
+ # utils-agents) and the browser half (client.js).
21
+ # dsh-approval-policy — unattended approval gate: subagent/scheduled/cron
22
+ # approval requests wait a bounded window, then settle
23
+ # with a fail-closed default instead of hanging forever.
24
+ # dsh-notify — session notifications: a turn ending, a pending
25
+ # approval, or a pending question is pushed through a
26
+ # Gotify gateway, tagged with this device's name.
27
+ # dsh-skill-panel — settings-page skill switchboard: lists the skills the
28
+ # current session can read and hides disabled ones from
29
+ # the model catalog while keeping them manually
30
+ # invocable.
31
+ # utils-agents — the agents/presets panel: registers each
32
+ # ~/.dsh/.agent-presets/<id>/ directory as a real
33
+ # agent preset through cordis:include, then serves
34
+ # routes that list/toggle its skills, edit its
35
+ # Markdown, and clone/fast-forward a Git repository
36
+ # (public or private, via a Deploy Key) into it.
37
+ #
38
+ # Row ids double as settings namespaces and stay stable.
39
+
40
+ - insert:
41
+ - id: utils-main
42
+ name: '@xi4z/dsh-utils'
43
+ config: {}
44
+ - id: dsh-approval-policy
45
+ name: '@xi4z/dsh-utils/approval-policy'
46
+ config: {}
47
+ - id: dsh-notify
48
+ name: '@xi4z/dsh-utils/notify'
49
+ config:
50
+ # 留空 = 内置默认。下面只列出最常改的几项,完整字段见 README。
51
+ #
52
+ # 出口:Gotify 网关。url/token 建议用环境变量注入,避免把凭据写进仓库:
53
+ # DSH_QQ_NOTIFY_GOTIFY_URL / DSH_QQ_NOTIFY_GOTIFY_TOKEN
54
+ transport: gotify
55
+ # 密钥可以不落盘:'${VAR}' 在投递前从环境变量展开(也支持 targets[].tokenEnv),
56
+ # 或整段用 DSH_QQ_NOTIFY_GOTIFY_URL / DSH_QQ_NOTIFY_GOTIFY_TOKEN 覆盖。
57
+ # 先只记日志:确认能收到再改成 false(或在 profile patch 里覆盖)。
58
+ dryRun: true
59
+ # 设备名留空 = 自动取主机名;deviceLabel 是渲染到 {device} 的显示名。
60
+ deviceName: ''
61
+ deviceLabel: ''
62
+ notifyOnReasons:
63
+ - completed
64
+ - error
65
+ - aborted
66
+ notifyOnApproval: true
67
+ notifyOnQuestion: true
68
+ - id: dsh-skill-panel
69
+ name: '@xi4z/dsh-utils/skill-panel'
70
+ config:
71
+ # 模型技能目录里隐藏的技能名;面板开关写入这里,热生效。
72
+ disabledSkills: []
73
+ - id: utils-agents
74
+ name: '@xi4z/dsh-utils/utils-agents'
75
+ config:
76
+ # 单文件读写上限(字节)。AGENTS.md 本质上也是提示词,别放太大。
77
+ maxBytes: 524288
78
+ # 额外的预设根目录;每个子目录是一个预设。
79
+ presetDirs: []
80
+ # 额外的共享预设来源(技能仓库);读取其 .dsh 下的预设,供面板同步。
81
+ presetSourceDirs: []
82
+ # 保留为原生的预设 id;其余原生声明可导入成目录预设并发布到共享仓库。
83
+ builtinPresets:
84
+ - standard
85
+ - ptc
86
+ - minimal
87
+ - creator
88
+ # 全局 / 项目 AGENTS.md 视图的额外文件与递归扫描。
89
+ extraAgentsFiles: []
90
+ scanNestedAgents: false
91
+ nestedDepth: 3
92
+ # 新预设技能仓库的默认值。
93
+ defaultRepoUrl: 'https://github.com/xi4z/skills'
94
+ defaultBranch: 'Agent'
95
+ # 面板顶部的版本检查:定时查询 npm 上 @xi4z/dsh-utils 的 latest。
96
+ # 手动「检查更新」按钮不受间隔限制;改镜像时把 updateRegistry 换掉。
97
+ updateCheck: true
98
+ updateCheckIntervalHours: 6
99
+ updateRegistry: 'https://registry.npmjs.org'
100
+ # 查到新版本就后台 pnpm add;装完要重启 dsh web。link:/file: 安装自动跳过。
101
+ updateAutoInstall: true
package/icon.svg ADDED
@@ -0,0 +1,21 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" role="img" aria-label="Nested folders and a bounded approval window">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#1d2f57"/>
5
+ <stop offset="1" stop-color="#0d1a33"/>
6
+ </linearGradient>
7
+ <linearGradient id="sheet" x1="0" y1="0" x2="0" y2="1">
8
+ <stop offset="0" stop-color="#ffffff"/>
9
+ <stop offset="1" stop-color="#d9e4ff"/>
10
+ </linearGradient>
11
+ </defs>
12
+ <rect width="64" height="64" rx="14" fill="url(#bg)"/>
13
+ <path d="M8 20.5A3.5 3.5 0 0 1 11.5 17h8l3 3h14a3.5 3.5 0 0 1 3.5 3.5v4" fill="none" stroke="#4a6bb5" stroke-width="2.4" stroke-linecap="round" opacity="0.75"/>
14
+ <path d="M12 26.5A3 3 0 0 1 15 23.5h7l2.6 2.6h11.4a3 3 0 0 1 3 3v2" fill="none" stroke="#6d92e6" stroke-width="2.4" stroke-linecap="round" opacity="0.9"/>
15
+ <rect x="15" y="29" width="19" height="14" rx="3" fill="#5f8cf0"/>
16
+ <rect x="18" y="32" width="13" height="8" rx="1.8" fill="url(#sheet)"/>
17
+ <path d="M20.5 35h8M20.5 37.6h5.5" stroke="#33518f" stroke-width="1.4" stroke-linecap="round"/>
18
+ <path d="M44 17.5l10 3.4v7.6c0 6-4 10.2-10 12.3-6-2.1-10-6.3-10-12.3v-7.6z" fill="none" stroke="#ffd166" stroke-width="2.6" stroke-linejoin="round"/>
19
+ <path d="M44 24v5.4l3.4 2.1" fill="none" stroke="#ffd166" stroke-width="2.4" stroke-linecap="round"/>
20
+ <circle cx="44" cy="29" r="1.4" fill="#ffd166"/>
21
+ </svg>
package/lib/index.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `dsh-utils` main component (`utils-main`): the package root half of the
3
+ * bundle, mounted as a normal row by `cordis.patch.yml`.
4
+ *
5
+ * It adds nested `SKILL.md` bundles (depth >= `minDepth`) to the skill catalog,
6
+ * leaving depth-1 discovery to the built-in filesystem provider, and owns the
7
+ * skill-repository sync routes imported from `./ui-host.js`. The browser half
8
+ * (`client.js`) is published by this same package: `utils-main` is a
9
+ * package-root row, so the client-module scanner serves it from this row.
10
+ *
11
+ * @module dsh-utils
12
+ */
13
+ import type { Context } from '@deepseek-ai/cordis';
14
+ import z from '@deepseek-ai/schemastery';
15
+ export declare const name = "utils-main";
16
+ export declare const inject: string[];
17
+ /**
18
+ * Settings schema. Volatile fields are the only ones DSH exposes in the
19
+ * Settings form and the ones the Loader can refresh in place.
20
+ */
21
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
22
+ minDepth: z<number, number, "volatile-defined">;
23
+ maxDepth: z<number, number, "volatile-defined">;
24
+ watch: z<boolean, boolean, "volatile-defined">;
25
+ debounceMs: z<number, number, "volatile-defined">;
26
+ pollIntervalMs: z<number, number, "volatile-defined">;
27
+ includeProjectRoots: z<boolean, boolean, "volatile-defined">;
28
+ includeUserRoots: z<boolean, boolean, "volatile-defined">;
29
+ followSymlinks: z<boolean, boolean, "volatile-defined">;
30
+ extraRoots: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
31
+ ignoreDirs: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
32
+ }>>, Schemastery.ObjectT<NoInfer<{
33
+ minDepth: z<number, number, "volatile-defined">;
34
+ maxDepth: z<number, number, "volatile-defined">;
35
+ watch: z<boolean, boolean, "volatile-defined">;
36
+ debounceMs: z<number, number, "volatile-defined">;
37
+ pollIntervalMs: z<number, number, "volatile-defined">;
38
+ includeProjectRoots: z<boolean, boolean, "volatile-defined">;
39
+ includeUserRoots: z<boolean, boolean, "volatile-defined">;
40
+ followSymlinks: z<boolean, boolean, "volatile-defined">;
41
+ extraRoots: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
42
+ ignoreDirs: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
43
+ }>>, "plain">;
44
+ /** Volatile Config fields arrive as live references; `.get()` snapshots. */
45
+ interface VolatileRef<T> {
46
+ get(): T;
47
+ }
48
+ /** One setting as the Loader supplies it: a live reference, or a plain value in tests. */
49
+ type MaybeRef<T> = T | VolatileRef<T>;
50
+ /** The runtime shape `apply` receives (every field volatile, every field optional). */
51
+ export interface UtilsMainConfig {
52
+ readonly minDepth?: MaybeRef<number>;
53
+ readonly maxDepth?: MaybeRef<number>;
54
+ readonly watch?: MaybeRef<boolean>;
55
+ readonly debounceMs?: MaybeRef<number>;
56
+ readonly pollIntervalMs?: MaybeRef<number>;
57
+ readonly includeProjectRoots?: MaybeRef<boolean>;
58
+ readonly includeUserRoots?: MaybeRef<boolean>;
59
+ readonly followSymlinks?: MaybeRef<boolean>;
60
+ readonly extraRoots?: MaybeRef<readonly string[]>;
61
+ readonly ignoreDirs?: MaybeRef<readonly string[]>;
62
+ }
63
+ /**
64
+ * Register the recursive skill provider on the host `skills` registry.
65
+ * @param ctx - plugin context carrying the `skills` service.
66
+ * @param config - optional row config; see {@link normalizeConfig}.
67
+ */
68
+ export declare function apply(ctx: Context, config?: UtilsMainConfig): void;
69
+ export {};