doukui 0.6.0 → 0.9.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 (92) hide show
  1. package/README.en.md +85 -18
  2. package/README.md +32 -72
  3. package/bin/commands/help.js +2 -25
  4. package/bin/commands/plan-lint.js +105 -0
  5. package/bin/commands/verify.js +263 -0
  6. package/bin/doukui.js +3 -3
  7. package/package.json +2 -3
  8. package/plugins/core/hook-session-start/index.js +1 -1
  9. package/plugins/core/hook-skill-gate/index.js +64 -15
  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 +89 -0
  13. package/plugins/core/skill-agent-dispatcher/plugin.json +1 -1
  14. package/plugins/core/skill-agent-dispatcher/recovery-reference.md +132 -0
  15. package/plugins/core/skill-agent-dispatcher/roles-reference.md +9 -22
  16. package/plugins/core/skill-agent-dispatcher/skill.md +124 -796
  17. package/plugins/core/skill-agentic-loop/mirror-rules.md +95 -24
  18. package/plugins/core/skill-agentic-loop/plugin.json +2 -7
  19. package/plugins/core/skill-agentic-loop/skill.md +125 -354
  20. package/plugins/core/skill-batch-task-creator/plugin.json +1 -1
  21. package/plugins/core/skill-checklist/skill.md +15 -141
  22. package/plugins/core/skill-completion-report/plugin.json +1 -1
  23. package/plugins/core/skill-completion-report/skill.md +7 -1
  24. package/plugins/core/skill-doukui-plan/plugin.json +1 -1
  25. package/plugins/core/skill-doukui-plan/skill.md +24 -21
  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-task-creator/plugin.json +1 -1
  30. package/plugins/core/skill-task-creator/skill.md +1 -139
  31. package/plugins/core/skill-workflow-orchestrator/plugin.json +1 -1
  32. package/plugins/plugin-registry.json +0 -48
  33. package/plugins/runtime/harness-build.js +5 -5
  34. package/plugins/runtime/plan-reader.js +54 -21
  35. package/plugins/runtime/resolve-plugin-path.js +2 -2
  36. package/templates/harness-config.yaml +0 -100
  37. package/bin/commands/loop-server.js +0 -357
  38. package/bin/commands/loop.js +0 -1508
  39. package/plugins/contracts/capabilities.js +0 -268
  40. package/plugins/contracts/checkresult-schema.json +0 -75
  41. package/plugins/core/provider-loop-engine/index.js +0 -1411
  42. package/plugins/core/provider-loop-engine/plugin.json +0 -15
  43. package/plugins/core/provider-memory-store/index.js +0 -510
  44. package/plugins/core/provider-memory-store/plugin.json +0 -9
  45. package/plugins/core/provider-state-store/index.js +0 -244
  46. package/plugins/core/provider-state-store/plugin.json +0 -9
  47. package/plugins/core/provider-watchdog/assets/daemon-config.template.json +0 -32
  48. package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +0 -676
  49. package/plugins/core/provider-watchdog/assets/watchdog.js +0 -754
  50. package/plugins/core/provider-watchdog/index.js +0 -151
  51. package/plugins/core/provider-watchdog/plugin.json +0 -13
  52. package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +0 -249
  53. package/plugins/core/skill-watchdog-manager/plugin.json +0 -10
  54. package/plugins/core/skill-watchdog-manager/skill.md +0 -143
  55. package/plugins/core/validator-doc-sync/index.js +0 -248
  56. package/plugins/core/validator-doc-sync/plugin.json +0 -12
  57. package/plugins/core/validator-work-package/index.js +0 -300
  58. package/plugins/core/validator-work-package/plugin.json +0 -12
  59. package/plugins/runtime/audit-logger.js +0 -311
  60. package/plugins/runtime/build-cli.js +0 -89
  61. package/plugins/runtime/checkresult-validator.js +0 -131
  62. package/plugins/runtime/context-window.js +0 -81
  63. package/plugins/runtime/event-bus.js +0 -207
  64. package/plugins/runtime/executor-claude.js +0 -604
  65. package/plugins/runtime/executor-default.js +0 -448
  66. package/plugins/runtime/executor-local.js +0 -178
  67. package/plugins/runtime/executor-sdk.js +0 -415
  68. package/plugins/runtime/hook-dispatcher.js +0 -315
  69. package/plugins/runtime/loop-actuator.js +0 -292
  70. package/plugins/runtime/loop-coordinator.js +0 -347
  71. package/plugins/runtime/loop-defaults.js +0 -29
  72. package/plugins/runtime/loop-dispatch-batch.js +0 -351
  73. package/plugins/runtime/loop-executor.js +0 -120
  74. package/plugins/runtime/loop-report.js +0 -395
  75. package/plugins/runtime/loop-server-core.js +0 -750
  76. package/plugins/runtime/loop-snapshot.js +0 -581
  77. package/plugins/runtime/loop-trace.js +0 -242
  78. package/plugins/runtime/loop-worktree.js +0 -404
  79. package/plugins/runtime/multi-window-coordinator.js +0 -560
  80. package/plugins/runtime/objective-verifier.js +0 -136
  81. package/plugins/runtime/plan-lint.js +0 -106
  82. package/plugins/runtime/plugin-loader.js +0 -798
  83. package/plugins/runtime/plugin-trust.js +0 -182
  84. package/plugins/runtime/provider-failover.js +0 -114
  85. package/plugins/runtime/provider-resolver.js +0 -342
  86. package/plugins/runtime/reflection-evaluator.js +0 -545
  87. package/plugins/runtime/sandbox-context.js +0 -235
  88. package/plugins/runtime/sandbox-manager.js +0 -609
  89. package/plugins/runtime/sandbox-worker.js +0 -215
  90. package/plugins/runtime/self-rescue-ladder.js +0 -51
  91. package/plugins/runtime/text-tokenize.js +0 -25
  92. 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
