@redaksjon/protokoll 0.0.8 → 0.0.10

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.
Files changed (112) hide show
  1. package/.cursor/rules/definition-of-done.md +89 -0
  2. package/.cursor/rules/no-emoticons.md +43 -0
  3. package/LICENSE +1 -1
  4. package/README.md +928 -35
  5. package/dist/agentic/executor.js +315 -0
  6. package/dist/agentic/executor.js.map +1 -0
  7. package/dist/agentic/index.js +19 -0
  8. package/dist/agentic/index.js.map +1 -0
  9. package/dist/agentic/registry.js +41 -0
  10. package/dist/agentic/registry.js.map +1 -0
  11. package/dist/agentic/tools/lookup-person.js +66 -0
  12. package/dist/agentic/tools/lookup-person.js.map +1 -0
  13. package/dist/agentic/tools/lookup-project.js +93 -0
  14. package/dist/agentic/tools/lookup-project.js.map +1 -0
  15. package/dist/agentic/tools/route-note.js +45 -0
  16. package/dist/agentic/tools/route-note.js.map +1 -0
  17. package/dist/agentic/tools/store-context.js +51 -0
  18. package/dist/agentic/tools/store-context.js.map +1 -0
  19. package/dist/agentic/tools/verify-spelling.js +57 -0
  20. package/dist/agentic/tools/verify-spelling.js.map +1 -0
  21. package/dist/arguments.js +23 -6
  22. package/dist/arguments.js.map +1 -1
  23. package/dist/constants.js +13 -11
  24. package/dist/constants.js.map +1 -1
  25. package/dist/context/discovery.js +114 -0
  26. package/dist/context/discovery.js.map +1 -0
  27. package/dist/context/index.js +58 -0
  28. package/dist/context/index.js.map +1 -0
  29. package/dist/context/storage.js +131 -0
  30. package/dist/context/storage.js.map +1 -0
  31. package/dist/interactive/handler.js +223 -0
  32. package/dist/interactive/handler.js.map +1 -0
  33. package/dist/interactive/index.js +18 -0
  34. package/dist/interactive/index.js.map +1 -0
  35. package/dist/interactive/onboarding.js +28 -0
  36. package/dist/interactive/onboarding.js.map +1 -0
  37. package/dist/main.js +0 -0
  38. package/dist/output/index.js +8 -0
  39. package/dist/output/index.js.map +1 -0
  40. package/dist/output/manager.js +105 -0
  41. package/dist/output/manager.js.map +1 -0
  42. package/dist/phases/complete.js +107 -0
  43. package/dist/phases/complete.js.map +1 -0
  44. package/dist/phases/locate.js +14 -5
  45. package/dist/phases/locate.js.map +1 -1
  46. package/dist/pipeline/index.js +8 -0
  47. package/dist/pipeline/index.js.map +1 -0
  48. package/dist/pipeline/orchestrator.js +281 -0
  49. package/dist/pipeline/orchestrator.js.map +1 -0
  50. package/dist/prompt/instructions/transcribe.md +6 -6
  51. package/dist/prompt/personas/transcriber.md +5 -5
  52. package/dist/protokoll.js +38 -5
  53. package/dist/protokoll.js.map +1 -1
  54. package/dist/reasoning/client.js +150 -0
  55. package/dist/reasoning/client.js.map +1 -0
  56. package/dist/reasoning/index.js +36 -0
  57. package/dist/reasoning/index.js.map +1 -0
  58. package/dist/reasoning/strategy.js +60 -0
  59. package/dist/reasoning/strategy.js.map +1 -0
  60. package/dist/reflection/collector.js +124 -0
  61. package/dist/reflection/collector.js.map +1 -0
  62. package/dist/reflection/index.js +16 -0
  63. package/dist/reflection/index.js.map +1 -0
  64. package/dist/reflection/reporter.js +238 -0
  65. package/dist/reflection/reporter.js.map +1 -0
  66. package/dist/routing/classifier.js +201 -0
  67. package/dist/routing/classifier.js.map +1 -0
  68. package/dist/routing/index.js +27 -0
  69. package/dist/routing/index.js.map +1 -0
  70. package/dist/routing/router.js +153 -0
  71. package/dist/routing/router.js.map +1 -0
  72. package/dist/transcription/index.js +41 -0
  73. package/dist/transcription/index.js.map +1 -0
  74. package/dist/transcription/service.js +64 -0
  75. package/dist/transcription/service.js.map +1 -0
  76. package/dist/transcription/types.js +31 -0
  77. package/dist/transcription/types.js.map +1 -0
  78. package/dist/util/media.js +4 -4
  79. package/dist/util/media.js.map +1 -1
  80. package/dist/util/metadata.js +95 -0
  81. package/dist/util/metadata.js.map +1 -0
  82. package/dist/util/storage.js +2 -2
  83. package/dist/util/storage.js.map +1 -1
  84. package/docs/examples.md +224 -0
  85. package/docs/index.html +5 -3
  86. package/docs/package-lock.json +639 -332
  87. package/docs/package.json +5 -4
  88. package/docs/troubleshooting.md +257 -0
  89. package/docs/vite.config.js +9 -3
  90. package/eslint.config.mjs +1 -0
  91. package/guide/architecture.md +217 -0
  92. package/guide/configuration.md +199 -0
  93. package/guide/context-system.md +215 -0
  94. package/guide/development.md +273 -0
  95. package/guide/index.md +91 -0
  96. package/guide/interactive.md +199 -0
  97. package/guide/quickstart.md +138 -0
  98. package/guide/reasoning.md +193 -0
  99. package/guide/routing.md +222 -0
  100. package/package.json +10 -7
  101. package/tsconfig.tsbuildinfo +1 -1
  102. package/vitest.config.ts +27 -5
  103. package/dist/phases/transcribe.js +0 -149
  104. package/dist/phases/transcribe.js.map +0 -1
  105. package/dist/processor.js +0 -35
  106. package/dist/processor.js.map +0 -1
  107. package/dist/prompt/transcribe.js +0 -41
  108. package/dist/prompt/transcribe.js.map +0 -1
  109. package/dist/util/general.js +0 -39
  110. package/dist/util/general.js.map +0 -1
  111. package/dist/util/openai.js +0 -92
  112. package/dist/util/openai.js.map +0 -1
