@intent-framework/core 0.1.0-alpha.1 → 0.1.0-alpha.2
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 +67 -0
- package/dist/index.js +16 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @intent-framework/core
|
|
2
|
+
|
|
3
|
+
Platformless semantic graph and runtime for Intent applications.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @intent-framework/core@0.1.0-alpha.1
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @intent-framework/core@0.1.0-alpha.1
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What it provides
|
|
16
|
+
|
|
17
|
+
- `screen()` — define a semantic interaction space
|
|
18
|
+
- `$.state.text()` / `$.state.boolean()` / `$.state.choice()` — reactive state
|
|
19
|
+
- `$.ask()` — user-facing question with validation
|
|
20
|
+
- `$.act()` — executable action with conditions, lifecycle, and feedback
|
|
21
|
+
- `$.resource()` — async state with load/reload lifecycle
|
|
22
|
+
- `$.surface()` — named containment surface
|
|
23
|
+
- `createScreenRuntime()` — runtime that owns screen state and resources
|
|
24
|
+
- `inspectScreen()` — semantic graph snapshot with diagnostics
|
|
25
|
+
- Condition and signal primitives
|
|
26
|
+
|
|
27
|
+
## Minimal example
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { screen, inspectScreen } from "@intent-framework/core"
|
|
31
|
+
|
|
32
|
+
const InviteMember = screen("InviteMember", $ => {
|
|
33
|
+
const email = $.state.text("email")
|
|
34
|
+
|
|
35
|
+
const emailAsk = $.ask("Email", email)
|
|
36
|
+
.required("Email is required")
|
|
37
|
+
.validate(value => value.includes("@") ? true : "Enter a valid email")
|
|
38
|
+
|
|
39
|
+
const invite = $.act("Invite member")
|
|
40
|
+
.primary()
|
|
41
|
+
.when(emailAsk.valid, "Enter a valid email first")
|
|
42
|
+
.does(() => {
|
|
43
|
+
console.log("invite", email.value)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
$.surface("main").contains(emailAsk, invite)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const graph = inspectScreen(InviteMember)
|
|
50
|
+
console.log(graph.diagnostics)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Where this fits
|
|
54
|
+
|
|
55
|
+
Core defines the product graph. It has no DOM, React, Node, or framework dependencies. Renderers (`@intent-framework/dom`), the router (`@intent-framework/router`), and testing (`@intent-framework/testing`) all build on core.
|
|
56
|
+
|
|
57
|
+
## Learn more
|
|
58
|
+
|
|
59
|
+
- [Root README](../../README.md) — project overview and philosophy
|
|
60
|
+
- [Quickstart](../../docs/Quickstart.md) — step-by-step guide
|
|
61
|
+
- [Inspect Screen and Diagnostics Guide](../../docs/Inspect-Screen.md) — graph inspection and diagnostics
|
|
62
|
+
- [Resources Guide](../../docs/Resources.md) — resource lifecycle and runtime scoping
|
|
63
|
+
- [MVP Checkpoint](../../docs/MVP-Checkpoint.md) — current implementation boundaries
|
|
64
|
+
|
|
65
|
+
## Status
|
|
66
|
+
|
|
67
|
+
Experimental alpha. Version `0.1.0-alpha.1`. APIs may change. Not recommended for production use.
|
package/dist/index.js
CHANGED
|
@@ -761,6 +761,22 @@ function computeDiagnostics(screenDef) {
|
|
|
761
761
|
message: "Action is defined but not included in any surface.",
|
|
762
762
|
nodeId: act.id
|
|
763
763
|
});
|
|
764
|
+
if (screenDef.flows.length > 0) {
|
|
765
|
+
const flowNodeIds = /* @__PURE__ */ new Set();
|
|
766
|
+
for (const flow of screenDef.flows) for (const step of flow.steps) flowNodeIds.add(step.node.id);
|
|
767
|
+
for (const ask of screenDef.asks) if (surfacedNodeIds.has(ask.id) && !flowNodeIds.has(ask.id)) diagnostics.push({
|
|
768
|
+
severity: "info",
|
|
769
|
+
code: "surfaced-node-not-in-any-flow",
|
|
770
|
+
message: `"${ask.label}" is surfaced but not referenced in any flow.`,
|
|
771
|
+
nodeId: ask.id
|
|
772
|
+
});
|
|
773
|
+
for (const act of screenDef.acts) if (surfacedNodeIds.has(act.id) && !flowNodeIds.has(act.id)) diagnostics.push({
|
|
774
|
+
severity: "info",
|
|
775
|
+
code: "surfaced-node-not-in-any-flow",
|
|
776
|
+
message: `"${act.label}" is surfaced but not referenced in any flow.`,
|
|
777
|
+
nodeId: act.id
|
|
778
|
+
});
|
|
779
|
+
}
|
|
764
780
|
return diagnostics;
|
|
765
781
|
}
|
|
766
782
|
function inspectScreen(screenDef, runtimeResources) {
|