@lovelybunch/core 1.0.73 → 1.0.74
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/dist/context.d.ts +174 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +201 -0
- package/dist/context.js.map +1 -0
- package/dist/events.d.ts +89 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +102 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge.d.ts +1148 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +427 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/logging/jsonl-writer.d.ts.map +1 -1
- package/dist/logging/jsonl-writer.js +11 -15
- package/dist/logging/jsonl-writer.js.map +1 -1
- package/dist/markdown-storage.d.ts.map +1 -1
- package/dist/markdown-storage.js +43 -1
- package/dist/markdown-storage.js.map +1 -1
- package/dist/proposals.d.ts +645 -0
- package/dist/proposals.d.ts.map +1 -0
- package/dist/proposals.js +454 -0
- package/dist/proposals.js.map +1 -0
- package/dist/system-prompts/coconut-assistant.md +103 -25
- package/package.json +6 -4
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ContextTypeSchema: z.ZodEnum<["project", "architecture", "role"]>;
|
|
3
|
+
export type ContextType = z.infer<typeof ContextTypeSchema>;
|
|
4
|
+
export declare const ContextDocumentSchema: z.ZodObject<{
|
|
5
|
+
content: z.ZodString;
|
|
6
|
+
frontmatter: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
7
|
+
raw: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
content: string;
|
|
10
|
+
frontmatter: Record<string, unknown>;
|
|
11
|
+
raw: string;
|
|
12
|
+
}, {
|
|
13
|
+
content: string;
|
|
14
|
+
frontmatter: Record<string, unknown>;
|
|
15
|
+
raw: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type ContextDocument = z.infer<typeof ContextDocumentSchema>;
|
|
18
|
+
export declare const GetContextInputSchema: z.ZodObject<{
|
|
19
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
type: "project" | "architecture" | "role";
|
|
22
|
+
}, {
|
|
23
|
+
type: "project" | "architecture" | "role";
|
|
24
|
+
}>;
|
|
25
|
+
export type GetContextInput = z.infer<typeof GetContextInputSchema>;
|
|
26
|
+
export declare const UpdateContextInputSchema: z.ZodObject<{
|
|
27
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
28
|
+
content: z.ZodString;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
content: string;
|
|
31
|
+
type: "project" | "architecture" | "role";
|
|
32
|
+
}, {
|
|
33
|
+
content: string;
|
|
34
|
+
type: "project" | "architecture" | "role";
|
|
35
|
+
}>;
|
|
36
|
+
export type UpdateContextInput = z.infer<typeof UpdateContextInputSchema>;
|
|
37
|
+
export declare const AppendContextInputSchema: z.ZodObject<{
|
|
38
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
39
|
+
content: z.ZodString;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
content: string;
|
|
42
|
+
type: "project" | "architecture" | "role";
|
|
43
|
+
}, {
|
|
44
|
+
content: string;
|
|
45
|
+
type: "project" | "architecture" | "role";
|
|
46
|
+
}>;
|
|
47
|
+
export type AppendContextInput = z.infer<typeof AppendContextInputSchema>;
|
|
48
|
+
export declare const ReplaceContextSectionInputSchema: z.ZodObject<{
|
|
49
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
50
|
+
oldText: z.ZodString;
|
|
51
|
+
newText: z.ZodString;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
type: "project" | "architecture" | "role";
|
|
54
|
+
oldText: string;
|
|
55
|
+
newText: string;
|
|
56
|
+
}, {
|
|
57
|
+
type: "project" | "architecture" | "role";
|
|
58
|
+
oldText: string;
|
|
59
|
+
newText: string;
|
|
60
|
+
}>;
|
|
61
|
+
export type ReplaceContextSectionInput = z.infer<typeof ReplaceContextSectionInputSchema>;
|
|
62
|
+
export declare const ReplaceContextResultSchema: z.ZodObject<{
|
|
63
|
+
success: z.ZodBoolean;
|
|
64
|
+
error: z.ZodOptional<z.ZodString>;
|
|
65
|
+
fallbackMarkdown: z.ZodOptional<z.ZodString>;
|
|
66
|
+
suggestion: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
success: boolean;
|
|
69
|
+
error?: string | undefined;
|
|
70
|
+
fallbackMarkdown?: string | undefined;
|
|
71
|
+
suggestion?: string | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
success: boolean;
|
|
74
|
+
error?: string | undefined;
|
|
75
|
+
fallbackMarkdown?: string | undefined;
|
|
76
|
+
suggestion?: string | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
export type ReplaceContextResult = z.infer<typeof ReplaceContextResultSchema>;
|
|
79
|
+
/**
|
|
80
|
+
* Read a context document (project, architecture, or role)
|
|
81
|
+
*/
|
|
82
|
+
export declare function getContext(type: ContextType): Promise<ContextDocument>;
|
|
83
|
+
/**
|
|
84
|
+
* Replace entire context document with new content
|
|
85
|
+
*/
|
|
86
|
+
export declare function updateContext(type: ContextType, content: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Append content to the end of a context document
|
|
89
|
+
*/
|
|
90
|
+
export declare function appendContext(type: ContextType, content: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Find and replace specific text in a context document
|
|
93
|
+
*/
|
|
94
|
+
export declare function replaceContextSection(type: ContextType, oldText: string, newText: string): Promise<ReplaceContextResult>;
|
|
95
|
+
export declare const contextSchemas: {
|
|
96
|
+
ContextTypeSchema: z.ZodEnum<["project", "architecture", "role"]>;
|
|
97
|
+
ContextDocumentSchema: z.ZodObject<{
|
|
98
|
+
content: z.ZodString;
|
|
99
|
+
frontmatter: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
100
|
+
raw: z.ZodString;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
content: string;
|
|
103
|
+
frontmatter: Record<string, unknown>;
|
|
104
|
+
raw: string;
|
|
105
|
+
}, {
|
|
106
|
+
content: string;
|
|
107
|
+
frontmatter: Record<string, unknown>;
|
|
108
|
+
raw: string;
|
|
109
|
+
}>;
|
|
110
|
+
GetContextInputSchema: z.ZodObject<{
|
|
111
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
type: "project" | "architecture" | "role";
|
|
114
|
+
}, {
|
|
115
|
+
type: "project" | "architecture" | "role";
|
|
116
|
+
}>;
|
|
117
|
+
UpdateContextInputSchema: z.ZodObject<{
|
|
118
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
119
|
+
content: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
content: string;
|
|
122
|
+
type: "project" | "architecture" | "role";
|
|
123
|
+
}, {
|
|
124
|
+
content: string;
|
|
125
|
+
type: "project" | "architecture" | "role";
|
|
126
|
+
}>;
|
|
127
|
+
AppendContextInputSchema: z.ZodObject<{
|
|
128
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
129
|
+
content: z.ZodString;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
content: string;
|
|
132
|
+
type: "project" | "architecture" | "role";
|
|
133
|
+
}, {
|
|
134
|
+
content: string;
|
|
135
|
+
type: "project" | "architecture" | "role";
|
|
136
|
+
}>;
|
|
137
|
+
ReplaceContextSectionInputSchema: z.ZodObject<{
|
|
138
|
+
type: z.ZodEnum<["project", "architecture", "role"]>;
|
|
139
|
+
oldText: z.ZodString;
|
|
140
|
+
newText: z.ZodString;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
type: "project" | "architecture" | "role";
|
|
143
|
+
oldText: string;
|
|
144
|
+
newText: string;
|
|
145
|
+
}, {
|
|
146
|
+
type: "project" | "architecture" | "role";
|
|
147
|
+
oldText: string;
|
|
148
|
+
newText: string;
|
|
149
|
+
}>;
|
|
150
|
+
ReplaceContextResultSchema: z.ZodObject<{
|
|
151
|
+
success: z.ZodBoolean;
|
|
152
|
+
error: z.ZodOptional<z.ZodString>;
|
|
153
|
+
fallbackMarkdown: z.ZodOptional<z.ZodString>;
|
|
154
|
+
suggestion: z.ZodOptional<z.ZodString>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
success: boolean;
|
|
157
|
+
error?: string | undefined;
|
|
158
|
+
fallbackMarkdown?: string | undefined;
|
|
159
|
+
suggestion?: string | undefined;
|
|
160
|
+
}, {
|
|
161
|
+
success: boolean;
|
|
162
|
+
error?: string | undefined;
|
|
163
|
+
fallbackMarkdown?: string | undefined;
|
|
164
|
+
suggestion?: string | undefined;
|
|
165
|
+
}>;
|
|
166
|
+
};
|
|
167
|
+
export declare const contextJsonSchemas: {
|
|
168
|
+
contextType: Record<string, unknown>;
|
|
169
|
+
get: Record<string, unknown>;
|
|
170
|
+
update: Record<string, unknown>;
|
|
171
|
+
append: Record<string, unknown>;
|
|
172
|
+
replaceSection: Record<string, unknown>;
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA4DvB,eAAO,MAAM,iBAAiB,gDAA8C,CAAA;AAC5E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,e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AO,CAAC,oBAAoB,CAAC,CAmC/B;AAMD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQ1B,CAAA;AAWD,eAAO,MAAM,kBAAkB;;;;;;CAM9B,CAAA"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import matter from 'gray-matter';
|
|
6
|
+
import { getLogger, ContextKinds } from './logging/index.js';
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Path Resolution (matches proposals.ts pattern)
|
|
9
|
+
// ============================================================================
|
|
10
|
+
function resolveGaitPath() {
|
|
11
|
+
if (process.env.NODE_ENV === 'development' && process.env.GAIT_DEV_ROOT) {
|
|
12
|
+
return process.env.GAIT_DEV_ROOT;
|
|
13
|
+
}
|
|
14
|
+
if (process.env.GAIT_DATA_PATH) {
|
|
15
|
+
return `${process.env.GAIT_DATA_PATH}/.nut`;
|
|
16
|
+
}
|
|
17
|
+
return '.nut';
|
|
18
|
+
}
|
|
19
|
+
function getContextPath() {
|
|
20
|
+
return path.join(resolveGaitPath(), 'context');
|
|
21
|
+
}
|
|
22
|
+
function getContextFilePath(type) {
|
|
23
|
+
return path.join(getContextPath(), `${type}.md`);
|
|
24
|
+
}
|
|
25
|
+
function getContextEventKind(type) {
|
|
26
|
+
switch (type) {
|
|
27
|
+
case 'project': return ContextKinds.PROJECT_UPDATE;
|
|
28
|
+
case 'architecture': return ContextKinds.ARCHITECTURE_UPDATE;
|
|
29
|
+
case 'role': return ContextKinds.ROLE_UPDATE;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function logContextEvent(type, operation, payload) {
|
|
33
|
+
try {
|
|
34
|
+
const logger = getLogger();
|
|
35
|
+
logger.log({
|
|
36
|
+
kind: getContextEventKind(type),
|
|
37
|
+
actor: 'cli:nut', // CLI operations
|
|
38
|
+
subject: `context:${type}`,
|
|
39
|
+
tags: ['context', type],
|
|
40
|
+
payload: {
|
|
41
|
+
operation,
|
|
42
|
+
...payload,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
// Don't fail the operation if logging fails
|
|
48
|
+
console.error('Failed to log context event:', err);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Zod Schemas
|
|
53
|
+
// ============================================================================
|
|
54
|
+
export const ContextTypeSchema = z.enum(['project', 'architecture', 'role']);
|
|
55
|
+
export const ContextDocumentSchema = z.object({
|
|
56
|
+
content: z.string(),
|
|
57
|
+
frontmatter: z.record(z.unknown()),
|
|
58
|
+
raw: z.string(),
|
|
59
|
+
});
|
|
60
|
+
export const GetContextInputSchema = z.object({
|
|
61
|
+
type: ContextTypeSchema,
|
|
62
|
+
});
|
|
63
|
+
export const UpdateContextInputSchema = z.object({
|
|
64
|
+
type: ContextTypeSchema,
|
|
65
|
+
content: z.string().min(1, 'Content is required'),
|
|
66
|
+
});
|
|
67
|
+
export const AppendContextInputSchema = z.object({
|
|
68
|
+
type: ContextTypeSchema,
|
|
69
|
+
content: z.string().min(1, 'Content is required'),
|
|
70
|
+
});
|
|
71
|
+
export const ReplaceContextSectionInputSchema = z.object({
|
|
72
|
+
type: ContextTypeSchema,
|
|
73
|
+
oldText: z.string().min(1, 'Old text is required'),
|
|
74
|
+
newText: z.string(), // Can be empty to delete a section
|
|
75
|
+
});
|
|
76
|
+
export const ReplaceContextResultSchema = z.object({
|
|
77
|
+
success: z.boolean(),
|
|
78
|
+
error: z.string().optional(),
|
|
79
|
+
fallbackMarkdown: z.string().optional(),
|
|
80
|
+
suggestion: z.string().optional(),
|
|
81
|
+
});
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// Core Functions
|
|
84
|
+
// ============================================================================
|
|
85
|
+
/**
|
|
86
|
+
* Read a context document (project, architecture, or role)
|
|
87
|
+
*/
|
|
88
|
+
export async function getContext(type) {
|
|
89
|
+
ContextTypeSchema.parse(type);
|
|
90
|
+
const filePath = getContextFilePath(type);
|
|
91
|
+
try {
|
|
92
|
+
const raw = await fs.readFile(filePath, 'utf-8');
|
|
93
|
+
const { data, content } = matter(raw);
|
|
94
|
+
return { content, frontmatter: data, raw };
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
if (err.code === 'ENOENT') {
|
|
98
|
+
return { content: '', frontmatter: {}, raw: '' };
|
|
99
|
+
}
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Replace entire context document with new content
|
|
105
|
+
*/
|
|
106
|
+
export async function updateContext(type, content) {
|
|
107
|
+
UpdateContextInputSchema.parse({ type, content });
|
|
108
|
+
const contextPath = getContextPath();
|
|
109
|
+
await fs.mkdir(contextPath, { recursive: true });
|
|
110
|
+
await fs.writeFile(getContextFilePath(type), content, 'utf-8');
|
|
111
|
+
logContextEvent(type, 'update', {
|
|
112
|
+
contentLength: content.length,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Append content to the end of a context document
|
|
117
|
+
*/
|
|
118
|
+
export async function appendContext(type, content) {
|
|
119
|
+
AppendContextInputSchema.parse({ type, content });
|
|
120
|
+
const filePath = getContextFilePath(type);
|
|
121
|
+
const contextPath = getContextPath();
|
|
122
|
+
await fs.mkdir(contextPath, { recursive: true });
|
|
123
|
+
let existing = '';
|
|
124
|
+
try {
|
|
125
|
+
existing = await fs.readFile(filePath, 'utf-8');
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (err.code !== 'ENOENT')
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
const newContent = existing
|
|
132
|
+
? existing.trimEnd() + '\n\n' + content
|
|
133
|
+
: content;
|
|
134
|
+
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
135
|
+
logContextEvent(type, 'append', {
|
|
136
|
+
appendedLength: content.length,
|
|
137
|
+
totalLength: newContent.length,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Find and replace specific text in a context document
|
|
142
|
+
*/
|
|
143
|
+
export async function replaceContextSection(type, oldText, newText) {
|
|
144
|
+
ReplaceContextSectionInputSchema.parse({ type, oldText, newText });
|
|
145
|
+
const filePath = getContextFilePath(type);
|
|
146
|
+
let existing;
|
|
147
|
+
try {
|
|
148
|
+
existing = await fs.readFile(filePath, 'utf-8');
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
if (err.code === 'ENOENT') {
|
|
152
|
+
return {
|
|
153
|
+
success: false,
|
|
154
|
+
error: `Context document does not exist. Use updateContext to create it first.`,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
if (!existing.includes(oldText)) {
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: 'Could not find the specified text in the document. The text may have been paraphrased or changed.',
|
|
163
|
+
fallbackMarkdown: newText,
|
|
164
|
+
suggestion: 'Here is the replacement text. You can copy it and manually edit the document.',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const updated = existing.replace(oldText, newText);
|
|
168
|
+
await fs.writeFile(filePath, updated, 'utf-8');
|
|
169
|
+
logContextEvent(type, 'replace_section', {
|
|
170
|
+
oldTextLength: oldText.length,
|
|
171
|
+
newTextLength: newText.length,
|
|
172
|
+
});
|
|
173
|
+
return { success: true };
|
|
174
|
+
}
|
|
175
|
+
// ============================================================================
|
|
176
|
+
// Export all schemas for MCP tool generation
|
|
177
|
+
// ============================================================================
|
|
178
|
+
export const contextSchemas = {
|
|
179
|
+
ContextTypeSchema,
|
|
180
|
+
ContextDocumentSchema,
|
|
181
|
+
GetContextInputSchema,
|
|
182
|
+
UpdateContextInputSchema,
|
|
183
|
+
AppendContextInputSchema,
|
|
184
|
+
ReplaceContextSectionInputSchema,
|
|
185
|
+
ReplaceContextResultSchema,
|
|
186
|
+
};
|
|
187
|
+
// ============================================================================
|
|
188
|
+
// Pre-computed JSON Schemas for MCP tool parameters
|
|
189
|
+
// ============================================================================
|
|
190
|
+
function extractJsonSchemaProperties(schema) {
|
|
191
|
+
const jsonSchema = zodToJsonSchema(schema, { $refStrategy: 'none' });
|
|
192
|
+
return (jsonSchema.properties || {});
|
|
193
|
+
}
|
|
194
|
+
export const contextJsonSchemas = {
|
|
195
|
+
contextType: extractJsonSchemaProperties(ContextTypeSchema),
|
|
196
|
+
get: extractJsonSchemaProperties(GetContextInputSchema),
|
|
197
|
+
update: extractJsonSchemaProperties(UpdateContextInputSchema),
|
|
198
|
+
append: extractJsonSchemaProperties(AppendContextInputSchema),
|
|
199
|
+
replaceSection: extractJsonSchemaProperties(ReplaceContextSectionInputSchema),
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAA;AACnC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE5D,+EAA+E;AAC/E,iDAAiD;AACjD,+EAA+E;AAE/E,SAAS,eAAe;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QACxE,OAAO,OAAO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CAAgC;IAChC,0BAA0B;CAC3B,CAAA;AAED,+EAA+E;AAC/E,oDAAoD;AACpD,+EAA+E;AAE/E,SAAS,2BAA2B,CAAC,MAAe;IAClD,MAAM,UAAU,GAAG,eAAe,CAAC,MAAa,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAA4B,CAAA;IACtG,OAAO,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE,CAA4B,CAAA;AACjE,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,2BAA2B,CAAC,iBAAiB,CAAC;IAC3D,GAAG,EAAE,2BAA2B,CAAC,qBAAqB,CAAC;IACvD,MAAM,EAAE,2BAA2B,CAAC,wBAAwB,CAAC;IAC7D,MAAM,EAAE,2BAA2B,CAAC,wBAAwB,CAAC;IAC7D,cAAc,EAAE,2BAA2B,CAAC,gCAAgC,CAAC;CAC9E,CAAA"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ActivityEventSchema: z.ZodObject<{
|
|
3
|
+
seq: z.ZodNumber;
|
|
4
|
+
kind: z.ZodString;
|
|
5
|
+
actor: z.ZodString;
|
|
6
|
+
subject: z.ZodString;
|
|
7
|
+
timestamp: z.ZodString;
|
|
8
|
+
level: z.ZodOptional<z.ZodString>;
|
|
9
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
seq: number;
|
|
13
|
+
kind: string;
|
|
14
|
+
actor: string;
|
|
15
|
+
subject: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
level?: string | undefined;
|
|
18
|
+
tags?: string[] | undefined;
|
|
19
|
+
summary?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
seq: number;
|
|
22
|
+
kind: string;
|
|
23
|
+
actor: string;
|
|
24
|
+
subject: string;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
level?: string | undefined;
|
|
27
|
+
tags?: string[] | undefined;
|
|
28
|
+
summary?: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export type ActivityEvent = z.infer<typeof ActivityEventSchema>;
|
|
31
|
+
export declare const ListEventsOptionsSchema: z.ZodObject<{
|
|
32
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
33
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
limit: number;
|
|
36
|
+
kind?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
kind?: string | undefined;
|
|
39
|
+
limit?: number | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export type ListEventsOptions = z.infer<typeof ListEventsOptionsSchema>;
|
|
42
|
+
/**
|
|
43
|
+
* List recent activity events from the event log
|
|
44
|
+
*/
|
|
45
|
+
export declare function listEvents(options?: ListEventsOptions): Promise<ActivityEvent[]>;
|
|
46
|
+
export declare const eventsSchemas: {
|
|
47
|
+
ActivityEventSchema: z.ZodObject<{
|
|
48
|
+
seq: z.ZodNumber;
|
|
49
|
+
kind: z.ZodString;
|
|
50
|
+
actor: z.ZodString;
|
|
51
|
+
subject: z.ZodString;
|
|
52
|
+
timestamp: z.ZodString;
|
|
53
|
+
level: z.ZodOptional<z.ZodString>;
|
|
54
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
55
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
seq: number;
|
|
58
|
+
kind: string;
|
|
59
|
+
actor: string;
|
|
60
|
+
subject: string;
|
|
61
|
+
timestamp: string;
|
|
62
|
+
level?: string | undefined;
|
|
63
|
+
tags?: string[] | undefined;
|
|
64
|
+
summary?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
seq: number;
|
|
67
|
+
kind: string;
|
|
68
|
+
actor: string;
|
|
69
|
+
subject: string;
|
|
70
|
+
timestamp: string;
|
|
71
|
+
level?: string | undefined;
|
|
72
|
+
tags?: string[] | undefined;
|
|
73
|
+
summary?: string | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
ListEventsOptionsSchema: z.ZodObject<{
|
|
76
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
77
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
limit: number;
|
|
80
|
+
kind?: string | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
kind?: string | undefined;
|
|
83
|
+
limit?: number | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
export declare const eventsJsonSchemas: {
|
|
87
|
+
list: Record<string, unknown>;
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAYvB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS9B,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAMvE;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA2DtF;AAMD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGzB,CAAA;AAWD,eAAO,MAAM,iBAAiB;;CAE7B,CAAA"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
import { createReadStream } from 'fs';
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import readline from 'readline';
|
|
7
|
+
import { getLogsDir } from './app-paths.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Zod Schemas
|
|
10
|
+
// ============================================================================
|
|
11
|
+
export const ActivityEventSchema = z.object({
|
|
12
|
+
seq: z.number(),
|
|
13
|
+
kind: z.string(),
|
|
14
|
+
actor: z.string(),
|
|
15
|
+
subject: z.string(),
|
|
16
|
+
timestamp: z.string(),
|
|
17
|
+
level: z.string().optional(),
|
|
18
|
+
tags: z.array(z.string()).optional(),
|
|
19
|
+
summary: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
export const ListEventsOptionsSchema = z.object({
|
|
22
|
+
limit: z.number().min(1).max(100).optional().default(20),
|
|
23
|
+
kind: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Core Functions
|
|
27
|
+
// ============================================================================
|
|
28
|
+
/**
|
|
29
|
+
* List recent activity events from the event log
|
|
30
|
+
*/
|
|
31
|
+
export async function listEvents(options) {
|
|
32
|
+
const opts = ListEventsOptionsSchema.parse(options || {});
|
|
33
|
+
const { limit = 20, kind } = opts;
|
|
34
|
+
const eventsDir = getLogsDir();
|
|
35
|
+
const currentFile = path.join(eventsDir, 'events-current.jsonl');
|
|
36
|
+
// Check if file exists
|
|
37
|
+
try {
|
|
38
|
+
await fs.access(currentFile);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
// Read all events from file
|
|
44
|
+
const allEvents = [];
|
|
45
|
+
const fileStream = createReadStream(currentFile);
|
|
46
|
+
const rl = readline.createInterface({
|
|
47
|
+
input: fileStream,
|
|
48
|
+
crlfDelay: Infinity,
|
|
49
|
+
});
|
|
50
|
+
for await (const line of rl) {
|
|
51
|
+
if (!line.trim())
|
|
52
|
+
continue;
|
|
53
|
+
try {
|
|
54
|
+
const event = JSON.parse(line);
|
|
55
|
+
// Apply kind filter if specified
|
|
56
|
+
if (kind && typeof kind === 'string') {
|
|
57
|
+
if (!event.kind || !event.kind.startsWith(kind)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
allEvents.push(event);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Skip malformed lines
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Sort by seq descending (most recent first) and limit
|
|
69
|
+
const cappedLimit = Math.min(Math.max(1, limit), 100);
|
|
70
|
+
const sortedEvents = allEvents
|
|
71
|
+
.sort((a, b) => (b.seq || 0) - (a.seq || 0))
|
|
72
|
+
.slice(0, cappedLimit);
|
|
73
|
+
// Format events for output
|
|
74
|
+
return sortedEvents.map(event => ({
|
|
75
|
+
seq: event.seq,
|
|
76
|
+
kind: event.kind,
|
|
77
|
+
actor: event.actor,
|
|
78
|
+
subject: event.subject,
|
|
79
|
+
timestamp: event.ts,
|
|
80
|
+
level: event.level,
|
|
81
|
+
tags: event.tags,
|
|
82
|
+
summary: event.payload?.summary || event.payload?.message || event.payload?.title || undefined
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Export all schemas for MCP tool generation
|
|
87
|
+
// ============================================================================
|
|
88
|
+
export const eventsSchemas = {
|
|
89
|
+
ActivityEventSchema,
|
|
90
|
+
ListEventsOptionsSchema,
|
|
91
|
+
};
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// Pre-computed JSON Schemas for MCP tool parameters
|
|
94
|
+
// ============================================================================
|
|
95
|
+
function extractJsonSchemaProperties(schema) {
|
|
96
|
+
const jsonSchema = zodToJsonSchema(schema, { $refStrategy: 'none' });
|
|
97
|
+
return (jsonSchema.properties || {});
|
|
98
|
+
}
|
|
99
|
+
export const eventsJsonSchemas = {
|
|
100
|
+
list: extractJsonSchemaProperties(ListEventsOptionsSchema),
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAA;AACrC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAA;AACnC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,KAAK,E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AC,MAAM,aAAa,GAAG;IAC3B,mBAAmB;IACnB,uBAAuB;CACxB,CAAA;AAED,+EAA+E;AAC/E,oDAAoD;AACpD,+EAA+E;AAE/E,SAAS,2BAA2B,CAAC,MAAe;IAClD,MAAM,UAAU,GAAG,eAAe,CAAC,MAAa,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAA4B,CAAA;IACtG,OAAO,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE,CAA4B,CAAA;AACjE,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,2BAA2B,CAAC,uBAAuB,CAAC;CAC3D,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export * from './change-proposal.js';
|
|
2
1
|
export * from './storage.js';
|
|
3
2
|
export * from './markdown-storage.js';
|
|
4
3
|
export * from './logging/index.js';
|
|
5
4
|
export * from './app-paths.js';
|
|
5
|
+
export * from './proposals.js';
|
|
6
|
+
export * from './context.js';
|
|
7
|
+
export * from './knowledge.js';
|
|
8
|
+
export * from './events.js';
|
|
6
9
|
export type * from '@lovelybunch/types';
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,mBAAmB,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export * from './change-proposal.js';
|
|
2
1
|
export * from './storage.js';
|
|
3
2
|
export * from './markdown-storage.js';
|
|
4
3
|
export * from './logging/index.js';
|
|
5
4
|
export * from './app-paths.js';
|
|
5
|
+
export * from './proposals.js';
|
|
6
|
+
export * from './context.js';
|
|
7
|
+
export * from './knowledge.js';
|
|
8
|
+
export * from './events.js';
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|