@yaks/task 0.0.0-stage → 0.2.36

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 (68) hide show
  1. package/DecisionForm.js +118 -0
  2. package/DecisionForm.js.map +1 -0
  3. package/DecisionForm.ts +211 -0
  4. package/LICENSE +202 -0
  5. package/README.md +389 -2
  6. package/_dist/DecisionForm.d.ts +25 -0
  7. package/_dist/DecisionForm.d.ts.map +1 -0
  8. package/_dist/comp.d.ts +20 -0
  9. package/_dist/comp.d.ts.map +1 -0
  10. package/_dist/decision.d.ts +41 -0
  11. package/_dist/decision.d.ts.map +1 -0
  12. package/_dist/deps.d.ts +58 -0
  13. package/_dist/deps.d.ts.map +1 -0
  14. package/_dist/graph.d.ts +3 -0
  15. package/_dist/graph.d.ts.map +1 -0
  16. package/_dist/mod.d.ts +71 -0
  17. package/_dist/mod.d.ts.map +1 -0
  18. package/_dist/plugin.d.ts +28 -0
  19. package/_dist/plugin.d.ts.map +1 -0
  20. package/_dist/text.d.ts +5 -0
  21. package/_dist/text.d.ts.map +1 -0
  22. package/_dist/tools.d.ts +20 -0
  23. package/_dist/tools.d.ts.map +1 -0
  24. package/_dist/views.d.ts +6 -0
  25. package/_dist/views.d.ts.map +1 -0
  26. package/_dist/vocab.d.ts +7 -0
  27. package/_dist/vocab.d.ts.map +1 -0
  28. package/_dist/words.d.ts +28 -0
  29. package/_dist/words.d.ts.map +1 -0
  30. package/comp.js +66 -0
  31. package/comp.js.map +1 -0
  32. package/comp.ts +77 -0
  33. package/decision.js +156 -0
  34. package/decision.js.map +1 -0
  35. package/decision.ts +174 -0
  36. package/deno.json +1 -0
  37. package/deps.js +127 -0
  38. package/deps.js.map +1 -0
  39. package/deps.ts +163 -0
  40. package/graph.js +9 -0
  41. package/graph.js.map +1 -0
  42. package/graph.ts +10 -0
  43. package/inspect.js +131 -0
  44. package/inspect.js.map +1 -0
  45. package/inspect.ts +144 -0
  46. package/mod.js +71 -0
  47. package/mod.js.map +1 -0
  48. package/mod.ts +83 -0
  49. package/package.json +53 -4
  50. package/plugin.js +46 -0
  51. package/plugin.js.map +1 -0
  52. package/plugin.ts +40 -0
  53. package/text.js +22 -0
  54. package/text.js.map +1 -0
  55. package/text.ts +30 -0
  56. package/tools.js +303 -0
  57. package/tools.js.map +1 -0
  58. package/tools.ts +282 -0
  59. package/views.js +35 -0
  60. package/views.js.map +1 -0
  61. package/views.ts +39 -0
  62. package/vocab.js +18 -0
  63. package/vocab.js.map +1 -0
  64. package/vocab.json +860 -0
  65. package/vocab.ts +20 -0
  66. package/words.js +46 -0
  67. package/words.js.map +1 -0
  68. package/words.ts +57 -0
