@hraness/wordcell 0.22.0 → 0.22.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 (46) hide show
  1. package/README.md +40 -17
  2. package/dist/authoring.js +5 -3
  3. package/dist/{authority-1pgftmwq.js → authority-06eqhqam.js} +2 -2
  4. package/dist/benchmark.js +3 -3
  5. package/dist/cli.js +15 -15
  6. package/dist/evaluation-builder.js +10 -10
  7. package/dist/evaluation-kb.js +10 -10
  8. package/dist/graph-authority.js +4 -4
  9. package/dist/graph-percolation.js +6 -6
  10. package/dist/graph.js +1 -1
  11. package/dist/{index-e6p9e926.js → index-1k595z6v.js} +2 -2
  12. package/dist/{index-1tm7bgx7.js → index-233z9wmn.js} +1 -1
  13. package/dist/{index-a6kbv718.js → index-76dbn6pe.js} +1 -1
  14. package/dist/{index-avbce90h.js → index-bqtqeak3.js} +4 -4
  15. package/dist/{index-4ag64rc1.js → index-bw2r37z9.js} +74 -19
  16. package/dist/{index-t2bs9xdr.js → index-djrcc1yf.js} +4 -4
  17. package/dist/{index-6sw24nvv.js → index-ecqpgr5y.js} +53 -2
  18. package/dist/{index-0dqfnrz9.js → index-hmw17zaa.js} +2 -2
  19. package/dist/{index-nd6nynv2.js → index-jk1sgx36.js} +1 -1
  20. package/dist/{index-qwgsmtsz.js → index-n386evxj.js} +1 -1
  21. package/dist/{index-2hf27mws.js → index-q7tbg07z.js} +7 -7
  22. package/dist/{index-ekpwvbra.js → index-qbssx940.js} +1 -2
  23. package/dist/{index-hcw140eb.js → index-rr9kzq4n.js} +2 -2
  24. package/dist/{index-11621h23.js → index-tf4wzjew.js} +1 -1
  25. package/dist/{index-gm9t95d9.js → index-vnybgywh.js} +1 -1
  26. package/dist/{index-famy7fhs.js → index-xv80vzfp.js} +4 -4
  27. package/dist/index.js +16 -14
  28. package/dist/percolate.js +2 -2
  29. package/dist/portfolio.js +10 -10
  30. package/dist/publish.js +3 -3
  31. package/dist/sdk.js +9 -9
  32. package/dist/search.js +2 -2
  33. package/dist/semantic.js +4 -4
  34. package/dist/{support-mywv1em0.js → support-p452p9c4.js} +15 -15
  35. package/dist/workflows/decision-context.js +10 -10
  36. package/dist/workflows/index.js +10 -10
  37. package/package.json +7 -6
  38. package/skills/wordcell/SKILL.md +2 -2
  39. package/skills/wordcell/references/publish.md +34 -0
  40. package/skills/wordcell/references/refresh.md +14 -0
  41. package/src/authoring-model.ts +29 -0
  42. package/src/authoring-program.ts +38 -3
  43. package/src/authoring.ts +17 -3
  44. package/src/cli-program.ts +95 -4
  45. package/src/graph.ts +1 -1
  46. package/src/support-profile.ts +1 -1
package/dist/portfolio.js CHANGED
@@ -20,20 +20,20 @@ import {
20
20
  selectAuthorizedVaults,
21
21
  snapshotPortfolioRegistry,
22
22
  validateResolvedPortfolioVaults
23
- } from "./index-avbce90h.js";
24
- import"./index-2hf27mws.js";
23
+ } from "./index-bqtqeak3.js";
24
+ import"./index-q7tbg07z.js";
25
25
  import"./index-adx6khj5.js";
26
- import"./index-hcw140eb.js";
26
+ import"./index-rr9kzq4n.js";
27
27
  import"./index-4j3tt0c3.js";
28
28
  import"./index-j70m75wd.js";
29
- import"./index-t2bs9xdr.js";
30
- import"./index-nd6nynv2.js";
31
- import"./index-famy7fhs.js";
32
- import"./index-11621h23.js";
29
+ import"./index-djrcc1yf.js";
30
+ import"./index-jk1sgx36.js";
31
+ import"./index-xv80vzfp.js";
32
+ import"./index-tf4wzjew.js";
33
33
  import"./index-1gwbassd.js";
