@esotech/contextuate 2.0.0 → 2.1.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/README.md +169 -1
- package/dist/commands/claude.d.ts +21 -0
- package/dist/commands/claude.js +213 -0
- package/dist/commands/context.d.ts +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +67 -6
- package/dist/commands/install.d.ts +28 -0
- package/dist/commands/install.js +116 -11
- package/dist/commands/monitor.d.ts +55 -0
- package/dist/commands/monitor.js +1007 -0
- package/dist/commands/remove.d.ts +3 -0
- package/dist/commands/run.d.ts +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +113 -1
- package/dist/monitor/daemon/circuit-breaker.d.ts +121 -0
- package/dist/monitor/daemon/circuit-breaker.js +552 -0
- package/dist/monitor/daemon/cli.d.ts +8 -0
- package/dist/monitor/daemon/cli.js +82 -0
- package/dist/monitor/daemon/index.d.ts +137 -0
- package/dist/monitor/daemon/index.js +695 -0
- package/dist/monitor/daemon/notifier.d.ts +25 -0
- package/dist/monitor/daemon/notifier.js +98 -0
- package/dist/monitor/daemon/processor.d.ts +89 -0
- package/dist/monitor/daemon/processor.js +455 -0
- package/dist/monitor/daemon/state.d.ts +80 -0
- package/dist/monitor/daemon/state.js +162 -0
- package/dist/monitor/daemon/watcher.d.ts +47 -0
- package/dist/monitor/daemon/watcher.js +171 -0
- package/dist/monitor/daemon/wrapper-manager.d.ts +106 -0
- package/dist/monitor/daemon/wrapper-manager.js +374 -0
- package/dist/monitor/hooks/emit-event.js +652 -0
- package/dist/monitor/persistence/file-store.d.ts +88 -0
- package/dist/monitor/persistence/file-store.js +335 -0
- package/dist/monitor/persistence/index.d.ts +7 -0
- package/dist/monitor/persistence/index.js +10 -0
- package/dist/monitor/server/adapters/redis.d.ts +38 -0
- package/dist/monitor/server/adapters/redis.js +213 -0
- package/dist/monitor/server/adapters/unix-socket.d.ts +33 -0
- package/dist/monitor/server/adapters/unix-socket.js +182 -0
- package/dist/monitor/server/broker.d.ts +135 -0
- package/dist/monitor/server/broker.js +475 -0
- package/dist/monitor/server/cli.d.ts +8 -0
- package/dist/monitor/server/cli.js +98 -0
- package/dist/monitor/server/fastify.d.ts +16 -0
- package/dist/monitor/server/fastify.js +184 -0
- package/dist/monitor/server/index.d.ts +36 -0
- package/dist/monitor/server/index.js +153 -0
- package/dist/monitor/server/websocket.d.ts +80 -0
- package/dist/monitor/server/websocket.js +453 -0
- package/dist/monitor/ui/assets/index-4IssW9On.js +59 -0
- package/dist/monitor/ui/assets/index-vo9hLe5R.css +32 -0
- package/dist/monitor/ui/favicon.png +0 -0
- package/dist/monitor/ui/index.html +14 -0
- package/dist/monitor/ui/logo.png +0 -0
- package/dist/monitor/ui/logo.svg +1 -0
- package/dist/runtime/driver.d.ts +16 -0
- package/dist/runtime/tools.d.ts +10 -0
- package/dist/templates/README.md +33 -7
- package/dist/templates/agents/aegis.md +4 -0
- package/dist/templates/agents/archon.md +13 -22
- package/dist/templates/agents/atlas.md +4 -0
- package/dist/templates/agents/canvas.md +4 -0
- package/dist/templates/agents/chronicle.md +4 -0
- package/dist/templates/agents/chronos.md +4 -0
- package/dist/templates/agents/cipher.md +4 -0
- package/dist/templates/agents/crucible.md +4 -0
- package/dist/templates/agents/echo.md +4 -0
- package/dist/templates/agents/forge.md +4 -0
- package/dist/templates/agents/ledger.md +4 -0
- package/dist/templates/agents/meridian.md +4 -0
- package/dist/templates/agents/nexus.md +4 -0
- package/dist/templates/agents/pythia.md +217 -0
- package/dist/templates/agents/scribe.md +4 -0
- package/dist/templates/agents/sentinel.md +4 -0
- package/dist/templates/agents/{oracle.md → thoth.md} +11 -7
- package/dist/templates/agents/unity.md +4 -0
- package/dist/templates/agents/vox.md +4 -0
- package/dist/templates/agents/weaver.md +4 -0
- package/dist/templates/framework-agents/documentation-expert.md +3 -3
- package/dist/templates/framework-agents/tools-expert.md +8 -8
- package/dist/templates/skills/consult.md +138 -0
- package/dist/templates/skills/orchestrate.md +173 -0
- package/dist/templates/skills/pythia.md +37 -0
- package/dist/templates/standards/agent-roles.md +68 -21
- package/dist/templates/standards/coding-standards.md +9 -26
- package/dist/templates/templates/context.md +17 -2
- package/dist/templates/templates/contextuate.md +21 -28
- package/dist/templates/templates/standards/go.md +167 -0
- package/dist/templates/templates/standards/java.md +167 -0
- package/dist/templates/templates/standards/javascript.md +292 -0
- package/dist/templates/templates/standards/php.md +181 -0
- package/dist/templates/templates/standards/python.md +175 -0
- package/dist/templates/tools/agent-creator.md +252 -0
- package/dist/templates/tools/agent-creator.tool.md +2 -2
- package/dist/templates/tools/quickref.md +216 -0
- package/dist/templates/tools/spawn.md +31 -0
- package/dist/templates/tools/standards-detector.md +301 -0
- package/dist/templates/version.json +1 -1
- package/dist/types/monitor.d.ts +660 -0
- package/dist/types/monitor.js +75 -0
- package/dist/utils/git.d.ts +9 -0
- package/dist/utils/tokens.d.ts +10 -0
- package/package.json +18 -5
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -9,6 +9,8 @@ const create_1 = require("./commands/create");
|
|
|
9
9
|
const index_1 = require("./commands/index");
|
|
10
10
|
const context_1 = require("./commands/context");
|
|
11
11
|
const install_1 = require("./commands/install");
|
|
12
|
+
const monitor_1 = require("./commands/monitor");
|
|
13
|
+
const claude_1 = require("./commands/claude");
|
|
12
14
|
const fs_1 = require("fs");
|
|
13
15
|
const path_1 = require("path");
|
|
14
16
|
const program = new commander_1.Command();
|
|
@@ -23,7 +25,7 @@ catch (error) {
|
|
|
23
25
|
}
|
|
24
26
|
program
|
|
25
27
|
.name('contextuate')
|
|
26
|
-
.description('Standardized AI context framework for any project.
|
|
28
|
+
.description('Standardized AI context framework for any project.')
|
|
27
29
|
.version(version);
|
|
28
30
|
program
|
|
29
31
|
.command('init [platforms...]')
|
|
@@ -68,6 +70,7 @@ const install = program
|
|
|
68
70
|
.option('-a, --agents <names...>', 'Install specific agents (use "all" for all)')
|
|
69
71
|
.option('-s, --standards <names...>', 'Install language standards (use "all" for all)')
|
|
70
72
|
.option('-t, --tools <names...>', 'Install tools (use "all" for all)')
|
|
73
|
+
.option('-k, --skills <names...>', 'Install skills/slash commands (use "all" for all)')
|
|
71
74
|
.option('--all', 'Install all available templates')
|
|
72
75
|
.option('-l, --list', 'List available templates')
|
|
73
76
|
.option('-f, --force', 'Overwrite existing files')
|
|
@@ -93,4 +96,113 @@ install
|
|
|
93
96
|
.option('--all', 'Install all tools')
|
|
94
97
|
.option('-f, --force', 'Overwrite existing files')
|
|
95
98
|
.action(install_1.installToolsCommand);
|
|
99
|
+
// Subcommand: install skills
|
|
100
|
+
install
|
|
101
|
+
.command('skills [names...]')
|
|
102
|
+
.description('Install skill templates (slash commands like /orchestrate)')
|
|
103
|
+
.option('--all', 'Install all skills')
|
|
104
|
+
.option('-f, --force', 'Overwrite existing files')
|
|
105
|
+
.action(install_1.installSkillsCommand);
|
|
106
|
+
// Monitor command with subcommands
|
|
107
|
+
const monitor = program
|
|
108
|
+
.command('monitor')
|
|
109
|
+
.description('Real-time monitoring dashboard for Claude Code sessions')
|
|
110
|
+
.option('-p, --port <number>', 'HTTP server port')
|
|
111
|
+
.option('-w, --ws-port <number>', 'WebSocket server port')
|
|
112
|
+
.option('--no-open', 'Do not open browser automatically')
|
|
113
|
+
.option('-f, --foreground', 'Run server in foreground (blocking)')
|
|
114
|
+
.action((options) => (0, monitor_1.monitorStartCommand)({
|
|
115
|
+
port: options.port ? parseInt(options.port) : undefined,
|
|
116
|
+
wsPort: options.wsPort ? parseInt(options.wsPort) : undefined,
|
|
117
|
+
noOpen: options.open === false,
|
|
118
|
+
foreground: options.foreground,
|
|
119
|
+
}));
|
|
120
|
+
// Subcommand: monitor init
|
|
121
|
+
monitor
|
|
122
|
+
.command('init')
|
|
123
|
+
.description('Initialize monitor configuration and install hooks')
|
|
124
|
+
.option('--global', 'Install hooks at user level (~/.claude/settings.json) - DEFAULT')
|
|
125
|
+
.option('--project', 'Install hooks at project level (.claude/settings.json)')
|
|
126
|
+
.action(monitor_1.monitorInitCommand);
|
|
127
|
+
// Subcommand: monitor start (explicit)
|
|
128
|
+
monitor
|
|
129
|
+
.command('start')
|
|
130
|
+
.description('Start the monitor server')
|
|
131
|
+
.option('-p, --port <number>', 'HTTP server port')
|
|
132
|
+
.option('-w, --ws-port <number>', 'WebSocket server port')
|
|
133
|
+
.option('--no-open', 'Do not open browser automatically')
|
|
134
|
+
.option('-f, --foreground', 'Run server in foreground (blocking)')
|
|
135
|
+
.action((options) => (0, monitor_1.monitorStartCommand)({
|
|
136
|
+
port: options.port ? parseInt(options.port) : undefined,
|
|
137
|
+
wsPort: options.wsPort ? parseInt(options.wsPort) : undefined,
|
|
138
|
+
noOpen: options.open === false,
|
|
139
|
+
foreground: options.foreground,
|
|
140
|
+
}));
|
|
141
|
+
// Subcommand: monitor stop
|
|
142
|
+
monitor
|
|
143
|
+
.command('stop')
|
|
144
|
+
.description('Stop the monitor daemon')
|
|
145
|
+
.option('--all', 'Also stop any background processes')
|
|
146
|
+
.action((options) => (0, monitor_1.monitorStopCommand)({ all: options.all }));
|
|
147
|
+
// Subcommand: monitor status
|
|
148
|
+
monitor
|
|
149
|
+
.command('status')
|
|
150
|
+
.description('Show monitor server status')
|
|
151
|
+
.action(monitor_1.monitorStatusCommand);
|
|
152
|
+
// Daemon command group (top-level)
|
|
153
|
+
const daemon = program
|
|
154
|
+
.command('daemon')
|
|
155
|
+
.description('Manage the monitor daemon');
|
|
156
|
+
daemon
|
|
157
|
+
.command('start')
|
|
158
|
+
.description('Start the event processing daemon')
|
|
159
|
+
.option('-d, --detach', 'Run in background (detached mode)')
|
|
160
|
+
.action(async (options) => {
|
|
161
|
+
await (0, monitor_1.monitorDaemonStartCommand)(options);
|
|
162
|
+
});
|
|
163
|
+
daemon
|
|
164
|
+
.command('stop')
|
|
165
|
+
.description('Stop the daemon')
|
|
166
|
+
.action(async () => {
|
|
167
|
+
await (0, monitor_1.monitorDaemonStopCommand)();
|
|
168
|
+
});
|
|
169
|
+
daemon
|
|
170
|
+
.command('status')
|
|
171
|
+
.description('Check daemon status')
|
|
172
|
+
.action(async () => {
|
|
173
|
+
await (0, monitor_1.monitorDaemonStatusCommand)();
|
|
174
|
+
});
|
|
175
|
+
daemon
|
|
176
|
+
.command('logs')
|
|
177
|
+
.description('View daemon logs')
|
|
178
|
+
.option('-f, --follow', 'Follow log output (like tail -f)')
|
|
179
|
+
.option('-n, --lines <n>', 'Number of lines to show', '50')
|
|
180
|
+
.action(async (options) => {
|
|
181
|
+
await (0, monitor_1.monitorDaemonLogsCommand)({
|
|
182
|
+
follow: options.follow,
|
|
183
|
+
lines: parseInt(options.lines)
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
// Claude wrapper command - wraps Claude CLI with PTY for monitor integration
|
|
187
|
+
program
|
|
188
|
+
.command('claude')
|
|
189
|
+
.description('Run Claude Code with monitor integration (PTY wrapper)')
|
|
190
|
+
.argument('[args...]', 'Arguments to pass to Claude CLI')
|
|
191
|
+
.allowUnknownOption(true)
|
|
192
|
+
.action((args) => {
|
|
193
|
+
(0, claude_1.claudeCommand)(args);
|
|
194
|
+
});
|
|
195
|
+
// Wrapper command group - manage Claude wrapper sessions
|
|
196
|
+
const wrapper = program
|
|
197
|
+
.command('wrapper')
|
|
198
|
+
.description('Manage Claude wrapper sessions');
|
|
199
|
+
wrapper
|
|
200
|
+
.command('list')
|
|
201
|
+
.description('List active wrapper sessions')
|
|
202
|
+
.action(claude_1.listWrappersCommand);
|
|
203
|
+
wrapper
|
|
204
|
+
.command('kill')
|
|
205
|
+
.argument('<wrapperId>', 'Wrapper ID to kill')
|
|
206
|
+
.description('Kill a wrapper session')
|
|
207
|
+
.action(claude_1.killWrapperCommand);
|
|
96
208
|
program.parse();
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circuit Breaker
|
|
3
|
+
*
|
|
4
|
+
* Monitors Claude Code sessions for stagnation and takes corrective action.
|
|
5
|
+
* Inspired by Michael Nygard's "Release It!" circuit breaker pattern.
|
|
6
|
+
*
|
|
7
|
+
* States:
|
|
8
|
+
* - CLOSED: Normal operation, progress being made
|
|
9
|
+
* - HALF_OPEN: Warning state, monitoring for recovery
|
|
10
|
+
* - OPEN: Stagnation detected, intervention required
|
|
11
|
+
*
|
|
12
|
+
* Detection methods:
|
|
13
|
+
* - Time-based: No events for X seconds, no progress for Y seconds
|
|
14
|
+
* - Loop-based: N loops without file changes, M consecutive errors
|
|
15
|
+
*
|
|
16
|
+
* Actions:
|
|
17
|
+
* - Alert: Notify UI of state change
|
|
18
|
+
* - Inject prompt: Send "you're stuck" message to Claude
|
|
19
|
+
* - Kill: Terminate the session
|
|
20
|
+
* - Restart: Kill and spawn new session
|
|
21
|
+
*/
|
|
22
|
+
import type { WrapperManager } from './wrapper-manager.js';
|
|
23
|
+
import type { MonitorEvent, CircuitBreakerConfig, SessionHealth, CircuitAlert } from '../../types/monitor.js';
|
|
24
|
+
/**
|
|
25
|
+
* Callback for circuit alerts
|
|
26
|
+
*/
|
|
27
|
+
export type CircuitAlertCallback = (alert: CircuitAlert) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Circuit Breaker class
|
|
30
|
+
*
|
|
31
|
+
* Monitors session health and takes action when stagnation is detected.
|
|
32
|
+
*/
|
|
33
|
+
export declare class CircuitBreaker {
|
|
34
|
+
private config;
|
|
35
|
+
private wrapperManager;
|
|
36
|
+
private sessionHealth;
|
|
37
|
+
private cronJob;
|
|
38
|
+
private onAlert;
|
|
39
|
+
private pendingKills;
|
|
40
|
+
constructor(config: Partial<CircuitBreakerConfig>, wrapperManager: WrapperManager, onAlert: CircuitAlertCallback);
|
|
41
|
+
/**
|
|
42
|
+
* Start the cron-based health monitoring
|
|
43
|
+
*/
|
|
44
|
+
start(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Stop health monitoring
|
|
47
|
+
*/
|
|
48
|
+
stop(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Update configuration at runtime
|
|
51
|
+
*/
|
|
52
|
+
updateConfig(config: Partial<CircuitBreakerConfig>): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get current configuration
|
|
55
|
+
*/
|
|
56
|
+
getConfig(): CircuitBreakerConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Scheduled health check - runs on cron interval
|
|
59
|
+
*/
|
|
60
|
+
private runHealthChecks;
|
|
61
|
+
/**
|
|
62
|
+
* Process an incoming event (called by EventProcessor)
|
|
63
|
+
*/
|
|
64
|
+
processEvent(event: MonitorEvent, wrapperId: string | null): void;
|
|
65
|
+
/**
|
|
66
|
+
* Handle state transitions and take action
|
|
67
|
+
*/
|
|
68
|
+
private transitionState;
|
|
69
|
+
/**
|
|
70
|
+
* Take intervention action
|
|
71
|
+
*/
|
|
72
|
+
private takeAction;
|
|
73
|
+
/**
|
|
74
|
+
* Schedule a kill after the grace period
|
|
75
|
+
*/
|
|
76
|
+
private scheduleKill;
|
|
77
|
+
/**
|
|
78
|
+
* Build a context-aware intervention prompt
|
|
79
|
+
*/
|
|
80
|
+
private buildInterventionPrompt;
|
|
81
|
+
/**
|
|
82
|
+
* Kill wrapper and optionally restart
|
|
83
|
+
*/
|
|
84
|
+
private killAndMaybeRestart;
|
|
85
|
+
/**
|
|
86
|
+
* Check if event indicates file modification progress
|
|
87
|
+
*/
|
|
88
|
+
private isProgressEvent;
|
|
89
|
+
/**
|
|
90
|
+
* Get recommendation based on current health state
|
|
91
|
+
*/
|
|
92
|
+
private getRecommendation;
|
|
93
|
+
/**
|
|
94
|
+
* Get or create health tracking for a session
|
|
95
|
+
*/
|
|
96
|
+
private getOrCreateHealth;
|
|
97
|
+
/**
|
|
98
|
+
* Get health status for all sessions (for UI)
|
|
99
|
+
*/
|
|
100
|
+
getAllHealth(): SessionHealth[];
|
|
101
|
+
/**
|
|
102
|
+
* Get health for a specific session
|
|
103
|
+
*/
|
|
104
|
+
getSessionHealth(sessionId: string): SessionHealth | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Reset circuit for a session (manual intervention)
|
|
107
|
+
*/
|
|
108
|
+
resetCircuit(sessionId: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Associate a wrapper with a session (called when correlation is detected)
|
|
111
|
+
*/
|
|
112
|
+
associateWrapper(sessionId: string, wrapperId: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Remove health tracking for a session (on session end)
|
|
115
|
+
*/
|
|
116
|
+
removeSession(sessionId: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Check if circuit breaker is enabled
|
|
119
|
+
*/
|
|
120
|
+
isEnabled(): boolean;
|
|
121
|
+
}
|