@tagma/sdk 0.4.6 → 0.4.8
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.md +3 -34
- package/dist/dag.d.ts +0 -1
- package/dist/dag.d.ts.map +1 -1
- package/dist/dag.js +0 -5
- package/dist/dag.js.map +1 -1
- package/dist/schema.d.ts +1 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +29 -143
- package/dist/schema.js.map +1 -1
- package/dist/schema.test.d.ts +2 -0
- package/dist/schema.test.d.ts.map +1 -0
- package/dist/schema.test.js +90 -0
- package/dist/schema.test.js.map +1 -0
- package/dist/sdk.d.ts +1 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -3
- package/dist/sdk.js.map +1 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -12
- package/dist/utils.js.map +1 -1
- package/dist/validate-raw.d.ts.map +1 -1
- package/dist/validate-raw.js +1 -4
- package/dist/validate-raw.js.map +1 -1
- package/package.json +1 -1
- package/src/dag.ts +17 -20
- package/src/schema.test.ts +97 -0
- package/src/schema.ts +41 -178
- package/src/sdk.ts +2 -6
- package/src/utils.ts +1 -15
- package/src/validate-raw.ts +1 -4
- package/dist/templates.d.ts +0 -20
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -93
- package/dist/templates.js.map +0 -1
- package/src/templates.ts +0 -97
package/dist/templates.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// ═══ Template Discovery (F1) ═══
|
|
2
|
-
//
|
|
3
|
-
// Public helpers so editors / UIs can enumerate installed `@tagma/template-*`
|
|
4
|
-
// packages in a workspace and read each template's declarative metadata
|
|
5
|
-
// (name, description, params) without actually expanding the template.
|
|
6
|
-
//
|
|
7
|
-
// The legacy private `loadTemplate` in schema.ts uses Bun-specific APIs
|
|
8
|
-
// (Bun.file, require.resolve). These helpers are Node-compatible because
|
|
9
|
-
// the editor server runs on Node, not Bun.
|
|
10
|
-
import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
|
|
11
|
-
import { join } from 'path';
|
|
12
|
-
import yaml from 'js-yaml';
|
|
13
|
-
/**
|
|
14
|
-
* Scan the workspace's `node_modules/@tagma/*` for packages whose name starts
|
|
15
|
-
* with `template-` and load each one's manifest. Packages without a valid
|
|
16
|
-
* `template.yaml` (or that fail to parse) are silently skipped.
|
|
17
|
-
*
|
|
18
|
-
* Returns an empty array when `workDir` doesn't exist or has no such packages.
|
|
19
|
-
*/
|
|
20
|
-
export function discoverTemplates(workDir) {
|
|
21
|
-
const out = [];
|
|
22
|
-
const scopeDir = join(workDir, 'node_modules', '@tagma');
|
|
23
|
-
if (!existsSync(scopeDir))
|
|
24
|
-
return out;
|
|
25
|
-
let entries = [];
|
|
26
|
-
try {
|
|
27
|
-
entries = readdirSync(scopeDir);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return out;
|
|
31
|
-
}
|
|
32
|
-
for (const entry of entries) {
|
|
33
|
-
if (!entry.startsWith('template-'))
|
|
34
|
-
continue;
|
|
35
|
-
const pkgDir = join(scopeDir, entry);
|
|
36
|
-
try {
|
|
37
|
-
const st = statSync(pkgDir);
|
|
38
|
-
if (!st.isDirectory())
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
const ref = `@tagma/${entry}`;
|
|
45
|
-
const manifest = loadTemplateManifestFromDir(pkgDir, ref);
|
|
46
|
-
if (manifest)
|
|
47
|
-
out.push(manifest);
|
|
48
|
-
}
|
|
49
|
-
// Sort alphabetically for deterministic UI rendering.
|
|
50
|
-
out.sort((a, b) => a.ref.localeCompare(b.ref));
|
|
51
|
-
return out;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Load a single template's manifest by its ref (e.g. `@tagma/template-review`)
|
|
55
|
-
* from the given workspace's `node_modules`. Returns `null` if the package
|
|
56
|
-
* isn't installed or its manifest can't be parsed.
|
|
57
|
-
*/
|
|
58
|
-
export function loadTemplateManifest(ref, workDir) {
|
|
59
|
-
// Only @tagma/template-* refs are supported (matches SDK validateTemplateRef).
|
|
60
|
-
const stripped = ref.replace(/@v\d+$/, '');
|
|
61
|
-
if (!stripped.startsWith('@tagma/template-'))
|
|
62
|
-
return null;
|
|
63
|
-
const pkgDir = join(workDir, 'node_modules', stripped);
|
|
64
|
-
if (!existsSync(pkgDir))
|
|
65
|
-
return null;
|
|
66
|
-
return loadTemplateManifestFromDir(pkgDir, stripped);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Resolve a template manifest from an absolute package directory. Tries
|
|
70
|
-
* `template.yaml` first (the documented convention), then a `template` export
|
|
71
|
-
* from `package.json`'s `main`. Returns `null` on any failure so discovery
|
|
72
|
-
* stays robust against malformed packages.
|
|
73
|
-
*/
|
|
74
|
-
function loadTemplateManifestFromDir(pkgDir, ref) {
|
|
75
|
-
const yamlPath = join(pkgDir, 'template.yaml');
|
|
76
|
-
if (existsSync(yamlPath)) {
|
|
77
|
-
try {
|
|
78
|
-
const content = readFileSync(yamlPath, 'utf-8');
|
|
79
|
-
const doc = yaml.load(content);
|
|
80
|
-
const tpl = (doc && typeof doc === 'object' && 'template' in doc
|
|
81
|
-
? doc.template
|
|
82
|
-
: doc);
|
|
83
|
-
if (tpl && typeof tpl === 'object' && tpl.name && Array.isArray(tpl.tasks)) {
|
|
84
|
-
return { ...tpl, ref };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=templates.js.map
|
package/dist/templates.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,kCAAkC;AACl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I,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3E,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/src/templates.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// ═══ Template Discovery (F1) ═══
|
|
2
|
-
//
|
|
3
|
-
// Public helpers so editors / UIs can enumerate installed `@tagma/template-*`
|
|
4
|
-
// packages in a workspace and read each template's declarative metadata
|
|
5
|
-
// (name, description, params) without actually expanding the template.
|
|
6
|
-
//
|
|
7
|
-
// The legacy private `loadTemplate` in schema.ts uses Bun-specific APIs
|
|
8
|
-
// (Bun.file, require.resolve). These helpers are Node-compatible because
|
|
9
|
-
// the editor server runs on Node, not Bun.
|
|
10
|
-
|
|
11
|
-
import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
|
|
12
|
-
import { join } from 'path';
|
|
13
|
-
import yaml from 'js-yaml';
|
|
14
|
-
import type { TemplateConfig } from './types';
|
|
15
|
-
|
|
16
|
-
export interface TemplateManifest extends TemplateConfig {
|
|
17
|
-
/** The package ref as it would appear in `task.use`, e.g. `@tagma/template-review`. */
|
|
18
|
-
readonly ref: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Scan the workspace's `node_modules/@tagma/*` for packages whose name starts
|
|
23
|
-
* with `template-` and load each one's manifest. Packages without a valid
|
|
24
|
-
* `template.yaml` (or that fail to parse) are silently skipped.
|
|
25
|
-
*
|
|
26
|
-
* Returns an empty array when `workDir` doesn't exist or has no such packages.
|
|
27
|
-
*/
|
|
28
|
-
export function discoverTemplates(workDir: string): TemplateManifest[] {
|
|
29
|
-
const out: TemplateManifest[] = [];
|
|
30
|
-
const scopeDir = join(workDir, 'node_modules', '@tagma');
|
|
31
|
-
if (!existsSync(scopeDir)) return out;
|
|
32
|
-
|
|
33
|
-
let entries: string[] = [];
|
|
34
|
-
try {
|
|
35
|
-
entries = readdirSync(scopeDir);
|
|
36
|
-
} catch {
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
for (const entry of entries) {
|
|
41
|
-
if (!entry.startsWith('template-')) continue;
|
|
42
|
-
const pkgDir = join(scopeDir, entry);
|
|
43
|
-
try {
|
|
44
|
-
const st = statSync(pkgDir);
|
|
45
|
-
if (!st.isDirectory()) continue;
|
|
46
|
-
} catch {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const ref = `@tagma/${entry}`;
|
|
51
|
-
const manifest = loadTemplateManifestFromDir(pkgDir, ref);
|
|
52
|
-
if (manifest) out.push(manifest);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Sort alphabetically for deterministic UI rendering.
|
|
56
|
-
out.sort((a, b) => a.ref.localeCompare(b.ref));
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Load a single template's manifest by its ref (e.g. `@tagma/template-review`)
|
|
62
|
-
* from the given workspace's `node_modules`. Returns `null` if the package
|
|
63
|
-
* isn't installed or its manifest can't be parsed.
|
|
64
|
-
*/
|
|
65
|
-
export function loadTemplateManifest(ref: string, workDir: string): TemplateManifest | null {
|
|
66
|
-
// Only @tagma/template-* refs are supported (matches SDK validateTemplateRef).
|
|
67
|
-
const stripped = ref.replace(/@v\d+$/, '');
|
|
68
|
-
if (!stripped.startsWith('@tagma/template-')) return null;
|
|
69
|
-
const pkgDir = join(workDir, 'node_modules', stripped);
|
|
70
|
-
if (!existsSync(pkgDir)) return null;
|
|
71
|
-
return loadTemplateManifestFromDir(pkgDir, stripped);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Resolve a template manifest from an absolute package directory. Tries
|
|
76
|
-
* `template.yaml` first (the documented convention), then a `template` export
|
|
77
|
-
* from `package.json`'s `main`. Returns `null` on any failure so discovery
|
|
78
|
-
* stays robust against malformed packages.
|
|
79
|
-
*/
|
|
80
|
-
function loadTemplateManifestFromDir(pkgDir: string, ref: string): TemplateManifest | null {
|
|
81
|
-
const yamlPath = join(pkgDir, 'template.yaml');
|
|
82
|
-
if (existsSync(yamlPath)) {
|
|
83
|
-
try {
|
|
84
|
-
const content = readFileSync(yamlPath, 'utf-8');
|
|
85
|
-
const doc = yaml.load(content) as { template?: TemplateConfig } | TemplateConfig;
|
|
86
|
-
const tpl = (doc && typeof doc === 'object' && 'template' in doc
|
|
87
|
-
? (doc as { template?: TemplateConfig }).template
|
|
88
|
-
: (doc as TemplateConfig)) as TemplateConfig | undefined;
|
|
89
|
-
if (tpl && typeof tpl === 'object' && tpl.name && Array.isArray(tpl.tasks)) {
|
|
90
|
-
return { ...tpl, ref };
|
|
91
|
-
}
|
|
92
|
-
} catch {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return null;
|
|
97
|
-
}
|