@mukulaggarwal/pacman 0.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 +39 -0
- package/dist/chunk-3QNXXON5.js +330 -0
- package/dist/chunk-3QNXXON5.js.map +1 -0
- package/dist/chunk-43PUZDIZ.js +148 -0
- package/dist/chunk-43PUZDIZ.js.map +1 -0
- package/dist/chunk-7D4SUZUM.js +38 -0
- package/dist/chunk-7D4SUZUM.js.map +1 -0
- package/dist/chunk-AYFIQNZ5.js +807 -0
- package/dist/chunk-AYFIQNZ5.js.map +1 -0
- package/dist/chunk-FH6ZHWGR.js +37 -0
- package/dist/chunk-FH6ZHWGR.js.map +1 -0
- package/dist/chunk-O6T35A4O.js +137 -0
- package/dist/chunk-O6T35A4O.js.map +1 -0
- package/dist/chunk-TRQIZP6Z.js +451 -0
- package/dist/chunk-TRQIZP6Z.js.map +1 -0
- package/dist/chunk-UWT6AFJB.js +471 -0
- package/dist/chunk-UWT6AFJB.js.map +1 -0
- package/dist/chunk-ZKKMIDRK.js +3923 -0
- package/dist/chunk-ZKKMIDRK.js.map +1 -0
- package/dist/daemon.d.ts +3 -0
- package/dist/daemon.js +141 -0
- package/dist/daemon.js.map +1 -0
- package/dist/dist-3PIJOFZ4.js +91 -0
- package/dist/dist-3PIJOFZ4.js.map +1 -0
- package/dist/dist-L76NGFFH.js +102 -0
- package/dist/dist-L76NGFFH.js.map +1 -0
- package/dist/dist-NV2YVVHI.js +178 -0
- package/dist/dist-NV2YVVHI.js.map +1 -0
- package/dist/dist-RMYCRZIU.js +41 -0
- package/dist/dist-RMYCRZIU.js.map +1 -0
- package/dist/dist-THLCZNOZ.js +14 -0
- package/dist/dist-THLCZNOZ.js.map +1 -0
- package/dist/dist-TWNHTXYH.js +95 -0
- package/dist/dist-TWNHTXYH.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +452 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-compat.d.ts +1 -0
- package/dist/mcp-compat.js +78 -0
- package/dist/mcp-compat.js.map +1 -0
- package/dist/onboarding-server.d.ts +3 -0
- package/dist/onboarding-server.js +1172 -0
- package/dist/onboarding-server.js.map +1 -0
- package/dist/provider-runtime.d.ts +11 -0
- package/dist/provider-runtime.js +10 -0
- package/dist/provider-runtime.js.map +1 -0
- package/dist/slack-listener.d.ts +49 -0
- package/dist/slack-listener.js +888 -0
- package/dist/slack-listener.js.map +1 -0
- package/dist/storage.d.ts +8 -0
- package/dist/storage.js +9 -0
- package/dist/storage.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WORKSPACE_PATHS
|
|
3
|
+
} from "./chunk-TRQIZP6Z.js";
|
|
4
|
+
|
|
5
|
+
// ../context-manager/dist/index.js
|
|
6
|
+
import * as crypto from "crypto";
|
|
7
|
+
var RAW_CONTEXT_SCAN_LIMIT = 50;
|
|
8
|
+
var RAW_CONTEXT_RESULT_LIMIT = 8;
|
|
9
|
+
var ContextManager = class {
|
|
10
|
+
constructor(storage) {
|
|
11
|
+
this.storage = storage;
|
|
12
|
+
}
|
|
13
|
+
async initWorkspace() {
|
|
14
|
+
const dirs = [
|
|
15
|
+
"profile",
|
|
16
|
+
"templates",
|
|
17
|
+
"context/canonical",
|
|
18
|
+
"context/canonical/projects",
|
|
19
|
+
"context/raw/slack",
|
|
20
|
+
"context/raw/gmail",
|
|
21
|
+
"context/raw/github",
|
|
22
|
+
"context/raw/gitlab",
|
|
23
|
+
"context/raw/gdrive",
|
|
24
|
+
"context/raw/gchat",
|
|
25
|
+
"context/derived/daily",
|
|
26
|
+
"context/derived/slack",
|
|
27
|
+
"context/derived/slack/reply-inputs",
|
|
28
|
+
"context/derived/slack/drafts",
|
|
29
|
+
"context/derived/slack/deliveries",
|
|
30
|
+
"context/derived/indexes",
|
|
31
|
+
"context/derived/suggestions",
|
|
32
|
+
"context/derived/update-proposals",
|
|
33
|
+
"context/derived/update-proposals/applied",
|
|
34
|
+
"logs"
|
|
35
|
+
];
|
|
36
|
+
for (const d of dirs) {
|
|
37
|
+
await this.storage.mkdir(d);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async writeCanonicalFiles(files) {
|
|
41
|
+
await Promise.all(
|
|
42
|
+
Object.entries(files).map(
|
|
43
|
+
([fileName, content]) => this.storage.write(`context/canonical/${fileName}`, content)
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
async readCanonical(filePath) {
|
|
48
|
+
return this.storage.read(`context/canonical/${filePath}`);
|
|
49
|
+
}
|
|
50
|
+
async writeCanonical(filePath, content) {
|
|
51
|
+
await this.storage.write(`context/canonical/${filePath}`, content);
|
|
52
|
+
}
|
|
53
|
+
async readDerived(filePath) {
|
|
54
|
+
return this.storage.read(`context/derived/${filePath}`);
|
|
55
|
+
}
|
|
56
|
+
async listProjects() {
|
|
57
|
+
const files = await this.storage.list(WORKSPACE_PATHS.context.canonical.projects);
|
|
58
|
+
return files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
|
|
59
|
+
}
|
|
60
|
+
async suggestProject(hint) {
|
|
61
|
+
const projects = await this.listProjects();
|
|
62
|
+
if (projects.length === 0) return null;
|
|
63
|
+
if (projects.length === 1) return { name: projects[0], confidence: 0.9 };
|
|
64
|
+
if (hint) {
|
|
65
|
+
const hintLower = hint.toLowerCase();
|
|
66
|
+
const exact = projects.find((p) => p.toLowerCase() === hintLower);
|
|
67
|
+
if (exact) return { name: exact, confidence: 1 };
|
|
68
|
+
const partial = projects.find((p) => p.toLowerCase().includes(hintLower));
|
|
69
|
+
if (partial) return { name: partial, confidence: 0.7 };
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const inferred = await this.storage.read(
|
|
73
|
+
WORKSPACE_PATHS.context.derived.suggestions.inferredProjects
|
|
74
|
+
);
|
|
75
|
+
const data = JSON.parse(inferred);
|
|
76
|
+
if (data.length > 0) {
|
|
77
|
+
return { name: data[0].name, confidence: data[0].score };
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
return { name: projects[0], confidence: 0.3 };
|
|
82
|
+
}
|
|
83
|
+
async getProjectContext(projectName) {
|
|
84
|
+
const canonicalFiles = [];
|
|
85
|
+
const derivedFiles = [];
|
|
86
|
+
const rawFiles = [];
|
|
87
|
+
let projectContent = "";
|
|
88
|
+
try {
|
|
89
|
+
projectContent = await this.storage.read(
|
|
90
|
+
`${WORKSPACE_PATHS.context.canonical.projects}/${projectName}.md`
|
|
91
|
+
);
|
|
92
|
+
canonicalFiles.push({
|
|
93
|
+
path: `${WORKSPACE_PATHS.context.canonical.projects}/${projectName}.md`,
|
|
94
|
+
content: projectContent,
|
|
95
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
96
|
+
});
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
for (const file of ["overview.md", "responsibilities.md", "stakeholders.md", "docs.md"]) {
|
|
100
|
+
try {
|
|
101
|
+
const content = await this.storage.read(`context/canonical/${file}`);
|
|
102
|
+
canonicalFiles.push({
|
|
103
|
+
path: `context/canonical/${file}`,
|
|
104
|
+
content,
|
|
105
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
106
|
+
});
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
112
|
+
const content = await this.storage.read(`context/derived/daily/${today}.md`);
|
|
113
|
+
derivedFiles.push({
|
|
114
|
+
path: `context/derived/daily/${today}.md`,
|
|
115
|
+
content,
|
|
116
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
117
|
+
});
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const entities = await this.storage.read(WORKSPACE_PATHS.context.derived.indexes.entities);
|
|
122
|
+
derivedFiles.push({
|
|
123
|
+
path: WORKSPACE_PATHS.context.derived.indexes.entities,
|
|
124
|
+
content: entities,
|
|
125
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
126
|
+
});
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
rawFiles.push(...await this.collectRelevantRawFiles(projectName, projectContent));
|
|
130
|
+
return {
|
|
131
|
+
name: projectName,
|
|
132
|
+
canonicalFiles,
|
|
133
|
+
derivedFiles,
|
|
134
|
+
rawFiles
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async collectRelevantRawFiles(projectName, projectContent) {
|
|
138
|
+
if (!projectName.trim()) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
const rawDirs = Object.values(WORKSPACE_PATHS.context.raw);
|
|
142
|
+
const projectPhrase = normalizeForSearch(projectName);
|
|
143
|
+
const projectTokens = extractSearchTokens(`${projectName}
|
|
144
|
+
${projectContent}`);
|
|
145
|
+
const ranked = [];
|
|
146
|
+
for (const rawDir of rawDirs) {
|
|
147
|
+
let entries = [];
|
|
148
|
+
try {
|
|
149
|
+
entries = await this.storage.list(rawDir);
|
|
150
|
+
} catch {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
for (const entry of entries.slice(0, RAW_CONTEXT_SCAN_LIMIT)) {
|
|
154
|
+
const filePath = `${rawDir}/${entry}`;
|
|
155
|
+
let content = "";
|
|
156
|
+
try {
|
|
157
|
+
content = await this.storage.read(filePath);
|
|
158
|
+
} catch {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const score = scoreRawContext(content, projectPhrase, projectTokens);
|
|
162
|
+
if (score <= 0) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
ranked.push({ path: filePath, content, score });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
ranked.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));
|
|
169
|
+
return ranked.slice(0, RAW_CONTEXT_RESULT_LIMIT).map((item) => ({
|
|
170
|
+
path: item.path,
|
|
171
|
+
content: item.content,
|
|
172
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
async proposeUpdate(proposal) {
|
|
176
|
+
const fullProposal = {
|
|
177
|
+
...proposal,
|
|
178
|
+
id: crypto.randomUUID(),
|
|
179
|
+
status: "pending",
|
|
180
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
181
|
+
};
|
|
182
|
+
await this.storage.write(
|
|
183
|
+
`${WORKSPACE_PATHS.context.derived.updateProposals}/${fullProposal.id}.json`,
|
|
184
|
+
JSON.stringify(fullProposal, null, 2)
|
|
185
|
+
);
|
|
186
|
+
return fullProposal;
|
|
187
|
+
}
|
|
188
|
+
async applyUpdate(proposalId) {
|
|
189
|
+
const proposalPath = `${WORKSPACE_PATHS.context.derived.updateProposals}/${proposalId}.json`;
|
|
190
|
+
const proposalContent = await this.storage.read(proposalPath);
|
|
191
|
+
const proposal = JSON.parse(proposalContent);
|
|
192
|
+
if (proposal.status !== "pending") {
|
|
193
|
+
throw new Error(`Proposal ${proposalId} is not pending (status: ${proposal.status})`);
|
|
194
|
+
}
|
|
195
|
+
if (proposal.section) {
|
|
196
|
+
const currentContent = await this.storage.read(proposal.targetFile);
|
|
197
|
+
const updated = this.replaceSectionContent(currentContent, proposal.section, proposal.proposedContent);
|
|
198
|
+
await this.storage.write(proposal.targetFile, updated);
|
|
199
|
+
} else {
|
|
200
|
+
await this.storage.write(proposal.targetFile, proposal.proposedContent);
|
|
201
|
+
}
|
|
202
|
+
proposal.status = "applied";
|
|
203
|
+
proposal.appliedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
204
|
+
await this.storage.write(
|
|
205
|
+
`${WORKSPACE_PATHS.context.derived.updateProposals}/applied/${proposalId}.json`,
|
|
206
|
+
JSON.stringify(proposal, null, 2)
|
|
207
|
+
);
|
|
208
|
+
await this.storage.delete(proposalPath);
|
|
209
|
+
const logEntry = `[${proposal.appliedAt}] Applied update ${proposalId} to ${proposal.targetFile}: ${proposal.reason}
|
|
210
|
+
`;
|
|
211
|
+
await this.storage.append(WORKSPACE_PATHS.logs.audit, logEntry);
|
|
212
|
+
return proposal;
|
|
213
|
+
}
|
|
214
|
+
async appendNote(projectName, note) {
|
|
215
|
+
const filePath = `${WORKSPACE_PATHS.context.canonical.projects}/${projectName}.md`;
|
|
216
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
217
|
+
const noteEntry = `
|
|
218
|
+
## Note - ${timestamp}
|
|
219
|
+
|
|
220
|
+
${note}
|
|
221
|
+
`;
|
|
222
|
+
try {
|
|
223
|
+
await this.storage.append(filePath, noteEntry);
|
|
224
|
+
} catch {
|
|
225
|
+
await this.storage.write(filePath, `# ${projectName}
|
|
226
|
+
${noteEntry}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async getDailySummary(date) {
|
|
230
|
+
const targetDate = date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
231
|
+
try {
|
|
232
|
+
return await this.storage.read(`context/derived/daily/${targetDate}.md`);
|
|
233
|
+
} catch {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async listRecentUpdates(limit = 10) {
|
|
238
|
+
const proposals = [];
|
|
239
|
+
try {
|
|
240
|
+
const files = await this.storage.list(WORKSPACE_PATHS.context.derived.updateProposals);
|
|
241
|
+
for (const file of files.filter((f) => f.endsWith(".json"))) {
|
|
242
|
+
try {
|
|
243
|
+
const content = await this.storage.read(
|
|
244
|
+
`${WORKSPACE_PATHS.context.derived.updateProposals}/${file}`
|
|
245
|
+
);
|
|
246
|
+
proposals.push(JSON.parse(content));
|
|
247
|
+
} catch {
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
} catch {
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
const files = await this.storage.list(`${WORKSPACE_PATHS.context.derived.updateProposals}/applied`);
|
|
254
|
+
for (const file of files.filter((f) => f.endsWith(".json"))) {
|
|
255
|
+
try {
|
|
256
|
+
const content = await this.storage.read(
|
|
257
|
+
`${WORKSPACE_PATHS.context.derived.updateProposals}/applied/${file}`
|
|
258
|
+
);
|
|
259
|
+
proposals.push(JSON.parse(content));
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
}
|
|
265
|
+
return proposals.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()).slice(0, limit);
|
|
266
|
+
}
|
|
267
|
+
async forceUpdate(targetFile, content, reason, section) {
|
|
268
|
+
if (section) {
|
|
269
|
+
try {
|
|
270
|
+
const currentContent = await this.storage.read(targetFile);
|
|
271
|
+
const updated = this.replaceSectionContent(currentContent, section, content);
|
|
272
|
+
await this.storage.write(targetFile, updated);
|
|
273
|
+
} catch {
|
|
274
|
+
const newContent = `# ${targetFile.split("/").pop()?.replace(".md", "") ?? "Untitled"}
|
|
275
|
+
|
|
276
|
+
## ${section}
|
|
277
|
+
|
|
278
|
+
${content}
|
|
279
|
+
`;
|
|
280
|
+
await this.storage.write(targetFile, newContent);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
await this.storage.write(targetFile, content);
|
|
284
|
+
}
|
|
285
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
286
|
+
const logEntry = `[${timestamp}] [FORCE] Updated ${targetFile}${section ? ` > ${section}` : ""}: ${reason}
|
|
287
|
+
`;
|
|
288
|
+
await this.storage.append(WORKSPACE_PATHS.logs.audit, logEntry);
|
|
289
|
+
}
|
|
290
|
+
async applyAllPending() {
|
|
291
|
+
const appliedIds = [];
|
|
292
|
+
try {
|
|
293
|
+
const files = await this.storage.list(WORKSPACE_PATHS.context.derived.updateProposals);
|
|
294
|
+
const proposalFiles = files.filter((f) => f.endsWith(".json"));
|
|
295
|
+
for (const file of proposalFiles) {
|
|
296
|
+
try {
|
|
297
|
+
const content = await this.storage.read(
|
|
298
|
+
`${WORKSPACE_PATHS.context.derived.updateProposals}/${file}`
|
|
299
|
+
);
|
|
300
|
+
const proposal = JSON.parse(content);
|
|
301
|
+
if (proposal.status === "pending") {
|
|
302
|
+
await this.applyUpdate(proposal.id);
|
|
303
|
+
appliedIds.push(proposal.id);
|
|
304
|
+
}
|
|
305
|
+
} catch {
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
310
|
+
return appliedIds;
|
|
311
|
+
}
|
|
312
|
+
async readFile(filePath) {
|
|
313
|
+
return this.storage.read(filePath);
|
|
314
|
+
}
|
|
315
|
+
async readSection(filePath, sectionName) {
|
|
316
|
+
try {
|
|
317
|
+
const content = await this.storage.read(filePath);
|
|
318
|
+
return this.extractSection(content, sectionName);
|
|
319
|
+
} catch {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
extractSection(content, sectionName) {
|
|
324
|
+
const lines = content.split("\n");
|
|
325
|
+
let inSection = false;
|
|
326
|
+
let sectionLevel = 0;
|
|
327
|
+
const sectionLines = [];
|
|
328
|
+
for (const line of lines) {
|
|
329
|
+
const headingMatch = line.match(/^(#+)\s+(.+)/);
|
|
330
|
+
if (headingMatch) {
|
|
331
|
+
const level = headingMatch[1].length;
|
|
332
|
+
const heading = headingMatch[2];
|
|
333
|
+
if (heading.toLowerCase() === sectionName.toLowerCase()) {
|
|
334
|
+
inSection = true;
|
|
335
|
+
sectionLevel = level;
|
|
336
|
+
sectionLines.push(line);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (inSection && level <= sectionLevel) {
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (inSection) {
|
|
344
|
+
sectionLines.push(line);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return sectionLines.length > 0 ? sectionLines.join("\n").trim() : null;
|
|
348
|
+
}
|
|
349
|
+
replaceSectionContent(content, sectionName, newContent) {
|
|
350
|
+
const lines = content.split("\n");
|
|
351
|
+
const result = [];
|
|
352
|
+
let inSection = false;
|
|
353
|
+
let sectionLevel = 0;
|
|
354
|
+
let replaced = false;
|
|
355
|
+
for (const line of lines) {
|
|
356
|
+
const headingMatch = line.match(/^(#+)\s+(.+)/);
|
|
357
|
+
if (headingMatch) {
|
|
358
|
+
const level = headingMatch[1].length;
|
|
359
|
+
const heading = headingMatch[2];
|
|
360
|
+
if (heading.toLowerCase() === sectionName.toLowerCase()) {
|
|
361
|
+
inSection = true;
|
|
362
|
+
sectionLevel = level;
|
|
363
|
+
result.push(line);
|
|
364
|
+
result.push("");
|
|
365
|
+
result.push(newContent);
|
|
366
|
+
replaced = true;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (inSection && level <= sectionLevel) {
|
|
370
|
+
inSection = false;
|
|
371
|
+
result.push("");
|
|
372
|
+
result.push(line);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (!inSection) {
|
|
377
|
+
result.push(line);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (!replaced) {
|
|
381
|
+
result.push("");
|
|
382
|
+
result.push(`## ${sectionName}`);
|
|
383
|
+
result.push("");
|
|
384
|
+
result.push(newContent);
|
|
385
|
+
}
|
|
386
|
+
return result.join("\n");
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
function normalizeForSearch(value) {
|
|
390
|
+
return value.toLowerCase().replace(/[_-]+/g, " ").replace(/[^a-z0-9\s]+/g, " ").replace(/\s+/g, " ").trim();
|
|
391
|
+
}
|
|
392
|
+
function extractSearchTokens(value) {
|
|
393
|
+
const stopwords = /* @__PURE__ */ new Set([
|
|
394
|
+
"about",
|
|
395
|
+
"after",
|
|
396
|
+
"again",
|
|
397
|
+
"also",
|
|
398
|
+
"and",
|
|
399
|
+
"any",
|
|
400
|
+
"are",
|
|
401
|
+
"back",
|
|
402
|
+
"been",
|
|
403
|
+
"before",
|
|
404
|
+
"being",
|
|
405
|
+
"between",
|
|
406
|
+
"both",
|
|
407
|
+
"but",
|
|
408
|
+
"can",
|
|
409
|
+
"could",
|
|
410
|
+
"does",
|
|
411
|
+
"from",
|
|
412
|
+
"have",
|
|
413
|
+
"into",
|
|
414
|
+
"just",
|
|
415
|
+
"make",
|
|
416
|
+
"more",
|
|
417
|
+
"most",
|
|
418
|
+
"need",
|
|
419
|
+
"only",
|
|
420
|
+
"other",
|
|
421
|
+
"over",
|
|
422
|
+
"same",
|
|
423
|
+
"should",
|
|
424
|
+
"than",
|
|
425
|
+
"that",
|
|
426
|
+
"their",
|
|
427
|
+
"them",
|
|
428
|
+
"there",
|
|
429
|
+
"these",
|
|
430
|
+
"this",
|
|
431
|
+
"those",
|
|
432
|
+
"through",
|
|
433
|
+
"under",
|
|
434
|
+
"using",
|
|
435
|
+
"want",
|
|
436
|
+
"what",
|
|
437
|
+
"when",
|
|
438
|
+
"which",
|
|
439
|
+
"while",
|
|
440
|
+
"with",
|
|
441
|
+
"would",
|
|
442
|
+
"your"
|
|
443
|
+
]);
|
|
444
|
+
return [...new Set(
|
|
445
|
+
normalizeForSearch(value).split(" ").filter((token) => token.length > 2 && !stopwords.has(token))
|
|
446
|
+
)];
|
|
447
|
+
}
|
|
448
|
+
function scoreRawContext(content, projectPhrase, projectTokens) {
|
|
449
|
+
const normalized = normalizeForSearch(content);
|
|
450
|
+
if (!normalized) {
|
|
451
|
+
return 0;
|
|
452
|
+
}
|
|
453
|
+
let score = 0;
|
|
454
|
+
if (projectPhrase && normalized.includes(projectPhrase)) {
|
|
455
|
+
score += 100;
|
|
456
|
+
}
|
|
457
|
+
for (const token of projectTokens) {
|
|
458
|
+
if (normalized.includes(token)) {
|
|
459
|
+
score += token.length >= 6 ? 4 : 2;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return score;
|
|
463
|
+
}
|
|
464
|
+
function createContextManager(storage) {
|
|
465
|
+
return new ContextManager(storage);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export {
|
|
469
|
+
createContextManager
|
|
470
|
+
};
|
|
471
|
+
//# sourceMappingURL=chunk-UWT6AFJB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../context-manager/dist/index.js"],"sourcesContent":["// src/index.ts\nimport * as crypto from \"crypto\";\nimport { WORKSPACE_PATHS as PATHS } from \"@personal-assistant/core-types\";\nvar RAW_CONTEXT_SCAN_LIMIT = 50;\nvar RAW_CONTEXT_RESULT_LIMIT = 8;\nvar ContextManager = class {\n constructor(storage) {\n this.storage = storage;\n }\n async initWorkspace() {\n const dirs = [\n \"profile\",\n \"templates\",\n \"context/canonical\",\n \"context/canonical/projects\",\n \"context/raw/slack\",\n \"context/raw/gmail\",\n \"context/raw/github\",\n \"context/raw/gitlab\",\n \"context/raw/gdrive\",\n \"context/raw/gchat\",\n \"context/derived/daily\",\n \"context/derived/slack\",\n \"context/derived/slack/reply-inputs\",\n \"context/derived/slack/drafts\",\n \"context/derived/slack/deliveries\",\n \"context/derived/indexes\",\n \"context/derived/suggestions\",\n \"context/derived/update-proposals\",\n \"context/derived/update-proposals/applied\",\n \"logs\"\n ];\n for (const d of dirs) {\n await this.storage.mkdir(d);\n }\n }\n async writeCanonicalFiles(files) {\n await Promise.all(\n Object.entries(files).map(\n ([fileName, content]) => this.storage.write(`context/canonical/${fileName}`, content)\n )\n );\n }\n async readCanonical(filePath) {\n return this.storage.read(`context/canonical/${filePath}`);\n }\n async writeCanonical(filePath, content) {\n await this.storage.write(`context/canonical/${filePath}`, content);\n }\n async readDerived(filePath) {\n return this.storage.read(`context/derived/${filePath}`);\n }\n async listProjects() {\n const files = await this.storage.list(PATHS.context.canonical.projects);\n return files.filter((f) => f.endsWith(\".md\")).map((f) => f.replace(\".md\", \"\"));\n }\n async suggestProject(hint) {\n const projects = await this.listProjects();\n if (projects.length === 0) return null;\n if (projects.length === 1) return { name: projects[0], confidence: 0.9 };\n if (hint) {\n const hintLower = hint.toLowerCase();\n const exact = projects.find((p) => p.toLowerCase() === hintLower);\n if (exact) return { name: exact, confidence: 1 };\n const partial = projects.find((p) => p.toLowerCase().includes(hintLower));\n if (partial) return { name: partial, confidence: 0.7 };\n }\n try {\n const inferred = await this.storage.read(\n PATHS.context.derived.suggestions.inferredProjects\n );\n const data = JSON.parse(inferred);\n if (data.length > 0) {\n return { name: data[0].name, confidence: data[0].score };\n }\n } catch {\n }\n return { name: projects[0], confidence: 0.3 };\n }\n async getProjectContext(projectName) {\n const canonicalFiles = [];\n const derivedFiles = [];\n const rawFiles = [];\n let projectContent = \"\";\n try {\n projectContent = await this.storage.read(\n `${PATHS.context.canonical.projects}/${projectName}.md`\n );\n canonicalFiles.push({\n path: `${PATHS.context.canonical.projects}/${projectName}.md`,\n content: projectContent,\n lastModified: (/* @__PURE__ */ new Date()).toISOString()\n });\n } catch {\n }\n for (const file of [\"overview.md\", \"responsibilities.md\", \"stakeholders.md\", \"docs.md\"]) {\n try {\n const content = await this.storage.read(`context/canonical/${file}`);\n canonicalFiles.push({\n path: `context/canonical/${file}`,\n content,\n lastModified: (/* @__PURE__ */ new Date()).toISOString()\n });\n } catch {\n }\n }\n try {\n const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);\n const content = await this.storage.read(`context/derived/daily/${today}.md`);\n derivedFiles.push({\n path: `context/derived/daily/${today}.md`,\n content,\n lastModified: (/* @__PURE__ */ new Date()).toISOString()\n });\n } catch {\n }\n try {\n const entities = await this.storage.read(PATHS.context.derived.indexes.entities);\n derivedFiles.push({\n path: PATHS.context.derived.indexes.entities,\n content: entities,\n lastModified: (/* @__PURE__ */ new Date()).toISOString()\n });\n } catch {\n }\n rawFiles.push(...await this.collectRelevantRawFiles(projectName, projectContent));\n return {\n name: projectName,\n canonicalFiles,\n derivedFiles,\n rawFiles\n };\n }\n async collectRelevantRawFiles(projectName, projectContent) {\n if (!projectName.trim()) {\n return [];\n }\n const rawDirs = Object.values(PATHS.context.raw);\n const projectPhrase = normalizeForSearch(projectName);\n const projectTokens = extractSearchTokens(`${projectName}\n${projectContent}`);\n const ranked = [];\n for (const rawDir of rawDirs) {\n let entries = [];\n try {\n entries = await this.storage.list(rawDir);\n } catch {\n continue;\n }\n for (const entry of entries.slice(0, RAW_CONTEXT_SCAN_LIMIT)) {\n const filePath = `${rawDir}/${entry}`;\n let content = \"\";\n try {\n content = await this.storage.read(filePath);\n } catch {\n continue;\n }\n const score = scoreRawContext(content, projectPhrase, projectTokens);\n if (score <= 0) {\n continue;\n }\n ranked.push({ path: filePath, content, score });\n }\n }\n ranked.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));\n return ranked.slice(0, RAW_CONTEXT_RESULT_LIMIT).map((item) => ({\n path: item.path,\n content: item.content,\n lastModified: (/* @__PURE__ */ new Date()).toISOString()\n }));\n }\n async proposeUpdate(proposal) {\n const fullProposal = {\n ...proposal,\n id: crypto.randomUUID(),\n status: \"pending\",\n createdAt: (/* @__PURE__ */ new Date()).toISOString()\n };\n await this.storage.write(\n `${PATHS.context.derived.updateProposals}/${fullProposal.id}.json`,\n JSON.stringify(fullProposal, null, 2)\n );\n return fullProposal;\n }\n async applyUpdate(proposalId) {\n const proposalPath = `${PATHS.context.derived.updateProposals}/${proposalId}.json`;\n const proposalContent = await this.storage.read(proposalPath);\n const proposal = JSON.parse(proposalContent);\n if (proposal.status !== \"pending\") {\n throw new Error(`Proposal ${proposalId} is not pending (status: ${proposal.status})`);\n }\n if (proposal.section) {\n const currentContent = await this.storage.read(proposal.targetFile);\n const updated = this.replaceSectionContent(currentContent, proposal.section, proposal.proposedContent);\n await this.storage.write(proposal.targetFile, updated);\n } else {\n await this.storage.write(proposal.targetFile, proposal.proposedContent);\n }\n proposal.status = \"applied\";\n proposal.appliedAt = (/* @__PURE__ */ new Date()).toISOString();\n await this.storage.write(\n `${PATHS.context.derived.updateProposals}/applied/${proposalId}.json`,\n JSON.stringify(proposal, null, 2)\n );\n await this.storage.delete(proposalPath);\n const logEntry = `[${proposal.appliedAt}] Applied update ${proposalId} to ${proposal.targetFile}: ${proposal.reason}\n`;\n await this.storage.append(PATHS.logs.audit, logEntry);\n return proposal;\n }\n async appendNote(projectName, note) {\n const filePath = `${PATHS.context.canonical.projects}/${projectName}.md`;\n const timestamp = (/* @__PURE__ */ new Date()).toISOString();\n const noteEntry = `\n## Note - ${timestamp}\n\n${note}\n`;\n try {\n await this.storage.append(filePath, noteEntry);\n } catch {\n await this.storage.write(filePath, `# ${projectName}\n${noteEntry}`);\n }\n }\n async getDailySummary(date) {\n const targetDate = date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);\n try {\n return await this.storage.read(`context/derived/daily/${targetDate}.md`);\n } catch {\n return null;\n }\n }\n async listRecentUpdates(limit = 10) {\n const proposals = [];\n try {\n const files = await this.storage.list(PATHS.context.derived.updateProposals);\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\n try {\n const content = await this.storage.read(\n `${PATHS.context.derived.updateProposals}/${file}`\n );\n proposals.push(JSON.parse(content));\n } catch {\n }\n }\n } catch {\n }\n try {\n const files = await this.storage.list(`${PATHS.context.derived.updateProposals}/applied`);\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\n try {\n const content = await this.storage.read(\n `${PATHS.context.derived.updateProposals}/applied/${file}`\n );\n proposals.push(JSON.parse(content));\n } catch {\n }\n }\n } catch {\n }\n return proposals.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()).slice(0, limit);\n }\n async forceUpdate(targetFile, content, reason, section) {\n if (section) {\n try {\n const currentContent = await this.storage.read(targetFile);\n const updated = this.replaceSectionContent(currentContent, section, content);\n await this.storage.write(targetFile, updated);\n } catch {\n const newContent = `# ${targetFile.split(\"/\").pop()?.replace(\".md\", \"\") ?? \"Untitled\"}\n\n## ${section}\n\n${content}\n`;\n await this.storage.write(targetFile, newContent);\n }\n } else {\n await this.storage.write(targetFile, content);\n }\n const timestamp = (/* @__PURE__ */ new Date()).toISOString();\n const logEntry = `[${timestamp}] [FORCE] Updated ${targetFile}${section ? ` > ${section}` : \"\"}: ${reason}\n`;\n await this.storage.append(PATHS.logs.audit, logEntry);\n }\n async applyAllPending() {\n const appliedIds = [];\n try {\n const files = await this.storage.list(PATHS.context.derived.updateProposals);\n const proposalFiles = files.filter((f) => f.endsWith(\".json\"));\n for (const file of proposalFiles) {\n try {\n const content = await this.storage.read(\n `${PATHS.context.derived.updateProposals}/${file}`\n );\n const proposal = JSON.parse(content);\n if (proposal.status === \"pending\") {\n await this.applyUpdate(proposal.id);\n appliedIds.push(proposal.id);\n }\n } catch {\n }\n }\n } catch {\n }\n return appliedIds;\n }\n async readFile(filePath) {\n return this.storage.read(filePath);\n }\n async readSection(filePath, sectionName) {\n try {\n const content = await this.storage.read(filePath);\n return this.extractSection(content, sectionName);\n } catch {\n return null;\n }\n }\n extractSection(content, sectionName) {\n const lines = content.split(\"\\n\");\n let inSection = false;\n let sectionLevel = 0;\n const sectionLines = [];\n for (const line of lines) {\n const headingMatch = line.match(/^(#+)\\s+(.+)/);\n if (headingMatch) {\n const level = headingMatch[1].length;\n const heading = headingMatch[2];\n if (heading.toLowerCase() === sectionName.toLowerCase()) {\n inSection = true;\n sectionLevel = level;\n sectionLines.push(line);\n continue;\n }\n if (inSection && level <= sectionLevel) {\n break;\n }\n }\n if (inSection) {\n sectionLines.push(line);\n }\n }\n return sectionLines.length > 0 ? sectionLines.join(\"\\n\").trim() : null;\n }\n replaceSectionContent(content, sectionName, newContent) {\n const lines = content.split(\"\\n\");\n const result = [];\n let inSection = false;\n let sectionLevel = 0;\n let replaced = false;\n for (const line of lines) {\n const headingMatch = line.match(/^(#+)\\s+(.+)/);\n if (headingMatch) {\n const level = headingMatch[1].length;\n const heading = headingMatch[2];\n if (heading.toLowerCase() === sectionName.toLowerCase()) {\n inSection = true;\n sectionLevel = level;\n result.push(line);\n result.push(\"\");\n result.push(newContent);\n replaced = true;\n continue;\n }\n if (inSection && level <= sectionLevel) {\n inSection = false;\n result.push(\"\");\n result.push(line);\n continue;\n }\n }\n if (!inSection) {\n result.push(line);\n }\n }\n if (!replaced) {\n result.push(\"\");\n result.push(`## ${sectionName}`);\n result.push(\"\");\n result.push(newContent);\n }\n return result.join(\"\\n\");\n }\n};\nfunction normalizeForSearch(value) {\n return value.toLowerCase().replace(/[_-]+/g, \" \").replace(/[^a-z0-9\\s]+/g, \" \").replace(/\\s+/g, \" \").trim();\n}\nfunction extractSearchTokens(value) {\n const stopwords = /* @__PURE__ */ new Set([\n \"about\",\n \"after\",\n \"again\",\n \"also\",\n \"and\",\n \"any\",\n \"are\",\n \"back\",\n \"been\",\n \"before\",\n \"being\",\n \"between\",\n \"both\",\n \"but\",\n \"can\",\n \"could\",\n \"does\",\n \"from\",\n \"have\",\n \"into\",\n \"just\",\n \"make\",\n \"more\",\n \"most\",\n \"need\",\n \"only\",\n \"other\",\n \"over\",\n \"same\",\n \"should\",\n \"than\",\n \"that\",\n \"their\",\n \"them\",\n \"there\",\n \"these\",\n \"this\",\n \"those\",\n \"through\",\n \"under\",\n \"using\",\n \"want\",\n \"what\",\n \"when\",\n \"which\",\n \"while\",\n \"with\",\n \"would\",\n \"your\"\n ]);\n return [...new Set(\n normalizeForSearch(value).split(\" \").filter((token) => token.length > 2 && !stopwords.has(token))\n )];\n}\nfunction scoreRawContext(content, projectPhrase, projectTokens) {\n const normalized = normalizeForSearch(content);\n if (!normalized) {\n return 0;\n }\n let score = 0;\n if (projectPhrase && normalized.includes(projectPhrase)) {\n score += 100;\n }\n for (const token of projectTokens) {\n if (normalized.includes(token)) {\n score += token.length >= 6 ? 4 : 2;\n }\n }\n return score;\n}\nfunction createContextManager(storage) {\n return new ContextManager(storage);\n}\nexport {\n ContextManager,\n createContextManager\n};\n"],"mappings":";;;;;AACA,YAAY,YAAY;AAExB,IAAI,yBAAyB;AAC7B,IAAI,2BAA2B;AAC/B,IAAI,iBAAiB,MAAM;AAAA,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