@tutorflow/cli 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Runtime helpers shared by every command.
3
+ *
4
+ * Output mode and debug are set once on the root program and read here so
5
+ * subcommands don't need to thread options through. They are the *only*
6
+ * pieces of mutable global state in the CLI.
7
+ */
8
+ export declare function setJsonMode(on: boolean): void;
9
+ export declare function setDebugMode(on: boolean): void;
10
+ export declare function isJsonMode(): boolean;
11
+ export declare function isDebugMode(): boolean;
12
+ /**
13
+ * True when stdin is connected to a terminal. False in CI, pipes,
14
+ * AI agent sandboxes, etc. — i.e. anywhere `@clack/prompts` would crash.
15
+ */
16
+ export declare function isInteractive(): boolean;
17
+ /**
18
+ * Wrap a command action so:
19
+ * - thrown errors always set exit code 1 (or the error's `exitCode`)
20
+ * - in JSON mode, errors are serialized as { error: { message, code? } }
21
+ * - in text mode, errors are formatted via `printError`
22
+ * - stack traces are printed only when DEBUG / --debug is on
23
+ */
24
+ export declare function command<T extends unknown[]>(fn: (...args: T) => Promise<void> | void): (...args: T) => Promise<void>;
25
+ export declare class CliError extends Error {
26
+ readonly code: string;
27
+ readonly exitCode: number;
28
+ constructor(message: string, opts?: {
29
+ code?: string;
30
+ exitCode?: number;
31
+ });
32
+ }
33
+ export declare function printError(error: unknown): void;
34
+ /**
35
+ * Refuse to launch an interactive prompt in a non-TTY environment.
36
+ * `hint` should describe the flags the caller could use instead.
37
+ */
38
+ export declare function requireInteractive(hint: string): void;
39
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE9C;AAED,wBAAgB,UAAU,IAAI,OAAO,CAGpC;AAED,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,EACzC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GACvC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAS/B;AAED,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;CAK7E;AAiBD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAc/C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMrD"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * Runtime helpers shared by every command.
4
+ *
5
+ * Output mode and debug are set once on the root program and read here so
6
+ * subcommands don't need to thread options through. They are the *only*
7
+ * pieces of mutable global state in the CLI.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CliError = void 0;
11
+ exports.setJsonMode = setJsonMode;
12
+ exports.setDebugMode = setDebugMode;
13
+ exports.isJsonMode = isJsonMode;
14
+ exports.isDebugMode = isDebugMode;
15
+ exports.isInteractive = isInteractive;
16
+ exports.command = command;
17
+ exports.printError = printError;
18
+ exports.requireInteractive = requireInteractive;
19
+ let jsonMode = false;
20
+ let debugMode = false;
21
+ function setJsonMode(on) {
22
+ jsonMode = on;
23
+ }
24
+ function setDebugMode(on) {
25
+ debugMode = on;
26
+ }
27
+ function isJsonMode() {
28
+ // Env var override lets agents set this once globally without a flag.
29
+ return jsonMode || process.env.TUTORFLOW_JSON === '1';
30
+ }
31
+ function isDebugMode() {
32
+ return debugMode || process.env.DEBUG === '1' || process.env.TUTORFLOW_DEBUG === '1';
33
+ }
34
+ /**
35
+ * True when stdin is connected to a terminal. False in CI, pipes,
36
+ * AI agent sandboxes, etc. — i.e. anywhere `@clack/prompts` would crash.
37
+ */
38
+ function isInteractive() {
39
+ return Boolean(process.stdin.isTTY) && Boolean(process.stdout.isTTY);
40
+ }
41
+ /**
42
+ * Wrap a command action so:
43
+ * - thrown errors always set exit code 1 (or the error's `exitCode`)
44
+ * - in JSON mode, errors are serialized as { error: { message, code? } }
45
+ * - in text mode, errors are formatted via `printError`
46
+ * - stack traces are printed only when DEBUG / --debug is on
47
+ */
48
+ function command(fn) {
49
+ return async (...args) => {
50
+ try {
51
+ await fn(...args);
52
+ }
53
+ catch (error) {
54
+ printError(error);
55
+ process.exit(getExitCode(error));
56
+ }
57
+ };
58
+ }
59
+ class CliError extends Error {
60
+ constructor(message, opts = {}) {
61
+ super(message);
62
+ this.code = opts.code ?? 'EGENERIC';
63
+ this.exitCode = opts.exitCode ?? 1;
64
+ }
65
+ }
66
+ exports.CliError = CliError;
67
+ function getExitCode(error) {
68
+ if (error instanceof CliError)
69
+ return error.exitCode;
70
+ return 1;
71
+ }
72
+ function getErrorCode(error) {
73
+ if (error instanceof CliError)
74
+ return error.code;
75
+ return 'EGENERIC';
76
+ }
77
+ function getErrorMessage(error) {
78
+ if (error instanceof Error)
79
+ return error.message;
80
+ return String(error);
81
+ }
82
+ function printError(error) {
83
+ const message = getErrorMessage(error);
84
+ const code = getErrorCode(error);
85
+ if (isJsonMode()) {
86
+ process.stderr.write(JSON.stringify({ error: { message, code } }) + '\n');
87
+ }
88
+ else {
89
+ // chalk is loaded by callers; keep this dependency-free and use ANSI directly.
90
+ process.stderr.write(`\x1b[31m✗ ${message}\x1b[0m\n`);
91
+ }
92
+ if (isDebugMode() && error instanceof Error && error.stack) {
93
+ process.stderr.write(error.stack + '\n');
94
+ }
95
+ }
96
+ /**
97
+ * Refuse to launch an interactive prompt in a non-TTY environment.
98
+ * `hint` should describe the flags the caller could use instead.
99
+ */
100
+ function requireInteractive(hint) {
101
+ if (isInteractive())
102
+ return;
103
+ throw new CliError(`Required input not provided and stdin is not a terminal. ${hint}`, { code: 'ENOINTERACTIVE', exitCode: 2 });
104
+ }
105
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAKH,kCAEC;AAED,oCAEC;AAED,gCAGC;AAED,kCAEC;AAMD,sCAEC;AASD,0BAWC;AA4BD,gCAcC;AAMD,gDAMC;AApGD,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,SAAgB,WAAW,CAAC,EAAW;IACrC,QAAQ,GAAG,EAAE,CAAC;AAChB,CAAC;AAED,SAAgB,YAAY,CAAC,EAAW;IACtC,SAAS,GAAG,EAAE,CAAC;AACjB,CAAC;AAED,SAAgB,UAAU;IACxB,sEAAsE;IACtE,OAAO,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,GAAG,CAAC;AACxD,CAAC;AAED,SAAgB,WAAW;IACzB,OAAO,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,GAAG,CAAC;AACvF,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa;IAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED;;;;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AAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5E,CAAC;SAAM,CAAC;QACN,+EAA+E;QAC/E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,OAAO,WAAW,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,WAAW,EAAE,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC3D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,IAAI,aAAa,EAAE;QAAE,OAAO;IAC5B,MAAM,IAAI,QAAQ,CAChB,4DAA4D,IAAI,EAAE,EAClE,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,EAAE,CACxC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,23 @@
1
1
  {
2
2
  "name": "@tutorflow/cli",
3
- "version": "0.1.2",
4
- "description": "TutorFlow CLI for creating AI-powered educational content (slides, videos, courses) and evaluating student responses.",
3
+ "version": "0.2.0",
4
+ "description": "TutorFlow CLI - agent-friendly tool for creating AI-powered educational content (slides, videos, courses) and evaluating student responses. Supports --json output, env-var auth, and non-interactive use.",
5
+ "keywords": [
6
+ "tutorflow",
7
+ "education",
8
+ "edtech",
9
+ "ai",
10
+ "ai-content",
11
+ "slides",
12
+ "video",
13
+ "course",
14
+ "tutor",
15
+ "lesson",
16
+ "evaluation",
17
+ "cli",
18
+ "agent",
19
+ "automation"
20
+ ],
5
21
  "bin": {
6
22
  "tutorflow": "./dist/index.js"
7
23
  },