@zgeoff/skill-gate 0.2.0 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/skill-gate",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A Claude Code PreToolUse hook that denies an edit until the session loads the skills the path needs, and warns on a Bash command that writes a gated path",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -35,7 +35,7 @@
35
35
  "typecheck": "tsc"
36
36
  },
37
37
  "dependencies": {
38
- "@zgeoff/std": "0.2.0",
38
+ "@zgeoff/std": "0.3.0",
39
39
  "ts-pattern": "5.9.0"
40
40
  },
41
41
  "devDependencies": {
@@ -1,6 +1,12 @@
1
1
  import { formatSkillList } from './format-skill-list.ts';
2
2
  import type { SkillGateHookOutput, SkillGateOutputContext, SkillGatePlan } from './types.ts';
3
3
 
4
+ const RULES_PATH = '.claude/skill-gate.json';
5
+
6
+ // A gated path changes only through these tools; the gate warns on a Bash write and blocks an edit.
7
+ const EDIT_TOOLS_NOTE =
8
+ 'Change a gated path only with Edit, Write or MultiEdit, never through Bash.';
9
+
4
10
  // Builds the PreToolUse hook output for one edit, or null when the edit goes ahead in silence. A
5
11
  // missing skill denies the edit. A broken rules file or a rule that names a skill the repo does
6
12
  // not have never denies: it warns the user and the agent, and the edit goes ahead.
@@ -46,9 +52,3 @@ export function buildSkillGateOutput(
46
52
  hookSpecificOutput: { hookEventName: 'PreToolUse', additionalContext: warning },
47
53
  };
48
54
  }
49
-
50
- const RULES_PATH = '.claude/skill-gate.json';
51
-
52
- // A gated path changes only through these tools; the gate warns on a Bash write and blocks an edit.
53
- const EDIT_TOOLS_NOTE =
54
- 'Change a gated path only with Edit, Write or MultiEdit, never through Bash.';
@@ -58,6 +58,10 @@ function collectEntrySkills(entry: unknown, succeeded: readonly string[]): reado
58
58
  );
59
59
  }
60
60
 
