ai-hero-cli 0.0.5 → 0.0.7

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 (153) hide show
  1. package/README.md +133 -2
  2. package/bin.js +67704 -0
  3. package/package.json +7 -50
  4. package/LICENSE +0 -21
  5. package/dist/bin.d.ts +0 -2
  6. package/dist/bin.js +0 -4
  7. package/dist/bin.js.map +0 -1
  8. package/dist/command.d.ts +0 -2
  9. package/dist/command.js +0 -114
  10. package/dist/command.js.map +0 -1
  11. package/dist/config.d.ts +0 -15
  12. package/dist/config.js +0 -52
  13. package/dist/config.js.map +0 -1
  14. package/dist/model.d.ts +0 -6
  15. package/dist/model.js +0 -26
  16. package/dist/model.js.map +0 -1
  17. package/docs/tsconfig/allowArbitraryExtensions.md +0 -38
  18. package/docs/tsconfig/allowImportingTsExtensions.md +0 -9
  19. package/docs/tsconfig/allowJs.md +0 -41
  20. package/docs/tsconfig/allowSyntheticDefaultImports.md +0 -56
  21. package/docs/tsconfig/allowUmdGlobalAccess.md +0 -8
  22. package/docs/tsconfig/allowUnreachableCode.md +0 -40
  23. package/docs/tsconfig/allowUnusedLabels.md +0 -23
  24. package/docs/tsconfig/alwaysStrict.md +0 -8
  25. package/docs/tsconfig/assumeChangesOnlyAffectDirectDependencies.md +0 -8
  26. package/docs/tsconfig/baseUrl.md +0 -26
  27. package/docs/tsconfig/charset.md +0 -7
  28. package/docs/tsconfig/checkJs.md +0 -40
  29. package/docs/tsconfig/clean.md +0 -6
  30. package/docs/tsconfig/composite.md +0 -17
  31. package/docs/tsconfig/customConditions.md +0 -41
  32. package/docs/tsconfig/declaration.md +0 -32
  33. package/docs/tsconfig/declarationDir.md +0 -36
  34. package/docs/tsconfig/declarationMap.md +0 -9
  35. package/docs/tsconfig/diagnostics.md +0 -8
  36. package/docs/tsconfig/disableFilenameBasedTypeAcquisition.md +0 -16
  37. package/docs/tsconfig/disableReferencedProjectLoad.md +0 -8
  38. package/docs/tsconfig/disableSizeLimit.md +0 -6
  39. package/docs/tsconfig/disableSolutionSearching.md +0 -8
  40. package/docs/tsconfig/disableSourceOfProjectReferenceRedirect.md +0 -7
  41. package/docs/tsconfig/downlevelIteration.md +0 -100
  42. package/docs/tsconfig/emitBOM.md +0 -8
  43. package/docs/tsconfig/emitDeclarationOnly.md +0 -11
  44. package/docs/tsconfig/emitDecoratorMetadata.md +0 -81
  45. package/docs/tsconfig/enable.md +0 -14
  46. package/docs/tsconfig/erasableSyntaxOnly.md +0 -65
  47. package/docs/tsconfig/esModuleInterop.md +0 -74
  48. package/docs/tsconfig/exactOptionalPropertyTypes.md +0 -37
  49. package/docs/tsconfig/exclude.md +0 -11
  50. package/docs/tsconfig/excludeDirectories.md +0 -14
  51. package/docs/tsconfig/excludeFiles.md +0 -14
  52. package/docs/tsconfig/experimentalDecorators.md +0 -11
  53. package/docs/tsconfig/explainFiles.md +0 -54
  54. package/docs/tsconfig/extendedDiagnostics.md +0 -9
  55. package/docs/tsconfig/extends.md +0 -49
  56. package/docs/tsconfig/fallbackPolling.md +0 -11
  57. package/docs/tsconfig/files.md +0 -26
  58. package/docs/tsconfig/force.md +0 -6
  59. package/docs/tsconfig/forceConsistentCasingInFileNames.md +0 -10
  60. package/docs/tsconfig/generateCpuProfile.md +0 -15
  61. package/docs/tsconfig/generateTrace.md +0 -6
  62. package/docs/tsconfig/importHelpers.md +0 -46
  63. package/docs/tsconfig/importsNotUsedAsValues.md +0 -16
  64. package/docs/tsconfig/include.md +0 -66
  65. package/docs/tsconfig/incremental.md +0 -10
  66. package/docs/tsconfig/inlineSourceMap.md +0 -35
  67. package/docs/tsconfig/inlineSources.md +0 -36
  68. package/docs/tsconfig/isolatedDeclarations.md +0 -8
  69. package/docs/tsconfig/isolatedModules.md +0 -77
  70. package/docs/tsconfig/jsx.md +0 -111
  71. package/docs/tsconfig/jsxFactory.md +0 -43
  72. package/docs/tsconfig/jsxFragmentFactory.md +0 -69
  73. package/docs/tsconfig/jsxImportSource.md +0 -95
  74. package/docs/tsconfig/keyofStringsOnly.md +0 -8
  75. package/docs/tsconfig/lib.md +0 -75
  76. package/docs/tsconfig/libReplacement.md +0 -22
  77. package/docs/tsconfig/listEmittedFiles.md +0 -42
  78. package/docs/tsconfig/listFiles.md +0 -40
  79. package/docs/tsconfig/locale.md +0 -26
  80. package/docs/tsconfig/mapRoot.md +0 -18
  81. package/docs/tsconfig/maxNodeModuleJsDepth.md +0 -11
  82. package/docs/tsconfig/module.md +0 -125
  83. package/docs/tsconfig/moduleDetection.md +0 -15
  84. package/docs/tsconfig/moduleResolution.md +0 -13
  85. package/docs/tsconfig/moduleSuffixes.md +0 -26
  86. package/docs/tsconfig/newLine.md +0 -6
  87. package/docs/tsconfig/noCheck.md +0 -6
  88. package/docs/tsconfig/noEmit.md +0 -10
  89. package/docs/tsconfig/noEmitHelpers.md +0 -38
  90. package/docs/tsconfig/noEmitOnError.md +0 -8
  91. package/docs/tsconfig/noErrorTruncation.md +0 -45
  92. package/docs/tsconfig/noFallthroughCasesInSwitch.md +0 -22
  93. package/docs/tsconfig/noImplicitAny.md +0 -26
  94. package/docs/tsconfig/noImplicitOverride.md +0 -66
  95. package/docs/tsconfig/noImplicitReturns.md +0 -17
  96. package/docs/tsconfig/noImplicitThis.md +0 -28
  97. package/docs/tsconfig/noImplicitUseStrict.md +0 -7
  98. package/docs/tsconfig/noLib.md +0 -9
  99. package/docs/tsconfig/noPropertyAccessFromIndexSignature.md +0 -57
  100. package/docs/tsconfig/noResolve.md +0 -9
  101. package/docs/tsconfig/noStrictGenericChecks.md +0 -20
  102. package/docs/tsconfig/noUncheckedIndexedAccess.md +0 -53
  103. package/docs/tsconfig/noUncheckedSideEffectImports.md +0 -52
  104. package/docs/tsconfig/noUnusedLocals.md +0 -15
  105. package/docs/tsconfig/noUnusedParameters.md +0 -15
  106. package/docs/tsconfig/out.md +0 -9
  107. package/docs/tsconfig/outDir.md +0 -39
  108. package/docs/tsconfig/outFile.md +0 -11
  109. package/docs/tsconfig/paths.md +0 -39
  110. package/docs/tsconfig/plugins.md +0 -17
  111. package/docs/tsconfig/preserveConstEnums.md +0 -58
  112. package/docs/tsconfig/preserveSymlinks.md +0 -10
  113. package/docs/tsconfig/preserveValueImports.md +0 -18
  114. package/docs/tsconfig/preserveWatchOutput.md +0 -6
  115. package/docs/tsconfig/pretty.md +0 -7
  116. package/docs/tsconfig/reactNamespace.md +0 -6
  117. package/docs/tsconfig/references.md +0 -9
  118. package/docs/tsconfig/removeComments.md +0 -33
  119. package/docs/tsconfig/resolveJsonModule.md +0 -44
  120. package/docs/tsconfig/resolvePackageJsonExports.md +0 -8
  121. package/docs/tsconfig/resolvePackageJsonImports.md +0 -8
  122. package/docs/tsconfig/rewriteRelativeImportExtensions.md +0 -8
  123. package/docs/tsconfig/rootDir.md +0 -66
  124. package/docs/tsconfig/rootDirs.md +0 -66
  125. package/docs/tsconfig/skipDefaultLibCheck.md +0 -6
  126. package/docs/tsconfig/skipLibCheck.md +0 -19
  127. package/docs/tsconfig/sourceMap.md +0 -39
  128. package/docs/tsconfig/sourceRoot.md +0 -18
  129. package/docs/tsconfig/stopBuildOnErrors.md +0 -6
  130. package/docs/tsconfig/strict.md +0 -11
  131. package/docs/tsconfig/strictBindCallApply.md +0 -34
  132. package/docs/tsconfig/strictBuiltinIteratorReturn.md +0 -6
  133. package/docs/tsconfig/strictFunctionTypes.md +0 -55
  134. package/docs/tsconfig/strictNullChecks.md +0 -58
  135. package/docs/tsconfig/strictPropertyInitialization.md +0 -29
  136. package/docs/tsconfig/stripInternal.md +0 -60
  137. package/docs/tsconfig/suppressExcessPropertyErrors.md +0 -16
  138. package/docs/tsconfig/suppressImplicitAnyIndexErrors.md +0 -25
  139. package/docs/tsconfig/synchronousWatchDirectory.md +0 -14
  140. package/docs/tsconfig/target.md +0 -18
  141. package/docs/tsconfig/traceResolution.md +0 -7
  142. package/docs/tsconfig/tsBuildInfoFile.md +0 -17
  143. package/docs/tsconfig/typeAcquisition.md +0 -37
  144. package/docs/tsconfig/typeRoots.md +0 -21
  145. package/docs/tsconfig/types.md +0 -40
  146. package/docs/tsconfig/useDefineForClassFields.md +0 -10
  147. package/docs/tsconfig/useUnknownInCatchVariables.md +0 -21
  148. package/docs/tsconfig/verbatimModuleSyntax.md +0 -148
  149. package/docs/tsconfig/verbose.md +0 -6
  150. package/docs/tsconfig/watchDirectory.md +0 -10
  151. package/docs/tsconfig/watchFile.md +0 -12
  152. package/prompts/hows-my-tsconfig-score.md +0 -29
  153. package/prompts/hows-my-tsconfig.md +0 -75
