@deepseek-ai/dsh-typert-generator 0.2.1-alpha.2 → 0.2.1-alpha.4
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/README.i18n.yaml +16 -10
- package/README.md +30 -3
- package/README.zh.md +30 -3
- package/lib/index.js +693 -101
- package/lib/types/analyzer.d.ts +34 -2
- package/lib/types/analyzer.js +176 -45
- package/lib/types/artifact-files.d.ts +30 -0
- package/lib/types/artifact-files.js +57 -0
- package/lib/types/build-output-guard.d.ts +61 -0
- package/lib/types/build-output-guard.js +193 -0
- package/lib/types/emitter.d.ts +3 -0
- package/lib/types/emitter.js +148 -48
- package/lib/types/index.d.ts +3 -2
- package/lib/types/index.js +2 -1
- package/lib/types/model.d.ts +6 -2
- package/lib/types/tool-schema.d.ts +20 -0
- package/lib/types/tool-schema.js +156 -0
- package/lib/types/tsdown-plugin.d.ts +21 -6
- package/lib/types/tsdown-plugin.js +171 -72
- package/lib/types/worker.d.ts +28 -0
- package/lib/types/worker.js +49 -0
- package/lib/types/workspace.d.ts +34 -2
- package/lib/types/workspace.js +55 -7
- package/package.json +7 -6
package/lib/types/workspace.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export interface WorkspaceTypertGeneratorOptions {
|
|
|
19
19
|
* merges) run regardless.
|
|
20
20
|
*/
|
|
21
21
|
readonly checkDiagnostics?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Fail when an analyzed face program loads a file from a workspace
|
|
24
|
+
* package's `lib/` directory or cannot resolve an import of a workspace
|
|
25
|
+
* package (default false); see
|
|
26
|
+
* `WorkspaceAnalyzerOptions.rejectBuildOutputs`.
|
|
27
|
+
*/
|
|
28
|
+
readonly rejectBuildOutputs?: boolean;
|
|
22
29
|
}
|
|
23
30
|
/** Discover, analyze, and emit package reflection from independent faces. */
|
|
24
31
|
export declare class WorkspaceTypertGenerator {
|
|
@@ -36,16 +43,41 @@ export declare class WorkspaceTypertGenerator {
|
|
|
36
43
|
* Find public package faces that contribute Cordis services/events or
|
|
37
44
|
* explicitly tagged Typert roots.
|
|
38
45
|
* @param faces - optional independent program faces to inspect.
|
|
46
|
+
* @param includeManifest - optional `package.json` predicate; a rejected package's sources and project config are not read.
|
|
39
47
|
* @returns discovered packages in stable package-name order.
|
|
40
48
|
*/
|
|
41
|
-
discover(faces?: readonly TypertFace[]): DiscoveredTypertPackage[];
|
|
49
|
+
discover(faces?: readonly TypertFace[], includeManifest?: (manifest: Readonly<Record<string, unknown>>) => boolean): DiscoveredTypertPackage[];
|
|
42
50
|
/**
|
|
43
51
|
* Generate all discovered contributors, or an explicit package subset.
|
|
44
|
-
* @param packages - optional exact package names
|
|
52
|
+
* @param packages - optional exact package names to emit; every pass includes the same face-wide declaration merges.
|
|
45
53
|
* @param faces - optional independent program faces to analyze.
|
|
46
54
|
* @returns one artifact per package face.
|
|
47
55
|
*/
|
|
48
56
|
generate(packages?: readonly string[], faces?: readonly TypertFace[]): WorkspaceEmitResult[];
|
|
57
|
+
/**
|
|
58
|
+
* Generate every explicit contributor: a package whose manifest declares a
|
|
59
|
+
* Typert artifact export and whose public graph has a Typert surface.
|
|
60
|
+
* @param faces - optional independent program faces to analyze.
|
|
61
|
+
* @returns one artifact per contributor face.
|
|
62
|
+
*/
|
|
63
|
+
generateContributors(faces?: readonly TypertFace[]): WorkspaceEmitResult[];
|
|
49
64
|
private validateExport;
|
|
50
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Find the workspace root that Typert generation runs against: the nearest
|
|
68
|
+
* directory at or above `start` that holds both `tsconfig.host.json` and
|
|
69
|
+
* `packages/`. The analyzer registers projects under `<root>/packages`, so a
|
|
70
|
+
* package's own `tsconfig.host.json` face leaf does not qualify.
|
|
71
|
+
* @param start - directory to search from, such as a bundle output or a working directory.
|
|
72
|
+
* @returns the absolute workspace root.
|
|
73
|
+
* @throws If no ancestor of `start` qualifies.
|
|
74
|
+
*/
|
|
75
|
+
export declare function findWorkspaceRoot(start: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Whether a `package.json#exports` field declares a Typert artifact subpath
|
|
78
|
+
* (`./typert`, `./client/typert`, or `./remote`).
|
|
79
|
+
* @param exportsField - the manifest's `exports` value.
|
|
80
|
+
* @returns true when the package opts in to Typert publication.
|
|
81
|
+
*/
|
|
82
|
+
export declare function hasTypertExport(exportsField: unknown): boolean;
|
|
51
83
|
//# sourceMappingURL=workspace.d.ts.map
|
package/lib/types/workspace.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Workspace-level discovery and model-driven Typert generation.
|
|
3
3
|
* @module @deepseek-ai/dsh-typert-generator/workspace
|
|
4
4
|
*/
|
|
5
|
-
import { readFileSync } from 'node:fs';
|
|
6
|
-
import { resolve } from 'node:path';
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
6
|
+
import { dirname, join, resolve } from 'node:path';
|
|
7
7
|
import { TypertAnalysisError, WorkspaceAnalyzer, WorkspaceCaches } from "./analyzer.js";
|
|
8
8
|
import { FaceModelEmitter } from "./emitter.js";
|
|
9
9
|
/** Discover, analyze, and emit package reflection from independent faces. */
|
|
@@ -25,34 +25,39 @@ export class WorkspaceTypertGenerator {
|
|
|
25
25
|
* Find public package faces that contribute Cordis services/events or
|
|
26
26
|
* explicitly tagged Typert roots.
|
|
27
27
|
* @param faces - optional independent program faces to inspect.
|
|
28
|
+
* @param includeManifest - optional `package.json` predicate; a rejected package's sources and project config are not read.
|
|
28
29
|
* @returns discovered packages in stable package-name order.
|
|
29
30
|
*/
|
|
30
|
-
discover(faces) {
|
|
31
|
+
discover(faces, includeManifest) {
|
|
31
32
|
return new WorkspaceAnalyzer({
|
|
32
33
|
root: this.root,
|
|
33
34
|
caches: this.caches,
|
|
34
35
|
...(faces === undefined ? {} : { faces }),
|
|
35
|
-
}).discoverPackages();
|
|
36
|
+
}).discoverPackages(includeManifest);
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* Generate all discovered contributors, or an explicit package subset.
|
|
39
|
-
* @param packages - optional exact package names
|
|
40
|
+
* @param packages - optional exact package names to emit; every pass includes the same face-wide declaration merges.
|
|
40
41
|
* @param faces - optional independent program faces to analyze.
|
|
41
42
|
* @returns one artifact per package face.
|
|
42
43
|
*/
|
|
43
44
|
generate(packages, faces) {
|
|
44
|
-
const
|
|
45
|
+
const contributors = this.discover(faces).map(candidate => candidate.package);
|
|
46
|
+
const selected = new Set(packages ?? contributors);
|
|
45
47
|
const workspace = new WorkspaceAnalyzer({
|
|
46
48
|
root: this.root,
|
|
47
|
-
packages:
|
|
49
|
+
packages: contributors,
|
|
48
50
|
caches: this.caches,
|
|
49
51
|
...(faces === undefined ? {} : { faces }),
|
|
50
52
|
...(this.options.checkDiagnostics === undefined ? {} : { checkDiagnostics: this.options.checkDiagnostics }),
|
|
53
|
+
...(this.options.rejectBuildOutputs === undefined ? {} : { rejectBuildOutputs: this.options.rejectBuildOutputs }),
|
|
51
54
|
}).analyze();
|
|
52
55
|
const artifacts = [];
|
|
53
56
|
for (const face of workspace.faces) {
|
|
54
57
|
const emitter = new FaceModelEmitter(face);
|
|
55
58
|
for (const packageModel of face.packages) {
|
|
59
|
+
if (!selected.has(packageModel.name))
|
|
60
|
+
continue;
|
|
56
61
|
const artifact = {
|
|
57
62
|
...emitter.emit(packageModel.name),
|
|
58
63
|
packageRoot: packageModel.root,
|
|
@@ -63,6 +68,17 @@ export class WorkspaceTypertGenerator {
|
|
|
63
68
|
}
|
|
64
69
|
return artifacts;
|
|
65
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Generate every explicit contributor: a package whose manifest declares a
|
|
73
|
+
* Typert artifact export and whose public graph has a Typert surface.
|
|
74
|
+
* @param faces - optional independent program faces to analyze.
|
|
75
|
+
* @returns one artifact per contributor face.
|
|
76
|
+
*/
|
|
77
|
+
generateContributors(faces) {
|
|
78
|
+
const packages = this.discover(faces, manifest => hasTypertExport(manifest.exports))
|
|
79
|
+
.map(candidate => candidate.package);
|
|
80
|
+
return packages.length === 0 ? [] : this.generate(packages, faces);
|
|
81
|
+
}
|
|
66
82
|
validateExport(artifact) {
|
|
67
83
|
const manifestPath = resolve(this.root, artifact.packageRoot, 'package.json');
|
|
68
84
|
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
@@ -115,6 +131,38 @@ export class WorkspaceTypertGenerator {
|
|
|
115
131
|
}
|
|
116
132
|
}
|
|
117
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Find the workspace root that Typert generation runs against: the nearest
|
|
136
|
+
* directory at or above `start` that holds both `tsconfig.host.json` and
|
|
137
|
+
* `packages/`. The analyzer registers projects under `<root>/packages`, so a
|
|
138
|
+
* package's own `tsconfig.host.json` face leaf does not qualify.
|
|
139
|
+
* @param start - directory to search from, such as a bundle output or a working directory.
|
|
140
|
+
* @returns the absolute workspace root.
|
|
141
|
+
* @throws If no ancestor of `start` qualifies.
|
|
142
|
+
*/
|
|
143
|
+
export function findWorkspaceRoot(start) {
|
|
144
|
+
let current = resolve(start);
|
|
145
|
+
while (!existsSync(join(current, 'tsconfig.host.json')) || !existsSync(join(current, 'packages'))) {
|
|
146
|
+
const parent = dirname(current);
|
|
147
|
+
if (parent === current)
|
|
148
|
+
throw new Error(`typert-generator: cannot find workspace root above ${start}`);
|
|
149
|
+
current = parent;
|
|
150
|
+
}
|
|
151
|
+
return current;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Whether a `package.json#exports` field declares a Typert artifact subpath
|
|
155
|
+
* (`./typert`, `./client/typert`, or `./remote`).
|
|
156
|
+
* @param exportsField - the manifest's `exports` value.
|
|
157
|
+
* @returns true when the package opts in to Typert publication.
|
|
158
|
+
*/
|
|
159
|
+
export function hasTypertExport(exportsField) {
|
|
160
|
+
if (exportsField === null || typeof exportsField !== 'object' || Array.isArray(exportsField))
|
|
161
|
+
return false;
|
|
162
|
+
return Object.hasOwn(exportsField, './typert')
|
|
163
|
+
|| Object.hasOwn(exportsField, './client/typert')
|
|
164
|
+
|| Object.hasOwn(exportsField, './remote');
|
|
165
|
+
}
|
|
118
166
|
function sameExport(actual, expected) {
|
|
119
167
|
if (actual === null || typeof actual !== 'object' || Array.isArray(actual))
|
|
120
168
|
return false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-typert-generator",
|
|
3
3
|
"description": "TypeScript project analyzer and model-driven Typert artifact generator",
|
|
4
|
-
"version": "0.2.1-alpha.
|
|
4
|
+
"version": "0.2.1-alpha.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -36,12 +36,13 @@
|
|
|
36
36
|
"typescript": "^6.0.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@deepseek-ai/cordis": "~4.0.5-alpha.
|
|
39
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@deepseek-ai/dsh-
|
|
43
|
-
"@deepseek-ai/dsh-
|
|
44
|
-
"@deepseek-ai/
|
|
45
|
-
"
|
|
42
|
+
"@deepseek-ai/dsh-tools": "0.2.1-alpha.4",
|
|
43
|
+
"@deepseek-ai/dsh-tool-cordis": "0.2.1-alpha.4",
|
|
44
|
+
"@deepseek-ai/dsh-typert-registry": "0.2.1-alpha.4",
|
|
45
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.2",
|
|
46
|
+
"zod": "4.4.3"
|
|
46
47
|
}
|
|
47
48
|
}
|