doukui 0.8.0 → 0.9.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 (66) hide show
  1. package/README.en.md +85 -18
  2. package/README.md +8 -8
  3. package/bin/commands/help.js +2 -0
  4. package/bin/commands/plan-lint.js +105 -0
  5. package/bin/commands/verify.js +263 -0
  6. package/bin/doukui.js +2 -0
  7. package/package.json +1 -1
  8. package/plugins/core/hook-session-start/index.js +1 -1
  9. package/plugins/core/hook-skill-gate/index.js +154 -19
  10. package/plugins/core/hook-skill-gate/plugin.json +1 -1
  11. package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +7 -28
  12. package/plugins/core/skill-agent-dispatcher/monitoring-reference.md +5 -177
  13. package/plugins/core/skill-agent-dispatcher/plugin.json +1 -1
  14. package/plugins/core/skill-agent-dispatcher/recovery-reference.md +99 -58
  15. package/plugins/core/skill-agent-dispatcher/roles-reference.md +9 -22
  16. package/plugins/core/skill-agent-dispatcher/skill.md +112 -524
  17. package/plugins/core/skill-agentic-loop/mirror-rules.md +15 -3
  18. package/plugins/core/skill-agentic-loop/plugin.json +1 -1
  19. package/plugins/core/skill-agentic-loop/skill.md +123 -324
  20. package/plugins/core/skill-batch-task-creator/plugin.json +1 -1
  21. package/plugins/core/skill-batch-task-creator/skill.md +22 -24
  22. package/plugins/core/skill-checklist/skill.md +15 -141
  23. package/plugins/core/skill-completion-report/plugin.json +1 -1
  24. package/plugins/core/skill-doukui-plan/plugin.json +1 -1
  25. package/plugins/core/skill-doukui-plan/skill.md +33 -38
  26. package/plugins/core/skill-experience-logger/plugin.json +1 -1
  27. package/plugins/core/skill-human-checkpoint/skill.md +1 -0
  28. package/plugins/core/skill-split-work-package/plugin.json +1 -1
  29. package/plugins/core/skill-split-work-package/skill.md +20 -18
  30. package/plugins/core/skill-task-creator/plugin.json +1 -1
  31. package/plugins/core/skill-task-creator/skill.md +25 -165
  32. package/plugins/core/skill-workflow-orchestrator/plugin.json +1 -1
  33. package/plugins/plugin-registry.json +0 -36
  34. package/plugins/runtime/claude-md-injector.js +1 -0
  35. package/plugins/runtime/harness-build.js +5 -5
  36. package/plugins/runtime/plan-reader.js +21 -3
  37. package/plugins/runtime/resolve-plugin-path.js +2 -2
  38. package/plugins/runtime/settings-merger.js +5 -0
  39. package/plugins/contracts/capabilities.js +0 -268
  40. package/plugins/core/provider-memory-store/index.js +0 -510
  41. package/plugins/core/provider-memory-store/plugin.json +0 -9
  42. package/plugins/core/provider-state-store/index.js +0 -244
  43. package/plugins/core/provider-state-store/plugin.json +0 -9
  44. package/plugins/core/provider-watchdog/assets/daemon-config.template.json +0 -32
  45. package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +0 -676
  46. package/plugins/core/provider-watchdog/assets/watchdog.js +0 -754
  47. package/plugins/core/provider-watchdog/index.js +0 -151
  48. package/plugins/core/provider-watchdog/plugin.json +0 -13
  49. package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +0 -249
  50. package/plugins/core/skill-watchdog-manager/plugin.json +0 -10
  51. package/plugins/core/skill-watchdog-manager/skill.md +0 -143
  52. package/plugins/core/validator-doc-sync/index.js +0 -248
  53. package/plugins/core/validator-doc-sync/plugin.json +0 -12
  54. package/plugins/core/validator-work-package/index.js +0 -300
  55. package/plugins/core/validator-work-package/plugin.json +0 -12
  56. package/plugins/runtime/audit-logger.js +0 -311
  57. package/plugins/runtime/build-cli.js +0 -89
  58. package/plugins/runtime/event-bus.js +0 -207
  59. package/plugins/runtime/hook-dispatcher.js +0 -315
  60. package/plugins/runtime/plugin-loader.js +0 -798
  61. package/plugins/runtime/plugin-trust.js +0 -182
  62. package/plugins/runtime/sandbox-context.js +0 -235
  63. package/plugins/runtime/sandbox-manager.js +0 -609
  64. package/plugins/runtime/sandbox-worker.js +0 -215
  65. package/plugins/runtime/text-tokenize.js +0 -24
  66. package/plugins/runtime/validator-pipeline.js +0 -475
