@redaksjon/protokoll 0.0.6
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/.nvmrc +2 -0
- package/LICENSE +190 -0
- package/README.md +88 -0
- package/dist/arguments.js +158 -0
- package/dist/arguments.js.map +1 -0
- package/dist/constants.js +82 -0
- package/dist/constants.js.map +1 -0
- package/dist/logging.js +46 -0
- package/dist/logging.js.map +1 -0
- package/dist/main.js +5 -0
- package/dist/main.js.map +1 -0
- package/dist/phases/locate.js +55 -0
- package/dist/phases/locate.js.map +1 -0
- package/dist/phases/transcribe.js +149 -0
- package/dist/phases/transcribe.js.map +1 -0
- package/dist/processor.js +35 -0
- package/dist/processor.js.map +1 -0
- package/dist/prompt/instructions/transcribe.md +46 -0
- package/dist/prompt/personas/transcriber.md +37 -0
- package/dist/prompt/transcribe.js +41 -0
- package/dist/prompt/transcribe.js.map +1 -0
- package/dist/protokoll.js +81 -0
- package/dist/protokoll.js.map +1 -0
- package/dist/util/dates.js +96 -0
- package/dist/util/dates.js.map +1 -0
- package/dist/util/general.js +39 -0
- package/dist/util/general.js.map +1 -0
- package/dist/util/media.js +103 -0
- package/dist/util/media.js.map +1 -0
- package/dist/util/openai.js +92 -0
- package/dist/util/openai.js.map +1 -0
- package/dist/util/storage.js +135 -0
- package/dist/util/storage.js.map +1 -0
- package/docs/index.html +16 -0
- package/docs/package-lock.json +1521 -0
- package/docs/package.json +21 -0
- package/docs/vite.config.js +10 -0
- package/eslint.config.mjs +82 -0
- package/nodemon.json +14 -0
- package/output/kodrdriv/250702-1905-commit-message.md +1 -0
- package/output/kodrdriv/250702-1905-commit.request.json +14 -0
- package/output/kodrdriv/250702-1905-commit.response.json +36 -0
- package/output/kodrdriv/250702-1906-commit-message.md +1 -0
- package/output/kodrdriv/250702-1907-commit-message.md +1 -0
- package/output/kodrdriv/250702-1907-commit.request.json +14 -0
- package/output/kodrdriv/250702-1907-commit.response.json +36 -0
- package/output/kodrdriv/250716-1517-review-analysis.md +39 -0
- package/output/kodrdriv/250716-1517-review-notes.md +69 -0
- package/output/kodrdriv/250716-1518-review-analysis.md +15 -0
- package/output/kodrdriv/250716-1518-review-notes.md +67 -0
- package/output/kodrdriv/250716-1523-review-analysis.md +36 -0
- package/output/kodrdriv/250716-1523-review-notes.md +87 -0
- package/output/kodrdriv/250722-1135-commit-message.md +1 -0
- package/output/kodrdriv/250722-1331-commit-message.md +1 -0
- package/output/kodrdriv/250722-1335-commit-message.md +1 -0
- package/output/kodrdriv/250722-1337-commit-message.md +1 -0
- package/output/kodrdriv/250722-1342-release-notes.md +26 -0
- package/output/kodrdriv/250722-1416-commit-message.md +3 -0
- package/output/kodrdriv/250722-1420-commit-message.md +1 -0
- package/output/kodrdriv/250722-1422-commit-message.md +1 -0
- package/output/kodrdriv/250722-1423-commit-message.md +1 -0
- package/output/kodrdriv/250722-1425-release-notes.md +41 -0
- package/output/kodrdriv/250722-1527-commit-message.md +13 -0
- package/output/kodrdriv/250722-1532-commit-message.md +1 -0
- package/output/kodrdriv/250722-1532-release-notes.md +32 -0
- package/output/kodrdriv/250722-2314-review-analysis.md +28 -0
- package/output/kodrdriv/250722-2314-review-notes.md +464 -0
- package/output/kodrdriv/250722-2315-review-analysis.md +28 -0
- package/output/kodrdriv/250722-2315-review-notes.md +477 -0
- package/output/kodrdriv/250804-1623-review-analysis.md +38 -0
- package/output/kodrdriv/250804-1623-review-notes.md +479 -0
- package/output/kodrdriv/250804-1638-review-analysis.md +56 -0
- package/output/kodrdriv/250804-1638-review-notes.md +502 -0
- package/output/kodrdriv/250812-2021-review-analysis.md +27 -0
- package/output/kodrdriv/250812-2021-review-notes.md +571 -0
- package/output/kodrdriv/250826-0700-commit-message.md +12 -0
- package/output/kodrdriv/RELEASE_NOTES.md +30 -0
- package/output/kodrdriv/RELEASE_TITLE.md +1 -0
- package/package.json +78 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.ts +124 -0
- package/vitest.config.ts +30 -0
package/.nvmrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 Simran Jafari
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Protokoll: Intelligent Audio Transcription
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Protokoll is a focused command-line utility that transforms audio recordings into intelligent, context-enhanced transcriptions. It uses AI to transcribe and enhance audio content, making it more useful and actionable.
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
Protokoll processes each audio file through a streamlined workflow:
|
|
10
|
+
|
|
11
|
+
1. **Locate**: Scans your input directory to find audio files
|
|
12
|
+
2. **Transcribe**: Uses OpenAI's Whisper to convert speech to text, enhanced with context
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Global Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @redaksjon/protokoll
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### From Source
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/tobrien/redaksjon-protokoll.git
|
|
26
|
+
cd protokoll
|
|
27
|
+
npm install
|
|
28
|
+
npm run build
|
|
29
|
+
npm link
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Set your OpenAI API key
|
|
36
|
+
export OPENAI_API_KEY='your-key-here'
|
|
37
|
+
|
|
38
|
+
# Process audio files
|
|
39
|
+
protokoll --input-directory ./recordings --output-directory ./notes
|
|
40
|
+
|
|
41
|
+
# Or use npx without installing
|
|
42
|
+
npx @redaksjon/protokoll --input-directory ./recordings --output-directory ./notes
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Output
|
|
46
|
+
|
|
47
|
+
Protokoll generates enhanced markdown notes for each processed audio file with intelligent formatting and structure.
|
|
48
|
+
|
|
49
|
+
## Command Line Options
|
|
50
|
+
|
|
51
|
+
| Option | Description | Default |
|
|
52
|
+
|--------|-------------|---------|
|
|
53
|
+
| `--input-directory <dir>` | Directory containing audio files | Required |
|
|
54
|
+
| `--output-directory <dir>` | Where to save output files | Required |
|
|
55
|
+
| `--recursive` | Process subdirectories | `false` |
|
|
56
|
+
| `--model <model>` | OpenAI model for enhancement | `gpt-4o-mini` |
|
|
57
|
+
| `--transcription-model <model>` | Whisper model | `whisper-1` |
|
|
58
|
+
| `--config-dir <dir>` | Configuration directory | `~/.protokoll` |
|
|
59
|
+
| `--context-directories <dirs>` | Directories with context files | None |
|
|
60
|
+
| `--verbose` | Enable verbose logging | `false` |
|
|
61
|
+
| `--debug` | Enable debug mode | `false` |
|
|
62
|
+
| `--dry-run` | Show what would be done | `false` |
|
|
63
|
+
|
|
64
|
+
> **Note on Model Selection**: Protokoll accepts any OpenAI model string without restrictions. You can use `gpt-5-mini`, `o1-preview`, or any other model supported by your OpenAI API. Model validation happens at the API level, ensuring future compatibility.
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Process current directory
|
|
70
|
+
protokoll --input-directory . --output-directory ./notes
|
|
71
|
+
|
|
72
|
+
# Process recursively with verbose output
|
|
73
|
+
protokoll --input-directory ./recordings --output-directory ./notes --recursive --verbose
|
|
74
|
+
|
|
75
|
+
# Use a specific model
|
|
76
|
+
protokoll --model gpt-5-mini --input-directory ./recordings
|
|
77
|
+
|
|
78
|
+
# Use a specific transcription model
|
|
79
|
+
protokoll --transcription-model whisper-1 --input-directory ./recordings
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
Apache-2.0
|
|
85
|
+
|
|
86
|
+
## Author
|
|
87
|
+
|
|
88
|
+
Tim O'Brien <tobrien@discursive.com>
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { PROGRAM_NAME, VERSION, PROTOKOLL_DEFAULTS, DEFAULT_MAX_AUDIO_SIZE } from './constants.js';
|
|
3
|
+
import { getLogger } from './logging.js';
|
|
4
|
+
import { create } from './util/storage.js';
|
|
5
|
+
|
|
6
|
+
const configure = async (dreadcabinet, cardigantime)=>{
|
|
7
|
+
const logger = getLogger();
|
|
8
|
+
let program = new Command();
|
|
9
|
+
program.name(PROGRAM_NAME).summary('Intelligent audio transcription tool with context').description('Protokoll transcribes audio files intelligently using context to improve accuracy').option('--dry-run', 'perform a dry run without saving files').option('--verbose', 'enable verbose logging').option('--debug', 'enable debug logging').option('--openai-api-key <openaiApiKey>', 'OpenAI API key').option('--transcription-model <transcriptionModel>', 'OpenAI transcription model to use').option('--model <model>', 'OpenAI model to use for transcription enhancement').option('--overrides', 'allow overrides of the default configuration').option('--context-directories [contextDirectories...]', 'directories containing context files to be included in prompts').option('--max-audio-size <maxAudioSize>', 'maximum audio file size in bytes').option('--temp-directory <tempDirectory>', 'temporary directory for processing files');
|
|
10
|
+
await dreadcabinet.configure(program);
|
|
11
|
+
program = await cardigantime.configure(program);
|
|
12
|
+
program.version(VERSION);
|
|
13
|
+
// Check if --check-config is in process.argv early
|
|
14
|
+
if (process.argv.includes('--check-config')) {
|
|
15
|
+
program.parse();
|
|
16
|
+
const cliArgs = program.opts();
|
|
17
|
+
// Use CardiganTime's built-in checkConfig method
|
|
18
|
+
await cardigantime.checkConfig(cliArgs);
|
|
19
|
+
// Return minimal config for consistency, but main processing is done
|
|
20
|
+
const config = PROTOKOLL_DEFAULTS;
|
|
21
|
+
const secureConfig = {
|
|
22
|
+
openaiApiKey: process.env.OPENAI_API_KEY
|
|
23
|
+
};
|
|
24
|
+
return [
|
|
25
|
+
config,
|
|
26
|
+
secureConfig
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
// Check if --init-config is in process.argv early
|
|
30
|
+
if (process.argv.includes('--init-config')) {
|
|
31
|
+
program.parse();
|
|
32
|
+
const cliArgs = program.opts();
|
|
33
|
+
// Use CardiganTime's built-in generateConfig method
|
|
34
|
+
await cardigantime.generateConfig(cliArgs.configDirectory || PROTOKOLL_DEFAULTS.configDirectory);
|
|
35
|
+
// Return minimal config for consistency, but main processing is done
|
|
36
|
+
const config = PROTOKOLL_DEFAULTS;
|
|
37
|
+
const secureConfig = {
|
|
38
|
+
openaiApiKey: process.env.OPENAI_API_KEY
|
|
39
|
+
};
|
|
40
|
+
return [
|
|
41
|
+
config,
|
|
42
|
+
secureConfig
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
program.parse();
|
|
46
|
+
const cliArgs = program.opts();
|
|
47
|
+
logger.info('Loaded Command Line Options: %s', JSON.stringify(cliArgs, null, 2));
|
|
48
|
+
// Get values from config file first using CardiganTime's hierarchical configuration
|
|
49
|
+
const fileValues = await cardigantime.read(cliArgs);
|
|
50
|
+
// Read the Raw values from the Dreadcabinet Command Line Arguments
|
|
51
|
+
const dreadcabinetValues = await dreadcabinet.read(cliArgs);
|
|
52
|
+
// Merge configurations: Defaults -> File -> CLI (highest precedence)
|
|
53
|
+
let mergedConfig = {
|
|
54
|
+
...PROTOKOLL_DEFAULTS,
|
|
55
|
+
...fileValues,
|
|
56
|
+
...dreadcabinetValues
|
|
57
|
+
};
|
|
58
|
+
const secureConfig = {
|
|
59
|
+
...process.env.OPENAI_API_KEY !== undefined && {
|
|
60
|
+
openaiApiKey: process.env.OPENAI_API_KEY
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// Convert maxAudioSize if it's a string AFTER merging
|
|
64
|
+
if (typeof mergedConfig.maxAudioSize === 'string') {
|
|
65
|
+
const parsedSize = parseInt(mergedConfig.maxAudioSize, 10);
|
|
66
|
+
if (!isNaN(parsedSize)) {
|
|
67
|
+
mergedConfig.maxAudioSize = parsedSize;
|
|
68
|
+
} else {
|
|
69
|
+
logger.warn(`Invalid maxAudioSize value detected after merge: '${mergedConfig.maxAudioSize}', using default: ${DEFAULT_MAX_AUDIO_SIZE}`);
|
|
70
|
+
mergedConfig.maxAudioSize = DEFAULT_MAX_AUDIO_SIZE; // Use Protokoll default if parsing fails
|
|
71
|
+
}
|
|
72
|
+
} else if (mergedConfig.maxAudioSize === undefined) {
|
|
73
|
+
// If still undefined after all merges, apply Protokoll default
|
|
74
|
+
mergedConfig.maxAudioSize = DEFAULT_MAX_AUDIO_SIZE;
|
|
75
|
+
}
|
|
76
|
+
// Apply Dreadcabinet defaults
|
|
77
|
+
mergedConfig = dreadcabinet.applyDefaults(mergedConfig);
|
|
78
|
+
const config = mergedConfig;
|
|
79
|
+
// Validate Dreadcabinet final config
|
|
80
|
+
dreadcabinet.validate(config);
|
|
81
|
+
// Validate Protokoll final config
|
|
82
|
+
await validateConfig(config);
|
|
83
|
+
await validateSecureConfig(secureConfig);
|
|
84
|
+
logger.info('Final configuration: %s', JSON.stringify(config, null, 2));
|
|
85
|
+
return [
|
|
86
|
+
config,
|
|
87
|
+
secureConfig
|
|
88
|
+
];
|
|
89
|
+
};
|
|
90
|
+
async function validateSecureConfig(config) {
|
|
91
|
+
const logger = getLogger();
|
|
92
|
+
if (!config.openaiApiKey) {
|
|
93
|
+
config.openaiApiKey = process.env.OPENAI_API_KEY;
|
|
94
|
+
if (!config.openaiApiKey) {
|
|
95
|
+
throw new Error('OpenAI API key is required. Provide it via CLI (--openai-api-key), config file, or OPENAI_API_KEY environment variable.');
|
|
96
|
+
}
|
|
97
|
+
logger.debug("Using OpenAI API key from environment variable.");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function validateConfig(config) {
|
|
101
|
+
const logger = getLogger();
|
|
102
|
+
// Validate that models are provided (but don't restrict to specific allowlist)
|
|
103
|
+
validateModelPresence(config.model, true, 'model');
|
|
104
|
+
validateModelPresence(config.transcriptionModel, true, 'transcriptionModel');
|
|
105
|
+
if (config.contextDirectories && config.contextDirectories.length > 0) {
|
|
106
|
+
await validateContextDirectories(config.contextDirectories);
|
|
107
|
+
} else {
|
|
108
|
+
logger.debug("No context directories provided.");
|
|
109
|
+
config.contextDirectories = [];
|
|
110
|
+
}
|
|
111
|
+
if (config.tempDirectory) {
|
|
112
|
+
await validateTempDirectory(config.tempDirectory);
|
|
113
|
+
} else {
|
|
114
|
+
throw new Error('Temp directory is required.');
|
|
115
|
+
}
|
|
116
|
+
if (typeof config.maxAudioSize !== 'number' || config.maxAudioSize <= 0) {
|
|
117
|
+
throw new Error(`Invalid maxAudioSize: ${config.maxAudioSize}. Must be a positive number.`);
|
|
118
|
+
}
|
|
119
|
+
logger.info("Final configuration validated successfully.");
|
|
120
|
+
}
|
|
121
|
+
function validateModelPresence(model, required, modelOptionName) {
|
|
122
|
+
const logger = getLogger();
|
|
123
|
+
logger.debug(`Validating model presence for ${modelOptionName}: ${model} (Required: ${required})`);
|
|
124
|
+
if (!model) {
|
|
125
|
+
throw new Error(`Model for ${modelOptionName} is required`);
|
|
126
|
+
}
|
|
127
|
+
if (model && model.trim() === '') {
|
|
128
|
+
throw new Error(`Model for ${modelOptionName} cannot be empty`);
|
|
129
|
+
}
|
|
130
|
+
// Note: We no longer validate against a static allowlist
|
|
131
|
+
// The actual model validation will happen when the API call is made
|
|
132
|
+
// This allows for dynamic model discovery and future model additions
|
|
133
|
+
}
|
|
134
|
+
async function validateContextDirectories(contextDirectories) {
|
|
135
|
+
const logger = getLogger();
|
|
136
|
+
logger.debug(`Validating context directories: ${contextDirectories.join(', ')}`);
|
|
137
|
+
const storage = create({
|
|
138
|
+
log: logger.info.bind(logger)
|
|
139
|
+
});
|
|
140
|
+
for (const directory of contextDirectories){
|
|
141
|
+
if (!await storage.isDirectoryReadable(directory)) {
|
|
142
|
+
throw new Error(`Context directory does not exist or is not readable: ${directory}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function validateTempDirectory(tempDirectory) {
|
|
147
|
+
const logger = getLogger();
|
|
148
|
+
logger.debug(`Validating temp directory: ${tempDirectory}`);
|
|
149
|
+
const storage = create({
|
|
150
|
+
log: logger.info.bind(logger)
|
|
151
|
+
});
|
|
152
|
+
if (!await storage.isDirectoryWritable(tempDirectory)) {
|
|
153
|
+
throw new Error(`Temp directory does not exist or is not writable: ${tempDirectory}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export { configure };
|
|
158
|
+
//# sourceMappingURL=arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arguments.js","sources":["../src/arguments.ts"],"sourcesContent":["import * as Dreadcabinet from \"@theunwalked/dreadcabinet\";\nimport * as Cardigantime from '@theunwalked/cardigantime';\nimport { Command } from \"commander\";\nimport {\n PROTOKOLL_DEFAULTS,\n DEFAULT_MAX_AUDIO_SIZE,\n PROGRAM_NAME,\n VERSION\n} from \"@/constants\";\nimport { Args, Config, SecureConfig } from \"@/protokoll\";\nimport { getLogger } from \"@/logging\";\nimport * as Storage from \"@/util/storage\";\n\nexport const configure = async (dreadcabinet: Dreadcabinet.DreadCabinet, cardigantime: Cardigantime.Cardigantime<any>): Promise<[Config, SecureConfig]> => {\n const logger = getLogger();\n\n let program = new Command();\n program\n .name(PROGRAM_NAME)\n .summary('Intelligent audio transcription tool with context')\n .description('Protokoll transcribes audio files intelligently using context to improve accuracy')\n .option('--dry-run', 'perform a dry run without saving files')\n .option('--verbose', 'enable verbose logging')\n .option('--debug', 'enable debug logging')\n .option('--openai-api-key <openaiApiKey>', 'OpenAI API key')\n .option('--transcription-model <transcriptionModel>', 'OpenAI transcription model to use')\n .option('--model <model>', 'OpenAI model to use for transcription enhancement')\n .option('--overrides', 'allow overrides of the default configuration')\n .option('--context-directories [contextDirectories...]', 'directories containing context files to be included in prompts')\n .option('--max-audio-size <maxAudioSize>', 'maximum audio file size in bytes')\n .option('--temp-directory <tempDirectory>', 'temporary directory for processing files')\n\n await dreadcabinet.configure(program);\n program = await cardigantime.configure(program);\n program.version(VERSION);\n\n // Check if --check-config is in process.argv early\n if (process.argv.includes('--check-config')) {\n program.parse();\n const cliArgs: Args = program.opts<Args>();\n\n // Use CardiganTime's built-in checkConfig method\n await cardigantime.checkConfig(cliArgs);\n\n // Return minimal config for consistency, but main processing is done\n const config: Config = PROTOKOLL_DEFAULTS as Config;\n const secureConfig: SecureConfig = { openaiApiKey: process.env.OPENAI_API_KEY };\n return [config, secureConfig];\n }\n\n // Check if --init-config is in process.argv early\n if (process.argv.includes('--init-config')) {\n program.parse();\n const cliArgs: Args = program.opts<Args>();\n\n // Use CardiganTime's built-in generateConfig method\n await cardigantime.generateConfig(cliArgs.configDirectory || PROTOKOLL_DEFAULTS.configDirectory);\n\n // Return minimal config for consistency, but main processing is done\n const config: Config = PROTOKOLL_DEFAULTS as Config;\n const secureConfig: SecureConfig = { openaiApiKey: process.env.OPENAI_API_KEY };\n return [config, secureConfig];\n }\n\n program.parse();\n\n const cliArgs: Args = program.opts<Args>();\n logger.info('Loaded Command Line Options: %s', JSON.stringify(cliArgs, null, 2));\n\n // Get values from config file first using CardiganTime's hierarchical configuration\n const fileValues = await cardigantime.read(cliArgs);\n\n // Read the Raw values from the Dreadcabinet Command Line Arguments\n const dreadcabinetValues = await dreadcabinet.read(cliArgs);\n\n // Merge configurations: Defaults -> File -> CLI (highest precedence)\n let mergedConfig: Partial<Config> = {\n ...PROTOKOLL_DEFAULTS, // Start with Protokoll defaults\n ...fileValues, // Apply file values (overwrites defaults)\n ...dreadcabinetValues, // Apply all CLI args last (highest precedence)\n } as Partial<Config>;\n\n const secureConfig: SecureConfig = {\n ...(process.env.OPENAI_API_KEY !== undefined && { openaiApiKey: process.env.OPENAI_API_KEY }), // Apply Env vars\n } as SecureConfig;\n\n // Convert maxAudioSize if it's a string AFTER merging\n if (typeof mergedConfig.maxAudioSize === 'string') {\n const parsedSize = parseInt(mergedConfig.maxAudioSize, 10);\n if (!isNaN(parsedSize)) {\n mergedConfig.maxAudioSize = parsedSize;\n } else {\n logger.warn(`Invalid maxAudioSize value detected after merge: '${mergedConfig.maxAudioSize}', using default: ${DEFAULT_MAX_AUDIO_SIZE}`);\n mergedConfig.maxAudioSize = DEFAULT_MAX_AUDIO_SIZE; // Use Protokoll default if parsing fails\n }\n } else if (mergedConfig.maxAudioSize === undefined) {\n // If still undefined after all merges, apply Protokoll default\n mergedConfig.maxAudioSize = DEFAULT_MAX_AUDIO_SIZE;\n }\n\n // Apply Dreadcabinet defaults\n mergedConfig = dreadcabinet.applyDefaults(mergedConfig) as Partial<Config>;\n\n const config = mergedConfig as Config;\n\n // Validate Dreadcabinet final config\n dreadcabinet.validate(config);\n\n // Validate Protokoll final config\n await validateConfig(config);\n await validateSecureConfig(secureConfig);\n\n logger.info('Final configuration: %s', JSON.stringify(config, null, 2));\n return [config, secureConfig];\n}\n\nasync function validateSecureConfig(config: SecureConfig): Promise<void> {\n const logger = getLogger();\n if (!config.openaiApiKey) {\n config.openaiApiKey = process.env.OPENAI_API_KEY;\n\n if (!config.openaiApiKey) {\n throw new Error('OpenAI API key is required. Provide it via CLI (--openai-api-key), config file, or OPENAI_API_KEY environment variable.');\n }\n logger.debug(\"Using OpenAI API key from environment variable.\");\n }\n}\n\nasync function validateConfig(config: Config): Promise<void> {\n const logger = getLogger();\n\n // Validate that models are provided (but don't restrict to specific allowlist)\n validateModelPresence(config.model, true, 'model');\n validateModelPresence(config.transcriptionModel, true, 'transcriptionModel');\n\n if (config.contextDirectories && config.contextDirectories.length > 0) {\n await validateContextDirectories(config.contextDirectories);\n } else {\n logger.debug(\"No context directories provided.\");\n config.contextDirectories = [];\n }\n\n if (config.tempDirectory) {\n await validateTempDirectory(config.tempDirectory);\n } else {\n throw new Error('Temp directory is required.');\n }\n\n if (typeof config.maxAudioSize !== 'number' || config.maxAudioSize <= 0) {\n throw new Error(`Invalid maxAudioSize: ${config.maxAudioSize}. Must be a positive number.`);\n }\n\n logger.info(\"Final configuration validated successfully.\");\n}\n\nfunction validateModelPresence(model: string | undefined, required: boolean, modelOptionName: string) {\n const logger = getLogger();\n logger.debug(`Validating model presence for ${modelOptionName}: ${model} (Required: ${required})`);\n if (required && !model) {\n throw new Error(`Model for ${modelOptionName} is required`);\n }\n\n if (model && model.trim() === '') {\n throw new Error(`Model for ${modelOptionName} cannot be empty`);\n }\n\n // Note: We no longer validate against a static allowlist\n // The actual model validation will happen when the API call is made\n // This allows for dynamic model discovery and future model additions\n}\n\nasync function validateContextDirectories(contextDirectories: string[]) {\n const logger = getLogger();\n logger.debug(`Validating context directories: ${contextDirectories.join(', ')}`);\n const storage = Storage.create({ log: logger.info.bind(logger) });\n for (const directory of contextDirectories) {\n if (!await storage.isDirectoryReadable(directory)) {\n throw new Error(`Context directory does not exist or is not readable: ${directory}`);\n }\n }\n}\n\n\n\nasync function validateTempDirectory(tempDirectory: string) {\n const logger = getLogger();\n logger.debug(`Validating temp directory: ${tempDirectory}`);\n const storage = Storage.create({ log: logger.info.bind(logger) });\n if (!await storage.isDirectoryWritable(tempDirectory)) {\n throw new Error(`Temp directory does not exist or is not writable: ${tempDirectory}`);\n }\n}\n"],"names":["configure","dreadcabinet","cardigantime","logger","getLogger","program","Command","name","PROGRAM_NAME","summary","description","option","version","VERSION","process","argv","includes","parse","cliArgs","opts","checkConfig","config","PROTOKOLL_DEFAULTS","secureConfig","openaiApiKey","env","OPENAI_API_KEY","generateConfig","configDirectory","info","JSON","stringify","fileValues","read","dreadcabinetValues","mergedConfig","undefined","maxAudioSize","parsedSize","parseInt","isNaN","warn","DEFAULT_MAX_AUDIO_SIZE","applyDefaults","validate","validateConfig","validateSecureConfig","Error","debug","validateModelPresence","model","transcriptionModel","contextDirectories","length","validateContextDirectories","tempDirectory","validateTempDirectory","required","modelOptionName","trim","join","storage","Storage","log","bind","directory","isDirectoryReadable","isDirectoryWritable"],"mappings":";;;;;AAaO,MAAMA,SAAAA,GAAY,OAAOC,YAAAA,EAAyCC,YAAAA,GAAAA;AACrE,IAAA,MAAMC,MAAAA,GAASC,SAAAA,EAAAA;AAEf,IAAA,IAAIC,UAAU,IAAIC,OAAAA,EAAAA;IAClBD,OAAAA,CACKE,IAAI,CAACC,YAAAA,CAAAA,CACLC,OAAO,CAAC,mDAAA,CAAA,CACRC,WAAW,CAAC,mFAAA,CA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AgB;AACnD,QAAA,MAAM,IAAIR,KAAAA,CAAM,CAAC,kDAAkD,EAAEQ,aAAAA,CAAAA,CAAe,CAAA;AACxF,IAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
|
|
3
|
+
const VERSION = '0.0.6 (working/bb55012 T:v0.0.6-dev.0 2026-01-10 17:18:45 -0800) darwin arm64 v24.8.0';
|
|
4
|
+
const PROGRAM_NAME = 'protokoll';
|
|
5
|
+
const DEFAULT_DIFF = true;
|
|
6
|
+
const DEFAULT_LOG = false;
|
|
7
|
+
const DEFAULT_TIMEZONE = 'Etc/UTC';
|
|
8
|
+
const DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS = 'YYYY-M-D-HHmmss';
|
|
9
|
+
const DEFAULT_VERBOSE = false;
|
|
10
|
+
const DEFAULT_DRY_RUN = false;
|
|
11
|
+
const DEFAULT_DEBUG = false;
|
|
12
|
+
const DEFAULT_CONTENT_TYPES = [
|
|
13
|
+
'diff'
|
|
14
|
+
];
|
|
15
|
+
const DEFAULT_INPUT_DIRECTORY = './';
|
|
16
|
+
const DEFAULT_OUTPUT_DIRECTORY = './';
|
|
17
|
+
const DEFAULT_AUDIO_EXTENSIONS = [
|
|
18
|
+
'mp3',
|
|
19
|
+
'mp4',
|
|
20
|
+
'mpeg',
|
|
21
|
+
'mpga',
|
|
22
|
+
'm4a',
|
|
23
|
+
'wav',
|
|
24
|
+
'webm'
|
|
25
|
+
];
|
|
26
|
+
const ALLOWED_AUDIO_EXTENSIONS = [
|
|
27
|
+
'mp3',
|
|
28
|
+
'mp4',
|
|
29
|
+
'mpeg',
|
|
30
|
+
'mpga',
|
|
31
|
+
'm4a',
|
|
32
|
+
'wav',
|
|
33
|
+
'webm'
|
|
34
|
+
];
|
|
35
|
+
const DEFAULT_OUTPUT_STRUCTURE = 'month';
|
|
36
|
+
const DEFAULT_OUTPUT_FILENAME_OPTIONS = [
|
|
37
|
+
'date',
|
|
38
|
+
'time',
|
|
39
|
+
'subject'
|
|
40
|
+
];
|
|
41
|
+
const ALLOWED_OUTPUT_STRUCTURES = [
|
|
42
|
+
'none',
|
|
43
|
+
'year',
|
|
44
|
+
'month',
|
|
45
|
+
'day'
|
|
46
|
+
];
|
|
47
|
+
const ALLOWED_OUTPUT_FILENAME_OPTIONS = [
|
|
48
|
+
'date',
|
|
49
|
+
'time',
|
|
50
|
+
'subject'
|
|
51
|
+
];
|
|
52
|
+
const DEFAULT_CONFIG_DIR = `./.${PROGRAM_NAME}`;
|
|
53
|
+
const DEFAULT_PERSONAS_DIR = `/personas`;
|
|
54
|
+
const DEFAULT_PERSONA_TRANSCRIBER_FILE = `${DEFAULT_PERSONAS_DIR}/transcriber.md`;
|
|
55
|
+
const DEFAULT_INSTRUCTIONS_DIR = `/instructions`;
|
|
56
|
+
const DEFAULT_INSTRUCTIONS_TRANSCRIBE_FILE = `${DEFAULT_INSTRUCTIONS_DIR}/transcribe.md`;
|
|
57
|
+
// Note: We no longer maintain a static allowlist of models
|
|
58
|
+
// This allows for dynamic model discovery and future model additions
|
|
59
|
+
// Users can specify any model supported by their OpenAI API
|
|
60
|
+
const DEFAULT_TRANSCRIPTION_MODEL = 'whisper-1';
|
|
61
|
+
const DEFAULT_MODEL = 'gpt-4o-mini';
|
|
62
|
+
const DEFAULT_OVERRIDES = false;
|
|
63
|
+
const DEFAULT_MAX_AUDIO_SIZE = 26214400; // 25MB in bytes
|
|
64
|
+
const DEFAULT_TEMP_DIRECTORY = os.tmpdir(); // Use OS default temp directory
|
|
65
|
+
// Define Protokoll-specific defaults
|
|
66
|
+
const PROTOKOLL_DEFAULTS = {
|
|
67
|
+
dryRun: DEFAULT_DRY_RUN,
|
|
68
|
+
verbose: DEFAULT_VERBOSE,
|
|
69
|
+
debug: DEFAULT_DEBUG,
|
|
70
|
+
diff: DEFAULT_DIFF,
|
|
71
|
+
log: DEFAULT_LOG,
|
|
72
|
+
transcriptionModel: DEFAULT_TRANSCRIPTION_MODEL,
|
|
73
|
+
model: DEFAULT_MODEL,
|
|
74
|
+
contentTypes: DEFAULT_CONTENT_TYPES,
|
|
75
|
+
overrides: DEFAULT_OVERRIDES,
|
|
76
|
+
maxAudioSize: DEFAULT_MAX_AUDIO_SIZE,
|
|
77
|
+
tempDirectory: DEFAULT_TEMP_DIRECTORY || os.tmpdir(),
|
|
78
|
+
configDirectory: DEFAULT_CONFIG_DIR
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { ALLOWED_AUDIO_EXTENSIONS, ALLOWED_OUTPUT_FILENAME_OPTIONS, ALLOWED_OUTPUT_STRUCTURES, DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_CONFIG_DIR, DEFAULT_CONTENT_TYPES, DEFAULT_DEBUG, DEFAULT_DIFF, DEFAULT_DRY_RUN, DEFAULT_INPUT_DIRECTORY, DEFAULT_INSTRUCTIONS_DIR, DEFAULT_INSTRUCTIONS_TRANSCRIBE_FILE, DEFAULT_LOG, DEFAULT_MAX_AUDIO_SIZE, DEFAULT_MODEL, DEFAULT_OUTPUT_DIRECTORY, DEFAULT_OUTPUT_FILENAME_OPTIONS, DEFAULT_OUTPUT_STRUCTURE, DEFAULT_OVERRIDES, DEFAULT_PERSONAS_DIR, DEFAULT_PERSONA_TRANSCRIBER_FILE, DEFAULT_TEMP_DIRECTORY, DEFAULT_TIMEZONE, DEFAULT_TRANSCRIPTION_MODEL, DEFAULT_VERBOSE, PROGRAM_NAME, PROTOKOLL_DEFAULTS, VERSION };
|
|
82
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["import os from 'os';\nimport { FilenameOption } from '@theunwalked/dreadcabinet';\nimport { FilesystemStructure } from '@theunwalked/dreadcabinet';\n\nexport const VERSION = '__VERSION__ (__GIT_BRANCH__/__GIT_COMMIT__ __GIT_TAGS__ __GIT_COMMIT_DATE__) __SYSTEM_INFO__';\nexport const PROGRAM_NAME = 'protokoll';\nexport const DEFAULT_CHARACTER_ENCODING = 'utf-8';\nexport const DEFAULT_BINARY_TO_TEXT_ENCODING = 'base64';\nexport const DEFAULT_DIFF = true;\nexport const DEFAULT_LOG = false;\nexport const DEFAULT_TIMEZONE = 'Etc/UTC';\nexport const DATE_FORMAT_MONTH_DAY = 'M-D';\nexport const DATE_FORMAT_YEAR = 'YYYY';\nexport const DATE_FORMAT_YEAR_MONTH = 'YYYY-M';\nexport const DATE_FORMAT_YEAR_MONTH_DAY = 'YYYY-M-D';\nexport const DATE_FORMAT_YEAR_MONTH_DAY_SLASH = 'YYYY/M/D';\nexport const DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES = 'YYYY-M-D-HHmm';\nexport const DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS = 'YYYY-M-D-HHmmss';\nexport const DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS_MILLISECONDS = 'YYYY-M-D-HHmmss.SSS';\nexport const DATE_FORMAT_MONTH = 'M';\nexport const DATE_FORMAT_DAY = 'D';\nexport const DATE_FORMAT_HOURS = 'HHmm';\nexport const DATE_FORMAT_MINUTES = 'mm';\nexport const DATE_FORMAT_SECONDS = 'ss';\nexport const DATE_FORMAT_MILLISECONDS = 'SSS';\nexport const DEFAULT_VERBOSE = false;\nexport const DEFAULT_DRY_RUN = false;\nexport const DEFAULT_DEBUG = false;\nexport const DEFAULT_CONTENT_TYPES = ['diff'];\nexport const DEFAULT_RECURSIVE = false;\nexport const DEFAULT_INPUT_DIRECTORY = './';\nexport const DEFAULT_OUTPUT_DIRECTORY = './';\n\nexport const DEFAULT_AUDIO_EXTENSIONS = ['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm'];\n\nexport const ALLOWED_CONTENT_TYPES = ['log', 'diff'];\nexport const ALLOWED_AUDIO_EXTENSIONS = ['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm'];\n\nexport const DEFAULT_OUTPUT_STRUCTURE = 'month' as FilesystemStructure;\nexport const DEFAULT_OUTPUT_FILENAME_OPTIONS = ['date', 'time', 'subject'] as FilenameOption[];\n\nexport const ALLOWED_OUTPUT_STRUCTURES = ['none', 'year', 'month', 'day'] as FilesystemStructure[];\nexport const ALLOWED_OUTPUT_FILENAME_OPTIONS = ['date', 'time', 'subject'] as FilenameOption[];\n\nexport const DEFAULT_CONFIG_DIR = `./.${PROGRAM_NAME}`;\nexport const DEFAULT_PROCESSED_DIR = './processed';\n\nexport const DEFAULT_PERSONAS_DIR = `/personas`;\n\nexport const DEFAULT_PERSONA_TRANSCRIBER_FILE = `${DEFAULT_PERSONAS_DIR}/transcriber.md`;\n\nexport const DEFAULT_INSTRUCTIONS_DIR = `/instructions`;\n\nexport const DEFAULT_INSTRUCTIONS_TRANSCRIBE_FILE = `${DEFAULT_INSTRUCTIONS_DIR}/transcribe.md`;\n\n// Note: We no longer maintain a static allowlist of models\n// This allows for dynamic model discovery and future model additions\n// Users can specify any model supported by their OpenAI API\n\nexport const DEFAULT_TRANSCRIPTION_MODEL = 'whisper-1';\nexport const DEFAULT_MODEL = 'gpt-4o-mini';\n\nexport const DEFAULT_OVERRIDES = false;\nexport const DEFAULT_MAX_AUDIO_SIZE = 26214400; // 25MB in bytes\nexport const DEFAULT_TEMP_DIRECTORY = os.tmpdir(); // Use OS default temp directory\n\n// Define Protokoll-specific defaults\nexport const PROTOKOLL_DEFAULTS = {\n dryRun: DEFAULT_DRY_RUN,\n verbose: DEFAULT_VERBOSE,\n debug: DEFAULT_DEBUG,\n diff: DEFAULT_DIFF,\n log: DEFAULT_LOG,\n transcriptionModel: DEFAULT_TRANSCRIPTION_MODEL,\n model: DEFAULT_MODEL,\n contentTypes: DEFAULT_CONTENT_TYPES,\n overrides: DEFAULT_OVERRIDES,\n maxAudioSize: DEFAULT_MAX_AUDIO_SIZE,\n tempDirectory: DEFAULT_TEMP_DIRECTORY || os.tmpdir(),\n configDirectory: DEFAULT_CONFIG_DIR,\n};\n"],"names":["VERSION","PROGRAM_NAME","DEFAULT_DIFF","DEFAULT_LOG","DEFAULT_TIMEZONE","DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS","DEFAULT_VERBOSE","DEFAULT_DRY_RUN","DEFAULT_DEBUG","DEFAULT_CONTENT_TYPES","DEFAULT_INPUT_DIRECTORY","DEFAULT_OUTPUT_DIRECTORY","DEFAULT_AUDIO_EXTENSIONS","ALLOWED_AUDIO_EXTENSIONS","DEFAULT_OUTPUT_STRUCTURE","DEFAULT_OUTPUT_FILENAME_OPTIONS","ALLOWED_OUTPUT_STRUCTURES","ALLOWED_OUTPUT_FILENAME_OPTIONS","DEFAULT_CONFIG_DIR","DEFAULT_PERSONAS_DIR","DEFAULT_PERSONA_TRANSCRIBER_FILE","DEFAULT_INSTRUCTIONS_DIR","DEFAULT_INSTRUCTIONS_TRANSCRIBE_FILE","DEFAULT_TRANSCRIPTION_MODEL","DEFAULT_MODEL","DEFAULT_OVERRIDES","DEFAULT_MAX_AUDIO_SIZE","DEFAULT_TEMP_DIRECTORY","os","tmpdir","PROTOKOLL_DEFAULTS","dryRun","verbose","debug","diff","log","transcriptionModel","model","contentTypes","overrides","maxAudioSize","tempDirectory","configDirectory"],"mappings":";;AAIO,MAAMA,UAAU;AAChB,MAAMC,eAAe;AAGrB,MAAMC,eAAe;AACrB,MAAMC,cAAc;AACpB,MAAMC,mBAAmB;AAOzB,MAAMC,mDAAmD;AAQzD,MAAMC,kBAAkB;AACxB,MAAMC,kBAAkB;AACxB,MAAMC,gBAAgB;MAChBC,qBAAAA,GAAwB;AAAC,IAAA;;AAE/B,MAAMC,0BAA0B;AAChC,MAAMC,2BAA2B;MAE3BC,wBAAAA,GAA2B;AAAC,IAAA,KAAA;AAAO,IAAA,KAAA;AAAO,IAAA,MAAA;AAAQ,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A,EAAed,sBAAAA,IAA0BC,GAAGC,MAAM,EAAA;IAClDa,eAAAA,EAAiBxB;AACrB;;;;"}
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import winston from 'winston';
|
|
2
|
+
import { DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS, PROGRAM_NAME } from './constants.js';
|
|
3
|
+
|
|
4
|
+
const createLogger = (level = 'info')=>{
|
|
5
|
+
let format = winston.format.combine(winston.format.timestamp({
|
|
6
|
+
format: DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS
|
|
7
|
+
}), winston.format.errors({
|
|
8
|
+
stack: true
|
|
9
|
+
}), winston.format.splat(), winston.format.json());
|
|
10
|
+
let transports = [
|
|
11
|
+
new winston.transports.Console({
|
|
12
|
+
format: winston.format.combine(winston.format.colorize(), winston.format.printf(({ timestamp, level, message, ...meta })=>{
|
|
13
|
+
const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : '';
|
|
14
|
+
return `${timestamp} ${level}: ${message}${metaStr}`;
|
|
15
|
+
}))
|
|
16
|
+
})
|
|
17
|
+
];
|
|
18
|
+
if (level === 'info') {
|
|
19
|
+
format = winston.format.combine(winston.format.errors({
|
|
20
|
+
stack: true
|
|
21
|
+
}), winston.format.splat());
|
|
22
|
+
transports = [
|
|
23
|
+
new winston.transports.Console({
|
|
24
|
+
format: winston.format.combine(winston.format.colorize(), winston.format.printf(({ level, message })=>{
|
|
25
|
+
return `${level}: ${message}`;
|
|
26
|
+
}))
|
|
27
|
+
})
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
return winston.createLogger({
|
|
31
|
+
level,
|
|
32
|
+
format,
|
|
33
|
+
defaultMeta: {
|
|
34
|
+
service: PROGRAM_NAME
|
|
35
|
+
},
|
|
36
|
+
transports
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
let logger = createLogger();
|
|
40
|
+
const setLogLevel = (level)=>{
|
|
41
|
+
logger = createLogger(level);
|
|
42
|
+
};
|
|
43
|
+
const getLogger = ()=>logger;
|
|
44
|
+
|
|
45
|
+
export { getLogger, setLogLevel };
|
|
46
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sources":["../src/logging.ts"],"sourcesContent":["import winston from 'winston';\nimport { DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS, PROGRAM_NAME } from './constants';\n\nexport interface LogContext {\n [key: string]: any;\n}\n\nconst createLogger = (level: string = 'info') => {\n\n let format = winston.format.combine(\n winston.format.timestamp({ format: DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS }),\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n winston.format.json()\n );\n\n let transports = [\n new winston.transports.Console({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ timestamp, level, message, ...meta }) => {\n const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : '';\n return `${timestamp} ${level}: ${message}${metaStr}`;\n })\n )\n })\n ];\n\n if (level === 'info') {\n format = winston.format.combine(\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n );\n\n transports = [\n new winston.transports.Console({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ level, message }) => {\n return `${level}: ${message}`;\n })\n )\n })\n ];\n }\n\n return winston.createLogger({\n level,\n format,\n defaultMeta: { service: PROGRAM_NAME },\n transports,\n });\n};\n\nlet logger = createLogger();\n\nexport const setLogLevel = (level: string) => {\n logger = createLogger(level);\n};\n\nexport const getLogger = () => logger; "],"names":["createLogger","level","format","winston","combine","timestamp","DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS","errors","stack","splat","json","transports","Console","colorize","printf","message","meta","metaStr","Object","keys","length","JSON","stringify","defaultMeta","service","PROGRAM_NAME","logger","setLogLevel","getLogger"],"mappings":";;;AAOA,MAAMA,YAAAA,GA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,CAACC,OAAO,CAAC;gBAC3BV,MAAAA,EAAQC,OAAAA,CAAQD,MAAM,CAACE,OAAO,CAC1BD,OAAAA,CAAQD,MAAM,CAACW,QAAQ,EAAA,EACvBV,QAAQD,MAAM,CAACY,MAAM,CAAC,CAAC,EAAEb,KAAK,EAAEc,OAAO,EAAE,GAAA;AACrC,oBAAA,OAAO,CAAA,EAAGd,KAAAA,CAAM,EAAE,EAAEc,OAAAA,CAAAA,CAAS;AACjC,gBAAA,CAAA,CAAA;AAER,aAAA;AACH,SAAA;AACL,IAAA;IAEA,OAAOZ,OAAAA,CAAQH,YAAY,CAAC;AACxBC,QAAAA,KAAAA;AACAC,QAAAA,MAAAA;QACAqB,WAAAA,EAAa;YAAEC,OAAAA,EAASC;AAAa,SAAA;AACrCd,QAAAA;AACJ,KAAA,CAAA;AACJ,CAAA;AAEA,IAAIe,MAAAA,GAAS1B,YAAAA,EAAAA;AAEN,MAAM2B,cAAc,CAAC1B,KAAAA,GAAAA;AACxByB,IAAAA,MAAAA,GAAS1B,YAAAA,CAAaC,KAAAA,CAAAA;AAC1B;AAEO,MAAM2B,SAAAA,GAAY,IAAMF;;;;"}
|
package/dist/main.js
ADDED
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../src/main.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { main } from '@/protokoll';\n\nmain();"],"names":["main"],"mappings":";;;AAGAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
|