@celljs/kit 0.0.0-stage → 4.1.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/README.md CHANGED
@@ -1,3 +1,18 @@
1
- # Temporary Holding Version
1
+ # @celljs/kit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Cell 4 工具链的共享类型,供 `@celljs/cli`、`@celljs/vite` 和 toolchain 模块、preset 作者使用,没有运行时依赖。
4
+
5
+ - `CellError`:所有工具链错误的形状 `{ code, message, file?, line?, column?, hint, docs }`;`CellError.is(e)` 按名字判断,跨包副本也能识别;`format()` 是 CLI 的输出格式,`toJSON()` 是 `--json` 的格式。
6
+ - 事件:`CELL_EVENTS`、`EVENT_RULES`(每个事件固定的组合规则:`notify` / `mutate` / `gate`)、`HOOKABLE_EVENTS`(项目 `hooks` 可以订阅的事件)。
7
+ - `Preset` 与 `definePreset`。
8
+ - `ComponentManifest`:组件 package.json 的 `cell` 字段(`modules`、`staticModules`、`targets`、`entries`、`optionalDependencies`、`toolchain`)。
9
+ - `ProjectModel` / `TargetModel`:`@celljs/vite` 产出的项目模型。
10
+ - `CellModuleOptions`:toolchain 模块通过扩充它为 `cell.config.ts` 声明选项类型。
11
+
12
+ ```ts
13
+ declare module '@celljs/kit' {
14
+ interface CellModuleOptions {
15
+ audit?: { url: string };
16
+ }
17
+ }
18
+ ```
@@ -0,0 +1,51 @@
1
+ import type { OutputManifest } from './types.js';
2
+ /** What a deployer gets: the built output and where to report progress. */
3
+ export interface DeployContext {
4
+ root: string;
5
+ /** Absolute output directory. */
6
+ outDir: string;
7
+ manifest: OutputManifest;
8
+ env: NodeJS.ProcessEnv;
9
+ /** The options of the preset the output was built with (its field of cell.config.ts); `{}` when absent. */
10
+ options: Record<string, unknown>;
11
+ /** Progress for people; on stderr with `--json`. */
12
+ info(message: string): void;
13
+ warn(message: string): void;
14
+ /** Relays output of a child process (a platform CLI): `stderr` stays stderr, `stdout` goes to stderr with `--json`. */
15
+ relay(chunk: string, stream: 'stdout' | 'stderr'): void;
16
+ }
17
+ /** A cloud resource that `apply` creates, updates or replaces. */
18
+ export interface DeployResource {
19
+ /** Kind of resource, e.g. `worker`, `assets`. */
20
+ type: string;
21
+ name: string;
22
+ /** `deploy`: created or updated, whichever applies. */
23
+ action: 'deploy' | 'create' | 'update' | 'delete';
24
+ details?: Record<string, unknown>;
25
+ }
26
+ /** What `cell deploy --dry-run` prints and `apply` carries out (docs/design/modules.md §4). */
27
+ export interface DeployPlan {
28
+ deployer: string;
29
+ resources: DeployResource[];
30
+ /** Facts a reviewer needs (target account, tool versions), no credentials. */
31
+ details?: Record<string, unknown>;
32
+ }
33
+ export interface Deployment {
34
+ /** Where the application answers, when the platform tells. */
35
+ url?: string;
36
+ details?: Record<string, unknown>;
37
+ }
38
+ /**
39
+ * Publishes a build output to a platform, in two steps: `plan` computes the changes without
40
+ * making them (`cell deploy --dry-run` stops there), `apply` makes them.
41
+ */
42
+ export interface Deployer {
43
+ name: string;
44
+ /** One-line description for `cell info` and `--help`. */
45
+ description?: string;
46
+ plan(context: DeployContext): Promise<DeployPlan>;
47
+ apply(context: DeployContext, plan: DeployPlan): Promise<Deployment>;
48
+ }
49
+ /** Types a deployer definition; returns it unchanged. */
50
+ export declare function defineDeployer(deployer: Deployer): Deployer;
51
+ //# sourceMappingURL=deployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployer.d.ts","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,2GAA2G;IAC3G,OAA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AQ,EAAE,QAAQ,GAAG,QAAQ,CAE3D"}
@@ -0,0 +1,5 @@
1
+ /** Types a deployer definition; returns it unchanged. */
2
+ export function defineDeployer(deployer) {
3
+ return deployer;
4
+ }
5
+ //# sourceMappingURL=deployer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployer.js","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAsDA,yDAAyD;AACzD,MAAM,UAAU,cAAc,CAAC,QAAkB;IAC7C,OAAO,QAAQ,CAAC;AACpB,CAAC"}
package/lib/error.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The only error type the Cell toolchain throws. Every error carries a stable `code`, a one-line
3
+ * `hint` that says how to fix it, and (when known) the file and line it comes from, so that coding
4
+ * agents and humans can act on it without reading a stack trace (docs/design/agent-first.md R5).
5
+ */
6
+ export interface CellErrorOptions {
7
+ /** Stable identifier, e.g. `CELL_CONFIG_PARSE`. Never changes meaning within a major version. */
8
+ code: string;
9
+ message: string;
10
+ /** One actionable sentence describing the fix. */
11
+ hint?: string;
12
+ file?: string;
13
+ line?: number;
14
+ column?: number;
15
+ cause?: unknown;
16
+ }
17
+ export declare class CellError extends Error {
18
+ readonly code: string;
19
+ readonly hint?: string;
20
+ readonly file?: string;
21
+ readonly line?: number;
22
+ readonly column?: number;
23
+ constructor(options: CellErrorOptions);
24
+ /** Documentation page of this error code. */
25
+ get docs(): string;
26
+ toJSON(): {
27
+ code: string;
28
+ message: string;
29
+ hint: string | undefined;
30
+ file: string | undefined;
31
+ line: number | undefined;
32
+ column: number | undefined;
33
+ docs: string;
34
+ };
35
+ /** One line of problem, then location, fix and docs; how the CLI prints errors. */
36
+ format(): string;
37
+ static is(value: unknown): value is CellError;
38
+ }
39
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,iGAAiG;IACjG,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,SAAU,SAAQ,KAAK;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,YAAY,OAAO,EAAE,gBAAgB,EAQpC;IAED,6CAA6C;IAC7C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,MAAM;QACO,IAAI;QAAa,OAAO;QAAgB,IAAI;QAAa,IAAI;QAAa,IAAI;QAAa,MAAM;QAAe,IAAI;MAChI;IAED,mFAAmF;IACnF,MAAM,IAAI,MAAM,CAKf;IAED,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE5C;CACJ"}
package/lib/error.js ADDED
@@ -0,0 +1,34 @@
1
+ export class CellError extends Error {
2
+ code;
3
+ hint;
4
+ file;
5
+ line;
6
+ column;
7
+ constructor(options) {
8
+ super(options.message, options.cause === undefined ? undefined : { cause: options.cause });
9
+ this.name = 'CellError';
10
+ this.code = options.code;
11
+ this.hint = options.hint;
12
+ this.file = options.file;
13
+ this.line = options.line;
14
+ this.column = options.column;
15
+ }
16
+ /** Documentation page of this error code. */
17
+ get docs() {
18
+ return `https://cell.cellbang.com/errors/${this.code.toLowerCase().replace(/_/g, '-')}`;
19
+ }
20
+ toJSON() {
21
+ return { code: this.code, message: this.message, hint: this.hint, file: this.file, line: this.line, column: this.column, docs: this.docs };
22
+ }
23
+ /** One line of problem, then location, fix and docs; how the CLI prints errors. */
24
+ format() {
25
+ const position = this.line ? `:${this.line}${this.column ? `:${this.column}` : ''}` : '';
26
+ const location = this.file ? `\n at ${this.file}${position}` : '';
27
+ const hint = this.hint ? `\n fix: ${this.hint}` : '';
28
+ return `[${this.code}] ${this.message}${location}${hint}\n docs: ${this.docs}`;
29
+ }
30
+ static is(value) {
31
+ return value instanceof Error && value.name === 'CellError' && typeof value.code === 'string';
32
+ }
33
+ }
34
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,SAAU,SAAQ,KAAK;IACvB,IAAI,CAAS;IACb,IAAI,CAAU;IACd,IAAI,CAAU;IACd,IAAI,CAAU;IACd,MAAM,CAAU;IAEzB,YAAY,OAAyB;QACjC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3F,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,6CAA6C;IAC7C,IAAI,IAAI;QACJ,OAAO,oCAAoC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IA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 {"version":3,"file":"error.spec.d.ts","sourceRoot":"","sources":["../src/error.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { CellError } from './error.js';
3
+ describe('CellError', () => {
4
+ const error = new CellError({ code: 'CELL_CONFIG_PARSE', message: 'Invalid YAML.', hint: 'Fix the syntax.', file: '/app/cell.yml', line: 3, column: 5 });
5
+ it('derives a stable docs URL from the code', () => {
6
+ expect(error.docs).toBe('https://cell.cellbang.com/errors/cell-config-parse');
7
+ });
8
+ it('formats problem, location, fix and docs', () => {
9
+ expect(error.format()).toBe('[CELL_CONFIG_PARSE] Invalid YAML.\n at /app/cell.yml:3:5\n fix: Fix the syntax.\n docs: https://cell.cellbang.com/errors/cell-config-parse');
10
+ });
11
+ it('serializes to JSON for --json output', () => {
12
+ expect(JSON.parse(JSON.stringify(error))).toEqual({
13
+ code: 'CELL_CONFIG_PARSE',
14
+ message: 'Invalid YAML.',
15
+ hint: 'Fix the syntax.',
16
+ file: '/app/cell.yml',
17
+ line: 3,
18
+ column: 5,
19
+ docs: error.docs,
20
+ });
21
+ });
22
+ it('recognizes Cell errors only', () => {
23
+ expect(CellError.is(error)).toBe(true);
24
+ expect(CellError.is(new Error('x'))).toBe(false);
25
+ });
26
+ });
27
+ //# sourceMappingURL=error.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.spec.js","sourceRoot":"","sources":["../src/error.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAEzJ,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CACvB,+IAA+I,CAClJ,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC9C,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,KAAK,CAAC,IAAI;SACnB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Toolchain events, in lifecycle order. Modules subscribe with `cell.on(event, handler)`; projects
3
+ * run commands on them through the `hooks` field of cell.config.ts. Each event has one fixed
4
+ * composition rule (docs/design/modules.md §3.2).
5
+ */
6
+ export declare const CELL_EVENTS: readonly ['modules:done', 'config:resolved', 'dev:ready', 'dev:reload', 'build:before', 'build:done', 'output:done', 'deploy:before', 'deploy:plan', 'deploy:done', 'close'];
7
+ export type CellEventName = (typeof CELL_EVENTS)[number];
8
+ /**
9
+ * - `notify`: return values are ignored;
10
+ * - `mutate`: handlers change the event object in place, later ones see the changes;
11
+ * - `gate`: a handler returning `{ cancel: true, reason }` (or throwing) stops the operation.
12
+ */
13
+ export type EventRule = 'notify' | 'mutate' | 'gate';
14
+ export declare const EVENT_RULES: Record<CellEventName, EventRule>;
15
+ /** Events a project hook (a shell command) may subscribe to: a command cannot change an event object. */
16
+ export declare const HOOKABLE_EVENTS: ("build:before" | "build:done" | "close" | "config:resolved" | "deploy:before" | "deploy:done" | "deploy:plan" | "dev:ready" | "dev:reload" | "modules:done" | "output:done")[];
17
+ export type HookableEventName = Exclude<CellEventName, 'build:done' | 'deploy:plan'>;
18
+ /** What a gate handler returns to stop the operation. */
19
+ export interface GateResult {
20
+ cancel: true;
21
+ reason: string;
22
+ }
23
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,WAAW,YACpB,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,aAAa,EACb,aAAa,EACb,OAAO,CACD,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,SAAS,CAYxD,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,eAAe,iLAA+D,CAAC;AAE5F,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,EAAE,YAAY,GAAG,aAAa,CAAC,CAAC;AAErF,yDAAyD;AACzD,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB"}
package/lib/events.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Toolchain events, in lifecycle order. Modules subscribe with `cell.on(event, handler)`; projects
3
+ * run commands on them through the `hooks` field of cell.config.ts. Each event has one fixed
4
+ * composition rule (docs/design/modules.md §3.2).
5
+ */
6
+ export const CELL_EVENTS = [
7
+ 'modules:done',
8
+ 'config:resolved',
9
+ 'dev:ready',
10
+ 'dev:reload',
11
+ 'build:before',
12
+ 'build:done',
13
+ 'output:done',
14
+ 'deploy:before',
15
+ 'deploy:plan',
16
+ 'deploy:done',
17
+ 'close',
18
+ ];
19
+ export const EVENT_RULES = {
20
+ 'modules:done': 'notify',
21
+ 'config:resolved': 'notify',
22
+ 'dev:ready': 'notify',
23
+ 'dev:reload': 'notify',
24
+ 'build:before': 'gate',
25
+ 'build:done': 'mutate',
26
+ 'output:done': 'notify',
27
+ 'deploy:before': 'gate',
28
+ 'deploy:plan': 'mutate',
29
+ 'deploy:done': 'notify',
30
+ close: 'notify',
31
+ };
32
+ /** Events a project hook (a shell command) may subscribe to: a command cannot change an event object. */
33
+ export const HOOKABLE_EVENTS = CELL_EVENTS.filter(event => EVENT_RULES[event] !== 'mutate');
34
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,cAAc;IACd,iBAAiB;IACjB,WAAW;IACX,YAAY;IACZ,cAAc;IACd,YAAY;IACZ,aAAa;IACb,eAAe;IACf,aAAa;IACb,aAAa;IACb,OAAO;CACD,CAAC;AAWX,MAAM,CAAC,MAAM,WAAW,GAAqC;IACzD,cAAc,EAAE,QAAQ;IACxB,iBAAiB,EAAE,QAAQ;IAC3B,WAAW,EAAE,QAAQ;IACrB,YAAY,EAAE,QAAQ;IACtB,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,QAAQ;IACtB,aAAa,EAAE,QAAQ;IACvB,eAAe,EAAE,MAAM;IACvB,aAAa,EAAE,QAAQ;IACvB,aAAa,EAAE,QAAQ;IACvB,KAAK,EAAE,QAAQ;CAClB,CAAC;AAEF,yGAAyG;AACzG,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './deployer.js';
2
+ export * from './error.js';
3
+ export * from './events.js';
4
+ export * from './module.js';
5
+ export * from './options.js';
6
+ export * from './preset.js';
7
+ export * from './types.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './deployer.js';
2
+ export * from './error.js';
3
+ export * from './events.js';
4
+ export * from './module.js';
5
+ export * from './options.js';
6
+ export * from './preset.js';
7
+ export * from './types.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,166 @@
1
+ import type { CellEventName } from './events.js';
2
+ import type { Preset } from './preset.js';
3
+ import type { Target } from './types.js';
4
+ /** Messages of a module, prefixed with its name; on stderr with `--json`. */
5
+ export interface CellLogger {
6
+ info(message: string): void;
7
+ success(message: string): void;
8
+ warn(message: string): void;
9
+ error(message: string): void;
10
+ }
11
+ /** A component as modules see it. */
12
+ export interface CellComponent {
13
+ name: string;
14
+ version: string;
15
+ dir: string;
16
+ root: boolean;
17
+ }
18
+ /** A finding of a check (`cell check`). `code` is stable, like the codes of CellError. */
19
+ export interface CheckIssue {
20
+ level: 'error' | 'warning' | 'info';
21
+ code: string;
22
+ message: string;
23
+ file?: string;
24
+ line?: number;
25
+ column?: number;
26
+ hint?: string;
27
+ }
28
+ /** What a check gets: the project root and the facts `cell info` has. */
29
+ export interface CheckContext {
30
+ root: string;
31
+ mode: string[];
32
+ /** The project model (`cell info --json` without the toolchain parts). */
33
+ project: unknown;
34
+ }
35
+ /** A check of `cell check` (docs/design/agent-first.md R4). */
36
+ export interface CheckDefinition {
37
+ /** Stable name, e.g. `typeorm:entities`. */
38
+ name: string;
39
+ description: string;
40
+ run(context: CheckContext): CheckIssue[] | Promise<CheckIssue[]>;
41
+ }
42
+ /** A tool of `cell mcp` (docs/design/agent-first.md R8). */
43
+ export interface McpToolDefinition {
44
+ /** Stable name, e.g. `typeorm_entities`. */
45
+ name: string;
46
+ description: string;
47
+ /** JSON Schema of the arguments. */
48
+ inputSchema: Record<string, unknown>;
49
+ /** Does not change files, the project or anything remote. */
50
+ readOnly: boolean;
51
+ /** Talks to the network. */
52
+ network?: boolean;
53
+ run(input: Record<string, unknown>): unknown | Promise<unknown>;
54
+ }
55
+ /** A schema in the Standard Schema form (zod, valibot, arktype implement it). */
56
+ export interface StandardSchema<T = unknown> {
57
+ readonly '~standard': {
58
+ readonly version: 1;
59
+ readonly vendor: string;
60
+ validate(value: unknown): {
61
+ value: T;
62
+ issues?: undefined;
63
+ } | {
64
+ issues: ReadonlyArray<{
65
+ message: string;
66
+ path?: ReadonlyArray<PropertyKey | {
67
+ key: PropertyKey;
68
+ }>;
69
+ }>;
70
+ } | Promise<unknown>;
71
+ };
72
+ }
73
+ /** A Vite plugin, typed loosely so that @celljs/kit does not depend on Vite. */
74
+ export interface VitePluginLike {
75
+ name: string;
76
+ [hook: string]: unknown;
77
+ }
78
+ /** A Node.js request handler of `cell dev` (connect style). */
79
+ export type DevHandler = (req: unknown, res: unknown, next: (error?: unknown) => void) => void;
80
+ /**
81
+ * What a toolchain module gets (docs/design/modules.md §3.1). The factory only registers: it does not
82
+ * start processes, servers, watchers or timers (those belong after `dev:ready`, closed on `close`),
83
+ * because factories also run for `cell info`.
84
+ */
85
+ export interface CellAPI {
86
+ /** The command: `dev`, `build`, `info`, ... */
87
+ readonly command: string;
88
+ readonly mode: readonly string[];
89
+ readonly dev: boolean;
90
+ readonly ci: boolean;
91
+ readonly root: string;
92
+ /** Name of the preset chosen by flag, cell.config.ts or CELL_PRESET; the resolved preset is in `config:resolved`. */
93
+ readonly preset: string | undefined;
94
+ readonly components: readonly CellComponent[];
95
+ readonly logger: CellLogger;
96
+ /** The `key` field of cell.config.ts merged over `defaults`; claims the field. Only during the factory. */
97
+ options<T extends object>(key: string, defaults?: T): T;
98
+ /**
99
+ * Adds to the toolchain configuration, only during the factory: `external` packages join the
100
+ * project's, `vite` is merged under the project's `vite` field (the project wins). Application
101
+ * configuration stays in cell.yml (docs/design/agent-first.md R1): a component ships its defaults
102
+ * in its own cell.yml.
103
+ */
104
+ updateConfig(partial: {
105
+ build?: {
106
+ external?: string[];
107
+ };
108
+ vite?: Record<string, unknown>;
109
+ }): void;
110
+ /** Validates the `key` field of cell.config.ts with a Standard Schema; claims the field. */
111
+ addConfigSchema(key: string, schema: StandardSchema): void;
112
+ /** Adds a Vite plugin to every environment, or only to `client` (frontend) or `server` (backend). */
113
+ addVitePlugin(plugin: VitePluginLike, options?: {
114
+ env?: 'client' | 'server';
115
+ }): void;
116
+ /** Adds a DI module (a file path or package specifier) to a target, after the components' own. */
117
+ addRuntimeModule(path: string, options: {
118
+ target: Target;
119
+ static?: boolean;
120
+ }): void;
121
+ /** Serves `code` as the module `id` (e.g. `virtual:my-module`) in both environments. */
122
+ addVirtualModule(id: string, code: string | (() => string)): void;
123
+ /** Uses `path` as the entry of `target`, over the preset's choice. */
124
+ setEntry(target: Target, path: string): void;
125
+ /** Answers requests under `path` in `cell dev`, before the backend. */
126
+ addDevHandler(path: string, handler: DevHandler): void;
127
+ /** Restarts `cell dev` when the file changes. */
128
+ addWatchFile(path: string): void;
129
+ addPreset(preset: Preset): void;
130
+ /** Writes a file into the output directory after the build (path relative to it). */
131
+ addOutputFile(path: string, content: string | Uint8Array): void;
132
+ addCheck(check: CheckDefinition): void;
133
+ addMcpTool(tool: McpToolDefinition): void;
134
+ /** A directory of Markdown docs for `cell docs` and AGENTS.md (an `AGENTS.md` in it is the guide snippet). */
135
+ addDocs(dir: string): void;
136
+ /** Subscribes to a toolchain event; returns the function that unsubscribes. */
137
+ on(event: CellEventName, handler: (event: any) => unknown): () => void;
138
+ /** A bus between modules, for events of their own. */
139
+ readonly events: {
140
+ on(name: string, handler: (payload: unknown) => unknown): () => void;
141
+ emit(name: string, payload?: unknown): Promise<void>;
142
+ };
143
+ /** Runs a program without a shell. */
144
+ exec(command: string, args?: string[], options?: {
145
+ cwd?: string;
146
+ signal?: AbortSignal;
147
+ timeout?: number;
148
+ }): Promise<{
149
+ code: number;
150
+ stdout: string;
151
+ stderr: string;
152
+ }>;
153
+ /** Resolves a module specifier from the project root. */
154
+ resolve(specifier: string): string;
155
+ }
156
+ export type CellModuleFactory = (cell: CellAPI) => void | Promise<void>;
157
+ export interface CellModuleMeta {
158
+ name: string;
159
+ /** Range of @celljs/cli versions the module works with. */
160
+ compatibility?: string;
161
+ }
162
+ /** A factory with metadata: `export default defineCellModule({ name: '@x/y' }, cell => { ... })`. */
163
+ export declare function defineCellModule(meta: CellModuleMeta, factory: CellModuleFactory): CellModuleFactory & {
164
+ meta: CellModuleMeta;
165
+ };
166
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACvB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,0FAA0F;AAC1F,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,yEAAyE;AACzE,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAA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AAO,KAAK,OAAO,GAAG,MAAM,IAAI,CAAC;QACrE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACxD,CAAC;IAEF,sCAAsC;IACtC,IAAI,CACA,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACnE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,yDAAyD;IACzD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CACtC;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAExE,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qGAAqG;AACrG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,GAAG;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAE/H"}
package/lib/module.js ADDED
@@ -0,0 +1,5 @@
1
+ /** A factory with metadata: `export default defineCellModule({ name: '@x/y' }, cell => { ... })`. */
2
+ export function defineCellModule(meta, factory) {
3
+ return Object.assign((cell) => factory(cell), { meta });
4
+ }
5
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAkKA,qGAAqG;AACrG,MAAM,UAAU,gBAAgB,CAAC,IAAoB,EAAE,OAA0B;IAC7E,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAa,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Options of toolchain modules, keyed by the top-level field of cell.config.ts that each module reads
3
+ * with `cell.options(key, defaults)`. A module declares its options by augmenting this interface, so
4
+ * that a misspelt option is a type error in the project's cell.config.ts:
5
+ *
6
+ * ```ts
7
+ * declare module '@celljs/kit' {
8
+ * interface CellModuleOptions {
9
+ * react?: { fastRefresh?: boolean };
10
+ * }
11
+ * }
12
+ * ```
13
+ */
14
+ export interface CellModuleOptions {
15
+ }
16
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,iBAAiB;CAAG"}
package/lib/options.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ import type { StandardSchema } from './module.js';
2
+ import type { OutputManifest, ProjectModel } from './types.js';
3
+ /** Runtime the server bundle is built for. `workerd` is Cloudflare Workers (with Node.js compatibility). */
4
+ export type ServerRuntime = 'node' | 'workerd';
5
+ /** What {@link Preset.output} gets after the bundles are written. */
6
+ export interface PresetOutputContext {
7
+ /** Project root. */
8
+ root: string;
9
+ /** Absolute output directory. */
10
+ outDir: string;
11
+ project: ProjectModel;
12
+ /** The manifest the build wrote; it is saved again after `output` returns, with the preset's changes. */
13
+ manifest: OutputManifest;
14
+ env: NodeJS.ProcessEnv;
15
+ /** The preset's field of cell.config.ts (named like the preset), validated by {@link Preset.options}; `{}` when absent. */
16
+ options: Record<string, unknown>;
17
+ /** Writes a file relative to the output directory and lists it in `manifest.files`; `mode` e.g. `0o755` for a start script. */
18
+ write(path: string, content: string | Uint8Array, mode?: number): void;
19
+ /** Reported like other build warnings (stderr, and `warnings` of `--json`). */
20
+ warn(message: string): void;
21
+ }
22
+ /** What {@link Preset.preview} gets to run the output locally. */
23
+ export interface PresetPreviewContext {
24
+ root: string;
25
+ /** Absolute output directory. */
26
+ outDir: string;
27
+ manifest: OutputManifest;
28
+ /** `cell preview --port`. */
29
+ port?: number;
30
+ env: NodeJS.ProcessEnv;
31
+ }
32
+ /** A process that runs the output locally, started by `cell preview`. */
33
+ export interface PreviewProcess {
34
+ command: string;
35
+ args: string[];
36
+ /** Added to the environment of `cell preview`. */
37
+ env?: NodeJS.ProcessEnv;
38
+ /** Default: the project root. */
39
+ cwd?: string;
40
+ }
41
+ /**
42
+ * The shape of a build output for a platform (docs/design/modules.md §4): the backend entry and
43
+ * bundle format, files around the bundles, how to run the output locally and which deployer
44
+ * publishes it.
45
+ */
46
+ export interface Preset {
47
+ name: string;
48
+ /** Name of the preset whose fields this one inherits. */
49
+ extends?: string;
50
+ /** Name of the backend entry, picked from the components' `entries` (e.g. `http`). */
51
+ entry?: string;
52
+ /** Server bundle format unless the project chooses one. */
53
+ format?: 'esm' | 'cjs';
54
+ /** Runtime the server bundle runs on. Default `node`. */
55
+ runtime?: ServerRuntime;
56
+ /** One-line description for `cell info` and `--help`. */
57
+ description?: string;
58
+ /** Recognises the CI platform this preset targets; only consulted when `CI` is set. */
59
+ detect?(env: NodeJS.ProcessEnv): boolean;
60
+ /** Writes the platform's files around the bundles (an entry wrapper, deployment configuration). */
61
+ output?(context: PresetOutputContext): void | Promise<void>;
62
+ /** How `cell preview` runs the output; by default Node.js runs `manifest.server`. */
63
+ preview?(context: PresetPreviewContext): PreviewProcess | Promise<PreviewProcess>;
64
+ /** Name of the deployer `cell deploy` uses for this output. */
65
+ deployer?: string;
66
+ /**
67
+ * Schema of the preset's options: the field of cell.config.ts named like the preset (e.g.
68
+ * `fc: { region: 'cn-shanghai' }`). The field is accepted whichever preset a build uses.
69
+ */
70
+ options?: StandardSchema;
71
+ /** Output directory unless the project chooses one, e.g. `.vercel/output` where the platform looks for it. */
72
+ outDir?: string;
73
+ /** The platform serves the frontend as static files: `--single` and `--compile` do not apply. */
74
+ staticHosting?: boolean;
75
+ }
76
+ /** Types a preset definition; returns it unchanged. */
77
+ export declare function definePreset(preset: Preset): Preset;
78
+ //# sourceMappingURL=preset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/D,4GAA4G;AAC5G,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;AAE/C,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IAChC,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC;IACtB,yGAAyG;IACzG,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,2HAA2H;IAC3H,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,+HAA+H;IAC/H,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvE,+EAA+E;IAC/E,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,MAAM,CAAC;IAC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AC3B;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD"}
package/lib/preset.js ADDED
@@ -0,0 +1,5 @@
1
+ /** Types a preset definition; returns it unchanged. */
2
+ export function definePreset(preset) {
3
+ return preset;
4
+ }
5
+ //# sourceMappingURL=preset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAiFA,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAC,MAAc;IACvC,OAAO,MAAM,CAAC;AAClB,CAAC"}