aktion-runtime 0.5.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 +1246 -0
- package/dist/aktion.iife.js +8431 -0
- package/dist/aktion.iife.js.map +1 -0
- package/dist/aktion.js +22594 -0
- package/dist/aktion.js.map +1 -0
- package/dist/aktion.umd.cjs +8431 -0
- package/dist/aktion.umd.cjs.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/system_prompt.txt +1095 -0
- package/dist/system_prompt_chat.txt +404 -0
- package/dist/types/element.d.ts +175 -0
- package/dist/types/icons/index.d.ts +45 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/language/builtins.d.ts +33 -0
- package/dist/types/language/components.d.ts +28 -0
- package/dist/types/language/grammar.d.ts +121 -0
- package/dist/types/language/index.d.ts +41 -0
- package/dist/types/language/snippets.d.ts +17 -0
- package/dist/types/library/components/_internal.d.ts +56 -0
- package/dist/types/library/components/advanced-charts.d.ts +6 -0
- package/dist/types/library/components/advanced-data.d.ts +6 -0
- package/dist/types/library/components/advanced-forms.d.ts +12 -0
- package/dist/types/library/components/advanced-patterns.d.ts +13 -0
- package/dist/types/library/components/charts.d.ts +5 -0
- package/dist/types/library/components/chat.d.ts +6 -0
- package/dist/types/library/components/content.d.ts +33 -0
- package/dist/types/library/components/data.d.ts +9 -0
- package/dist/types/library/components/editors.d.ts +5 -0
- package/dist/types/library/components/feedback.d.ts +14 -0
- package/dist/types/library/components/forms-shared.d.ts +7 -0
- package/dist/types/library/components/forms.d.ts +21 -0
- package/dist/types/library/components/helpers.d.ts +33 -0
- package/dist/types/library/components/layout.d.ts +20 -0
- package/dist/types/library/components/media.d.ts +7 -0
- package/dist/types/library/components/menu.d.ts +5 -0
- package/dist/types/library/components/navigation.d.ts +6 -0
- package/dist/types/library/components/new-components.d.ts +13 -0
- package/dist/types/library/components/patterns.d.ts +39 -0
- package/dist/types/library/components/router.d.ts +2 -0
- package/dist/types/library/components/theme.d.ts +2 -0
- package/dist/types/library/index.d.ts +5 -0
- package/dist/types/library/registry.d.ts +15 -0
- package/dist/types/library/types.d.ts +140 -0
- package/dist/types/library/utils.d.ts +73 -0
- package/dist/types/library/validate.d.ts +27 -0
- package/dist/types/parser/frontier.d.ts +65 -0
- package/dist/types/parser/index.d.ts +4 -0
- package/dist/types/parser/lexer.d.ts +46 -0
- package/dist/types/parser/parser.d.ts +2 -0
- package/dist/types/parser/types.d.ts +349 -0
- package/dist/types/prompt/generator.d.ts +33 -0
- package/dist/types/prompt/index.d.ts +1 -0
- package/dist/types/renderer/index.d.ts +1 -0
- package/dist/types/renderer/morph.d.ts +42 -0
- package/dist/types/renderer/renderer.d.ts +73 -0
- package/dist/types/runtime/builtins.d.ts +27 -0
- package/dist/types/runtime/console.d.ts +21 -0
- package/dist/types/runtime/effects.d.ts +69 -0
- package/dist/types/runtime/evaluator.d.ts +151 -0
- package/dist/types/runtime/http.d.ts +85 -0
- package/dist/types/runtime/i18n.d.ts +40 -0
- package/dist/types/runtime/index.d.ts +9 -0
- package/dist/types/runtime/router.d.ts +105 -0
- package/dist/types/runtime/state.d.ts +84 -0
- package/dist/types/runtime/storage.d.ts +50 -0
- package/dist/types/theme/index.d.ts +175 -0
- package/dist/types/theme/styles.d.ts +9 -0
- package/dist/types/tooling/codemod.d.ts +36 -0
- package/dist/types/tooling/delta.d.ts +74 -0
- package/dist/types/tooling/formatter.d.ts +8 -0
- package/dist/types/tooling/index.d.ts +29 -0
- package/dist/types/tooling/inspector.d.ts +49 -0
- package/dist/types/tooling/language-service.d.ts +57 -0
- package/package.json +63 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aktion 0.5 §27 — automatic v1 → 0.5 source codemod.
|
|
3
|
+
*
|
|
4
|
+
* The migration helper accepts a *v1* source string and returns a
|
|
5
|
+
* best-effort *0.5* equivalent, plus a list of advisory notes describing
|
|
6
|
+
* each transformation. The codemod targets the legacy surfaces enumerated
|
|
7
|
+
* in `language-update-final.md` Appendix A; surfaces that have no clean
|
|
8
|
+
* textual rewrite (e.g. `Action([@Set, …])`'s open-ended payload DSL)
|
|
9
|
+
* surface a note pointing the author at the manual migration path.
|
|
10
|
+
*
|
|
11
|
+
* Why a text codemod rather than an AST-to-AST one? The v1 grammar is
|
|
12
|
+
* accepted as a hard parse error by the current parser (the legacy
|
|
13
|
+
* `name=value`, `$$x` sigil, `Name(args) = expr` macros, etc. all raise
|
|
14
|
+
* definitive errors). Re-introducing v1 syntax just to round-trip
|
|
15
|
+
* through the parser would defeat the purpose of removing it — and a
|
|
16
|
+
* focused set of regexes handles the line-oriented transforms cleanly
|
|
17
|
+
* because the v1 grammar is itself line-oriented.
|
|
18
|
+
*
|
|
19
|
+
* The codemod is idempotent: feeding its output back through `migrateV1`
|
|
20
|
+
* is a no-op.
|
|
21
|
+
*/
|
|
22
|
+
export interface MigrateV1Result {
|
|
23
|
+
/** Best-effort 0.5 source. */
|
|
24
|
+
source: string;
|
|
25
|
+
/** Human-readable record of every transform that fired, in source order. */
|
|
26
|
+
notes: string[];
|
|
27
|
+
/** Hand-migration hints for surfaces that have no clean text rewrite. */
|
|
28
|
+
manualMigrations: string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Run the v1 → 0.5 codemod on `source`. The transform is best-effort:
|
|
32
|
+
* unmigratable surfaces produce a `manualMigrations` note instead of an
|
|
33
|
+
* automatic rewrite, so the caller knows which lines still need a human
|
|
34
|
+
* touch.
|
|
35
|
+
*/
|
|
36
|
+
export declare function migrateV1(source: string): MigrateV1Result;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aktion 0.5 §14 — Delta Protocol.
|
|
3
|
+
*
|
|
4
|
+
* In v1 every LLM turn replaced the entire program. SUIS/2 ships a
|
|
5
|
+
* structured delta surface so a "tweak the UI" turn can stay tiny:
|
|
6
|
+
* a handful of typed operations applied to the previous program's
|
|
7
|
+
* Committed AST. The runtime mounts the patched program with the
|
|
8
|
+
* user's `$state` preserved across the diff.
|
|
9
|
+
*
|
|
10
|
+
* The spec's original pragma signalling (`#sus/2 delta`) was retired
|
|
11
|
+
* along with every other pragma in 0.5 (`#…` lines are comments). The
|
|
12
|
+
* delta is therefore expressed as **structured operations** — hosts
|
|
13
|
+
* call `el.applyDelta(ops)` directly, no in-language pragma required.
|
|
14
|
+
*
|
|
15
|
+
* Operations
|
|
16
|
+
* ----------
|
|
17
|
+
*
|
|
18
|
+
* { kind: "patch", target: "stateName", value: 50 }
|
|
19
|
+
* Update a `$state` atom in place. Does not touch the program
|
|
20
|
+
* text. Use for "set the slider to 50", "expand the panel", etc.
|
|
21
|
+
*
|
|
22
|
+
* { kind: "replace", binding: "header", source: "PageHeader(\"Sales\")" }
|
|
23
|
+
* Replace a top-level binding's RHS. Equivalent to deleting and
|
|
24
|
+
* re-emitting the line(s).
|
|
25
|
+
*
|
|
26
|
+
* { kind: "append", binding: "items", item: "{ label: \"Reports\" }" }
|
|
27
|
+
* Append an item to a top-level array binding. `binding`'s RHS
|
|
28
|
+
* must be a literal array expression.
|
|
29
|
+
*
|
|
30
|
+
* { kind: "new", source: "component ReportCard(r) { Card([Text(r.title)]) }" }
|
|
31
|
+
* Append a new top-level statement to the program.
|
|
32
|
+
*
|
|
33
|
+
* { kind: "delete", binding: "legacyWidget" }
|
|
34
|
+
* Remove a top-level binding (or component / action / effect /
|
|
35
|
+
* endpoint declaration) by name.
|
|
36
|
+
*
|
|
37
|
+
* Op application is best-effort: each op that does not match its
|
|
38
|
+
* target surfaces an advisory warning and is skipped. The runtime
|
|
39
|
+
* still mounts the rest of the patched program — partial deltas
|
|
40
|
+
* never strand the user with no UI.
|
|
41
|
+
*
|
|
42
|
+
* The function is pure: feed in `(source, ops)`, get back
|
|
43
|
+
* `(programText, stateUpdates, warnings)`. State application is the
|
|
44
|
+
* caller's responsibility (the host element wires it up — see
|
|
45
|
+
* `AktionElement.applyDelta`).
|
|
46
|
+
*/
|
|
47
|
+
export type DeltaOp = {
|
|
48
|
+
kind: "patch";
|
|
49
|
+
target: string;
|
|
50
|
+
value: unknown;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "replace";
|
|
53
|
+
binding: string;
|
|
54
|
+
source: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "append";
|
|
57
|
+
binding: string;
|
|
58
|
+
item: string;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "new";
|
|
61
|
+
source: string;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "delete";
|
|
64
|
+
binding: string;
|
|
65
|
+
};
|
|
66
|
+
export interface DeltaResult {
|
|
67
|
+
/** Source text after every structural op (replace/append/new/delete) lands. */
|
|
68
|
+
programText: string;
|
|
69
|
+
/** `patch` ops collected as a name→value map; the caller applies these to its state store. */
|
|
70
|
+
stateUpdates: Record<string, unknown>;
|
|
71
|
+
/** Advisory diagnostics for ops that became no-ops. */
|
|
72
|
+
warnings: string[];
|
|
73
|
+
}
|
|
74
|
+
export declare function applyDelta(source: string, ops: readonly DeltaOp[]): DeltaResult;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParseError } from '../parser/types.js';
|
|
2
|
+
export interface FormatResult {
|
|
3
|
+
/** Canonical source. Equal to the input when parse errors occur. */
|
|
4
|
+
formatted: string;
|
|
5
|
+
/** Parse errors raised while reading the input — formatting is a no-op when non-empty. */
|
|
6
|
+
errors: ParseError[];
|
|
7
|
+
}
|
|
8
|
+
export declare function formatProgram(source: string): FormatResult;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tooling surface (§27) — host-side helpers projected from the schema.
|
|
3
|
+
*
|
|
4
|
+
* The pieces ship as a separate entry so library consumers can opt in
|
|
5
|
+
* without paying for them at runtime. Each helper is pure: feed in
|
|
6
|
+
* source / AST / library, get diagnostics, canonical source, or a
|
|
7
|
+
* structured AST view back.
|
|
8
|
+
*
|
|
9
|
+
* Surfaces
|
|
10
|
+
* --------
|
|
11
|
+
*
|
|
12
|
+
* - `formatProgram(source)` — canonical pretty-printer.
|
|
13
|
+
* - `applyDelta(source, ops)` — structured edit protocol (§14).
|
|
14
|
+
* - `migrateV1(source)` — best-effort v1 → 0.5 codemod (Appendix A).
|
|
15
|
+
* - `inspectAST(source)` — Committed + Drafting AST snapshot.
|
|
16
|
+
* - `getDiagnostics(source, library)` — language-service diagnostics.
|
|
17
|
+
* - `getCompletions(source, position, library)` — completions.
|
|
18
|
+
* - `getHoverInfo(source, position, library)` — hover docs.
|
|
19
|
+
*/
|
|
20
|
+
export { formatProgram } from './formatter.js';
|
|
21
|
+
export type { FormatResult } from './formatter.js';
|
|
22
|
+
export { applyDelta } from './delta.js';
|
|
23
|
+
export type { DeltaOp, DeltaResult } from './delta.js';
|
|
24
|
+
export { migrateV1 } from './codemod.js';
|
|
25
|
+
export type { MigrateV1Result } from './codemod.js';
|
|
26
|
+
export { inspectAST, inspectProgram } from './inspector.js';
|
|
27
|
+
export type { InspectorBinding, InspectorView } from './inspector.js';
|
|
28
|
+
export { getDiagnostics, getCompletions, getHoverInfo, } from './language-service.js';
|
|
29
|
+
export type { Position, Diagnostic, CompletionItem, HoverInfo, } from './language-service.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Program } from '../parser/types.js';
|
|
2
|
+
export interface InspectorBinding {
|
|
3
|
+
/** Top-level name (e.g. `root`, `count`, `Header`). */
|
|
4
|
+
name: string;
|
|
5
|
+
/** What kind of declaration introduced this binding. */
|
|
6
|
+
kind: "assignment" | "component" | "effect" | "action" | "router";
|
|
7
|
+
/** Source line (1-indexed). */
|
|
8
|
+
line: number;
|
|
9
|
+
/** Source column (1-indexed). */
|
|
10
|
+
column: number;
|
|
11
|
+
/** Brief textual summary (callee name for assignments, endpoint method, …). */
|
|
12
|
+
summary?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface InspectorView {
|
|
15
|
+
/** Committed prefix that has already parsed cleanly. */
|
|
16
|
+
committed: {
|
|
17
|
+
source: string;
|
|
18
|
+
bindings: InspectorBinding[];
|
|
19
|
+
statementCount: number;
|
|
20
|
+
};
|
|
21
|
+
/** Drafting tail past the committed frontier. */
|
|
22
|
+
drafting: {
|
|
23
|
+
source: string;
|
|
24
|
+
bindings: InspectorBinding[];
|
|
25
|
+
statementCount: number;
|
|
26
|
+
/** SCC-2 — names declared in the drafting tail but not yet committed. */
|
|
27
|
+
inFlightNames: string[];
|
|
28
|
+
};
|
|
29
|
+
/** Parse errors (if any). Empty when the whole input parses cleanly. */
|
|
30
|
+
errors: ReadonlyArray<{
|
|
31
|
+
line: number;
|
|
32
|
+
column: number;
|
|
33
|
+
message: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** Total number of declared bindings across both ASTs. */
|
|
36
|
+
totalBindings: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Inspect `source` and return a JSON-friendly view of the Committed +
|
|
40
|
+
* Drafting ASTs. Cheap — runs a single `parse` pass via
|
|
41
|
+
* `computeFrontier`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function inspectAST(source: string): InspectorView;
|
|
44
|
+
/**
|
|
45
|
+
* Build a view directly from a parsed `Program`. Useful for hosts that
|
|
46
|
+
* have already paid the parse cost and just need the structured
|
|
47
|
+
* projection.
|
|
48
|
+
*/
|
|
49
|
+
export declare function inspectProgram(source: string, program: Program): InspectorView;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ComponentLibrary } from '../library/types.js';
|
|
2
|
+
export interface Position {
|
|
3
|
+
/** 1-indexed line number. */
|
|
4
|
+
line: number;
|
|
5
|
+
/** 1-indexed column number. */
|
|
6
|
+
column: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Diagnostic {
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
message: string;
|
|
12
|
+
/** `error` when the program will not render; `warning` is reserved for the future. */
|
|
13
|
+
severity: "error" | "warning";
|
|
14
|
+
}
|
|
15
|
+
export interface CompletionItem {
|
|
16
|
+
/** Insertion text (the user types this to accept). */
|
|
17
|
+
label: string;
|
|
18
|
+
/**
|
|
19
|
+
* What kind of symbol this is. Useful when the host wants to render
|
|
20
|
+
* different icons per kind (LSP / editor UIs typically display these).
|
|
21
|
+
*/
|
|
22
|
+
kind: "component" | "prop" | "state" | "builtin" | "keyword";
|
|
23
|
+
/** Short textual description. */
|
|
24
|
+
detail?: string;
|
|
25
|
+
/** Long-form documentation surfaced in a tooltip. */
|
|
26
|
+
documentation?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface HoverInfo {
|
|
29
|
+
/** Markdown-friendly text rendered in the hover popup. */
|
|
30
|
+
contents: string;
|
|
31
|
+
/** Symbol kind for clients that prefer typed surfaces. */
|
|
32
|
+
kind: "component" | "prop" | "state" | "builtin" | "unknown";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Combine parse-level + schema-level diagnostics into one list. Every
|
|
36
|
+
* entry has a `severity` field so editors can theme errors vs warnings
|
|
37
|
+
* (in 0.5 every entry is currently `error` — there are no soft
|
|
38
|
+
* warnings — but the surface stays future-proof).
|
|
39
|
+
*/
|
|
40
|
+
export declare function getDiagnostics(source: string, library: ComponentLibrary): Diagnostic[];
|
|
41
|
+
/**
|
|
42
|
+
* Completion items for the cursor position `position`. Heuristics are
|
|
43
|
+
* intentionally simple — the prompt + the closed schema (§16) make
|
|
44
|
+
* deep static analysis unnecessary:
|
|
45
|
+
*
|
|
46
|
+
* - Inside `(...)` after a known component name → the spec's prop
|
|
47
|
+
* names (filtered to unconsumed props).
|
|
48
|
+
* - After `$` → state-tier keywords (`$state`, `$persist`, …).
|
|
49
|
+
* - At top of line / inside a block → top-level keywords + the
|
|
50
|
+
* full library component list.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getCompletions(source: string, position: Position, library: ComponentLibrary): CompletionItem[];
|
|
53
|
+
/**
|
|
54
|
+
* Hover info for the symbol under the cursor. Returns `null` when the
|
|
55
|
+
* cursor is not over a recognised symbol.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getHoverInfo(source: string, position: Position, library: ComponentLibrary): HoverInfo | null;
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aktion-runtime",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Aktion is a single web component that turns a compact, streaming-first DSL into a rich, interactive UI inside its shadow DOM. Works in React, Vue, Angular, Svelte, plain HTML — or no framework at all.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/aktion.css",
|
|
16
|
+
"./system_prompt.txt": "./dist/system_prompt.txt",
|
|
17
|
+
"./system_prompt_chat.txt": "./dist/system_prompt_chat.txt"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "vite",
|
|
27
|
+
"build": "tsc -p tsconfig.build.json && vite build && node scripts/emit-prompt.mjs && node scripts/emit-entry.mjs",
|
|
28
|
+
"build:lib": "vite build",
|
|
29
|
+
"build:prompt": "node scripts/emit-prompt.mjs",
|
|
30
|
+
"build:entry": "node scripts/emit-entry.mjs",
|
|
31
|
+
"build:docs": "node scripts/build-docs.mjs",
|
|
32
|
+
"preview": "vite preview",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"prepublishOnly": "npm run build"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"typescript": "^5.6.3",
|
|
39
|
+
"vite": "^5.4.10",
|
|
40
|
+
"vite-plugin-dts": "^4.3.0",
|
|
41
|
+
"vitest": "^2.1.4",
|
|
42
|
+
"@vitest/web-worker": "^2.1.4",
|
|
43
|
+
"happy-dom": "^15.7.4"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"llm",
|
|
47
|
+
"ai",
|
|
48
|
+
"web-components",
|
|
49
|
+
"aktion",
|
|
50
|
+
"generative-ui",
|
|
51
|
+
"rich-ui",
|
|
52
|
+
"custom-elements"
|
|
53
|
+
],
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/asfand-dev/aktion.git"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://asfand-dev.github.io/aktion/",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/asfand-dev/aktion/issues"
|
|
61
|
+
},
|
|
62
|
+
"license": "MIT"
|
|
63
|
+
}
|