61
+ // A slash command opens the user message with its tags, in either order.
62
+ const SLASH_COMMAND_PATTERN =
63
+ /^\s*(?:<command-message>[^<]*<\/command-message>\s*)?<command-name>\/(?<skill>[^<\s]+)<\/command-name>/u;
64
+
61
65
  function findSlashCommand(entry: unknown): string | undefined {
62
66
  if (
63
67
  !isRecord(entry) ||
@@ -75,10 +79,6 @@ function findSlashCommand(entry: unknown): string | undefined {
75
79
  : undefined;
76
80
  }
77
81
 
78
- // A slash command opens the user message with its tags, in either order.
79
- const SLASH_COMMAND_PATTERN =
80
- /^\s*(?:<command-message>[^<]*<\/command-message>\s*)?<command-name>\/(?<skill>[^<\s]+)<\/command-name>/u;
81
-
82
82
  function collectSkillCall(
83
83
  block: Readonly<Record<string, unknown>>,
84
84
  succeeded: readonly string[],
@@ -9,13 +9,13 @@ export function collectWrittenPaths(command: string): readonly WrittenPath[] {
9
9
  return collectTextPaths(command, '');
10
10
  }
11
11
 
12
- // `dir` is the working directory relative to the command's start, or null after a `cd` the parser
13
- // cannot follow, which leaves only absolute paths.
14
- function collectTextPaths(text: string, dir: string | null): WrittenPath[] {
12
+ // `directory` is the working directory relative to the command's start, or null after a
13
+ // `cd` the parser cannot follow, which leaves only absolute paths.
14
+ function collectTextPaths(text: string, directory: string | null): WrittenPath[] {
15
15
  const commands = parseShellCommands(text) ?? [];
16
16
  const paths: WrittenPath[] = [];
17
17
  const parentDirs: (string | null)[] = [];
18
- let current = dir;
18
+ let current = directory;
19
19
 
20
20
  for (const command of commands) {
21
21
  const enteredFrom = current;
@@ -34,10 +34,10 @@ function collectTextPaths(text: string, dir: string | null): WrittenPath[] {
34
34
  return paths;
35
35
  }
36
36
 
37
- function collectCommandPaths(command: ShellCommand, dir: string | null): WrittenPath[] {
37
+ function collectCommandPaths(command: ShellCommand, directory: string | null): WrittenPath[] {
38
38
  const redirected = command.redirects
39
39
  .filter((redirect) => isWriteRedirect(redirect.operator, redirect.target))
40
- .flatMap((redirect) => resolveWordPath(redirect.target, dir));
40
+ .flatMap((redirect) => resolveWordPath(redirect.target, directory));
41
41
 
42
42
  const words = getProgramWords(command.words);
43
43
  const [program] = words;
@@ -49,7 +49,7 @@ function collectCommandPaths(command: ShellCommand, dir: string | null): Written
49
49
  const name = path.basename(program.text);
50
50
  const args = words.slice(1);
51
51
 
52
- return [...redirected, ...collectProgramPaths(name, args, command.stdin, dir)];
52
+ return [...redirected, ...collectProgramPaths(name, args, command.stdin, directory)];
53
53
  }
54
54
 
55
55
  const WRITE_REDIRECTS = new Set(['>', '>>', '>|', '&>', '&>>', '<>']);
@@ -59,7 +59,7 @@ function isWriteRedirect(operator: string, target: ShellWord): boolean {
59
59
  return WRITE_REDIRECTS.has(operator) || (operator === '>&' && !/^(?:\d+|-)$/u.test(target.text));
60
60
  }
61
61
 
62
- function resolveWordPath(word: ShellWord | undefined, dir: string | null): WrittenPath[] {
62
+ function resolveWordPath(word: ShellWord | undefined, directory: string | null): WrittenPath[] {
63
63
  if (word === undefined || !word.literal || word.text === '' || word.text === '-') {
64
64
  return [];
65
65
  }
@@ -68,7 +68,7 @@ function resolveWordPath(word: ShellWord | undefined, dir: string | null): Writt
68
68
  return [{ path: word.text }];
69
69
  }
70
70
 
71
- return dir === null ? [] : [{ path: path.join(dir, word.text) }];
71
+ return directory === null ? [] : [{ path: path.join(directory, word.text) }];
72
72
  }
73
73
 
74
74
  const ASSIGNMENT = /^[A-Za-z_]\w*=/u;
@@ -120,49 +120,48 @@ const INTERPRETERS = new Set(['python', 'python3', 'node', 'bun', 'deno', 'ruby'
120
120
  // Python, Ruby and Perl start a comment with `#`, where JavaScript has `//`, and Python's `//` is
121
121
  // floor division.
122
122
  const JS_RUNTIMES = new Set(['node', 'bun', 'deno']);
123
+ const SED_SCRIPT_FLAGS = new Set(['e', 'f']);
123
124
 
124
125
  function collectProgramPaths(
125
126
  name: string,
126
127
  args: readonly ShellWord[],
127
128
  stdin: string | null,
128
- dir: string | null,
129
+ directory: string | null,
129
130
  ): WrittenPath[] {
130
131
  if (name === 'sed' || name === 'gsed') {
131
132
  return collectInPlacePaths(args, SED_SCRIPT_FLAGS).flatMap((word) =>
132
- resolveWordPath(word, dir),
133
+ resolveWordPath(word, directory),
133
134
  );
134
135
  }
135
136
 
136
137
  if (name === 'perl') {
137
- return collectPerlPaths(args, stdin, dir);
138
+ return collectPerlPaths(args, stdin, directory);
138
139
  }
139
140
 
140
141
  if (name === 'tee') {
141
- return collectOperands(args).flatMap((word) => resolveWordPath(word, dir));
142
+ return collectOperands(args).flatMap((word) => resolveWordPath(word, directory));
142
143
  }
143
144
 
144
145
  if (name === 'cp' || name === 'mv') {
145
- return collectCopyPaths(args, dir);
146
+ return collectCopyPaths(args, directory);
146
147
  }
147
148
 
148
149
  if (SHELLS.has(name)) {
149
150
  const script = findShellScript(args, stdin);
150
151
 
151
- return script === null ? [] : collectTextPaths(script, dir);
152
+ return script === null ? [] : collectTextPaths(script, directory);
152
153
  }
153
154
 
154
155
  if (INTERPRETERS.has(name)) {
155
156
  const script = findInlineScript(args, stdin);
156
157
  const commentStart = JS_RUNTIMES.has(name) ? '//' : '#';
157
158
 
158
- return script === null ? [] : collectScriptPaths(script, commentStart, dir);
159
+ return script === null ? [] : collectScriptPaths(script, commentStart, directory);
159
160
  }
160
161
 
161
162
  return [];
162
163
  }
163
164
 
164
- const SED_SCRIPT_FLAGS = new Set(['e', 'f']);
165
-
166
165
  // Collects the files that `sed -i` or `perl -i` rewrites: every operand after the script, or every
167
166
  // operand when an `-e` or `-f` flag gives the script. Without `-i` (or `--in-place`), it writes
168
167
  // nothing.
@@ -236,98 +235,17 @@ const PERL_SCRIPT_FLAGS = new Set(['e', 'E']);
236
235
  function collectPerlPaths(
237
236
  args: readonly ShellWord[],
238
237
  stdin: string | null,
239
- dir: string | null,
238
+ directory: string | null,
240
239
  ): WrittenPath[] {
241
240
  const inPlace = collectInPlacePaths(args, PERL_SCRIPT_FLAGS);
242
241
 
243
242
  if (inPlace.length > 0) {
244
- return inPlace.flatMap((word) => resolveWordPath(word, dir));
243
+ return inPlace.flatMap((word) => resolveWordPath(word, directory));
245
244
  }
246
245
 
247
246
  const script = findInlineScript(args, stdin);
248
247
 
249
- return script === null ? [] : collectScriptPaths(script, '#', dir);
250
- }
251
-
252
- function collectOperands(args: readonly ShellWord[]): readonly ShellWord[] {
253
- return args.filter((arg) => !arg.text.startsWith('-'));
254
- }
255
-
256
- // Collects where `cp` or `mv` writes: into the `-t` directory, into the destination when several
257
- // sources or a trailing slash make it a directory, and otherwise onto the destination, or into it
258
- // when it turns out to be a directory.
259
- function collectCopyPaths(args: readonly ShellWord[], dir: string | null): WrittenPath[] {
260
- const operands: ShellWord[] = [];
261
- let targetDir: ShellWord | undefined;
262
- let optionsEnded = false;
263
-
264
- for (let index = 0; index < args.length; index += 1) {
265
- const arg = args[index];
266
-
267
- if (arg === undefined) {
268
- break;
269
- }
270
-
271
- if (optionsEnded || !arg.text.startsWith('-') || arg.text === '-') {
272
- operands.push(arg);
273
- } else if (arg.text === '--') {
274
- optionsEnded = true;
275
- } else if (arg.text.startsWith('--target-directory=')) {
276
- targetDir = { ...arg, text: arg.text.slice('--target-directory='.length) };
277
- } else if (arg.text === '--target-directory' || /^-[^-]*t$/u.test(arg.text)) {
278
- targetDir = args[index + 1];
279
- index += 1;
280
- } else if (arg.text === '-S' || arg.text === '--suffix') {
281
- index += 1;
282
- }
283
- }
284
-
285
- if (targetDir !== undefined) {
286
- return collectIntoDirPaths(targetDir, operands, dir);
287
- }
288
-
289
- const destination = operands.at(-1);
290
- const sources = operands.slice(0, -1);
291
- const [source] = sources;
292
-
293
- if (destination === undefined || source === undefined) {
294
- return [];
295
- }
296
-
297
- if (sources.length > 1 || destination.text.endsWith('/')) {
298
- return collectIntoDirPaths(destination, sources, dir);
299
- }
300
-
301
- const fileName = source.literal ? path.basename(source.text) : undefined;
302
-
303
- return resolveWordPath(destination, dir).map((written) =>
304
- fileName === undefined ? written : { path: written.path, fileName },
305
- );
306
- }
307
-
308
- function collectIntoDirPaths(
309
- target: ShellWord,
310
- sources: readonly ShellWord[],
311
- dir: string | null,
312
- ): WrittenPath[] {
313
- return resolveWordPath(target, dir).flatMap((written) =>
314
- sources
315
- .filter((source) => source.literal)
316
- .map((source) => ({ path: path.join(written.path, path.basename(source.text)) })),
317
- );
318
- }
319
-
320
- // Finds the script a shell runs: the operand after `-c`, or the here document when the shell has
321
- // no script file.
322
- function findShellScript(args: readonly ShellWord[], stdin: string | null): string | null {
323
- const hasCommandFlag = args.some((arg) => /^-[A-Za-z]*c[A-Za-z]*$/u.test(arg.text));
324
- const [script] = collectOperands(args);
325
-
326
- if (hasCommandFlag) {
327
- return script?.literal === true ? script.text : null;
328
- }
329
-
330
- return script === undefined ? stdin : null;
248
+ return script === null ? [] : collectScriptPaths(script, '#', directory);
331
249
  }
332
250
 
333
251
  const INLINE_FLAGS = new Set(['-c', '-e', '-E', '--eval', '-p', '--print', 'eval']);
@@ -360,7 +278,7 @@ const SCRIPT_WRITE_PATTERNS = [
360
278
  function collectScriptPaths(
361
279
  script: string,
362
280
  commentStart: string,
363
- dir: string | null,
281
+ directory: string | null,
364
282
  ): WrittenPath[] {
365
283
  const textRanges = collectScriptTextRanges(script, commentStart);
366
284
 
@@ -374,7 +292,7 @@ function collectScriptPaths(
374
292
 
375
293
  return isText || /[$*?{]/u.test(written)
376
294
  ? []
377
- : resolveWordPath({ text: written, literal: true }, dir);
295
+ : resolveWordPath({ text: written, literal: true }, directory);
378
296
  }),
379
297
  );
380
298
  }
@@ -430,11 +348,92 @@ function getQuoteEndOrScriptEnd(script: string, start: number): number {
430
348
  return Math.min(index + 1, script.length);
431
349
  }
432
350
 
433
- function resolveNextDir(command: ShellCommand, dir: string | null): string | null {
351
+ function collectOperands(args: readonly ShellWord[]): readonly ShellWord[] {
352
+ return args.filter((arg) => !arg.text.startsWith('-'));
353
+ }
354
+
355
+ // Collects where `cp` or `mv` writes: into the `-t` directory, into the destination when several
356
+ // sources or a trailing slash make it a directory, and otherwise onto the destination, or into it
357
+ // when it turns out to be a directory.
358
+ function collectCopyPaths(args: readonly ShellWord[], directory: string | null): WrittenPath[] {
359
+ const operands: ShellWord[] = [];
360
+ let targetDir: ShellWord | undefined;
361
+ let optionsEnded = false;
362
+
363
+ for (let index = 0; index < args.length; index += 1) {
364
+ const arg = args[index];
365
+
366
+ if (arg === undefined) {
367
+ break;
368
+ }
369
+
370
+ if (optionsEnded || !arg.text.startsWith('-') || arg.text === '-') {
371
+ operands.push(arg);
372
+ } else if (arg.text === '--') {
373
+ optionsEnded = true;
374
+ } else if (arg.text.startsWith('--target-directory=')) {
375
+ targetDir = { ...arg, text: arg.text.slice('--target-directory='.length) };
376
+ } else if (arg.text === '--target-directory' || /^-[^-]*t$/u.test(arg.text)) {
377
+ targetDir = args[index + 1];
378
+ index += 1;
379
+ } else if (arg.text === '-S' || arg.text === '--suffix') {
380
+ index += 1;
381
+ }
382
+ }
383
+
384
+ if (targetDir !== undefined) {
385
+ return collectIntoDirPaths(targetDir, operands, directory);
386
+ }
387
+
388
+ const destination = operands.at(-1);
389
+ const sources = operands.slice(0, -1);
390
+ const [source] = sources;
391
+
392
+ if (destination === undefined || source === undefined) {
393
+ return [];
394
+ }
395
+
396
+ if (sources.length > 1 || destination.text.endsWith('/')) {
397
+ return collectIntoDirPaths(destination, sources, directory);
398
+ }
399
+
400
+ const fileName = source.literal ? path.basename(source.text) : undefined;
401
+
402
+ return resolveWordPath(destination, directory).map((written) =>
403
+ fileName === undefined ? written : { path: written.path, fileName },
404
+ );
405
+ }
406
+
407
+ function collectIntoDirPaths(
408
+ target: ShellWord,
409
+ sources: readonly ShellWord[],
410
+ directory: string | null,
411
+ ): WrittenPath[] {
412
+ return resolveWordPath(target, directory).flatMap((written) =>
413
+ sources
414
+ .filter((source) => source.literal)
415
+ .map((source) => ({ path: path.join(written.path, path.basename(source.text)) })),
416
+ );
417
+ }
418
+
419
+ // Finds the script a shell runs: the operand after `-c`, or the here document when the shell has
420
+ // no script file.
421
+ function findShellScript(args: readonly ShellWord[], stdin: string | null): string | null {
422
+ const hasCommandFlag = args.some((arg) => /^-[A-Za-z]*c[A-Za-z]*$/u.test(arg.text));
423
+ const [script] = collectOperands(args);
424
+
425
+ if (hasCommandFlag) {
426
+ return script?.literal === true ? script.text : null;
427
+ }
428
+
429
+ return script === undefined ? stdin : null;
430
+ }
431
+
432
+ function resolveNextDir(command: ShellCommand, directory: string | null): string | null {
434
433
  const [program, ...args] = command.words;
435
434
 
436
435
  if (program?.text !== 'cd') {
437
- return dir;
436
+ return directory;
438
437
  }
439
438
 
440
439
  const [target] = collectOperands(args);
@@ -447,5 +446,5 @@ function resolveNextDir(command: ShellCommand, dir: string | null): string | nul
447
446
  return target.text;
448
447
  }
449
448
 
450
- return dir === null ? null : path.join(dir, target.text);
449
+ return directory === null ? null : path.join(directory, target.text);
451
450
  }
@@ -132,22 +132,12 @@ const OPERATORS = [
132
132
  ')',
133
133
  ];
134
134
 
135
- const SEPARATORS = new Set(['&&', '||', '|&', ';;', '|', '&', ';']);
136
-
137
- function buildOperatorToken(operator: string): ShellToken {
138
- if (operator === '(' || operator === ')') {
139
- return { kind: 'subshell', opens: operator === '(' };
140
- }
141
-
142
- return SEPARATORS.has(operator)
143
- ? { kind: 'separator', operator }
144
- : { kind: 'redirect', operator };
145
- }
146
-
147
135
  function findOperator(text: string, index: number): string | null {
148
136
  return OPERATORS.find((operator) => text.startsWith(operator, index)) ?? null;
149
137
  }
150
138
 
139
+ const GLOB_CHARS = '*?[{';
140
+
151
141
  function parseShellWord(
152
142
  text: string,
153
143
  start: number,
@@ -299,8 +289,6 @@ function getDepthChange(char: string): number {
299
289
  return ')}'.includes(char) ? -1 : 0;
300
290
  }
301
291
 
302
- const GLOB_CHARS = '*?[{';
303
-
304
292
  function isFileDescriptor(word: ShellWord): boolean {
305
293
  return word.literal && /^\d+$/u.test(word.text);
306
294
  }
@@ -309,6 +297,18 @@ function isRedirectStart(char: string): boolean {
309
297
  return char === '<' || char === '>';
310
298
  }
311
299
 
300
+ const SEPARATORS = new Set(['&&', '||', '|&', ';;', '|', '&', ';']);
301
+
302
+ function buildOperatorToken(operator: string): ShellToken {
303
+ if (operator === '(' || operator === ')') {
304
+ return { kind: 'subshell', opens: operator === '(' };
305
+ }
306
+
307
+ return SEPARATORS.has(operator)
308
+ ? { kind: 'separator', operator }
309
+ : { kind: 'redirect', operator };
310
+ }
311
+
312
312
  interface CommandDraft {
313
313
  words: ShellWord[];
314
314
  redirects: ShellRedirect[];
@@ -317,6 +317,8 @@ interface CommandDraft {
317
317
  leaves: number;
318
318
  }
319
319
 
320
+ const LIST_ENDS = new Set(['&', ';', ';;', '\n']);
321
+
320
322
  // A subshell's opening counts toward the next command's `enters`, and its closing toward the last
321
323
  // command's `leaves`. A pipe side and a list sent to the background run in their own subshell too,
322
324
  // so a caller can restore the state they changed, such as the directory.
@@ -422,8 +424,6 @@ function buildShellCommands(tokens: readonly ShellToken[]): readonly ShellComman
422
424
  return commands;
423
425
  }
424
426
 
425
- const LIST_ENDS = new Set(['&', ';', ';;', '\n']);
426
-
427
427
  function buildCommandDraft(): CommandDraft {
428
428
  return { words: [], redirects: [], stdin: null, enters: 0, leaves: 0 };
429
429
  }
@@ -25,11 +25,6 @@ function parseJSON(text: string): unknown {
25
25
  }
26
26
  }
27
27
 
28
- // An empty string would match every path as an ignore segment, and no session can load it as a skill.
29
- function isStringArray(value: unknown): value is string[] {
30
- return Array.isArray(value) && value.every((item) => typeof item === 'string' && item !== '');
31
- }
32
-
33
28
  function parseRulesRecord(value: Readonly<Record<string, unknown>>): SkillGateRulesResult {
34
29
  const ignore = value['ignore'] ?? [];
35
30
 
@@ -46,6 +41,11 @@ function parseRulesRecord(value: Readonly<Record<string, unknown>>): SkillGateRu
46
41
  return parseGates(ignore, gates);
47
42
  }
48
43
 
44
+ // An empty string would match every path as an ignore segment, and no session can load it as a skill.
45
+ function isStringArray(value: unknown): value is string[] {
46
+ return Array.isArray(value) && value.every((item) => typeof item === 'string' && item !== '');
47
+ }
48
+
49
49
  function parseGates(ignore: readonly string[], gates: readonly unknown[]): SkillGateRulesResult {
50
50
  const parsed = gates.map((gate, index) => parseGate(gate, index));
51
51
  const error = parsed.find((gate) => typeof gate === 'string');
@@ -108,10 +108,6 @@ function parseHookInput(value: unknown): HookInput | null {
108
108
  };
109
109
  }
110
110
 
111
- function isOutsideProject(fromProject: string): boolean {
112
- return fromProject === '..' || fromProject.startsWith('../') || path.isAbsolute(fromProject);
113
- }
114
-
115
111
  interface BashCheck {
116
112
  readonly hookInput: HookInput;
117
113
  readonly command: string;
@@ -179,6 +175,10 @@ function readWrittenPath(cwd: string, written: WrittenPath): string {
179
175
  return isDirectory ? path.join(absolute, written.fileName) : absolute;
180
176
  }
181
177
 
178
+ function isOutsideProject(fromProject: string): boolean {
179
+ return fromProject === '..' || fromProject.startsWith('../') || path.isAbsolute(fromProject);
180
+ }
181
+
182
182
  function toProjectPath(projectDir: string, absolute: string): string {
183
183
  return path.relative(projectDir, absolute).split(path.sep).join('/');
184
184
  }
@@ -199,6 +199,18 @@ async function readAvailableSkills(skillsDir: string): Promise<readonly string[]
199
199
  return skills;
200
200
  }
201
201
 
202
+ async function readTranscript(transcriptPath: string | null): Promise<string> {
203
+ if (transcriptPath === null) {
204
+ return '';
205
+ }
206
+
207
+ const transcriptFile = Bun.file(transcriptPath);
208
+
209
+ const exists = await transcriptFile.exists();
210
+
211
+ return exists ? transcriptFile.text() : '';
212
+ }
213
+
202
214
  // A subagent's call carries the main session's transcript_path plus its own agent_id, and Claude
203
215
  // Code keeps its transcript at <session>/subagents/agent-<agent_id>.jsonl. An agent_id that is not
204
216
  // a plain name resolves to no transcript, so the edit is denied.
@@ -216,18 +228,6 @@ function resolveSessionTranscriptPath(edit: HookInput): string | null {
216
228
  return path.join(sessionDir, 'subagents', `agent-${edit.agentID}.jsonl`);
217
229
  }
218
230
 
219
- async function readTranscript(transcriptPath: string | null): Promise<string> {
220
- if (transcriptPath === null) {
221
- return '';
222
- }
223
-
224
- const transcriptFile = Bun.file(transcriptPath);
225
-
226
- const exists = await transcriptFile.exists();
227
-
228
- return exists ? transcriptFile.text() : '';
229
- }
230
-
231
231
  function printOutput(output: object | null): void {
232
232
  if (output !== null) {
233
233
  console.log(JSON.stringify(output));