package/docs/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
- "name": "matnava-docs",
2
+ "name": "protokoll-docs",
3
+ "private": true,
3
4
  "version": "1.0.0",
4
- "description": "Documentation site for Matnava - a focused transcription tool",
5
+ "description": "Documentation site for Protokoll - intelligent audio transcription",
5
6
  "type": "module",
6
7
  "scripts": {
7
8
  "dev": "vite",
8
- "build": "vite build",
9
+ "build": "vite build && cp dist/index.html dist/404.html",
9
10
  "preview": "vite preview"
10
11
  },
11
12
  "dependencies": {
@@ -16,6 +17,6 @@
16
17
  "@types/react": "^18.2.0",
17
18
  "@types/react-dom": "^18.2.0",
18
19
  "@vitejs/plugin-react": "^4.0.0",
19
- "vite": "^5.0.0"
20
+ "vite": "^7.3.1"
20
21
  }
21
22
  }
@@ -0,0 +1,257 @@
1
+ # Troubleshooting Guide
2
+
3
+ ## Common Issues
4
+
5
+ ### Names Still Misspelled
6
+
7
+ **Problem**: Whisper keeps mishearing names even after adding context.
8
+
9
+ **Solution**: Add phonetic aliases to your context files:
10
+
11
+ ```yaml
12
+ # ~/.protokoll/people/priya-sharma.yaml
13
+ id: priya-sharma
14
+ name: Priya Sharma
15
+ sounds_like:
16
+ - "pre a"
17
+ - "pria"
18
+ - "preeya sharma"
19
+ - "preya"
20
+ ```
21
+
22
+ The `sounds_like` field helps Protokoll recognize common mishearings.
23
+
24
+ ### Notes Going to Wrong Directory
25
+
26
+ **Problem**: Notes about Project A are going to default directory.
27
+
28
+ **Solution**: Check your triggers in config:
29
+
30
+ ```yaml
31
+ routing:
32
+ projects:
33
+ - projectId: "projectA"
34
+ triggers:
35
+ - "project a" # Case insensitive
36
+ - "projecta" # No space version
37
+ - "this is about project a"
38
+ - "project alpha" # Alternative names
39
+ ```
40
+
41
+ Also check that your project context file exists:
42
+
43
+ ```yaml
44
+ # ~/.protokoll/projects/project-a.yaml
45
+ id: project-a
46
+ name: Project A
47
+ triggers:
48
+ - "project a"
49
+ - "project alpha"
50
+ active: true
51
+ ```
52
+
53
+ ### Slow Processing
54
+
55
+ **Problem**: Each file takes too long.
56
+
57
+ **Solutions**:
58
+
59
+ 1. Use a faster model:
60
+ ```bash
61
+ protokoll --model gpt-4o-mini --input-directory ./recordings
62
+ ```
63
+
64
+ 2. Check your audio file sizes - large files take longer to transcribe.
65
+
66
+ 3. Review self-reflection reports to identify bottlenecks:
67
+ ```bash
68
+ protokoll --self-reflection --input-directory ./recordings
69
+ cat output/protokoll/*-reflection.md
70
+ ```
71
+
72
+ ### API Rate Limits
73
+
74
+ **Problem**: Getting rate limit errors.
75
+
76
+ **Solutions**:
77
+
78
+ 1. Use batch mode with fewer concurrent requests:
79
+ ```bash
80
+ protokoll --batch --input-directory ./recordings
81
+ ```
82
+
83
+ 2. Process files one at a time:
84
+ ```bash
85
+ for f in ./recordings/*.m4a; do
86
+ protokoll --input-directory "$(dirname "$f")" --file "$(basename "$f")"
87
+ sleep 2
88
+ done
89
+ ```
90
+
91
+ ### Context Not Found
92
+
93
+ **Problem**: Protokoll isn't finding your context files.
94
+
95
+ **Solution**: Check the context directory structure:
96
+
97
+ ```
98
+ ~/.protokoll/
99
+ ├── config.yaml
100
+ ├── people/
101
+ │ └── *.yaml
102
+ ├── projects/
103
+ │ └── *.yaml
104
+ ├── companies/
105
+ │ └── *.yaml
106
+ └── terms/
107
+ └── *.yaml
108
+ ```
109
+
110
+ Run with verbose mode to see context discovery:
111
+ ```bash
112
+ protokoll --verbose --input-directory ./recordings
113
+ ```
114
+
115
+ ### Audio File Not Supported
116
+
117
+ **Problem**: Protokoll skips certain audio files.
118
+
119
+ **Solution**: Check supported formats:
120
+ - mp3
121
+ - mp4
122
+ - mpeg
123
+ - mpga
124
+ - m4a
125
+ - wav
126
+ - webm
127
+
128
+ Convert unsupported formats:
129
+ ```bash
130
+ ffmpeg -i input.ogg -acodec libmp3lame output.mp3
131
+ ```
132
+
133
+ ### Large Audio Files Fail
134
+
135
+ **Problem**: Files over 25MB fail to process.
136
+
137
+ **Solution**: Protokoll automatically splits large files. If this fails:
138
+
139
+ 1. Check you have ffmpeg installed:
140
+ ```bash
141
+ ffmpeg -version
142
+ ```
143
+
144
+ 2. Manually split large files:
145
+ ```bash
146
+ ffmpeg -i large-file.m4a -f segment -segment_time 300 -c copy part%03d.m4a
147
+ ```
148
+
149
+ ### Interactive Mode Not Asking Questions
150
+
151
+ **Problem**: Running with `--interactive` but no prompts appear.
152
+
153
+ **Solution**:
154
+
155
+ 1. Make sure you're not also using `--batch`:
156
+ ```bash
157
+ # Wrong - batch overrides interactive
158
+ protokoll --interactive --batch
159
+
160
+ # Correct
161
+ protokoll --interactive
162
+ ```
163
+
164
+ 2. Check if all entities are already in context (no questions needed).
165
+
166
+ ### Transcription Quality Issues
167
+
168
+ **Problem**: Raw Whisper output has many errors.
169
+
170
+ **Solutions**:
171
+
172
+ 1. Try the newer transcription model:
173
+ ```bash
174
+ protokoll --transcription-model gpt-4o-transcribe
175
+ ```
176
+
177
+ 2. Ensure good audio quality:
178
+ - Reduce background noise
179
+ - Speak clearly
180
+ - Use a good microphone
181
+
182
+ 3. Add more context for domain-specific terms:
183
+ ```yaml
184
+ # ~/.protokoll/terms/technical.yaml
185
+ id: kubernetes
186
+ term: Kubernetes
187
+ sounds_like:
188
+ - "kube"
189
+ - "k8s"
190
+ - "kuber netties"
191
+ ```
192
+
193
+ ### Self-Reflection Reports Missing
194
+
195
+ **Problem**: No reflection reports generated.
196
+
197
+ **Solution**: Enable self-reflection explicitly:
198
+ ```bash
199
+ protokoll --self-reflection --input-directory ./recordings
200
+ ```
201
+
202
+ Check the output directory:
203
+ ```bash
204
+ ls -la output/protokoll/*-reflection.md
205
+ ```
206
+
207
+ ### Permission Errors
208
+
209
+ **Problem**: Can't write to output directory.
210
+
211
+ **Solution**: Check directory permissions:
212
+ ```bash
213
+ # Check permissions
214
+ ls -la ~/notes
215
+
216
+ # Fix permissions
217
+ chmod 755 ~/notes
218
+ ```
219
+
220
+ Or specify a different output directory:
221
+ ```bash
222
+ protokoll --output-directory ./local-output --input-directory ./recordings
223
+ ```
224
+
225
+ ## Debug Mode
226
+
227
+ For detailed troubleshooting, enable debug mode:
228
+
229
+ ```bash
230
+ protokoll --debug --verbose --input-directory ./recordings
231
+ ```
232
+
233
+ This will:
234
+ - Show detailed logging
235
+ - Keep all intermediate files
236
+ - Display API requests/responses
237
+
238
+ Check intermediate files in `output/protokoll/`:
239
+ - `*-transcript.json` - Raw Whisper output
240
+ - `*-context.json` - Context snapshot used
241
+ - `*-request.json` - LLM request sent
242
+ - `*-response.json` - LLM response received
243
+ - `*-reflection.md` - Self-reflection report
244
+
245
+ ## Getting Help
246
+
247
+ If you're still having issues:
248
+
249
+ 1. Check the [examples documentation](./examples.md)
250
+ 2. Run with `--debug --verbose` and review the output
251
+ 3. Check intermediate files for clues
252
+ 4. File an issue with:
253
+ - Command used
254
+ - Error message
255
+ - Relevant config (sanitized)
256
+ - Debug output
257
+
@@ -3,8 +3,14 @@ import react from '@vitejs/plugin-react'
3
3
 
