dsh-hams 0.0.0-stage → 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.
Files changed (52) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +98 -2
  4. package/client/index.js +3122 -0
  5. package/cordis.patch.yml +16 -0
  6. package/package.json +74 -4
  7. package/src/domain/check.ts +193 -0
  8. package/src/domain/errors.ts +59 -0
  9. package/src/domain/evidence.ts +134 -0
  10. package/src/domain/ids.ts +31 -0
  11. package/src/host/chat-runtime.ts +489 -0
  12. package/src/host/dsh-adapter.ts +867 -0
  13. package/src/host/session-adapter.ts +276 -0
  14. package/src/http/handler.ts +1132 -0
  15. package/src/index.js +53 -0
  16. package/src/service/audit.ts +92 -0
  17. package/src/service/chat.ts +1100 -0
  18. package/src/service/contracts.ts +193 -0
  19. package/src/service/defaults.ts +182 -0
  20. package/src/service/deliverables.ts +240 -0
  21. package/src/service/hams.ts +3103 -0
  22. package/src/service/knowledge.ts +940 -0
  23. package/src/service/member-config.ts +39 -0
  24. package/src/service/members.ts +506 -0
  25. package/src/service/memory.ts +375 -0
  26. package/src/service/permissions.ts +118 -0
  27. package/src/service/project-lifecycle.ts +233 -0
  28. package/src/service/projects.ts +840 -0
  29. package/src/service/receipts.ts +63 -0
  30. package/src/service/templates.ts +140 -0
  31. package/src/service/tick.ts +751 -0
  32. package/src/service/tools.ts +711 -0
  33. package/src/service/types.ts +219 -0
  34. package/src/service/work-item-create.ts +159 -0
  35. package/src/service/workspace-profile.ts +443 -0
  36. package/src/store/backup.ts +239 -0
  37. package/src/store/bootstrap.ts +225 -0
  38. package/src/store/db.ts +179 -0
  39. package/src/store/lock.ts +194 -0
  40. package/src/store/migrations.ts +211 -0
  41. package/src/store/schema/001_p1.sql +846 -0
  42. package/src/store/schema/001_p1.sql.ts +865 -0
  43. package/src/store/schema/002_knowledge.sql +54 -0
  44. package/src/store/schema/002_knowledge.sql.ts +68 -0
  45. package/src/store/schema/003_projects.sql.ts +3 -0
  46. package/src/store/schema/004_team.sql.ts +50 -0
  47. package/src/store/schema/005_target_check.sql.ts +22 -0
  48. package/src/store/schema/006_target_flow.sql.ts +19 -0
  49. package/src/store/schema/007_project_delete.sql.ts +17 -0
  50. package/src/store/schema/008_memory.sql.ts +47 -0
  51. package/src/store/schema/generate-projects.mjs +16 -0
  52. package/src/store/seed.ts +114 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-11-15