- };
@@ -1,75 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "doukui/checkresult-schema.json",
4
- "title": "CheckResult Machine-Readable Block (Phase D-1)",
5
- "description": "skill-checklist 产出的 json:machine-readable 围栏块契约(对齐 docs/design/agentic-loop-design.md §5.4.2/5.4.3)。validator 硬改判仅针对数值谎报(summary 不一致);结构瑕疵软告警。",
6
- "type": "object",
7
- "required": ["wpId", "passed", "summary", "failedItems"],
8
- "properties": {
9
- "wpId": { "type": "string", "minLength": 1 },
10
- "checkedAt": { "type": "string" },
11
- "passed": { "type": "boolean" },
12
- "summary": {
13
- "type": "object",
14
- "required": ["total", "passed", "failed"],
15
- "properties": {
16
- "total": { "type": "integer", "minimum": 0 },
17
- "passed": { "type": "integer", "minimum": 0 },
18
- "failed": { "type": "integer", "minimum": 0 }
19
- },
20
- "additionalProperties": true
21
- },
22
- "categories": {
23
- "type": "array",
24
- "items": {
25
- "type": "object",
26
- "required": ["name", "passed", "items"],
27
- "properties": {
28
- "name": { "type": "string", "minLength": 1 },
29
- "passed": { "type": "boolean" },
30
- "items": {
31
- "type": "array",
32
- "items": {
33
- "type": "object",
34
- "required": ["id", "text", "passed"],
35
- "properties": {
36
- "id": { "type": "string", "minLength": 1 },
37
- "text": { "type": "string" },
38
- "passed": { "type": "boolean" },
39
- "reason": { "type": "string" },
40
- "verify": {
41
- "type": "object",
42
- "description": "Phase D-2 客观交叉验证声明:driver/executor 实跑 command,退出码不符 expectExit 则该项改判 fail(LLM 自报与客观结果冲突时以客观为准)",
43
- "required": ["command"],
44
- "properties": {
45
- "command": { "type": "string", "minLength": 1 },
46
- "expectExit": { "type": "integer", "minimum": 0, "default": 0 },
47
- "timeoutMs": { "type": "integer", "minimum": 1000, "default": 120000 }
48
- },
49
- "additionalProperties": false
50
- }
51
- },
52
- "additionalProperties": true
53
- }
54
- }
55
- },
56
- "additionalProperties": true
57
- }
58
- },
59
- "failedItems": {
60
- "type": "array",
61
- "items": {
62
- "type": "object",
63
- "properties": {
64
- "id": { "type": "string" },
65
- "category": { "type": "string" },
66
- "text": { "type": "string" },
67
- "reason": { "type": "string" },
68
- "wpId": { "type": "string" }
69
- },
70
- "additionalProperties": true
71
- }
72
- }
73
- },
74
- "additionalProperties": true
75
- }