4
4
  export default defineConfig({
5
5
  plugins: [react()],
6
- base: '/matnava/',
6
+ base: '/protokoll/', // GitHub Pages project path
7
+ publicDir: 'public',
7
8
  build: {
8
- outDir: 'dist'
9
- }
9
+ outDir: 'dist',
10
+ rollupOptions: {
11
+ output: {
12
+ manualChunks: undefined,
13
+ },
14
+ },
15
+ },
10
16
  })
package/eslint.config.mjs CHANGED
@@ -19,6 +19,7 @@ const compat = new FlatCompat({
19
19
  export default defineConfig([
20
20
  globalIgnores([
21
21
  "dist/**",
22
+ "docs/**",
22
23
  "node_modules/**",
23
24
  "**/*.test.ts",
24
25
  ]),
@@ -0,0 +1,217 @@
1
+ # Protokoll Architecture
2
+
3
+ ## System Overview
4
+
5
+ ```
6
+ ┌─────────────────────────────────────────────────────────────┐
7
+ │ PROTOKOLL │
8
+ ├─────────────────────────────────────────────────────────────┤
9
+ │ │
10
+ │ ┌─────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
11
+ │ │ INPUT │──▶│ WHISPER │──▶│ REASONING │──▶│ OUTPUT │ │
12
+ │ │ Audio │ │Transcript│ │ Model │ │ Markdown │ │
13
+ │ └─────────┘ └──────────┘ └────┬─────┘ └──────────┘ │
14
+ │ │ │
15
+ │ ┌──────────┴──────────┐ │
16
+ │ ▼ ▼ │
17
+ │ ┌─────────┐ ┌─────────┐ │
18
+ │ │ CONTEXT │ │ ROUTING │ │
19
+ │ │ System │ │ System │ │
20
+ │ └─────────┘ └─────────┘ │
21
+ │ │
22
+ └─────────────────────────────────────────────────────────────┘
23
+ ```
24
+
25
+ ## Core Components
26
+
27
+ ### 1. Context System (`src/context/`)
28
+
29
+ Manages the knowledge base using hierarchical configuration discovery:
30
+
31
+ - **Discovery**: Walks up directory tree finding `.protokoll/` directories
32
+ - **People**: Named individuals with phonetic aliases
33
+ - **Projects**: Work contexts with routing rules
34
+ - **Companies**: Organizations
35
+ - **Terms**: Domain-specific terminology
36
+
37
+ ```typescript
38
+ interface ContextInstance {
39
+ getConfig(): HierarchicalConfig;
40
+ getPerson(id: string): Person | undefined;
41
+ getProject(id: string): Project | undefined;
42
+ getCompany(id: string): Company | undefined;
43
+ getTerm(id: string): Term | undefined;
44
+ findByPhonetic(sounds_like: string): Entity | undefined;
45
+ hasContext(): boolean;
46
+ }
47
+ ```
48
+
49
+ ### 2. Routing System (`src/routing/`)
50
+
51
+ Determines where notes go using multi-signal classification:
52
+
53
+ - **Classifier**: Analyzes text for project signals
54
+ - **Router**: Builds output paths using Dreadcabinet patterns
55
+ - **Structures**: `none`, `year`, `month`, `day`
56
+
57
+ ```typescript
58
+ interface RoutingInstance {
59
+ classify(text: string): ProjectClassification[];
60
+ route(text: string, config: RoutingConfig): RouteDestination;
61
+ }
62
+ ```
63
+
64
+ ### 3. Transcription Service (`src/transcription/`)
65
+
66
+ Handles audio-to-text conversion:
67
+
68
+ - **Models**: whisper-1, gpt-4o-transcribe
69
+ - **Capabilities**: Prompting support detection
70
+ - **Formats**: JSON, text, verbose JSON
71
+
72
+ ```typescript
73
+ interface TranscriptionInstance {
74
+ transcribe(request: TranscriptionRequest): Promise<TranscriptionResult>;
75
+ getModelCapabilities(model: string): ModelCapabilities;
76
+ }
77
+ ```
78
+
79
+ ### 4. Reasoning System (`src/reasoning/`)
80
+
81
+ Integrates reasoning models for enhancement:
82
+
83
+ - **Models**: Claude, GPT-4o, GPT-5, GPT-5.2, O1
84
+ - **Strategies**: Simple, investigate-then-respond, multi-pass, adaptive
85
+ - **Token tracking**: Usage monitoring
86
+
87
+ ```typescript
88
+ interface ReasoningInstance {
89
+ complete(request: ReasoningRequest): Promise<ReasoningResponse>;
90
+ getRecommendedStrategy(model: string): ReasoningStrategy;
91
+ }
92
+ ```
93
+
94
+ ### 5. Agentic System (`src/agentic/`)
95
+
96
+ Tool-based transcription enhancement:
97
+
98
+ | Tool | Purpose |
99
+ |------|---------|
100
+ | `lookup_person` | Find person context by name |
101
+ | `lookup_project` | Find routing rules |
102
+ | `verify_spelling` | Ask user for clarification |
103
+ | `route_note` | Determine destination |
104
+ | `store_context` | Remember new information |
105
+
106
+ ```typescript
107
+ interface AgenticInstance {
108
+ execute(state: TranscriptionState): Promise<TranscriptionState>;
109
+ getAvailableTools(): TranscriptionTool[];
110
+ }
111
+ ```
112
+
113
+ ### 6. Interactive System (`src/interactive/`)
114
+
115
+ User interaction for learning:
116
+
117
+ - **Handler**: Manages clarification requests
118
+ - **Onboarding**: First-run detection
119
+ - **Session**: Tracks Q&A history
120
+
121
+ ```typescript
122
+ interface InteractiveInstance {
123
+ handleClarification(request: ClarificationRequest): Promise<ClarificationResponse>;
124
+ checkNeedsOnboarding(): OnboardingState;
125
+ }
126
+ ```
127
+
128
+ ### 7. Output System (`src/output/`)
129
+
130
+ Manages intermediate and final files:
131
+
132
+ - **Intermediate**: transcript, context, request, response, reflection, session
133
+ - **Final**: Routed markdown file
134
+ - **Cleanup**: Optional intermediate removal
135
+
136
+ ```typescript
137
+ interface OutputInstance {
138
+ createOutputPaths(audioFile, destination, hash, date): OutputPaths;
139
+ writeIntermediate(paths, type, content): Promise<string>;
140
+ writeTranscript(paths, content): Promise<string>;
141
+ }
142
+ ```
143
+
144
+ ### 8. Reflection System (`src/reflection/`)
145
+
146
+ Self-assessment and reporting (enabled by default):
147
+
148
+ - **Collector**: Gathers metrics during processing
149
+ - **Reporter**: Generates quality reports
150
+ - **Recommendations**: Suggests improvements
151
+
152
+ ```typescript
153
+ interface ReflectionInstance {
154
+ collector: CollectorInstance;
155
+ generate(audioFile, outputFile, history?, output?): ReflectionReport;
156
+ save(report, path): Promise<void>;
157
+ }
158
+ ```
159
+
160
+ ### 9. Pipeline System (`src/pipeline/`)
161
+
162
+ Orchestrates the entire processing flow:
163
+
164
+ - **Orchestrator**: Coordinates all phases
165
+ - **Phases**: locate, transcribe, complete
166
+
167
+ ```typescript
168
+ interface PipelineInstance {
169
+ process(audioFile: string): Promise<ProcessingResult>;
170
+ }
171
+ ```
172
+
173
+ ## Data Flow
174
+
175
+ ```
176
+ 1. Audio File
177
+
178
+ 2. Whisper Transcription → Raw text with errors
179
+
180
+ 3. Context Discovery → Find .protokoll/ directories
181
+
182
+ 4. Context Analysis → Identify potential names, projects
183
+
184
+ 5. Tool Execution → lookup_person, lookup_project, etc.
185
+
186
+ 6. Interactive Clarification (if enabled) → Ask user about unknowns
187
+
188
+ 7. Route Detection → Determine destination
189
+
190
+ 8. Enhanced Transcript → Clean, corrected text
191
+
192
+ 9. Output → Write to routed destination
193
+
194
+ 10. Reflection (enabled by default) → Generate self-reflection report
195
+ ```
196
+
197
+ ## File Locations
198
+
199
+ | Component | Location |
200
+ |-----------|----------|
201
+ | Global context | `~/.protokoll/` |
202
+ | Project context | `./.protokoll/` |
203
+ | Configuration | `~/.protokoll/config.yaml` |
204
+ | Intermediate files | `./output/protokoll/` |
205
+ | Final transcripts | Routed destination |
206
+
207
+ ## Dependencies
208
+
209
+ | Package | Purpose |
210
+ |---------|---------|
211
+ | `@theunwalked/dreadcabinet` | Filesystem structure patterns |
212
+ | `@theunwalked/cardigantime` | Hierarchical config discovery |
213
+ | `@riotprompt/riotprompt` | Prompt building and agentic execution |
214
+ | `openai` | Whisper and GPT APIs |
215
+ | `@anthropic-ai/sdk` | Claude API |
216
+ | `@google/generative-ai` | Gemini API |
217
+