34
- import"./index-gm9t95d9.js";
34
+ import"./index-vnybgywh.js";
35
35
  import"./index-1xxnjn0d.js";
36
- import"./index-1tm7bgx7.js";
36
+ import"./index-233z9wmn.js";
37
37
  import"./index-d13v9ckt.js";
38
38
  import"./index-48pz4jpc.js";
39
39
  import"./index-06c9ctr6.js";
@@ -50,7 +50,7 @@ import {
50
50
  parseVaultKey,
51
51
  portfolioDocumentIdentity,
52
52
  portfolioVaultIdentity
53
- } from "./index-ekpwvbra.js";
53
+ } from "./index-qbssx940.js";
54
54
  import"./index-z1w83f81.js";
55
55
  export {
56
56
  validateResolvedPortfolioVaults,
package/dist/publish.js CHANGED
@@ -10,8 +10,8 @@ import {
10
10
  publishVault,
11
11
  renderPublishReportText,
12
12
  serializeSiteFile
13
- } from "./index-0dqfnrz9.js";
14
- import"./index-1tm7bgx7.js";
13
+ } from "./index-hmw17zaa.js";
14
+ import"./index-233z9wmn.js";
15
15
  import"./index-d13v9ckt.js";
16
16
  import"./index-48pz4jpc.js";
17
17
  import"./index-06c9ctr6.js";
@@ -20,7 +20,7 @@ import"./index-66pshdtx.js";
20
20
  import"./index-3agn8scn.js";
21
21
  import"./index-5vwpzb5a.js";
22
22
  import"./index-x3fthpsc.js";
23
- import"./index-ekpwvbra.js";
23
+ import"./index-qbssx940.js";
24
24
  import"./index-z1w83f81.js";
25
25
  export {
26
26
  serializeSiteFile,
package/dist/sdk.js CHANGED
@@ -11,25 +11,25 @@ import {
11
11
  packUntrustedSearchContext,
12
12
  searchEvidenceRank,
13
13
  validateKnowledgeBaseSearchHistory
14
- } from "./index-2hf27mws.js";
14
+ } from "./index-q7tbg07z.js";
15
15
  import"./index-adx6khj5.js";
16
- import"./index-hcw140eb.js";
16
+ import"./index-rr9kzq4n.js";
17
17
  import"./index-4j3tt0c3.js";
18
18
  import"./index-j70m75wd.js";
19
- import"./index-t2bs9xdr.js";
20
- import"./index-nd6nynv2.js";
21
- import"./index-famy7fhs.js";
22
- import"./index-11621h23.js";
19
+ import"./index-djrcc1yf.js";
20
+ import"./index-jk1sgx36.js";
21
+ import"./index-xv80vzfp.js";
22
+ import"./index-tf4wzjew.js";
23
23
  import"./index-1gwbassd.js";
24
- import"./index-gm9t95d9.js";
24
+ import"./index-vnybgywh.js";
25
25
  import"./index-1xxnjn0d.js";
26
- import"./index-1tm7bgx7.js";
26
+ import"./index-233z9wmn.js";
27
27
  import"./index-d13v9ckt.js";
28
28
  import"./index-48pz4jpc.js";
29
29
  import"./index-06c9ctr6.js";
30
30
  import"./index-5vwpzb5a.js";
31
31
  import"./index-3rm7cz6h.js";
32
- import"./index-ekpwvbra.js";
32
+ import"./index-qbssx940.js";
33
33
  import"./index-z1w83f81.js";
34
34
  export {
35
35
  validateKnowledgeBaseSearchHistory,
package/dist/search.js CHANGED
@@ -6,12 +6,12 @@ import {
6
6
  fuseRankedCandidates,
7
7
  searchExactVault,
8
8
  validateSearchQuery
9
- } from "./index-gm9t95d9.js";
9
+ } from "./index-vnybgywh.js";
10
10
  import"./index-d13v9ckt.js";
11
11
  import"./index-48pz4jpc.js";
12
12
  import"./index-06c9ctr6.js";
13
13
  import"./index-5vwpzb5a.js";
