@kici-dev/compiler 0.1.26 → 0.2.0
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/auth/headless-detect.d.ts +14 -5
- package/dist/auth/headless-detect.js +50 -9
- package/dist/cli-banner.d.ts +6 -3
- package/dist/cli-banner.js +13 -5
- package/dist/cli.js +180 -48
- package/dist/commands/check-mode.d.ts +1 -1
- package/dist/commands/compile.js +31 -7
- package/dist/commands/diagnostics.js +14 -2
- package/dist/commands/doctor.d.ts +64 -0
- package/dist/commands/doctor.js +413 -0
- package/dist/commands/endpoints.js +6 -0
- package/dist/commands/fixture.js +13 -0
- package/dist/commands/hook.js +3 -2
- package/dist/commands/index.d.ts +13 -1
- package/dist/commands/index.js +10 -3
- package/dist/commands/init-host-os.d.ts +34 -0
- package/dist/commands/init-host-os.js +44 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +160 -37
- package/dist/commands/local-trust-root.d.ts +6 -0
- package/dist/commands/local-trust-root.js +52 -0
- package/dist/commands/local.d.ts +65 -0
- package/dist/commands/local.js +206 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +41 -1
- package/dist/commands/logout.js +7 -0
- package/dist/commands/notifications.d.ts +61 -0
- package/dist/commands/notifications.js +274 -0
- package/dist/commands/preview.js +9 -2
- package/dist/commands/run-banner.d.ts +31 -0
- package/dist/commands/run-banner.js +25 -0
- package/dist/commands/run-routed.d.ts +53 -0
- package/dist/commands/run-routed.js +185 -0
- package/dist/commands/run.d.ts +0 -17
- package/dist/commands/run.js +44 -58
- package/dist/commands/runs/artifacts/download.d.ts +24 -0
- package/dist/commands/runs/artifacts/download.js +154 -0
- package/dist/commands/runs/artifacts/list.d.ts +5 -0
- package/dist/commands/runs/artifacts/list.js +47 -0
- package/dist/commands/runs/cancel.js +2 -2
- package/dist/commands/runs/list.js +8 -2
- package/dist/commands/secrets-list.d.ts +2 -2
- package/dist/commands/secrets-list.js +4 -4
- package/dist/commands/types.d.ts +3 -3
- package/dist/commands/types.js +4 -4
- package/dist/commands/verify-attestation.d.ts +3 -1
- package/dist/commands/verify-attestation.js +18 -7
- package/dist/errors/formatter.d.ts +14 -1
- package/dist/errors/formatter.js +13 -3
- package/dist/errors/index.d.ts +2 -1
- package/dist/errors/index.js +3 -2
- package/dist/errors/source-location.d.ts +20 -0
- package/dist/errors/source-location.js +45 -0
- package/dist/execution/executor.js +32 -12
- package/dist/fixtures/defaults/index.js +2 -1
- package/dist/generators/secrets-dts.d.ts +9 -9
- package/dist/generators/secrets-dts.js +12 -12
- package/dist/llm-context/llms-architecture.txt +50 -21
- package/dist/llm-context/llms-cli.txt +2667 -1454
- package/dist/llm-context/llms-features.txt +484 -414
- package/dist/llm-context/llms-full.txt +6703 -4687
- package/dist/llm-context/llms-getting-started.txt +311 -55
- package/dist/llm-context/llms-patterns.txt +17 -29
- package/dist/llm-context/llms-providers.txt +10 -1
- package/dist/llm-context/llms-sdk-runtime.txt +2013 -0
- package/dist/llm-context/llms-sdk.txt +596 -2157
- package/dist/llm-context/llms.txt +31 -17
- package/dist/local-plane/orchestrator-process.d.ts +70 -0
- package/dist/local-plane/orchestrator-process.js +129 -0
- package/dist/local-plane/os-mismatch-hint.d.ts +16 -0
- package/dist/local-plane/os-mismatch-hint.js +34 -0
- package/dist/local-plane/paths.d.ts +39 -0
- package/dist/local-plane/paths.js +54 -0
- package/dist/local-plane/plane-liveness.d.ts +68 -0
- package/dist/local-plane/plane-liveness.js +145 -0
- package/dist/local-plane/plane-manager.d.ts +193 -0
- package/dist/local-plane/plane-manager.js +480 -0
- package/dist/local-plane/plane-seed.d.ts +76 -0
- package/dist/local-plane/plane-seed.js +59 -0
- package/dist/local-plane/plane-trigger.d.ts +71 -0
- package/dist/local-plane/plane-trigger.js +110 -0
- package/dist/local-plane/platform-attach.d.ts +53 -0
- package/dist/local-plane/platform-attach.js +107 -0
- package/dist/local-plane/port-holder.d.ts +78 -0
- package/dist/local-plane/port-holder.js +227 -0
- package/dist/local-plane/postgres.d.ts +56 -0
- package/dist/local-plane/postgres.js +187 -0
- package/dist/local-plane/resolve-plane.d.ts +37 -0
- package/dist/local-plane/resolve-plane.js +76 -0
- package/dist/local-plane/run-follow.d.ts +61 -0
- package/dist/local-plane/run-follow.js +151 -0
- package/dist/local-plane/scaler-config.d.ts +68 -0
- package/dist/local-plane/scaler-config.js +132 -0
- package/dist/local-plane/secret-seed.d.ts +59 -0
- package/dist/local-plane/secret-seed.js +112 -0
- package/dist/local-plane/source-provider.d.ts +43 -0
- package/dist/local-plane/source-provider.js +159 -0
- package/dist/local-plane/trusted-routing.d.ts +32 -0
- package/dist/local-plane/trusted-routing.js +47 -0
- package/dist/lockfile/generator.d.ts +14 -1
- package/dist/lockfile/generator.js +103 -37
- package/dist/lockfile/index.d.ts +3 -1
- package/dist/lockfile/index.js +3 -2
- package/dist/lockfile/purity-diagnostics.d.ts +31 -0
- package/dist/lockfile/purity-diagnostics.js +52 -0
- package/dist/postinstall.js +2 -1
- package/dist/remote/artifact-extract.d.ts +8 -0
- package/dist/remote/artifact-extract.js +58 -0
- package/dist/remote/config.d.ts +21 -3
- package/dist/remote/config.js +24 -5
- package/dist/remote/dashboard-client.d.ts +46 -9
- package/dist/remote/dashboard-client.js +54 -11
- package/dist/remote/fs-case.d.ts +21 -0
- package/dist/remote/fs-case.js +45 -0
- package/dist/remote/history.d.ts +9 -3
- package/dist/remote/history.js +79 -10
- package/dist/remote/local-repo-identity.d.ts +1 -1
- package/dist/remote/local-repo-identity.js +2 -1
- package/dist/remote/notifications-client.d.ts +149 -0
- package/dist/remote/notifications-client.js +103 -0
- package/dist/remote/oauth.d.ts +13 -0
- package/dist/remote/oauth.js +31 -5
- package/dist/remote/output/summary.js +76 -14
- package/dist/remote/platform-client.d.ts +1 -1
- package/dist/remote/render.js +30 -9
- package/dist/{local-executor → remote}/secret-loader.d.ts +1 -1
- package/dist/{local-executor → remote}/secret-loader.js +4 -4
- package/dist/remote/secret-upload.d.ts +1 -1
- package/dist/remote/secret-upload.js +2 -2
- package/dist/remote/uploader.d.ts +1 -1
- package/dist/remote/uploader.js +7 -6
- package/dist/templates/agents-md.d.ts +1 -1
- package/dist/templates/agents-md.js +8 -8
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.js +2 -2
- package/dist/templates/package-json.d.ts +15 -0
- package/dist/templates/package-json.js +26 -5
- package/dist/test-runner/dry-run.d.ts +2 -1
- package/dist/test-runner/dry-run.js +18 -1
- package/dist/test-runner/event-types.d.ts +2 -0
- package/dist/test-runner/event-types.js +3 -0
- package/dist/test-runner/job-executor.d.ts +1 -0
- package/dist/test-runner/job-executor.js +82 -44
- package/dist/test-runner/output-formatter.d.ts +5 -2
- package/dist/test-runner/output-formatter.js +6 -4
- package/dist/test-runner/payload-builder.d.ts +7 -1
- package/dist/test-runner/payload-builder.js +11 -2
- package/dist/test-runner/rule-evaluator.d.ts +7 -3
- package/dist/test-runner/rule-evaluator.js +13 -12
- package/dist/{local-executor → test-runner}/runs-on-display.js +1 -1
- package/dist/test-runner/step-context.d.ts +23 -5
- package/dist/test-runner/step-context.js +29 -119
- package/dist/types.d.ts +26 -7
- package/dist/types.js +4 -2
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.js +2 -1
- package/dist/validation/typecheck.d.ts +28 -0
- package/dist/validation/typecheck.js +110 -0
- package/dist/validation/validator.d.ts +9 -4
- package/dist/validation/validator.js +38 -44
- package/package.json +13 -13
- package/sbom.spdx.json +9311 -1528
- package/dist/assets/api-TJJVHrjC.json +0 -118
- package/dist/assets/descriptor-BTtjzN9L.json +0 -1382
- package/dist/assets/package-BpQF9kR8.json +0 -74
- package/dist/assets/package-Ceo2h27X.json +0 -89
- package/dist/assets/source_context-D0atuL28.json +0 -20
- package/dist/assets/type-BFqO8SCZ.json +0 -202
- package/dist/commands/cancel.d.ts +0 -22
- package/dist/commands/detect-package-manager.d.ts +0 -42
- package/dist/commands/held-run-resolve.d.ts +0 -50
- package/dist/commands/status.d.ts +0 -34
- package/dist/commands/test.d.ts +0 -88
- package/dist/errors/codes.d.ts +0 -25
- package/dist/local-executor/dag-scheduler.d.ts +0 -44
- package/dist/local-executor/dag-scheduler.js +0 -183
- package/dist/local-executor/index.d.ts +0 -23
- package/dist/local-executor/index.js +0 -378
- package/dist/local-executor/job-runner.d.ts +0 -47
- package/dist/local-executor/job-runner.js +0 -411
- package/dist/local-executor/materializer.d.ts +0 -44
- package/dist/local-executor/materializer.js +0 -132
- package/dist/local-executor/output-streamer.d.ts +0 -31
- package/dist/local-executor/output-streamer.js +0 -168
- package/dist/local-executor/payload-generator.d.ts +0 -16
- package/dist/local-executor/payload-generator.js +0 -138
- package/dist/local-executor/picker.d.ts +0 -33
- package/dist/local-executor/picker.js +0 -109
- package/dist/local-executor/to-event-payload.d.ts +0 -16
- package/dist/local-executor/to-event-payload.js +0 -21
- package/dist/local-executor/types.d.ts +0 -93
- package/dist/local-executor/types.js +0 -2
- package/dist/local-executor/workflow-lock.d.ts +0 -82
- package/dist/local-executor/workflow-lock.js +0 -0
- package/dist/package-F7UXSDHW.json +0 -74
- package/dist/remote/client.d.ts +0 -210
- package/dist/remote/observer.d.ts +0 -81
- package/dist/test-runner/summary.d.ts +0 -7
- /package/dist/{local-executor → test-runner}/runs-on-display.d.ts +0 -0
|
@@ -5,8 +5,8 @@ export interface SecretsListOptions {
|
|
|
5
5
|
/**
|
|
6
6
|
* List test-available secret contexts through the Platform.
|
|
7
7
|
*
|
|
8
|
-
* Calls GET /api/v1/orgs/:orgId/
|
|
9
|
-
* the org's orchestrator), filters to
|
|
8
|
+
* Calls GET /api/v1/orgs/:orgId/contexts?includeSecrets=true (relayed to
|
|
9
|
+
* the org's orchestrator), filters to contexts with
|
|
10
10
|
* allowLocalExecution=true, and displays a table of names, key names, and
|
|
11
11
|
* flags. Values are never exposed -- only key names.
|
|
12
12
|
*/
|
|
@@ -6,17 +6,17 @@ import { toErrorMessage } from "@kici-dev/core";
|
|
|
6
6
|
/**
|
|
7
7
|
* List test-available secret contexts through the Platform.
|
|
8
8
|
*
|
|
9
|
-
* Calls GET /api/v1/orgs/:orgId/
|
|
10
|
-
* the org's orchestrator), filters to
|
|
9
|
+
* Calls GET /api/v1/orgs/:orgId/contexts?includeSecrets=true (relayed to
|
|
10
|
+
* the org's orchestrator), filters to contexts with
|
|
11
11
|
* allowLocalExecution=true, and displays a table of names, key names, and
|
|
12
12
|
* flags. Values are never exposed -- only key names.
|
|
13
13
|
*/
|
|
14
14
|
async function secretsListCommand(_options = {}) {
|
|
15
15
|
try {
|
|
16
|
-
const contexts = (await (await DashboardClient.load()).
|
|
16
|
+
const contexts = (await (await DashboardClient.load()).listContexts(true)).filter((e) => e.allowLocalExecution);
|
|
17
17
|
if (contexts.length === 0) {
|
|
18
18
|
console.log(pc.yellow("No test-available secret contexts found."));
|
|
19
|
-
console.log(pc.gray("Enable test runs (allowLocalExecution) on
|
|
19
|
+
console.log(pc.gray("Enable test runs (allowLocalExecution) on a context to make its secrets available for test runs."));
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
renderContextTable(contexts);
|
package/dist/commands/types.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ export interface TypesOptions {
|
|
|
5
5
|
quiet?: boolean;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* Generate TypeScript declarations for
|
|
8
|
+
* Generate TypeScript declarations for context secrets.
|
|
9
9
|
*
|
|
10
|
-
* Fetches
|
|
10
|
+
* Fetches context metadata (with secret key names) through the Platform
|
|
11
11
|
* and generates .kici/types/secrets.d.ts with module augmentation for
|
|
12
|
-
* KnownSecretKeys and
|
|
12
|
+
* KnownSecretKeys and ContextSecrets.
|
|
13
13
|
*
|
|
14
14
|
* @param options - Command options
|
|
15
15
|
* @returns true on success, false on error
|
package/dist/commands/types.js
CHANGED
|
@@ -8,11 +8,11 @@ import fs from "node:fs/promises";
|
|
|
8
8
|
import { toErrorMessage } from "@kici-dev/core";
|
|
9
9
|
//#region src/commands/types.ts
|
|
10
10
|
/**
|
|
11
|
-
* Generate TypeScript declarations for
|
|
11
|
+
* Generate TypeScript declarations for context secrets.
|
|
12
12
|
*
|
|
13
|
-
* Fetches
|
|
13
|
+
* Fetches context metadata (with secret key names) through the Platform
|
|
14
14
|
* and generates .kici/types/secrets.d.ts with module augmentation for
|
|
15
|
-
* KnownSecretKeys and
|
|
15
|
+
* KnownSecretKeys and ContextSecrets.
|
|
16
16
|
*
|
|
17
17
|
* @param options - Command options
|
|
18
18
|
* @returns true on success, false on error
|
|
@@ -21,7 +21,7 @@ async function typesCommand(options = {}) {
|
|
|
21
21
|
try {
|
|
22
22
|
const config = await loadGlobalConfig();
|
|
23
23
|
const dtsContent = generateSecretsDts({
|
|
24
|
-
|
|
24
|
+
contexts: (await DashboardClient.fromConfig(config).listContexts(true)).map((e) => ({
|
|
25
25
|
name: e.name,
|
|
26
26
|
keys: e.secretKeys ?? []
|
|
27
27
|
})),
|
|
@@ -3,7 +3,9 @@ export interface VerifyAttestationOptions {
|
|
|
3
3
|
bundle?: string;
|
|
4
4
|
/**
|
|
5
5
|
* Trusted issuer URL (online discovery) or a self-contained `{ issuer, jwks }`
|
|
6
|
-
* file. Optional — defaults to the
|
|
6
|
+
* file. Optional — defaults to the configured orchestrator, falling back to
|
|
7
|
+
* the hosted KiCI Platform's provenance issuer when no orchestrator is
|
|
8
|
+
* configured.
|
|
7
9
|
*/
|
|
8
10
|
trustRoot?: string;
|
|
9
11
|
/** Expected token audience (defaults to the KiCI provenance audience). */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../rolldown-runtime-ClRpJifh.js";
|
|
2
2
|
import { resolveTrustRoot } from "../provenance-trust-root.js";
|
|
3
|
+
import { loadGlobalConfig } from "../remote/config.js";
|
|
3
4
|
import "../remote/prod-defaults.js";
|
|
4
5
|
import pc from "picocolors";
|
|
5
6
|
import { readFile } from "node:fs/promises";
|
|
@@ -16,10 +17,14 @@ import { verifyKiciBundle } from "@kici-dev/engine/provenance/verify";
|
|
|
16
17
|
* `@kici-dev/engine`. The engine owns all crypto; this command is the thin Node
|
|
17
18
|
* wrapper (fs / fetch / artifact digest / output).
|
|
18
19
|
*
|
|
19
|
-
* `--trust-root` is optional: when omitted it defaults to the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* `--trust-root` is optional: when omitted it defaults to the CONFIGURED
|
|
21
|
+
* ORCHESTRATOR (its own `.well-known`), which now owns provenance signing — the
|
|
22
|
+
* natural root of trust for a self-hosted customer. When no orchestrator is
|
|
23
|
+
* configured it falls back to the hosted KiCI Platform's provenance issuer (for
|
|
24
|
+
* historical Platform-signed bundles, which keep verifying forever). Pass
|
|
25
|
+
* `--trust-root` to verify against a different environment or an offline
|
|
26
|
+
* `{ issuer, jwks }` file (air-gap). The token `iss` is always pinned to the
|
|
27
|
+
* trust root out-of-band — a bundle can never name its own trusted issuer.
|
|
23
28
|
*
|
|
24
29
|
* Returns a boolean (verified) so `cli.ts` can map it to an exit code (0/1).
|
|
25
30
|
*/
|
|
@@ -29,9 +34,14 @@ async function verifyAttestationCommand(artifact, options = {}) {
|
|
|
29
34
|
logger.error(pc.red("Error: --bundle <path|url> is required"));
|
|
30
35
|
return false;
|
|
31
36
|
}
|
|
32
|
-
const
|
|
37
|
+
const configuredOrchestrator = (await loadGlobalConfig().catch(() => null))?.endpoint;
|
|
38
|
+
const trustRoot = options.trustRoot ?? configuredOrchestrator ?? "https://api.kici.dev";
|
|
33
39
|
const usingDefault = !options.trustRoot;
|
|
34
|
-
|
|
40
|
+
const usingConfiguredOrchestrator = usingDefault && !!configuredOrchestrator;
|
|
41
|
+
if (usingDefault) {
|
|
42
|
+
const which = usingConfiguredOrchestrator ? "configured orchestrator" : "hosted KiCI platform";
|
|
43
|
+
logger.info(pc.gray(`Using default trust root ${trustRoot} (${which}; pass --trust-root to override)`));
|
|
44
|
+
}
|
|
35
45
|
const bundle = JSON.parse(await readBundle(options.bundle));
|
|
36
46
|
let resolved;
|
|
37
47
|
try {
|
|
@@ -39,7 +49,8 @@ async function verifyAttestationCommand(artifact, options = {}) {
|
|
|
39
49
|
} catch (error) {
|
|
40
50
|
const msg = toErrorMessage(error);
|
|
41
51
|
if (usingDefault && /\b503\b/.test(msg)) {
|
|
42
|
-
|
|
52
|
+
const where = usingConfiguredOrchestrator ? `your configured orchestrator (${trustRoot})` : `the hosted KiCI platform (${trustRoot})`;
|
|
53
|
+
logger.error(pc.red(`Error: build provenance signing is not enabled on ${where} yet (returned 503). Pass --trust-root to verify against another environment or an offline { issuer, jwks } file.`));
|
|
43
54
|
return false;
|
|
44
55
|
}
|
|
45
56
|
throw error;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Error code string. Thrown compile errors use `E<digits>` (e.g. 'E001', 'E102');
|
|
3
|
+
* advisory, render-only diagnostics use `W<digits>` (e.g. 'W101'). `isCompilerError`
|
|
4
|
+
* only matches the `E<digits>` family — warning codes are never thrown, only rendered.
|
|
5
|
+
*/
|
|
2
6
|
type ErrorCode = string;
|
|
7
|
+
/** Diagnostic severity. Errors abort compilation; warnings are advisory (compile still succeeds). */
|
|
8
|
+
export declare enum DiagnosticSeverity {
|
|
9
|
+
Error = "error",
|
|
10
|
+
Warning = "warning"
|
|
11
|
+
}
|
|
12
|
+
/** Warning code for the impure dynamic-value → init-job fallback. */
|
|
13
|
+
export declare const PURITY_FALLBACK_CODE = "W101";
|
|
3
14
|
/** Source location for error reporting */
|
|
4
15
|
export interface SourceLocation {
|
|
5
16
|
readonly file: string;
|
|
@@ -12,6 +23,7 @@ export interface CompilerError {
|
|
|
12
23
|
readonly message: string;
|
|
13
24
|
readonly location?: SourceLocation;
|
|
14
25
|
readonly suggestion?: string;
|
|
26
|
+
readonly severity?: DiagnosticSeverity;
|
|
15
27
|
}
|
|
16
28
|
/**
|
|
17
29
|
* Format error in GNU standard format: file:line:column: error [CODE]: message
|
|
@@ -25,6 +37,7 @@ export declare function formatError(error: CompilerError): string;
|
|
|
25
37
|
export declare function compilerError(code: ErrorCode, message: string, options?: {
|
|
26
38
|
location?: SourceLocation;
|
|
27
39
|
suggestion?: string;
|
|
40
|
+
severity?: DiagnosticSeverity;
|
|
28
41
|
}): CompilerError;
|
|
29
42
|
/** Check if an error is a CompilerError (codes are E + digits, e.g. E001, E102) */
|
|
30
43
|
export declare function isCompilerError(error: unknown): error is CompilerError;
|
package/dist/errors/formatter.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import "../rolldown-runtime-ClRpJifh.js";
|
|
2
2
|
import pc from "picocolors";
|
|
3
3
|
//#region src/errors/formatter.ts
|
|
4
|
+
/** Diagnostic severity. Errors abort compilation; warnings are advisory (compile still succeeds). */
|
|
5
|
+
let DiagnosticSeverity = /* @__PURE__ */ function(DiagnosticSeverity) {
|
|
6
|
+
DiagnosticSeverity["Error"] = "error";
|
|
7
|
+
DiagnosticSeverity["Warning"] = "warning";
|
|
8
|
+
return DiagnosticSeverity;
|
|
9
|
+
}({});
|
|
10
|
+
/** Warning code for the impure dynamic-value → init-job fallback. */
|
|
11
|
+
const PURITY_FALLBACK_CODE = "W101";
|
|
4
12
|
/**
|
|
5
13
|
* Format error in GNU standard format: file:line:column: error [CODE]: message
|
|
6
14
|
*
|
|
@@ -11,7 +19,8 @@ import pc from "picocolors";
|
|
|
11
19
|
function formatError(error) {
|
|
12
20
|
const parts = [];
|
|
13
21
|
if (error.location) parts.push(pc.cyan(`${error.location.file}:${error.location.line}:${error.location.column}`));
|
|
14
|
-
|
|
22
|
+
const label = error.severity === "warning" ? pc.yellow("warning") : pc.red("error");
|
|
23
|
+
parts.push(label + pc.gray(` [${error.code}]`) + ": " + error.message);
|
|
15
24
|
let output = parts.join(" ");
|
|
16
25
|
if (error.suggestion) output += "\n " + pc.dim(`Suggestion: ${error.suggestion}`);
|
|
17
26
|
return output;
|
|
@@ -22,7 +31,8 @@ function compilerError(code, message, options) {
|
|
|
22
31
|
code,
|
|
23
32
|
message,
|
|
24
33
|
location: options?.location,
|
|
25
|
-
suggestion: options?.suggestion
|
|
34
|
+
suggestion: options?.suggestion,
|
|
35
|
+
severity: options?.severity
|
|
26
36
|
};
|
|
27
37
|
}
|
|
28
38
|
/** Check if an error is a CompilerError (codes are E + digits, e.g. E001, E102) */
|
|
@@ -30,6 +40,6 @@ function isCompilerError(error) {
|
|
|
30
40
|
return typeof error === "object" && error !== null && "code" in error && "message" in error && typeof error.code === "string" && /^E\d+$/.test(error.code);
|
|
31
41
|
}
|
|
32
42
|
//#endregion
|
|
33
|
-
export { compilerError, formatError, isCompilerError };
|
|
43
|
+
export { DiagnosticSeverity, PURITY_FALLBACK_CODE, compilerError, formatError, isCompilerError };
|
|
34
44
|
|
|
35
45
|
//# sourceMappingURL=formatter.js.map
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { formatError, compilerError, isCompilerError } from './formatter.js';
|
|
1
|
+
export { formatError, compilerError, isCompilerError, DiagnosticSeverity, PURITY_FALLBACK_CODE, } from './formatter.js';
|
|
2
2
|
export type { SourceLocation, CompilerError } from './formatter.js';
|
|
3
3
|
export { CapabilityGapError, formatCapabilityGapError } from './capability-gap.js';
|
|
4
4
|
export type { CapabilityGapInfo } from './capability-gap.js';
|
|
5
|
+
export { firstStepLocation, locationForJob, locationForWorkflow } from './source-location.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/errors/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../rolldown-runtime-ClRpJifh.js";
|
|
2
|
-
import { compilerError, formatError, isCompilerError } from "./formatter.js";
|
|
2
|
+
import { DiagnosticSeverity, PURITY_FALLBACK_CODE, compilerError, formatError, isCompilerError } from "./formatter.js";
|
|
3
3
|
import { CapabilityGapError, formatCapabilityGapError } from "./capability-gap.js";
|
|
4
|
-
|
|
4
|
+
import { firstStepLocation, locationForJob, locationForWorkflow } from "./source-location.js";
|
|
5
|
+
export { CapabilityGapError, DiagnosticSeverity, PURITY_FALLBACK_CODE, compilerError, firstStepLocation, formatCapabilityGapError, formatError, isCompilerError, locationForJob, locationForWorkflow };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Job } from '@kici-dev/sdk';
|
|
2
|
+
import type { SourceLocation } from './formatter.js';
|
|
3
|
+
/**
|
|
4
|
+
* First step (walking one level into parallel groups) that carries a captured
|
|
5
|
+
* `_sourceLocation`. `step()` records a precise V8 call-site; bare functions and
|
|
6
|
+
* parallel-group wrappers do not, so this returns the first real anchor found.
|
|
7
|
+
*/
|
|
8
|
+
export declare function firstStepLocation(job: Job): SourceLocation | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Best available location for a job-scoped error: its first step's captured
|
|
11
|
+
* location when a step exists, else the workflow source file at line 1
|
|
12
|
+
* (`job()` itself captures no call-site).
|
|
13
|
+
*/
|
|
14
|
+
export declare function locationForJob(job: Job, workflowFile: string): SourceLocation;
|
|
15
|
+
/**
|
|
16
|
+
* Location for a workflow-scoped error: `workflow()` captures no call-site, so
|
|
17
|
+
* the best anchor is the workflow's source file at line 1.
|
|
18
|
+
*/
|
|
19
|
+
export declare function locationForWorkflow(file: string): SourceLocation;
|
|
20
|
+
//# sourceMappingURL=source-location.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "../rolldown-runtime-ClRpJifh.js";
|
|
2
|
+
//#region src/errors/source-location.ts
|
|
3
|
+
/**
|
|
4
|
+
* First step (walking one level into parallel groups) that carries a captured
|
|
5
|
+
* `_sourceLocation`. `step()` records a precise V8 call-site; bare functions and
|
|
6
|
+
* parallel-group wrappers do not, so this returns the first real anchor found.
|
|
7
|
+
*/
|
|
8
|
+
function firstStepLocation(job) {
|
|
9
|
+
for (const entry of job.steps ?? []) {
|
|
10
|
+
const stepLike = entry;
|
|
11
|
+
if (stepLike._sourceLocation) return stepLike._sourceLocation;
|
|
12
|
+
const group = entry;
|
|
13
|
+
if (Array.isArray(group.steps)) {
|
|
14
|
+
const inner = group.steps.find((c) => c._sourceLocation)?._sourceLocation;
|
|
15
|
+
if (inner) return inner;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Best available location for a job-scoped error: its first step's captured
|
|
21
|
+
* location when a step exists, else the workflow source file at line 1
|
|
22
|
+
* (`job()` itself captures no call-site).
|
|
23
|
+
*/
|
|
24
|
+
function locationForJob(job, workflowFile) {
|
|
25
|
+
return firstStepLocation(job) ?? {
|
|
26
|
+
file: workflowFile,
|
|
27
|
+
line: 1,
|
|
28
|
+
column: 1
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Location for a workflow-scoped error: `workflow()` captures no call-site, so
|
|
33
|
+
* the best anchor is the workflow's source file at line 1.
|
|
34
|
+
*/
|
|
35
|
+
function locationForWorkflow(file) {
|
|
36
|
+
return {
|
|
37
|
+
file,
|
|
38
|
+
line: 1,
|
|
39
|
+
column: 1
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { firstStepLocation, locationForJob, locationForWorkflow };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=source-location.js.map
|
|
@@ -5,9 +5,33 @@ import { ensureTsLoaderHook } from "./ts-loader.js";
|
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
|
-
import fs from "node:fs/promises";
|
|
8
|
+
import fs$1 from "node:fs/promises";
|
|
9
9
|
//#region src/execution/executor.ts
|
|
10
10
|
/**
|
|
11
|
+
* Map a caught runtime error's stack to a `SourceLocation` in the entry file.
|
|
12
|
+
* Scans for the first stack frame referencing `entryPoint` (ignoring the
|
|
13
|
+
* `?t=` cache-buster and the `file://` scheme) and returns its line/column;
|
|
14
|
+
* falls back to `entryPoint` at line 1 when no frame matches.
|
|
15
|
+
*/
|
|
16
|
+
function locateInEntry(stack, entryPoint) {
|
|
17
|
+
const fallback = {
|
|
18
|
+
file: entryPoint,
|
|
19
|
+
line: 1,
|
|
20
|
+
column: 1
|
|
21
|
+
};
|
|
22
|
+
if (!stack) return fallback;
|
|
23
|
+
const needle = entryPoint.split("?")[0];
|
|
24
|
+
for (const raw of stack.split("\n")) {
|
|
25
|
+
const m = raw.match(/(.+?):(\d+):(\d+)\)?$/);
|
|
26
|
+
if (m && m[1].includes(needle)) return {
|
|
27
|
+
file: entryPoint,
|
|
28
|
+
line: parseInt(m[2], 10),
|
|
29
|
+
column: parseInt(m[3], 10)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
11
35
|
* Load a TypeScript workflow/config module by direct dynamic import.
|
|
12
36
|
*
|
|
13
37
|
* Relies on the `@kici-dev/core/ts-loader-hook` ESM loader hook, registered
|
|
@@ -23,7 +47,7 @@ import fs from "node:fs/promises";
|
|
|
23
47
|
async function loadModule(entryPoint, errorContext) {
|
|
24
48
|
let hashBundleSource;
|
|
25
49
|
try {
|
|
26
|
-
hashBundleSource = await fs.readFile(entryPoint, "utf-8");
|
|
50
|
+
hashBundleSource = await fs$1.readFile(entryPoint, "utf-8");
|
|
27
51
|
} catch {}
|
|
28
52
|
try {
|
|
29
53
|
ensureTsLoaderHook();
|
|
@@ -34,11 +58,7 @@ async function loadModule(entryPoint, errorContext) {
|
|
|
34
58
|
} catch (err) {
|
|
35
59
|
const message = err.message ?? "Failed to load module";
|
|
36
60
|
throw compilerError("E003", `Failed to load ${errorContext.fileLabel} module: ${message}`, {
|
|
37
|
-
location:
|
|
38
|
-
file: errorContext.filePath,
|
|
39
|
-
line: 1,
|
|
40
|
-
column: 1
|
|
41
|
-
},
|
|
61
|
+
location: locateInEntry(err.stack, errorContext.filePath),
|
|
42
62
|
suggestion: `Check for TypeScript or runtime errors in your ${errorContext.fileLabel}. Make sure you invoke the workflow via the kici CLI (the bin shim registers the oxc-transform loader hook that handles TS files).`
|
|
43
63
|
});
|
|
44
64
|
}
|
|
@@ -60,12 +80,12 @@ async function loadModule(entryPoint, errorContext) {
|
|
|
60
80
|
async function executeConfig(configPath) {
|
|
61
81
|
const absolutePath = path.resolve(configPath);
|
|
62
82
|
try {
|
|
63
|
-
await fs.access(absolutePath);
|
|
83
|
+
await fs$1.access(absolutePath);
|
|
64
84
|
} catch {
|
|
65
85
|
throw compilerError("E001", `Config file not found: ${absolutePath}`, { suggestion: "Ensure workflow files exist in .kici/workflows/" });
|
|
66
86
|
}
|
|
67
87
|
try {
|
|
68
|
-
await fs.readFile(absolutePath, "utf-8");
|
|
88
|
+
await fs$1.readFile(absolutePath, "utf-8");
|
|
69
89
|
} catch {
|
|
70
90
|
throw compilerError("E001", `Failed to read config file: ${absolutePath}`, { suggestion: "Check file permissions" });
|
|
71
91
|
}
|
|
@@ -180,14 +200,14 @@ async function discoverWorkflows(kiciDir) {
|
|
|
180
200
|
const absoluteKiciDir = resolveKiciDir(kiciDir);
|
|
181
201
|
const workflowDir = path.join(absoluteKiciDir, "workflows");
|
|
182
202
|
try {
|
|
183
|
-
if (!(await fs.stat(workflowDir)).isDirectory()) throw compilerError("E001", `.kici/workflows/ is not a directory: ${workflowDir}`, { suggestion: "Run \"kici init\" to create the .kici/workflows/ directory" });
|
|
203
|
+
if (!(await fs$1.stat(workflowDir)).isDirectory()) throw compilerError("E001", `.kici/workflows/ is not a directory: ${workflowDir}`, { suggestion: "Run \"kici init\" to create the .kici/workflows/ directory" });
|
|
184
204
|
} catch (err) {
|
|
185
205
|
if (err.code === "ENOENT") throw compilerError("E001", `.kici/workflows/ directory not found: ${workflowDir}`, { suggestion: "Run \"kici init\" to create the .kici/workflows/ directory" });
|
|
186
206
|
throw err;
|
|
187
207
|
}
|
|
188
208
|
let files;
|
|
189
209
|
try {
|
|
190
|
-
files = (await fs.readdir(workflowDir, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".ts")).map((entry) => path.join(workflowDir, entry.name));
|
|
210
|
+
files = (await fs$1.readdir(workflowDir, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".ts")).map((entry) => path.join(workflowDir, entry.name));
|
|
191
211
|
} catch {
|
|
192
212
|
throw compilerError("E001", `Failed to read .kici/workflows/ directory: ${workflowDir}`, { suggestion: "Check directory permissions" });
|
|
193
213
|
}
|
|
@@ -213,7 +233,7 @@ async function discoverWorkflows(kiciDir) {
|
|
|
213
233
|
*/
|
|
214
234
|
async function executeWorkflowFile(filePath) {
|
|
215
235
|
try {
|
|
216
|
-
await fs.access(filePath);
|
|
236
|
+
await fs$1.access(filePath);
|
|
217
237
|
} catch {
|
|
218
238
|
throw compilerError("E001", `Failed to read workflow file: ${filePath}`, { suggestion: "Check file permissions" });
|
|
219
239
|
}
|
|
@@ -86,7 +86,8 @@ const FIXTURES = {
|
|
|
86
86
|
* @throws Error if event is unknown
|
|
87
87
|
*/
|
|
88
88
|
function getDefaultFixture(event) {
|
|
89
|
-
const
|
|
89
|
+
const normalized = event.toLowerCase().trim();
|
|
90
|
+
const fixture = FIXTURES[normalized];
|
|
90
91
|
if (!fixture) {
|
|
91
92
|
const available = Object.keys(FIXTURES).filter((k, i, arr) => arr.indexOf(k) === i).join(", ");
|
|
92
93
|
throw new Error(`Unknown event type: ${event}\nAvailable events: ${available}`);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* .d.ts generator for
|
|
2
|
+
* .d.ts generator for context secret type augmentation.
|
|
3
3
|
*
|
|
4
4
|
* Produces a TypeScript declaration file that augments @kici-dev/sdk's
|
|
5
|
-
* KnownSecretKeys and
|
|
5
|
+
* KnownSecretKeys and ContextSecrets interfaces, enabling compile-time
|
|
6
6
|
* autocomplete and type checking for `ctx.secrets.get()` and `ctx.secrets.expose()`
|
|
7
|
-
* key names per
|
|
7
|
+
* key names per context.
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
9
|
+
export interface ContextMetadata {
|
|
10
10
|
name: string;
|
|
11
11
|
keys: string[];
|
|
12
12
|
}
|
|
13
13
|
interface GenerateSecretsDtsOptions {
|
|
14
|
-
|
|
14
|
+
contexts: ContextMetadata[];
|
|
15
15
|
endpoint: string;
|
|
16
16
|
generatedAt: Date;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Generate a .d.ts string from
|
|
19
|
+
* Generate a .d.ts string from context metadata.
|
|
20
20
|
*
|
|
21
|
-
* The output augments @kici-dev/sdk's KnownSecretKeys and
|
|
22
|
-
* interfaces, enabling compile-time autocomplete for secret keys per
|
|
21
|
+
* The output augments @kici-dev/sdk's KnownSecretKeys and ContextSecrets
|
|
22
|
+
* interfaces, enabling compile-time autocomplete for secret keys per context.
|
|
23
23
|
*
|
|
24
|
-
* @param options -
|
|
24
|
+
* @param options - Context metadata, endpoint URL, and generation timestamp
|
|
25
25
|
* @returns The .d.ts file content as a string
|
|
26
26
|
*/
|
|
27
27
|
export declare function generateSecretsDts(options: GenerateSecretsDtsOptions): string;
|
|
@@ -13,11 +13,11 @@ function formatProperty(name) {
|
|
|
13
13
|
return isValidIdentifier(name) ? name : `'${escapeQuotes(name)}'`;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Build a map of key -> list of
|
|
16
|
+
* Build a map of key -> list of context names that provide it.
|
|
17
17
|
*/
|
|
18
|
-
function buildKeySourceMap(
|
|
18
|
+
function buildKeySourceMap(contexts) {
|
|
19
19
|
const map = /* @__PURE__ */ new Map();
|
|
20
|
-
for (const env of
|
|
20
|
+
for (const env of contexts) for (const key of env.keys) {
|
|
21
21
|
const sources = map.get(key);
|
|
22
22
|
if (sources) sources.push(env.name);
|
|
23
23
|
else map.set(key, [env.name]);
|
|
@@ -25,16 +25,16 @@ function buildKeySourceMap(environments) {
|
|
|
25
25
|
return map;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Generate a .d.ts string from
|
|
28
|
+
* Generate a .d.ts string from context metadata.
|
|
29
29
|
*
|
|
30
|
-
* The output augments @kici-dev/sdk's KnownSecretKeys and
|
|
31
|
-
* interfaces, enabling compile-time autocomplete for secret keys per
|
|
30
|
+
* The output augments @kici-dev/sdk's KnownSecretKeys and ContextSecrets
|
|
31
|
+
* interfaces, enabling compile-time autocomplete for secret keys per context.
|
|
32
32
|
*
|
|
33
|
-
* @param options -
|
|
33
|
+
* @param options - Context metadata, endpoint URL, and generation timestamp
|
|
34
34
|
* @returns The .d.ts file content as a string
|
|
35
35
|
*/
|
|
36
36
|
function generateSecretsDts(options) {
|
|
37
|
-
const {
|
|
37
|
+
const { contexts, endpoint, generatedAt } = options;
|
|
38
38
|
const lines = [];
|
|
39
39
|
lines.push("// @generated by kici types -- DO NOT EDIT");
|
|
40
40
|
lines.push(`// Source: ${endpoint}`);
|
|
@@ -42,16 +42,16 @@ function generateSecretsDts(options) {
|
|
|
42
42
|
lines.push("// Run `kici types` to refresh");
|
|
43
43
|
lines.push("");
|
|
44
44
|
lines.push("declare module '@kici-dev/sdk' {");
|
|
45
|
-
const keySourceMap = buildKeySourceMap(
|
|
45
|
+
const keySourceMap = buildKeySourceMap(contexts);
|
|
46
46
|
lines.push(" interface KnownSecretKeys {");
|
|
47
47
|
for (const [key, sources] of keySourceMap) {
|
|
48
|
-
lines.push(` /** From
|
|
48
|
+
lines.push(` /** From context: ${sources.join(", ")} */`);
|
|
49
49
|
lines.push(` ${formatProperty(key)}: string;`);
|
|
50
50
|
}
|
|
51
51
|
lines.push(" }");
|
|
52
52
|
lines.push("");
|
|
53
|
-
lines.push(" interface
|
|
54
|
-
for (const env of
|
|
53
|
+
lines.push(" interface ContextSecrets {");
|
|
54
|
+
for (const env of contexts) if (env.keys.length === 0) lines.push(` ${formatProperty(env.name)}: never;`);
|
|
55
55
|
else {
|
|
56
56
|
const keyUnion = env.keys.map((k) => `'${escapeQuotes(k)}'`).join(" | ");
|
|
57
57
|
lines.push(` ${formatProperty(env.name)}: ${keyUnion};`);
|