doukui 0.0.0-stage → 0.3.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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +42 -0
  3. package/README.md +147 -2
  4. package/bin/commands/build.js +178 -0
  5. package/bin/commands/config.js +88 -0
  6. package/bin/commands/help.js +83 -0
  7. package/bin/commands/init.js +194 -0
  8. package/bin/commands/install.js +202 -0
  9. package/bin/commands/interactive.js +352 -0
  10. package/bin/commands/list.js +108 -0
  11. package/bin/commands/loop-server.js +357 -0
  12. package/bin/commands/loop.js +1443 -0
  13. package/bin/commands/migrate.js +120 -0
  14. package/bin/commands/setup-global.js +81 -0
  15. package/bin/commands/status.js +140 -0
  16. package/bin/commands/team-cleanup.js +190 -0
  17. package/bin/commands/validate-config.js +35 -0
  18. package/bin/commands/validate.js +21 -0
  19. package/bin/commands/version.js +22 -0
  20. package/bin/context.js +143 -0
  21. package/bin/doukui.js +216 -0
  22. package/package.json +47 -4
  23. package/plugins/contracts/capabilities.js +268 -0
  24. package/plugins/contracts/checkresult-schema.json +75 -0
  25. package/plugins/contracts/config-schema.json +179 -0
  26. package/plugins/contracts/plugin-interface.js +262 -0
  27. package/plugins/contracts/plugin-schema.json +104 -0
  28. package/plugins/core/hook-session-start/index.js +281 -0
  29. package/plugins/core/hook-session-start/plugin.json +7 -0
  30. package/plugins/core/hook-skill-gate/index.js +661 -0
  31. package/plugins/core/hook-skill-gate/plugin.json +12 -0
  32. package/plugins/core/provider-loop-engine/index.js +1411 -0
  33. package/plugins/core/provider-loop-engine/plugin.json +15 -0
  34. package/plugins/core/provider-memory-store/index.js +510 -0
  35. package/plugins/core/provider-memory-store/plugin.json +9 -0
  36. package/plugins/core/provider-role-registry/index.js +376 -0
  37. package/plugins/core/provider-role-registry/plugin.json +9 -0
  38. package/plugins/core/provider-state-store/index.js +244 -0
  39. package/plugins/core/provider-state-store/plugin.json +9 -0
  40. package/plugins/core/provider-watchdog/assets/daemon-config.template.json +32 -0
  41. package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +676 -0
  42. package/plugins/core/provider-watchdog/assets/watchdog.js +754 -0
  43. package/plugins/core/provider-watchdog/index.js +151 -0
  44. package/plugins/core/provider-watchdog/plugin.json +13 -0
  45. package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +214 -0
  46. package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +249 -0
  47. package/plugins/core/skill-agent-dispatcher/plugin.json +13 -0
  48. package/plugins/core/skill-agent-dispatcher/roles-reference.md +253 -0
  49. package/plugins/core/skill-agent-dispatcher/skill.md +1291 -0
  50. package/plugins/core/skill-agentic-loop/plugin.json +20 -0
  51. package/plugins/core/skill-agentic-loop/skill.md +588 -0
  52. package/plugins/core/skill-batch-task-creator/plugin.json +15 -0
  53. package/plugins/core/skill-batch-task-creator/skill.md +620 -0
  54. package/plugins/core/skill-checklist/plugin.json +10 -0
  55. package/plugins/core/skill-checklist/skill.md +171 -0
  56. package/plugins/core/skill-completion-report/plugin.json +10 -0
  57. package/plugins/core/skill-completion-report/skill.md +331 -0
  58. package/plugins/core/skill-doukui-plan/plugin.json +15 -0
  59. package/plugins/core/skill-doukui-plan/skill.md +233 -0
  60. package/plugins/core/skill-doukui-sync/plugin.json +10 -0
  61. package/plugins/core/skill-doukui-sync/skill.md +76 -0
  62. package/plugins/core/skill-experience-logger/plugin.json +10 -0
  63. package/plugins/core/skill-experience-logger/skill.md +235 -0
  64. package/plugins/core/skill-human-checkpoint/plugin.json +10 -0
  65. package/plugins/core/skill-human-checkpoint/skill.md +194 -0
  66. package/plugins/core/skill-progress-tracker/plugin.json +10 -0
  67. package/plugins/core/skill-progress-tracker/skill.md +228 -0
  68. package/plugins/core/skill-role-manager/plugin.json +10 -0
  69. package/plugins/core/skill-role-manager/skill.md +252 -0
  70. package/plugins/core/skill-split-work-package/plugin.json +15 -0
  71. package/plugins/core/skill-split-work-package/skill.md +441 -0
  72. package/plugins/core/skill-task-archive/plugin.json +10 -0
  73. package/plugins/core/skill-task-archive/skill.md +116 -0
  74. package/plugins/core/skill-task-creator/plugin.json +15 -0
  75. package/plugins/core/skill-task-creator/skill.md +886 -0
  76. package/plugins/core/skill-team-cleanup/plugin.json +10 -0
  77. package/plugins/core/skill-team-cleanup/skill.md +266 -0
  78. package/plugins/core/skill-watchdog-manager/plugin.json +10 -0
  79. package/plugins/core/skill-watchdog-manager/skill.md +143 -0
  80. package/plugins/core/skill-workflow-orchestrator/plugin.json +13 -0
  81. package/plugins/core/skill-workflow-orchestrator/skill.md +273 -0
  82. package/plugins/core/validator-doc-sync/index.js +248 -0
  83. package/plugins/core/validator-doc-sync/plugin.json +12 -0
  84. package/plugins/core/validator-work-package/index.js +300 -0
  85. package/plugins/core/validator-work-package/plugin.json +12 -0
  86. package/plugins/plugin-registry.json +186 -0
  87. package/plugins/runtime/agent-def-generator.js +150 -0
  88. package/plugins/runtime/audit-logger.js +311 -0
  89. package/plugins/runtime/build-cli.js +89 -0
  90. package/plugins/runtime/checkresult-validator.js +131 -0
  91. package/plugins/runtime/claude-md-injector.js +159 -0
  92. package/plugins/runtime/cleanup-utils.js +293 -0
  93. package/plugins/runtime/config-manager.js +317 -0
  94. package/plugins/runtime/config-validator.js +320 -0
  95. package/plugins/runtime/context-window.js +81 -0
  96. package/plugins/runtime/event-bus.js +207 -0
  97. package/plugins/runtime/executor-claude.js +828 -0
  98. package/plugins/runtime/executor-default.js +448 -0
  99. package/plugins/runtime/executor-local.js +178 -0
  100. package/plugins/runtime/executor-sdk.js +415 -0
  101. package/plugins/runtime/harness-build.js +1037 -0
  102. package/plugins/runtime/hook-dispatcher.js +315 -0
  103. package/plugins/runtime/logger.js +192 -0
  104. package/plugins/runtime/loop-actuator.js +292 -0
  105. package/plugins/runtime/loop-coordinator.js +347 -0
  106. package/plugins/runtime/loop-defaults.js +29 -0
  107. package/plugins/runtime/loop-dispatch-batch.js +247 -0
  108. package/plugins/runtime/loop-executor.js +120 -0
  109. package/plugins/runtime/loop-report.js +327 -0
  110. package/plugins/runtime/loop-server-core.js +750 -0
  111. package/plugins/runtime/loop-snapshot.js +581 -0
  112. package/plugins/runtime/loop-trace.js +242 -0
  113. package/plugins/runtime/loop-worktree.js +404 -0
  114. package/plugins/runtime/manifest-resolver.js +457 -0
  115. package/plugins/runtime/multi-window-coordinator.js +560 -0
  116. package/plugins/runtime/objective-verifier.js +136 -0
  117. package/plugins/runtime/plan-lint.js +100 -0
  118. package/plugins/runtime/plan-reader.js +763 -0
  119. package/plugins/runtime/plugin-loader.js +798 -0
  120. package/plugins/runtime/plugin-trust.js +182 -0
  121. package/plugins/runtime/plugin-validator.js +491 -0
  122. package/plugins/runtime/provider-failover.js +114 -0
  123. package/plugins/runtime/provider-resolver.js +342 -0
  124. package/plugins/runtime/reflection-evaluator.js +545 -0
  125. package/plugins/runtime/resolve-plugin-path.js +297 -0
  126. package/plugins/runtime/safe-path.js +119 -0
  127. package/plugins/runtime/sandbox-context.js +235 -0
  128. package/plugins/runtime/sandbox-manager.js +609 -0
  129. package/plugins/runtime/sandbox-worker.js +215 -0
  130. package/plugins/runtime/self-rescue-ladder.js +38 -0
  131. package/plugins/runtime/settings-merger.js +172 -0
  132. package/plugins/runtime/state-store.js +527 -0
  133. package/plugins/runtime/team-cleanup.js +497 -0
  134. package/plugins/runtime/text-tokenize.js +25 -0
  135. package/plugins/runtime/validator-pipeline.js +475 -0
  136. package/plugins/runtime/yaml-parser.js +692 -0
  137. package/templates/harness-config.yaml +394 -0
