openwriter 0.9.3 → 0.11.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.
@@ -1,58 +0,0 @@
1
- /**
2
- * File: prompt-debug.ts
3
- * Purpose: Write AV prompt debug data to timestamped .md files for inspection.
4
- * Each enhance creates a new file in DATA_DIR, visible in the sidebar.
5
- */
6
- import { DATA_DIR, ensureDataDir, atomicWriteFileSync } from './helpers.js';
7
- import { join } from 'path';
8
- /**
9
- * Write prompt debug info to a timestamped markdown file.
10
- * Returns the filename created.
11
- */
12
- export function writePromptDebug(action, debug, metadata) {
13
- ensureDataDir();
14
- const now = new Date();
15
- const ts = now.toISOString().replace(/[:.]/g, '-').slice(0, 19);
16
- const filename = `_prompt-${action || 'debug'}-${ts}.md`;
17
- const filePath = join(DATA_DIR, filename);
18
- const timeStr = now.toLocaleTimeString('en-US', { hour12: true, hour: '2-digit', minute: '2-digit', second: '2-digit' });
19
- let md = `---\ntitle: "Prompt Debug: ${action} @ ${timeStr}"\n---\n\n`;
20
- // Metadata summary
21
- if (metadata) {
22
- md += `## Metadata\n\n`;
23
- md += `| Key | Value |\n|-----|-------|\n`;
24
- if (metadata.action)
25
- md += `| Action | ${metadata.action} |\n`;
26
- if (metadata.profileUsed)
27
- md += `| Profile | ${metadata.profileUsed} |\n`;
28
- if (metadata.nodesIn != null)
29
- md += `| Nodes In | ${metadata.nodesIn} |\n`;
30
- if (metadata.nodesOut != null)
31
- md += `| Nodes Out | ${metadata.nodesOut} |\n`;
32
- if (metadata.ragExamples != null)
33
- md += `| RAG Examples | ${metadata.ragExamples} |\n`;
34
- if (metadata.ragTotalWords != null)
35
- md += `| RAG Total Words | ${metadata.ragTotalWords} |\n`;
36
- if (metadata.processingTimeMs != null)
37
- md += `| Processing Time | ${metadata.processingTimeMs}ms |\n`;
38
- if (metadata.estimatedCost != null)
39
- md += `| Estimated Cost | $${metadata.estimatedCost.toFixed(4)} |\n`;
40
- md += `\n`;
41
- }
42
- // System prompt
43
- if (debug.systemPrompt) {
44
- md += `## System Prompt\n\n`;
45
- md += debug.systemPrompt + '\n\n';
46
- }
47
- // User prompt
48
- if (debug.userPrompt) {
49
- md += `---\n\n## User Prompt\n\n`;
50
- md += debug.userPrompt + '\n\n';
51
- }
52
- // Raw LLM response (when available)
53
- if (debug.rawResponse) {
54
- md += `---\n\n## Raw LLM Output\n\n\`\`\`json\n${debug.rawResponse}\n\`\`\`\n\n`;
55
- }
56
- atomicWriteFileSync(filePath, md);
57
- return filename;
58
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Tag index operations for workspace v2.
3
- * Tags are a cross-cutting index: tag → [file1, file2, ...].
4
- */
5
- export function addTag(tags, tagName, file) {
6
- if (!tags[tagName])
7
- tags[tagName] = [];
8
- if (!tags[tagName].includes(file))
9
- tags[tagName].push(file);
10
- }
11
- export function removeTag(tags, tagName, file) {
12
- if (!tags[tagName])
13
- return;
14
- tags[tagName] = tags[tagName].filter((f) => f !== file);
15
- if (tags[tagName].length === 0)
16
- delete tags[tagName];
17
- }
18
- export function removeFileFromAllTags(tags, file) {
19
- for (const tagName of Object.keys(tags)) {
20
- removeTag(tags, tagName, file);
21
- }
22
- }
23
- export function listTagsForFile(tags, file) {
24
- const result = [];
25
- for (const [tagName, files] of Object.entries(tags)) {
26
- if (files.includes(file))
27
- result.push(tagName);
28
- }
29
- return result;
30
- }