@malloy-publisher/server 0.0.228 → 0.0.230
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/app/api-doc.yaml +102 -10
- package/dist/app/assets/EnvironmentPage-wa_EPkwK.js +1 -0
- package/dist/app/assets/{HomePage-Bkwc9Woc.js → HomePage-jnCrupQp.js} +1 -1
- package/dist/app/assets/{LightMode-Bum_KBpN.js → LightMode-DYbwNULZ.js} +1 -1
- package/dist/app/assets/MainPage-CuJLrPNI.js +2 -0
- package/dist/app/assets/MaterializationsPage-D_67x2ee.js +1 -0
- package/dist/app/assets/ModelPage-D5JtAWqR.js +1 -0
- package/dist/app/assets/PackagePage-BRwtqUSG.js +1 -0
- package/dist/app/assets/{RouteError-DmJLpLXm.js → RouteError-CBNNrnSD.js} +1 -1
- package/dist/app/assets/ThemeEditorPage-CTCeBneA.js +1 -0
- package/dist/app/assets/WorkbookPage-SN6f1RBm.js +1 -0
- package/dist/app/assets/{core-CEDZMHV1.es-_yGzNgNH.js → core-Dp3q5Ieu.es-CD5FvM2s.js} +10 -10
- package/dist/app/assets/{index-CdmFub34.js → index-B3Nn8Vm2.js} +459 -446
- package/dist/app/assets/index-BLCx1EdC.js +18 -0
- package/dist/app/assets/index-C_tJstcx.js +529 -0
- package/dist/app/assets/{index-CE9xhdra.js → index-CfmBVB6M.js} +1 -1
- package/dist/app/assets/{index-OEjKNSYb.js → index-DU4r7GdU.js} +573 -413
- package/dist/app/index.html +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/package_load_worker.mjs +109 -8
- package/dist/server.mjs +7504 -80
- package/package.json +15 -13
- package/scripts/bake-duckdb-extensions.js +5 -2
- package/src/config.spec.ts +87 -1
- package/src/config.ts +142 -1
- package/src/controller/materialization.controller.spec.ts +9 -0
- package/src/controller/materialization.controller.ts +15 -0
- package/src/ducklake_version.spec.ts +163 -0
- package/src/ducklake_version.ts +153 -0
- package/src/errors.ts +12 -0
- package/src/malloy_pin_prereqs.spec.ts +25 -0
- package/src/materialization_metrics.ts +33 -0
- package/src/mcp/skills/build_skills_bundle.ts +29 -9
- package/src/mcp/skills/skills_bundle.json +1 -1
- package/src/mcp/skills/skills_bundle.spec.ts +31 -2
- package/src/query_param_utils.ts +11 -0
- package/src/server.ts +74 -9
- package/src/service/authorize.spec.ts +22 -0
- package/src/service/authorize.ts +267 -10
- package/src/service/authorize_integration.spec.ts +1068 -26
- package/src/service/connection.spec.ts +79 -7
- package/src/service/connection.ts +312 -25
- package/src/service/connection_config.spec.ts +21 -0
- package/src/service/connection_config.ts +15 -1
- package/src/service/cron_evaluator.spec.ts +79 -0
- package/src/service/cron_evaluator.ts +105 -0
- package/src/service/ducklake_lazy_attach.spec.ts +110 -0
- package/src/service/environment.ts +156 -17
- package/src/service/environment_store.spec.ts +569 -14
- package/src/service/environment_store.ts +237 -31
- package/src/service/environment_store_anchoring.spec.ts +107 -0
- package/src/service/extension_fetch_policy.spec.ts +256 -0
- package/src/service/manifest_loader.spec.ts +3 -1
- package/src/service/manifest_loader.ts +9 -5
- package/src/service/materialization_scheduler.spec.ts +289 -0
- package/src/service/materialization_scheduler.ts +304 -0
- package/src/service/materialization_service.spec.ts +286 -5
- package/src/service/materialization_service.ts +121 -8
- package/src/service/materialization_test_fixtures.ts +10 -1
- package/src/service/model.spec.ts +67 -0
- package/src/service/model.ts +656 -31
- package/src/service/package.spec.ts +38 -0
- package/src/service/package.ts +102 -2
- package/src/service/package_quote_bound_tables.spec.ts +171 -0
- package/src/service/persistence_policy.spec.ts +31 -0
- package/src/service/quoting.spec.ts +57 -1
- package/src/service/quoting.ts +33 -0
- package/src/storage/DatabaseInterface.ts +15 -0
- package/src/storage/duckdb/DuckDBRepository.ts +17 -0
- package/src/storage/duckdb/MaterializationRepository.spec.ts +191 -0
- package/src/storage/duckdb/MaterializationRepository.ts +68 -0
- package/tests/fixtures/persist-schedule-test/data/orders.csv +5 -0
- package/tests/fixtures/persist-schedule-test/persist_schedule_test.malloy +11 -0
- package/tests/fixtures/persist-schedule-test/publisher.json +7 -0
- package/tests/fixtures/persist-schedule-warn-test/data/orders.csv +5 -0
- package/tests/fixtures/persist-schedule-warn-test/persist_warn_test.malloy +11 -0
- package/tests/fixtures/persist-schedule-warn-test/publisher.json +6 -0
- package/tests/integration/materialization/environment_list.integration.spec.ts +133 -0
- package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +7 -2
- package/tests/integration/materialization/orchestrated_rebind.integration.spec.ts +150 -0
- package/tests/integration/materialization/schedule_edit.integration.spec.ts +126 -0
- package/tests/integration/materialization/scheduler.integration.spec.ts +200 -0
- package/tests/integration/materialization/scheduler_recovery.integration.spec.ts +172 -0
- package/tests/integration/materialization/scheduler_transitions.integration.spec.ts +256 -0
- package/tests/integration/materialization/scheduler_wiring.integration.spec.ts +143 -0
- package/dist/app/assets/EnvironmentPage-EW2lbGvb.js +0 -1
- package/dist/app/assets/MainPage-oiEy7TNM.js +0 -2
- package/dist/app/assets/MaterializationsPage-C_VJsTgU.js +0 -1
- package/dist/app/assets/ModelPage-z8REqAmk.js +0 -1
- package/dist/app/assets/PackagePage-C2Vtt1Ln.js +0 -1
- package/dist/app/assets/ThemeEditorPage-BywFjC7A.js +0 -1
- package/dist/app/assets/WorkbookPage-DCMizDMR.js +0 -1
- package/dist/app/assets/index-DDMrjIT3.js +0 -18
- package/dist/app/assets/index-EqslXZ44.js +0 -527
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// DuckLake catalog-format version contract.
|
|
2
|
+
//
|
|
3
|
+
// A DuckLake catalog records the on-disk format version it was written at. The
|
|
4
|
+
// DuckLake extension bundled with a given DuckDB engine attaches only a bounded
|
|
5
|
+
// RANGE of catalog formats without migration; a catalog outside that range
|
|
6
|
+
// fails deep inside DuckDB with an opaque error. This module derives the
|
|
7
|
+
// supported range purely from the pinned DuckDB engine version, so it never has
|
|
8
|
+
// to enumerate an allow-list of "known good" catalog versions (which drifts
|
|
9
|
+
// silently on an engine bump and is easy to forget to update). Both the runtime
|
|
10
|
+
// attach preflight (`service/connection.ts`) and the CI version-contract check
|
|
11
|
+
// (`scripts/validate-ducklake-catalog-range.ts`) consume this one source.
|
|
12
|
+
//
|
|
13
|
+
// Lower bound: fixed at "1.0". The 1.x DuckLake line does not attach the older
|
|
14
|
+
// 0.x formats without AUTOMATIC_MIGRATION, and the Publisher attach paths never
|
|
15
|
+
// pass that flag, so 1.0 is the floor. Upper bound: the maximum format the
|
|
16
|
+
// engine's bundled extension writes/attaches, looked up in the migration matrix
|
|
17
|
+
// below and keyed by engine (major, minor).
|
|
18
|
+
|
|
19
|
+
/** A parsed DuckLake catalog format version, e.g. `1.0` or `0.3-dev1`. */
|
|
20
|
+
export interface CatalogFormat {
|
|
21
|
+
major: number;
|
|
22
|
+
minor: number;
|
|
23
|
+
/** e.g. `dev1` in `0.3-dev1`; a pre-release sorts BELOW the same release. */
|
|
24
|
+
prerelease?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The inclusive `[min, max]` catalog-format range for a given engine. */
|
|
28
|
+
export interface CatalogFormatRange {
|
|
29
|
+
min: string;
|
|
30
|
+
max: string;
|
|
31
|
+
/** The engine minor line the range was derived from (for error messages). */
|
|
32
|
+
engineVersion: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Fixed lower bound of the supported range (see file header). */
|
|
36
|
+
export const MIN_CATALOG_FORMAT = "1.0";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Migration matrix: DuckDB engine minor line -> the maximum DuckLake catalog
|
|
40
|
+
* format its bundled DuckLake extension attaches WITHOUT migration. This is NOT
|
|
41
|
+
* an allow-list of catalog versions -- it is the single fact, per engine minor
|
|
42
|
+
* line, from which the `[MIN_CATALOG_FORMAT, maxFormat]` range is derived.
|
|
43
|
+
*
|
|
44
|
+
* Verified against the baked extension: DuckDB 1.5.x's DuckLake extension writes
|
|
45
|
+
* and attaches the "1.0" catalog format (the older 0.x formats require
|
|
46
|
+
* AUTOMATIC_MIGRATION, which Publisher never passes). When a Malloy bump moves
|
|
47
|
+
* `@duckdb/node-api` to a new minor line, add its row here after verifying the
|
|
48
|
+
* extension's max attach-without-migration format -- the CI version-contract
|
|
49
|
+
* check FAILS THE BUILD until a row covers the pinned engine, so this never
|
|
50
|
+
* drifts silently.
|
|
51
|
+
*/
|
|
52
|
+
export const ENGINE_MAX_FORMAT: ReadonlyArray<{
|
|
53
|
+
engine: { major: number; minor: number };
|
|
54
|
+
maxFormat: string;
|
|
55
|
+
}> = [{ engine: { major: 1, minor: 5 }, maxFormat: "1.0" }];
|
|
56
|
+
|
|
57
|
+
const CATALOG_FORMAT_RE = /^(\d+)\.(\d+)(?:-([0-9A-Za-z.]+))?$/;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Parse a catalog format string into its components, or `null` if it is not a
|
|
61
|
+
* valid `<major>.<minor>[-<prerelease>]` format. A three-part version like
|
|
62
|
+
* `1.0.0` is intentionally rejected: catalog formats are two-part, and a
|
|
63
|
+
* three-part string is a malformed input, not a newer format.
|
|
64
|
+
*/
|
|
65
|
+
export function parseCatalogFormat(raw: string): CatalogFormat | null {
|
|
66
|
+
if (typeof raw !== "string") return null;
|
|
67
|
+
const m = CATALOG_FORMAT_RE.exec(raw);
|
|
68
|
+
if (!m) return null;
|
|
69
|
+
const format: CatalogFormat = { major: Number(m[1]), minor: Number(m[2]) };
|
|
70
|
+
if (m[3] !== undefined) format.prerelease = m[3];
|
|
71
|
+
return format;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Compare two parsed catalog formats: -1 if `a < b`, 0 if equal, 1 if `a > b`.
|
|
76
|
+
* A release sorts ABOVE its own pre-releases (`1.0` > `1.0-dev1`), matching
|
|
77
|
+
* semver ordering.
|
|
78
|
+
*/
|
|
79
|
+
export function compareCatalogFormat(
|
|
80
|
+
a: CatalogFormat,
|
|
81
|
+
b: CatalogFormat,
|
|
82
|
+
): number {
|
|
83
|
+
if (a.major !== b.major) return a.major < b.major ? -1 : 1;
|
|
84
|
+
if (a.minor !== b.minor) return a.minor < b.minor ? -1 : 1;
|
|
85
|
+
if (a.prerelease === b.prerelease) return 0;
|
|
86
|
+
if (a.prerelease === undefined) return 1; // release > pre-release
|
|
87
|
+
if (b.prerelease === undefined) return -1;
|
|
88
|
+
return a.prerelease < b.prerelease ? -1 : 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Extract the `{ major, minor }` line from a DuckDB engine version string
|
|
93
|
+
* (`1.5.3`, `1.5.3-r.2`, `v1.5.3` all parse to `{1, 5}`), or `null` if none is
|
|
94
|
+
* present.
|
|
95
|
+
*/
|
|
96
|
+
export function parseEngineMajorMinor(
|
|
97
|
+
raw: string,
|
|
98
|
+
): { major: number; minor: number } | null {
|
|
99
|
+
const m = /(\d+)\.(\d+)\.(\d+)/.exec(String(raw));
|
|
100
|
+
if (!m) return null;
|
|
101
|
+
return { major: Number(m[1]), minor: Number(m[2]) };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The supported catalog-format range for a DuckDB engine version, or `null`
|
|
106
|
+
* when the engine's minor line has no row in {@link ENGINE_MAX_FORMAT}. A
|
|
107
|
+
* `null` return is the DRIFT signal: the CI version-contract check fails the
|
|
108
|
+
* build on it, and the runtime preflight treats it as "unknown, skip" (the
|
|
109
|
+
* preflight is non-load-bearing). The match is by `(major, minor)` so any patch
|
|
110
|
+
* release of a known minor line resolves.
|
|
111
|
+
*/
|
|
112
|
+
export function catalogFormatRangeForEngine(
|
|
113
|
+
engineVersion: string,
|
|
114
|
+
): CatalogFormatRange | null {
|
|
115
|
+
const e = parseEngineMajorMinor(engineVersion);
|
|
116
|
+
if (!e) return null;
|
|
117
|
+
const entry = ENGINE_MAX_FORMAT.find(
|
|
118
|
+
(r) => r.engine.major === e.major && r.engine.minor === e.minor,
|
|
119
|
+
);
|
|
120
|
+
if (!entry) return null;
|
|
121
|
+
return {
|
|
122
|
+
min: MIN_CATALOG_FORMAT,
|
|
123
|
+
max: entry.maxFormat,
|
|
124
|
+
engineVersion: `${e.major}.${e.minor}`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Whether `format` falls within the inclusive range (invalid input -> false). */
|
|
129
|
+
export function isCatalogFormatInRange(
|
|
130
|
+
format: string,
|
|
131
|
+
range: CatalogFormatRange,
|
|
132
|
+
): boolean {
|
|
133
|
+
const f = parseCatalogFormat(format);
|
|
134
|
+
const min = parseCatalogFormat(range.min);
|
|
135
|
+
const max = parseCatalogFormat(range.max);
|
|
136
|
+
if (!f || !min || !max) return false;
|
|
137
|
+
return (
|
|
138
|
+
compareCatalogFormat(f, min) >= 0 && compareCatalogFormat(f, max) <= 0
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Whether a catalog `format` is supported by the DuckLake extension bundled
|
|
144
|
+
* with `engineVersion`. Returns `false` for an unknown engine (no matrix row)
|
|
145
|
+
* or a malformed format.
|
|
146
|
+
*/
|
|
147
|
+
export function isCatalogFormatSupportedByEngine(
|
|
148
|
+
format: string,
|
|
149
|
+
engineVersion: string,
|
|
150
|
+
): boolean {
|
|
151
|
+
const range = catalogFormatRangeForEngine(engineVersion);
|
|
152
|
+
return range ? isCatalogFormatInRange(format, range) : false;
|
|
153
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -22,6 +22,8 @@ export function internalErrorToHttpError(error: Error) {
|
|
|
22
22
|
return httpError(404, error.message);
|
|
23
23
|
} else if (error instanceof ConnectionAuthError) {
|
|
24
24
|
return httpError(422, error.message);
|
|
25
|
+
} else if (error instanceof UnsupportedCatalogFormatError) {
|
|
26
|
+
return httpError(422, error.message);
|
|
25
27
|
} else if (error instanceof ModelCompilationError) {
|
|
26
28
|
return httpError(424, error.message);
|
|
27
29
|
} else if (error instanceof ConnectionError) {
|
|
@@ -101,6 +103,16 @@ export class ConnectionAuthError extends Error {
|
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
// A catalog was reached and authenticated fine, but its on-disk format is
|
|
107
|
+
// outside the range the pinned engine's extension can attach (see
|
|
108
|
+
// ducklake_version.ts). Distinct from ConnectionAuthError so the 422 doesn't
|
|
109
|
+
// read as a credentials problem. Maps to HTTP 422.
|
|
110
|
+
export class UnsupportedCatalogFormatError extends Error {
|
|
111
|
+
constructor(message: string) {
|
|
112
|
+
super(message);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
export class ModelCompilationError extends Error {
|
|
105
117
|
// Accepts a MalloyError or any message-bearing object, so callers that add
|
|
106
118
|
// context around a compile failure (e.g. naming the source whose authorize
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import type { VirtualMap } from "@malloydata/malloy";
|
|
3
|
+
|
|
4
|
+
// Prerequisite guard for the DuckLake materialization tier's build path.
|
|
5
|
+
//
|
|
6
|
+
// The tier resolves persist/virtual sources by handing the Malloy compile a
|
|
7
|
+
// `virtualMap` (connectionName → virtualName → tablePath). This asserts the
|
|
8
|
+
// pinned `@malloydata/malloy` still exports that public `VirtualMap` type, so a
|
|
9
|
+
// pin bump that drops or renames it fails CI typecheck here — turning a
|
|
10
|
+
// point-in-time manual confirm into a durable guard. Confirmed present in the
|
|
11
|
+
// shipped pin (^0.0.422): `VirtualMap = Map<string, Map<string, string>>` is
|
|
12
|
+
// exported from the package root and rides `PrepareResultOptions.virtualMap`.
|
|
13
|
+
describe("malloy pin prerequisites (DuckLake tier)", () => {
|
|
14
|
+
it("exposes the VirtualMap substitution type in the pinned malloy", () => {
|
|
15
|
+
// Compile-time guard: this type reference fails typecheck if `VirtualMap`
|
|
16
|
+
// is removed/renamed in a future pin. The runtime assertions below double
|
|
17
|
+
// as a shape check on the nested Map<string, Map<string, string>>.
|
|
18
|
+
const virtualMap: VirtualMap = new Map([
|
|
19
|
+
["main_pg", new Map([["orders", "catalog.public.orders"]])],
|
|
20
|
+
]);
|
|
21
|
+
expect(virtualMap.get("main_pg")?.get("orders")).toBe(
|
|
22
|
+
"catalog.public.orders",
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -78,6 +78,13 @@ const manifestBindCounter = lazyCounter(
|
|
|
78
78
|
"publisher_materialization_manifest_bind_total",
|
|
79
79
|
"Manifest bind attempts. Label: outcome ('success'|'failure'|'timeout').",
|
|
80
80
|
);
|
|
81
|
+
const manifestBindDegradedCounter = lazyCounter(
|
|
82
|
+
"publisher_materialization_manifest_bind_degraded_total",
|
|
83
|
+
"Manifest entries bound with an UNQUOTED table path because their connection " +
|
|
84
|
+
"could not be resolved (serve-side bind) or is absent from the build " +
|
|
85
|
+
"(build-side seed). A misconfiguration that breaks the source on a " +
|
|
86
|
+
"case-folding engine (Snowflake); alertable.",
|
|
87
|
+
);
|
|
81
88
|
const sourceBuildDuration = lazyHistogram(
|
|
82
89
|
"publisher_materialization_source_build_duration_ms",
|
|
83
90
|
"Wall-clock duration of building a single persist source.",
|
|
@@ -87,6 +94,22 @@ const dropTablesCounter = lazyCounter(
|
|
|
87
94
|
"publisher_materialization_drop_tables_total",
|
|
88
95
|
"Physical tables dropped on delete. Label: outcome ('success'|'failure').",
|
|
89
96
|
);
|
|
97
|
+
const scheduledFireCounter = lazyCounter(
|
|
98
|
+
"publisher_materialization_scheduled_fires_total",
|
|
99
|
+
"Standalone-scheduler attempts to fire a package's materialization.schedule. " +
|
|
100
|
+
"Label: outcome ('fired'|'conflict'|'error').",
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Record a standalone-scheduler fire attempt. `fired` = a SCHEDULER run started;
|
|
105
|
+
* `conflict` = a materialization was already active (this occurrence coalesces
|
|
106
|
+
* into it); `error` = the fire failed unexpectedly.
|
|
107
|
+
*/
|
|
108
|
+
export function recordScheduledFire(
|
|
109
|
+
outcome: "fired" | "conflict" | "error",
|
|
110
|
+
): void {
|
|
111
|
+
scheduledFireCounter().add(1, { outcome });
|
|
112
|
+
}
|
|
90
113
|
|
|
91
114
|
/** Record the outcome and duration of a materialization build. */
|
|
92
115
|
export function recordMaterializationRun(
|
|
@@ -147,6 +170,16 @@ export function recordManifestBind(outcome: ManifestBindOutcome): void {
|
|
|
147
170
|
manifestBindCounter().add(1, { outcome });
|
|
148
171
|
}
|
|
149
172
|
|
|
173
|
+
/**
|
|
174
|
+
* A single manifest entry bound with an unquoted table path because its
|
|
175
|
+
* connection could not be resolved for quoting. Per-entry degradation (the rest
|
|
176
|
+
* of the bind succeeds), distinct from the whole-bind {@link recordManifestBind}
|
|
177
|
+
* outcome — hence its own counter rather than a label on that one.
|
|
178
|
+
*/
|
|
179
|
+
export function recordManifestBindDegraded(): void {
|
|
180
|
+
manifestBindDegradedCounter().add(1);
|
|
181
|
+
}
|
|
182
|
+
|
|
150
183
|
/** Record the wall-clock duration of building one persist source's table. */
|
|
151
184
|
export function recordSourceBuildDuration(durationMs: number): void {
|
|
152
185
|
sourceBuildDuration().record(durationMs);
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import * as fs from "fs";
|
|
14
14
|
import * as path from "path";
|
|
15
15
|
|
|
16
|
-
interface SkillEntry {
|
|
16
|
+
export interface SkillEntry {
|
|
17
17
|
name: string;
|
|
18
18
|
description: string;
|
|
19
19
|
body: string;
|
|
@@ -36,6 +36,33 @@ export function parseSkill(md: string, dirName: string): SkillEntry {
|
|
|
36
36
|
return { name, description, body };
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* `credible-*` skills are Credible-platform-specific and never ship (see
|
|
41
|
+
* skills/README.md). They can legitimately sit in skills/ uncommitted: the
|
|
42
|
+
* directory is a gitignored local install target (`skills/credible-*` in
|
|
43
|
+
* .gitignore), so the bundle must skip them or a regeneration on a machine
|
|
44
|
+
* with Credible installed would bake them into the committed bundle, and the
|
|
45
|
+
* regenerate-and-compare spec would fail on a clean checkout.
|
|
46
|
+
*
|
|
47
|
+
* The canonical predicate lives in packages/skills/scripts/exclusions.ts;
|
|
48
|
+
* duplicated here because the server does not depend on that package.
|
|
49
|
+
*/
|
|
50
|
+
export function isCredible(dirName: string): boolean {
|
|
51
|
+
return dirName.toLowerCase().startsWith("credible-");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Read every skill under a skills directory, in the bundle's own order. */
|
|
55
|
+
export function buildSkills(skillsDir: string): SkillEntry[] {
|
|
56
|
+
const skills: SkillEntry[] = [];
|
|
57
|
+
for (const entry of fs.readdirSync(skillsDir, { withFileTypes: true })) {
|
|
58
|
+
if (!entry.isDirectory() || isCredible(entry.name)) continue;
|
|
59
|
+
const skillFile = path.join(skillsDir, entry.name, "SKILL.md");
|
|
60
|
+
if (!fs.existsSync(skillFile)) continue;
|
|
61
|
+
skills.push(parseSkill(fs.readFileSync(skillFile, "utf8"), entry.name));
|
|
62
|
+
}
|
|
63
|
+
return skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
64
|
+
}
|
|
65
|
+
|
|
39
66
|
function main(): void {
|
|
40
67
|
const skillsDir = process.argv[2];
|
|
41
68
|
const outFile =
|
|
@@ -47,14 +74,7 @@ function main(): void {
|
|
|
47
74
|
process.exit(1);
|
|
48
75
|
}
|
|
49
76
|
|
|
50
|
-
const skills
|
|
51
|
-
for (const entry of fs.readdirSync(skillsDir, { withFileTypes: true })) {
|
|
52
|
-
if (!entry.isDirectory()) continue;
|
|
53
|
-
const skillFile = path.join(skillsDir, entry.name, "SKILL.md");
|
|
54
|
-
if (!fs.existsSync(skillFile)) continue;
|
|
55
|
-
skills.push(parseSkill(fs.readFileSync(skillFile, "utf8"), entry.name));
|
|
56
|
-
}
|
|
57
|
-
skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
77
|
+
const skills = buildSkills(skillsDir);
|
|
58
78
|
|
|
59
79
|
fs.writeFileSync(outFile, JSON.stringify({ skills }));
|
|
60
80
|
console.log(`Wrote ${skills.length} skills to ${outFile}`);
|