14
- import"./index-ekpwvbra.js";
14
+ import"./index-qbssx940.js";
15
15
  import"./index-z1w83f81.js";
16
16
  export {
17
17
  validateSearchQuery,
package/dist/semantic.js CHANGED
@@ -14,14 +14,14 @@ import {
14
14
  searchSemanticVault,
15
15
  semanticDatabasePath,
16
16
  sha256EmbeddingModelFile
17
- } from "./index-hcw140eb.js";
18
- import"./index-gm9t95d9.js";
19
- import"./index-1tm7bgx7.js";
17
+ } from "./index-rr9kzq4n.js";
18
+ import"./index-vnybgywh.js";
19
+ import"./index-233z9wmn.js";
20
20
  import"./index-d13v9ckt.js";
21
21
  import"./index-48pz4jpc.js";
22
22
  import"./index-06c9ctr6.js";
23
23
  import"./index-5vwpzb5a.js";
24
- import"./index-ekpwvbra.js";
24
+ import"./index-qbssx940.js";
25
25
  import"./index-z1w83f81.js";
26
26
  export {
27
27
  sha256EmbeddingModelFile,
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  parseArguments as parseArguments2,
4
4
  parseUrlMetadataArguments
5
- } from "./index-4ag64rc1.js";
5
+ } from "./index-bw2r37z9.js";
6
6
  import"./index-bcknqxrq.js";
7
7
  import {
8
8
  parsePdfArguments
9
9
  } from "./index-054mb7d3.js";
10
- import"./index-avbce90h.js";
10
+ import"./index-bqtqeak3.js";
11
11
  import"./index-j4zgmzjr.js";
12
12
  import"./index-de2w8crk.js";
13
13
  import"./index-6jcz0m1c.js";
@@ -28,22 +28,22 @@ import"./index-mxxxytys.js";
28
28
  import"./index-23z4zxgg.js";
29
29
  import"./index-pj501bh1.js";
30
30
  import"./index-9rf81m0p.js";
31
- import"./index-e6p9e926.js";
32
- import"./index-2hf27mws.js";
31
+ import"./index-1k595z6v.js";
32
+ import"./index-q7tbg07z.js";
33
33
  import"./index-adx6khj5.js";
34
- import"./index-hcw140eb.js";
34
+ import"./index-rr9kzq4n.js";
35
35
  import"./index-4j3tt0c3.js";
36
36
  import"./index-j70m75wd.js";
37
37
  import"./index-b88v3vtm.js";
38
- import"./index-t2bs9xdr.js";
39
- import"./index-nd6nynv2.js";
40
- import"./index-famy7fhs.js";
41
- import"./index-11621h23.js";
38
+ import"./index-djrcc1yf.js";
39
+ import"./index-jk1sgx36.js";
40
+ import"./index-xv80vzfp.js";
41
+ import"./index-tf4wzjew.js";
42
42
  import"./index-1gwbassd.js";
43
- import"./index-gm9t95d9.js";
43
+ import"./index-vnybgywh.js";
44
44
  import"./index-1xxnjn0d.js";
45
- import"./index-0dqfnrz9.js";
46
- import"./index-1tm7bgx7.js";
45
+ import"./index-hmw17zaa.js";
46
+ import"./index-233z9wmn.js";
47
47
  import"./index-d13v9ckt.js";
48
48
  import"./index-48pz4jpc.js";
49
49
  import"./index-06c9ctr6.js";
@@ -53,9 +53,9 @@ import"./index-3agn8scn.js";
53
53
  import"./index-hya40gb2.js";
54
54
  import"./index-5vwpzb5a.js";
55
55
  import"./index-x3fthpsc.js";
56
- import"./index-6sw24nvv.js";
56
+ import"./index-ecqpgr5y.js";
57
57
  import"./index-3rm7cz6h.js";
58
- import"./index-ekpwvbra.js";
58
+ import"./index-qbssx940.js";
59
59
  import"./index-z1w83f81.js";
60
60
 
61
61
  // src/support.ts
