dsh-tower 2.0.3 → 2.1.0-beta.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.
Files changed (193) hide show
  1. package/CHANGELOG.md +141 -0
  2. package/COMPATIBILITY.md +38 -0
  3. package/CONTRIBUTING.md +150 -2
  4. package/README.en.md +59 -16
  5. package/README.md +57 -16
  6. package/SECURITY.md +31 -1
  7. package/adapters/default.js +10 -0
  8. package/adapters/store-fs.js +6 -0
  9. package/adapters/vcs-git.js +4 -0
  10. package/app/batch.js +79 -0
  11. package/app/board.js +25 -0
  12. package/app/checkCompletion.js +76 -0
  13. package/app/enrichedMissions.js +26 -0
  14. package/app/findings.js +78 -0
  15. package/app/gate.js +108 -0
  16. package/app/init.js +249 -0
  17. package/app/merge.js +567 -0
  18. package/app/messages.js +66 -0
  19. package/app/mission.js +35 -0
  20. package/app/missionContext.js +14 -0
  21. package/app/plan.js +42 -0
  22. package/app/provision.js +193 -0
  23. package/app/read.js +57 -0
  24. package/app/rebase.js +302 -0
  25. package/app/recording.js +72 -0
  26. package/app/review.js +145 -0
  27. package/app/roster.js +123 -0
  28. package/app/spawn.js +125 -0
  29. package/app/teardown.js +184 -0
  30. package/app/tower.js +524 -0
  31. package/cordis.patch.yml +61 -53
  32. package/docs/README.md +33 -1
  33. package/docs/architecture/overview.md +114 -14
  34. package/docs/board.md +72 -0
  35. package/docs/examples/first-mission.md +2 -1
  36. package/docs/faq.md +11 -7
  37. package/docs/guide/hot-reload.md +1 -1
  38. package/docs/guide/install-upgrade-migration.md +22 -6
  39. package/docs/guide/quickstart.md +12 -7
  40. package/docs/guide/release.md +125 -0
  41. package/docs/guide/scenarios-and-philosophy.md +86 -69
  42. package/docs/operations/security.md +65 -14
  43. package/docs/reference/blockers.md +11 -10
  44. package/docs/reference/config.generated.md +66 -0
  45. package/docs/reference/config.md +11 -7
  46. package/docs/reference/errors.generated.md +39 -0
  47. package/docs/reference/errors.md +10 -2
  48. package/docs/reference/events.md +7 -4
  49. package/docs/reference/testing.md +2 -1
  50. package/docs/reference/tools.generated.md +33 -0
  51. package/docs/reference/tools.md +8 -7
  52. package/docs/zh/README.md +4 -3
  53. package/docs/zh/faq.md +9 -6
  54. package/docs/zh/guide/hot-reload.md +1 -1
  55. package/docs/zh/guide/install-upgrade-migration.md +17 -5
  56. package/docs/zh/guide/quickstart.md +13 -8
  57. package/docs/zh/guide/scenarios-and-philosophy.md +55 -50
  58. package/docs/zh/operations/security.md +43 -7
  59. package/docs/zh/reference/blockers.md +10 -10
  60. package/docs/zh/reference/config.md +11 -7
  61. package/docs/zh/reference/errors.md +4 -1
  62. package/docs/zh/reference/events.md +6 -3
  63. package/docs/zh/reference/testing.md +3 -2
  64. package/docs/zh/reference/tools.md +8 -7
  65. package/domain/collab/batch.js +112 -0
  66. package/domain/collab/messages.js +127 -0
  67. package/domain/collab/roster.js +158 -0
  68. package/domain/collab/spawn.js +188 -0
  69. package/domain/config/schema.js +404 -0
  70. package/domain/contracts/outputs.js +279 -0
  71. package/domain/contracts/tool-inputs/collaboration.js +58 -0
  72. package/domain/contracts/tool-inputs/findings.js +29 -0
  73. package/domain/contracts/tool-inputs/index.js +94 -0
  74. package/domain/contracts/tool-inputs/integration.js +37 -0
  75. package/domain/contracts/tool-inputs/missions.js +94 -0
  76. package/domain/contracts/tool-inputs/ops.js +75 -0
  77. package/domain/contracts/tool-inputs/shared.js +25 -0
  78. package/domain/errors.js +96 -0
  79. package/domain/gate.js +125 -0
  80. package/domain/integration/gate.js +176 -0
  81. package/domain/integration/init.js +225 -0
  82. package/domain/integration/liveness.js +31 -0
  83. package/domain/integration/merge.js +377 -0
  84. package/domain/integration/provision.js +124 -0
  85. package/domain/integration/rebase.js +236 -0
  86. package/domain/integration/review.js +52 -0
  87. package/domain/integration/teardown.js +118 -0
  88. package/domain/mission.js +68 -0
  89. package/domain/missions/completion.js +114 -0
  90. package/domain/missions/findings.js +201 -0
  91. package/domain/missions/lifecycle.js +185 -0
  92. package/domain/missions/plan.js +149 -0
  93. package/domain/missions/review.js +179 -0
  94. package/domain/planning.js +118 -0
  95. package/domain/read/enrichedMissions.js +58 -0
  96. package/domain/read/missionContext.js +53 -0
  97. package/domain/read/views.js +128 -0
  98. package/domain/report.js +59 -0
  99. package/domain/roster.js +40 -0
  100. package/domain/scope.js +105 -0
  101. package/domain/state/schema.js +233 -0
  102. package/domain/state/semantics.js +117 -0
  103. package/domain/state.js +33 -0
  104. package/domain/summary.js +114 -0
  105. package/domain/vocabulary.js +179 -0
  106. package/index.js +86 -34
  107. package/lib/briefing.js +176 -0
  108. package/lib/compatibility.js +108 -0
  109. package/lib/config.js +54 -302
  110. package/lib/doctor.js +108 -9
  111. package/lib/git.js +93 -15
  112. package/lib/hmr.js +4 -3
  113. package/lib/leases.js +3 -2
  114. package/lib/legacy.js +20 -9
  115. package/lib/modeState.js +39 -0
  116. package/lib/modeStore.js +35 -33
  117. package/lib/persistence.js +349 -0
  118. package/lib/presets.js +35 -0
  119. package/lib/spawn-prechecks.js +168 -0
  120. package/lib/spawn-support.js +79 -0
  121. package/lib/store.js +57 -85
  122. package/lib/tests.js +46 -11
  123. package/lib/tool-registry.js +544 -0
  124. package/lib/workspaceLock.js +46 -22
  125. package/lib/worktreeOwnership.js +5 -4
  126. package/locale/en.json +23 -1
  127. package/locale/zh.json +22 -0
  128. package/package.json +33 -4
  129. package/ports/clock.js +6 -0
  130. package/ports/ids.js +7 -0
  131. package/ports/index.js +2 -0
  132. package/ports/store.js +11 -0
  133. package/ports/vcs.js +11 -0
  134. package/scripts/architecture.mjs +94 -0
  135. package/scripts/check-docs.mjs +44 -3
  136. package/scripts/check-pack.mjs +49 -0
  137. package/scripts/domain-metrics.mjs +48 -0
  138. package/scripts/generate-config-reference.mjs +46 -0
  139. package/scripts/generate-error-reference.mjs +29 -0
  140. package/scripts/generate-tools-reference.mjs +56 -0
  141. package/scripts/issue-audit.mjs +259 -0
  142. package/scripts/lib/cli.mjs +76 -0
  143. package/scripts/lib/tmp.mjs +20 -0
  144. package/scripts/mount-smoke/fixtures.mjs +162 -0
  145. package/scripts/mount-smoke/host.json +4 -0
  146. package/scripts/mount-smoke/probe.mjs +125 -0
  147. package/scripts/mount-smoke/surface.mjs +141 -0
  148. package/scripts/mount-smoke.mjs +270 -0
  149. package/scripts/pack-manifest.txt +203 -0
  150. package/scripts/release-check.mjs +303 -0
  151. package/skills/tower-recovery.md +7 -5
  152. package/tools/adopt.js +72 -0
  153. package/tools/batch.js +78 -0
  154. package/tools/complete.js +53 -0
  155. package/tools/diff.js +39 -0
  156. package/tools/doctor.js +50 -0
  157. package/tools/finding.js +40 -0
  158. package/tools/findings.js +39 -0
  159. package/tools/import-legacy.js +42 -0
  160. package/tools/inbox.js +39 -0
  161. package/tools/index.js +39 -0
  162. package/tools/init.js +63 -0
  163. package/tools/interrupt.js +42 -0
  164. package/tools/legacy-map.js +44 -0
  165. package/tools/merge.js +39 -0
  166. package/tools/mission.js +41 -0
  167. package/tools/plan.js +39 -0
  168. package/tools/preflight.js +44 -0
  169. package/tools/rebase.js +39 -0
  170. package/tools/recover.js +45 -0
  171. package/tools/reload.js +52 -0
  172. package/tools/resource.js +54 -0
  173. package/tools/review.js +45 -0
  174. package/tools/roster.js +60 -0
  175. package/tools/send.js +147 -0
  176. package/tools/spawn.js +196 -0
  177. package/tools/status.js +94 -0
  178. package/tools/teardown.js +42 -0
  179. package/tools/test.js +61 -0
  180. package/types/cordis.d.ts +6 -0
  181. package/types/index.d.ts +339 -0
  182. package/ui-bundle/README.md +111 -0
  183. package/ui-bundle/client.js +1980 -0
  184. package/ui-bundle/cordis.patch.yml +3 -0
  185. package/ui-bundle/icon.svg +6 -0
  186. package/ui-bundle/index.js +2 -0
  187. package/ui-bundle/locale/en.json +6 -0
  188. package/ui-bundle/locale/zh.json +6 -0
  189. package/ui-bundle/package.json +35 -0
  190. package/lib/errors.js +0 -111
  191. package/lib/tools.js +0 -2250
  192. package/lib/tower.js +0 -2689
  193. /package/{lib → domain}/batch.js +0 -0
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: tower-ui
3
+ name: 'dsh-tower-ui'
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
+ <rect x="4" y="4" width="56" height="56" rx="12" fill="#141a24"/>
3
+ <rect x="18" y="16" width="28" height="8" rx="2" fill="#f9b98c"/>
4
+ <rect x="22" y="28" width="20" height="7" rx="2" fill="#b56f4c"/>
5
+ <path d="M16 50h32" stroke="#8a5238" stroke-width="3" stroke-linecap="round"/>
6
+ </svg>
@@ -0,0 +1,2 @@
1
+ /** Host half of the opt-in Tower UI bundle; the Client module owns the hint. */
2
+ export function apply() {}
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Tower UI",
4
+ "description": "Shows Tower tool cards, a composer-dock tower summary, and a transient Tower status strip."
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Tower 界面",
4
+ "description": "显示 Tower 工具卡片、输入框区域的 Tower 状态摘要,以及短暂的 Tower 状态提示条。"
5
+ }
6
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "dsh-tower-ui",
3
+ "version": "0.2.2",
4
+ "private": true,
5
+ "type": "module",
6
+ "description": "Opt-in Tower Web Client surfaces: tool cards, a persistent Tower-mode chip, mode-aware denied-tool rows, composer dock summary, and a transient overlay status strip.",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./client": "./client.js",
10
+ "./locale/*.json": "./locale/*.json",
11
+ "./icon": "./icon.svg"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "client.js",
16
+ "cordis.patch.yml",
17
+ "locale/*.json",
18
+ "icon.svg",
19
+ "README.md"
20
+ ],
21
+ "dsh": {
22
+ "bundle": {
23
+ "patch": "./cordis.patch.yml"
24
+ },
25
+ "client": {
26
+ "platform": "web",
27
+ "immediately": true,
28
+ "inject": [
29
+ "@deepseek-ai/dsh-client-ui-conversation",
30
+ "@deepseek-ai/dsh-client-ui-tool",
31
+ "@deepseek-ai/dsh-client-ui-layout"
32
+ ]
33
+ }
34
+ }
35
+ }
package/lib/errors.js DELETED
@@ -1,111 +0,0 @@
1
- // Stable tool error codes.
2
- //
3
- // Everything a Tower tool throws reaches the model as
4
- // [tower:<code>] <original message>
5
- // so callers (and tests) can branch on the code instead of matching prose.
6
- // The catalog is documented in docs/reference/errors.md; scripts/check-docs.mjs
7
- // keeps the two in sync.
8
- import { GitError } from './git.js'
9
-
10
- export const ERROR_CODES = {
11
- 'invalid-argument': 'A tool argument is missing, malformed, or not allowed.',
12
- 'repo-invalid': 'repoRoot is missing, relative, or not inside a Git repository.',
13
- 'not-initialized': 'Tower is not initialized for this repository; run tower_init.',
14
- 'mission-not-found': 'No mission with that id exists.',
15
- 'finding-not-found': 'No finding with that id exists.',
16
- 'invalid-transition': 'The requested state transition is not allowed.',
17
- 'state-locked': 'Another Tower writer holds the state lock.',
18
- 'state-corrupt': 'The Tower state file is unreadable or invalid.',
19
- 'config-invalid': 'Tower configuration is invalid.',
20
- 'config-unknown-key': 'Tower configuration has an unknown top-level key.',
21
- 'git-failed': 'A git command failed.',
22
- 'git-timeout': 'A git command timed out or exceeded its output buffer.',
23
- 'spawn-unavailable': 'The subagents service is unavailable.',
24
- 'provider-missing': 'No subagent provider is registered.',
25
- 'preset-missing': 'The configured agent preset is not registered.',
26
- 'reviewer-prerequisite': 'The reviewer spawn prerequisite is not met.',
27
- 'not-authorized': 'The calling agent role may not perform this action.',
28
- 'workspace-busy': 'Another Tower session owns this repository workspace lock.',
29
- 'worker-limit': 'The repository reached spawn.maxLiveWorkers live workers.',
30
- 'rate-limited': 'The tower_send per-minute rate limit was reached.',
31
- 'takeover-refused': 'The mission already has a live worker that was not stopped first.',
32
- 'reload-unavailable': 'The DSH HMR service is not available in this profile.',
33
- 'reload-failed': 'The HMR reload failed; check the DSH log and restart if needed.',
34
- 'tests-failed': 'Declared test discovery failed or did not meet its admission requirements.',
35
- 'tests-timeout': 'Test discovery exceeded its time or output budget.',
36
- 'lease-busy': 'Another holder owns the requested advisory lease.',
37
- 'lease-token': 'The lease release token does not match the current holder.',
38
- 'batch-invalid': 'The batch request or its close evidence is invalid.',
39
- 'legacy-invalid': 'The legacy snapshot or mapping is invalid.',
40
- 'tool-internal': 'An unexpected failure; read the message and the activity log.',
41
- }
42
-
43
- export class TowerToolError extends Error {
44
- constructor(code, message, options = {}) {
45
- super(`[tower:${code}] ${message}`, options.cause ? { cause: options.cause } : undefined)
46
- this.name = 'TowerToolError'
47
- this.code = code
48
- }
49
- }
50
-
51
- // Ordered rules; the first match wins. Keep the specific patterns above the
52
- // generic argument fallback so `no open task matching` never becomes internal.
53
- const RULES = [
54
- ['not-initialized', /tower is not initialized/i],
55
- ['mission-not-found', /^unknown mission "/i],
56
- ['finding-not-found', /^unknown finding "/i],
57
- ['state-locked', /locked by another writer/i],
58
- [
59
- 'state-corrupt',
60
- /corrupt tower state|^tower state |^unsupported tower state|^invalid (?:mission|roster|message|finding|review) entry|^mission entry without id|^duplicate (?:mission|roster|message|finding|review)|^mission .* (?:has unknown status|has no tasks array|has no deps array)|^message .* has no readBy array|^finding .* has unknown status|^review .* has unknown (?:status|merge verdict)/i,
61
- ],
62
- ['config-unknown-key', /unknown key|unknown top-level key/i],
63
- ['config-invalid', /config (?:is invalid|must be an object)|repo config/i],
64
- ['lease-busy', /lease .* (?:held|owned)|another holder owns/i],
65
- ['lease-token', /lease .*token|token does not match/i],
66
- ['tests-timeout', /test discovery .*(?:timed out|exceeded|too large)/i],
67
- ['tests-failed', /test discovery (?:failed|did not)|tests? (?:failed|missing|did not pass)/i],
68
- ['batch-invalid', /batch (?:is invalid|close|member|receipt)/i],
69
- ['legacy-invalid', /legacy (?:snapshot|map|source)|unsupported legacy/i],
70
- ['spawn-unavailable', /subagents service is unavailable/i],
71
- ['provider-missing', /no subagent provider/i],
72
- ['preset-missing', /agent preset .*is not registered/i],
73
- ['reviewer-prerequisite', /reviewer needs an existing|reviewer requires a completed/i],
74
- ['repo-invalid', /repoRoot is required|repoRoot must be an absolute path/i],
75
- ['workspace-busy', /workspace .*lock|another tower session owns/i],
76
- ['worker-limit', /live worker limit|too many live workers|worker limit reached/i],
77
- ['rate-limited', /rate limit|too many tower messages/i],
78
- ['takeover-refused', /takeover refused|cannot take over/i],
79
- ['not-authorized', /only the tower|only an assigned reviewer|only the tower or a worker|does not own mission|not authorized|may not perform this action/i],
80
- [
81
- 'invalid-transition',
82
- /cannot move from|cannot be completed from that state|is already completed|merged is recorded only|can only be widened|only a completed mission|reviewers may list and read|still has \d+ open task|has unresolved blockers|has no worktree|has no commits since|cannot complete with \d+ unread inbox|not assigned to mission|is a [a-z]+, not a worker|cannot reanchor base|worktree is missing|worktree .* is not a Git worktree|belongs to a different repository|is on .* expected|has \d+ live worker|already has a live worker|cannot reopen a terminal mission|stopped worker cannot report completion|can only be spawned|violates? (?:the )?mission (?:state|transition)/i,
83
- ],
84
- [
85
- 'invalid-argument',
86
- /requires |is required|must be (?:a|an|one|an integer|non-empty|printable)|must not be|must be one of|no open task matching|unknown mission status|unknown finding severity|unknown finding type|not an array|is not an array|scope must|title must|checks must|role must|timeoutMs must|repoRoot is required|only a list filter|snapshotDirty was requested|refusing to send a message to yourself|mission has \d+ live worker|roster name already used|is already in the roster|depends on unknown mission/i,
87
- ],
88
- ]
89
-
90
- function originalMessage(error) {
91
- return String(error?.message ?? error)
92
- }
93
-
94
- /** Wrap any thrown value into a TowerToolError with a stable code. */
95
- export function classifyError(error) {
96
- if (error instanceof TowerToolError) return error
97
- if (error && typeof error.code === 'string' && ERROR_CODES[error.code]) {
98
- return new TowerToolError(error.code, originalMessage(error), { cause: error })
99
- }
100
- if (error instanceof GitError || error?.name === 'GitError') {
101
- const message = originalMessage(error)
102
- if (/not a git repository/i.test(message)) return new TowerToolError('repo-invalid', message, { cause: error })
103
- const code = error?.timedOut === true || error?.bufferOverflow === true ? 'git-timeout' : 'git-failed'
104
- return new TowerToolError(code, message, { cause: error })
105
- }
106
- const message = originalMessage(error)
107
- for (const [code, pattern] of RULES) {
108
- if (pattern.test(message)) return new TowerToolError(code, message, { cause: error })
109
- }
110
- return new TowerToolError('tool-internal', message, { cause: error })
111
- }