@@ -0,0 +1,75 @@
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
+ }
@@ -0,0 +1,179 @@
1
+ {
2
+ "context_window": {
3
+ "type": "object",
4
+ "required": false,
5
+ "properties": {
6
+ "max_tokens": { "type": "number", "required": false, "default": 200000 },
7
+ "safety_margin": { "type": "number", "required": false, "default": 40000 },
8
+ "chunk_lines": { "type": "number", "required": false, "default": 500 },
9
+ "strategy": {
10
+ "type": "string",
11
+ "required": false,
12
+ "default": "auto",
13
+ "allowedValues": ["auto", "greedy", "conservative"]
14
+ },
15
+ "thresholds": {
16
+ "type": "object",
17
+ "required": false,
18
+ "properties": {
19
+ "small": { "type": "number", "required": false, "default": 200 },
20
+ "medium": { "type": "number", "required": false, "default": 800 },
21
+ "large": { "type": "number", "required": false, "default": 2000 }
22
+ }
23
+ }
24
+ }
25
+ },
26
+
27
+ "workflow": {
28
+ "type": "object",
29
+ "required": false,
30
+ "properties": {
31
+ "default": {
32
+ "type": "object",
33
+ "required": false,
34
+ "properties": {
35
+ "name": { "type": "string", "required": false },
36
+ "description": { "type": "string", "required": false },
37
+ "stages": {
38
+ "type": "array",
39
+ "required": false,
40
+ "items": {
41
+ "type": "object",
42
+ "properties": {
43
+ "id": { "type": "string", "required": true },
44
+ "name": { "type": "string", "required": true },
45
+ "description": { "type": "string", "required": false },
46
+ "skills": { "type": "array", "required": false },
47
+ "auto_advance": { "type": "boolean", "required": false, "default": false },
48
+ "checkpoint": { "type": "boolean", "required": false, "default": false }
49
+ }
50
+ }
51
+ },
52
+ "transitions": {
53
+ "type": "array",
54
+ "required": false,
55
+ "items": {
56
+ "type": "object",
57
+ "properties": {
58
+ "from": { "type": "string", "required": true },
59
+ "to": { "type": "string", "required": true },
60
+ "condition": { "type": "string", "required": true }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ },
68
+
69
+ "roles": {
70
+ "type": "object",
71
+ "required": false,
72
+ "properties": {
73
+ "roles_dir": { "type": "string", "required": false, "default": ".claude/agents/roles" },
74
+ "registry_file": { "type": "string", "required": false, "default": ".claude/agents/role-registry.yaml" },
75
+ "defaults": {
76
+ "type": "object",
77
+ "required": false,
78
+ "properties": {
79
+ "planner": { "type": "string", "required": false, "default": "planner" },
80
+ "implementer": { "type": "string", "required": false, "default": "implementer" },
81
+ "reviewer": { "type": "string", "required": false, "default": "reviewer" },
82
+ "tester": { "type": "string", "required": false, "default": "tester" }
83
+ }
84
+ },
85
+ "capabilities": {
86
+ "type": "object",
87
+ "required": false
88
+ }
89
+ }
90
+ },
91
+
92
+ "memory": {
93
+ "type": "object",
94
+ "required": false,
95
+ "properties": {
96
+ "storage_dir": { "type": "string", "required": false, "default": ".claude/agents/memories" },
97
+ "format": {
98
+ "type": "string",
99
+ "required": false,
100
+ "default": "yaml",
101
+ "allowedValues": ["yaml", "json"]
102
+ },
103
+ "auto_extraction": {
104
+ "type": "object",
105
+ "required": false,
106
+ "properties": {
107
+ "enabled": { "type": "boolean", "required": false, "default": true },
108
+ "trigger_keywords": {
109
+ "type": "array",
110
+ "required": false,
111
+ "items": { "type": "string" }
112
+ },
113
+ "min_confidence": { "type": "number", "required": false, "default": 0.7 }
114
+ }
115
+ },
116
+ "types": {
117
+ "type": "object",
118
+ "required": false,
119
+ "patternProperties": {
120
+ ".*": {
121
+ "type": "object",
122
+ "properties": {
123
+ "enabled": { "type": "boolean", "required": false, "default": true },
124
+ "max_entries": { "type": "number", "required": false }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ },
131
+
132
+ "mcp": {
133
+ "type": "object",
134
+ "required": false,
135
+ "properties": {
136
+ "config_dir": { "type": "string", "required": false, "default": ".claude/mcp/servers" },
137
+ "servers": {
138
+ "type": "array",
139
+ "required": false,
140
+ "items": {
141
+ "type": "object",
142
+ "properties": {
143
+ "name": { "type": "string", "required": true },
144
+ "type": {
145
+ "type": "string",
146
+ "required": false,
147
+ "allowedValues": ["stdio", "http"]
148
+ },
149
+ "enabled": { "type": "boolean", "required": false, "default": false },
150
+ "command": { "type": "string", "required": false },
151
+ "args": { "type": "array", "required": false },
152
+ "env": { "type": "object", "required": false }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ },
158
+
159
+ "middleware": {
160
+ "type": "object",
161
+ "required": false,
162
+ "properties": {
163
+ "chain": {
164
+ "type": "array",
165
+ "required": false,
166
+ "items": { "type": "string" }
167
+ },
168
+ "config": {
169
+ "type": "object",
170
+ "required": false
171
+ }
172
+ }
173
+ },
174
+
175
+ "overrides": {
176
+ "type": "object",
177
+ "required": false
178
+ }
179
+ }
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Plugin Interface - Plugin contract definitions for AI Agent Harness
3
+ *
4
+ * Defines the base interface and type markers for all plugin types:
5
+ * - ProviderPlugin: capability providers (role-registry, memory-store, etc.)
6
+ * - HookPlugin: lifecycle hooks (pre/post tool use)
7
+ * - ValidatorPlugin: output validators
8
+ * - SkillPlugin: executable skills
9
+ *
10
+ * @module plugin-interface
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ /**
16
+ * Plugin lifecycle states.
17
+ * @public
18
+ */
19
+ const PluginState = {
20
+ DISCOVERED: 'discovered',
21
+ LOADED: 'loaded',
22
+ RESOLVED: 'resolved',
23
+ ACTIVATED: 'activated',
24
+ RUNNING: 'running',
25
+ DEACTIVATED: 'deactivated',
26
+ UNLOADED: 'unloaded',
27
+ };
28
+
29
+ /**
30
+ * Plugin type constants.
31
+ * @public
32
+ */
33
+ const PluginType = {
34
+ SKILL: 'skill',
35
+ HOOK: 'hook',
36
+ VALIDATOR: 'validator',
37
+ PROVIDER: 'provider',
38
+ };
39
+
40
+ /**
41
+ * Base Plugin class. All plugin implementations should extend this.
42
+ * @public
43
+ *
44
+ * Subclasses must set:
45
+ * - type {string} one of PluginType values
46
+ * - name {string} unique kebab-case identifier
47
+ * - version {string} semver version string
48
+ *
49
+ * Optional overrides:
50
+ * - description {string}
51
+ * - dependencies {{ plugins?: string[], providers?: string[] }}
52
+ * - onActivate(context) called during activation
53
+ * - onDeactivate() called during deactivation
54
+ */
55
+ class Plugin {
56
+ constructor() {
57
+ /** @type {string} */
58
+ this.type = '';
59
+ /** @type {string} */
60
+ this.name = '';
61
+ /** @type {string} */
62
+ this.version = '0.0.0';
63
+ /** @type {string} */
64
+ this.description = '';
65
+ /** @type {{ plugins?: string[], providers?: string[] }} */
66
+ this.dependencies = {};
67
+ /** @type {string} current lifecycle state */
68
+ this.state = PluginState.DISCOVERED;
69
+ }
70
+
71
+ /**
72
+ * Called when the plugin is activated.
73
+ * @public
74
+ * @param {PluginContext} context - injected runtime context
75
+ */
76
+ async onActivate(context) {
77
+ // default no-op
78
+ }
79
+
80
+ /**
81
+ * Called when the plugin is deactivated.
82
+ * @public
83
+ */
84
+ async onDeactivate() {
85
+ // default no-op
86
+ }
87
+ }
88
+
89
+ /**
90
+ * SkillPlugin - executable skill plugin.
91
+ * @public
92
+ *
93
+ * Additional properties:
94
+ * - triggers {string[]} keywords that activate this skill
95
+ * - metadata.stage workflow stage
96
+ * - metadata.requiresPlanMode
97
+ * - metadata.gatedByHuman
98
+ * - metadata.gatedByCode
99
+ */
100
+ class SkillPlugin extends Plugin {
101
+ constructor() {
102
+ super();
103
+ this.type = PluginType.SKILL;
104
+ /** @type {string[]} */
105
+ this.triggers = [];
106
+ /** @type {object} */
107
+ this.metadata = {};
108
+ }
109
+
110
+ /**
111
+ * Execute the skill.
112
+ * @public
113
+ * @param {PluginContext} context
114
+ * @param {object} args - skill-specific arguments
115
+ * @returns {Promise<object>} skill result
116
+ */
117
+ async execute(context, args) {
118
+ throw new Error('SkillPlugin.execute() must be implemented by subclass');
119
+ }
120
+ }
121
+
122
+ /**
123
+ * HookPlugin - lifecycle hook plugin.
124
+ * @public
125
+ *
126
+ * Additional properties:
127
+ * - trigger.event {'PreToolUse' | 'PostToolUse'}
128
+ * - trigger.tools {string[]} (optional) tool filter
129
+ * - trigger.skills {string[]} (optional) skill filter
130
+ * - priority {number} execution priority (lower = earlier)
131
+ */
132
+ class HookPlugin extends Plugin {
133
+ constructor() {
134
+ super();
135
+ this.type = PluginType.HOOK;
136
+ /** @type {{ event: string, tools?: string[], skills?: string[] }} */
137
+ this.trigger = { event: '', tools: [], skills: [] };
138
+ /** @type {number} */
139
+ this.priority = 100;
140
+ }
141
+
142
+ /**
143
+ * Handle a hook invocation.
144
+ * @public
145
+ * @param {object} context - hook context
146
+ * @returns {Promise<{ allowed: boolean, reason?: string, stateChanges?: object[] }>}
147
+ */
148
+ async handle(context) {
149
+ throw new Error('HookPlugin.handle() must be implemented by subclass');
150
+ }
151
+ }
152
+
153
+ /**
154
+ * ValidatorPlugin - output validation plugin.
155
+ * @public
156
+ *
157
+ * Additional properties:
158
+ * - targets {string[]} skill names this validator checks
159
+ * - blocking {boolean} whether failure stops the workflow
160
+ */
161
+ class ValidatorPlugin extends Plugin {
162
+ constructor() {
163
+ super();
164
+ this.type = PluginType.VALIDATOR;
165
+ /** @type {string[]} */
166
+ this.targets = [];
167
+ /** @type {boolean} */
168
+ this.blocking = true;
169
+ }
170
+
171
+ /**
172
+ * Run validation.
173
+ * @public
174
+ * @param {object} context - validation context
175
+ * @returns {Promise<{ passed: boolean, errors: object[], warnings: object[] }>}
176
+ */
177
+ async validate(context) {
178
+ throw new Error('ValidatorPlugin.validate() must be implemented by subclass');
179
+ }
180
+ }
181
+
182
+ /**
183
+ * ProviderPlugin - capability provider plugin.
184
+ * @public
185
+ *
186
+ * Additional properties:
187
+ * - provides {string} capability identifier
188
+ */
189
+ class ProviderPlugin extends Plugin {
190
+ constructor() {
191
+ super();
192
+ this.type = PluginType.PROVIDER;
193
+ /** @type {string} */
194
+ this.provides = '';
195
+ }
196
+
197
+ /**
198
+ * Create the provider instance.
199
+ * @public
200
+ * @param {PluginContext} context
201
+ * @returns {Promise<object>} provider instance
202
+ */
203
+ async factory(context) {
204
+ throw new Error('ProviderPlugin.factory() must be implemented by subclass');
205
+ }
206
+ }
207
+
208
+ /**
209
+ * PluginContext - injected into every plugin on activation.
210
+ * @public
211
+ */
212
+ class PluginContext {
213
+ /**
214
+ * @param {string} pluginName
215
+ * @param {object} runtime - { eventBus, stateStore, logger, configManager }
216
+ */
217
+ constructor(pluginName, runtime) {
218
+ this.pluginName = pluginName;
219
+ this.eventBus = runtime.eventBus;
220
+ this.stateStore = runtime.stateStore;
221
+ this.logger = runtime.logger;
222
+ this.config = runtime.configManager;
223
+ this._runtime = runtime;
224
+ this._providerCache = new Map();
225
+ }
226
+
227
+ /**
228
+ * Lazily query a provider by name.
229
+ * @public
230
+ * @param {string} name - provider identifier
231
+ * @returns {Promise<object>}
232
+ */
233
+ async getProvider(name) {
234
+ if (this._providerCache.has(name)) {
235
+ return this._providerCache.get(name);
236
+ }
237
+ const provider = await this._runtime.getProvider(name);
238
+ this._providerCache.set(name, provider);
239
+ return provider;
240
+ }
241
+
242
+ /**
243
+ * Get another loaded plugin by name.
244
+ * @public
245
+ * @param {string} name
246
+ * @returns {Plugin|undefined}
247
+ */
248
+ getPlugin(name) {
249
+ return this._runtime.loadedPlugins.get(name);
250
+ }
251
+ }
252
+
253
+ module.exports = {
254
+ PluginState,
255
+ PluginType,
256
+ Plugin,
257
+ SkillPlugin,
258
+ HookPlugin,
259
+ ValidatorPlugin,
260
+ ProviderPlugin,
261
+ PluginContext,
262
+ };
@@ -0,0 +1,104 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Doukui Plugin Manifest",
4
+ "description": "Schema for plugin.json files used by doukui plugins.",
5
+ "type": "object",
6
+ "required": ["name", "version", "type", "description"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "name": {
10
+ "type": "string",
11
+ "pattern": "^[a-z][a-z0-9-]*$",
12
+ "description": "Plugin identifier, lowercase with hyphens."
13
+ },
14
+ "version": {
15
+ "type": "string",
16
+ "pattern": "^\\d+\\.\\d+\\.\\d+",
17
+ "description": "Semver version string (at least major.minor.patch)."
18
+ },
19
+ "type": {
20
+ "enum": ["skill", "hook", "validator", "provider"],
21
+ "description": "Plugin type determining lifecycle and companion files."
22
+ },
23
+ "description": {
24
+ "type": "string",
25
+ "minLength": 1,
26
+ "description": "Human-readable plugin description."
27
+ },
28
+ "source": {
29
+ "type": "string",
30
+ "description": "Source identifier for non-core plugins (npm package name or local path)."
31
+ },
32
+ "sourceType": {
33
+ "enum": ["core", "npm", "local"],
34
+ "description": "Origin type of the plugin."
35
+ },
36
+ "triggers": {
37
+ "type": "array",
38
+ "items": { "type": "string", "minLength": 1 },
39
+ "description": "Trigger phrases that activate this skill. Typically used by skill plugins."
40
+ },
41
+ "dependencies": {
42
+ "type": "array",
43
+ "items": { "type": "string", "pattern": "^[a-z]" },
44
+ "description": "List of provider or plugin dependencies (e.g. 'provider:state-store')."
45
+ },
46
+ "provides": {
47
+ "type": "array",
48
+ "items": { "type": "string", "pattern": "^[a-z]" },
49
+ "description": "List of service identifiers this plugin provides (e.g. 'skill:task-creator')."
50
+ },
51
+ "config": {
52
+ "type": "object",
53
+ "description": "Plugin-specific configuration options.",
54
+ "additionalProperties": true
55
+ },
56
+ "metadata": {
57
+ "type": "object",
58
+ "description": "Optional metadata for build and runtime behavior.",
59
+ "additionalProperties": true,
60
+ "properties": {
61
+ "requiresPlanMode": {
62
+ "type": "boolean",
63
+ "description": "Whether this skill must enter Plan mode before execution."
64
+ },
65
+ "gatedByCode": {
66
+ "type": "boolean",
67
+ "description": "Whether this plugin is gated by code-level hooks."
68
+ },
69
+ "targets": {
70
+ "type": "array",
71
+ "items": { "type": "string" },
72
+ "description": "Build targets this validator applies to."
73
+ },
74
+ "deploy_assets": {
75
+ "type": "boolean",
76
+ "description": "Whether this plugin deploys static assets."
77
+ },
78
+ "deploy_path": {
79
+ "type": "string",
80
+ "description": "Target path for deployed assets."
81
+ }
82
+ }
83
+ },
84
+ "capabilities": {
85
+ "type": "object",
86
+ "description": "Declared runtime capabilities for sandbox and security control.",
87
+ "additionalProperties": true,
88
+ "properties": {
89
+ "filesystem": {
90
+ "type": "object",
91
+ "description": "Filesystem access whitelist. Uses a nested object (rather than boolean) to separately control read and write path patterns.",
92
+ "properties": {
93
+ "read": { "type": "array", "items": { "type": "string" }, "description": "Glob patterns for paths the plugin may read." },
94
+ "write": { "type": "array", "items": { "type": "string" }, "description": "Glob patterns for paths the plugin may write." }
95
+ }
96
+ },
97
+ "network": { "type": "boolean" },
98
+ "child_process": { "type": "boolean" },
99
+ "env": { "type": "array", "items": { "type": "string" } },
100
+ "plugin_access": { "type": "boolean" }
101
+ }
102
+ }
103
+ }
104
+ }