@contractspec/module.ai-chat 4.3.5 → 4.3.7
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 +62 -370
- package/dist/adapters/ai-sdk-bundle-adapter.d.ts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/browser/context/index.js +93 -93
- package/dist/browser/core/index.js +308 -307
- package/dist/browser/index.js +3803 -3801
- package/dist/browser/presentation/components/index.js +2617 -2618
- package/dist/browser/presentation/hooks/index.js +476 -476
- package/dist/browser/presentation/index.js +2474 -2475
- package/dist/browser/providers/index.js +7 -7
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +93 -93
- package/dist/core/agent-tools-adapter.d.ts +1 -1
- package/dist/core/chat-service.d.ts +4 -4
- package/dist/core/create-chat-route.d.ts +1 -1
- package/dist/core/create-completion-route.d.ts +15 -0
- package/dist/core/export-formatters.d.ts +1 -1
- package/dist/core/index.d.ts +6 -6
- package/dist/core/index.js +308 -307
- package/dist/core/local-storage-conversation-store.d.ts +1 -1
- package/dist/core/surface-planner-tools.d.ts +2 -2
- package/dist/core/workflow-tools.d.ts +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +3803 -3801
- package/dist/node/context/index.js +93 -93
- package/dist/node/core/index.js +308 -307
- package/dist/node/index.js +3803 -3801
- package/dist/node/presentation/components/index.js +2617 -2618
- package/dist/node/presentation/hooks/index.js +476 -476
- package/dist/node/presentation/index.js +2474 -2475
- package/dist/node/providers/index.js +7 -7
- package/dist/presentation/components/ChainOfThought.d.ts +1 -1
- package/dist/presentation/components/ChatExportToolbar.d.ts +1 -1
- package/dist/presentation/components/ChatSidebar.d.ts +1 -1
- package/dist/presentation/components/ChatWithExport.d.ts +1 -1
- package/dist/presentation/components/index.d.ts +11 -11
- package/dist/presentation/components/index.js +2617 -2618
- package/dist/presentation/hooks/index.d.ts +4 -4
- package/dist/presentation/hooks/index.js +476 -476
- package/dist/presentation/hooks/useChat.d.ts +6 -6
- package/dist/presentation/hooks/useConversations.d.ts +1 -1
- package/dist/presentation/hooks/useProviders.d.ts +1 -1
- package/dist/presentation/index.js +2474 -2475
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +7 -7
- package/package.json +15 -15
|
@@ -1,99 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
-
// src/context/workspace-context.ts
|
|
5
|
-
class WorkspaceContext {
|
|
6
|
-
workspacePath;
|
|
7
|
-
allowWrites;
|
|
8
|
-
specs = [];
|
|
9
|
-
files = [];
|
|
10
|
-
initialized = false;
|
|
11
|
-
constructor(config) {
|
|
12
|
-
this.workspacePath = config.workspacePath;
|
|
13
|
-
this.allowWrites = config.allowWrites ?? false;
|
|
14
|
-
}
|
|
15
|
-
async initialize() {
|
|
16
|
-
if (this.initialized)
|
|
17
|
-
return;
|
|
18
|
-
this.initialized = true;
|
|
19
|
-
}
|
|
20
|
-
getSpecs() {
|
|
21
|
-
return this.specs;
|
|
22
|
-
}
|
|
23
|
-
getFiles() {
|
|
24
|
-
return this.files;
|
|
25
|
-
}
|
|
26
|
-
addSpecs(specs) {
|
|
27
|
-
this.specs.push(...specs);
|
|
28
|
-
}
|
|
29
|
-
addFiles(files) {
|
|
30
|
-
this.files.push(...files);
|
|
31
|
-
}
|
|
32
|
-
getSummary() {
|
|
33
|
-
const commands = this.specs.filter((s) => s.type === "command").length;
|
|
34
|
-
const queries = this.specs.filter((s) => s.type === "query").length;
|
|
35
|
-
const events = this.specs.filter((s) => s.type === "event").length;
|
|
36
|
-
const presentations = this.specs.filter((s) => s.type === "presentation").length;
|
|
37
|
-
const tsFiles = this.files.filter((f) => f.extension === ".ts").length;
|
|
38
|
-
const specFiles = this.files.filter((f) => f.isSpec).length;
|
|
39
|
-
return {
|
|
40
|
-
name: this.workspacePath.split("/").pop() ?? "workspace",
|
|
41
|
-
path: this.workspacePath,
|
|
42
|
-
specs: {
|
|
43
|
-
total: this.specs.length,
|
|
44
|
-
commands,
|
|
45
|
-
queries,
|
|
46
|
-
events,
|
|
47
|
-
presentations
|
|
48
|
-
},
|
|
49
|
-
files: {
|
|
50
|
-
total: this.files.length,
|
|
51
|
-
typescript: tsFiles,
|
|
52
|
-
specFiles
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
getContextSummary() {
|
|
57
|
-
const summary = this.getSummary();
|
|
58
|
-
const parts = [
|
|
59
|
-
`Workspace: ${summary.name}`,
|
|
60
|
-
`Path: ${summary.path}`,
|
|
61
|
-
"",
|
|
62
|
-
"### Specs",
|
|
63
|
-
`- Commands: ${summary.specs.commands}`,
|
|
64
|
-
`- Queries: ${summary.specs.queries}`,
|
|
65
|
-
`- Events: ${summary.specs.events}`,
|
|
66
|
-
`- Presentations: ${summary.specs.presentations}`
|
|
67
|
-
];
|
|
68
|
-
if (this.specs.length > 0) {
|
|
69
|
-
parts.push("", "### Available Specs");
|
|
70
|
-
for (const spec of this.specs.slice(0, 20)) {
|
|
71
|
-
parts.push(`- ${spec.name} (${spec.type})`);
|
|
72
|
-
}
|
|
73
|
-
if (this.specs.length > 20) {
|
|
74
|
-
parts.push(`- ... and ${this.specs.length - 20} more`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return parts.join(`
|
|
78
|
-
`);
|
|
79
|
-
}
|
|
80
|
-
findSpecs(query) {
|
|
81
|
-
const lowerQuery = query.toLowerCase();
|
|
82
|
-
return this.specs.filter((s) => s.name.toLowerCase().includes(lowerQuery) || s.description?.toLowerCase().includes(lowerQuery) || s.tags?.some((t) => t.toLowerCase().includes(lowerQuery)));
|
|
83
|
-
}
|
|
84
|
-
findFiles(query) {
|
|
85
|
-
const lowerQuery = query.toLowerCase();
|
|
86
|
-
return this.files.filter((f) => f.path.toLowerCase().includes(lowerQuery) || f.name.toLowerCase().includes(lowerQuery));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function createWorkspaceContext(path, options) {
|
|
90
|
-
const context = new WorkspaceContext({
|
|
91
|
-
workspacePath: path,
|
|
92
|
-
...options
|
|
93
|
-
});
|
|
94
|
-
await context.initialize();
|
|
95
|
-
return context;
|
|
96
|
-
}
|
|
97
4
|
// src/context/context-builder.ts
|
|
98
5
|
function estimateTokens(text) {
|
|
99
6
|
return Math.ceil(text.length / 4);
|
|
@@ -400,6 +307,99 @@ function createNodeFileOperations(workspacePath, allowWrites = false) {
|
|
|
400
307
|
};
|
|
401
308
|
return new FileOperations(fs, workspacePath, allowWrites);
|
|
402
309
|
}
|
|
310
|
+
// src/context/workspace-context.ts
|
|
311
|
+
class WorkspaceContext {
|
|
312
|
+
workspacePath;
|
|
313
|
+
allowWrites;
|
|
314
|
+
specs = [];
|
|
315
|
+
files = [];
|
|
316
|
+
initialized = false;
|
|
317
|
+
constructor(config) {
|
|
318
|
+
this.workspacePath = config.workspacePath;
|
|
319
|
+
this.allowWrites = config.allowWrites ?? false;
|
|
320
|
+
}
|
|
321
|
+
async initialize() {
|
|
322
|
+
if (this.initialized)
|
|
323
|
+
return;
|
|
324
|
+
this.initialized = true;
|
|
325
|
+
}
|
|
326
|
+
getSpecs() {
|
|
327
|
+
return this.specs;
|
|
328
|
+
}
|
|
329
|
+
getFiles() {
|
|
330
|
+
return this.files;
|
|
331
|
+
}
|
|
332
|
+
addSpecs(specs) {
|
|
333
|
+
this.specs.push(...specs);
|
|
334
|
+
}
|
|
335
|
+
addFiles(files) {
|
|
336
|
+
this.files.push(...files);
|
|
337
|
+
}
|
|
338
|
+
getSummary() {
|
|
339
|
+
const commands = this.specs.filter((s) => s.type === "command").length;
|
|
340
|
+
const queries = this.specs.filter((s) => s.type === "query").length;
|
|
341
|
+
const events = this.specs.filter((s) => s.type === "event").length;
|
|
342
|
+
const presentations = this.specs.filter((s) => s.type === "presentation").length;
|
|
343
|
+
const tsFiles = this.files.filter((f) => f.extension === ".ts").length;
|
|
344
|
+
const specFiles = this.files.filter((f) => f.isSpec).length;
|
|
345
|
+
return {
|
|
346
|
+
name: this.workspacePath.split("/").pop() ?? "workspace",
|
|
347
|
+
path: this.workspacePath,
|
|
348
|
+
specs: {
|
|
349
|
+
total: this.specs.length,
|
|
350
|
+
commands,
|
|
351
|
+
queries,
|
|
352
|
+
events,
|
|
353
|
+
presentations
|
|
354
|
+
},
|
|
355
|
+
files: {
|
|
356
|
+
total: this.files.length,
|
|
357
|
+
typescript: tsFiles,
|
|
358
|
+
specFiles
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
getContextSummary() {
|
|
363
|
+
const summary = this.getSummary();
|
|
364
|
+
const parts = [
|
|
365
|
+
`Workspace: ${summary.name}`,
|
|
366
|
+
`Path: ${summary.path}`,
|
|
367
|
+
"",
|
|
368
|
+
"### Specs",
|
|
369
|
+
`- Commands: ${summary.specs.commands}`,
|
|
370
|
+
`- Queries: ${summary.specs.queries}`,
|
|
371
|
+
`- Events: ${summary.specs.events}`,
|
|
372
|
+
`- Presentations: ${summary.specs.presentations}`
|
|
373
|
+
];
|
|
374
|
+
if (this.specs.length > 0) {
|
|
375
|
+
parts.push("", "### Available Specs");
|
|
376
|
+
for (const spec of this.specs.slice(0, 20)) {
|
|
377
|
+
parts.push(`- ${spec.name} (${spec.type})`);
|
|
378
|
+
}
|
|
379
|
+
if (this.specs.length > 20) {
|
|
380
|
+
parts.push(`- ... and ${this.specs.length - 20} more`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return parts.join(`
|
|
384
|
+
`);
|
|
385
|
+
}
|
|
386
|
+
findSpecs(query) {
|
|
387
|
+
const lowerQuery = query.toLowerCase();
|
|
388
|
+
return this.specs.filter((s) => s.name.toLowerCase().includes(lowerQuery) || s.description?.toLowerCase().includes(lowerQuery) || s.tags?.some((t) => t.toLowerCase().includes(lowerQuery)));
|
|
389
|
+
}
|
|
390
|
+
findFiles(query) {
|
|
391
|
+
const lowerQuery = query.toLowerCase();
|
|
392
|
+
return this.files.filter((f) => f.path.toLowerCase().includes(lowerQuery) || f.name.toLowerCase().includes(lowerQuery));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
async function createWorkspaceContext(path, options) {
|
|
396
|
+
const context = new WorkspaceContext({
|
|
397
|
+
workspacePath: path,
|
|
398
|
+
...options
|
|
399
|
+
});
|
|
400
|
+
await context.initialize();
|
|
401
|
+
return context;
|
|
402
|
+
}
|
|
403
403
|
export {
|
|
404
404
|
createWorkspaceContext,
|
|
405
405
|
createNodeFileOperations,
|