antigravity-ai-kit 3.1.1 → 3.2.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.
- package/.agent/agents/planner.md +205 -62
- package/.agent/contexts/plan-quality-log.md +30 -0
- package/.agent/engine/loading-rules.json +37 -3
- package/.agent/hooks/hooks.json +10 -0
- package/.agent/manifest.json +4 -3
- package/.agent/skills/plan-validation/SKILL.md +192 -0
- package/.agent/skills/plan-writing/SKILL.md +47 -8
- package/.agent/skills/plan-writing/domain-enhancers.md +114 -0
- package/.agent/skills/plan-writing/plan-retrospective.md +116 -0
- package/.agent/skills/plan-writing/plan-schema.md +119 -0
- package/.agent/workflows/plan.md +49 -5
- package/README.md +30 -29
- package/bin/ag-kit.js +26 -5
- package/lib/agent-registry.js +17 -3
- package/lib/agent-reputation.js +3 -11
- package/lib/circuit-breaker.js +195 -0
- package/lib/cli-commands.js +88 -1
- package/lib/config-validator.js +274 -0
- package/lib/conflict-detector.js +29 -22
- package/lib/constants.js +35 -0
- package/lib/engineering-manager.js +9 -27
- package/lib/error-budget.js +105 -29
- package/lib/hook-system.js +8 -4
- package/lib/identity.js +22 -27
- package/lib/io.js +74 -0
- package/lib/loading-engine.js +248 -35
- package/lib/logger.js +118 -0
- package/lib/marketplace.js +43 -20
- package/lib/plugin-system.js +55 -31
- package/lib/plugin-verifier.js +197 -0
- package/lib/rate-limiter.js +113 -0
- package/lib/security-scanner.js +1 -4
- package/lib/self-healing.js +58 -24
- package/lib/session-manager.js +51 -48
- package/lib/skill-sandbox.js +1 -1
- package/lib/task-governance.js +10 -11
- package/lib/task-model.js +42 -27
- package/lib/updater.js +1 -1
- package/lib/verify.js +4 -4
- package/lib/workflow-engine.js +88 -68
- package/lib/workflow-events.js +166 -0
- package/lib/workflow-persistence.js +19 -19
- package/package.json +2 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Antigravity AI Kit — Workflow Event Emitter
|
|
3
|
+
*
|
|
4
|
+
* Provides an event-driven interface for workflow state transitions.
|
|
5
|
+
* Enables reactive hook triggering and observability when the
|
|
6
|
+
* workflow engine changes phases.
|
|
7
|
+
*
|
|
8
|
+
* @module lib/workflow-events
|
|
9
|
+
* @author Emre Dursun
|
|
10
|
+
* @since v3.2.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const { EventEmitter } = require('events');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} WorkflowEvent
|
|
19
|
+
* @property {string} type - Event type
|
|
20
|
+
* @property {string} fromPhase - Source phase
|
|
21
|
+
* @property {string} toPhase - Target phase
|
|
22
|
+
* @property {string} trigger - What triggered the transition
|
|
23
|
+
* @property {string} timestamp - ISO timestamp
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Singleton workflow event bus */
|
|
27
|
+
const workflowBus = new EventEmitter();
|
|
28
|
+
|
|
29
|
+
/** Event type constants */
|
|
30
|
+
const EVENTS = {
|
|
31
|
+
TRANSITION_START: 'workflow:transition:start',
|
|
32
|
+
TRANSITION_COMPLETE: 'workflow:transition:complete',
|
|
33
|
+
TRANSITION_FAILED: 'workflow:transition:failed',
|
|
34
|
+
PHASE_ENTERED: 'workflow:phase:entered',
|
|
35
|
+
WORKFLOW_RESET: 'workflow:reset',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Emits a transition start event.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} fromPhase - Source phase
|
|
42
|
+
* @param {string} toPhase - Target phase
|
|
43
|
+
* @param {string} trigger - Transition trigger
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
function emitTransitionStart(fromPhase, toPhase, trigger) {
|
|
47
|
+
const event = {
|
|
48
|
+
type: EVENTS.TRANSITION_START,
|
|
49
|
+
fromPhase,
|
|
50
|
+
toPhase,
|
|
51
|
+
trigger,
|
|
52
|
+
timestamp: new Date().toISOString(),
|
|
53
|
+
};
|
|
54
|
+
workflowBus.emit(EVENTS.TRANSITION_START, event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Emits a transition complete event.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} fromPhase - Source phase
|
|
61
|
+
* @param {string} toPhase - Target phase
|
|
62
|
+
* @param {string} trigger - Transition trigger
|
|
63
|
+
* @returns {void}
|
|
64
|
+
*/
|
|
65
|
+
function emitTransitionComplete(fromPhase, toPhase, trigger) {
|
|
66
|
+
const event = {
|
|
67
|
+
type: EVENTS.TRANSITION_COMPLETE,
|
|
68
|
+
fromPhase,
|
|
69
|
+
toPhase,
|
|
70
|
+
trigger,
|
|
71
|
+
timestamp: new Date().toISOString(),
|
|
72
|
+
};
|
|
73
|
+
workflowBus.emit(EVENTS.TRANSITION_COMPLETE, event);
|
|
74
|
+
workflowBus.emit(EVENTS.PHASE_ENTERED, { ...event, type: EVENTS.PHASE_ENTERED, phase: toPhase });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Emits a transition failed event.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} fromPhase - Source phase
|
|
81
|
+
* @param {string} toPhase - Target phase
|
|
82
|
+
* @param {string} error - Error message
|
|
83
|
+
* @returns {void}
|
|
84
|
+
*/
|
|
85
|
+
function emitTransitionFailed(fromPhase, toPhase, error) {
|
|
86
|
+
const event = {
|
|
87
|
+
type: EVENTS.TRANSITION_FAILED,
|
|
88
|
+
fromPhase,
|
|
89
|
+
toPhase,
|
|
90
|
+
trigger: '',
|
|
91
|
+
error,
|
|
92
|
+
timestamp: new Date().toISOString(),
|
|
93
|
+
};
|
|
94
|
+
workflowBus.emit(EVENTS.TRANSITION_FAILED, event);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Emits a workflow reset event.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} previousPhase - Phase before reset
|
|
101
|
+
* @returns {void}
|
|
102
|
+
*/
|
|
103
|
+
function emitWorkflowReset(previousPhase) {
|
|
104
|
+
const event = {
|
|
105
|
+
type: EVENTS.WORKFLOW_RESET,
|
|
106
|
+
fromPhase: previousPhase,
|
|
107
|
+
toPhase: 'IDLE',
|
|
108
|
+
trigger: 'reset',
|
|
109
|
+
timestamp: new Date().toISOString(),
|
|
110
|
+
};
|
|
111
|
+
workflowBus.emit(EVENTS.WORKFLOW_RESET, event);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Subscribes to a workflow event.
|
|
116
|
+
*
|
|
117
|
+
* @param {string} eventType - Event type from EVENTS
|
|
118
|
+
* @param {Function} handler - Event handler
|
|
119
|
+
* @returns {void}
|
|
120
|
+
*/
|
|
121
|
+
function on(eventType, handler) {
|
|
122
|
+
workflowBus.on(eventType, handler);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Subscribes to a workflow event once.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} eventType - Event type from EVENTS
|
|
129
|
+
* @param {Function} handler - Event handler
|
|
130
|
+
* @returns {void}
|
|
131
|
+
*/
|
|
132
|
+
function once(eventType, handler) {
|
|
133
|
+
workflowBus.once(eventType, handler);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Removes an event listener.
|
|
138
|
+
*
|
|
139
|
+
* @param {string} eventType - Event type
|
|
140
|
+
* @param {Function} handler - Handler to remove
|
|
141
|
+
* @returns {void}
|
|
142
|
+
*/
|
|
143
|
+
function off(eventType, handler) {
|
|
144
|
+
workflowBus.off(eventType, handler);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Removes all listeners for testing cleanup.
|
|
149
|
+
*
|
|
150
|
+
* @returns {void}
|
|
151
|
+
*/
|
|
152
|
+
function removeAllListeners() {
|
|
153
|
+
workflowBus.removeAllListeners();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = {
|
|
157
|
+
EVENTS,
|
|
158
|
+
emitTransitionStart,
|
|
159
|
+
emitTransitionComplete,
|
|
160
|
+
emitTransitionFailed,
|
|
161
|
+
emitWorkflowReset,
|
|
162
|
+
on,
|
|
163
|
+
once,
|
|
164
|
+
off,
|
|
165
|
+
removeAllListeners,
|
|
166
|
+
};
|
|
@@ -16,8 +16,8 @@ const path = require('path');
|
|
|
16
16
|
const crypto = require('crypto');
|
|
17
17
|
const workflowEngine = require('./workflow-engine');
|
|
18
18
|
|
|
19
|
-
const AGENT_DIR = '
|
|
20
|
-
const
|
|
19
|
+
const { AGENT_DIR, ENGINE_DIR } = require('./constants');
|
|
20
|
+
const { writeJsonAtomic } = require('./io');
|
|
21
21
|
const CHECKPOINTS_DIR = 'checkpoints';
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -41,10 +41,6 @@ function createCheckpoint(projectRoot, label) {
|
|
|
41
41
|
const { state } = workflowEngine.loadWorkflowState(projectRoot);
|
|
42
42
|
const checkpointsDir = resolveCheckpointsDir(projectRoot);
|
|
43
43
|
|
|
44
|
-
if (!fs.existsSync(checkpointsDir)) {
|
|
45
|
-
fs.mkdirSync(checkpointsDir, { recursive: true });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
const timestamp = new Date().toISOString();
|
|
49
45
|
const checkpointId = crypto.randomUUID().slice(0, 8);
|
|
50
46
|
|
|
@@ -57,7 +53,7 @@ function createCheckpoint(projectRoot, label) {
|
|
|
57
53
|
};
|
|
58
54
|
|
|
59
55
|
const filePath = path.join(checkpointsDir, `${checkpointId}.json`);
|
|
60
|
-
|
|
56
|
+
writeJsonAtomic(filePath, checkpoint);
|
|
61
57
|
|
|
62
58
|
return { checkpointId, filePath, timestamp };
|
|
63
59
|
}
|
|
@@ -107,18 +103,22 @@ function resumeFromCheckpoint(projectRoot, checkpointId) {
|
|
|
107
103
|
|
|
108
104
|
const checkpoint = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
109
105
|
const statePath = path.join(projectRoot, AGENT_DIR, ENGINE_DIR, 'workflow-state.json');
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
106
|
+
|
|
107
|
+
// Create restored state with appended history (H-9: immutable — no mutation of checkpoint)
|
|
108
|
+
const restoredState = {
|
|
109
|
+
...checkpoint.state,
|
|
110
|
+
history: [
|
|
111
|
+
...(checkpoint.state.history || []),
|
|
112
|
+
{
|
|
113
|
+
from: 'RESTORED',
|
|
114
|
+
to: checkpoint.state.currentPhase,
|
|
115
|
+
trigger: `Restored from checkpoint ${checkpointId}`,
|
|
116
|
+
timestamp: new Date().toISOString(),
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
writeJsonAtomic(statePath, restoredState);
|
|
122
122
|
|
|
123
123
|
return { success: true, restoredPhase: checkpoint.state.currentPhase };
|
|
124
124
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antigravity-ai-kit",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "🚀 Trust-Grade AI development framework with a
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"description": "🚀 Trust-Grade AI development framework with a 29-module runtime engine — 19 Agents, 32 Skills, 31 Commands, 14 Workflows, 327 Tests. Workflow enforcement, task governance, agent reputation, self-healing, and skill marketplace.",
|
|
5
5
|
"main": "bin/ag-kit.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ag-kit": "./bin/ag-kit.js"
|