@joe-broadhead/opencode-mem 0.8.5 → 0.9.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/CHANGELOG.md +429 -0
- package/README.md +114 -61
- package/docs/agent-protocol.md +67 -177
- package/package.json +1351 -98
- package/skills/mem.pages/SKILL.md +143 -0
- package/skills/mem.sharing/SKILL.md +82 -0
- package/skills/mem.sources/SKILL.md +93 -0
- package/skills/mem.usage/SKILL.md +118 -492
- package/src/backend/records.js +285 -0
- package/src/bootstrap.js +49 -45
- package/src/call-shapes.js +41 -10
- package/src/collector-lock.js +162 -0
- package/src/collector-service.js +441 -0
- package/src/collector.js +381 -0
- package/src/commands.js +3 -3
- package/src/config.js +12 -1
- package/src/curation.js +1 -1
- package/src/permissions.js +18 -2
- package/src/protocol.js +29 -20
- package/src/recall.js +104 -27
- package/src/records-store.js +280 -120
- package/src/records.js +63 -11
- package/src/runtime.js +23 -14
- package/src/skills.js +44 -18
- package/src/sources.js +58 -0
- package/src/spaces.js +93 -10
- package/src/tools/aliases.js +163 -0
- package/src/tools/commitments.js +12 -9
- package/src/tools/index.js +88 -19
- package/src/tools/ingest.js +277 -0
- package/src/tools/knowledge.js +6 -1
- package/src/tools/memory.js +640 -210
- package/src/tools/page.js +411 -0
- package/src/tools/recall.js +363 -112
- package/src/tools/records-kit.js +142 -0
- package/src/tools/share.js +1012 -0
- package/src/tools/shared.js +8 -1
- package/src/tools/spaces.js +431 -143
- package/src/tools/status.js +87 -58
- package/src/tools/wiki.js +2 -2
- package/src/views/contracts.js +273 -3
- package/src/views/records-reads.js +675 -0
- package/src/views/rpc.js +17 -100
- package/src/views/shape.js +61 -0
- package/views/commitments.html +4 -0
- package/views/graph.html +753 -0
- package/views/home.html +11 -5
- package/views/journal.html +621 -0
- package/views/memory.html +7 -1
- package/views/pages.html +636 -0
- package/views/review.html +406 -0
- package/views/today.html +309 -0
package/src/tools/status.js
CHANGED
|
@@ -1,65 +1,94 @@
|
|
|
1
|
-
import { describeBootstrap, describeSpool, errorMessage, oneLine } from "../util.js"
|
|
1
|
+
import { describeBootstrap, describeSpool, errorMessage, isPlainObject, oneLine } from "../util.js"
|
|
2
|
+
import { recordsFailure, recordsOf } from "./share.js"
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* The health report `mem_spaces` (`"action": "health"`) gives, and the
|
|
6
|
+
* deprecated `mem_status` alias with it: backend health, active scope,
|
|
7
|
+
* per-layer counts (L0-L3), skills, knowledge assets, queued captures, then the
|
|
8
|
+
* records service's counts for the space (`space.stats`) and the collector.
|
|
5
9
|
*
|
|
6
|
-
* @param {any} editor
|
|
7
10
|
* @param {ReturnType<import("./shared.js").createToolkit>} toolkit
|
|
11
|
+
* @returns {Promise<{ text: string } | { failure: string }>}
|
|
8
12
|
*/
|
|
9
|
-
export function
|
|
10
|
-
const
|
|
13
|
+
export async function renderHealth(toolkit, input, context) {
|
|
14
|
+
const resolved = await toolkit.resolveSpace(input, context)
|
|
15
|
+
if (resolved.error) return { failure: resolved.error }
|
|
16
|
+
const spaceContext = resolved.context
|
|
17
|
+
let status
|
|
18
|
+
try {
|
|
19
|
+
status = await toolkit.runtime.status({
|
|
20
|
+
sessionID: input?.space ? undefined : context?.sessionID,
|
|
21
|
+
agent: context?.agent,
|
|
22
|
+
context: spaceContext,
|
|
23
|
+
})
|
|
24
|
+
} catch (error) {
|
|
25
|
+
return { failure: errorMessage(error) }
|
|
26
|
+
}
|
|
27
|
+
const lines = [
|
|
28
|
+
`backend: ${status.health}`,
|
|
29
|
+
`scope: ${status.scope}`,
|
|
30
|
+
`capture: ${status.capture}`,
|
|
31
|
+
`credential: ${status.credential}`,
|
|
32
|
+
]
|
|
33
|
+
if (status.space) {
|
|
34
|
+
const kind = status.spaceKind && status.spaceKind !== "unknown" ? ` [${status.spaceKind}]` : ""
|
|
35
|
+
const name = status.spaceName ? ` ${oneLine(status.spaceName, 120)}` : ""
|
|
36
|
+
lines.splice(2, 0, `space: ${oneLine(status.space, 80)}${kind}${name}`)
|
|
37
|
+
if (status.collection) lines.splice(3, 0, `collection: ${oneLine(status.collection, 120)}`)
|
|
38
|
+
}
|
|
39
|
+
lines.push(
|
|
40
|
+
`L0 conversations: ${status.layers.l0 ?? "?"}`,
|
|
41
|
+
`L1 atoms: ${status.layers.l1 ?? "?"}`,
|
|
42
|
+
`L2 scenarios: ${status.layers.l2 ?? "?"}`,
|
|
43
|
+
`L3 persona: ${status.layers.l3 ? "present" : "empty"}`,
|
|
44
|
+
`skills: ${status.layers.skills ?? "?"}`,
|
|
45
|
+
`source spaces: ${status.sourceSpaces}`,
|
|
46
|
+
`mirrored skills: ${status.mirroredSkills}`,
|
|
47
|
+
`knowledge assets: ${status.layers.knowledge ?? "?"}`,
|
|
48
|
+
`pinned sessions: ${status.pinned}`,
|
|
49
|
+
`bootstrap: ${describeBootstrap(status.bootstrap)}`,
|
|
50
|
+
`spooled captures: ${describeSpool(status.spool)}`,
|
|
51
|
+
)
|
|
52
|
+
lines.push(...(await recordsLines(toolkit, input, context, spaceContext)))
|
|
53
|
+
if (toolkit.collector) lines.push(toolkit.collector.describe())
|
|
54
|
+
return { text: lines.join("\n") }
|
|
55
|
+
}
|
|
11
56
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`L2 scenarios: ${status.layers.l2 ?? "?"}`,
|
|
50
|
-
`L3 persona: ${status.layers.l3 ? "present" : "empty"}`,
|
|
51
|
-
`skills: ${status.layers.skills ?? "?"}`,
|
|
52
|
-
`source spaces: ${status.sourceSpaces}`,
|
|
53
|
-
`mirrored skills: ${status.mirroredSkills}`,
|
|
54
|
-
`knowledge assets: ${status.layers.knowledge ?? "?"}`,
|
|
55
|
-
`pinned sessions: ${status.pinned}`,
|
|
56
|
-
`bootstrap: ${describeBootstrap(status.bootstrap)}`,
|
|
57
|
-
`spooled captures: ${describeSpool(status.spool)}`,
|
|
58
|
-
)
|
|
59
|
-
return text(lines.join("\n"))
|
|
60
|
-
} catch (error) {
|
|
61
|
-
return fail(errorMessage(error))
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
})
|
|
57
|
+
/** The records service's counts for the space, or why they are missing. */
|
|
58
|
+
async function recordsLines(toolkit, input, context, spaceContext) {
|
|
59
|
+
const records = recordsOf(toolkit)
|
|
60
|
+
if (!records) return ["records: not available in this plugin build"]
|
|
61
|
+
const where = spaceContext?.space_id ? (input?.space ? { space: spaceContext.space_id } : { sessionID: context?.sessionID, space: spaceContext.space_id }) : { sessionID: context?.sessionID }
|
|
62
|
+
let stats
|
|
63
|
+
try {
|
|
64
|
+
stats = await records.call("space.stats", {}, where)
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return [`records: unavailable (${oneLine(recordsFailure(error), 240)})`]
|
|
67
|
+
}
|
|
68
|
+
// `space.stats` (contract §2.4): `records: {total, by_kind: {kind: {status: n}}}`,
|
|
69
|
+
// `events: {total, by_source}`, `sources: {total, confirmed, pending, enabled}`, `last_runs`.
|
|
70
|
+
const lines = []
|
|
71
|
+
const byKind = isPlainObject(stats?.records?.by_kind) ? stats.records.by_kind : {}
|
|
72
|
+
const kinds = new Map()
|
|
73
|
+
const statuses = new Map()
|
|
74
|
+
for (const [kind, byStatus] of Object.entries(byKind)) {
|
|
75
|
+
for (const [status, count] of Object.entries(isPlainObject(byStatus) ? byStatus : {})) {
|
|
76
|
+
const n = Number(count) || 0
|
|
77
|
+
kinds.set(kind, (kinds.get(kind) ?? 0) + n)
|
|
78
|
+
statuses.set(status, (statuses.get(status) ?? 0) + n)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const counts = (map) => [...map].map(([key, count]) => `${oneLine(key, 40)} ${count}`).join(", ")
|
|
82
|
+
lines.push(`records: ${counts(kinds) || "none"}`)
|
|
83
|
+
if (statuses.size > 0) lines.push(`records by status: ${counts(statuses)}`)
|
|
84
|
+
if (isPlainObject(stats?.events)) lines.push(`events: ${Number(stats.events.total) || 0}`)
|
|
85
|
+
if (isPlainObject(stats?.sources)) {
|
|
86
|
+
const sources = stats.sources
|
|
87
|
+
lines.push(`sources: ${Number(sources.total) || 0} (${Number(sources.confirmed) || 0} confirmed, ${Number(sources.pending) || 0} pending)`)
|
|
88
|
+
}
|
|
89
|
+
const runs = Array.isArray(stats?.last_runs) ? stats.last_runs : []
|
|
90
|
+
for (const run of runs.slice(0, 5)) {
|
|
91
|
+
lines.push(`routine ${oneLine(run?.routine ?? "?", 20)}: ${oneLine(run?.status ?? "?", 20)} ${oneLine(run?.date ?? run?.ended ?? run?.started ?? "", 40)}${run?.error ? ` (${oneLine(run.error, 120)})` : ""}`)
|
|
92
|
+
}
|
|
93
|
+
return lines
|
|
65
94
|
}
|
package/src/tools/wiki.js
CHANGED
|
@@ -597,7 +597,7 @@ export function registerWiki(editor, toolkit) {
|
|
|
597
597
|
editor.add({
|
|
598
598
|
name: "wiki",
|
|
599
599
|
description:
|
|
600
|
-
"
|
|
600
|
+
"Call list, search and read for documentation, architecture, ownership and call-graph questions about what was uploaded or indexed. Write only documents the person gave you, as flat source files (\"notes.md\"; a name with a folder is refused). A space has a knowledge wiki only once action create makes one (name it \"My knowledge\" in the personal space); list shows which wikis exist. A write starts an ingest that locks the wiki for a few minutes: to write several files, pass ingest: false on each and ingest: true on the last. Like mem_recall it uses the session's space by default: your personal space, or a shared space bound to the session. A write to a shared space asks the person and shows the file and an excerpt; a write to your personal space does not. delete removes one source file (filename), one generated page (ref), or a whole wiki (wiki_id alone): without confirm it only previews; with confirm: true it always asks the person, then deletes and reads it back. Never put things to do (mem_commitments), where a project stands, or person and project pages (mem_page) here.",
|
|
601
601
|
input: {
|
|
602
602
|
type: "object",
|
|
603
603
|
properties: {
|
|
@@ -625,7 +625,7 @@ export function registerWiki(editor, toolkit) {
|
|
|
625
625
|
content: {
|
|
626
626
|
type: "string",
|
|
627
627
|
description:
|
|
628
|
-
"Markdown for create, write (replaces the file), or append
|
|
628
|
+
"Markdown for create, write (replaces the file), or append: a document the person gave you. Person, project, decision and runbook pages go in mem_page; things to do go in mem_commitments",
|
|
629
629
|
},
|
|
630
630
|
ingest: {
|
|
631
631
|
type: "boolean",
|
package/src/views/contracts.js
CHANGED
|
@@ -10,8 +10,14 @@
|
|
|
10
10
|
* before the plugin sees it, so every method reads under the permission of the
|
|
11
11
|
* tool that makes the same read: the overview under `mem_status`, the space
|
|
12
12
|
* list under `mem_spaces`, recent memories under `mem_recall`, the wiki under
|
|
13
|
-
* `mem_wiki`, commitments under `mem_commitments
|
|
14
|
-
*
|
|
13
|
+
* `mem_wiki`, commitments under `mem_commitments`, and (0.9) journals, pages,
|
|
14
|
+
* history and the graph under `mem_page`, proposals awaiting review under
|
|
15
|
+
* `mem_spaces` (its `review` action). None of them writes: a write starts as a
|
|
16
|
+
* message the person sends (`open-agent`), and the agent's tool runs under the
|
|
17
|
+
* person's rules. That includes a review decision: Jelly lets a view call only
|
|
18
|
+
* read-only methods (its `viewIssues`, and its host route), and a view call
|
|
19
|
+
* carries no session the plugin could ask `memory.revise` in, so the Review
|
|
20
|
+
* view starts the message and `mem_spaces` (`review`, `decide`) asks.
|
|
15
21
|
*
|
|
16
22
|
* The schemas are JSON Schema documents Jelly reads as data, checked on every
|
|
17
23
|
* call both ways (input and answer), each at most 16 KB. They use no
|
|
@@ -38,7 +44,7 @@ export const ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$"
|
|
|
38
44
|
*/
|
|
39
45
|
export const RECENT_PAGE = 50
|
|
40
46
|
export const RECENT_MAX_OFFSET = 50
|
|
41
|
-
/** Characters of one memory a view is given; the tool reads the rest. */
|
|
47
|
+
/** Characters of one memory (a record of kind `memory`) a view is given; the tool reads the rest. */
|
|
42
48
|
export const MEMORY_TEXT_CHARS = 600
|
|
43
49
|
/** Characters of one wiki page a view is given. */
|
|
44
50
|
export const PAGE_TEXT_CHARS = 48_000
|
|
@@ -47,6 +53,39 @@ export const LIST_MAX = 100
|
|
|
47
53
|
/** The most commitments one answer lists (the Home card shows fewer). */
|
|
48
54
|
export const COMMITMENTS_MAX = 100
|
|
49
55
|
|
|
56
|
+
/** Journal pages one answer lists, newest first. */
|
|
57
|
+
export const JOURNAL_MAX = 100
|
|
58
|
+
/** Characters of a journal's summary line. */
|
|
59
|
+
export const SUMMARY_CHARS = 300
|
|
60
|
+
/** Characters of a record's body a view is given (journal, page). */
|
|
61
|
+
export const RECORD_BODY_CHARS = 40_000
|
|
62
|
+
/** A journal's sources one answer carries, for its citation chips. */
|
|
63
|
+
export const JOURNAL_SOURCES_MAX = 200
|
|
64
|
+
/** Proposals one Review answer lists. */
|
|
65
|
+
export const REVIEW_MAX = 20
|
|
66
|
+
/** Evidence quotes shown per proposal. */
|
|
67
|
+
export const EVIDENCE_MAX = 3
|
|
68
|
+
/** Pages one Pages answer lists, and the folders it names. */
|
|
69
|
+
export const PAGES_MAX = 150
|
|
70
|
+
export const FOLDERS_MAX = 50
|
|
71
|
+
/** A page's fields, outlinks and backlinks one answer carries. */
|
|
72
|
+
export const FIELDS_MAX = 24
|
|
73
|
+
export const LINKS_MAX = 50
|
|
74
|
+
/** Versions and lineage one history answer lists. */
|
|
75
|
+
export const HISTORY_MAX = 50
|
|
76
|
+
export const LINEAGE_MAX = 20
|
|
77
|
+
/** The graph's caps: nodes (the records service's own cap) and edges. */
|
|
78
|
+
export const GRAPH_NODES_MAX = 200
|
|
79
|
+
export const GRAPH_EDGES_MAX = 600
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* What every view says, as one plain line, when the server has no records
|
|
83
|
+
* service (503 `records_unavailable`): memories, commitments, journals, pages
|
|
84
|
+
* and review all live there from 0.9. The pages show it as it is.
|
|
85
|
+
*/
|
|
86
|
+
export const RECORDS_OFF =
|
|
87
|
+
"This Memory server has no records service yet, so memories, journals, pages and review can't be shown. Ask whoever runs it to turn it on."
|
|
88
|
+
|
|
50
89
|
/** The input property a Jelly host of contract v1.5 or later fills with the caller's speaker id. */
|
|
51
90
|
export const SPEAKER_FIELD = "jellySpeaker"
|
|
52
91
|
|
|
@@ -95,6 +134,8 @@ const overviewOutput = {
|
|
|
95
134
|
/** Capture as this engine runs it now: the declared setting, read at start. */
|
|
96
135
|
capture: { type: "boolean" },
|
|
97
136
|
health: { type: "string", enum: ["ok", "unreachable", "unknown"] },
|
|
137
|
+
/** Whether the records service answers (memories are records from 0.9); "unavailable" says the page shows `RECORDS_OFF`. */
|
|
138
|
+
records: { type: "string", enum: ["ok", "unavailable"] },
|
|
98
139
|
space,
|
|
99
140
|
counts: {
|
|
100
141
|
type: "object",
|
|
@@ -242,6 +283,186 @@ const commitmentsOutput = {
|
|
|
242
283
|
},
|
|
243
284
|
}
|
|
244
285
|
|
|
286
|
+
/* ---------------------------------------------------------------- records (0.9) */
|
|
287
|
+
|
|
288
|
+
const integer = { type: "integer", minimum: 0 }
|
|
289
|
+
const flag = { type: "boolean" }
|
|
290
|
+
const list = (items, max) => ({ type: "array", maxItems: max, items })
|
|
291
|
+
const object = (properties, required = Object.keys(properties)) => ({
|
|
292
|
+
type: "object",
|
|
293
|
+
additionalProperties: false,
|
|
294
|
+
required,
|
|
295
|
+
properties,
|
|
296
|
+
})
|
|
297
|
+
/** A space the person chose from `spaces.list`; omitted, their personal space. */
|
|
298
|
+
const spaceInput = { space: id }
|
|
299
|
+
const period = { type: "string", enum: ["day", "week", "month"] }
|
|
300
|
+
|
|
301
|
+
const journalListInput = viewInput({ ...spaceInput, period })
|
|
302
|
+
|
|
303
|
+
const journalListOutput = object({
|
|
304
|
+
space,
|
|
305
|
+
items: list(
|
|
306
|
+
object({
|
|
307
|
+
path: id,
|
|
308
|
+
title: line(200),
|
|
309
|
+
period,
|
|
310
|
+
/** The day the page covers, YYYY-MM-DD (a week's Monday, a month's first). */
|
|
311
|
+
date: line(40),
|
|
312
|
+
/** Whether a person edited it: the routine leaves it alone then. */
|
|
313
|
+
edited: flag,
|
|
314
|
+
summary: line(SUMMARY_CHARS),
|
|
315
|
+
updated: line(40),
|
|
316
|
+
}),
|
|
317
|
+
JOURNAL_MAX,
|
|
318
|
+
),
|
|
319
|
+
more: flag,
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
const journalReadOutput = object(
|
|
323
|
+
{
|
|
324
|
+
space,
|
|
325
|
+
path: id,
|
|
326
|
+
title: line(200),
|
|
327
|
+
period,
|
|
328
|
+
date: line(40),
|
|
329
|
+
edited: flag,
|
|
330
|
+
updated: line(40),
|
|
331
|
+
/** Markdown without its Sources section and footer, which come apart. */
|
|
332
|
+
body: line(RECORD_BODY_CHARS),
|
|
333
|
+
clipped: flag,
|
|
334
|
+
/** The journal's cited sources, for the chips: an event's title and address, a turn's source. */
|
|
335
|
+
sources: list(
|
|
336
|
+
object({
|
|
337
|
+
ref: id,
|
|
338
|
+
kind: { type: "string", enum: ["event", "turn"] },
|
|
339
|
+
source: line(40),
|
|
340
|
+
title: line(160),
|
|
341
|
+
url: line(300),
|
|
342
|
+
}),
|
|
343
|
+
JOURNAL_SOURCES_MAX,
|
|
344
|
+
),
|
|
345
|
+
footer: object(
|
|
346
|
+
{
|
|
347
|
+
routine: line(40),
|
|
348
|
+
counts: list(object({ source: line(40), count: integer }), 20),
|
|
349
|
+
tokens: integer,
|
|
350
|
+
budget: integer,
|
|
351
|
+
line: line(600),
|
|
352
|
+
},
|
|
353
|
+
["routine", "counts", "line"],
|
|
354
|
+
),
|
|
355
|
+
},
|
|
356
|
+
["space", "path", "title", "period", "date", "edited", "updated", "body", "clipped", "sources", "footer"],
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
const reviewListOutput = object({
|
|
360
|
+
space,
|
|
361
|
+
items: list(
|
|
362
|
+
object(
|
|
363
|
+
{
|
|
364
|
+
id,
|
|
365
|
+
/** create, append, supersede, merge, close_commitment, open_commitment, share. */
|
|
366
|
+
action: line(40),
|
|
367
|
+
title: line(200),
|
|
368
|
+
/** The record or page it changes, when it changes one. */
|
|
369
|
+
target: line(200),
|
|
370
|
+
reason: line(300),
|
|
371
|
+
stated_by: { type: "string", enum: ["person", "agent", "inferred", "external", "unknown"] },
|
|
372
|
+
/** Whether the words came from someone other than the person: the page labels it. */
|
|
373
|
+
external: flag,
|
|
374
|
+
evidence: list(
|
|
375
|
+
object({ kind: { type: "string", enum: ["event", "turn", "record"] }, ref: id, quote: line(300) }),
|
|
376
|
+
EVIDENCE_MAX,
|
|
377
|
+
),
|
|
378
|
+
/** The text accepting it would apply; the Edit box starts from it. */
|
|
379
|
+
proposed: line(600),
|
|
380
|
+
expires: line(40),
|
|
381
|
+
created: line(40),
|
|
382
|
+
},
|
|
383
|
+
["id", "action", "title", "target", "reason", "stated_by", "external", "evidence", "proposed", "expires", "created"],
|
|
384
|
+
),
|
|
385
|
+
REVIEW_MAX,
|
|
386
|
+
),
|
|
387
|
+
more: flag,
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
const pagesListOutput = object({
|
|
391
|
+
space,
|
|
392
|
+
/** The folder listed, "" for the top. */
|
|
393
|
+
folder: line(64),
|
|
394
|
+
folders: list(object({ name: line(64), count: integer }), FOLDERS_MAX),
|
|
395
|
+
pages: list(object({ path: id, title: line(200), type: line(40), updated: line(40) }), PAGES_MAX),
|
|
396
|
+
more: flag,
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
const pageRef = { ...spaceInput, path: id, id }
|
|
400
|
+
|
|
401
|
+
const pagesReadOutput = object({
|
|
402
|
+
space,
|
|
403
|
+
id,
|
|
404
|
+
path: line(200),
|
|
405
|
+
kind: line(20),
|
|
406
|
+
type: line(40),
|
|
407
|
+
title: line(200),
|
|
408
|
+
status: line(20),
|
|
409
|
+
stated_by: line(20),
|
|
410
|
+
updated: line(40),
|
|
411
|
+
version: integer,
|
|
412
|
+
fields: list(object({ name: line(40), value: line(300) }), FIELDS_MAX),
|
|
413
|
+
body: line(RECORD_BODY_CHARS),
|
|
414
|
+
clipped: flag,
|
|
415
|
+
/** Each `[[link]]` of the body: its target, and the record it names when there is one. */
|
|
416
|
+
outlinks: list(object({ target: line(200), title: line(200), exists: flag }), LINKS_MAX),
|
|
417
|
+
backlinks: list(object({ id, path: line(200), title: line(200), type: line(40) }), LINKS_MAX),
|
|
418
|
+
backlinksMore: flag,
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
const lineageItem = object({ id, title: line(200), status: line(20) })
|
|
422
|
+
|
|
423
|
+
const pagesHistoryOutput = object({
|
|
424
|
+
id,
|
|
425
|
+
versions: list(
|
|
426
|
+
object({ version: integer, updated: line(40), title: line(200), status: line(20), change: line(200) }),
|
|
427
|
+
HISTORY_MAX,
|
|
428
|
+
),
|
|
429
|
+
supersedes: list(lineageItem, LINEAGE_MAX),
|
|
430
|
+
supersededBy: list(lineageItem, LINEAGE_MAX),
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
const graphInput = viewInput({
|
|
434
|
+
...pageRef,
|
|
435
|
+
depth: { type: "integer", minimum: 1, maximum: 2 },
|
|
436
|
+
max: { type: "integer", minimum: 10, maximum: GRAPH_NODES_MAX },
|
|
437
|
+
/** Record types to keep (person, project, decision, …); empty keeps every type. */
|
|
438
|
+
types: list(line(40), 20),
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
const graphOutput = object({
|
|
442
|
+
space,
|
|
443
|
+
/** The index in `nodes` of the record the neighbourhood is around. */
|
|
444
|
+
start: integer,
|
|
445
|
+
nodes: list(
|
|
446
|
+
object({
|
|
447
|
+
/** The record id; "" for a dangling link or a cited source. */
|
|
448
|
+
id: line(200),
|
|
449
|
+
path: line(200),
|
|
450
|
+
title: line(80),
|
|
451
|
+
/** memory, page, commitment, proposal; event or turn for a cited source; "" when dangling. */
|
|
452
|
+
kind: line(20),
|
|
453
|
+
type: line(40),
|
|
454
|
+
dangling: flag,
|
|
455
|
+
}),
|
|
456
|
+
GRAPH_NODES_MAX,
|
|
457
|
+
),
|
|
458
|
+
/** Edges by node index. */
|
|
459
|
+
edges: list(
|
|
460
|
+
object({ from: integer, to: integer, type: { type: "string", enum: ["link", "supersedes", "source"] } }),
|
|
461
|
+
GRAPH_EDGES_MAX,
|
|
462
|
+
),
|
|
463
|
+
truncated: flag,
|
|
464
|
+
})
|
|
465
|
+
|
|
245
466
|
/**
|
|
246
467
|
* The methods, in the order `package.json` declares them.
|
|
247
468
|
* @type {ReadonlyArray<{ name: string, label: string, permission: string, input: object, output: object }>}
|
|
@@ -284,6 +505,55 @@ export const VIEW_METHODS = Object.freeze([
|
|
|
284
505
|
input: commitmentsInput,
|
|
285
506
|
output: commitmentsOutput,
|
|
286
507
|
},
|
|
508
|
+
{
|
|
509
|
+
name: "journal.list",
|
|
510
|
+
label: "list your journal pages",
|
|
511
|
+
permission: "mem_page",
|
|
512
|
+
input: journalListInput,
|
|
513
|
+
output: journalListOutput,
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: "journal.read",
|
|
517
|
+
label: "read a journal page",
|
|
518
|
+
permission: "mem_page",
|
|
519
|
+
input: viewInput({ ...spaceInput, path: id }, ["path"]),
|
|
520
|
+
output: journalReadOutput,
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
name: "review.list",
|
|
524
|
+
label: "list what waits for your review",
|
|
525
|
+
permission: "mem_spaces",
|
|
526
|
+
input: viewInput(spaceInput),
|
|
527
|
+
output: reviewListOutput,
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: "pages.list",
|
|
531
|
+
label: "list your pages by folder",
|
|
532
|
+
permission: "mem_page",
|
|
533
|
+
input: viewInput({ ...spaceInput, folder: line(64) }),
|
|
534
|
+
output: pagesListOutput,
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
name: "pages.read",
|
|
538
|
+
label: "read a page or memory, with its links",
|
|
539
|
+
permission: "mem_page",
|
|
540
|
+
input: viewInput(pageRef),
|
|
541
|
+
output: pagesReadOutput,
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
name: "pages.history",
|
|
545
|
+
label: "read a page's history",
|
|
546
|
+
permission: "mem_page",
|
|
547
|
+
input: viewInput({ ...spaceInput, id }, ["id"]),
|
|
548
|
+
output: pagesHistoryOutput,
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
name: "graph.links",
|
|
552
|
+
label: "map the links around a page",
|
|
553
|
+
permission: "mem_page",
|
|
554
|
+
input: graphInput,
|
|
555
|
+
output: graphOutput,
|
|
556
|
+
},
|
|
287
557
|
])
|
|
288
558
|
|
|
289
559
|
/** The refusal a page can show in the plugin's own words (`call.error`). */
|