@contractspec/example.product-intent 3.7.5 → 3.7.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.
@@ -12,13 +12,13 @@ export const DEFAULT_TRANSCRIPT_DIRS = ['interviews', 'tickets', 'public'];
12
12
  export const DEFAULT_CHUNK_SIZE = 800;
13
13
 
14
14
  export interface EvidenceLoadOptions {
15
- evidenceRoot?: string;
16
- transcriptDirs?: string[];
17
- chunkSize?: number;
15
+ evidenceRoot?: string;
16
+ transcriptDirs?: string[];
17
+ chunkSize?: number;
18
18
  }
19
19
 
20
20
  export interface EvidenceLoadWithSignalsOptions extends EvidenceLoadOptions {
21
- posthog?: PosthogEvidenceOptions;
21
+ posthog?: PosthogEvidenceOptions;
22
22
  }
23
23
 
24
24
  /**
@@ -26,33 +26,33 @@ export interface EvidenceLoadWithSignalsOptions extends EvidenceLoadOptions {
26
26
  * files include a YAML header delimited by triple dashes.
27
27
  */
28
28
  function stripYamlFrontMatter(contents: string): string {
29
- const start = contents.indexOf('---');
30
- if (start === -1) return contents;
31
- const end = contents.indexOf('---', start + 3);
32
- if (end === -1) return contents;
33
- return contents.slice(end + 3).trimStart();
29
+ const start = contents.indexOf('---');
30
+ if (start === -1) return contents;
31
+ const end = contents.indexOf('---', start + 3);
32
+ if (end === -1) return contents;
33
+ return contents.slice(end + 3).trimStart();
34
34
  }
35
35
 
36
36
  /**
37
37
  * Split a transcript into fixed-size chunks.
38
38
  */
39
39
  function chunkTranscript(
40
- fileId: string,
41
- text: string,
42
- chunkSize: number
40
+ fileId: string,
41
+ text: string,
42
+ chunkSize: number
43
43
  ): EvidenceChunk[] {
44
- const chunks: EvidenceChunk[] = [];
45
- const clean = text.trim();
46
- for (let offset = 0, idx = 0; offset < clean.length; idx += 1) {
47
- const slice = clean.slice(offset, offset + chunkSize);
48
- chunks.push({
49
- chunkId: `${fileId}#c_${String(idx).padStart(2, '0')}`,
50
- text: slice,
51
- meta: { source: fileId },
52
- });
53
- offset += chunkSize;
54
- }
55
- return chunks;
44
+ const chunks: EvidenceChunk[] = [];
45
+ const clean = text.trim();
46
+ for (let offset = 0, idx = 0; offset < clean.length; idx += 1) {
47
+ const slice = clean.slice(offset, offset + chunkSize);
48
+ chunks.push({
49
+ chunkId: `${fileId}#c_${String(idx).padStart(2, '0')}`,
50
+ text: slice,
51
+ meta: { source: fileId },
52
+ });
53
+ offset += chunkSize;
54
+ }
55
+ return chunks;
56
56
  }
57
57
 
58
58
  /**
@@ -60,35 +60,35 @@ function chunkTranscript(
60
60
  * EvidenceChunk objects ready for prompt formatting.
61
61
  */
62
62
  export function loadEvidenceChunks(
63
- options: EvidenceLoadOptions = {}
63
+ options: EvidenceLoadOptions = {}
64
64
  ): EvidenceChunk[] {
65
- const evidenceRoot = options.evidenceRoot ?? DEFAULT_EVIDENCE_ROOT;
66
- const transcriptDirs = options.transcriptDirs ?? DEFAULT_TRANSCRIPT_DIRS;
67
- const chunkSize = options.chunkSize ?? DEFAULT_CHUNK_SIZE;
65
+ const evidenceRoot = options.evidenceRoot ?? DEFAULT_EVIDENCE_ROOT;
66
+ const transcriptDirs = options.transcriptDirs ?? DEFAULT_TRANSCRIPT_DIRS;
67
+ const chunkSize = options.chunkSize ?? DEFAULT_CHUNK_SIZE;
68
68
 
69
- const chunks: EvidenceChunk[] = [];
70
- for (const dir of transcriptDirs) {
71
- const fullDir = path.join(evidenceRoot, dir);
72
- if (!fs.existsSync(fullDir)) continue;
73
- for (const fileName of fs.readdirSync(fullDir)) {
74
- const ext = path.extname(fileName).toLowerCase();
75
- if (ext !== '.md') continue;
76
- const filePath = path.join(fullDir, fileName);
77
- const raw = fs.readFileSync(filePath, 'utf8');
78
- const withoutFrontMatter = stripYamlFrontMatter(raw);
79
- const baseId = path.parse(fileName).name;
80
- const fileChunks = chunkTranscript(baseId, withoutFrontMatter, chunkSize);
81
- chunks.push(...fileChunks);
82
- }
83
- }
84
- return chunks;
69
+ const chunks: EvidenceChunk[] = [];
70
+ for (const dir of transcriptDirs) {
71
+ const fullDir = path.join(evidenceRoot, dir);
72
+ if (!fs.existsSync(fullDir)) continue;
73
+ for (const fileName of fs.readdirSync(fullDir)) {
74
+ const ext = path.extname(fileName).toLowerCase();
75
+ if (ext !== '.md') continue;
76
+ const filePath = path.join(fullDir, fileName);
77
+ const raw = fs.readFileSync(filePath, 'utf8');
78
+ const withoutFrontMatter = stripYamlFrontMatter(raw);
79
+ const baseId = path.parse(fileName).name;
80
+ const fileChunks = chunkTranscript(baseId, withoutFrontMatter, chunkSize);
81
+ chunks.push(...fileChunks);
82
+ }
83
+ }
84
+ return chunks;
85
85
  }
86
86
 
87
87
  export async function loadEvidenceChunksWithSignals(
88
- options: EvidenceLoadWithSignalsOptions = {}
88
+ options: EvidenceLoadWithSignalsOptions = {}
89
89
  ): Promise<EvidenceChunk[]> {
90
- const baseChunks = loadEvidenceChunks(options);
91
- if (!options.posthog) return baseChunks;
92
- const posthogChunks = await loadPosthogEvidenceChunks(options.posthog);
93
- return [...baseChunks, ...posthogChunks];
90
+ const baseChunks = loadEvidenceChunks(options);
91
+ if (!options.posthog) return baseChunks;
92
+ const posthogChunks = await loadPosthogEvidenceChunks(options.posthog);
93
+ return [...baseChunks, ...posthogChunks];
94
94
  }