package/package.json CHANGED
@@ -1,56 +1,13 @@
1
1
  {
2
2
  "name": "ai-hero-cli",
3
- "version": "0.0.5",
4
- "bin": {
5
- "ai-hero": "./dist/bin.js"
6
- },
7
- "description": "A CLI for AI Hero",
8
- "keywords": [
9
- "ai",
10
- "hero",
11
- "cli"
12
- ],
13
- "homepage": "https://github.com/mattpocock/ai-hero-cli",
14
- "bugs": {
15
- "url": "https://github.com/mattpocock/ai-hero-cli/issues"
16
- },
17
- "author": "Matt Pocock <team@aihero.dev> (https://aihero.dev)",
3
+ "version": "0.0.7",
4
+ "type": "module",
5
+ "description": "The CLI used to run exercises for the AI Hero course",
6
+ "bin": "bin.js",
18
7
  "repository": {
19
8
  "type": "git",
20
- "url": "git+https://github.com/mattpocock/ai-hero-cli.git"
9
+ "url": "https://github.com/mattpocock/ai-hero-cli"
21
10
  },
22
- "license": "MIT",
23
- "files": [
24
- "dist",
25
- "docs",
26
- "prompts"
27
- ],
28
- "type": "module",
29
- "devDependencies": {
30
- "@arethetypeswrong/cli": "^0.18.2",
31
- "@changesets/cli": "^2.29.4",
32
- "@types/node": "^24.0.3",
33
- "prettier": "^3.5.3",
34
- "typescript": "^5.8.3",
35
- "vitest": "^3.2.4"
36
- },
37
- "dependencies": {
38
- "@ai-sdk/anthropic": "^1.2.12",
39
- "@ai-sdk/google": "^1.2.19",
40
- "@ai-sdk/openai": "^1.3.22",
41
- "@clack/prompts": "^0.11.0",
42
- "@zod/mini": "4.0.0-beta.0",
43
- "ai": "^4.3.16",
44
- "commander": "^14.0.0",
45
- "jsonc-parser": "^3.3.1"
46
- },
47
- "scripts": {
48
- "dev": "node --no-warnings --experimental-strip-types src/bin.ts",
49
- "ci": "npm run build && npm run check-format",
50
- "build": "tsc",
51
- "test": "vitest run",
52
- "format": "prettier --write .",
53
- "check-format": "prettier --check .",
54
- "local-release": "npm run ci && changeset version && changeset publish"
55
- }
11
+ "author": "Matt Pocock <team@aihero.dev> (https://aihero.dev)",
12
+ "license": "MIT"
56
13
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Matt Pocock 2025
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/bin.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/bin.js DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { command } from "./command.js";
3
- command.parse(process.argv);
4
- //# sourceMappingURL=bin.js.map
package/dist/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
package/dist/command.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const command: Command;
package/dist/command.js DELETED
@@ -1,114 +0,0 @@
1
- import * as c from '@clack/prompts';
2
- import { generateText, smoothStream, streamText } from 'ai';
3
- import { Command } from 'commander';
4
- import { readFileSync } from 'fs';
5
- import { readFile } from 'fs/promises';
6
- import { parse } from 'jsonc-parser';
7
- import path from 'path';
8
- import { setupConfig, setupConfigIfNeeded } from "./config.js";
9
- import { getModel } from "./model.js";
10
- export const command = new Command();
11
- const getDocsForTSConfigOption = (option) => {
12
- try {
13
- return readFileSync(path.resolve(import.meta.dirname, `../docs/tsconfig/${option}.md`), 'utf8');
14
- }
15
- catch (error) {
16
- c.log.warn(`No docs found for ${option}`);
17
- return '';
18
- }
19
- };
20
- command
21
- .command('hows-my-tsconfig [tsconfig-path]')
22
- .action(async (tsconfigPath = 'tsconfig.json') => {
23
- c.intro("OK, let's check your tsconfig.json for you.");
24
- const config = await setupConfigIfNeeded();
25
- const models = getModel(config);
26
- const tsconfig = await readFile(tsconfigPath, 'utf8');
27
- const parsedTsconfig = parse(tsconfig);
28
- const compilerOptions = parsedTsconfig.compilerOptions;
29
- if (!compilerOptions) {
30
- c.log.error('No compilerOptions found in tsconfig.json');
31
- c.outro();
32
- return;
33
- }
34
- const docs = Object.keys(compilerOptions).map((option) => {
35
- return {
36
- option,
37
- docs: getDocsForTSConfigOption(option),
38
- };
39
- });
40
- const system = readFileSync(path.resolve(import.meta.dirname, '../prompts/hows-my-tsconfig.md'), 'utf8').replace('{{docs}}', docs.map((doc) => `### ${doc.option}\n\n${doc.docs}`).join('\n\n'));
41
- const messages = [
42
- {
43
- role: 'system',
44
- content: system,
45
- },
46
- {
47
- role: 'user',
48
- content: tsconfig,
49
- },
50
- ];
51
- const thoughts = streamText({
52
- model: models.thoughts,
53
- messages,
54
- onError: ({ error }) => {
55
- if (error instanceof Error) {
56
- c.log.error(error.message);
57
- }
58
- else {
59
- c.log.error('An unknown error occurred');
60
- }
61
- },
62
- experimental_transform: [
63
- smoothStream({
64
- chunking: 'word',
65
- }),
66
- ],
67
- });
68
- await c.stream.message(thoughts.textStream);
69
- messages.push({
70
- role: 'assistant',
71
- content: await thoughts.text,
72
- });
73
- const score = await generateText({
74
- model: models.score,
75
- system: readFileSync(path.resolve(import.meta.dirname, '../prompts/hows-my-tsconfig-score.md'), 'utf8'),
76
- prompt: await thoughts.text,
77
- });
78
- c.log.success(await score.text);
79
- messages.push({
80
- role: 'assistant',
81
- content: score.text,
82
- });
83
- while (true) {
84
- const response = await c.text({
85
- message: 'Ask a question',
86
- placeholder: '',
87
- });
88
- if (c.isCancel(response)) {
89
- break;
90
- }
91
- messages.push({
92
- role: 'user',
93
- content: response,
94
- });
95
- const followup = streamText({
96
- model: models.thoughts,
97
- messages,
98
- });
99
- await c.stream.message(followup.textStream);
100
- messages.push({
101
- role: 'assistant',
102
- content: await followup.text,
103
- });
104
- }
105
- c.outro('Goodbye!');
106
- });
107
- command
108
- .command('setup')
109
- .description('Setup the AI Hero CLI with the AI you want to use')
110
- .action(async () => {
111
- await setupConfig();
112
- c.outro('Setup complete');
113
- });
114
- //# sourceMappingURL=command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAoB,MAAM,IAAI,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,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EAAE,MAAM,QAAQ,CAAC,IAAI;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,mDAAmD,CAAC;KAChE,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,WAAW,EAAE,CAAC;IACpB,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC"}
package/dist/config.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import * as z from '@zod/mini';
2
- declare const configSchema: z.ZodMiniObject<{
3
- provider: z.ZodMiniEnum<{
4
- anthropic: "anthropic";
5
- openai: "openai";
6
- google: "google";
7
- }>;
8
- apiKey: z.ZodMiniString<string>;
9
- }, {}>;
10
- export type Config = z.output<typeof configSchema>;
11
- export declare function readConfig(): Config | null;
12
- export declare function writeConfig(config: Config): void;
13
- export declare function setupConfig(): Promise<Config>;
14
- export declare function setupConfigIfNeeded(): Promise<Config>;
15
- export {};
package/dist/config.js DELETED
@@ -1,52 +0,0 @@
1
- import { homedir } from 'os';
2
- import path from 'path';
3
- import { readFileSync, writeFileSync, existsSync } from 'fs';
4
- import * as z from '@zod/mini';
5
- import * as c from '@clack/prompts';
6
- const configSchema = z.object({
7
- provider: z.enum(['anthropic', 'openai', 'google']),
8
- apiKey: z.string(),
9
- });
10
- const CONFIG_LOCATION = path.join(homedir(), '.ai-hero-config.json');
11
- export function readConfig() {
12
- if (!existsSync(CONFIG_LOCATION)) {
13
- return null;
14
- }
15
- const configData = readFileSync(CONFIG_LOCATION, 'utf-8');
16
- const parsed = configSchema.parse(JSON.parse(configData));
17
- return parsed;
18
- }
19
- export function writeConfig(config) {
20
- const configData = JSON.stringify(config, null, 2);
21
- writeFileSync(CONFIG_LOCATION, configData, 'utf-8');
22
- }
23
- export async function setupConfig() {
24
- const provider = await c.select({
25
- message: 'Which AI provider do you want to use?',
26
- options: [
27
- { label: 'Anthropic', value: 'anthropic' },
28
- { label: 'OpenAI', value: 'openai' },
29
- { label: 'Google', value: 'google' },
30
- ],
31
- });
32
- if (c.isCancel(provider)) {
33
- throw new Error('User cancelled');
34
- }
35
- const apiKey = await c.password({
36
- message: 'Enter your API key',
37
- mask: '*',
38
- });
39
- if (c.isCancel(apiKey)) {
40
- throw new Error('User cancelled');
41
- }
42
- writeConfig({ provider, apiKey });
43
- return { provider, apiKey };
44
- }
45
- export function setupConfigIfNeeded() {
46
- const config = readConfig();
47
- if (config) {
48
- return Promise.resolve(config);
49
- }
50
- return setupConfig();
51
- }
52
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,KAAK,CAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,sBAAsB,CAAC,CAAC;AAIrE,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CA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EAAE,CAAC;IAC5B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC"}
package/dist/model.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import type { Config } from './config.ts';
2
- import type { LanguageModelV1 } from 'ai';
3
- export declare const getModel: (config: Config) => {
4
- thoughts: LanguageModelV1;
5
- score: LanguageModelV1;
6
- };
package/dist/model.js DELETED
@@ -1,26 +0,0 @@
1
- import { anthropic } from '@ai-sdk/anthropic';
2
- import { openai } from '@ai-sdk/openai';
3
- import { google } from '@ai-sdk/google';
4
- export const getModel = (config) => {
5
- switch (config.provider) {
6
- case 'anthropic':
7
- process.env.ANTHROPIC_API_KEY = config.apiKey;
8
- return {
9
- thoughts: anthropic('claude-4-sonnet-20250514'),
10
- score: anthropic('claude-3-5-haiku-latest'),
11
- };
12
- case 'openai':
13
- process.env.OPENAI_API_KEY = config.apiKey;
14
- return {
15
- thoughts: openai('gpt-4o'),
16
- score: openai('gpt-4o-mini'),
17
- };
18
- case 'google':
19
- process.env.GOOGLE_GENERATIVE_AI_API_KEY = config.apiKey;
20
- return {
21
- thoughts: google('gemini-2.5-flash-preview-04-17'),
22
- score: google('gemini-2.5-flash-preview-04-17'),
23
- };
24
- }
25
- };
26
- //# sourceMappingURL=model.js.map
package/dist/model.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,MAAc,EAId,EAAE;IACF,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxB,KAAK,WAAW;YACd,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;YAC9C,OAAO;gBACL,QAAQ,EAAE,SAAS,CAAC,0BAA0B,CAAC;gBAC/C,KAAK,EAAE,SAAS,CAAC,yBAAyB,CAAC;aAC5C,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;YAC3C,OAAO;gBACL,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;gBAC1B,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC;aAC7B,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC;YACzD,OAAO;gBACL,QAAQ,EAAE,MAAM,CAAC,gCAAgC,CAAC;gBAClD,KAAK,EAAE,MAAM,CAAC,gCAAgC,CAAC;aAChD,CAAC;IACN,CAAC;AACH,CAAC,CAAC"}
@@ -1,38 +0,0 @@
1
- ---
2
- display: 'Allow Arbitrary Extensions'
3
- oneline: 'Enable importing files with any extension, provided a declaration file is present.'
4
- ---
5
-
6
- In TypeScript 5.0, when an import path ends in an extension that isn't a known JavaScript or TypeScript file extension, the compiler will look for a declaration file for that path in the form of `{file basename}.d.{extension}.ts`.
7
- For example, if you are using a CSS loader in a bundler project, you might want to write (or generate) declaration files for those stylesheets:
8
-
9
- ```css
10
- /* app.css */
11
- .cookie-banner {
12
- display: none;
13
- }
14
- ```
15
-
16
- ```ts
17
- // app.d.css.ts
18
- declare const css: {
19
- cookieBanner: string;
20
- };
21
- export default css;
22
- ```
23
-
24
- ```ts
25
- // App.tsx
26
- import styles from './app.css';
27
-
28
- styles.cookieBanner; // string
29
- ```
30
-
31
- By default, this import will raise an error to let you know that TypeScript doesn't understand this file type and your runtime might not support importing it.
32
- But if you've configured your runtime or bundler to handle it, you can suppress the error with the new `--allowArbitraryExtensions` compiler option.
33
-
34
- Note that historically, a similar effect has often been achievable by adding a declaration file named `app.css.d.ts` instead of `app.d.css.ts` - however, this just worked through Node's `require` resolution rules for CommonJS.
35
- Strictly speaking, the former is interpreted as a declaration file for a JavaScript file named `app.css.js`.
36
- Because relative files imports need to include extensions in Node's ESM support, TypeScript would error on our example in an ESM file under `--moduleResolution node16` or `nodenext`.
37
-
38
- For more information, read up [the proposal for this feature](https://github.com/microsoft/TypeScript/issues/50133) and [its corresponding pull request](https://github.com/microsoft/TypeScript/pull/51435).
@@ -1,9 +0,0 @@
1
- ---
2
- display: 'Allow Importing TS Extensions'
3
- oneline: 'Allow imports to include TypeScript file extensions.'
4
- ---
5
-
6
- `--allowImportingTsExtensions` allows TypeScript files to import each other with a TypeScript-specific extension like `.ts`, `.mts`, or `.tsx`.
7
-
8
- This flag is only allowed when `--noEmit` or `--emitDeclarationOnly` is enabled, since these import paths would not be resolvable at runtime in JavaScript output files.
9
- The expectation here is that your resolver (e.g. your bundler, a runtime, or some other tool) is going to make these imports between `.ts` files work.
@@ -1,41 +0,0 @@
1
- ---
2
- display: 'Allow JS'
3
- oneline: 'Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.'
4
- ---
5
-
6
- Allow JavaScript files to be imported inside your project, instead of just `.ts` and `.tsx` files. For example, this JS file:
7
-
8
- ```js twoslash
9
- // @filename: card.js
10
- export const defaultCardDeck = 'Heart';
11
- ```
12
-
13
- When imported into a TypeScript file will raise an error:
14
-
15
- ```ts twoslash
16
- // @errors: 2307
17
- // @filename: card.js
18
- module.exports.defaultCardDeck = 'Heart';
19
- // ---cut---
20
- // @filename: index.ts
21
- import { defaultCardDeck } from './card';
22
-
23
- console.log(defaultCardDeck);
24
- ```
25
-
26
- Imports fine with `allowJs` enabled:
27
-
28
- ```ts twoslash
29
- // @filename: card.js
30
- module.exports.defaultCardDeck = 'Heart';
31
- // ---cut---
32
- // @allowJs
33
- // @filename: index.ts
34
- import { defaultCardDeck } from './card';
35
-
36
- console.log(defaultCardDeck);
37
- ```
38
-
39
- This flag can be used as a way to incrementally add TypeScript files into JS projects by allowing the `.ts` and `.tsx` files to live along-side existing JavaScript files.
40
-
41
- It can also be used along-side [`declaration`](#declaration) and [`emitDeclarationOnly`](#emitDeclarationOnly) to [create declarations for JS files](/docs/handbook/declaration-files/dts-from-js.html).
@@ -1,56 +0,0 @@
1
- ---
2
- display: 'Allow Synthetic Default Imports'
3
- oneline: "Allow 'import x from y' when a module doesn't have a default export."
4
- ---
5
-
6
- When set to true, `allowSyntheticDefaultImports` allows you to write an import like:
7
-
8
- ```ts
9
- import React from 'react';
10
- ```
11
-
12
- instead of:
13
-
14
- ```ts
15
- import * as React from 'react';
16
- ```
17
-
18
- When the module **does not** explicitly specify a default export.
19
-
20
- For example, without `allowSyntheticDefaultImports` as true:
21
-
22
- ```ts twoslash
23
- // @errors: 1259 1192
24
- // @checkJs
25
- // @allowJs
26
- // @esModuleInterop: false
27
- // @filename: utilFunctions.js
28
- // @noImplicitAny: false
29
- const getStringLength = (str) => str.length;
30
-
31
- module.exports = {
32
- getStringLength,
33
- };
34
-
35
- // @filename: index.ts
36
- import utils from './utilFunctions';
37
-
38
- const count = utils.getStringLength('Check JS');
39
- ```
40
-
41
- This code raises an error because there isn't a `default` object which you can import. Even though it feels like it should.
42
- For convenience, transpilers like Babel will automatically create a default if one isn't created. Making the module look a bit more like:
43
-
44
- ```js
45
- // @filename: utilFunctions.js
46
- const getStringLength = (str) => str.length;
47
- const allFunctions = {
48
- getStringLength,
49
- };
50
-
51
- module.exports = allFunctions;
52
- module.exports.default = allFunctions;
53
- ```
54
-
55
- This flag does not affect the JavaScript emitted by TypeScript, it's only for the type checking.
56
- This option brings the behavior of TypeScript in-line with Babel, where extra code is emitted to make using a default export of a module more ergonomic.
@@ -1,8 +0,0 @@
1
- ---
2
- display: 'Allow Umd Global Access'
3
- oneline: 'Allow accessing UMD globals from modules.'
4
- ---
5
-
6
- When set to true, `allowUmdGlobalAccess` lets you access UMD exports as globals from inside module files. A module file is a file that has imports and/or exports. Without this flag, using an export from a UMD module requires an import declaration.
7
-
8
- An example use case for this flag would be a web project where you know the particular library (like jQuery or Lodash) will always be available at runtime, but you can’t access it with an import.
@@ -1,40 +0,0 @@
1
- ---
2
- display: 'Allow Unreachable Code'
3
- oneline: 'Disable error reporting for unreachable code.'
4
- ---
5
-
6
- When:
7
-
8
- - `undefined` (default) provide suggestions as warnings to editors
9
- - `true` unreachable code is ignored
10
- - `false` raises compiler errors about unreachable code
11
-
12
- These warnings are only about code which is provably unreachable due to the use of JavaScript syntax, for example:
13
-
14
- ```ts
15
- function fn(n: number) {
16
- if (n > 5) {
17
- return true;
18
- } else {
19
- return false;
20
- }
21
- return true;
22
- }
23
- ```
24
-
25
- With `"allowUnreachableCode": false`:
26
-
27
- ```ts twoslash
28
- // @errors: 7027
29
- // @allowUnreachableCode: false
30
- function fn(n: number) {
31
- if (n > 5) {
32
- return true;
33
- } else {
34
- return false;
35
- }
36
- return true;
37
- }
38
- ```
39
-
40
- This does not affect errors on the basis of code which _appears_ to be unreachable due to type analysis.
@@ -1,23 +0,0 @@
1
- ---
2
- display: 'Allow Unused Labels'
3
- oneline: 'Disable error reporting for unused labels.'
4
- ---
5
-
6
- When:
7
-
8
- - `undefined` (default) provide suggestions as warnings to editors
9
- - `true` unused labels are ignored
10
- - `false` raises compiler errors about unused labels
11
-
12
- Labels are very rare in JavaScript and typically indicate an attempt to write an object literal:
13
-
14
- ```ts twoslash
15
- // @errors: 7028
16
- // @allowUnusedLabels: false
17
- function verifyAge(age: number) {
18
- // Forgot 'return' statement
19
- if (age > 18) {
20
- verified: true;
21
- }
22
- }
23
- ```
@@ -1,8 +0,0 @@
1
- ---
2
- display: 'Always Strict'
3
- oneline: "Ensure 'use strict' is always emitted."
4
- ---
5
-
6
- Ensures that your files are parsed in the ECMAScript strict mode, and emit "use strict" for each source file.
7
-
8
- [ECMAScript strict](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode) mode was introduced in ES5 and provides behavior tweaks to the runtime of the JavaScript engine to improve performance, and makes a set of errors throw instead of silently ignoring them.
@@ -1,8 +0,0 @@
1
- ---
2
- display: 'Assume Changes Only Affect Direct Dependencies'
3
- oneline: 'Have recompiles in projects that use [`incremental`](#incremental) and `watch` mode assume that changes within a file will only affect files directly depending on it.'
4
- ---
5
-
6
- When this option is enabled, TypeScript will avoid rechecking/rebuilding all truly possibly-affected files, and only recheck/rebuild files that have changed as well as files that directly import them.
7
-
8
- This can be considered a 'fast & loose' implementation of the watching algorithm, which can drastically reduce incremental rebuild times at the expense of having to run the full build occasionally to get all compiler error messages.
@@ -1,26 +0,0 @@
1
- ---
2
- display: 'Base URL'
3
- oneline: 'Specify the base directory to resolve bare specifier module names.'
4
- ---
5
-
6
- Sets a base directory from which to resolve bare specifier module names. For example, in the directory structure:
7
-
8
- ```
9
- project
10
- ├── ex.ts
11
- ├── hello
12
- │ └── world.ts
13
- └── tsconfig.json
14
- ```
15
-
16
- With `"baseUrl": "./"`, TypeScript will look for files starting at the same folder as the `tsconfig.json`:
17
-
18
- ```ts
19
- import { helloWorld } from 'hello/world';
20
-
21
- console.log(helloWorld);
22
- ```
23
-
24
- This resolution has higher priority than lookups from `node_modules`.
25
-
26
- This feature was designed for use in conjunction with AMD module loaders in the browser, and is not recommended in any other context. As of TypeScript 4.1, `baseUrl` is no longer required to be set when using [`paths`](#paths).
@@ -1,7 +0,0 @@
1
- ---
2
- display: 'Charset'
3
- oneline: 'No longer supported. In early versions, manually set the text encoding for reading files.'
4
- ---
5
-
6
- In prior versions of TypeScript, this controlled what encoding was used when reading text files from disk.
7
- Today, TypeScript assumes UTF-8 encoding, but will correctly detect UTF-16 (BE and LE) or UTF-8 BOMs.
@@ -1,40 +0,0 @@
1
- ---
2
- display: 'Check JS'
3
- oneline: 'Enable error reporting in type-checked JavaScript files.'
4
- ---
5
-
6
- Works in tandem with [`allowJs`](#allowJs). When `checkJs` is enabled then errors are reported in JavaScript files. This is
7
- the equivalent of including `// @ts-check` at the top of all JavaScript files which are included in your project.
8
-
9
- For example, this is incorrect JavaScript according to the `parseFloat` type definition which comes with TypeScript:
10
-
11
- ```js
12
- // parseFloat only takes a string
13
- module.exports.pi = parseFloat(3.142);
14
- ```
15
-
16
- When imported into a TypeScript module:
17
-
18
- ```ts twoslash
19
- // @allowJs
20
- // @filename: constants.js
21
- module.exports.pi = parseFloat(3.142);
22
-
23
- // @filename: index.ts
24
- import { pi } from './constants';
25
- console.log(pi);
26
- ```
27
-
28
- You will not get any errors. However, if you turn on `checkJs` then you will get error messages from the JavaScript file.
29
-
30
- ```ts twoslash
31
- // @errors: 2345
32
- // @allowjs: true
33
- // @checkjs: true
34
- // @filename: constants.js
35
- module.exports.pi = parseFloat(3.142);
36
-
37
- // @filename: index.ts
38
- import { pi } from './constants';
39
- console.log(pi);
40
- ```