@pathmx/completion 0.5.0 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +35 -135
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,28 +1,27 @@
1
1
  # `@pathmx/completion`
2
2
 
3
- The opt-in, domain-neutral Completion primitive for PathMX. It owns stable
4
- Source-local leaf references, Actor-owned outcomes, flat summaries, State
5
- persistence, authored manual targets, and the canonical set/unset Action. It
6
- does not own Path trees, forms, or domain rollups.
3
+ Actor-relative completion tracking for PathMX. It stores stable terminal
4
+ outcomes while domains such as Paths and Assessment own their structure and
5
+ rollups.
7
6
 
8
- ```ts
9
- import { createCompletionPlugin } from "@pathmx/completion"
7
+ ## Install
10
8
 
11
- const completion = createCompletionPlugin()
9
+ ```sh
10
+ bun run pmx plugins add completion
11
+ ```
12
12
 
13
- export const plugins = [completion.plugin]
13
+ Activate Completion directly when you are not using `@pathmx/paths`:
14
14
 
15
- completion.reader.read(actor.id, {
16
- source: "/lessons/setup.page",
17
- key: "task/install",
18
- })
15
+ ```ts
16
+ // plugins/completion.plugin.ts
17
+ import { createCompletionPlugin } from "@pathmx/completion"
18
+
19
+ export default createCompletionPlugin().plugin
19
20
  ```
20
21
 
21
- ## Authored targets
22
+ ## Author completion targets
22
23
 
23
- A Source or authored Block can declare a manual target with the owned
24
- `completion` schema prop. Source targets use `source/self`; Block targets use
25
- their required stable authored id:
24
+ Mark an entire Source as completable in frontmatter:
26
25
 
27
26
  ```md
28
27
  ---
@@ -30,142 +29,43 @@ completion:
30
29
  target: true
31
30
  label: Finish this lesson
32
31
  ---
33
-
34
- # Lesson
35
-
36
- ---
37
-
38
- <!--
39
- id: practice
40
- completion:
41
- target: true
42
- label: Finish the practice
43
- optional: true
44
- -->
45
32
  ```
46
33
 
47
- A trailing task mark produces a stable `task/<id>` target without obscuring
48
- the human label:
34
+ Or add stable task targets:
49
35
 
50
36
  ```md
51
37
  - [ ] Install dependencies {#install}
52
38
  - [ ] Explore the bonus {#bonus .optional}
53
39
  ```
54
40
 
55
- `completionTargets(source)` projects the same frozen target model from a
56
- canonical `Source` or viewer-safe `SourceView`. The Completion Action is
57
- available only when the current Source has valid configured targets; it binds
58
- the Source id and validates the submitted key and optionality.
59
-
60
- Domains using Completion-owned manual facts can contribute only their stable
61
- keys and optionality:
62
-
63
- ```ts
64
- const completion = createCompletionPlugin({
65
- contributors: [
66
- (source) =>
67
- source.type === "project"
68
- ? [{ key: "project/launch", optional: false }]
69
- : [],
70
- ],
71
- })
72
- ```
73
-
74
- The domain continues to own labels, structure, and rollups. Derived evidence
75
- such as a valid Input submission remains owned by its provider and uses a
76
- separate read contract rather than writing a duplicate manual fact:
77
-
78
- ```ts
79
- import { createCompletionPlugin } from "@pathmx/completion"
80
- import { createInputPlugin } from "@pathmx/core/plugins"
81
-
82
- const input = createInputPlugin()
83
- const completion = createCompletionPlugin({
84
- evidence: [input.completion],
85
- })
86
-
87
- export const plugins = [input.plugin, completion.plugin]
88
- ```
89
-
90
- Input completion is declared on one stable authored Block, making the form or
91
- question container—not each field—the semantic leaf:
41
+ A Block can also declare its own target when it has a stable authored id:
92
42
 
93
43
  ```md
94
44
  <!--
95
- id: reflection
96
- input-response:
97
- completion: true
45
+ id: practice
46
+ completion:
47
+ target: true
48
+ label: Finish the practice
98
49
  -->
99
-
100
- <x-input-text name="response" label="Reflection" required />
101
- <x-input-submit label="Save response" />
102
50
  ```
103
51
 
104
- This declares `input/reflection`. It becomes complete only when that Actor has
105
- a submitted Input State whose values still validate against the current
106
- authored fields. The derived target never exposes `completion:set` and never
107
- writes Completion State. Input currently owns one aggregate State per Source,
108
- so a Source may declare one Input completion Block.
52
+ Run `bun run pmx lint` to catch malformed, duplicate, or stale completion
53
+ targets.
109
54
 
110
- `pmx lint` reports malformed props, unstable Block targets, checked or empty
111
- marked tasks, invalid and duplicate keys, stale facts, manual/derived
112
- collisions, and invalid skips for the currently configured contributors and
113
- evidence providers. Input additionally reports invalid completion containers,
114
- bound State references, and stored values.
55
+ ## Plugin API
115
56
 
116
- State is grouped by originating Source and stores only terminal leaf outcomes:
57
+ `createCompletionPlugin()` returns both a Plugin factory and an Actor-relative
58
+ reader:
117
59
 
118
- ```yaml
119
- ---
120
- type: state
121
- plugin: completion
122
- for: /lessons/setup.page
123
- items:
124
- task/install:
125
- outcome: complete
126
- occurred_at: 2026-08-22T12:00:00.000Z
127
- task/bonus:
128
- outcome: skipped
129
- occurred_at: 2026-08-22T12:05:00.000Z
130
- ---
131
- ```
60
+ ```ts
61
+ import { createCompletionPlugin } from "@pathmx/completion"
132
62
 
133
- `occurred_at` is the occurrence time of the current terminal fact. Repeating
134
- the same outcome preserves it; clearing and completing again records a new
135
- time. `pending` is represented by the absence of an item. Provider evidence is
136
- read through the composed Completion reader; domain rollups remain with their
137
- owning plugins.
138
-
139
- ## React apps
140
-
141
- React remains an optional subpath:
142
-
143
- ```tsx
144
- import {
145
- CompletionProvider,
146
- useCompletion,
147
- useCompletionAction,
148
- } from "@pathmx/completion/react"
149
-
150
- function Task() {
151
- const fact = useCompletion("task/install")
152
- const completion = useCompletionAction("task/install")
153
- return (
154
- <button
155
- disabled={completion.pending}
156
- onClick={() => completion.set(fact ? "pending" : "complete")}
157
- >
158
- {fact ? "Completed" : "Mark complete"}
159
- </button>
160
- )
161
- }
162
-
163
- ;<CompletionProvider initial={serverProjectedFacts}>
164
- <Task />
165
- </CompletionProvider>
63
+ const completion = createCompletionPlugin()
64
+ const fact = completion.reader.read(actor.id, {
65
+ source: "/lessons/setup.page",
66
+ key: "task/install",
67
+ })
166
68
  ```
167
69
 
168
- The App Component server renderer supplies `serverProjectedFacts` for the
169
- current viewer. The browser receives no Completion reader or repository
170
- access. See `labs/assessment/plugins/class-assessment` for a complete App
171
- Component using the same provider with derived submission completion.
70
+ React integrations can import `CompletionProvider`, `useCompletion`, and
71
+ `useCompletionAction` from `@pathmx/completion/react`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pathmx/completion",
3
3
  "description": "Actor-relative completion tracking for PathMX.",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
7
7
  "type": "git",