4
+
5
+ 首个公开发布版本。
6
+
7
+ - 项目:目标口径版本冻结、指标与读数、阶段目标与人工验收、复盘快照、草稿、归档后删除。
8
+ - 任务:待处理 → 执行 → 复查 → 验收闭环,证据、审批关单、暂停/恢复、看板与日历。
9
+ - 人机成员:人 + bot 同表,bot 配置版本化;内置默认 bot「项目管理 / 数据分析」。
10
+ - 项目群聊:推进 bot 派活并在正文中 `@成员名`;人类可用 `@bot名` 直接点名排查。
11
+ - 知识:面板撰写/导入 Markdown、技能镜像、业务表结构登记。
12
+ - 项目记忆:群聊自动发现决策 / 偏好 / 教训 / 能力 / 事实;能力类同步给对应 bot。
13
+ - 存储:SQLite 单写者锁、可校验备份、迁移链 v1–v8、审计与幂等回执。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tianweichao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # HAMS · Human–Agent Management System
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ HAMS 是 [DeepSeek Harness](https://github.com/deepseek-ai)(DSH)的原生业务工作台插件:把**项目、任务、人机成员、知识、项目记忆**放进同一个本地面板,让一个或多个人与一组 bot 在同一个项目里协作、留痕、复盘。
4
+
5
+ 数据保存在本机 SQLite(`$DSH_HOME/hams`),不依赖外部服务,不上传遥测。
6
+
7
+ ## 功能
8
+
9
+ - **项目**:目标口径与版本冻结、指标与读数、阶段目标与人工验收、复盘快照;新建项目默认使用「项目管理」bot 推进,支持草稿与归档后删除。
10
+ - **任务**:待处理 → 执行 → 复查 → 验收的闭环;证据追加、审批关单、暂停/恢复、看板与日历。
11
+ - **人机成员**:人和 bot 同一张表,bot 配置发布即版本化;默认内置「项目管理 / 数据分析」两个 bot。
12
+ - **项目群聊**:项目有自己的群,推进 bot 在群里派活;人类用 `@bot名` 直接点名某个 bot 去排查。
13
+ - **知识**:面板撰写或导入本机 Markdown(登记路径与哈希,不复制正文)、技能镜像、业务表结构登记。
14
+ - **项目记忆**:群聊中自动发现决策 / 偏好 / 教训 / 能力 / 事实,收进项目「记忆」页签;能力类记忆同步给对应 bot,进入它的会话上下文。
15
+ - **权限与审计**:人按岗位授权、bot 按能力白名单;证据与审计只追加;写命令带幂等键。
16
+
17
+ ## 环境要求
18
+
19
+ - DSH `>= 0.2.2-rc.3 < 0.3.0`
20
+ - Node.js `>= 24.3`(使用原生 TypeScript 类型剥离与 `node:sqlite`)
21
+ - 可选:Python 3(只用于跑库级不变量自测)
22
+
23
+ ## 安装
24
+
25
+ ```bash
26
+ # 安装到 DSH profile(把 desktop 换成你的 profile 名)
27
+ dsh plugin --profile desktop add dsh-hams
28
+ ```
29
+
30
+ 然后在同一 profile 的 `package.json` 里把包名加入 `dsh.profile.bundles`(`dsh plugin add` 通常会自动处理),重启 DSH 即可在侧栏看到 **HAMS** 入口。
31
+
32
+ 手动安装等价于:
33
+
34
+ ```jsonc
35
+ {
36
+ "dependencies": { "dsh-hams": "^0.1.0" },
37
+ "dsh": { "profile": { "bundles": ["dsh-hams"] } }
38
+ }
39
+ ```
40
+
41
+ 首次启动会在 `$DSH_HOME/hams` 建库、自动备份并迁移到当前 schema;本机操作者、默认 bot、起步模板都会自动补齐,不需要手工初始化。
42
+
43
+ ## 配置
44
+
45
+ 在 profile 的 bundle 配置或 DSH 配置中覆盖(全部可省略):
46
+
47
+ | 配置 | 默认 | 说明 |
48
+ |---|---|---|
49
+ | `dataDir` | `$DSH_HOME/hams` | 数据目录(SQLite、备份、知识文档、bot 工作区) |
50
+ | `tickMs` | `5000` | 后台 tick 周期 |
51
+ | `localPrincipalId` | 自动 | 本机操作者 member id;空 = 读 `hams_user(local_host)` |
52
+ | `toolsEnabled` | `true` | 是否向宿主注册 bot 工具 |
53
+ | `botRuntime` | `true` | 是否接宿主 agent 会话(单聊/群聊/工作项派发) |
54
+ | `tickEnabled` | `true` | 是否启动后台调度 |
55
+ | `backupKeep` | `3` | 升级前备份保留份数 |
56
+ | `hostSession` | `auto` | 浏览器会话校验:`auto` / `require` / `off` |
57
+ | `knowledgeSkillDirs` | `[$DSH_HOME/skills]` | 知识屏扫描的技能目录 |
58
+ | `workspaceProfileFile` | `$DSH_HOME/hams/workspace-profile.json` | 可选的工作区画像 JSON |
59
+ | `workspaceRoot` | 画像内的 `workspaceRoot` | 画像里相对路径的根 |
60
+
61
+ ### 可选:工作区画像
62
+
63
+ 把一个 JSON 文件放到 `$DSH_HOME/hams/workspace-profile.json`,首次启动时会把其中的成员、项目、工作项、文档一次性导入(只补缺失,不覆盖已有内容)。格式见 [docs/workspace-profile.example.json](https://github.com/tianweichao/dsh-hams/blob/main/docs/workspace-profile.example.json)。
64
+
65
+ ## 开发
66
+
67
+ ```bash
68
+ npm test # Node 自测(store + service)
69
+ npm run test:py # SQLite 库级不变量
70
+ npm run schema:check
71
+ ```
72
+
73
+ 自测不访问真实 `$DSH_HOME`:存储与服务测试都跑在临时目录里,结束即释放。需要启动宿主做端到端验证时,也请使用独立的 `DSH_HOME` 和临时工作目录。
74
+
75
+ ### 目录
76
+
77
+ ```
78
+ src/index.js Cordis 插件入口
79
+ src/host/dsh-adapter.ts 宿主适配:HTTP 路由、工具注册、启动编排
80
+ src/store/ 迁移、单写者锁、备份、启动
81
+ src/domain/ 纯逻辑(错误码、判据、复查节奏)
82
+ src/service/ 领域命令、读模型、对话、记忆、调度
83
+ src/http/ POST /hams/api/v1/<domain>/<command>
84
+ client/index.js 客户端模块(宿主提供 React,无需打包器)
85
+ tests/ Node / Python 自测
86
+ scripts/ schema 生成、初始化、备份
87
+ docs/schema-2026-11-14.sql 权威 DDL(迁移由它生成)
88
+ ```
89
+
90
+ ### 数据安全
91
+
92
+ - 所有业务数据在 `$DSH_HOME/hams`;升级前自动做可校验备份,默认保留 3 份。
93
+ - 证据与审计只追加,不提供物理删除;项目「删除」是软删,工作项解绑保留。
94
+ - bot 工具没有审批、决定、直接关单和任意 SQL;审批只能由人在界面完成。
95
+ - 本机同 OS 账户的管理员仍可直接改库,这是单机部署的诚实边界。
96
+
97
+ ## 许可证
98
+
99
+ [MIT](LICENSE)