tgo-wiki 0.1.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +255 -0
  3. package/docs/mcp-usage.md +631 -0
  4. package/docs/v0-acceptance.md +105 -0
  5. package/docs/v0-delivery-checklist.md +57 -0
  6. package/docs/v1-acceptance.md +39 -0
  7. package/docs/v2-acceptance.md +165 -0
  8. package/package.json +69 -0
  9. package/packages/core/src/config/config-loader.ts +109 -0
  10. package/packages/core/src/config/defaults.ts +74 -0
  11. package/packages/core/src/config/workspace-resolver.ts +40 -0
  12. package/packages/core/src/documents/command-document-parser.ts +206 -0
  13. package/packages/core/src/documents/document-id.ts +26 -0
  14. package/packages/core/src/documents/document-parser-registry.ts +126 -0
  15. package/packages/core/src/documents/document-service.ts +656 -0
  16. package/packages/core/src/documents/document-store.ts +132 -0
  17. package/packages/core/src/documents/document-types.ts +33 -0
  18. package/packages/core/src/documents/pdf-text-parser.ts +35 -0
  19. package/packages/core/src/documents/text-markdown-parser.ts +50 -0
  20. package/packages/core/src/errors.ts +46 -0
  21. package/packages/core/src/git/git-service.ts +68 -0
  22. package/packages/core/src/index.ts +38 -0
  23. package/packages/core/src/markdown/markdown-scanner.ts +90 -0
  24. package/packages/core/src/permissions/permission-service.ts +50 -0
  25. package/packages/core/src/publish/publish-service.ts +142 -0
  26. package/packages/core/src/result.ts +13 -0
  27. package/packages/core/src/services/session-workflow-service.ts +493 -0
  28. package/packages/core/src/services/wiki-service.ts +119 -0
  29. package/packages/core/src/services/workspace-service.ts +223 -0
  30. package/packages/core/src/session/session-id.ts +14 -0
  31. package/packages/core/src/session/session-service.ts +77 -0
  32. package/packages/core/src/session/session-store.ts +91 -0
  33. package/packages/core/src/session/session-types.ts +17 -0
  34. package/packages/core/src/sources/source-id.ts +19 -0
  35. package/packages/core/src/sources/source-paths.ts +15 -0
  36. package/packages/core/src/sources/source-service.ts +416 -0
  37. package/packages/core/src/sources/source-types.ts +77 -0
  38. package/packages/core/src/sources/source-validator.ts +132 -0
  39. package/packages/core/src/sources/source-writer.ts +419 -0
  40. package/packages/core/src/validation/frontmatter-validator.ts +128 -0
  41. package/packages/core/src/validation/link-validator.ts +55 -0
  42. package/packages/core/src/validation/path-validator.ts +65 -0
  43. package/packages/core/src/validation/source-reference-validator.ts +191 -0
  44. package/packages/core/src/validation/validation-service.ts +106 -0
  45. package/packages/core/src/vfs/vfs-command-parser.ts +69 -0
  46. package/packages/core/src/vfs/vfs-service.ts +498 -0
  47. package/packages/core/src/web/html-to-markdown.ts +144 -0
  48. package/packages/core/src/web/static-web-fetcher.ts +537 -0
  49. package/packages/core/src/web/web-id.ts +26 -0
  50. package/packages/core/src/web/web-ingestion-service.ts +335 -0
  51. package/packages/core/src/web/web-paths.ts +6 -0
  52. package/packages/core/src/web/web-types.ts +33 -0
  53. package/packages/server/src/cli.ts +56 -0
  54. package/packages/server/src/context.ts +7 -0
  55. package/packages/server/src/index.ts +2 -0
  56. package/packages/server/src/mcp-server.ts +111 -0
  57. package/packages/server/src/schemas/documents.ts +17 -0
  58. package/packages/server/src/schemas/read.ts +16 -0
  59. package/packages/server/src/schemas/session.ts +31 -0
  60. package/packages/server/src/schemas/sources.ts +12 -0
  61. package/packages/server/src/schemas/web.ts +23 -0
  62. package/packages/server/src/tools/document-tools.ts +46 -0
  63. package/packages/server/src/tools/publish-tools.ts +33 -0
  64. package/packages/server/src/tools/read-tools.ts +52 -0
  65. package/packages/server/src/tools/response.ts +24 -0
  66. package/packages/server/src/tools/session-tools.ts +100 -0
  67. package/packages/server/src/tools/source-tools.ts +32 -0
  68. package/packages/server/src/tools/web-tools.ts +26 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-06-13