@@ -65,7 +65,7 @@ import { maybeShowSupportInvitation, runSupportCommand } from "@hraness/support-
65
65
  var supportProfile = {
66
66
  id: "kb",
67
67
  name: "Wordcell",
68
- valueProposition: "Support ongoing development of inspectable Markdown memory for coding agents.",
68
+ valueProposition: "Support ongoing development of inspectable Markdown memory.",
69
69
  updates: false
70
70
  };
71
71
 
@@ -1,27 +1,27 @@
1
1
  // @bun
2
2
  import {
3
3
  decisionContextWorkflow
4
- } from "../index-a6kbv718.js";
4
+ } from "../index-76dbn6pe.js";
5
5
  import"../index-h170byqw.js";
6
- import"../index-2hf27mws.js";
6
+ import"../index-q7tbg07z.js";
7
7
  import"../index-adx6khj5.js";
8
- import"../index-hcw140eb.js";
8
+ import"../index-rr9kzq4n.js";
9
9
  import"../index-4j3tt0c3.js";
10
10
  import"../index-j70m75wd.js";
11
- import"../index-t2bs9xdr.js";
12
- import"../index-nd6nynv2.js";
13
- import"../index-famy7fhs.js";
14
- import"../index-11621h23.js";
11
+ import"../index-djrcc1yf.js";
12
+ import"../index-jk1sgx36.js";
13
+ import"../index-xv80vzfp.js";
14
+ import"../index-tf4wzjew.js";
15
15
  import"../index-1gwbassd.js";
16
- import"../index-gm9t95d9.js";
16
+ import"../index-vnybgywh.js";
17
17
  import"../index-1xxnjn0d.js";
18
- import"../index-1tm7bgx7.js";
18
+ import"../index-233z9wmn.js";
19
19
  import"../index-d13v9ckt.js";
20
20
  import"../index-48pz4jpc.js";
21
21
  import"../index-06c9ctr6.js";
22
22
  import"../index-5vwpzb5a.js";
23
23
  import"../index-3rm7cz6h.js";
24
- import"../index-ekpwvbra.js";
24
+ import"../index-qbssx940.js";
25
25
  import"../index-z1w83f81.js";
26
26
  export {
27
27
  decisionContextWorkflow
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  decisionContextWorkflow
4
- } from "../index-a6kbv718.js";
4
+ } from "../index-76dbn6pe.js";
5
5
  import {
6
6
  explainChangeWorkflow
7
7
  } from "../index-e4fagfjz.js";
@@ -9,25 +9,25 @@ import {
9
9
  planRadarWorkflow
10
10
  } from "../index-rdd5f7jj.js";
11
11
  import"../index-h170byqw.js";
12
- import"../index-2hf27mws.js";
12
+ import"../index-q7tbg07z.js";
13
13
  import"../index-adx6khj5.js";
14
- import"../index-hcw140eb.js";
14
+ import"../index-rr9kzq4n.js";
15
15
  import"../index-4j3tt0c3.js";
16
16
  import"../index-j70m75wd.js";
17
- import"../index-t2bs9xdr.js";
18
- import"../index-nd6nynv2.js";
19
- import"../index-famy7fhs.js";
20
- import"../index-11621h23.js";
17
+ import"../index-djrcc1yf.js";
18
+ import"../index-jk1sgx36.js";
19
+ import"../index-xv80vzfp.js";
20
+ import"../index-tf4wzjew.js";
21
21
  import"../index-1gwbassd.js";
22
- import"../index-gm9t95d9.js";
22
+ import"../index-vnybgywh.js";
23
23
  import"../index-1xxnjn0d.js";
24
- import"../index-1tm7bgx7.js";
24
+ import"../index-233z9wmn.js";
25
25
  import"../index-d13v9ckt.js";
26
26
  import"../index-48pz4jpc.js";
27
27
  import"../index-06c9ctr6.js";
28
28
  import"../index-5vwpzb5a.js";
29
29
  import"../index-3rm7cz6h.js";
30
- import"../index-ekpwvbra.js";
30
+ import"../index-qbssx940.js";
31
31
  import"../index-z1w83f81.js";