@@ -1,268 +0,0 @@
1
- /**
2
- * Capabilities - Capability declaration and runtime enforcement for plugin sandboxing
3
- *
4
- * Defines:
5
- * - Capability enumeration (fs.read, fs.write, net.*, child_process, env, plugin.access)
6
- * - CapabilityLevel risk classification (safe, low_risk, medium, high_risk)
7
- * - CAPABILITY_LEVELS mapping (capability -> risk level)
8
- * - TRUST_LEVELS matrix (sourceType -> allowed capabilities)
9
- * - Runtime checker: isCapabilityAllowed(sourceType, capability)
10
- *
11
- * Design based on docs/design/harness-universal-platform-final-design.md section 3.2-3.4.
12
- *
13
- * @module capabilities
14
- */
15
-
16
- 'use strict';
17
-
18
- // ---------------------------------------------------------------------------
19
- // Capability enumeration
20
- // ---------------------------------------------------------------------------
21
-
22
- /**
23
- * All recognized capabilities that a plugin may declare in plugin.json.
24
- * Core services (eventBus, stateStore, logger, config) are always available
25
- * and do not need to be declared.
26
- * @public
27
- */
28
- var Capability = Object.freeze({
29
- // File system access
30
- FS_READ: 'fs.read',
31
- FS_WRITE: 'fs.write',
32
-
33
- // Network access
34
- NET_REQUEST: 'net.request',
35
- NET_LISTEN: 'net.listen',
36
-
37
- // Process control
38
- CHILD_PROCESS: 'child_process',
39
-
40
- // Environment variables
41
- ENV_READ: 'env.read',
42
-
43
- // Cross-plugin provider access
44
- PLUGIN_ACCESS: 'plugin.access',
45
- });
46
-
47
- /**
48
- * Risk classification for capabilities.
49
- * Used to determine audit severity and UI presentation.
50
- * @public
51
- */
52
- var CapabilityLevel = Object.freeze({
53
- SAFE: 'safe',
54
- LOW_RISK: 'low_risk',
55
- MEDIUM: 'medium',
56
- HIGH_RISK: 'high_risk',
57
- });
58
-
59
- /**
60
- * Maps each capability to its risk level.
61
- * Used by audit logger and capability display logic.
62
- * @public
63
- */
64
- var CAPABILITY_LEVELS = {};
65
- CAPABILITY_LEVELS[Capability.FS_READ] = CapabilityLevel.LOW_RISK;
66
- CAPABILITY_LEVELS[Capability.FS_WRITE] = CapabilityLevel.MEDIUM;
67
- CAPABILITY_LEVELS[Capability.NET_REQUEST] = CapabilityLevel.MEDIUM;
68
- CAPABILITY_LEVELS[Capability.NET_LISTEN] = CapabilityLevel.HIGH_RISK;
69
- CAPABILITY_LEVELS[Capability.CHILD_PROCESS] = CapabilityLevel.HIGH_RISK;
70
- CAPABILITY_LEVELS[Capability.ENV_READ] = CapabilityLevel.LOW_RISK;
71
- CAPABILITY_LEVELS[Capability.PLUGIN_ACCESS] = CapabilityLevel.LOW_RISK;
72
-
73
- Object.freeze(CAPABILITY_LEVELS);
74
-
75
- // ---------------------------------------------------------------------------
76
- // Trust levels and capability restriction matrix
77
- // ---------------------------------------------------------------------------
78
-
79
- /**
80
- * Trust levels by source type.
81
- * core — fully trusted, all capabilities available, no sandboxing
82
- * npm — moderate trust, capabilities must be declared, sandboxed
83
- * local — low trust, capabilities must be declared, sandboxed + path audit
84
- * @public
85
- */
86
- var TRUST_LEVELS = Object.freeze({
87
- core: 'full',
88
- npm: 'moderate',
89
- local: 'low',
90
- });
91
-
92
- /**
93
- * Per-sourceType capability restrictions.
94
- *
95
- * 'auto' — always granted without declaration
96
- * 'declared' — granted only if declared in plugin.json capabilities
97
- * 'forbidden' — never granted (blocked at runtime)
98
- *
99
- * NOTE: npm and local share identical restriction matrices by design.
100
- * Both require explicit capability declaration (declared) and forbid
101
- * child_process. Although TRUST_LEVELS differentiates 'moderate' vs 'low',
102
- * the capability enforcement is intentionally uniform — any third-party
103
- * plugin (whether from npm or local filesystem) must declare its capabilities.
104
- * If differentiated restrictions are needed in the future, the structure
105
- * supports independent modification per sourceType.
106
- *
107
- * @internal 此数据结构可能在不同版本间变更以支持新的安全策略
108
- */
109
- var CAPABILITY_RESTRICTIONS = Object.freeze({
110
- core: Object.freeze({
111
- 'fs.read': 'auto',
112
- 'fs.write': 'auto',
113
- 'net.request': 'auto',
114
- 'net.listen': 'auto',
115
- 'child_process': 'auto',
116
- 'env.read': 'auto',
117
- 'plugin.access': 'auto',
118
- }),
119
- npm: Object.freeze({
120
- 'fs.read': 'declared',
121
- 'fs.write': 'declared',
122
- 'net.request': 'declared',
123
- 'net.listen': 'declared',
124
- 'child_process': 'forbidden',
125
- 'env.read': 'declared',
126
- 'plugin.access': 'declared',
127
- }),
128
- local: Object.freeze({
129
- 'fs.read': 'declared',
130
- 'fs.write': 'declared',
131
- 'net.request': 'declared',
132
- 'net.listen': 'declared',
133
- 'child_process': 'forbidden',
134
- 'env.read': 'declared',
135
- 'plugin.access': 'declared',
136
- }),
137
- });
138
-
139
- // ---------------------------------------------------------------------------
140
- // Runtime capability checker
141
- // ---------------------------------------------------------------------------
142
-
143
- /**
144
- * Check whether a specific capability is allowed for a given source type.
145
- *
146
- * @public
147
- * @param {string} sourceType - 'core' | 'npm' | 'local'
148
- * @param {string} capability - one of Capability values
149
- * @param {object} [declaredCapabilities] - the capabilities field from plugin.json (optional)
150
- * @returns {{ allowed: boolean, reason: string }}
151
- */
152
- function isCapabilityAllowed(sourceType, capability, declaredCapabilities) {
153
- // Core plugins: everything allowed
154
- if (sourceType === 'core') {
155
- return { allowed: true, reason: 'core plugin: full trust' };
156
- }
157
-
158
- // Validate sourceType
159
- if (!CAPABILITY_RESTRICTIONS[sourceType]) {
160
- return { allowed: false, reason: 'unknown sourceType: ' + sourceType };
161
- }
162
-
163
- var restrictions = CAPABILITY_RESTRICTIONS[sourceType];
164
- var restriction = restrictions[capability];
165
-
166
- if (!restriction) {
167
- // Unknown capability — deny by default for non-core
168
- return { allowed: false, reason: 'unknown capability: ' + capability };
169
- }
170
-
171
- if (restriction === 'auto') {
172
- return { allowed: true, reason: 'auto-granted for ' + sourceType };
173
- }
174
-
175
- if (restriction === 'forbidden') {
176
- return { allowed: false, reason: capability + ' is forbidden for ' + sourceType + ' plugins' };
177
- }
178
-
179
- // restriction === 'declared': check if declared in plugin.json
180
- if (declaredCapabilities) {
181
- // The capabilities field maps top-level keys like "filesystem", "network", "child_process", "env"
182
- // to sub-structures. We need to map capability enums back to top-level keys.
183
- var capKey = _capabilityToTopLevelKey(capability);
184
- if (capKey && declaredCapabilities[capKey] !== undefined) {
185
- // If the value is explicitly false, treat as not declared
186
- if (declaredCapabilities[capKey] === false) {
187
- return { allowed: false, reason: capability + ' explicitly disabled in plugin.json' };
188
- }
189
- return { allowed: true, reason: capability + ' declared in plugin.json' };
190
- }
191
- }
192
-
193
- return { allowed: false, reason: capability + ' not declared in plugin.json capabilities' };
194
- }
195
-
196
- /**
197
- * Determine if a plugin should run in a sandbox (Worker Thread).
198
- * Core plugins run in the main process; npm/local plugins run sandboxed.
199
- *
200
- * @public
201
- * @param {string} sourceType - 'core' | 'npm' | 'local'
202
- * @returns {boolean}
203
- */
204
- function shouldSandbox(sourceType) {
205
- return sourceType === 'npm' || sourceType === 'local';
206
- }
207
-
208
- /**
209
- * Get all allowed capabilities for a source type, given declared capabilities.
210
- *
211
- * @public
212
- * @param {string} sourceType
213
- * @param {object} [declaredCapabilities]
214
- * @returns {string[]} list of allowed Capability values
215
- */
216
- function getAllowedCapabilities(sourceType, declaredCapabilities) {
217
- var allCaps = Object.keys(Capability).map(function (k) { return Capability[k]; });
218
- var allowed = [];
219
-
220
- for (var i = 0; i < allCaps.length; i++) {
221
- var result = isCapabilityAllowed(sourceType, allCaps[i], declaredCapabilities);
222
- if (result.allowed) {
223
- allowed.push(allCaps[i]);
224
- }
225
- }
226
-
227
- return allowed;
228
- }
229
-
230
- // ---------------------------------------------------------------------------
231
- // Internal helpers
232
- // ---------------------------------------------------------------------------
233
-
234
- /**
235
- * Map a Capability enum value back to the top-level plugin.json key.
236
- * e.g. 'fs.read' -> 'filesystem', 'net.request' -> 'network', etc.
237
- *
238
- * @internal
239
- * @param {string} capability
240
- * @returns {string|null}
241
- */
242
- function _capabilityToTopLevelKey(capability) {
243
- var map = {
244
- 'fs.read': 'filesystem',
245
- 'fs.write': 'filesystem',
246
- 'net.request': 'network',
247
- 'net.listen': 'network',
248
- 'child_process': 'child_process',
249
- 'env.read': 'env',
250
- 'plugin.access': 'plugin_access',
251
- };
252
- return map[capability] || null;
253
- }
254
-
255
- // ---------------------------------------------------------------------------
256
- // Exports
257
- // ---------------------------------------------------------------------------
258
-
259
- module.exports = {
260
- Capability: Capability,
261
- CapabilityLevel: CapabilityLevel,
262
- CAPABILITY_LEVELS: CAPABILITY_LEVELS,
263
- TRUST_LEVELS: TRUST_LEVELS,
264
- CAPABILITY_RESTRICTIONS: CAPABILITY_RESTRICTIONS,
265
- isCapabilityAllowed: isCapabilityAllowed,
266
- shouldSandbox: shouldSandbox,
267
- getAllowedCapabilities: getAllowedCapabilities,
268
- };