4
+
5
+ ### Added
6
+
7
+ - MCP-first Agent Wiki v0 slice with local git-backed workspace initialization, status, stable reads, and writer sessions.
8
+ - Reader and writer role enforcement for the v0 MCP tool surface.
9
+ - Markdown validation for frontmatter, headings, links, and wiki path safety.
10
+ - Independent black-box package that exercises the public CLI and MCP stdio JSON-RPC surface.
11
+ - Packed tarball smoke via `bun run smoke:pack`.
12
+ - Release-readiness gate via `bun run release:check`.
13
+ - v1 document ingestion MCP tools for upload, parse, source listing, and source reading.
14
+ - v1.1 direct Markdown and plain text document ingestion through the existing document tools.
15
+ - v1.1 command-backed document parser configuration for local parser plugins.
16
+ - Git-tracked `sources/` raw Markdown with state-stored source blobs.
17
+ - Optional wiki page `sources` frontmatter validation.
18
+ - ff-only session publish for publisher and admin roles.
19
+ - v2 web ingestion MVP with `web_fetch`, state-stored HTML blobs, generated web sources, source citations, commit, publish, and stable source reads.
20
+ - Publish-ready npm package metadata for installing the `tgo-wiki` CLI from the registry.
21
+
22
+ ### Verification
23
+
24
+ - `bun run release:check`
25
+ - `bun run verify:v0`
26
+ - `bun run smoke:pack`
27
+
28
+ ### Deferred
29
+
30
+ - Rollback tooling.
31
+ - Search and QA tooling
32
+ - Remote git, pull request integration, and web UI
package/README.md ADDED
@@ -0,0 +1,255 @@
1
+ # TGO Wiki
2
+
3
+ TGO Wiki is a Bun-first TypeScript implementation of the Agent Wiki MCP surface. It gives an agent a local git-backed wiki workspace, stable read tools, isolated edit sessions for Markdown changes, v1 document ingestion that turns uploaded source documents into git-tracked wiki sources, and v2 web ingestion that fetches static HTML pages into citable sources.
4
+
5
+ ## v2 Current Scope
6
+
7
+ v2 extends the v1 local git/worktree/session/validation/commit/publish/source surface with static web ingestion:
8
+
9
+ - Fetch one public `http:` or `https:` HTML page into an open session with `web_fetch` as `publisher` or `admin`.
10
+ - Store original HTML blobs outside git under workspace state.
11
+ - Convert fetched HTML into raw Markdown source files under `sources/<source_id>/`.
12
+ - Read web sources from stable or from an active session ref.
13
+ - Validate optional wiki page `sources` frontmatter against returned web source IDs.
14
+ - Commit wiki pages and web source files together on a session branch.
15
+ - Fast-forward publish committed clean sessions as `publisher` or `admin`.
16
+
17
+ Typical v2 MCP flow:
18
+
19
+ ```text
20
+ wiki_session_start
21
+ web_fetch
22
+ source_read with ref = session_id
23
+ wiki_session_patch with frontmatter.sources
24
+ wiki_session_validate
25
+ wiki_session_diff
26
+ wiki_session_commit
27
+ wiki_publish_session as publisher/admin
28
+ source_read from stable
29
+ ```
30
+
31
+ ## v1 Scope
32
+
33
+ v1 extends the v0 local git/worktree/session/validation/commit/MCP surface with document ingestion and stable publishing:
34
+
35
+ - Upload source document blobs into workspace state outside git. Supported input MIME types are `application/pdf`, `text/markdown`, `text/x-markdown`, and `text/plain`.
36
+ - Parse uploaded documents into session worktree files under `sources/<document_id>/`.
37
+ - Configure external command parsers that read document bytes from stdin and emit Markdown on stdout.
38
+ - Read source files from stable or from an active session ref.
39
+ - Validate optional wiki page `sources` frontmatter against parsed source IDs.
40
+ - Commit wiki pages and source files together on a session branch.
41
+ - Fast-forward publish committed clean sessions as `publisher` or `admin`.
42
+
43
+ Typical v1 MCP flow:
44
+
45
+ ```text
46
+ wiki_session_start
47
+ document_upload
48
+ document_parse
49
+ source_read with ref = session_id
50
+ wiki_session_patch with frontmatter.sources
51
+ wiki_session_validate
52
+ wiki_session_diff
53
+ wiki_session_commit
54
+ wiki_publish_session as publisher/admin
55
+ source_read from stable
56
+ ```
57
+
58
+ ## v0 Scope
59
+
60
+ v0 is the historical baseline that v1 builds on. Supported in v0:
61
+
62
+ - Initialize and inspect a local wiki workspace.
63
+ - Start an MCP server over stdio.
64
+ - Read stable wiki content.
65
+ - Run read-only VFS commands against stable content.
66
+ - Create isolated edit sessions.
67
+ - Replace Markdown pages in a session.
68
+ - Validate, diff, and commit session branches.
69
+ - Enforce reader and writer tool permissions.
70
+
71
+ Out of scope in v0:
72
+
73
+ - Publish and rollback tools.
74
+ - Search, document ingestion, web ingestion, and QA tools.
75
+ - Remote git or pull request integration.
76
+ - Web UI.
77
+
78
+ ## Quick Start
79
+
80
+ Install Bun first; the published CLI runs TypeScript directly with the `bun` runtime:
81
+
82
+ ```bash
83
+ curl -fsSL https://bun.sh/install | bash
84
+ ```
85
+
86
+ Install the CLI:
87
+
88
+ ```bash
89
+ bun add -g tgo-wiki
90
+ ```
91
+
92
+ After installation, the `tgo-wiki` command is available on your PATH:
93
+
94
+ ```bash
95
+ workspace="$HOME/.tgo-wiki/default"
96
+ tgo-wiki init --workspace "$workspace"
97
+ tgo-wiki status --workspace "$workspace"
98
+ tgo-wiki mcp --workspace "$workspace" --role reader
99
+ ```
100
+
101
+ `npm install -g tgo-wiki` also works when `bun` is already installed and available on PATH.
102
+
103
+ For one-off usage without a global install:
104
+
105
+ ```bash
106
+ bunx tgo-wiki status --workspace "$workspace"
107
+ ```
108
+
109
+ ## Source Checkout
110
+
111
+ Install dependencies from a source checkout:
112
+
113
+ ```bash
114
+ bun install --frozen-lockfile
115
+ ```
116
+
117
+ Run the release-readiness gate:
118
+
119
+ ```bash
120
+ bun run release:check
121
+ ```
122
+
123
+ Run the executable MCP stdio example:
124
+
125
+ ```bash
126
+ bun run example:mcp
127
+ ```
128
+
129
+ The example creates a temporary workspace, starts the MCP server, lists tools, reads `wiki/index.md`, runs a writer session flow, commits the session branch, and cleans up the temporary workspace.
130
+
131
+ Run the packaging smoke before handoff or release checks:
132
+
133
+ ```bash
134
+ bun run smoke:pack
135
+ ```
136
+
137
+ The packed smoke creates a tarball with `bun pm pack`, installs that tarball into a temporary consumer project, runs the installed `tgo-wiki` bin for `init` and `status`, starts MCP through the installed bin, and checks `initialize` plus `tools/list`.
138
+
139
+ For a faster local check without packing, run:
140
+
141
+ ```bash
142
+ bun run smoke:cli
143
+ ```
144
+
145
+ ## CLI
146
+
147
+ Create a wiki workspace:
148
+
149
+ ```bash
150
+ workspace="$(mktemp -d)"
151
+ tgo-wiki init --workspace "$workspace"
152
+ ```
153
+
154
+ Inspect workspace status:
155
+
156
+ ```bash
157
+ tgo-wiki status --workspace "$workspace"
158
+ ```
159
+
160
+ Start the MCP server as a reader:
161
+
162
+ ```bash
163
+ tgo-wiki mcp --workspace "$workspace" --role reader
164
+ ```
165
+
166
+ Start the MCP server as a writer:
167
+
168
+ ```bash
169
+ tgo-wiki mcp --workspace "$workspace" --role writer
170
+ ```
171
+
172
+ From a source checkout before publishing, replace `tgo-wiki` with `bun packages/server/src/cli.ts`.
173
+
174
+ ## MCP Tools
175
+
176
+ Reader tools:
177
+
178
+ - `vfs_exec`
179
+ - `wiki_read`
180
+ - `wiki_channel_status`
181
+ - `source_list`
182
+ - `source_read`
183
+
184
+ Writer tools:
185
+
186
+ - `wiki_session_start`
187
+ - `wiki_session_patch`
188
+ - `wiki_session_validate`
189
+ - `wiki_session_diff`
190
+ - `wiki_session_commit`
191
+ - `document_upload`
192
+ - `document_parse`
193
+
194
+ Publisher and admin tools:
195
+
196
+ - `web_fetch`
197
+ - `wiki_publish_session`
198
+
199
+ `web_fetch` rejects private, loopback, link-local, multicast, and reserved network targets by default. Workspace config can explicitly allow private hosts with `web.allowedPrivateHosts` when local or internal fixtures are intentional. `publisher` and `admin` roles can publish committed clean sessions. v0 did not expose publish or rollback behavior; see the v0 docs for that historical scope.
200
+
201
+ ## Documentation
202
+
203
+ - [MCP usage guide](docs/mcp-usage.md)
204
+ - [v2 acceptance gate](docs/v2-acceptance.md)
205
+ - [v1 acceptance gate](docs/v1-acceptance.md)
206
+ - [v0 acceptance gate](docs/v0-acceptance.md)
207
+ - [v0 delivery checklist](docs/v0-delivery-checklist.md)
208
+ - [Changelog](CHANGELOG.md)
209
+
210
+ ## Development
211
+
212
+ Default unit and integration checks:
213
+
214
+ ```bash
215
+ bun run check
216
+ ```
217
+
218
+ Independent black-box tests:
219
+
220
+ ```bash
221
+ bun run test:blackbox
222
+ ```
223
+
224
+ Full v0 verification:
225
+
226
+ ```bash
227
+ bun run verify:v0
228
+ ```
229
+
230
+ Full v1 verification:
231
+
232
+ ```bash
233
+ bun run verify:v1
234
+ ```
235
+
236
+ Full v2 verification:
237
+
238
+ ```bash
239
+ bun run verify:v2
240
+ ```
241
+
242
+ Release-readiness check:
243
+
244
+ ```bash
245
+ bun run release:check
246
+ ```
247
+
248
+ Packaging smoke commands:
249
+
250
+ ```bash
251
+ bun run smoke:pack
252
+ bun run smoke:cli
253
+ ```
254
+
255
+ GitHub Actions runs the default checks, black-box tests, and packed CLI smoke as separate jobs.