32
32
  export {
33
33
  planRadarWorkflow,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hraness/wordcell",
3
- "version": "0.22.0",
4
- "description": "A local knowledge base for coding agents. Save decisions in Markdown and recover the context behind your code.",
3
+ "version": "0.22.2",
4
+ "description": "A local Markdown knowledge base with superpowers. Save decisions, sources, and plans as files you own, then recover them through exact and semantic search, typed relationships, backlinks, and Git history.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": [
@@ -476,14 +476,15 @@
476
476
  "url-metadata:tool:build": "bun ./dist/cli.js url-metadata tool build",
477
477
  "url-metadata:tool:check": "bun ./dist/cli.js url-metadata tool check",
478
478
  "test:package": "bun run ./scripts/package-smoke.ts",
479
- "check": "bun run check:effect && bun run check:workflows && bun run check:portfolio-inventory && bun run check:installed-command-docs && bun run typecheck && bun run build && bun run test:package && bun run test && bun run url-metadata:tool:check",
479
+ "check": "bun run check:worker && bun run check:effect && bun run check:workflows && bun run check:portfolio-inventory && bun run check:installed-command-docs && bun run typecheck && bun run build && bun run test:package && bun run test && bun run url-metadata:tool:check",
480
480
  "prepack": "bun run check",
481
481
  "check:effect": "bun run scripts/check-effect-policy.ts",
482
- "kb:search": "bunx --bun --package https://github.com/hraness/wordcell/releases/download/v0.22.0/hraness-wordcell-0.22.0.tgz wordcell search --root kb --mode exact --rerank typesafe --rerank-limit 25",
483
- "kb:search:local": "bunx --bun --package https://github.com/hraness/wordcell/releases/download/v0.22.0/hraness-wordcell-0.22.0.tgz wordcell search --root kb --mode exact"
482
+ "kb:search": "bunx --bun --package https://github.com/hraness/wordcell/releases/download/v0.22.1/hraness-wordcell-0.22.1.tgz wordcell search --root kb --mode exact --rerank typesafe --rerank-limit 25",
483
+ "kb:search:local": "bunx --bun --package https://github.com/hraness/wordcell/releases/download/v0.22.1/hraness-wordcell-0.22.1.tgz wordcell search --root kb --mode exact",
484
+ "check:worker": "tsc -p worker/tsconfig.json --noEmit"
484
485
  },
485
486
  "dependencies": {
486
- "@hraness/oh": "https://github.com/hraness/oh/releases/download/v0.10.8/hraness-oh-0.10.8.tgz",
487
+ "@hraness/oh": "https://github.com/hraness/oh/releases/download/v0.12.0/hraness-oh-0.12.0.tgz",
487
488
  "@steipete/sweet-cookie": "0.4.3",
488
489
  "@tobilu/qmd": "git+https://github.com/hraness/qmd.git#aa993dceb3ef8cfb71d470554ca437570f5a2b3c",
489
490
  "agent-browser": "0.32.3",
@@ -35,7 +35,7 @@ selected.
35
35
  | Create or update an implementation plan, proposal, RFC, migration plan, execution audit, or phased checklist in the vault | [Write a durable plan](references/plan.md) and [use its structure](references/plan-structure.md) |
36
36
  | Review recurring ideas, promote concepts, or add and verify typed relationships | [Percolate concepts and relationships](references/percolate.md) |
37
37
  | Refresh or validate the catalog, graph, attachments, repository scopes, context mappings, or overall vault health | [Refresh and check the knowledge base](references/refresh.md) |
38
- | Publish a vault or a selected subsection as a hosted read-only static site with browser-local search | [Publish a static site](references/publish.md) |
38
+ | Publish a vault or a selected subsection as a hosted read-only static site with browser-local search — locally via `wordcell publish`, or over the wordcell.io REST/MCP surface when no filesystem or Bun runtime is available | [Publish a static site](references/publish.md) |
39
39
 
40
40
  Read more than one primary reference only when the request spans those
41
41
  workflows. For example, saving a source and linking it from a maintained note
@@ -56,7 +56,7 @@ missing:
56
56
  ```sh
57
57
  command -v wordcell >/dev/null 2>&1 || {
58
58
  command -v bun >/dev/null 2>&1 || exit 1
59
- bun add --global --ignore-scripts https://github.com/hraness/wordcell/releases/download/v0.22.0/hraness-wordcell-0.22.0.tgz
59
+ bun add --global --ignore-scripts https://github.com/hraness/wordcell/releases/download/v0.22.2/hraness-wordcell-0.22.2.tgz
60
60
  }
61
61
  wordcell --help
62
62
  ```
@@ -91,3 +91,37 @@ local build alone is not a live deployment.
91
91
 
92
92
  The full artifact contract and hosting options are in
93
93
  [the publishing guide](https://github.com/hraness/wordcell/blob/main/docs/publish.md).
94
+
95
+ ## Publish through wordcell.io when the CLI cannot run
96
+
97
+ Agents on platforms without a filesystem or Bun runtime can publish the same
98
+ `hraness.wordcell.site.v1` artifact through the hosted surface. It runs the
99
+ identical projection server-side; published sites are public.
100
+
101
+ ```sh
102
+ # Self-serve capability token (IP-limited; shown once — store it).
103
+ TOKEN=$(curl -sf -X POST https://wordcell.io/api/v1/tokens \
104
+ -H 'content-type: application/json' -d '{"label":"my-agent"}' | jq -r .token)
105
+
106
+ # Publish a vault as a files map: path -> utf8 string, {"base64":"..."}, or
107
+ # {"upload":"<id>"} from POST /api/v1/uploads for larger assets.
108
+ curl -sf -X PUT "https://wordcell.io/api/v1/sites/my-notes" \
109
+ -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
110
+ -d '{"files":{"index.md":"# Notes\n","a.md":"# A\n"},"title":"My notes"}'
111
+ # -> {"site":{"url":"https://wordcell.io/p/<key8>/my-notes/",...},"idempotent":false}
112
+ ```
113
+
114
+ `GET /api/v1/sites` lists the token's sites and `DELETE /api/v1/sites/{slug}`
115
+ unpublishes. Identical bytes republish idempotently without a revision bump;
116
+ changed bytes sweep the superseded artifact. Deletes and republishes can take
117
+ up to 60 seconds to propagate at the edge. MCP clients can instead point at the
118
+ streamable-HTTP endpoint `POST https://wordcell.io/api/v1/mcp`, which exposes
119
+ `create_token`, `publish_site`, `list_sites`, and `delete_site` tools over the
120
+ same routes — `create_token` is unauthenticated so an MCP-only client can
121
+ onboard itself. `GET /api/v1/openapi.json` describes the REST surface.
122
+
123
+ The hosted surface carries the same selection semantics (`selection` mirrors
124
+ the CLI selectors) and the same redaction warning: `publish: false` excludes a
125
+ note, it does not erase text quoted elsewhere. Bounded inputs apply — at most
126
+ 256 files and 4 MiB inline per publish, 32 MiB per uploaded asset, 50 live
127
+ sites per token.
@@ -126,6 +126,20 @@ After any note or link edit, run the refresh command again so derived state and
126
126
  wordcell check --root "$KB_ROOT"
127
127
  ```
128
128
 
129
+ When the vault lives inside a repository and `KB_REPO` is set, add the advisory
130
+ repository-state pass:
131
+
132
+ ```sh
133
+ wordcell check --root "$KB_ROOT" --repo "$KB_REPO"
134
+ ```
135
+
136
+ This compares every authored `repository_scopes` declaration with the current
137
+ working tree and reports each current record whose declared path is now absent
138
+ or unusable. It is advisory: the exit code does not change, and a terminal plan
139
+ that names a removed path stays silent because that is valid authored history.
140
+ Treat an absent-scope advisory as a note to reread against the code, not as a
141
+ proven error; confirm the path in the repository before editing the note.
142
+
129
143
  Finish only when the graph check and any required agent-context check succeed,
130
144
  the configured catalog mode is satisfied, and broken or ambiguous links,
131
145
  relationships, and local attachments are resolved. Summarize deliberate
@@ -89,6 +89,11 @@ export interface AuthoringOptions {
89
89
  readonly dependencies?: Partial<AuthoringDependencies>;
90
90
  }
91
91
 
92
+ export interface UpdateNoteBodyOptions extends AuthoringOptions {
93
+ /** Exact revision read before preparing the replacement body. */
94
+ readonly expectedRevision: NoteRevision;
95
+ }
96
+
92
97
  export class InvalidCanonicalNoteIdError extends TypeError {
93
98
  readonly noteId: string;
94
99
 
@@ -692,6 +697,30 @@ export function normalizedRequestedBody(body: string): string {
692
697
  return body.endsWith("\n") ? body : `${body}\n`;
693
698
  }
694
699
 
700
+ /** Replace prose without serializing or modifying the authored frontmatter. */
701
+ export function renderUpdatedNoteBody(
702
+ snapshot: Pick<NoteSnapshot, "content" | "relativePath">,
703
+ parts: FrontmatterParts,
704
+ body: string,
705
+ ): string {
706
+ if (typeof body !== "string") throw new TypeError("a note body must be a string");
707
+ if (Buffer.byteLength(body, "utf8") > MAX_NOTE_BYTES) {
708
+ throw new RangeError("the note body is too large for bounded authoring");
709
+ }
710
+ if (Buffer.from(body, "utf8").toString("utf8") !== body) {
711
+ throw new TypeError("a note body must contain well-formed Unicode");
712
+ }
713
+ const normalized = normalizedRequestedBody(body);
714
+ if (!parts.hadFrontmatter) {
715
+ if (frontmatter(normalized, snapshot.relativePath).hadFrontmatter) {
716
+ throw new TypeError("a body update cannot introduce frontmatter into a note");
717
+ }
718
+ return normalized;
719
+ }
720
+ const header = snapshot.content.slice(0, snapshot.content.length - parts.bodySuffix.length);
721
+ return `${header}${parts.newline}${parts.newline}${normalized}`;
722
+ }
723
+
695
724
  export function renderCreatedNote(input: CreateNoteInput, documentId: string): string {
696
725
  const title = validateTitle(input.title);
697
726
  const type = validateType(input.type);
@@ -3,13 +3,13 @@ import { Effect, Exit } from "effect";
3
3
  import {
4
4
  MAX_NOTE_BYTES, NoteRevisionConflictError, addRelationToParts, assertCompatibleCreate,
5
5
  assertExpected, canonicalNoteId, canonicalRelationTarget, checkedExpectedRevision,
6
- frontmatter, isErrno, normalizeRelationPredicate, noteResult, pathFor, relationsFromParts,
7
- removeRelationFromParts, renderCreatedNote, renderFrontmatter, revisionFor,
6
+ existingDocumentId, frontmatter, isErrno, normalizeRelationPredicate, noteResult, pathFor, relationsFromParts,
7
+ removeRelationFromParts, renderCreatedNote, renderFrontmatter, renderUpdatedNoteBody, requireRevision, revisionFor,
8
8
  sameQuarantinedSnapshot, sameSnapshot, withRecoveryPath,
9
9
  } from "./authoring-model.js";
10
10
  import type {
11
11
  AuthoringDependencies, AuthoringInstallContext, AuthoringOptions, CreateNoteInput,
12
- DirectoryIdentity, NoteAuthoringResult, NoteRevision, NoteSnapshot, RecoveryLocation, Vault,
12
+ DirectoryIdentity, NoteAuthoringResult, NoteRevision, NoteSnapshot, RecoveryLocation, UpdateNoteBodyOptions, Vault,
13
13
  } from "./authoring-model.js";
14
14
  import type { NoteLock } from "./note-lock.js";
15
15
  import { parseDocumentId } from "./portfolio-identity.js";
@@ -276,3 +276,38 @@ export function editNoteRelationProgram(
276
276
  );
277
277
  });
278
278
  }
279
+
280
+ export function updateNoteBodyProgram(
281
+ platform: AuthoringPlatform, root: string, idInput: string, body: string,
282
+ options: UpdateNoteBodyOptions,
283
+ ): Effect.Effect<NoteAuthoringResult, AuthoringFailure> {
284
+ return Effect.gen(function*() {
285
+ const id = yield* authoringSync(() => canonicalNoteId(idInput));
286
+ const expected = yield* authoringSync(() => {
287
+ if (typeof options?.expectedRevision !== "string") {
288
+ throw new TypeError("expectedRevision is required for a note body update");
289
+ }
290
+ return requireRevision(options.expectedRevision);
291
+ });
292
+ const vault = yield* authoringNative(() => platform.resolveVault(root));
293
+ const dependencies = yield* authoringSync(() => platform.dependenciesFor(options.dependencies));
294
+ return yield* authoringResource(
295
+ authoringNative(() => platform.acquireNoteLock(vault.root, id, options.lock)),
296
+ (lock) => Effect.gen(function*() {
297
+ yield* authoringNative(() => platform.recoverInterruptedAuthoring(vault, id, lock));
298
+ const source = yield* authoringNative(() => platform.readSnapshot(vault, id));
299
+ yield* authoringSync(() => assertExpected(source, expected));
300
+ const parts = yield* authoringSync(() => frontmatter(source.content, source.relativePath));
301
+ const identity = yield* authoringSync(() => existingDocumentId(parts));
302
+ if (identity.kind === "invalid") return yield* fail(new TypeError("the note has an invalid document_id"));
303
+ const documentId = identity.kind === "valid" ? identity.documentId : undefined;
304
+ const relations = yield* authoringSync(() => relationsFromParts(parts, source.relativePath));
305
+ const content = yield* authoringSync(() => renderUpdatedNoteBody(source, parts, body));
306
+ if (content === source.content) return yield* authoringSync(() => noteResult(source, relations, false, documentId));
307
+ const revision = yield* installNote(platform, vault, id, content, source, lock, dependencies);
308
+ return yield* authoringSync(() => noteResult({ relativePath: source.relativePath, revision }, relations, true, documentId));
309
+ }),
310
+ (lock) => authoringNative(() => lock.release()),
311
+ );
312
+ });
313
+ }
package/src/authoring.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type {
2
2
  AuthoringOptions, CreateConceptNoteInput, CreateNoteInput, NoteAuthoringResult,
3
- NoteRelation, NoteRevision,
3
+ NoteRelation, NoteRevision, UpdateNoteBodyOptions,
4
4
  } from "./authoring-model.js";
5
5
  import { canonicalNoteId, frontmatter, relationsFromParts } from "./authoring-model.js";
6
6
  import {
7
7
  assertNoInterruptedRecovery, nativeAuthoringPlatform, readSnapshot, resolveVault,
8
8
  } from "./authoring-platform.js";
9
- import { createNoteProgram, editNoteRelationProgram } from "./authoring-program.js";
9
+ import { createNoteProgram, editNoteRelationProgram, updateNoteBodyProgram } from "./authoring-program.js";
10
10
  import { runAuthoring } from "./authoring-runtime.js";
11
11
 
12
12
  export {
@@ -15,7 +15,7 @@ export {
15
15
  } from "./authoring-model.js";
16
16
  export type {
17
17
  AuthoringDependencies, AuthoringInstallContext, AuthoringOptions,
18
- CreateConceptNoteInput, CreateNoteInput, NoteAuthoringResult, NoteRelation, NoteRevision,
18
+ CreateConceptNoteInput, CreateNoteInput, NoteAuthoringResult, NoteRelation, NoteRevision, UpdateNoteBodyOptions,
19
19
  } from "./authoring-model.js";
20
20
 
21
21
  /**
@@ -60,6 +60,20 @@ export async function createConceptNote(
60
60
  return createNote(root, { ...input, type: "concept" }, options);
61
61
  }
62
62
 
63
+ /**
64
+ * Replace one existing note's body at an exact revision. Frontmatter bytes,
65
+ * stable identity and relations remain unchanged. Like createNote, this adds a
66
+ * final newline and separates frontmatter from the body with one blank line.
67
+ *
68
+ * A stale revision fails even if the requested body already matches. Callers
69
+ * must read back an interrupted operation before deciding whether to retry.
70
+ */
71
+ export async function updateNoteBody(
72
+ root: string, id: string, body: string, options: UpdateNoteBodyOptions,
73
+ ): Promise<NoteAuthoringResult> {
74
+ return runAuthoring(updateNoteBodyProgram(nativeAuthoringPlatform, root, id, body, options));
75
+ }
76
+
63
77
  /** Add one exact outbound typed relation, idempotently. */
64
78
  export async function addNoteRelation(
65
79
  root: string, sourceId: string, predicate: string, targetId: string, options: AuthoringOptions = {},