package/README.md CHANGED
@@ -1,3 +1,390 @@
1
- # Temporary Holding Version
1
+ # @yaks/task
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
+ Task components and operations for [@yaks/graph](../graph). The package defines
4
+ open, completed and cancelled tasks, counts unfinished dependencies, and
5
+ supplies tools to create task plans, list and edit tasks, and ask and answer
6
+ decisions.
7
+
8
+ A task is an entity with a `task` component. It can also carry a title from
9
+ [@yaks/doc](../doc), filing information from [@yaks/project](../project), or
10
+ components your application defines.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ deno add jsr:@yaks/task
16
+ # or: npx jsr add @yaks/task
17
+ ```
18
+
19
+ The examples also use `@yaks/graph`, `@yaks/vocab`, `@yaks/ram`, `@yaks/kernel`,
20
+ `@yaks/doc` and `@yaks/edge`.
21
+
22
+ ## What it is
23
+
24
+ The package declares these stored components:
25
+
26
+ | Component | Meaning |
27
+ | ------------------------------------------ | ----------------------------------------------------------------- |
28
+ | `decision{question, choices, recommended}` | A task asking for a listed or custom answer. |
29
+ | `task{}` | Identifies an entity as a task. |
30
+ | `blocked{on, since}` | Describes an external obstacle; `since` is declared server-owned. |
31
+ | `accept{body}` | Describes the conditions for completion. |
32
+ | `requires{}`, `contains{}` | Relation components on an `edge{from, to}` entity. |
33
+
34
+ `task.status` is computed from component presence; it is never stored. The first
35
+ mark the task wears, in the order its `status` ladder declares, wins:
36
+ `cancelled` means `cancelled`, otherwise `completed` means `done`, otherwise a
37
+ task is `open`. `completed{at, by, via}` and `cancelled{at, by, via, reason}`
38
+ are [@yaks/kernel](../kernel)'s marks, shared with anything that finishes or is
39
+ called off, so a graph of tasks loads the kernel's words beside these. An entity
40
+ without `task` has no task status. If both completion and cancellation are
41
+ present, cancellation takes precedence.
42
+
43
+ This package does not open or own storage. The graph's storage adapter keeps
44
+ these components, using memory, SQLite or another supported backend. References
45
+ from completion and cancellation records remain as history when the referenced
46
+ entity is deleted. `accept.body` is declared for blob storage; composing
47
+ [@yaks/blob](../blob) supplies that behavior.
48
+
49
+ Project, priority, domain and assignee are properties on `filed`, which belongs
50
+ to [@yaks/project](../project). That package also owns `board{query}`, a saved
51
+ query whose results determine board membership. Neither filing nor a board is
52
+ required to create a task.
53
+
54
+ ## Use
55
+
56
+ A **bundle** is one entity's components as a JSON object. A **batch** is a list
57
+ of bundles applied in one transaction. This complete example creates two tasks
58
+ and their dependency in an in-memory graph:
59
+
60
+ ```ts
61
+ import { loadVocab } from '@yaks/vocab'
62
+ import { graph } from '@yaks/graph'
63
+ import { ram } from '@yaks/ram'
64
+ import { kernel, kernelDoc, kernelKeywords } from '@yaks/kernel'
65
+ import { docDoc } from '@yaks/doc'
66
+ import { edgeDoc, edgeKeywords, edges, link } from '@yaks/edge'
67
+ import { openDeps, statusOf, taskDoc, tasks } from '@yaks/task'
68
+
69
+ let vocab = loadVocab([kernelDoc, docDoc, edgeDoc, taskDoc], [
70
+ kernelKeywords,
71
+ edgeKeywords,
72
+ ])
73
+ let g = graph({
74
+ storage: ram(vocab),
75
+ vocab,
76
+ plugins: [kernel(), edges(vocab), tasks()],
77
+ })
78
+
79
+ await g.apply([
80
+ { entity: { eid: 't1' }, task: {}, doc: { title: 'Buy the cake' } },
81
+ { entity: { eid: 't2' }, task: {}, doc: { title: 'Book the room' } },
82
+ link('t1', 'requires', 't2'),
83
+ ])
84
+ console.log(await openDeps(g, 't1')) // 1
85
+
86
+ await g.apply([{ entity: { eid: 't2' }, completed: {} }])
87
+ let [room] = await g.read('.completed')
88
+ console.log(statusOf(vocab, room)) // done
89
+ console.log(await openDeps(g, 't1')) // 0
90
+
91
+ await g.apply([{ entity: { eid: 't2' }, completed: null }]) // reopen
92
+ ```
93
+
94
+ Write `completed: {}` to finish a task. The graph fills the server-owned `at`,
95
+ `by` and `via` fields from its clock and the batch's `$actor`; an anonymous
96
+ write has no actor identity to record. Client-supplied values for those fields
97
+ are dropped. Trusted server writes may supply them. The `kernel()` plugin
98
+ preserves the original completion author when an existing completion is edited.
99
+ To attribute a new completion, supply an authenticated actor beside it:
100
+ `{ entity: { eid: 't2' }, completed: {}, $actor: { by: 'dana' } }`.
101
+
102
+ Code accepting remote requests must authenticate that identity and replace any
103
+ actor supplied by the client.
104
+
105
+ ## A plan is one list of bundles
106
+
107
+ Create related tasks together by putting their bundles and edge bundles in one
108
+ batch. An id beginning with `$` is a temporary alias resolved during `apply()`.
109
+ Give each new edge an alias too: the edge plugin derives its final id after
110
+ resolving its endpoints. Use `link()` only when the endpoint ids are already
111
+ known, because it computes the edge id immediately.
112
+
113
+ ```ts
114
+ import { loadVocab } from '@yaks/vocab'
115
+ import { graph } from '@yaks/graph'
116
+ import { ram } from '@yaks/ram'
117
+ import { kernelDoc, kernelKeywords } from '@yaks/kernel'
118
+ import { docDoc } from '@yaks/doc'
119
+ import { edgeDoc, edgeKeywords, edges } from '@yaks/edge'
120
+ import { taskDoc, tasks } from '@yaks/task'
121
+
122
+ let vocab = loadVocab([kernelDoc, docDoc, edgeDoc, taskDoc], [
123
+ kernelKeywords,
124
+ edgeKeywords,
125
+ ])
126
+ let g = graph({ storage: ram(vocab), vocab, plugins: [edges(vocab), tasks()] })
127
+
128
+ let plan = [
129
+ { entity: { eid: '$goal' }, task: {}, doc: { title: 'Organize the event' } },
130
+ { entity: { eid: '$step' }, task: {}, doc: { title: 'Choose the date' } },
131
+ {
132
+ entity: { eid: '$dependency' },
133
+ edge: { from: '$goal', to: '$step' },
134
+ requires: {},
135
+ },
136
+ ]
137
+
138
+ let preview = await g.apply(plan, { check: true })
139
+ let written = await g.apply(plan)
140
+ ```
141
+
142
+ A dry run returns the proposed bundles with resolved ids, then rolls back the
143
+ transaction. It runs admission, preconditions and rules, but keeps no entity or
144
+ journal writes and runs no post-commit effects. Invalid batches still fail. Ids
145
+ generated during a preview are not reserved for a later write. The HTTP form is
146
+ `POST /apply?check=1`; the CLI form is `yak graph apply --check`.
147
+
148
+ ## The status rule is written once
149
+
150
+ `task` declares its status in the vocabulary with the `status` keyword
151
+ ([@yaks/vocab](../vocab)): an ordered map from a mark to the status it gives.
152
+
153
+ ```json
154
+ "status": { "cancelled": "cancelled", "completed": "done", "started": "wip", "default": "open" }
155
+ ```
156
+
157
+ Every store reads `.task.status` from that declaration: @yaks/sql as a `case`
158
+ over the marks, @yaks/match off a bundle, so a saved filter selects the same
159
+ tasks in a database and in a page, and nothing has to be registered.
160
+ `statusOf(vocab, bundle)` reads it off an entity in hand:
161
+
162
+ ```ts
163
+ import { loadVocab } from '@yaks/vocab'
164
+ import { matcher } from '@yaks/match'
165
+ import { kernelDoc, kernelKeywords } from '@yaks/kernel'
166
+ import { statusOf, taskDoc } from '@yaks/task'
167
+
168
+ let vocab = loadVocab([kernelDoc, taskDoc], [kernelKeywords])
169
+ let tasks = [
170
+ { entity: { eid: 't1' }, task: {} },
171
+ { entity: { eid: 't2' }, task: {}, completed: {} },
172
+ ]
173
+ matcher('.task.status=open', vocab)(tasks) // t1 alone
174
+ statusOf(vocab, tasks[1]) // done
175
+ ```
176
+
177
+ `started` is a person saying they are on a task. Another package adds a rung
178
+ with an `extends` entry, appended after these. [@yaks/session](../session) reads
179
+ a held `claim` as `wip`:
180
+ `"task": {"component": true, "extends": true, "status": {"claim": "wip"}}`. A
181
+ claim, like `started`, marks work in progress, which is not completion:
182
+ `settled(status)` is true for `done` and `cancelled` alone.
183
+
184
+ `statusComps(vocab)` names what the status reads: `task` and the mark on every
185
+ rung, including those another package adds. A read naming only these answers the
186
+ status without the rest a task wears, which is how `done` and `openDeps` read:
187
+ `graph.get([eid], statusComps(vocab))`.
188
+
189
+ ## Blocked is not a status
190
+
191
+ `blocked{on}` describes an external obstacle independently of status. Adding it
192
+ to an open task leaves the task open. `gated(bundle)` tests for the component's
193
+ presence.
194
+
195
+ `openDeps(graph, eid, options?)` follows outgoing `requires` and `contains`
196
+ links and counts distinct direct endpoints that are unfinished. Cancelled and
197
+ completed tasks both count as settled. Missing endpoints and entities without
198
+ `task` remain counted. It does not recursively inspect descendants.
199
+
200
+ `done(graph, eid, options?)` returns true only when the entity is a settled task
201
+ and has no unfinished direct dependencies. Both read status through the graph's
202
+ vocabulary, and accept `{ relations }` to override the relation names. They
203
+ return values with synchronous storage and promises with asynchronous storage.
204
+ `dependencies(graph, eid, options?)` lists the same direct endpoints, settled or
205
+ not, and `dependents(graph, eid, options?)` walks the edges the other way: the
206
+ tasks that require or contain this one, which its finishing may free. A UI can
207
+ display the dependency count as "3 left" and omit zero; this package does not
208
+ render it.
209
+
210
+ ## Tools
211
+
212
+ `@yaks/task/tools` exports `runs()`, which supplies implementations for the tool
213
+ declarations in `taskDoc`. A server that loads these tools exposes them through
214
+ CLI or MCP:
215
+
216
+ ```sh
217
+ yak task new 'Buy the cake' --project P-1 --priority 1
218
+ yak task list '.filed.project=P-1&.filed.priority<3'
219
+ yak task update T-42 done
220
+ ```
221
+
222
+ | MCP name | Behavior |
223
+ | ------------- | -------------------------------------------------------------------- |
224
+ | `task_new` | Creates one task or an atomic plan with parent and dependency links. |
225
+ | `task_list` | Reads matching task bundles; it does not write them. |
226
+ | `task_update` | Updates one task or a batch, including body edits and filing fields. |
227
+
228
+ The tool runner commits results from the write tools. `done` adds `completed`
229
+ and removes `cancelled`; `cancelled` does the reverse; `open` removes both.
230
+ Omitted arguments leave existing values unchanged.
231
+
232
+ ### Create a task plan
233
+
234
+ Pass `tasks` to `task_new` to create related tasks in one transaction. Each row
235
+ has a title and can name a local `$id`. `parent` puts a `contains` link from the
236
+ parent to the task; `requires` puts links from the task to its prerequisites.
237
+ Both accept existing ids and local ids from the same call. Top-level fields
238
+ provide defaults that each row can override:
239
+
240
+ ```json
241
+ {
242
+ "project": "P-1",
243
+ "tasks": [
244
+ { "id": "$event", "title": "Organize the event" },
245
+ { "id": "$date", "title": "Choose the date", "parent": "$event" },
246
+ { "title": "Send invitations", "parent": "$event", "requires": ["$date"] }
247
+ ]
248
+ }
249
+ ```
250
+
251
+ The CLI takes the same array with
252
+ `yak task new --project P-1 --tasks
253
+ @tasks.json`. `check: true` (CLI `--check`)
254
+ previews the whole plan. The result includes resolved ids beside the local
255
+ aliases, ready for later calls.
256
+
257
+ ### Edit tasks
258
+
259
+ One `task_update` call can change `title`, `body`, `status`, filing fields,
260
+ `accept` (completion conditions), `blocked` (an external obstacle), and `reason`
261
+ (why the task is cancelled). `reason` is passed with `status: cancelled`; alone
262
+ it is refused, since only a status moves a task. `requires` adds a link from the
263
+ task to each prerequisite it waits for: `yak task update T-4 --requires T-3`.
264
+ Text, filing fields and `reason` accept `null` to clear the supplied field;
265
+ `accept: null` and `blocked: null` remove their components.
266
+
267
+ `edit` changes part of `doc.body` without sending the rest of the body back:
268
+
269
+ ```json
270
+ {
271
+ "task": "T-42",
272
+ "priority": 1,
273
+ "accept": "Invitations include the agreed date.",
274
+ "edit": { "find": "Friday", "replace": "Saturday" }
275
+ }
276
+ ```
277
+
278
+ `find` is literal and must match once unless `all: true` is supplied. Omit
279
+ `find` to replace the whole body with `replace`; `prepend` and `append` add text
280
+ before and after the result. The edit reads the stored body and adds a
281
+ compare-and-set guard automatically. A caller can pass `edit.was` from an
282
+ earlier read to require that version. A full `body` replacement accepts `was`
283
+ from `$was.doc.body` on `task_list` or `graph_show`.
284
+
285
+ ```sh
286
+ yak task update T-42 --edit '{"append":"\nInclude the venue address."}' --priority 1
287
+ yak task update T-42 --body @body.md --was <read-token>
288
+ yak task update T-42 cancelled --reason 'The event was called off.'
289
+ yak task update T-42 --clear blocked --clear priority
290
+ ```
291
+
292
+ `--clear` supplies JSON `null` for a nullable field. `--body null` and a body
293
+ file containing `null` preserve that literal text.
294
+
295
+ `updates` applies several task updates atomically. Its rows inherit shared
296
+ top-level fields, so this `task_update` call closes both tasks:
297
+
298
+ ```json
299
+ { "status": "done", "updates": [{ "task": "T-42" }, { "task": "T-43" }] }
300
+ ```
301
+
302
+ The CLI form is
303
+ `yak task update --status done --updates
304
+ '[{"task":"T-42"},{"task":"T-43"}]'`.
305
+ For text or arrays kept in a file, the CLI reads `@path` as that argument's
306
+ contents.
307
+
308
+ ### Listing and lookup
309
+
310
+ `task_list` always includes `.task`, combines it with the caller's query using
311
+ `&`, and defaults to `.task.status=open`. Every store reads that computed status
312
+ from the vocabulary, as described above.
313
+
314
+ The tools can write `doc` and `filed` without importing their packages because
315
+ bundles are plain data. Load `@yaks/doc` and `@yaks/project` to keep those
316
+ components: graph admission refuses a component the graph does not declare, and
317
+ an unknown property on a declared one, naming it.
318
+
319
+ Showing a complete entity uses the generic `graph_show` tool. Ranked search uses
320
+ `search` when the server supplies a search implementation. `task_new` files task
321
+ plans; [`graph_apply`](../graph/README.md#field-and-relationship-edits) edits
322
+ arbitrary components and adds or removes relationships. This package supplies no
323
+ separate show, search or tree tool.
324
+
325
+ ## Decisions
326
+
327
+ `decision{question, choices, recommended}` is a question on a task. `choices` is
328
+ two to four `{label, description}` values, and `recommended` is a listed label.
329
+ An answer is kernel’s `decided{choice, at, by, via}`: a listed label or custom
330
+ words, stamped as whoever answers. A transactional rule adds `completed` so
331
+ requiring work proceeds. Ordinary approval verdicts do not complete tasks.
332
+
333
+ ```sh
334
+ yak decision new 'Which route?' --choices '[{"label":"Train","description":"Arrive earlier"},{"label":"Bus","description":"Spend less"}]' --recommended Train --assignee <person>
335
+ yak decision answer T-42 Bus
336
+ yak decision answer T-42 'Walk together'
337
+ yak decision answer T-42 Bus --by Jeff
338
+ ```
339
+
340
+ Every door validates the ask and answer, including partial graph edits. Empty
341
+ answers, invalid recommendations, duplicate labels, and answers to cancelled or
342
+ already answered decisions refuse the transaction. Pass `by` to record a
343
+ person's explicit answer. The caller remains the writer for authorization and
344
+ the journal, while `decided.by` names that person and `decided.via` keeps the
345
+ calling session. `answer(eid, choice, by?)` gives interfaces the answer patch,
346
+ leaving stamps and lifecycle to the graph.
347
+
348
+ Blocking is derived only from incoming `requires` edges from unfinished work;
349
+ without one, a decision is eventual. `contains` never makes a decision blocking.
350
+ Filing and assignment use the same `filed` fields as other tasks. Nothing sends
351
+ mail as part of asking or answering.
352
+
353
+ ## The board guard
354
+
355
+ [@yaks/project](../project) validates saved board queries in a `precondition`
356
+ hook. It rejects unknown properties such as `.task.staus=open` and unsupported
357
+ status values such as `.task.status=complete`. A refusal rolls back the whole
358
+ batch. Writing `task.status` itself does not set status: graph admission drops
359
+ computed properties before that hook runs.
360
+
361
+ ## Integration
362
+
363
+ Use [@yaks/edge](../edge) for dependency relations, [@yaks/project](../project)
364
+ for filing and boards, and [@yaks/sql](../sql) or [@yaks/match](../match) for
365
+ status filtering. The task package supplies no database or transport. Its UI is
366
+ a portable [@yaks/render](../render) `Status` view in `@yaks/task/views`, which
367
+ draws the status its marks give in a browser or a terminal alike, and a task's
368
+ page in the inspector (@yaks/inspect): where it stands, what it asks, and the
369
+ comments on it. `DecisionForm` draws a question, choices, recommendation and
370
+ answer controls using the shared UI parts. Its host supplies the graph write
371
+ door, draft desk, reference names and the blocking classification. The web and
372
+ TUI use the same `<eid>.decision.answer` draft place; choosing a listed answer
373
+ keeps an unused custom draft. In the TUI, 1–4 choose, a types a custom answer,
374
+ Enter sends it and Escape leaves its draft.
375
+
376
+ ## Compatibility
377
+
378
+ Pure TypeScript with no platform API imports. It can run on Deno, Node, browsers
379
+ and Cloudflare Workers with suitable storage and package resolution.
380
+
381
+ ## Interface
382
+
383
+ | Import path | Exports |
384
+ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
385
+ | `@yaks/task` | `taskDoc`, `tasks`, `settled`, `statusOf`, `statusComps`, `gated`, `openDeps`, `dependencies`, `dependents`, `done`, `answer`; types `Choice`, `Decision`, `DepOpts`; constants `TASK`, `CANCELLED`, `BLOCKED`, `REQUIRES`, `CONTAINS`. |
386
+ | `@yaks/task/vocab` | `taskDoc` and `docs`. |
387
+ | `@yaks/task/graph` | `plugins()`, returning the task graph plugin in an array. |
388
+ | `@yaks/task/tools` | `runs()`, status patches in `marked`, and the query-building helper `listing()`. |
389
+ | `@yaks/task/form` | `DecisionForm`, `answerPlace` for a decision question and its answer. |
390
+ | `@yaks/task/views` | `views`: the `Status` renderer, the status read with `statusOf` through the vocabulary the view was chosen by; `inspectViews()`: loads a task's page in the inspector. |
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A decision's question, choices and answer, shared by browser and terminal.
3
+ * The question, labels and descriptions are Markdown. The last choice is
4
+ * always "Other": an answer of one's own, recorded as theirs, which takes
5
+ * several lines: Shift-Enter types a new one, and Enter or the button
6
+ * sends it, as in a chat box. A choice that shows entities (its `shows`
7
+ * edges, read with `showing` and grouped by `shown`) draws each over its
8
+ * button through the host's `show`, which draws them by their components.
9
+ */ import { type JSX, type ReactNode } from "@types/react";
10
+ import type { Bundle } from "@yaks/graph";
11
+ import type { Drafts } from "@yaks/draft";
12
+ import { type Shown } from "./decision.js";
13
+ /** Where a custom answer waits, across every interface. */ export declare let answerPlace: (eid: string) => string;
14
+ /** Domain controls; the host owns writes, drafts and reference names. */ export declare let DecisionForm: ({}: {
15
+ e: Bundle;
16
+ drafts: Drafts;
17
+ apply: (bundles: Bundle[]) => unknown;
18
+ name: (eid: string) => ReactNode;
19
+ shown?: Shown;
20
+ show?: (eid: string) => ReactNode;
21
+ blocking?: boolean;
22
+ caret?: number;
23
+ pending?: boolean;
24
+ }) => JSX.Element | null;
25
+ //# sourceMappingURL=DecisionForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DecisionForm.d.ts","sources":["../DecisionForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;CAQC,GACyC,SAGxC,KAAK,GAAG,EACR,KAAK,SAAS,uBAKS;AACzB,cAAc,MAAM,2BAAsC;AAC1D,cAAc,MAAM,2BAAgC;AAIpD,SAAgC,KAAK,KAAK,wBAAuB;AAEjE,yDAAyD,GACzD,OAAO,YAAI,cAAe,KAAK,MAAM,KAAG,MAAM,CAA4B;AAE1E,uEAAuE,GACvE,OAAO,YAAI,eACT;EACE,GAAG;EACH,QAAQ;EACR,QAAQ,SAAS,aAAa,OAAO;EACrC,OAAO,KAAK,MAAM,KAAK;EACvB,QAAQ;EACR,QAAQ,KAAK,MAAM,KAAK;EACxB,WAAW,OAAO;EAClB,QAAQ,MAAM;EACd,UAAU,OAAO;CAClB,KACA,IAAI,UAAU,IAAI,CAwKpB"}
@@ -0,0 +1,20 @@
1
+ import type { VocabDoc } from "@yaks/vocab";
2
+ /** The component that makes an entity a task. */ export declare let TASK: string;
3
+ /** The mark on a task that was called off. */ export declare let CANCELLED: string;
4
+ /** The component recording that something outside the graph is in the way. */ export declare let BLOCKED: string;
5
+ /** The relation from a task to work it waits for. */ export declare let REQUIRES: string;
6
+ /** The relation from a task to work that is part of it. */ export declare let CONTAINS: string;
7
+ /**
8
+ * The task vocabulary, to load beside your own:
9
+ * `loadVocab([taskDoc, ...mine], [edgeKeywords, ...])`. It declares nothing
10
+ * about what a person or a document is — bring your own `doc` (or
11
+ * {@link https://jsr.io/@yaks/doc | @yaks/doc}'s), and whatever else your tasks
12
+ * carry.
13
+ *
14
+ * `requires` and `contains` are declared through
15
+ * {@link https://jsr.io/@yaks/edge | @yaks/edge}'s `edge` keyword, so an
16
+ * edge entity carrying one of them states that link. Register `edgeKeywords`
17
+ * when you load, or the loader will carry the declaration with nobody reading
18
+ * it.
19
+ */ export declare let taskDoc: VocabDoc;
20
+ //# sourceMappingURL=comp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comp.d.ts","sources":["../comp.ts"],"names":[],"mappings":"AA6CA,cAAc,QAAQ,2BAAgC;AAGtD,+CAA+C,GAC/C,OAAO,YAAI,aAAa;AAExB,4CAA4C,GAC5C,OAAO,YAAI,kBAAuB;AAElC,4EAA4E,GAC5E,OAAO,YAAI,gBAAmB;AAE9B,mDAAmD,GACnD,OAAO,YAAI,iBAAqB;AAEhC,yDAAyD,GACzD,OAAO,YAAI,iBAAqB;AAEhC;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,SAAS,SAAc"}
@@ -0,0 +1,41 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import { type Built } from "@yaks/query";
3
+ /** A label and a line saying what choosing it means. */ export type Choice = {
4
+ label: string;
5
+ description: string;
6
+ };
7
+ /** The ask, read whole by every door. */ export type Decision = {
8
+ question: string;
9
+ choices: Choice[];
10
+ recommended: string;
11
+ };
12
+ /** What each choice presents, by label, in the order the decision shows them:
13
+ * read from its `shows` edges (`edge{from, to, ord}` + `shows{choice}`). */ export type Shown = Map<string, string[]>;
14
+ /** The query for a decision's `shows` edges. */ export declare let showing: (eid: string) => Built;
15
+ /** Each choice's shown entities, from the decision's `shows` edges. */ export declare let shown: (edges: Bundle[]) => Shown;
16
+ /** The query for the decisions waiting on `person`: assigned to them, and
17
+ * neither answered nor cancelled. */ export declare let waiting: (person: string) => Built;
18
+ /**
19
+ * The decisions in `rows` as one line each: its id (`id`, the eid where it
20
+ * gives none), its question and its choices' labels, the recommended one
21
+ * marked.
22
+ *
23
+ * ```ts
24
+ * import { asked } from '@yaks/task'
25
+ * import { equal } from '@yaks/testing'
26
+ *
27
+ * let row = {
28
+ * entity: { eid: 'e1' },
29
+ * decision: {
30
+ * question: 'Which cover?',
31
+ * choices: [{ label: 'Gothic' }, { label: 'Plain' }],
32
+ * recommended: 'Plain',
33
+ * },
34
+ * }
35
+ * equal(asked([row], () => 'T-4'), '- T-4: Which cover? "Gothic", "Plain" (recommended)')
36
+ * equal(asked([]), '')
37
+ * ```
38
+ */ export declare let asked: (rows: Bundle[], id?: (eid: string) => string | undefined) => string;
39
+ /** The answer a door writes, optionally recording another person's words. */ export declare let answer: (eid: string, choice: string, by?: string) => Bundle[];
40
+ /** A stale answer attempt can read the decision's settled state. */ export declare let DECISION_SETTLED: string;
41
+ //# sourceMappingURL=decision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.d.ts","sources":["../decision.ts"],"names":[],"mappings":"AAEA,cAAc,MAAM,2BAA4C;AAEhE,SAAS,KAAK,KAAK,2BAAsC;AAEzD,sDAAsD,GACtD,YAAY;EAAW,OAAO,MAAM;EAAE,aAAa,MAAM;;AACzD,uCAAuC,GACvC,YAAY;EACV,UAAU,MAAM;EAChB,SAAS;EACT,aAAa,MAAM;;AAGrB;0EAC0E,GAC1E,YAAY,QAAQ,IAAI,MAAM,EAAE,MAAM;AAEtC,8CAA8C,GAC9C,OAAO,YAAI,UAAW,KAAK,MAAM,KAAG,MAAuC;AAE3E,qEAAqE,GACrE,OAAO,YAAI,QAAS,OAAO,aAAW,MAYrC;AAkBD;mCACmC,GACnC,OAAO,YAAI,UAAW,QAAQ,MAAM,KAAG,MACwB;AAE/D;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,YAAI,QACT,MAAM,UACN,MAAK,KAAK,MAAM,KAAK,MAAM,GAAG,SAAS,KACtC,MAAM,CAUM;AAEf,2EAA2E,GAC3E,OAAO,YAAI,SAAU,KAAK,MAAM,EAAE,QAAQ,MAAM,EAAE,KAAK,MAAM,KAAG,SAI9D;AAEF,kEAAkE,GAClE,OAAO,YAAI,yBAAmE"}
@@ -0,0 +1,58 @@
1
+ import type { Bundle, Eid, Graph } from "@yaks/graph";
2
+ /**
3
+ * Is something outside the graph in the way? Reads the `blocked` component,
4
+ * which is never a status — a blocked task is still open work, and still shows
5
+ * up in every query for open work.
6
+ *
7
+ * ```ts
8
+ * import { gated } from '@yaks/task'
9
+ *
10
+ * gated({ entity: { eid: 't1' }, task: {}, blocked: { on: 'legal' } }) // true
11
+ * ```
12
+ */ export declare let gated: (b: Bundle) => boolean;
13
+ /** Which links count as work this task is waiting on. */ export type DepOpts = {
14
+ /** the relation tags to follow. Default: `requires` and `contains`. */ relations?: string[];
15
+ };
16
+ /**
17
+ * What this task waits on: the far ends of its `requires` and `contains`
18
+ * edges, settled or not.
19
+ *
20
+ * ```ts
21
+ * import { dependencies } from '@yaks/task'
22
+ *
23
+ * // dependencies(graph, 'p') // → ['a', 'b']
24
+ * ```
25
+ */ export declare let dependencies: ({}: Pick<Graph, 'storage'>, eid: Eid, opts?: DepOpts) => Eid[] | Promise<Eid[]>;
26
+ /**
27
+ * What waits on this task: the near ends of the `requires` and `contains`
28
+ * edges leading to it, the tasks its finishing may free.
29
+ *
30
+ * ```ts
31
+ * import { dependents } from '@yaks/task'
32
+ *
33
+ * // dependents(graph, 'a') // → ['p']
34
+ * ```
35
+ */ export declare let dependents: ({}: Pick<Graph, 'storage'>, eid: Eid, opts?: DepOpts) => Eid[] | Promise<Eid[]>;
36
+ /**
37
+ * How many of this task's children are still unfinished — the calm "3 left"
38
+ * count, never an alarm. Follows `requires` and `contains` out of the task and
39
+ * counts the far ends that have not settled; a child that is not a task cannot
40
+ * settle and so counts as open. Zero is the ordinary answer, and renders as
41
+ * nothing.
42
+ *
43
+ * ```ts
44
+ * import { openDeps } from '@yaks/task'
45
+ *
46
+ * // openDeps(graph, 't1') // → 2
47
+ * ```
48
+ */ export declare let openDeps: ({}: Pick<Graph, 'storage' | 'vocab'>, eid: Eid, opts?: DepOpts) => number | Promise<number>;
49
+ /**
50
+ * Has this task settled and finished its dependencies? Completion alone does
51
+ * not release a parent while `requires` or `contains` children remain open.
52
+ * Like {@link openDeps}, this counts direct far ends, not a recursive walk.
53
+ * A missing entity, or an entity without a `task` component, is never done.
54
+ *
55
+ * Synchronous storage returns a boolean; asynchronous storage returns a
56
+ * promise.
57
+ */ export declare let done: (held: Pick<Graph, 'storage' | 'vocab'>, eid: Eid, opts?: DepOpts) => boolean | Promise<boolean>;
58
+ //# sourceMappingURL=deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.d.ts","sources":["../deps.ts"],"names":[],"mappings":"AAwBA,cAAc,MAAM,EAAE,GAAG,EAAE,KAAK,2BAAoC;AAQpE;;;;;;;;;;CAUC,GACD,OAAO,YAAI,QAAS,GAAG,WAAS,OAAO,CAGtC;AAED,uDAAuD,GACvD,YAAY;EACV,qEAAqE,GACrE,YAAY,MAAM;;AA4BpB;;;;;;;;;CASC,GACD,OAAO,YAAI,eACT,IAAa,KAAK,OAAO,UAAU,EACnC,KAAK,KACL,OAAM,YACL,QAAQ,QAAQ,OAC2D;AAE9E;;;;;;;;;CASC,GACD,OAAO,YAAI,aACT,IAAa,KAAK,OAAO,UAAU,EACnC,KAAK,KACL,OAAM,YACL,QAAQ,QAAQ,OACyD;AAE5E;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,WACT,IAAoB,KAAK,OAAO,YAAY,QAAQ,EACpD,KAAK,KACL,OAAM,YACL,MAAM,GAAG,QAAQ,MAAM,EAazB;AAED;;;;;;;;CAQC,GACD,OAAO,YAAI,OACT,MAAM,KAAK,OAAO,YAAY,UAC9B,KAAK,KACL,OAAM,YACL,OAAO,GAAG,QAAQ,OAAO,EAIM"}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "@yaks/graph";
2
+ /** The task components. */ export declare let plugins: () => Plugin[];
3
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAKA,cAAc,MAAM,2BAAgC;AAGpD,yBAAyB,GACzB,OAAO,YAAI,eAAc,SAAqB"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @yaks/task — a to-do list as a set of components for a
3
+ * {@link https://jsr.io/@yaks/graph | @yaks/graph}.
4
+ *
5
+ * Say a team keeps a list of what it has to do. Four things come up, and this
6
+ * package is the four answers:
7
+ *
8
+ * - **What is on the list?** An entity with a `task{}` component is a to-do
9
+ * item. `task` is one component among the entity's others, not a record type
10
+ * of its own: the same entity also carries your `doc`, your `estimate`,
11
+ * anything else it is — adding `task` to something makes it something to do
12
+ * without making it stop being what it was. @yaks/project's optional
13
+ * `filed{project, priority, domain, assignee}` places it in a portfolio.
14
+ * - **Where does it stand?** No stored property holds the answer. A task with a
15
+ * `completed` component (@yaks/kernel's mark) is done, one with `cancelled`
16
+ * is cancelled, one with `started` is wip, and one with none is open. `status` is computed from
17
+ * those components, so finishing something records when and by whom instead
18
+ * of overwriting a value, and reopening it means removing a component rather
19
+ * than guessing what the status used to be.
20
+ * - **How do you look at the list?** A `board{query}` is a saved filter. Its
21
+ * membership is never stored — no row records that a task is on a board — so
22
+ * a board is always current, and a task that starts matching the query is on
23
+ * it. The empty query selects nothing, on purpose.
24
+ * - **What is it waiting for?** `requires` and `contains` relate one task to
25
+ * another through {@link https://jsr.io/@yaks/edge | @yaks/edge}, and
26
+ * `blocked{on}` records that something outside the graph is in the way.
27
+ *
28
+ * ## Blocked is not a status
29
+ * There is no `blocked` status, and that is a decision rather than an omission.
30
+ * A blocked task is still open work: rolling it into the status would hide it
31
+ * from every query for open work exactly when somebody needs to see it. So
32
+ * `blocked` is a component read by {@link gated}, and unfinished children are
33
+ * an ordinary count read by {@link openDeps} — "3 left", never an alarm.
34
+ *
35
+ * ## The status rule is written once
36
+ * The rule is data in the vocabulary: `task` declares its status as a ladder
37
+ * of marks (`"status": {"cancelled": "cancelled", "completed": "done",
38
+ * "started": "wip", "default": "open"}`, @yaks/vocab's `status` keyword). @yaks/sql and
39
+ * @yaks/match read it from that declaration, so a saved filter selects the
40
+ * same tasks in a database and in a page, and {@link statusOf} reads it off an
41
+ * entity in hand. A graph that leases its tasks adds a rung where it declares
42
+ * the lease: @yaks/session reads a held claim as `wip`.
43
+ *
44
+ * ## Use
45
+ * ```ts
46
+ * import { loadVocab } from '@yaks/vocab'
47
+ * import { graph } from '@yaks/graph'
48
+ * import { ram } from '@yaks/ram'
49
+ * import { kernel, kernelDoc, kernelKeywords } from '@yaks/kernel'
50
+ * import { edgeDoc, edgeKeywords, edges } from '@yaks/edge'
51
+ * import { taskDoc, tasks } from '@yaks/task'
52
+ *
53
+ * let vocab = loadVocab([kernelDoc, edgeDoc, taskDoc], [
54
+ * kernelKeywords,
55
+ * edgeKeywords,
56
+ * ])
57
+ * let plugins = [kernel(), edges(vocab), tasks()]
58
+ * let g = graph({ storage: ram(vocab), vocab, plugins })
59
+ * await g.apply([{ entity: { eid: 't1' }, task: {}, completed: {} }])
60
+ * ```
61
+ *
62
+ * It imports no platform API, so the same list runs on a server, in a worker,
63
+ * and in a browser tab.
64
+ *
65
+ * @module
66
+ */ export * from "./words.js";
67
+ export * from "./comp.js";
68
+ export * from "./deps.js";
69
+ export * from "./plugin.js";
70
+ export { answer, asked, type Choice, type Decision, DECISION_SETTLED, showing, type Shown, shown, waiting } from "./decision.js";
71
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEC,GAED,2BAA0B;AAC1B,0BAAyB;AACzB,0BAAyB;AACzB,4BAA2B;AAE3B,SACE,MAAM,EACN,KAAK,EACL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,gBAAgB,EAChB,OAAO,EACP,KAAK,KAAK,EACV,KAAK,EACL,OAAO,wBACa"}