@redaksjon/protokoll 0.0.13 → 0.0.15
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 +199 -0
- package/dist/feedback.js +5193 -0
- package/dist/feedback.js.map +1 -0
- package/dist/main.js +1858 -9
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.js +1330 -0
- package/dist/mcp/server.js.map +1 -0
- package/guide/index.md +16 -0
- package/guide/mcp-integration.md +341 -0
- package/package.json +5 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +13 -29
- package/dist/agentic/executor.js +0 -747
- package/dist/agentic/executor.js.map +0 -1
- package/dist/agentic/index.js +0 -19
- package/dist/agentic/index.js.map +0 -1
- package/dist/agentic/registry.js +0 -41
- package/dist/agentic/registry.js.map +0 -1
- package/dist/agentic/tools/lookup-person.js +0 -185
- package/dist/agentic/tools/lookup-person.js.map +0 -1
- package/dist/agentic/tools/lookup-project.js +0 -210
- package/dist/agentic/tools/lookup-project.js.map +0 -1
- package/dist/agentic/tools/route-note.js +0 -49
- package/dist/agentic/tools/route-note.js.map +0 -1
- package/dist/agentic/tools/store-context.js +0 -51
- package/dist/agentic/tools/store-context.js.map +0 -1
- package/dist/agentic/tools/verify-spelling.js +0 -57
- package/dist/agentic/tools/verify-spelling.js.map +0 -1
- package/dist/arguments.js +0 -178
- package/dist/arguments.js.map +0 -1
- package/dist/cli/action.js +0 -704
- package/dist/cli/action.js.map +0 -1
- package/dist/cli/config.js +0 -482
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/context.js +0 -466
- package/dist/cli/context.js.map +0 -1
- package/dist/cli/feedback.js +0 -858
- package/dist/cli/feedback.js.map +0 -1
- package/dist/cli/index.js +0 -103
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/install.js +0 -572
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/transcript.js +0 -199
- package/dist/cli/transcript.js.map +0 -1
- package/dist/constants.js +0 -91
- package/dist/constants.js.map +0 -1
- package/dist/context/discovery.js +0 -114
- package/dist/context/discovery.js.map +0 -1
- package/dist/context/index.js +0 -82
- package/dist/context/index.js.map +0 -1
- package/dist/context/storage.js +0 -184
- package/dist/context/storage.js.map +0 -1
- package/dist/interactive/handler.js +0 -524
- package/dist/interactive/handler.js.map +0 -1
- package/dist/interactive/index.js +0 -18
- package/dist/interactive/index.js.map +0 -1
- package/dist/interactive/onboarding.js +0 -28
- package/dist/interactive/onboarding.js.map +0 -1
- package/dist/logging.js +0 -46
- package/dist/logging.js.map +0 -1
- package/dist/output/index.js +0 -8
- package/dist/output/index.js.map +0 -1
- package/dist/output/manager.js +0 -150
- package/dist/output/manager.js.map +0 -1
- package/dist/phases/complete.js +0 -142
- package/dist/phases/complete.js.map +0 -1
- package/dist/phases/locate.js +0 -64
- package/dist/phases/locate.js.map +0 -1
- package/dist/pipeline/index.js +0 -8
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/orchestrator.js +0 -354
- package/dist/pipeline/orchestrator.js.map +0 -1
- package/dist/protokoll.js +0 -180
- package/dist/protokoll.js.map +0 -1
- package/dist/reasoning/client.js +0 -233
- package/dist/reasoning/client.js.map +0 -1
- package/dist/reasoning/index.js +0 -37
- package/dist/reasoning/index.js.map +0 -1
- package/dist/reasoning/strategy.js +0 -60
- package/dist/reasoning/strategy.js.map +0 -1
- package/dist/reflection/collector.js +0 -124
- package/dist/reflection/collector.js.map +0 -1
- package/dist/reflection/index.js +0 -16
- package/dist/reflection/index.js.map +0 -1
- package/dist/reflection/reporter.js +0 -238
- package/dist/reflection/reporter.js.map +0 -1
- package/dist/routing/classifier.js +0 -201
- package/dist/routing/classifier.js.map +0 -1
- package/dist/routing/index.js +0 -27
- package/dist/routing/index.js.map +0 -1
- package/dist/routing/router.js +0 -153
- package/dist/routing/router.js.map +0 -1
- package/dist/transcription/index.js +0 -41
- package/dist/transcription/index.js.map +0 -1
- package/dist/transcription/service.js +0 -64
- package/dist/transcription/service.js.map +0 -1
- package/dist/transcription/types.js +0 -31
- package/dist/transcription/types.js.map +0 -1
- package/dist/util/dates.js +0 -96
- package/dist/util/dates.js.map +0 -1
- package/dist/util/media.js +0 -103
- package/dist/util/media.js.map +0 -1
- package/dist/util/metadata.js +0 -95
- package/dist/util/metadata.js.map +0 -1
- package/dist/util/sound.js +0 -116
- package/dist/util/sound.js.map +0 -1
- package/dist/util/storage.js +0 -135
- package/dist/util/storage.js.map +0 -1
package/dist/util/metadata.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format metadata as Markdown heading section
|
|
3
|
-
*/ const formatMetadataMarkdown = (metadata)=>{
|
|
4
|
-
const lines = [];
|
|
5
|
-
// Title section
|
|
6
|
-
if (metadata.title) {
|
|
7
|
-
lines.push(`# ${metadata.title}`);
|
|
8
|
-
lines.push('');
|
|
9
|
-
}
|
|
10
|
-
// Metadata frontmatter as readable markdown
|
|
11
|
-
lines.push('## Metadata');
|
|
12
|
-
lines.push('');
|
|
13
|
-
// Date and Time
|
|
14
|
-
if (metadata.date) {
|
|
15
|
-
const dateStr = metadata.date.toLocaleDateString('en-US', {
|
|
16
|
-
year: 'numeric',
|
|
17
|
-
month: 'long',
|
|
18
|
-
day: 'numeric'
|
|
19
|
-
});
|
|
20
|
-
lines.push(`**Date**: ${dateStr}`);
|
|
21
|
-
if (metadata.recordingTime) {
|
|
22
|
-
lines.push(`**Time**: ${metadata.recordingTime}`);
|
|
23
|
-
} else {
|
|
24
|
-
const timeStr = metadata.date.toLocaleTimeString('en-US', {
|
|
25
|
-
hour: '2-digit',
|
|
26
|
-
minute: '2-digit',
|
|
27
|
-
hour12: true
|
|
28
|
-
});
|
|
29
|
-
lines.push(`**Time**: ${timeStr}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
lines.push('');
|
|
33
|
-
// Project
|
|
34
|
-
if (metadata.project) {
|
|
35
|
-
lines.push(`**Project**: ${metadata.project}`);
|
|
36
|
-
if (metadata.projectId) {
|
|
37
|
-
lines.push(`**Project ID**: \`${metadata.projectId}\``);
|
|
38
|
-
}
|
|
39
|
-
lines.push('');
|
|
40
|
-
}
|
|
41
|
-
// Routing Information
|
|
42
|
-
if (metadata.routing) {
|
|
43
|
-
lines.push('### Routing');
|
|
44
|
-
lines.push('');
|
|
45
|
-
lines.push(`**Destination**: ${metadata.routing.destination}`);
|
|
46
|
-
lines.push(`**Confidence**: ${(metadata.routing.confidence * 100).toFixed(1)}%`);
|
|
47
|
-
lines.push('');
|
|
48
|
-
if (metadata.routing.signals.length > 0) {
|
|
49
|
-
lines.push('**Classification Signals**:');
|
|
50
|
-
for (const signal of metadata.routing.signals){
|
|
51
|
-
const signalType = signal.type.replace(/_/g, ' ');
|
|
52
|
-
const weight = (signal.weight * 100).toFixed(0);
|
|
53
|
-
lines.push(`- ${signalType}: "${signal.value}" (${weight}% weight)`);
|
|
54
|
-
}
|
|
55
|
-
lines.push('');
|
|
56
|
-
}
|
|
57
|
-
if (metadata.routing.reasoning) {
|
|
58
|
-
lines.push(`**Reasoning**: ${metadata.routing.reasoning}`);
|
|
59
|
-
lines.push('');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Tags
|
|
63
|
-
if (metadata.tags && metadata.tags.length > 0) {
|
|
64
|
-
lines.push('**Tags**: ' + metadata.tags.map((tag)=>`\`${tag}\``).join(', '));
|
|
65
|
-
lines.push('');
|
|
66
|
-
}
|
|
67
|
-
// Duration
|
|
68
|
-
if (metadata.duration) {
|
|
69
|
-
lines.push(`**Duration**: ${metadata.duration}`);
|
|
70
|
-
lines.push('');
|
|
71
|
-
}
|
|
72
|
-
// Separator
|
|
73
|
-
lines.push('---');
|
|
74
|
-
lines.push('');
|
|
75
|
-
return lines.join('\n');
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Extract routing metadata from a RouteDecision
|
|
79
|
-
*/ const createRoutingMetadata = (decision)=>{
|
|
80
|
-
return {
|
|
81
|
-
destination: decision.destination.path,
|
|
82
|
-
confidence: decision.confidence,
|
|
83
|
-
signals: decision.signals,
|
|
84
|
-
reasoning: decision.reasoning
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Extract all tags from routing signals
|
|
89
|
-
*/ const extractTagsFromSignals = (signals)=>{
|
|
90
|
-
return signals.filter((s)=>s.type !== 'context_type') // Skip generic context type
|
|
91
|
-
.map((s)=>s.value).filter((v)=>typeof v === 'string');
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export { createRoutingMetadata, extractTagsFromSignals, formatMetadataMarkdown };
|
|
95
|
-
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sources":["../../src/util/metadata.ts"],"sourcesContent":["import * as Routing from '@/routing';\n\nexport interface TranscriptMetadata {\n title?: string;\n project?: string;\n projectId?: string;\n routing?: RoutingMetadata;\n tags?: string[];\n date?: Date;\n recordingTime?: string;\n confidence?: number;\n duration?: string;\n}\n\nexport interface RoutingMetadata {\n destination: string;\n confidence: number;\n signals: Routing.ClassificationSignal[];\n reasoning: string;\n}\n\n/**\n * Format metadata as Markdown heading section\n */\nexport const formatMetadataMarkdown = (metadata: TranscriptMetadata): string => {\n const lines: string[] = [];\n \n // Title section\n if (metadata.title) {\n lines.push(`# ${metadata.title}`);\n lines.push('');\n }\n \n // Metadata frontmatter as readable markdown\n lines.push('## Metadata');\n lines.push('');\n \n // Date and Time\n if (metadata.date) {\n const dateStr = metadata.date.toLocaleDateString('en-US', {\n year: 'numeric',\n month: 'long',\n day: 'numeric'\n });\n lines.push(`**Date**: ${dateStr}`);\n \n if (metadata.recordingTime) {\n lines.push(`**Time**: ${metadata.recordingTime}`);\n } else {\n const timeStr = metadata.date.toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n hour12: true\n });\n lines.push(`**Time**: ${timeStr}`);\n }\n }\n \n lines.push('');\n \n // Project\n if (metadata.project) {\n lines.push(`**Project**: ${metadata.project}`);\n if (metadata.projectId) {\n lines.push(`**Project ID**: \\`${metadata.projectId}\\``);\n }\n lines.push('');\n }\n \n // Routing Information\n if (metadata.routing) {\n lines.push('### Routing');\n lines.push('');\n lines.push(`**Destination**: ${metadata.routing.destination}`);\n lines.push(`**Confidence**: ${(metadata.routing.confidence * 100).toFixed(1)}%`);\n lines.push('');\n \n if (metadata.routing.signals.length > 0) {\n lines.push('**Classification Signals**:');\n for (const signal of metadata.routing.signals) {\n const signalType = signal.type.replace(/_/g, ' ');\n const weight = (signal.weight * 100).toFixed(0);\n lines.push(`- ${signalType}: \"${signal.value}\" (${weight}% weight)`);\n }\n lines.push('');\n }\n \n if (metadata.routing.reasoning) {\n lines.push(`**Reasoning**: ${metadata.routing.reasoning}`);\n lines.push('');\n }\n }\n \n // Tags\n if (metadata.tags && metadata.tags.length > 0) {\n lines.push('**Tags**: ' + metadata.tags.map(tag => `\\`${tag}\\``).join(', '));\n lines.push('');\n }\n \n // Duration\n if (metadata.duration) {\n lines.push(`**Duration**: ${metadata.duration}`);\n lines.push('');\n }\n \n // Separator\n lines.push('---');\n lines.push('');\n \n return lines.join('\\n');\n};\n\n/**\n * Extract routing metadata from a RouteDecision\n */\nexport const createRoutingMetadata = (decision: Routing.RouteDecision): RoutingMetadata => {\n return {\n destination: decision.destination.path,\n confidence: decision.confidence,\n signals: decision.signals,\n reasoning: decision.reasoning,\n };\n};\n\n/**\n * Format duration in seconds to readable format (e.g., \"2m 30s\")\n */\nexport const formatDuration = (seconds: number): string => {\n const minutes = Math.floor(seconds / 60);\n const secs = Math.round(seconds % 60);\n \n if (minutes === 0) {\n return `${secs}s`;\n }\n \n if (secs === 0) {\n return `${minutes}m`;\n }\n \n return `${minutes}m ${secs}s`;\n};\n\n/**\n * Format time as HH:MM AM/PM\n */\nexport const formatTime = (date: Date): string => {\n return date.toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n hour12: true\n });\n};\n\n/**\n * Extract topic from routing signals\n */\nexport const extractTopicFromSignals = (signals: Routing.ClassificationSignal[]): string | undefined => {\n const topicSignal = signals.find(s => s.type === 'topic' || s.type === 'context_type');\n return topicSignal?.value;\n};\n\n/**\n * Extract all tags from routing signals\n */\nexport const extractTagsFromSignals = (signals: Routing.ClassificationSignal[]): string[] => {\n return signals\n .filter(s => s.type !== 'context_type') // Skip generic context type\n .map(s => s.value)\n .filter((v): v is string => typeof v === 'string');\n};\n\n\n"],"names":["formatMetadataMarkdown","metadata","lines","title","push","date","dateStr","toLocaleDateString","year","month","day","recordingTime","timeStr","toLocaleTimeString","hour","minute","hour12","project","projectId","routing","destination","confidence","toFixed","signals","length","signal","signalType","type","replace","weight","value","reasoning","tags","map","tag","join","duration","createRoutingMetadata","decision","path","extractTagsFromSignals","filter","s","v"],"mappings":"AAqBA;;IAGO,MAAMA,sBAAAA,GAAyB,CAACC,QAAAA,GAAAA;AACnC,IAAA,MAAMC,QAAkB,EAAE;;IAG1B,IAAID,QAAAA,CAASE,KAAK,EAAE;AAChBD,QAAAA,KAAAA,CAAME,IAAI,CAAC,CAAC,EAAE,EAAEH,QAAAA,CAASE,KAAK,CAAA,CAAE,CAAA;AAChCD,QAAAA,KAAAA,CAAME,IAAI,CAAC,EAAA,CAAA;AACf,IAAA;;AAGAF,IAAAA,KAAAA,CAAME,IAAI,CAAC,aAAA,CAAA;AACXF,IAAAA,KAAAA,CAAME,IAAI,CAAC,EAAA,CAAA;;IAGX,IAAIH,QAAAA,CAASI,IAAI,EAAE;AACf,QAAA,MAAMC,UAAUL,QAAAA,CAASI,IAAI,CAACE,kBAAkB,CAAC,OAAA,EAAS;YACtDC,IAAAA,EAAM,SAAA;YACNC,KAAAA,EAAO,MAAA;YACPC,GAAAA,EAAK;AACT,SAAA,CAAA;AACAR,QAAAA,KAAAA,CAAME,IAAI,CAAC,CAAC,UAAU,EAAEE,OAAAA,CAAAA,CAAS,CAAA;QAEjC,IAAIL,QAAAA,CAASU,aAAa,EAAE;AACxB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,IAAI,CAAC,EAAA,CAAA;AACf,IAAA;;IAGA,IAAIH,QAAAA,CAASmC,QAAQ,EAAE;AACnBlC,QAAAA,KAAAA,CAAME,IAAI,CAAC,CAAC,cAAc,EAAEH,QAAAA,CAASmC,QAAQ,CAAA,CAAE,CAAA;AAC/ClC,QAAAA,KAAAA,CAAME,IAAI,CAAC,EAAA,CAAA;AACf,IAAA;;AAGAF,IAAAA,KAAAA,CAAME,IAAI,CAAC,KAAA,CAAA;AACXF,IAAAA,KAAAA,CAAME,IAAI,CAAC,EAAA,CAAA;IAEX,OAAOF,KAAAA,CAAMiC,IAAI,CAAC,IAAA,CAAA;AACtB;AAEA;;IAGO,MAAME,qBAAAA,GAAwB,CAACC,QAAAA,GAAAA;IAClC,OAAO;QACHlB,WAAAA,EAAakB,QAAAA,CAASlB,WAAW,CAACmB,IAAI;AACtClB,QAAAA,UAAAA,EAAYiB,SAASjB,UAAU;AAC/BE,QAAAA,OAAAA,EAASe,SAASf,OAAO;AACzBQ,QAAAA,SAAAA,EAAWO,SAASP;AACxB,KAAA;AACJ;AAuCA;;IAGO,MAAMS,sBAAAA,GAAyB,CAACjB,OAAAA,GAAAA;IACnC,OAAOA,OAAAA,CACFkB,MAAM,CAACC,CAAAA,IAAKA,CAAAA,CAAEf,IAAI,KAAK,cAAA,CAAA;KACvBM,GAAG,CAACS,CAAAA,CAAAA,GAAKA,CAAAA,CAAEZ,KAAK,CAAA,CAChBW,MAAM,CAAC,CAACE,CAAAA,GAAmB,OAAOA,CAAAA,KAAM,QAAA,CAAA;AACjD;;;;"}
|
package/dist/util/sound.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { getLogger } from '../logging.js';
|
|
3
|
-
|
|
4
|
-
// macOS system sounds that work well for notifications
|
|
5
|
-
const MACOS_NOTIFICATION_SOUNDS = [
|
|
6
|
-
'/System/Library/Sounds/Glass.aiff',
|
|
7
|
-
'/System/Library/Sounds/Ping.aiff',
|
|
8
|
-
'/System/Library/Sounds/Pop.aiff',
|
|
9
|
-
'/System/Library/Sounds/Tink.aiff'
|
|
10
|
-
];
|
|
11
|
-
// Default sound to use (Glass is similar to Cursor's notification)
|
|
12
|
-
const DEFAULT_MACOS_SOUND = MACOS_NOTIFICATION_SOUNDS[0];
|
|
13
|
-
/**
|
|
14
|
-
* Play a sound file using afplay (macOS)
|
|
15
|
-
*/ const playWithAfplay = (soundPath)=>{
|
|
16
|
-
return new Promise((resolve)=>{
|
|
17
|
-
const afplay = spawn('afplay', [
|
|
18
|
-
soundPath
|
|
19
|
-
], {
|
|
20
|
-
stdio: 'ignore',
|
|
21
|
-
detached: true
|
|
22
|
-
});
|
|
23
|
-
afplay.on('error', ()=>{
|
|
24
|
-
resolve(false);
|
|
25
|
-
});
|
|
26
|
-
afplay.on('close', (code)=>{
|
|
27
|
-
resolve(code === 0);
|
|
28
|
-
});
|
|
29
|
-
// Don't wait for the sound to finish - just fire and forget
|
|
30
|
-
afplay.unref();
|
|
31
|
-
// Consider it successful if spawn didn't throw
|
|
32
|
-
setTimeout(()=>resolve(true), 50);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Play Windows system notification sound using PowerShell
|
|
37
|
-
* Uses SystemSounds.Asterisk which is a pleasant notification tone
|
|
38
|
-
*/ const playWithPowerShell = ()=>{
|
|
39
|
-
return new Promise((resolve)=>{
|
|
40
|
-
// Use PowerShell to access .NET System.Media.SystemSounds
|
|
41
|
-
// Asterisk is a pleasant notification sound, similar to macOS Glass
|
|
42
|
-
const ps = spawn('powershell', [
|
|
43
|
-
'-NoProfile',
|
|
44
|
-
'-NonInteractive',
|
|
45
|
-
'-Command',
|
|
46
|
-
'[System.Media.SystemSounds]::Asterisk.Play()'
|
|
47
|
-
], {
|
|
48
|
-
stdio: 'ignore',
|
|
49
|
-
detached: true,
|
|
50
|
-
// On Windows, use shell to ensure PowerShell is found
|
|
51
|
-
shell: true
|
|
52
|
-
});
|
|
53
|
-
ps.on('error', ()=>{
|
|
54
|
-
resolve(false);
|
|
55
|
-
});
|
|
56
|
-
ps.on('close', (code)=>{
|
|
57
|
-
resolve(code === 0);
|
|
58
|
-
});
|
|
59
|
-
ps.unref();
|
|
60
|
-
// Consider it successful if spawn didn't throw
|
|
61
|
-
setTimeout(()=>resolve(true), 50);
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Play terminal bell as fallback for Linux and other platforms
|
|
66
|
-
*/ const playTerminalBell = ()=>{
|
|
67
|
-
// Write ASCII bell character to stdout
|
|
68
|
-
process.stdout.write('\x07');
|
|
69
|
-
};
|
|
70
|
-
const create = (config)=>{
|
|
71
|
-
const logger = getLogger();
|
|
72
|
-
const playNotification = async ()=>{
|
|
73
|
-
if (config.silent) {
|
|
74
|
-
logger.debug('Sound notification skipped (silent mode)');
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
// macOS: use afplay with system sounds
|
|
79
|
-
if (process.platform === 'darwin') {
|
|
80
|
-
const success = await playWithAfplay(DEFAULT_MACOS_SOUND);
|
|
81
|
-
if (success) {
|
|
82
|
-
logger.debug('Played notification sound: %s', DEFAULT_MACOS_SOUND);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Windows: use PowerShell to play system sound
|
|
87
|
-
if (process.platform === 'win32') {
|
|
88
|
-
const success = await playWithPowerShell();
|
|
89
|
-
if (success) {
|
|
90
|
-
logger.debug('Played Windows notification sound via PowerShell');
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Linux and others: fall back to terminal bell
|
|
95
|
-
playTerminalBell();
|
|
96
|
-
logger.debug('Played terminal bell notification');
|
|
97
|
-
} catch (error) {
|
|
98
|
-
// Sound failures should never interrupt the workflow
|
|
99
|
-
logger.debug('Failed to play notification sound: %s', error);
|
|
100
|
-
// Try terminal bell as last resort
|
|
101
|
-
try {
|
|
102
|
-
playTerminalBell();
|
|
103
|
-
} catch {
|
|
104
|
-
// Silently ignore - sound is not critical
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
const isEnabled = ()=>!config.silent;
|
|
109
|
-
return {
|
|
110
|
-
playNotification,
|
|
111
|
-
isEnabled
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export { create };
|
|
116
|
-
//# sourceMappingURL=sound.js.map
|
package/dist/util/sound.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sound.js","sources":["../../src/util/sound.ts"],"sourcesContent":["/**\n * Sound Notification Utility\n * \n * Plays system sounds to notify the user when interactive input is needed.\n * Similar to Cursor's notification behavior.\n * \n * Platform support:\n * - macOS: Uses afplay with system sounds (Glass.aiff)\n * - Windows: Uses PowerShell to play system notification sound\n * - Linux/Other: Falls back to terminal bell\n */\n\nimport { spawn } from 'child_process';\nimport * as Logging from '../logging';\n\nexport interface SoundConfig {\n /** Whether sounds are disabled (silent mode) */\n silent: boolean;\n}\n\nexport interface SoundInstance {\n /** Play a notification sound to get user's attention */\n playNotification(): Promise<void>;\n /** Check if sounds are enabled */\n isEnabled(): boolean;\n}\n\n// macOS system sounds that work well for notifications\nconst MACOS_NOTIFICATION_SOUNDS = [\n '/System/Library/Sounds/Glass.aiff',\n '/System/Library/Sounds/Ping.aiff', \n '/System/Library/Sounds/Pop.aiff',\n '/System/Library/Sounds/Tink.aiff',\n];\n\n// Default sound to use (Glass is similar to Cursor's notification)\nconst DEFAULT_MACOS_SOUND = MACOS_NOTIFICATION_SOUNDS[0];\n\n/**\n * Play a sound file using afplay (macOS)\n */\nconst playWithAfplay = (soundPath: string): Promise<boolean> => {\n return new Promise((resolve) => {\n const afplay = spawn('afplay', [soundPath], {\n stdio: 'ignore',\n detached: true,\n });\n\n afplay.on('error', () => {\n resolve(false);\n });\n\n afplay.on('close', (code) => {\n resolve(code === 0);\n });\n\n // Don't wait for the sound to finish - just fire and forget\n afplay.unref();\n \n // Consider it successful if spawn didn't throw\n setTimeout(() => resolve(true), 50);\n });\n};\n\n/**\n * Play Windows system notification sound using PowerShell\n * Uses SystemSounds.Asterisk which is a pleasant notification tone\n */\nconst playWithPowerShell = (): Promise<boolean> => {\n return new Promise((resolve) => {\n // Use PowerShell to access .NET System.Media.SystemSounds\n // Asterisk is a pleasant notification sound, similar to macOS Glass\n const ps = spawn('powershell', [\n '-NoProfile',\n '-NonInteractive', \n '-Command',\n '[System.Media.SystemSounds]::Asterisk.Play()'\n ], {\n stdio: 'ignore',\n detached: true,\n // On Windows, use shell to ensure PowerShell is found\n shell: true,\n });\n\n ps.on('error', () => {\n resolve(false);\n });\n\n ps.on('close', (code) => {\n resolve(code === 0);\n });\n\n ps.unref();\n \n // Consider it successful if spawn didn't throw\n setTimeout(() => resolve(true), 50);\n });\n};\n\n/**\n * Play terminal bell as fallback for Linux and other platforms\n */\nconst playTerminalBell = (): void => {\n // Write ASCII bell character to stdout\n process.stdout.write('\\x07');\n};\n\nexport const create = (config: SoundConfig): SoundInstance => {\n const logger = Logging.getLogger();\n \n const playNotification = async (): Promise<void> => {\n if (config.silent) {\n logger.debug('Sound notification skipped (silent mode)');\n return;\n }\n\n try {\n // macOS: use afplay with system sounds\n if (process.platform === 'darwin') {\n const success = await playWithAfplay(DEFAULT_MACOS_SOUND);\n if (success) {\n logger.debug('Played notification sound: %s', DEFAULT_MACOS_SOUND);\n return;\n }\n }\n \n // Windows: use PowerShell to play system sound\n if (process.platform === 'win32') {\n const success = await playWithPowerShell();\n if (success) {\n logger.debug('Played Windows notification sound via PowerShell');\n return;\n }\n }\n \n // Linux and others: fall back to terminal bell\n playTerminalBell();\n logger.debug('Played terminal bell notification');\n } catch (error) {\n // Sound failures should never interrupt the workflow\n logger.debug('Failed to play notification sound: %s', error);\n // Try terminal bell as last resort\n try {\n playTerminalBell();\n } catch {\n // Silently ignore - sound is not critical\n }\n }\n };\n\n const isEnabled = (): boolean => !config.silent;\n\n return {\n playNotification,\n isEnabled,\n };\n};\n\n"],"names":["MACOS_NOTIFICATION_SOUNDS","DEFAULT_MACOS_SOUND","playWithAfplay","soundPath","Promise","resolve","afplay","spawn","stdio","detached","on","code","unref","setTimeout","playWithPowerShell","ps","shell","playTerminalBell","process","stdout","write","create","config","logger","Logging","playNotification","silent","debug","platform","success","error","isEnabled"],"mappings":";;;AA2BA;AACA,MAAMA,yBAAAA,GAA4B;AAC9B,IAAA,mCAAA;AACA,IAAA,kCAAA;AACA,IAAA,iCAAA;AACA,IAAA;AACH,CAAA;AAED;AACA,MAAMC,mBAAAA,GAAsBD,yBAAyB,CAAC,CAAA,CAAE;AAExD;;IAGA,MAAME,iBAAiB,CAACC,SAAAA,GAAAA;IACpB,OAAO,IAAIC,QAAQ,CAACC,OAAAA,GAAAA;QAChB,MAAMC,MAAAA,GAASC,MAAM,QAAA,EAAU;AAACJ,YAAAA;SAAU,EAAE;YACxCK,KAAAA,EAAO,QAAA;YACPC,QAAAA,EAAU;AACd,SAAA,CAAA;QAEAH,MAAAA,CAAOI,EAAE,CAAC,OAAA,EAAS,IAAA;YACfL,OAAAA,CAAQ,KAAA,CAAA;AACZ,QAAA,CAAA,CAAA;QAEAC,MAAAA,CAAOI,EAAE,CAAC,OAAA,EAAS,CAACC,IAAAA,GAAAA;AAChBN,YAAAA,OAAAA,CAAQM,IAAAA,KAAS,CAAA,CAAA;AACrB,QAAA,CAAA,CAAA;;AAGAL,QAAAA,MAAAA,CAAOM,KAAK,EAAA;;QAGZC,UAAAA,CAAW,IAAMR,QAAQ,IAAA,CAAA,EAAO,EAAA,CAAA;AACpC,IAAA,CAAA,CAAA;AACJ,CAAA;AAEA;;;AAGC,IACD,MAAMS,kBAAAA,GAAqB,IAAA;IACvB,OAAO,IAAIV,QAAQ,CAACC,OAAAA,GAAAA;;;QAGhB,MAAMU,EAAAA,GAAKR,MAAM,YAAA,EAAc;AAC3B,YAAA,YAAA;AACA,YAAA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AMC,UAAU,MAAMf,kBAAAA,EAAAA;AACtB,gBAAA,IAAIe,OAAAA,EAAS;AACTN,oBAAAA,MAAAA,CAAOI,KAAK,CAAC,kDAAA,CAAA;AACb,oBAAA;AACJ,gBAAA;AACJ,YAAA;;AAGAV,YAAAA,gBAAAA,EAAAA;AACAM,YAAAA,MAAAA,CAAOI,KAAK,CAAC,mCAAA,CAAA;AACjB,QAAA,CAAA,CAAE,OAAOG,KAAAA,EAAO;;YAEZP,MAAAA,CAAOI,KAAK,CAAC,uCAAA,EAAyCG,KAAAA,CAAAA;;YAEtD,IAAI;AACAb,gBAAAA,gBAAAA,EAAAA;AACJ,YAAA,CAAA,CAAE,OAAM;;AAER,YAAA;AACJ,QAAA;AACJ,IAAA,CAAA;AAEA,IAAA,MAAMc,SAAAA,GAAY,IAAe,CAACT,MAAAA,CAAOI,MAAM;IAE/C,OAAO;AACHD,QAAAA,gBAAAA;AACAM,QAAAA;AACJ,KAAA;AACJ;;;;"}
|
package/dist/util/storage.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
import { glob } from 'glob';
|
|
3
|
-
import path__default from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line no-restricted-imports
|
|
7
|
-
const create = (params)=>{
|
|
8
|
-
// eslint-disable-next-line no-console
|
|
9
|
-
const log = params.log || console.log;
|
|
10
|
-
const exists = async (path)=>{
|
|
11
|
-
try {
|
|
12
|
-
await fs.promises.stat(path);
|
|
13
|
-
return true;
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
|
-
} catch (error) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const isDirectory = async (path)=>{
|
|
20
|
-
const stats = await fs.promises.stat(path);
|
|
21
|
-
if (!stats.isDirectory()) {
|
|
22
|
-
log(`${path} is not a directory`);
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
};
|
|
27
|
-
const isFile = async (path)=>{
|
|
28
|
-
const stats = await fs.promises.stat(path);
|
|
29
|
-
if (!stats.isFile()) {
|
|
30
|
-
log(`${path} is not a file`);
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
const isReadable = async (path)=>{
|
|
36
|
-
try {
|
|
37
|
-
await fs.promises.access(path, fs.constants.R_OK);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
log(`${path} is not readable: %s %s`, error.message, error.stack);
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
const isWritable = async (path)=>{
|
|
45
|
-
try {
|
|
46
|
-
await fs.promises.access(path, fs.constants.W_OK);
|
|
47
|
-
} catch (error) {
|
|
48
|
-
log(`${path} is not writable: %s %s`, error.message, error.stack);
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
};
|
|
53
|
-
const isFileReadable = async (path)=>{
|
|
54
|
-
return await exists(path) && await isFile(path) && await isReadable(path);
|
|
55
|
-
};
|
|
56
|
-
const isDirectoryWritable = async (path)=>{
|
|
57
|
-
return await exists(path) && await isDirectory(path) && await isWritable(path);
|
|
58
|
-
};
|
|
59
|
-
const isDirectoryReadable = async (path)=>{
|
|
60
|
-
return await exists(path) && await isDirectory(path) && await isReadable(path);
|
|
61
|
-
};
|
|
62
|
-
const createDirectory = async (path)=>{
|
|
63
|
-
try {
|
|
64
|
-
await fs.promises.mkdir(path, {
|
|
65
|
-
recursive: true
|
|
66
|
-
});
|
|
67
|
-
} catch (mkdirError) {
|
|
68
|
-
throw new Error(`Failed to create output directory ${path}: ${mkdirError.message} ${mkdirError.stack}`);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const readFile = async (path, encoding)=>{
|
|
72
|
-
return await fs.promises.readFile(path, {
|
|
73
|
-
encoding: encoding
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
const writeFile = async (path, data, encoding)=>{
|
|
77
|
-
await fs.promises.writeFile(path, data, {
|
|
78
|
-
encoding: encoding
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
const forEachFileIn = async (directory, callback, options = {
|
|
82
|
-
pattern: '*.*'
|
|
83
|
-
})=>{
|
|
84
|
-
try {
|
|
85
|
-
const files = await glob(options.pattern, {
|
|
86
|
-
cwd: directory,
|
|
87
|
-
nodir: true
|
|
88
|
-
});
|
|
89
|
-
for (const file of files){
|
|
90
|
-
await callback(path__default.join(directory, file));
|
|
91
|
-
}
|
|
92
|
-
} catch (err) {
|
|
93
|
-
throw new Error(`Failed to glob pattern ${options.pattern} in ${directory}: ${err.message}`);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const readStream = async (path)=>{
|
|
97
|
-
return fs.createReadStream(path);
|
|
98
|
-
};
|
|
99
|
-
const hashFile = async (path, length)=>{
|
|
100
|
-
const file = await readFile(path, 'utf8');
|
|
101
|
-
return crypto.createHash('sha256').update(file).digest('hex').slice(0, length);
|
|
102
|
-
};
|
|
103
|
-
const listFiles = async (directory)=>{
|
|
104
|
-
return await fs.promises.readdir(directory);
|
|
105
|
-
};
|
|
106
|
-
const deleteFile = async (path)=>{
|
|
107
|
-
await fs.promises.unlink(path);
|
|
108
|
-
};
|
|
109
|
-
const getFileSize = async (path)=>{
|
|
110
|
-
const stats = await fs.promises.stat(path);
|
|
111
|
-
return stats.size;
|
|
112
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
exists,
|
|
115
|
-
isDirectory,
|
|
116
|
-
isFile,
|
|
117
|
-
isReadable,
|
|
118
|
-
isWritable,
|
|
119
|
-
isFileReadable,
|
|
120
|
-
isDirectoryWritable,
|
|
121
|
-
isDirectoryReadable,
|
|
122
|
-
createDirectory,
|
|
123
|
-
readFile,
|
|
124
|
-
readStream,
|
|
125
|
-
writeFile,
|
|
126
|
-
forEachFileIn,
|
|
127
|
-
hashFile,
|
|
128
|
-
listFiles,
|
|
129
|
-
deleteFile,
|
|
130
|
-
getFileSize
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export { create };
|
|
135
|
-
//# sourceMappingURL=storage.js.map
|
package/dist/util/storage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sources":["../../src/util/storage.ts"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport * as fs from 'node:fs';\nimport { glob } from 'glob';\nimport path from 'node:path';\nimport crypto from 'node:crypto';\n/**\n * This module exists to isolate filesystem operations from the rest of the codebase.\n * This makes testing easier by avoiding direct fs mocking in jest configuration.\n * \n * Additionally, abstracting storage operations allows for future flexibility - \n * this export utility may need to work with storage systems other than the local filesystem\n * (e.g. S3, Google Cloud Storage, etc).\n */\n\nexport interface Utility {\n exists: (path: string) => Promise<boolean>;\n isDirectory: (path: string) => Promise<boolean>;\n isFile: (path: string) => Promise<boolean>;\n isReadable: (path: string) => Promise<boolean>;\n isWritable: (path: string) => Promise<boolean>;\n isFileReadable: (path: string) => Promise<boolean>;\n isDirectoryWritable: (path: string) => Promise<boolean>;\n isDirectoryReadable: (path: string) => Promise<boolean>;\n createDirectory: (path: string) => Promise<void>;\n readFile: (path: string, encoding: string) => Promise<string>;\n readStream: (path: string) => Promise<fs.ReadStream>;\n writeFile: (path: string, data: string | Buffer, encoding: string) => Promise<void>;\n forEachFileIn: (directory: string, callback: (path: string) => Promise<void>, options?: { pattern: string }) => Promise<void>;\n hashFile: (path: string, length: number) => Promise<string>;\n listFiles: (directory: string) => Promise<string[]>;\n deleteFile: (path: string) => Promise<void>;\n getFileSize: (path: string) => Promise<number>;\n}\n\nexport const create = (params: { log?: (message: string, ...args: any[]) => void }): Utility => {\n\n // eslint-disable-next-line no-console\n const log = params.log || console.log;\n\n const exists = async (path: string): Promise<boolean> => {\n try {\n await fs.promises.stat(path);\n return true;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (error: any) {\n return false;\n }\n }\n\n const isDirectory = async (path: string): Promise<boolean> => {\n const stats = await fs.promises.stat(path);\n if (!stats.isDirectory()) {\n log(`${path} is not a directory`);\n return false;\n }\n return true;\n }\n\n const isFile = async (path: string): Promise<boolean> => {\n const stats = await fs.promises.stat(path);\n if (!stats.isFile()) {\n log(`${path} is not a file`);\n return false;\n }\n return true;\n }\n\n const isReadable = async (path: string): Promise<boolean> => {\n try {\n await fs.promises.access(path, fs.constants.R_OK);\n } catch (error: any) {\n log(`${path} is not readable: %s %s`, error.message, error.stack);\n return false;\n }\n return true;\n }\n\n const isWritable = async (path: string): Promise<boolean> => {\n try {\n await fs.promises.access(path, fs.constants.W_OK);\n } catch (error: any) {\n log(`${path} is not writable: %s %s`, error.message, error.stack);\n return false;\n }\n return true;\n }\n\n const isFileReadable = async (path: string): Promise<boolean> => {\n return await exists(path) && await isFile(path) && await isReadable(path);\n }\n\n const isDirectoryWritable = async (path: string): Promise<boolean> => {\n return await exists(path) && await isDirectory(path) && await isWritable(path);\n }\n\n const isDirectoryReadable = async (path: string): Promise<boolean> => {\n return await exists(path) && await isDirectory(path) && await isReadable(path);\n }\n\n const createDirectory = async (path: string): Promise<void> => {\n try {\n await fs.promises.mkdir(path, { recursive: true });\n } catch (mkdirError: any) {\n throw new Error(`Failed to create output directory ${path}: ${mkdirError.message} ${mkdirError.stack}`);\n }\n }\n\n const readFile = async (path: string, encoding: string): Promise<string> => {\n return await fs.promises.readFile(path, { encoding: encoding as BufferEncoding });\n }\n\n const writeFile = async (path: string, data: string | Buffer, encoding: string): Promise<void> => {\n await fs.promises.writeFile(path, data, { encoding: encoding as BufferEncoding });\n }\n\n const forEachFileIn = async (directory: string, callback: (file: string) => Promise<void>, options: { pattern: string | string[] } = { pattern: '*.*' }): Promise<void> => {\n try {\n const files = await glob(options.pattern, { cwd: directory, nodir: true });\n for (const file of files) {\n await callback(path.join(directory, file));\n }\n } catch (err: any) {\n throw new Error(`Failed to glob pattern ${options.pattern} in ${directory}: ${err.message}`);\n }\n }\n\n const readStream = async (path: string): Promise<fs.ReadStream> => {\n return fs.createReadStream(path);\n }\n\n const hashFile = async (path: string, length: number): Promise<string> => {\n const file = await readFile(path, 'utf8');\n return crypto.createHash('sha256').update(file).digest('hex').slice(0, length);\n }\n\n const listFiles = async (directory: string): Promise<string[]> => {\n return await fs.promises.readdir(directory);\n }\n\n const deleteFile = async (path: string): Promise<void> => {\n await fs.promises.unlink(path);\n }\n\n const getFileSize = async (path: string): Promise<number> => {\n const stats = await fs.promises.stat(path);\n return stats.size;\n }\n\n return {\n exists,\n isDirectory,\n isFile,\n isReadable,\n isWritable,\n isFileReadable,\n isDirectoryWritable,\n isDirectoryReadable,\n createDirectory,\n readFile,\n readStream,\n writeFile,\n forEachFileIn,\n hashFile,\n listFiles,\n deleteFile,\n getFileSize,\n };\n}"],"names":["create","params","log","console","exists","path","fs","promises","stat","error","isDirectory","stats","isFile","isReadable","access","constants","R_OK","message","stack","isWritable","W_OK","isFileReadable","isDirectoryWritable","isDirectoryReadable","createDirectory","mkdir","recursive","mkdirError","Error","readFile","encoding","writeFile","data","forEachFileIn","directory","callback","options","pattern","files","glob","cwd","nodir","file","join","err","readStream","createReadStream","hashFile","length","crypto","createHash","update","digest","slice","listFiles","readdir","deleteFile","unlink","getFileSize","size"],"mappings":";;;;;AAAA;AAkCO,MAAMA,SAAS,CAACC,MAAAA,GAAAA;;AAGnB,IAAA,MAAMC,GAAAA,GAAMD,MAAAA,CAAOC,GAAG,IAAIC,QAAQD,GAAG;AAErC,IAAA,MAAME,SAAS,OAAOC,IAAAA,GAAAA;QAClB,IAAI;AACA,YAAA,MAAMC,EAAAA,CAAGC,QAAQ,CAACC,IAAI,CAACH,IAAAA,CAAAA;YACvB,OAAO,IAAA;;AAEX,QAAA,CAAA,CAAE,OAAOI,KAAAA,EAAY;YACjB,OAAO,KAAA;AACX,QAAA;AACJ,IAAA,CAAA;AAEA,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