thinkwell 0.5.5 → 0.5.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/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +207 -279
- package/dist/agent.js.map +1 -1
- package/dist/build.js +44 -98
- package/dist/cli/build.js +92 -227
- package/dist/cli/bundle.js +570 -1136
- package/dist/cli/check.js +125 -214
- package/dist/cli/commands.js +63 -177
- package/dist/cli/compiler-host.js +81 -190
- package/dist/cli/dependency-check.js +125 -269
- package/dist/cli/dependency-errors.js +12 -84
- package/dist/cli/fmt.js +1 -13
- package/dist/cli/init-command.js +21 -68
- package/dist/cli/init.js +90 -220
- package/dist/cli/loader.js +95 -361
- package/dist/cli/new-command.js +25 -73
- package/dist/cli/package-manager.js +50 -117
- package/dist/cli/schema.js +89 -245
- package/dist/cli/workspace.js +92 -226
- package/dist/connectors/index.js +1 -7
- package/dist/generated/features.d.ts +5 -0
- package/dist/generated/features.d.ts.map +1 -0
- package/dist/generated/features.js +4 -0
- package/dist/generated/features.js.map +1 -0
- package/dist/index.js +0 -5
- package/dist/schema.js +3 -36
- package/dist/session.js +50 -82
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +269 -370
- package/dist/think-builder.js.map +1 -1
- package/dist/thought-event.d.ts +1 -0
- package/dist/thought-event.d.ts.map +1 -1
- package/dist/thought-event.js +0 -1
- package/dist/thought-stream.js +60 -96
- package/dist-pkg/acp.cjs +13385 -1876
- package/dist-pkg/cli-build.cjs +171 -369
- package/dist-pkg/cli-bundle.cjs +289 -690
- package/dist-pkg/cli-check.cjs +202 -415
- package/dist-pkg/cli-dependency-check.cjs +39 -82
- package/dist-pkg/cli-dependency-errors.cjs +9 -41
- package/dist-pkg/cli-loader.cjs +90 -173
- package/dist-pkg/protocol.cjs +2 -8
- package/dist-pkg/thinkwell.cjs +876 -1842
- package/package.json +7 -6
package/dist-pkg/cli-check.cjs
CHANGED
|
@@ -238622,61 +238622,49 @@ var import_node_fs = require("node:fs");
|
|
|
238622
238622
|
var import_ts_json_schema_generator = __toESM(require_dist(), 1);
|
|
238623
238623
|
function findTsConfig(startDir) {
|
|
238624
238624
|
let dir = startDir;
|
|
238625
|
-
|
|
238625
|
+
for (; ; ) {
|
|
238626
238626
|
const configPath = (0, import_node_path.join)(dir, "tsconfig.json");
|
|
238627
|
-
if ((0, import_node_fs.existsSync)(configPath))
|
|
238627
|
+
if ((0, import_node_fs.existsSync)(configPath))
|
|
238628
238628
|
return configPath;
|
|
238629
|
-
}
|
|
238630
238629
|
const parent = (0, import_node_path.dirname)(dir);
|
|
238631
|
-
if (parent === dir)
|
|
238632
|
-
return
|
|
238633
|
-
}
|
|
238630
|
+
if (parent === dir)
|
|
238631
|
+
return;
|
|
238634
238632
|
dir = parent;
|
|
238635
238633
|
}
|
|
238636
238634
|
}
|
|
238637
238635
|
__name(findTsConfig, "findTsConfig");
|
|
238638
238636
|
function inlineRefs(obj, definitions) {
|
|
238639
|
-
if (obj === null || typeof obj
|
|
238637
|
+
if (obj === null || typeof obj != "object")
|
|
238640
238638
|
return obj;
|
|
238641
|
-
|
|
238642
|
-
if (Array.isArray(obj)) {
|
|
238639
|
+
if (Array.isArray(obj))
|
|
238643
238640
|
return obj.map((item) => inlineRefs(item, definitions));
|
|
238644
|
-
}
|
|
238645
238641
|
const record = obj;
|
|
238646
|
-
if (typeof record
|
|
238647
|
-
const
|
|
238648
|
-
|
|
238649
|
-
if (match && definitions[match[1]]) {
|
|
238642
|
+
if (typeof record.$ref == "string") {
|
|
238643
|
+
const match = record.$ref.match(/^#\/definitions\/(.+)$/);
|
|
238644
|
+
if (match && definitions[match[1]])
|
|
238650
238645
|
return inlineRefs(definitions[match[1]], definitions);
|
|
238651
|
-
}
|
|
238652
238646
|
}
|
|
238653
238647
|
const result = {};
|
|
238654
|
-
for (const [key2, value] of Object.entries(record))
|
|
238648
|
+
for (const [key2, value] of Object.entries(record))
|
|
238655
238649
|
result[key2] = inlineRefs(value, definitions);
|
|
238656
|
-
}
|
|
238657
238650
|
return result;
|
|
238658
238651
|
}
|
|
238659
238652
|
__name(inlineRefs, "inlineRefs");
|
|
238660
238653
|
function cleanSchema(typeName, schema) {
|
|
238661
238654
|
const definitions = schema.definitions || {};
|
|
238662
238655
|
let result = definitions[typeName] || schema;
|
|
238663
|
-
result = inlineRefs(result, definitions)
|
|
238664
|
-
if (typeof result === "object" && result !== null) {
|
|
238656
|
+
if (result = inlineRefs(result, definitions), typeof result == "object" && result !== null) {
|
|
238665
238657
|
const cleaned = { ...result };
|
|
238666
|
-
delete cleaned
|
|
238667
|
-
delete cleaned["definitions"];
|
|
238668
|
-
return cleaned;
|
|
238658
|
+
return delete cleaned.$schema, delete cleaned.definitions, cleaned;
|
|
238669
238659
|
}
|
|
238670
238660
|
return result;
|
|
238671
238661
|
}
|
|
238672
238662
|
__name(cleanSchema, "cleanSchema");
|
|
238673
238663
|
function generateSchemas(filePath, typeNames) {
|
|
238674
238664
|
const schemas = /* @__PURE__ */ new Map();
|
|
238675
|
-
if (typeNames.length === 0)
|
|
238665
|
+
if (typeNames.length === 0)
|
|
238676
238666
|
return schemas;
|
|
238677
|
-
|
|
238678
|
-
const configPath = findTsConfig((0, import_node_path.dirname)(filePath));
|
|
238679
|
-
const generator = (0, import_ts_json_schema_generator.createGenerator)({
|
|
238667
|
+
const configPath = findTsConfig((0, import_node_path.dirname)(filePath)), generator = (0, import_ts_json_schema_generator.createGenerator)({
|
|
238680
238668
|
path: filePath,
|
|
238681
238669
|
...configPath && { tsconfig: configPath },
|
|
238682
238670
|
skipTypeCheck: true,
|
|
@@ -238693,8 +238681,7 @@ __name(generateSchemas, "generateSchemas");
|
|
|
238693
238681
|
// dist/cli/schema.js
|
|
238694
238682
|
var JSONSCHEMA_TAG = "JSONSchema";
|
|
238695
238683
|
function hasJsDocTag(node, tagName) {
|
|
238696
|
-
|
|
238697
|
-
return jsDocNodes.some((tag) => tag.tagName.text === tagName);
|
|
238684
|
+
return import_typescript.default.getJSDocTags(node).some((tag) => tag.tagName.text === tagName);
|
|
238698
238685
|
}
|
|
238699
238686
|
__name(hasJsDocTag, "hasJsDocTag");
|
|
238700
238687
|
function findMarkedTypes(path, source) {
|
|
@@ -238704,48 +238691,36 @@ function findMarkedTypes(path, source) {
|
|
|
238704
238691
|
import_typescript.default.ScriptTarget.Latest,
|
|
238705
238692
|
true
|
|
238706
238693
|
// setParentNodes - needed for JSDoc traversal
|
|
238707
|
-
);
|
|
238708
|
-
|
|
238709
|
-
|
|
238710
|
-
|
|
238711
|
-
if (
|
|
238712
|
-
const
|
|
238713
|
-
|
|
238714
|
-
|
|
238715
|
-
|
|
238716
|
-
|
|
238717
|
-
|
|
238718
|
-
|
|
238719
|
-
|
|
238720
|
-
|
|
238721
|
-
|
|
238722
|
-
|
|
238723
|
-
|
|
238724
|
-
|
|
238725
|
-
|
|
238726
|
-
node,
|
|
238727
|
-
startPosition: node.getStart(),
|
|
238728
|
-
endPosition: node.getEnd(),
|
|
238729
|
-
line: line + 1,
|
|
238730
|
-
column: character + 1,
|
|
238731
|
-
declarationLength,
|
|
238732
|
-
isExported
|
|
238733
|
-
});
|
|
238734
|
-
}
|
|
238694
|
+
), results = [];
|
|
238695
|
+
return import_typescript.default.forEachChild(sourceFile, /* @__PURE__ */ __name(function visit(node) {
|
|
238696
|
+
if ((import_typescript.default.isInterfaceDeclaration(node) || import_typescript.default.isTypeAliasDeclaration(node) || import_typescript.default.isEnumDeclaration(node) || import_typescript.default.isClassDeclaration(node)) && hasJsDocTag(node, JSONSCHEMA_TAG)) {
|
|
238697
|
+
const name = node.name?.text;
|
|
238698
|
+
if (name) {
|
|
238699
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
238700
|
+
let keyword = "interface";
|
|
238701
|
+
import_typescript.default.isTypeAliasDeclaration(node) ? keyword = "type" : import_typescript.default.isEnumDeclaration(node) ? keyword = "enum" : import_typescript.default.isClassDeclaration(node) && (keyword = "class");
|
|
238702
|
+
const declarationLength = keyword.length + 1 + name.length, isExported = node.modifiers?.some((m) => m.kind === import_typescript.default.SyntaxKind.ExportKeyword) ?? false;
|
|
238703
|
+
results.push({
|
|
238704
|
+
name,
|
|
238705
|
+
node,
|
|
238706
|
+
startPosition: node.getStart(),
|
|
238707
|
+
endPosition: node.getEnd(),
|
|
238708
|
+
line: line + 1,
|
|
238709
|
+
column: character + 1,
|
|
238710
|
+
declarationLength,
|
|
238711
|
+
isExported
|
|
238712
|
+
});
|
|
238735
238713
|
}
|
|
238736
238714
|
}
|
|
238737
238715
|
import_typescript.default.forEachChild(node, visit);
|
|
238738
|
-
}, "visit"));
|
|
238739
|
-
return results;
|
|
238716
|
+
}, "visit")), results;
|
|
238740
238717
|
}
|
|
238741
238718
|
__name(findMarkedTypes, "findMarkedTypes");
|
|
238742
238719
|
function resolveGenerateSchemas(projectDir) {
|
|
238743
238720
|
if (projectDir) {
|
|
238744
|
-
const
|
|
238745
|
-
|
|
238746
|
-
if (typeof buildMod.generateSchemas === "function") {
|
|
238721
|
+
const buildMod = (0, import_node_module.createRequire)((0, import_node_path2.join)(projectDir, "package.json"))("thinkwell/build");
|
|
238722
|
+
if (typeof buildMod.generateSchemas == "function")
|
|
238747
238723
|
return buildMod.generateSchemas;
|
|
238748
|
-
}
|
|
238749
238724
|
throw new Error(`thinkwell/build resolved from ${projectDir} but does not export generateSchemas. This may indicate a version mismatch \u2014 try updating the thinkwell dependency.`);
|
|
238750
238725
|
}
|
|
238751
238726
|
return generateSchemas;
|
|
@@ -238753,18 +238728,14 @@ function resolveGenerateSchemas(projectDir) {
|
|
|
238753
238728
|
__name(resolveGenerateSchemas, "resolveGenerateSchemas");
|
|
238754
238729
|
function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
238755
238730
|
const schemas = /* @__PURE__ */ new Map();
|
|
238756
|
-
if (types.length === 0)
|
|
238731
|
+
if (types.length === 0)
|
|
238757
238732
|
return schemas;
|
|
238758
|
-
}
|
|
238759
238733
|
const buildGenerateSchemas = resolveGenerateSchemas(projectDir);
|
|
238760
238734
|
for (const typeInfo of types) {
|
|
238761
238735
|
const { name, line, column } = typeInfo;
|
|
238762
238736
|
try {
|
|
238763
|
-
const
|
|
238764
|
-
|
|
238765
|
-
if (schema) {
|
|
238766
|
-
schemas.set(name, schema);
|
|
238767
|
-
}
|
|
238737
|
+
const schema = buildGenerateSchemas(path, [name]).get(name);
|
|
238738
|
+
schema && schemas.set(name, schema);
|
|
238768
238739
|
} catch (error) {
|
|
238769
238740
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
238770
238741
|
throw new Error(`Failed to generate schema for type '${name}' at ${path}:${line}:${column}
|
|
@@ -238777,27 +238748,27 @@ function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
|
238777
238748
|
__name(generateSchemas2, "generateSchemas");
|
|
238778
238749
|
var ACP_NAMESPACE = "$$__thinkwell__acp__$$";
|
|
238779
238750
|
function generateNamespace(name, schema, isExported) {
|
|
238780
|
-
const schemaJson = JSON.stringify(schema, null, 2).split(
|
|
238781
|
-
|
|
238751
|
+
const schemaJson = JSON.stringify(schema, null, 2).split(`
|
|
238752
|
+
`).map((line, i) => i === 0 ? line : " " + line).join(`
|
|
238753
|
+
`);
|
|
238782
238754
|
return [
|
|
238783
|
-
`${
|
|
238755
|
+
`${isExported ? "export " : ""}namespace ${name} {`,
|
|
238784
238756
|
` export const Schema: ${ACP_NAMESPACE}.SchemaProvider<${name}> = {`,
|
|
238785
238757
|
` toJsonSchema: () => (${schemaJson}) as ${ACP_NAMESPACE}.JsonSchema,`,
|
|
238786
|
-
|
|
238787
|
-
|
|
238788
|
-
].join(
|
|
238758
|
+
" };",
|
|
238759
|
+
"}"
|
|
238760
|
+
].join(`
|
|
238761
|
+
`);
|
|
238789
238762
|
}
|
|
238790
238763
|
__name(generateNamespace, "generateNamespace");
|
|
238791
238764
|
function generateInsertions(types, schemas) {
|
|
238792
238765
|
const insertions = [];
|
|
238793
238766
|
for (const { name, endPosition, isExported } of types) {
|
|
238794
238767
|
const schema = schemas.get(name);
|
|
238795
|
-
|
|
238796
|
-
continue;
|
|
238797
|
-
}
|
|
238798
|
-
insertions.push({
|
|
238768
|
+
schema && insertions.push({
|
|
238799
238769
|
position: endPosition,
|
|
238800
|
-
code:
|
|
238770
|
+
code: `
|
|
238771
|
+
` + generateNamespace(name, schema, isExported)
|
|
238801
238772
|
});
|
|
238802
238773
|
}
|
|
238803
238774
|
return insertions.sort((a, b) => b.position - a.position);
|
|
@@ -238809,9 +238780,8 @@ function generateSchemaImport() {
|
|
|
238809
238780
|
__name(generateSchemaImport, "generateSchemaImport");
|
|
238810
238781
|
function applyInsertions(source, insertions) {
|
|
238811
238782
|
let result = source;
|
|
238812
|
-
for (const { position, code } of insertions)
|
|
238783
|
+
for (const { position, code } of insertions)
|
|
238813
238784
|
result = result.slice(0, position) + code + result.slice(position);
|
|
238814
|
-
}
|
|
238815
238785
|
return result;
|
|
238816
238786
|
}
|
|
238817
238787
|
__name(applyInsertions, "applyInsertions");
|
|
@@ -238820,43 +238790,37 @@ function hasJsonSchemaMarkers(source) {
|
|
|
238820
238790
|
}
|
|
238821
238791
|
__name(hasJsonSchemaMarkers, "hasJsonSchemaMarkers");
|
|
238822
238792
|
function transformJsonSchemas(path, source, projectDir) {
|
|
238823
|
-
if (!hasJsonSchemaMarkers(source))
|
|
238793
|
+
if (!hasJsonSchemaMarkers(source))
|
|
238824
238794
|
return source;
|
|
238825
|
-
}
|
|
238826
238795
|
const markedTypes = findMarkedTypes(path, source);
|
|
238827
|
-
if (markedTypes.length === 0)
|
|
238796
|
+
if (markedTypes.length === 0)
|
|
238828
238797
|
return source;
|
|
238829
|
-
|
|
238830
|
-
const schemas = generateSchemas2(path, markedTypes, source, projectDir);
|
|
238831
|
-
const insertions = generateInsertions(markedTypes, schemas);
|
|
238798
|
+
const schemas = generateSchemas2(path, markedTypes, source, projectDir), insertions = generateInsertions(markedTypes, schemas);
|
|
238832
238799
|
let modifiedSource = applyInsertions(source, insertions);
|
|
238833
|
-
modifiedSource = generateSchemaImport() +
|
|
238834
|
-
|
|
238800
|
+
return modifiedSource = generateSchemaImport() + `
|
|
238801
|
+
` + modifiedSource, modifiedSource;
|
|
238835
238802
|
}
|
|
238836
238803
|
__name(transformJsonSchemas, "transformJsonSchemas");
|
|
238837
238804
|
|
|
238838
238805
|
// dist/cli/compiler-host.js
|
|
238839
238806
|
function getTypeScriptLibDir() {
|
|
238840
|
-
if (typeof process.pkg
|
|
238807
|
+
if (typeof process.pkg < "u") {
|
|
238841
238808
|
const snapshotLibDir = "/snapshot/thinkwell/packages/thinkwell/dist-pkg/typescript-lib";
|
|
238842
|
-
if ((0, import_node_fs2.existsSync)(snapshotLibDir))
|
|
238809
|
+
if ((0, import_node_fs2.existsSync)(snapshotLibDir))
|
|
238843
238810
|
return snapshotLibDir;
|
|
238844
|
-
}
|
|
238845
238811
|
}
|
|
238846
238812
|
return (0, import_node_path3.dirname)(import_typescript2.default.getDefaultLibFilePath({}));
|
|
238847
238813
|
}
|
|
238848
238814
|
__name(getTypeScriptLibDir, "getTypeScriptLibDir");
|
|
238849
238815
|
function parseTsConfig(configPath) {
|
|
238850
238816
|
const configFile = import_typescript2.default.readConfigFile(configPath, import_typescript2.default.sys.readFile);
|
|
238851
|
-
if (configFile.error)
|
|
238817
|
+
if (configFile.error)
|
|
238852
238818
|
return {
|
|
238853
238819
|
options: {},
|
|
238854
238820
|
fileNames: [],
|
|
238855
238821
|
errors: [configFile.error]
|
|
238856
238822
|
};
|
|
238857
|
-
|
|
238858
|
-
const configDir = (0, import_node_path3.dirname)(configPath);
|
|
238859
|
-
const parsed = import_typescript2.default.parseJsonConfigFileContent(
|
|
238823
|
+
const configDir = (0, import_node_path3.dirname)(configPath), parsed = import_typescript2.default.parseJsonConfigFileContent(
|
|
238860
238824
|
configFile.config,
|
|
238861
238825
|
import_typescript2.default.sys,
|
|
238862
238826
|
configDir,
|
|
@@ -238872,32 +238836,17 @@ function parseTsConfig(configPath) {
|
|
|
238872
238836
|
}
|
|
238873
238837
|
__name(parseTsConfig, "parseTsConfig");
|
|
238874
238838
|
function shouldTransform(fileName) {
|
|
238875
|
-
|
|
238876
|
-
return false;
|
|
238877
|
-
if (fileName.includes("/lib/lib."))
|
|
238878
|
-
return false;
|
|
238879
|
-
return true;
|
|
238839
|
+
return !(fileName.includes("node_modules") || fileName.includes("/lib/lib."));
|
|
238880
238840
|
}
|
|
238881
238841
|
__name(shouldTransform, "shouldTransform");
|
|
238882
238842
|
function isThinkwellHostOptions(options) {
|
|
238883
|
-
return typeof options.compilerOptions
|
|
238843
|
+
return typeof options.compilerOptions == "object" && options.compilerOptions !== null && !Array.isArray(options.compilerOptions);
|
|
238884
238844
|
}
|
|
238885
238845
|
__name(isThinkwellHostOptions, "isThinkwellHostOptions");
|
|
238886
238846
|
function createThinkwellHost(options) {
|
|
238887
|
-
let compilerOptions;
|
|
238888
|
-
|
|
238889
|
-
|
|
238890
|
-
if (isThinkwellHostOptions(options)) {
|
|
238891
|
-
compilerOptions = options.compilerOptions;
|
|
238892
|
-
fileFilter = options.fileFilter;
|
|
238893
|
-
projectDir = options.projectDir;
|
|
238894
|
-
} else {
|
|
238895
|
-
compilerOptions = options;
|
|
238896
|
-
fileFilter = void 0;
|
|
238897
|
-
projectDir = void 0;
|
|
238898
|
-
}
|
|
238899
|
-
const defaultHost = import_typescript2.default.createCompilerHost(compilerOptions);
|
|
238900
|
-
const tsLibDir = getTypeScriptLibDir();
|
|
238847
|
+
let compilerOptions, fileFilter, projectDir;
|
|
238848
|
+
isThinkwellHostOptions(options) ? (compilerOptions = options.compilerOptions, fileFilter = options.fileFilter, projectDir = options.projectDir) : (compilerOptions = options, fileFilter = void 0, projectDir = void 0);
|
|
238849
|
+
const defaultHost = import_typescript2.default.createCompilerHost(compilerOptions), tsLibDir = getTypeScriptLibDir();
|
|
238901
238850
|
return {
|
|
238902
238851
|
...defaultHost,
|
|
238903
238852
|
// Override getDefaultLibLocation to point to our bundled TypeScript lib files
|
|
@@ -238911,41 +238860,29 @@ function createThinkwellHost(options) {
|
|
|
238911
238860
|
},
|
|
238912
238861
|
getSourceFile(fileName, languageVersionOrOptions) {
|
|
238913
238862
|
const source = import_typescript2.default.sys.readFile(fileName);
|
|
238914
|
-
if (source
|
|
238915
|
-
|
|
238916
|
-
}
|
|
238917
|
-
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source)) {
|
|
238918
|
-
if (!fileFilter || fileFilter(fileName)) {
|
|
238863
|
+
if (source !== void 0) {
|
|
238864
|
+
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source) && (!fileFilter || fileFilter(fileName))) {
|
|
238919
238865
|
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238920
238866
|
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238921
238867
|
}
|
|
238868
|
+
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238922
238869
|
}
|
|
238923
|
-
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238924
238870
|
}
|
|
238925
238871
|
};
|
|
238926
238872
|
}
|
|
238927
238873
|
__name(createThinkwellHost, "createThinkwellHost");
|
|
238928
238874
|
function createThinkwellProgram(configPathOrOptions) {
|
|
238929
|
-
const configPath = typeof configPathOrOptions
|
|
238930
|
-
const fileFilter = typeof configPathOrOptions === "object" ? configPathOrOptions.fileFilter : void 0;
|
|
238931
|
-
const projectDir = typeof configPathOrOptions === "object" ? configPathOrOptions.projectDir : void 0;
|
|
238932
|
-
const resolvedConfigPath = (0, import_node_path3.resolve)(configPath);
|
|
238933
|
-
const { options, fileNames, errors } = parseTsConfig(resolvedConfigPath);
|
|
238875
|
+
const configPath = typeof configPathOrOptions == "string" ? configPathOrOptions : configPathOrOptions.configPath, fileFilter = typeof configPathOrOptions == "object" ? configPathOrOptions.fileFilter : void 0, projectDir = typeof configPathOrOptions == "object" ? configPathOrOptions.projectDir : void 0, resolvedConfigPath = (0, import_node_path3.resolve)(configPath), { options, fileNames, errors } = parseTsConfig(resolvedConfigPath);
|
|
238934
238876
|
function makeHost() {
|
|
238935
|
-
return fileFilter || projectDir ?
|
|
238877
|
+
return createThinkwellHost(fileFilter || projectDir ? { compilerOptions: options, fileFilter, projectDir } : options);
|
|
238936
238878
|
}
|
|
238937
238879
|
__name(makeHost, "makeHost");
|
|
238938
|
-
if (errors.length > 0) {
|
|
238939
|
-
const
|
|
238940
|
-
|
|
238941
|
-
const host2 = makeHost();
|
|
238942
|
-
const program2 = import_typescript2.default.createProgram([], options, host2);
|
|
238943
|
-
return { program: program2, configErrors: errors };
|
|
238944
|
-
}
|
|
238880
|
+
if (errors.length > 0 && errors.filter((d) => d.category === import_typescript2.default.DiagnosticCategory.Error).length > 0) {
|
|
238881
|
+
const host2 = makeHost();
|
|
238882
|
+
return { program: import_typescript2.default.createProgram([], options, host2), configErrors: errors };
|
|
238945
238883
|
}
|
|
238946
238884
|
const host = makeHost();
|
|
238947
|
-
|
|
238948
|
-
return { program, configErrors: errors };
|
|
238885
|
+
return { program: import_typescript2.default.createProgram(fileNames, options, host), configErrors: errors };
|
|
238949
238886
|
}
|
|
238950
238887
|
__name(createThinkwellProgram, "createThinkwellProgram");
|
|
238951
238888
|
|
|
@@ -238961,8 +238898,8 @@ var dim = /* @__PURE__ */ __name((t) => (0, import_node_util.styleText)("dim", t
|
|
|
238961
238898
|
var import_node_fs3 = require("node:fs");
|
|
238962
238899
|
var import_node_path4 = require("node:path");
|
|
238963
238900
|
function parsePnpmWorkspaceYaml(content) {
|
|
238964
|
-
const patterns = []
|
|
238965
|
-
|
|
238901
|
+
const patterns = [], lines = content.split(`
|
|
238902
|
+
`);
|
|
238966
238903
|
let inPackages = false;
|
|
238967
238904
|
for (const line of lines) {
|
|
238968
238905
|
const trimmed = line.trim();
|
|
@@ -238970,14 +238907,11 @@ function parsePnpmWorkspaceYaml(content) {
|
|
|
238970
238907
|
inPackages = true;
|
|
238971
238908
|
continue;
|
|
238972
238909
|
}
|
|
238973
|
-
if (inPackages && trimmed.length > 0 && !trimmed.startsWith("-") && !line.startsWith(" ") && !line.startsWith(" "))
|
|
238910
|
+
if (inPackages && trimmed.length > 0 && !trimmed.startsWith("-") && !line.startsWith(" ") && !line.startsWith(" "))
|
|
238974
238911
|
break;
|
|
238975
|
-
}
|
|
238976
238912
|
if (inPackages && trimmed.startsWith("-")) {
|
|
238977
238913
|
const value = trimmed.slice(1).trim().replace(/^["']|["']$/g, "");
|
|
238978
|
-
|
|
238979
|
-
patterns.push(value);
|
|
238980
|
-
}
|
|
238914
|
+
value.length > 0 && patterns.push(value);
|
|
238981
238915
|
}
|
|
238982
238916
|
}
|
|
238983
238917
|
return patterns;
|
|
@@ -238985,36 +238919,23 @@ function parsePnpmWorkspaceYaml(content) {
|
|
|
238985
238919
|
__name(parsePnpmWorkspaceYaml, "parsePnpmWorkspaceYaml");
|
|
238986
238920
|
function expandWorkspaceGlobs(rootDir, patterns) {
|
|
238987
238921
|
const dirs = [];
|
|
238988
|
-
for (const pattern of patterns)
|
|
238989
|
-
if (pattern.startsWith("!"))
|
|
238990
|
-
|
|
238991
|
-
|
|
238992
|
-
|
|
238993
|
-
|
|
238994
|
-
|
|
238995
|
-
|
|
238996
|
-
|
|
238997
|
-
|
|
238998
|
-
|
|
238999
|
-
continue;
|
|
239000
|
-
if (globPart === "*") {
|
|
239001
|
-
const entries = (0, import_node_fs3.readdirSync)(baseDir);
|
|
239002
|
-
for (const entry of entries) {
|
|
239003
|
-
const fullPath = suffix ? (0, import_node_path4.resolve)(baseDir, entry, suffix) : (0, import_node_path4.resolve)(baseDir, entry);
|
|
239004
|
-
if ((0, import_node_fs3.existsSync)(fullPath) && isDirectory(fullPath)) {
|
|
239005
|
-
dirs.push(fullPath);
|
|
238922
|
+
for (const pattern of patterns)
|
|
238923
|
+
if (!pattern.startsWith("!"))
|
|
238924
|
+
if (pattern.includes("*")) {
|
|
238925
|
+
const parts = pattern.split("/"), globIndex = parts.findIndex((p) => p.includes("*")), prefix = parts.slice(0, globIndex).join("/"), globPart = parts[globIndex], suffix = parts.slice(globIndex + 1).join("/"), baseDir = (0, import_node_path4.resolve)(rootDir, prefix);
|
|
238926
|
+
if (!(0, import_node_fs3.existsSync)(baseDir))
|
|
238927
|
+
continue;
|
|
238928
|
+
if (globPart === "*") {
|
|
238929
|
+
const entries = (0, import_node_fs3.readdirSync)(baseDir);
|
|
238930
|
+
for (const entry of entries) {
|
|
238931
|
+
const fullPath = suffix ? (0, import_node_path4.resolve)(baseDir, entry, suffix) : (0, import_node_path4.resolve)(baseDir, entry);
|
|
238932
|
+
(0, import_node_fs3.existsSync)(fullPath) && isDirectory(fullPath) && dirs.push(fullPath);
|
|
239006
238933
|
}
|
|
239007
|
-
}
|
|
239008
|
-
} else
|
|
239009
|
-
|
|
239010
|
-
|
|
239011
|
-
} else {
|
|
239012
|
-
const fullPath = (0, import_node_path4.resolve)(rootDir, pattern);
|
|
239013
|
-
if ((0, import_node_fs3.existsSync)(fullPath) && isDirectory(fullPath)) {
|
|
239014
|
-
dirs.push(fullPath);
|
|
238934
|
+
} else globPart === "**" && collectDirectories(baseDir, suffix, dirs);
|
|
238935
|
+
} else {
|
|
238936
|
+
const fullPath = (0, import_node_path4.resolve)(rootDir, pattern);
|
|
238937
|
+
(0, import_node_fs3.existsSync)(fullPath) && isDirectory(fullPath) && dirs.push(fullPath);
|
|
239015
238938
|
}
|
|
239016
|
-
}
|
|
239017
|
-
}
|
|
239018
238939
|
return dirs;
|
|
239019
238940
|
}
|
|
239020
238941
|
__name(expandWorkspaceGlobs, "expandWorkspaceGlobs");
|
|
@@ -239040,79 +238961,55 @@ function collectDirectories(baseDir, suffix, result) {
|
|
|
239040
238961
|
if (!isDirectory(fullPath))
|
|
239041
238962
|
continue;
|
|
239042
238963
|
const candidate = suffix ? (0, import_node_path4.resolve)(fullPath, suffix) : fullPath;
|
|
239043
|
-
|
|
239044
|
-
result.push(candidate);
|
|
239045
|
-
}
|
|
239046
|
-
collectDirectories(fullPath, suffix, result);
|
|
238964
|
+
(0, import_node_fs3.existsSync)(candidate) && isDirectory(candidate) && result.push(candidate), collectDirectories(fullPath, suffix, result);
|
|
239047
238965
|
}
|
|
239048
238966
|
}
|
|
239049
238967
|
__name(collectDirectories, "collectDirectories");
|
|
239050
238968
|
function readMember(dir) {
|
|
239051
238969
|
const pkgPath = (0, import_node_path4.join)(dir, "package.json");
|
|
239052
|
-
if (
|
|
239053
|
-
|
|
239054
|
-
|
|
239055
|
-
|
|
239056
|
-
|
|
239057
|
-
|
|
239058
|
-
|
|
239059
|
-
|
|
239060
|
-
|
|
239061
|
-
|
|
239062
|
-
|
|
239063
|
-
};
|
|
239064
|
-
} catch {
|
|
239065
|
-
return void 0;
|
|
239066
|
-
}
|
|
238970
|
+
if ((0, import_node_fs3.existsSync)(pkgPath))
|
|
238971
|
+
try {
|
|
238972
|
+
const content = (0, import_node_fs3.readFileSync)(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
238973
|
+
return !pkg.name || typeof pkg.name != "string" ? void 0 : {
|
|
238974
|
+
name: pkg.name,
|
|
238975
|
+
dir,
|
|
238976
|
+
hasTsConfig: (0, import_node_fs3.existsSync)((0, import_node_path4.join)(dir, "tsconfig.json"))
|
|
238977
|
+
};
|
|
238978
|
+
} catch {
|
|
238979
|
+
return;
|
|
238980
|
+
}
|
|
239067
238981
|
}
|
|
239068
238982
|
__name(readMember, "readMember");
|
|
239069
238983
|
function detectWorkspace(rootDir) {
|
|
239070
|
-
const absRoot = (0, import_node_path4.resolve)(rootDir);
|
|
239071
|
-
const pnpmPath = (0, import_node_path4.join)(absRoot, "pnpm-workspace.yaml");
|
|
238984
|
+
const absRoot = (0, import_node_path4.resolve)(rootDir), pnpmPath = (0, import_node_path4.join)(absRoot, "pnpm-workspace.yaml");
|
|
239072
238985
|
if ((0, import_node_fs3.existsSync)(pnpmPath)) {
|
|
239073
|
-
const content = (0, import_node_fs3.readFileSync)(pnpmPath, "utf-8");
|
|
239074
|
-
const patterns = parsePnpmWorkspaceYaml(content);
|
|
238986
|
+
const content = (0, import_node_fs3.readFileSync)(pnpmPath, "utf-8"), patterns = parsePnpmWorkspaceYaml(content);
|
|
239075
238987
|
if (patterns.length > 0) {
|
|
239076
|
-
const
|
|
239077
|
-
const members = dirs.map(readMember).filter((m) => m !== void 0);
|
|
238988
|
+
const members = expandWorkspaceGlobs(absRoot, patterns).map(readMember).filter((m) => m !== void 0);
|
|
239078
238989
|
return { rootDir: absRoot, type: "pnpm", members };
|
|
239079
238990
|
}
|
|
239080
238991
|
}
|
|
239081
238992
|
const pkgPath = (0, import_node_path4.join)(absRoot, "package.json");
|
|
239082
|
-
if ((0, import_node_fs3.existsSync)(pkgPath))
|
|
238993
|
+
if ((0, import_node_fs3.existsSync)(pkgPath))
|
|
239083
238994
|
try {
|
|
239084
|
-
const content = (0, import_node_fs3.readFileSync)(pkgPath, "utf-8");
|
|
239085
|
-
const pkg = JSON.parse(content);
|
|
238995
|
+
const content = (0, import_node_fs3.readFileSync)(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
239086
238996
|
if (Array.isArray(pkg.workspaces)) {
|
|
239087
|
-
const patterns = pkg.workspaces.filter((p) => typeof p
|
|
238997
|
+
const patterns = pkg.workspaces.filter((p) => typeof p == "string");
|
|
239088
238998
|
if (patterns.length > 0) {
|
|
239089
|
-
const
|
|
239090
|
-
const members = dirs.map(readMember).filter((m) => m !== void 0);
|
|
238999
|
+
const members = expandWorkspaceGlobs(absRoot, patterns).map(readMember).filter((m) => m !== void 0);
|
|
239091
239000
|
return { rootDir: absRoot, type: "npm", members };
|
|
239092
239001
|
}
|
|
239093
239002
|
}
|
|
239094
239003
|
} catch {
|
|
239095
239004
|
}
|
|
239096
|
-
}
|
|
239097
|
-
return void 0;
|
|
239098
239005
|
}
|
|
239099
239006
|
__name(detectWorkspace, "detectWorkspace");
|
|
239100
239007
|
function resolvePackageName(name, members) {
|
|
239101
239008
|
const exact = members.find((m) => m.name === name);
|
|
239102
|
-
if (exact)
|
|
239009
|
+
if (exact)
|
|
239103
239010
|
return { kind: "found", member: exact };
|
|
239104
|
-
|
|
239105
|
-
|
|
239106
|
-
const lastSegment = m.name.includes("/") ? m.name.split("/").pop() : m.name;
|
|
239107
|
-
return lastSegment === name;
|
|
239108
|
-
});
|
|
239109
|
-
if (shortMatches.length === 1) {
|
|
239110
|
-
return { kind: "found", member: shortMatches[0] };
|
|
239111
|
-
}
|
|
239112
|
-
if (shortMatches.length > 1) {
|
|
239113
|
-
return { kind: "ambiguous", name, matches: shortMatches };
|
|
239114
|
-
}
|
|
239115
|
-
return {
|
|
239011
|
+
const shortMatches = members.filter((m) => (m.name.includes("/") ? m.name.split("/").pop() : m.name) === name);
|
|
239012
|
+
return shortMatches.length === 1 ? { kind: "found", member: shortMatches[0] } : shortMatches.length > 1 ? { kind: "ambiguous", name, matches: shortMatches } : {
|
|
239116
239013
|
kind: "not-found",
|
|
239117
239014
|
name,
|
|
239118
239015
|
available: members.map((m) => m.name)
|
|
@@ -239136,33 +239033,25 @@ var LOCKFILES = [
|
|
|
239136
239033
|
function detectByLockfile(projectDir) {
|
|
239137
239034
|
for (const { file, pm } of LOCKFILES) {
|
|
239138
239035
|
const lockfilePath = (0, import_node_path5.join)(projectDir, file);
|
|
239139
|
-
if ((0, import_node_fs4.existsSync)(lockfilePath))
|
|
239036
|
+
if ((0, import_node_fs4.existsSync)(lockfilePath))
|
|
239140
239037
|
return { pm, lockfile: file };
|
|
239141
|
-
}
|
|
239142
239038
|
}
|
|
239143
239039
|
return null;
|
|
239144
239040
|
}
|
|
239145
239041
|
__name(detectByLockfile, "detectByLockfile");
|
|
239146
239042
|
function parsePackageManagerField(value) {
|
|
239147
|
-
if (typeof value
|
|
239043
|
+
if (typeof value != "string")
|
|
239148
239044
|
return null;
|
|
239149
|
-
|
|
239150
|
-
|
|
239151
|
-
const name = atIndex > 0 ? value.slice(0, atIndex) : value;
|
|
239152
|
-
if (name === "pnpm" || name === "npm" || name === "yarn") {
|
|
239153
|
-
return name;
|
|
239154
|
-
}
|
|
239155
|
-
return null;
|
|
239045
|
+
const atIndex = value.indexOf("@"), name = atIndex > 0 ? value.slice(0, atIndex) : value;
|
|
239046
|
+
return name === "pnpm" || name === "npm" || name === "yarn" ? name : null;
|
|
239156
239047
|
}
|
|
239157
239048
|
__name(parsePackageManagerField, "parsePackageManagerField");
|
|
239158
239049
|
function detectByPackageJson(projectDir) {
|
|
239159
239050
|
const pkgPath = (0, import_node_path5.join)(projectDir, "package.json");
|
|
239160
|
-
if (!(0, import_node_fs4.existsSync)(pkgPath))
|
|
239051
|
+
if (!(0, import_node_fs4.existsSync)(pkgPath))
|
|
239161
239052
|
return null;
|
|
239162
|
-
}
|
|
239163
239053
|
try {
|
|
239164
|
-
const content = (0, import_node_fs4.readFileSync)(pkgPath, "utf-8");
|
|
239165
|
-
const pkg = JSON.parse(content);
|
|
239054
|
+
const content = (0, import_node_fs4.readFileSync)(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
239166
239055
|
return parsePackageManagerField(pkg.packageManager);
|
|
239167
239056
|
} catch {
|
|
239168
239057
|
return null;
|
|
@@ -239198,23 +239087,18 @@ function createPackageManagerInfo(name, lockfile) {
|
|
|
239198
239087
|
__name(createPackageManagerInfo, "createPackageManagerInfo");
|
|
239199
239088
|
function detectPackageManager(projectDir) {
|
|
239200
239089
|
const lockfileResult = detectByLockfile(projectDir);
|
|
239201
|
-
if (lockfileResult)
|
|
239090
|
+
if (lockfileResult)
|
|
239202
239091
|
return createPackageManagerInfo(lockfileResult.pm, lockfileResult.lockfile);
|
|
239203
|
-
}
|
|
239204
239092
|
const fromField = detectByPackageJson(projectDir);
|
|
239205
|
-
|
|
239206
|
-
return createPackageManagerInfo(fromField, null);
|
|
239207
|
-
}
|
|
239208
|
-
return createPackageManagerInfo("npm", null);
|
|
239093
|
+
return createPackageManagerInfo(fromField || "npm", null);
|
|
239209
239094
|
}
|
|
239210
239095
|
__name(detectPackageManager, "detectPackageManager");
|
|
239211
239096
|
|
|
239212
239097
|
// dist/cli/dependency-check.js
|
|
239213
239098
|
function readPackageJson(dir) {
|
|
239214
239099
|
const pkgPath = (0, import_node_path6.join)(dir, "package.json");
|
|
239215
|
-
if (!(0, import_node_fs5.existsSync)(pkgPath))
|
|
239100
|
+
if (!(0, import_node_fs5.existsSync)(pkgPath))
|
|
239216
239101
|
return null;
|
|
239217
|
-
}
|
|
239218
239102
|
try {
|
|
239219
239103
|
const content = (0, import_node_fs5.readFileSync)(pkgPath, "utf-8");
|
|
239220
239104
|
return JSON.parse(content);
|
|
@@ -239230,42 +239114,31 @@ function checkPackageJsonDirect(pkg, packageName) {
|
|
|
239230
239114
|
pkg.peerDependencies,
|
|
239231
239115
|
pkg.optionalDependencies
|
|
239232
239116
|
];
|
|
239233
|
-
for (const deps of depTypes)
|
|
239234
|
-
if (deps && packageName in deps)
|
|
239117
|
+
for (const deps of depTypes)
|
|
239118
|
+
if (deps && packageName in deps)
|
|
239235
239119
|
return {
|
|
239236
239120
|
found: true,
|
|
239237
239121
|
version: deps[packageName],
|
|
239238
239122
|
source: "package.json"
|
|
239239
239123
|
};
|
|
239240
|
-
}
|
|
239241
|
-
}
|
|
239242
239124
|
return null;
|
|
239243
239125
|
}
|
|
239244
239126
|
__name(checkPackageJsonDirect, "checkPackageJsonDirect");
|
|
239245
239127
|
function execCommand(cmd, cwd) {
|
|
239246
239128
|
return new Promise((resolve4, reject) => {
|
|
239247
|
-
const [command, ...args] = cmd
|
|
239248
|
-
const proc = (0, import_node_child_process.spawn)(command, args, {
|
|
239129
|
+
const [command, ...args] = cmd, proc = (0, import_node_child_process.spawn)(command, args, {
|
|
239249
239130
|
cwd,
|
|
239250
239131
|
stdio: ["ignore", "pipe", "pipe"]
|
|
239251
239132
|
});
|
|
239252
|
-
let stdout = "";
|
|
239253
|
-
let stderr = "";
|
|
239133
|
+
let stdout = "", stderr = "";
|
|
239254
239134
|
proc.stdout.on("data", (data) => {
|
|
239255
239135
|
stdout += data.toString();
|
|
239256
|
-
})
|
|
239257
|
-
proc.stderr.on("data", (data) => {
|
|
239136
|
+
}), proc.stderr.on("data", (data) => {
|
|
239258
239137
|
stderr += data.toString();
|
|
239259
|
-
})
|
|
239260
|
-
proc.on("error", (err) => {
|
|
239138
|
+
}), proc.on("error", (err) => {
|
|
239261
239139
|
reject(err);
|
|
239262
|
-
})
|
|
239263
|
-
|
|
239264
|
-
if (code === 0) {
|
|
239265
|
-
resolve4({ stdout, stderr });
|
|
239266
|
-
} else {
|
|
239267
|
-
reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
239268
|
-
}
|
|
239140
|
+
}), proc.on("close", (code) => {
|
|
239141
|
+
code === 0 ? resolve4({ stdout, stderr }) : reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
239269
239142
|
});
|
|
239270
239143
|
});
|
|
239271
239144
|
}
|
|
@@ -239273,15 +239146,11 @@ __name(execCommand, "execCommand");
|
|
|
239273
239146
|
function parsePnpmWhyOutput(stdout, packageName) {
|
|
239274
239147
|
try {
|
|
239275
239148
|
const result = JSON.parse(stdout);
|
|
239276
|
-
|
|
239277
|
-
|
|
239278
|
-
|
|
239279
|
-
|
|
239280
|
-
|
|
239281
|
-
source: "workspace"
|
|
239282
|
-
};
|
|
239283
|
-
}
|
|
239284
|
-
return null;
|
|
239149
|
+
return result && typeof result == "object" && packageName in result ? {
|
|
239150
|
+
found: true,
|
|
239151
|
+
version: result[packageName]?.version,
|
|
239152
|
+
source: "workspace"
|
|
239153
|
+
} : null;
|
|
239285
239154
|
} catch {
|
|
239286
239155
|
return null;
|
|
239287
239156
|
}
|
|
@@ -239290,15 +239159,11 @@ __name(parsePnpmWhyOutput, "parsePnpmWhyOutput");
|
|
|
239290
239159
|
function parseNpmWhyOutput(stdout, _packageName) {
|
|
239291
239160
|
try {
|
|
239292
239161
|
const result = JSON.parse(stdout);
|
|
239293
|
-
|
|
239294
|
-
|
|
239295
|
-
|
|
239296
|
-
|
|
239297
|
-
|
|
239298
|
-
source: "workspace"
|
|
239299
|
-
};
|
|
239300
|
-
}
|
|
239301
|
-
return null;
|
|
239162
|
+
return Array.isArray(result) && result.length > 0 ? {
|
|
239163
|
+
found: true,
|
|
239164
|
+
version: result[0]?.version,
|
|
239165
|
+
source: "workspace"
|
|
239166
|
+
} : null;
|
|
239302
239167
|
} catch {
|
|
239303
239168
|
return null;
|
|
239304
239169
|
}
|
|
@@ -239308,7 +239173,8 @@ function parseYarnWhyOutput(stdout, _packageName) {
|
|
|
239308
239173
|
if (stdout.trim().length > 0) {
|
|
239309
239174
|
let version;
|
|
239310
239175
|
try {
|
|
239311
|
-
const lines = stdout.trim().split(
|
|
239176
|
+
const lines = stdout.trim().split(`
|
|
239177
|
+
`);
|
|
239312
239178
|
for (const line of lines) {
|
|
239313
239179
|
const obj = JSON.parse(line);
|
|
239314
239180
|
if (obj.type === "info" && obj.data) {
|
|
@@ -239348,31 +239214,21 @@ async function checkViaPackageManager(pm, packageName, cwd) {
|
|
|
239348
239214
|
}
|
|
239349
239215
|
__name(checkViaPackageManager, "checkViaPackageManager");
|
|
239350
239216
|
async function checkDependencies(projectDir) {
|
|
239351
|
-
const pm = detectPackageManager(projectDir);
|
|
239352
|
-
|
|
239353
|
-
let thinkwellStatus = { found: false };
|
|
239354
|
-
let typescriptStatus = { found: false };
|
|
239217
|
+
const pm = detectPackageManager(projectDir), pkg = readPackageJson(projectDir);
|
|
239218
|
+
let thinkwellStatus = { found: false }, typescriptStatus = { found: false };
|
|
239355
239219
|
if (pkg) {
|
|
239356
239220
|
const thinkwellDirect = checkPackageJsonDirect(pkg, "thinkwell");
|
|
239357
|
-
|
|
239358
|
-
thinkwellStatus = thinkwellDirect;
|
|
239359
|
-
}
|
|
239221
|
+
thinkwellDirect && (thinkwellStatus = thinkwellDirect);
|
|
239360
239222
|
const typescriptDirect = checkPackageJsonDirect(pkg, "typescript");
|
|
239361
|
-
|
|
239362
|
-
typescriptStatus = typescriptDirect;
|
|
239363
|
-
}
|
|
239223
|
+
typescriptDirect && (typescriptStatus = typescriptDirect);
|
|
239364
239224
|
}
|
|
239365
239225
|
if (!thinkwellStatus.found) {
|
|
239366
239226
|
const result = await checkViaPackageManager(pm, "thinkwell", projectDir);
|
|
239367
|
-
|
|
239368
|
-
thinkwellStatus = result;
|
|
239369
|
-
}
|
|
239227
|
+
result && (thinkwellStatus = result);
|
|
239370
239228
|
}
|
|
239371
239229
|
if (!typescriptStatus.found) {
|
|
239372
239230
|
const result = await checkViaPackageManager(pm, "typescript", projectDir);
|
|
239373
|
-
|
|
239374
|
-
typescriptStatus = result;
|
|
239375
|
-
}
|
|
239231
|
+
result && (typescriptStatus = result);
|
|
239376
239232
|
}
|
|
239377
239233
|
return {
|
|
239378
239234
|
thinkwell: thinkwellStatus,
|
|
@@ -239388,34 +239244,12 @@ __name(hasPackageJson, "hasPackageJson");
|
|
|
239388
239244
|
|
|
239389
239245
|
// dist/cli/dependency-errors.js
|
|
239390
239246
|
function formatMissingDependencyError(result) {
|
|
239391
|
-
const { thinkwell, typescript, packageManager } = result;
|
|
239392
|
-
|
|
239393
|
-
const missing = [];
|
|
239394
|
-
if (!thinkwell.found)
|
|
239395
|
-
missing.push("thinkwell");
|
|
239396
|
-
if (!typescript.found)
|
|
239397
|
-
missing.push("typescript");
|
|
239398
|
-
if (missing.length === 0) {
|
|
239247
|
+
const { thinkwell, typescript, packageManager } = result, pm = packageManager, missing = [];
|
|
239248
|
+
if (thinkwell.found || missing.push("thinkwell"), typescript.found || missing.push("typescript"), missing.length === 0)
|
|
239399
239249
|
return "";
|
|
239400
|
-
}
|
|
239401
239250
|
const lines = [];
|
|
239402
|
-
|
|
239403
|
-
|
|
239404
|
-
} else {
|
|
239405
|
-
lines.push(`Error: This project has a package.json but is missing required dependencies.`);
|
|
239406
|
-
}
|
|
239407
|
-
lines.push("");
|
|
239408
|
-
lines.push("When a project has explicit configuration, thinkwell expects explicit dependencies.");
|
|
239409
|
-
lines.push("This ensures you get the versions you expect, not versions bundled with the CLI.");
|
|
239410
|
-
lines.push("");
|
|
239411
|
-
lines.push("Run 'thinkwell init' to add the required dependencies, or add them manually:");
|
|
239412
|
-
if (!thinkwell.found) {
|
|
239413
|
-
lines.push(` ${pm.addCommand("thinkwell")}`);
|
|
239414
|
-
}
|
|
239415
|
-
if (!typescript.found) {
|
|
239416
|
-
lines.push(` ${pm.addCommand("typescript", true)}`);
|
|
239417
|
-
}
|
|
239418
|
-
return lines.join("\n");
|
|
239251
|
+
return missing.length === 1 ? lines.push(`Error: This project has a package.json but no dependency on '${missing[0]}'.`) : lines.push("Error: This project has a package.json but is missing required dependencies."), lines.push(""), lines.push("When a project has explicit configuration, thinkwell expects explicit dependencies."), lines.push("This ensures you get the versions you expect, not versions bundled with the CLI."), lines.push(""), lines.push("Run 'thinkwell init' to add the required dependencies, or add them manually:"), thinkwell.found || lines.push(` ${pm.addCommand("thinkwell")}`), typescript.found || lines.push(` ${pm.addCommand("typescript", true)}`), lines.join(`
|
|
239252
|
+
`);
|
|
239419
239253
|
}
|
|
239420
239254
|
__name(formatMissingDependencyError, "formatMissingDependencyError");
|
|
239421
239255
|
function hasMissingDependencies(result) {
|
|
@@ -239440,73 +239274,49 @@ function formatDiagnostics(diagnostics, pretty) {
|
|
|
239440
239274
|
}
|
|
239441
239275
|
__name(formatDiagnostics, "formatDiagnostics");
|
|
239442
239276
|
function checkPackage(dir, pretty, projectDir) {
|
|
239443
|
-
const configPath = (0, import_node_path7.resolve)(dir, "tsconfig.json");
|
|
239444
|
-
|
|
239445
|
-
|
|
239446
|
-
|
|
239447
|
-
|
|
239448
|
-
|
|
239449
|
-
return configErrors.filter((d) => d.category === import_typescript3.default.DiagnosticCategory.Error).length;
|
|
239450
|
-
}
|
|
239451
|
-
}
|
|
239452
|
-
const diagnostics = import_typescript3.default.getPreEmitDiagnostics(program);
|
|
239453
|
-
const errors = diagnostics.filter((d) => d.category === import_typescript3.default.DiagnosticCategory.Error);
|
|
239454
|
-
if (diagnostics.length > 0) {
|
|
239455
|
-
process.stderr.write("\n");
|
|
239456
|
-
process.stderr.write(formatDiagnostics(diagnostics, pretty));
|
|
239457
|
-
}
|
|
239458
|
-
return errors.length;
|
|
239277
|
+
const configPath = (0, import_node_path7.resolve)(dir, "tsconfig.json"), { program, configErrors } = projectDir ? createThinkwellProgram({ configPath, projectDir }) : createThinkwellProgram(configPath);
|
|
239278
|
+
if (configErrors.length > 0 && (process.stderr.write(formatDiagnostics(configErrors, pretty)), configErrors.some((d) => d.category === import_typescript3.default.DiagnosticCategory.Error)))
|
|
239279
|
+
return configErrors.filter((d) => d.category === import_typescript3.default.DiagnosticCategory.Error).length;
|
|
239280
|
+
const diagnostics = import_typescript3.default.getPreEmitDiagnostics(program), errors = diagnostics.filter((d) => d.category === import_typescript3.default.DiagnosticCategory.Error);
|
|
239281
|
+
return diagnostics.length > 0 && (process.stderr.write(`
|
|
239282
|
+
`), process.stderr.write(formatDiagnostics(diagnostics, pretty))), errors.length;
|
|
239459
239283
|
}
|
|
239460
239284
|
__name(checkPackage, "checkPackage");
|
|
239461
239285
|
async function runCheck(options) {
|
|
239462
|
-
const cwd = process.cwd();
|
|
239463
|
-
|
|
239464
|
-
|
|
239465
|
-
|
|
239466
|
-
process.stderr.write('Error: --package can only be used in a workspace.\nNo pnpm-workspace.yaml or package.json "workspaces" found in current directory.\n');
|
|
239467
|
-
process.exit(2);
|
|
239468
|
-
}
|
|
239469
|
-
if (!workspace) {
|
|
239286
|
+
const cwd = process.cwd(), pretty = options.pretty ?? process.stdout.isTTY ?? false, workspace = detectWorkspace(cwd);
|
|
239287
|
+
if (options.packages && options.packages.length > 0 && !workspace && (process.stderr.write(`Error: --package can only be used in a workspace.
|
|
239288
|
+
No pnpm-workspace.yaml or package.json "workspaces" found in current directory.
|
|
239289
|
+
`), process.exit(2)), !workspace) {
|
|
239470
239290
|
if (hasPackageJson(cwd)) {
|
|
239471
239291
|
const depCheck = await checkDependencies(cwd);
|
|
239472
|
-
|
|
239473
|
-
|
|
239474
|
-
process.exit(2);
|
|
239475
|
-
}
|
|
239292
|
+
hasMissingDependencies(depCheck) && (process.stderr.write(formatMissingDependencyError(depCheck) + `
|
|
239293
|
+
`), process.exit(2));
|
|
239476
239294
|
}
|
|
239477
239295
|
const configPath = (0, import_node_path7.resolve)(cwd, "tsconfig.json");
|
|
239478
|
-
|
|
239479
|
-
|
|
239480
|
-
|
|
239481
|
-
|
|
239482
|
-
process.exit(2);
|
|
239483
|
-
}
|
|
239296
|
+
(0, import_node_fs6.existsSync)(configPath) || (process.stderr.write(`Error: Cannot find tsconfig.json
|
|
239297
|
+
`), process.stderr.write(`
|
|
239298
|
+
`), process.stderr.write(` Run this command from a directory with a tsconfig.json.
|
|
239299
|
+
`), process.exit(2));
|
|
239484
239300
|
let pkgName = cwd.split("/").pop() ?? "project";
|
|
239485
239301
|
try {
|
|
239486
239302
|
const pkgPath = (0, import_node_path7.join)(cwd, "package.json");
|
|
239487
239303
|
if ((0, import_node_fs6.existsSync)(pkgPath)) {
|
|
239488
239304
|
const pkg = JSON.parse((await import("node:fs")).readFileSync(pkgPath, "utf-8"));
|
|
239489
|
-
|
|
239490
|
-
pkgName = pkg.name;
|
|
239305
|
+
pkg.name && (pkgName = pkg.name);
|
|
239491
239306
|
}
|
|
239492
239307
|
} catch {
|
|
239493
239308
|
}
|
|
239494
239309
|
process.stderr.write(` Checking ${pkgName}...
|
|
239495
239310
|
`);
|
|
239496
239311
|
const projectDir = hasPackageJson(cwd) ? cwd : void 0;
|
|
239497
|
-
|
|
239498
|
-
|
|
239499
|
-
process.exit(1);
|
|
239500
|
-
}
|
|
239501
|
-
process.stderr.write(" No type errors found.\n");
|
|
239312
|
+
checkPackage(cwd, pretty, projectDir) > 0 && process.exit(1), process.stderr.write(` No type errors found.
|
|
239313
|
+
`);
|
|
239502
239314
|
return;
|
|
239503
239315
|
}
|
|
239504
239316
|
if (hasPackageJson(workspace.rootDir)) {
|
|
239505
239317
|
const depCheck = await checkDependencies(workspace.rootDir);
|
|
239506
|
-
|
|
239507
|
-
|
|
239508
|
-
process.exit(2);
|
|
239509
|
-
}
|
|
239318
|
+
hasMissingDependencies(depCheck) && (process.stderr.write(formatMissingDependencyError(depCheck) + `
|
|
239319
|
+
`), process.exit(2));
|
|
239510
239320
|
}
|
|
239511
239321
|
let packagesToCheck;
|
|
239512
239322
|
if (options.packages && options.packages.length > 0) {
|
|
@@ -239515,45 +239325,37 @@ async function runCheck(options) {
|
|
|
239515
239325
|
const result = resolvePackageName(name, workspace.members);
|
|
239516
239326
|
switch (result.kind) {
|
|
239517
239327
|
case "found":
|
|
239518
|
-
|
|
239519
|
-
|
|
239520
|
-
`);
|
|
239521
|
-
process.exit(2);
|
|
239522
|
-
}
|
|
239523
|
-
packagesToCheck.push(result.member);
|
|
239328
|
+
result.member.hasTsConfig || (process.stderr.write(`Error: Package "${result.member.name}" has no tsconfig.json.
|
|
239329
|
+
`), process.exit(2)), packagesToCheck.push(result.member);
|
|
239524
239330
|
break;
|
|
239525
239331
|
case "ambiguous":
|
|
239526
239332
|
process.stderr.write(`Error: Ambiguous package name "${result.name}". Matches:
|
|
239527
239333
|
`);
|
|
239528
|
-
for (const m of result.matches)
|
|
239334
|
+
for (const m of result.matches)
|
|
239529
239335
|
process.stderr.write(` - ${m.name}
|
|
239530
239336
|
`);
|
|
239531
|
-
|
|
239532
|
-
|
|
239533
|
-
|
|
239337
|
+
process.stderr.write(`
|
|
239338
|
+
Use the full package name to disambiguate.
|
|
239339
|
+
`), process.exit(2);
|
|
239534
239340
|
break;
|
|
239535
239341
|
// unreachable but satisfies control flow
|
|
239536
239342
|
case "not-found":
|
|
239537
239343
|
process.stderr.write(`Error: Package "${result.name}" not found in workspace.
|
|
239344
|
+
`), process.stderr.write(`
|
|
239345
|
+
Available packages:
|
|
239538
239346
|
`);
|
|
239539
|
-
|
|
239540
|
-
for (const available of result.available) {
|
|
239347
|
+
for (const available of result.available)
|
|
239541
239348
|
process.stderr.write(` - ${available}
|
|
239542
239349
|
`);
|
|
239543
|
-
}
|
|
239544
239350
|
process.exit(2);
|
|
239545
239351
|
break;
|
|
239546
239352
|
}
|
|
239547
239353
|
}
|
|
239548
|
-
} else
|
|
239354
|
+
} else
|
|
239549
239355
|
packagesToCheck = workspace.members.filter((m) => m.hasTsConfig);
|
|
239550
|
-
|
|
239551
|
-
|
|
239552
|
-
|
|
239553
|
-
process.exit(2);
|
|
239554
|
-
}
|
|
239555
|
-
let totalErrors = 0;
|
|
239556
|
-
let packagesWithErrors = 0;
|
|
239356
|
+
packagesToCheck.length === 0 && (process.stderr.write(`No TypeScript packages found in workspace.
|
|
239357
|
+
`), process.exit(2));
|
|
239358
|
+
let totalErrors = 0, packagesWithErrors = 0;
|
|
239557
239359
|
const total = packagesToCheck.length;
|
|
239558
239360
|
for (const member of packagesToCheck) {
|
|
239559
239361
|
process.stderr.write(` Checking ${member.name}...`);
|
|
@@ -239561,53 +239363,37 @@ async function runCheck(options) {
|
|
|
239561
239363
|
process.chdir(member.dir);
|
|
239562
239364
|
try {
|
|
239563
239365
|
const errorCount = checkPackage(member.dir, pretty, member.dir);
|
|
239564
|
-
|
|
239565
|
-
|
|
239566
|
-
packagesWithErrors++;
|
|
239567
|
-
} else {
|
|
239568
|
-
process.stderr.write(" ok\n");
|
|
239569
|
-
}
|
|
239366
|
+
errorCount > 0 ? (totalErrors += errorCount, packagesWithErrors++) : process.stderr.write(` ok
|
|
239367
|
+
`);
|
|
239570
239368
|
} finally {
|
|
239571
239369
|
process.chdir(originalCwd);
|
|
239572
239370
|
}
|
|
239573
239371
|
}
|
|
239574
|
-
process.stderr.write(
|
|
239575
|
-
|
|
239576
|
-
|
|
239577
|
-
`);
|
|
239578
|
-
process.exit(1);
|
|
239579
|
-
}
|
|
239580
|
-
process.stderr.write(` All ${total} package${total === 1 ? "" : "s"} passed.
|
|
239372
|
+
process.stderr.write(`
|
|
239373
|
+
`), packagesWithErrors > 0 && (process.stderr.write(` ${packagesWithErrors} of ${total} package${total === 1 ? "" : "s"} had errors.
|
|
239374
|
+
`), process.exit(1)), process.stderr.write(` All ${total} package${total === 1 ? "" : "s"} passed.
|
|
239581
239375
|
`);
|
|
239582
239376
|
}
|
|
239583
239377
|
__name(runCheck, "runCheck");
|
|
239584
239378
|
function parseCheckArgs(args) {
|
|
239585
239379
|
const options = {};
|
|
239586
239380
|
let i = 0;
|
|
239587
|
-
|
|
239381
|
+
for (; i < args.length; ) {
|
|
239588
239382
|
const arg = args[i];
|
|
239589
239383
|
if (arg === "-p" || arg === "--package") {
|
|
239590
|
-
i
|
|
239591
|
-
if (i >= args.length) {
|
|
239384
|
+
if (i++, i >= args.length)
|
|
239592
239385
|
throw new Error("Missing value for --package");
|
|
239593
|
-
|
|
239594
|
-
|
|
239595
|
-
options.packages = [];
|
|
239596
|
-
options.packages.push(args[i]);
|
|
239597
|
-
} else if (arg === "--pretty") {
|
|
239386
|
+
options.packages || (options.packages = []), options.packages.push(args[i]);
|
|
239387
|
+
} else if (arg === "--pretty")
|
|
239598
239388
|
options.pretty = true;
|
|
239599
|
-
|
|
239389
|
+
else if (arg === "--no-pretty")
|
|
239600
239390
|
options.pretty = false;
|
|
239601
|
-
|
|
239602
|
-
throw new Error(`Unknown option: ${arg}`);
|
|
239603
|
-
} else {
|
|
239604
|
-
throw new Error(`Unexpected argument: ${arg}
|
|
239391
|
+
else throw arg.startsWith("-") ? new Error(`Unknown option: ${arg}`) : new Error(`Unexpected argument: ${arg}
|
|
239605
239392
|
|
|
239606
239393
|
"thinkwell check" type-checks the project without producing output.
|
|
239607
239394
|
It does not take positional arguments.
|
|
239608
239395
|
|
|
239609
239396
|
To check a specific workspace package, use: thinkwell check -p ${arg}`);
|
|
239610
|
-
}
|
|
239611
239397
|
i++;
|
|
239612
239398
|
}
|
|
239613
239399
|
return options;
|
|
@@ -239646,7 +239432,8 @@ ${greenBold("Examples:")}
|
|
|
239646
239432
|
${cyanBold("thinkwell check")} ${cyan("-p acp")} Check a specific workspace package
|
|
239647
239433
|
${cyanBold("thinkwell check")} ${cyan("-p acp -p protocol")} Check multiple packages
|
|
239648
239434
|
${cyanBold("thinkwell check")} ${cyan("--no-pretty")} Disable colorized output ${dim("(for CI)")}
|
|
239649
|
-
`.trim() +
|
|
239435
|
+
`.trim() + `
|
|
239436
|
+
`);
|
|
239650
239437
|
}
|
|
239651
239438
|
__name(showCheckHelp, "showCheckHelp");
|
|
239652
239439
|
// Annotate the CommonJS export names for ESM import in node:
|