@first-tree-ai/context-tree 0.1.7-alpha.202609010710 → 0.1.7

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 (37) hide show
  1. package/README.md +35 -38
  2. package/dist/cli/index.mjs +923 -647
  3. package/package.json +7 -28
  4. package/scripts/postinstall.mjs +53 -0
  5. package/skills/context-tree-connect/SKILL.md +9 -7
  6. package/skills/context-tree-create/SKILL.md +10 -10
  7. package/skills/context-tree-publish/SKILL.md +4 -8
  8. package/skills/context-tree-read/SKILL.md +32 -12
  9. package/skills/context-tree-setup/SKILL.md +7 -12
  10. package/skills/context-tree-write/SKILL.md +196 -17
  11. package/.agents/plugins/marketplace.json +0 -19
  12. package/.claude-plugin/marketplace.json +0 -21
  13. package/.claude-plugin/plugin.json +0 -16
  14. package/.codex-plugin/plugin.json +0 -36
  15. package/dist/cli/index.d.mts +0 -1
  16. package/dist/index.d.mts +0 -77
  17. package/dist/index.mjs +0 -1449
  18. package/dist/schemas-C_7izpsa.d.mts +0 -390
  19. package/dist/schemas-DKHE1sWt.mjs +0 -289
  20. package/dist/schemas.d.mts +0 -2
  21. package/dist/schemas.mjs +0 -2
  22. package/docs/specification.md +0 -160
  23. package/examples/basic/NODE.md +0 -15
  24. package/examples/basic/members/NODE.md +0 -8
  25. package/examples/basic/members/example-agent/NODE.md +0 -7
  26. package/examples/basic/members/example-agent/memory.md +0 -9
  27. package/examples/basic/systems/NODE.md +0 -10
  28. package/examples/basic/systems/runtime.md +0 -15
  29. package/hooks/hooks.json +0 -26
  30. package/hooks/session-start.mjs +0 -55
  31. package/policy/context-tree-policy.md +0 -156
  32. package/skills/context-tree-connect/scripts/context-tree.mjs +0 -41
  33. package/skills/context-tree-create/scripts/context-tree.mjs +0 -41
  34. package/skills/context-tree-publish/scripts/context-tree.mjs +0 -41
  35. package/skills/context-tree-read/scripts/context-tree.mjs +0 -41
  36. package/skills/context-tree-setup/scripts/context-tree.mjs +0 -41
  37. package/skills/context-tree-write/scripts/context-tree.mjs +0 -41
@@ -1,390 +0,0 @@
1
- import { z } from "zod";
2
-
3
- //#region src/schemas.d.ts
4
- declare const SCHEMA_VERSION: 1;
5
- declare const CONTEXT_TREE_ROOT_NODE_MAX_BYTES: number;
6
- declare const VALIDATION_CODES: {
7
- readonly rootMissing: "TREE_ROOT_MISSING";
8
- readonly rootNodeInvalid: "TREE_ROOT_NODE_INVALID";
9
- readonly rootOnlyFields: "TREE_ROOT_ONLY_FIELDS";
10
- readonly directoryNodeMissing: "TREE_DIRECTORY_NODE_MISSING";
11
- readonly frontmatterMissing: "TREE_FRONTMATTER_MISSING";
12
- readonly frontmatterParse: "TREE_FRONTMATTER_PARSE";
13
- readonly titleMissing: "TREE_TITLE_MISSING";
14
- readonly titleInvalid: "TREE_TITLE_INVALID";
15
- readonly descriptionInvalid: "TREE_DESCRIPTION_INVALID";
16
- readonly softLinksInvalid: "TREE_SOFT_LINKS_INVALID";
17
- readonly softLinkBroken: "TREE_SOFT_LINK_BROKEN";
18
- readonly softLinkPathEscape: "TREE_SOFT_LINK_PATH_ESCAPE";
19
- readonly markdownPathEscape: "TREE_MARKDOWN_LINK_PATH_ESCAPE";
20
- readonly markdownFileSymlinkBroken: "TREE_MARKDOWN_FILE_SYMLINK_BROKEN";
21
- readonly markdownFileSymlinkUnsupported: "TREE_MARKDOWN_FILE_SYMLINK_UNSUPPORTED";
22
- readonly markdownFilePathEscape: "TREE_MARKDOWN_FILE_PATH_ESCAPE";
23
- readonly markdownFileContentClassMismatch: "TREE_MARKDOWN_FILE_CONTENT_CLASS_MISMATCH";
24
- readonly directorySymlinkUnsupported: "TREE_DIRECTORY_SYMLINK_UNSUPPORTED";
25
- readonly directorySymlinkPathEscape: "TREE_DIRECTORY_SYMLINK_PATH_ESCAPE";
26
- };
27
- declare const CLI_ERROR_CODES: {
28
- readonly corruptConnection: "CORRUPT_CONNECTION";
29
- readonly dirtyTree: "DIRTY_TREE";
30
- readonly failed: "CONTEXT_TREE_FAILED";
31
- readonly githubAuth: "GITHUB_AUTH";
32
- readonly invalidTree: "INVALID_TREE";
33
- readonly noConnection: "NO_CONNECTION";
34
- readonly publishIncomplete: "PUBLISH_INCOMPLETE";
35
- readonly repositoryExists: "REPOSITORY_EXISTS";
36
- readonly staleConnection: "STALE_CONNECTION";
37
- readonly writeOutdated: "WRITE_OUTDATED";
38
- };
39
- declare const credentialFreeRepositoryUrlSchema: z.ZodString;
40
- declare const treeNameSchema: z.ZodString;
41
- declare const githubRepositoryIdentitySchema: z.ZodString;
42
- declare const contextTreeRootNodeFrontmatterSchema: z.ZodObject<{
43
- schemaVersion: z.ZodLiteral<1>;
44
- title: z.ZodString;
45
- description: z.ZodOptional<z.ZodString>;
46
- soft_links: z.ZodOptional<z.ZodArray<z.ZodString>>;
47
- }, z.core.$loose>;
48
- declare const contextTreeRootNodeSchema: z.ZodObject<{
49
- frontmatter: z.ZodObject<{
50
- schemaVersion: z.ZodLiteral<1>;
51
- title: z.ZodString;
52
- description: z.ZodOptional<z.ZodString>;
53
- soft_links: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
- }, z.core.$loose>;
55
- body: z.ZodString;
56
- }, z.core.$strip>;
57
- type ContextTreeRootNode = z.infer<typeof contextTreeRootNodeSchema>;
58
- declare function parseContextTreeRootNode(markdown: string): ContextTreeRootNode;
59
- declare const contextContentClassSchema: z.ZodEnum<{
60
- normal: "normal";
61
- member: "member";
62
- "repo-infra": "repo-infra";
63
- }>;
64
- type ContextContentClass = z.infer<typeof contextContentClassSchema>;
65
- declare const validationCodeSchema: z.ZodEnum<{
66
- readonly rootMissing: "TREE_ROOT_MISSING";
67
- readonly rootNodeInvalid: "TREE_ROOT_NODE_INVALID";
68
- readonly rootOnlyFields: "TREE_ROOT_ONLY_FIELDS";
69
- readonly directoryNodeMissing: "TREE_DIRECTORY_NODE_MISSING";
70
- readonly frontmatterMissing: "TREE_FRONTMATTER_MISSING";
71
- readonly frontmatterParse: "TREE_FRONTMATTER_PARSE";
72
- readonly titleMissing: "TREE_TITLE_MISSING";
73
- readonly titleInvalid: "TREE_TITLE_INVALID";
74
- readonly descriptionInvalid: "TREE_DESCRIPTION_INVALID";
75
- readonly softLinksInvalid: "TREE_SOFT_LINKS_INVALID";
76
- readonly softLinkBroken: "TREE_SOFT_LINK_BROKEN";
77
- readonly softLinkPathEscape: "TREE_SOFT_LINK_PATH_ESCAPE";
78
- readonly markdownPathEscape: "TREE_MARKDOWN_LINK_PATH_ESCAPE";
79
- readonly markdownFileSymlinkBroken: "TREE_MARKDOWN_FILE_SYMLINK_BROKEN";
80
- readonly markdownFileSymlinkUnsupported: "TREE_MARKDOWN_FILE_SYMLINK_UNSUPPORTED";
81
- readonly markdownFilePathEscape: "TREE_MARKDOWN_FILE_PATH_ESCAPE";
82
- readonly markdownFileContentClassMismatch: "TREE_MARKDOWN_FILE_CONTENT_CLASS_MISMATCH";
83
- readonly directorySymlinkUnsupported: "TREE_DIRECTORY_SYMLINK_UNSUPPORTED";
84
- readonly directorySymlinkPathEscape: "TREE_DIRECTORY_SYMLINK_PATH_ESCAPE";
85
- }>;
86
- type ValidationCode = z.infer<typeof validationCodeSchema>;
87
- declare const treeValidationFindingSchema: z.ZodObject<{
88
- code: z.ZodEnum<{
89
- readonly rootMissing: "TREE_ROOT_MISSING";
90
- readonly rootNodeInvalid: "TREE_ROOT_NODE_INVALID";
91
- readonly rootOnlyFields: "TREE_ROOT_ONLY_FIELDS";
92
- readonly directoryNodeMissing: "TREE_DIRECTORY_NODE_MISSING";
93
- readonly frontmatterMissing: "TREE_FRONTMATTER_MISSING";
94
- readonly frontmatterParse: "TREE_FRONTMATTER_PARSE";
95
- readonly titleMissing: "TREE_TITLE_MISSING";
96
- readonly titleInvalid: "TREE_TITLE_INVALID";
97
- readonly descriptionInvalid: "TREE_DESCRIPTION_INVALID";
98
- readonly softLinksInvalid: "TREE_SOFT_LINKS_INVALID";
99
- readonly softLinkBroken: "TREE_SOFT_LINK_BROKEN";
100
- readonly softLinkPathEscape: "TREE_SOFT_LINK_PATH_ESCAPE";
101
- readonly markdownPathEscape: "TREE_MARKDOWN_LINK_PATH_ESCAPE";
102
- readonly markdownFileSymlinkBroken: "TREE_MARKDOWN_FILE_SYMLINK_BROKEN";
103
- readonly markdownFileSymlinkUnsupported: "TREE_MARKDOWN_FILE_SYMLINK_UNSUPPORTED";
104
- readonly markdownFilePathEscape: "TREE_MARKDOWN_FILE_PATH_ESCAPE";
105
- readonly markdownFileContentClassMismatch: "TREE_MARKDOWN_FILE_CONTENT_CLASS_MISMATCH";
106
- readonly directorySymlinkUnsupported: "TREE_DIRECTORY_SYMLINK_UNSUPPORTED";
107
- readonly directorySymlinkPathEscape: "TREE_DIRECTORY_SYMLINK_PATH_ESCAPE";
108
- }>;
109
- message: z.ZodString;
110
- path: z.ZodString;
111
- target: z.ZodOptional<z.ZodString>;
112
- }, z.core.$strict>;
113
- type TreeValidationFinding = z.infer<typeof treeValidationFindingSchema>;
114
- declare const contextContentClassCountsSchema: z.ZodObject<{
115
- normal: z.ZodNumber;
116
- member: z.ZodNumber;
117
- "repo-infra": z.ZodNumber;
118
- }, z.core.$strict>;
119
- type ContextContentClassCounts = z.infer<typeof contextContentClassCountsSchema>;
120
- declare const contextTreePolicySchema: z.ZodObject<{
121
- content: z.ZodString;
122
- schemaVersion: z.ZodLiteral<1>;
123
- }, z.core.$strict>;
124
- type ContextTreePolicy = z.infer<typeof contextTreePolicySchema>;
125
- declare const contextTreeReadNodeSchema: z.ZodObject<{
126
- contentClass: z.ZodEnum<{
127
- normal: "normal";
128
- member: "member";
129
- "repo-infra": "repo-infra";
130
- }>;
131
- kind: z.ZodEnum<{
132
- file: "file";
133
- directory: "directory";
134
- }>;
135
- path: z.ZodString;
136
- body: z.ZodString;
137
- frontmatter: z.ZodRecord<z.ZodString, z.ZodUnknown>;
138
- }, z.core.$strict>;
139
- type ContextTreeReadNode = z.infer<typeof contextTreeReadNodeSchema>;
140
- declare const contextTreeReadChildSchema: z.ZodObject<{
141
- contentClass: z.ZodEnum<{
142
- normal: "normal";
143
- member: "member";
144
- "repo-infra": "repo-infra";
145
- }>;
146
- kind: z.ZodEnum<{
147
- file: "file";
148
- directory: "directory";
149
- }>;
150
- path: z.ZodString;
151
- description: z.ZodOptional<z.ZodString>;
152
- title: z.ZodString;
153
- }, z.core.$strict>;
154
- type ContextTreeReadChild = z.infer<typeof contextTreeReadChildSchema>;
155
- declare const contextTreeReadResultSchema: z.ZodObject<{
156
- children: z.ZodArray<z.ZodObject<{
157
- contentClass: z.ZodEnum<{
158
- normal: "normal";
159
- member: "member";
160
- "repo-infra": "repo-infra";
161
- }>;
162
- kind: z.ZodEnum<{
163
- file: "file";
164
- directory: "directory";
165
- }>;
166
- path: z.ZodString;
167
- description: z.ZodOptional<z.ZodString>;
168
- title: z.ZodString;
169
- }, z.core.$strict>>;
170
- node: z.ZodObject<{
171
- contentClass: z.ZodEnum<{
172
- normal: "normal";
173
- member: "member";
174
- "repo-infra": "repo-infra";
175
- }>;
176
- kind: z.ZodEnum<{
177
- file: "file";
178
- directory: "directory";
179
- }>;
180
- path: z.ZodString;
181
- body: z.ZodString;
182
- frontmatter: z.ZodRecord<z.ZodString, z.ZodUnknown>;
183
- }, z.core.$strict>;
184
- root: z.ZodString;
185
- schemaVersion: z.ZodLiteral<1>;
186
- target: z.ZodString;
187
- }, z.core.$strict>;
188
- type ContextTreeReadResult = z.infer<typeof contextTreeReadResultSchema>;
189
- declare const verifyTreeReportSchema: z.ZodObject<{
190
- findings: z.ZodArray<z.ZodObject<{
191
- code: z.ZodEnum<{
192
- readonly rootMissing: "TREE_ROOT_MISSING";
193
- readonly rootNodeInvalid: "TREE_ROOT_NODE_INVALID";
194
- readonly rootOnlyFields: "TREE_ROOT_ONLY_FIELDS";
195
- readonly directoryNodeMissing: "TREE_DIRECTORY_NODE_MISSING";
196
- readonly frontmatterMissing: "TREE_FRONTMATTER_MISSING";
197
- readonly frontmatterParse: "TREE_FRONTMATTER_PARSE";
198
- readonly titleMissing: "TREE_TITLE_MISSING";
199
- readonly titleInvalid: "TREE_TITLE_INVALID";
200
- readonly descriptionInvalid: "TREE_DESCRIPTION_INVALID";
201
- readonly softLinksInvalid: "TREE_SOFT_LINKS_INVALID";
202
- readonly softLinkBroken: "TREE_SOFT_LINK_BROKEN";
203
- readonly softLinkPathEscape: "TREE_SOFT_LINK_PATH_ESCAPE";
204
- readonly markdownPathEscape: "TREE_MARKDOWN_LINK_PATH_ESCAPE";
205
- readonly markdownFileSymlinkBroken: "TREE_MARKDOWN_FILE_SYMLINK_BROKEN";
206
- readonly markdownFileSymlinkUnsupported: "TREE_MARKDOWN_FILE_SYMLINK_UNSUPPORTED";
207
- readonly markdownFilePathEscape: "TREE_MARKDOWN_FILE_PATH_ESCAPE";
208
- readonly markdownFileContentClassMismatch: "TREE_MARKDOWN_FILE_CONTENT_CLASS_MISMATCH";
209
- readonly directorySymlinkUnsupported: "TREE_DIRECTORY_SYMLINK_UNSUPPORTED";
210
- readonly directorySymlinkPathEscape: "TREE_DIRECTORY_SYMLINK_PATH_ESCAPE";
211
- }>;
212
- message: z.ZodString;
213
- path: z.ZodString;
214
- target: z.ZodOptional<z.ZodString>;
215
- }, z.core.$strict>>;
216
- ok: z.ZodBoolean;
217
- root: z.ZodString;
218
- scannedByContentClass: z.ZodObject<{
219
- normal: z.ZodNumber;
220
- member: z.ZodNumber;
221
- "repo-infra": z.ZodNumber;
222
- }, z.core.$strict>;
223
- schemaVersion: z.ZodLiteral<1>;
224
- }, z.core.$strict>;
225
- type VerifyTreeReport = z.infer<typeof verifyTreeReportSchema>;
226
- declare const contextTreeStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
227
- kind: z.ZodLiteral<"local">;
228
- path: z.ZodString;
229
- }, z.core.$strict>, z.ZodObject<{
230
- kind: z.ZodLiteral<"github">;
231
- path: z.ZodString;
232
- repository: z.ZodString;
233
- }, z.core.$strict>], "kind">;
234
- type ContextTreeState = z.infer<typeof contextTreeStateSchema>;
235
- declare const contextTreeConnectionSchema: z.ZodObject<{
236
- projectPath: z.ZodString;
237
- tree: z.ZodDiscriminatedUnion<[z.ZodObject<{
238
- kind: z.ZodLiteral<"local">;
239
- path: z.ZodString;
240
- }, z.core.$strict>, z.ZodObject<{
241
- kind: z.ZodLiteral<"github">;
242
- path: z.ZodString;
243
- repository: z.ZodString;
244
- }, z.core.$strict>], "kind">;
245
- }, z.core.$strict>;
246
- type ContextTreeConnection = z.infer<typeof contextTreeConnectionSchema>;
247
- declare const contextTreeConnectionResultSchema: z.ZodObject<{
248
- schemaVersion: z.ZodLiteral<1>;
249
- tree: z.ZodDiscriminatedUnion<[z.ZodObject<{
250
- kind: z.ZodLiteral<"local">;
251
- path: z.ZodString;
252
- }, z.core.$strict>, z.ZodObject<{
253
- kind: z.ZodLiteral<"github">;
254
- path: z.ZodString;
255
- repository: z.ZodString;
256
- }, z.core.$strict>], "kind">;
257
- }, z.core.$strict>;
258
- type ContextTreeConnectionResult = z.infer<typeof contextTreeConnectionResultSchema>;
259
- declare const createProjectResultSchema: z.ZodObject<{
260
- branch: z.ZodString;
261
- commitSha: z.ZodString;
262
- created: z.ZodBoolean;
263
- schemaVersion: z.ZodLiteral<1>;
264
- title: z.ZodString;
265
- treePath: z.ZodString;
266
- }, z.core.$strict>;
267
- type CreateProjectResult = z.infer<typeof createProjectResultSchema>;
268
- declare const connectProjectResultSchema: z.ZodObject<{
269
- schemaVersion: z.ZodLiteral<1>;
270
- tree: z.ZodDiscriminatedUnion<[z.ZodObject<{
271
- kind: z.ZodLiteral<"local">;
272
- path: z.ZodString;
273
- }, z.core.$strict>, z.ZodObject<{
274
- kind: z.ZodLiteral<"github">;
275
- path: z.ZodString;
276
- repository: z.ZodString;
277
- }, z.core.$strict>], "kind">;
278
- }, z.core.$strict>;
279
- type ConnectProjectResult = z.infer<typeof connectProjectResultSchema>;
280
- declare const managedTreeListingEntrySchema: z.ZodObject<{
281
- name: z.ZodString;
282
- tree: z.ZodDiscriminatedUnion<[z.ZodObject<{
283
- kind: z.ZodLiteral<"local">;
284
- path: z.ZodString;
285
- }, z.core.$strict>, z.ZodObject<{
286
- kind: z.ZodLiteral<"github">;
287
- path: z.ZodString;
288
- repository: z.ZodString;
289
- }, z.core.$strict>], "kind">;
290
- }, z.core.$strict>;
291
- type ManagedTreeListingEntry = z.infer<typeof managedTreeListingEntrySchema>;
292
- declare const managedTreeListingResultSchema: z.ZodObject<{
293
- schemaVersion: z.ZodLiteral<1>;
294
- trees: z.ZodArray<z.ZodObject<{
295
- name: z.ZodString;
296
- tree: z.ZodDiscriminatedUnion<[z.ZodObject<{
297
- kind: z.ZodLiteral<"local">;
298
- path: z.ZodString;
299
- }, z.core.$strict>, z.ZodObject<{
300
- kind: z.ZodLiteral<"github">;
301
- path: z.ZodString;
302
- repository: z.ZodString;
303
- }, z.core.$strict>], "kind">;
304
- }, z.core.$strict>>;
305
- }, z.core.$strict>;
306
- type ManagedTreeListingResult = z.infer<typeof managedTreeListingResultSchema>;
307
- declare const contextTreeSyncResultSchema: z.ZodObject<{
308
- branch: z.ZodString;
309
- schemaVersion: z.ZodLiteral<1>;
310
- sha: z.ZodString;
311
- tree: z.ZodDiscriminatedUnion<[z.ZodObject<{
312
- kind: z.ZodLiteral<"local">;
313
- path: z.ZodString;
314
- }, z.core.$strict>, z.ZodObject<{
315
- kind: z.ZodLiteral<"github">;
316
- path: z.ZodString;
317
- repository: z.ZodString;
318
- }, z.core.$strict>], "kind">;
319
- }, z.core.$strict>;
320
- type ContextTreeSyncResult = z.infer<typeof contextTreeSyncResultSchema>;
321
- declare const prepareContextWriteResultSchema: z.ZodObject<{
322
- schemaVersion: z.ZodLiteral<1>;
323
- worktreePath: z.ZodString;
324
- }, z.core.$strict>;
325
- type PrepareContextWriteResult = z.infer<typeof prepareContextWriteResultSchema>;
326
- declare const finishContextWriteResultSchema: z.ZodObject<{
327
- branch: z.ZodString;
328
- schemaVersion: z.ZodLiteral<1>;
329
- sha: z.ZodString;
330
- }, z.core.$strict>;
331
- type FinishContextWriteResult = z.infer<typeof finishContextWriteResultSchema>;
332
- declare const contextTreePublishResultSchema: z.ZodObject<{
333
- branch: z.ZodString;
334
- repository: z.ZodString;
335
- schemaVersion: z.ZodLiteral<1>;
336
- sha: z.ZodString;
337
- url: z.ZodString;
338
- }, z.core.$strict>;
339
- type ContextTreePublishResult = z.infer<typeof contextTreePublishResultSchema>;
340
- declare const contextTreeCliErrorCodeSchema: z.ZodEnum<{
341
- readonly corruptConnection: "CORRUPT_CONNECTION";
342
- readonly dirtyTree: "DIRTY_TREE";
343
- readonly failed: "CONTEXT_TREE_FAILED";
344
- readonly githubAuth: "GITHUB_AUTH";
345
- readonly invalidTree: "INVALID_TREE";
346
- readonly noConnection: "NO_CONNECTION";
347
- readonly publishIncomplete: "PUBLISH_INCOMPLETE";
348
- readonly repositoryExists: "REPOSITORY_EXISTS";
349
- readonly staleConnection: "STALE_CONNECTION";
350
- readonly writeOutdated: "WRITE_OUTDATED";
351
- }>;
352
- type ContextTreeCliErrorCode = z.infer<typeof contextTreeCliErrorCodeSchema>;
353
- declare const contextTreeCliErrorSchema: z.ZodObject<{
354
- code: z.ZodEnum<{
355
- readonly corruptConnection: "CORRUPT_CONNECTION";
356
- readonly dirtyTree: "DIRTY_TREE";
357
- readonly failed: "CONTEXT_TREE_FAILED";
358
- readonly githubAuth: "GITHUB_AUTH";
359
- readonly invalidTree: "INVALID_TREE";
360
- readonly noConnection: "NO_CONNECTION";
361
- readonly publishIncomplete: "PUBLISH_INCOMPLETE";
362
- readonly repositoryExists: "REPOSITORY_EXISTS";
363
- readonly staleConnection: "STALE_CONNECTION";
364
- readonly writeOutdated: "WRITE_OUTDATED";
365
- }>;
366
- message: z.ZodString;
367
- }, z.core.$strict>;
368
- type ContextTreeCliError = z.infer<typeof contextTreeCliErrorSchema>;
369
- declare const contextTreeCliErrorEnvelopeSchema: z.ZodObject<{
370
- error: z.ZodObject<{
371
- code: z.ZodEnum<{
372
- readonly corruptConnection: "CORRUPT_CONNECTION";
373
- readonly dirtyTree: "DIRTY_TREE";
374
- readonly failed: "CONTEXT_TREE_FAILED";
375
- readonly githubAuth: "GITHUB_AUTH";
376
- readonly invalidTree: "INVALID_TREE";
377
- readonly noConnection: "NO_CONNECTION";
378
- readonly publishIncomplete: "PUBLISH_INCOMPLETE";
379
- readonly repositoryExists: "REPOSITORY_EXISTS";
380
- readonly staleConnection: "STALE_CONNECTION";
381
- readonly writeOutdated: "WRITE_OUTDATED";
382
- }>;
383
- message: z.ZodString;
384
- }, z.core.$strict>;
385
- ok: z.ZodLiteral<false>;
386
- schemaVersion: z.ZodLiteral<1>;
387
- }, z.core.$strict>;
388
- type ContextTreeCliErrorEnvelope = z.infer<typeof contextTreeCliErrorEnvelopeSchema>;
389
- //#endregion
390
- export { prepareContextWriteResultSchema as $, contextContentClassCountsSchema as A, contextTreeReadNodeSchema as B, PrepareContextWriteResult as C, ValidationCode as D, VALIDATION_CODES as E, contextTreeConnectionResultSchema as F, contextTreeSyncResultSchema as G, contextTreeRootNodeFrontmatterSchema as H, contextTreeConnectionSchema as I, finishContextWriteResultSchema as J, createProjectResultSchema as K, contextTreePolicySchema as L, contextTreeCliErrorCodeSchema as M, contextTreeCliErrorEnvelopeSchema as N, VerifyTreeReport as O, contextTreeCliErrorSchema as P, parseContextTreeRootNode as Q, contextTreePublishResultSchema as R, ManagedTreeListingResult as S, TreeValidationFinding as T, contextTreeRootNodeSchema as U, contextTreeReadResultSchema as V, contextTreeStateSchema as W, managedTreeListingEntrySchema as X, githubRepositoryIdentitySchema as Y, managedTreeListingResultSchema as Z, ContextTreeState as _, ContextContentClassCounts as a, FinishContextWriteResult as b, ContextTreeCliErrorEnvelope as c, ContextTreePolicy as d, treeNameSchema as et, ContextTreePublishResult as f, ContextTreeRootNode as g, ContextTreeReadResult as h, ContextContentClass as i, contextContentClassSchema as j, connectProjectResultSchema as k, ContextTreeConnection as l, ContextTreeReadNode as m, CONTEXT_TREE_ROOT_NODE_MAX_BYTES as n, validationCodeSchema as nt, ContextTreeCliError as o, ContextTreeReadChild as p, credentialFreeRepositoryUrlSchema as q, ConnectProjectResult as r, verifyTreeReportSchema as rt, ContextTreeCliErrorCode as s, CLI_ERROR_CODES as t, treeValidationFindingSchema as tt, ContextTreeConnectionResult as u, ContextTreeSyncResult as v, SCHEMA_VERSION as w, ManagedTreeListingEntry as x, CreateProjectResult as y, contextTreeReadChildSchema as z };
@@ -1,289 +0,0 @@
1
- import { isAbsolute } from "node:path";
2
- import { z } from "zod";
3
- import { parse as parse$1 } from "yaml";
4
- //#region src/internal/value.ts
5
- function isRecord(value) {
6
- return typeof value === "object" && value !== null && !Array.isArray(value);
7
- }
8
- //#endregion
9
- //#region src/internal/frontmatter.ts
10
- function parseYamlMapping(source) {
11
- const value = parse$1(source);
12
- if (!isRecord(value)) throw new Error("frontmatter must be a YAML mapping");
13
- return value;
14
- }
15
- function readLine(source, start) {
16
- const newline = source.indexOf("\n", start);
17
- const end = newline === -1 ? source.length : newline + 1;
18
- const contentEnd = newline === -1 ? source.length : source.charCodeAt(newline - 1) === 13 ? newline - 1 : newline;
19
- return {
20
- end,
21
- start,
22
- value: source.slice(start, contentEnd)
23
- };
24
- }
25
- function parseMarkdownFrontmatter(source) {
26
- const opening = readLine(source, 0);
27
- if (opening.value !== "---") return {
28
- body: source,
29
- data: null,
30
- frontmatter: "missing"
31
- };
32
- let closing;
33
- let lineStart = opening.end;
34
- while (lineStart < source.length) {
35
- const line = readLine(source, lineStart);
36
- if (line.value === "---") {
37
- closing = line;
38
- break;
39
- }
40
- lineStart = line.end;
41
- }
42
- if (closing === void 0) return {
43
- body: "",
44
- data: null,
45
- error: "frontmatter closing delimiter is missing",
46
- frontmatter: "invalid"
47
- };
48
- const body = source.slice(closing.end);
49
- try {
50
- return {
51
- body,
52
- data: parseYamlMapping(source.slice(opening.end, closing.start)),
53
- frontmatter: "valid"
54
- };
55
- } catch (error) {
56
- return {
57
- body,
58
- data: null,
59
- error: error instanceof Error ? error.message : String(error),
60
- frontmatter: "invalid"
61
- };
62
- }
63
- }
64
- //#endregion
65
- //#region src/schemas.ts
66
- const SCHEMA_VERSION = 1;
67
- const CONTEXT_TREE_ROOT_NODE_MAX_BYTES = 16 * 1024;
68
- const VALIDATION_CODES = {
69
- rootMissing: "TREE_ROOT_MISSING",
70
- rootNodeInvalid: "TREE_ROOT_NODE_INVALID",
71
- rootOnlyFields: "TREE_ROOT_ONLY_FIELDS",
72
- directoryNodeMissing: "TREE_DIRECTORY_NODE_MISSING",
73
- frontmatterMissing: "TREE_FRONTMATTER_MISSING",
74
- frontmatterParse: "TREE_FRONTMATTER_PARSE",
75
- titleMissing: "TREE_TITLE_MISSING",
76
- titleInvalid: "TREE_TITLE_INVALID",
77
- descriptionInvalid: "TREE_DESCRIPTION_INVALID",
78
- softLinksInvalid: "TREE_SOFT_LINKS_INVALID",
79
- softLinkBroken: "TREE_SOFT_LINK_BROKEN",
80
- softLinkPathEscape: "TREE_SOFT_LINK_PATH_ESCAPE",
81
- markdownPathEscape: "TREE_MARKDOWN_LINK_PATH_ESCAPE",
82
- markdownFileSymlinkBroken: "TREE_MARKDOWN_FILE_SYMLINK_BROKEN",
83
- markdownFileSymlinkUnsupported: "TREE_MARKDOWN_FILE_SYMLINK_UNSUPPORTED",
84
- markdownFilePathEscape: "TREE_MARKDOWN_FILE_PATH_ESCAPE",
85
- markdownFileContentClassMismatch: "TREE_MARKDOWN_FILE_CONTENT_CLASS_MISMATCH",
86
- directorySymlinkUnsupported: "TREE_DIRECTORY_SYMLINK_UNSUPPORTED",
87
- directorySymlinkPathEscape: "TREE_DIRECTORY_SYMLINK_PATH_ESCAPE"
88
- };
89
- const CLI_ERROR_CODES = {
90
- corruptConnection: "CORRUPT_CONNECTION",
91
- dirtyTree: "DIRTY_TREE",
92
- failed: "CONTEXT_TREE_FAILED",
93
- githubAuth: "GITHUB_AUTH",
94
- invalidTree: "INVALID_TREE",
95
- noConnection: "NO_CONNECTION",
96
- publishIncomplete: "PUBLISH_INCOMPLETE",
97
- repositoryExists: "REPOSITORY_EXISTS",
98
- staleConnection: "STALE_CONNECTION",
99
- writeOutdated: "WRITE_OUTDATED"
100
- };
101
- function hasUnsafeCharacter(value) {
102
- return [...value].some((character) => {
103
- const code = character.codePointAt(0);
104
- return code !== void 0 && (code <= 31 || code === 127 || code === 8232 || code === 8233);
105
- });
106
- }
107
- const absoluteSingleLinePathSchema = z.string().superRefine((value, context) => {
108
- if (!isAbsolute(value) || value.trim() !== value || hasUnsafeCharacter(value)) context.addIssue({
109
- code: "custom",
110
- message: "Paths must be absolute single-line values."
111
- });
112
- });
113
- const credentialFreeRepositoryUrlSchema = z.string().superRefine((value, context) => {
114
- if (value.trim() !== value || hasUnsafeCharacter(value) || value.includes("\\")) {
115
- context.addIssue({
116
- code: "custom",
117
- message: "Repository URLs must be canonical single-line values."
118
- });
119
- return;
120
- }
121
- if (value.includes("?") || value.includes("#")) {
122
- context.addIssue({
123
- code: "custom",
124
- message: "Repository URLs must not contain a query or fragment."
125
- });
126
- return;
127
- }
128
- if (/^(?:[a-z\d._-]+@)?[a-z\d.-]+:[^\s/][^\s]*$/iu.test(value)) return;
129
- try {
130
- const parsed = new URL(value);
131
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:" && parsed.protocol !== "ssh:" || !parsed.hostname || parsed.pathname.split("/").every((part) => part.length === 0) || parsed.password || (parsed.protocol === "http:" || parsed.protocol === "https:") && parsed.username) throw new Error("invalid transport");
132
- } catch {
133
- context.addIssue({
134
- code: "custom",
135
- message: "Repository URLs must use credential-free HTTP(S), ssh://, or scp-like SSH syntax."
136
- });
137
- }
138
- });
139
- const treeNameSchema = z.string().superRefine((value, context) => {
140
- if (!/^[A-Za-z\d][A-Za-z\d._-]{0,99}$/u.test(value) || /\.git$/iu.test(value)) context.addIssue({
141
- code: "custom",
142
- message: "Tree name must be a safe single path segment."
143
- });
144
- });
145
- const githubRepositoryIdentitySchema = z.string().superRefine((value, context) => {
146
- const parts = value.split("/");
147
- const [owner, name] = parts;
148
- if (parts.length !== 2 || owner === void 0 || name === void 0 || !/^[A-Za-z\d](?:[A-Za-z\d-]{0,37}[A-Za-z\d])?$/u.test(owner) || !treeNameSchema.safeParse(name).success) context.addIssue({
149
- code: "custom",
150
- message: "Repository must be an explicit GitHub OWNER/REPO identity."
151
- });
152
- });
153
- const contextTreeRootNodeFrontmatterSchema = z.object({
154
- schemaVersion: z.literal(1),
155
- title: z.string().trim().min(1),
156
- description: z.string().trim().min(1).optional(),
157
- soft_links: z.array(z.string().trim().min(1)).min(1).optional()
158
- }).loose();
159
- const contextTreeRootNodeSchema = z.object({
160
- frontmatter: contextTreeRootNodeFrontmatterSchema,
161
- body: z.string().trim().min(1, "Root NODE.md must contain repository-wide context.")
162
- });
163
- function parseContextTreeRootNode(markdown) {
164
- if (Buffer.byteLength(markdown, "utf8") > 16384) throw new Error(`Root NODE.md exceeds the ${CONTEXT_TREE_ROOT_NODE_MAX_BYTES}-byte limit.`);
165
- const document = parseMarkdownFrontmatter(markdown);
166
- if (document.frontmatter === "missing") throw new Error("Root NODE.md must contain YAML frontmatter.");
167
- if (document.frontmatter === "invalid") throw new Error(`Root NODE.md frontmatter is invalid: ${document.error}`);
168
- return contextTreeRootNodeSchema.parse({
169
- frontmatter: document.data,
170
- body: document.body
171
- });
172
- }
173
- const contextContentClassSchema = z.enum([
174
- "normal",
175
- "member",
176
- "repo-infra"
177
- ]);
178
- const validationCodeSchema = z.enum(VALIDATION_CODES);
179
- const treeValidationFindingSchema = z.object({
180
- code: validationCodeSchema,
181
- message: z.string(),
182
- path: z.string(),
183
- target: z.string().optional()
184
- }).strict();
185
- const contextContentClassCountsSchema = z.object({
186
- normal: z.number().int().nonnegative(),
187
- member: z.number().int().nonnegative(),
188
- "repo-infra": z.number().int().nonnegative()
189
- }).strict();
190
- const contextTreePolicySchema = z.object({
191
- content: z.string(),
192
- schemaVersion: z.literal(1)
193
- }).strict();
194
- const contextTreeReadCommonFields = {
195
- contentClass: contextContentClassSchema,
196
- kind: z.enum(["directory", "file"]),
197
- path: z.string()
198
- };
199
- const contextTreeReadNodeSchema = z.object({
200
- body: z.string(),
201
- frontmatter: z.record(z.string(), z.unknown()),
202
- ...contextTreeReadCommonFields
203
- }).strict();
204
- const contextTreeReadChildSchema = z.object({
205
- description: z.string().optional(),
206
- title: z.string(),
207
- ...contextTreeReadCommonFields
208
- }).strict();
209
- const contextTreeReadResultSchema = z.object({
210
- children: z.array(contextTreeReadChildSchema),
211
- node: contextTreeReadNodeSchema,
212
- root: z.string(),
213
- schemaVersion: z.literal(1),
214
- target: z.string()
215
- }).strict();
216
- const verifyTreeReportSchema = z.object({
217
- findings: z.array(treeValidationFindingSchema),
218
- ok: z.boolean(),
219
- root: z.string(),
220
- scannedByContentClass: contextContentClassCountsSchema,
221
- schemaVersion: z.literal(1)
222
- }).strict();
223
- const contextTreeStateSchema = z.discriminatedUnion("kind", [z.object({
224
- kind: z.literal("local"),
225
- path: absoluteSingleLinePathSchema
226
- }).strict(), z.object({
227
- kind: z.literal("github"),
228
- path: absoluteSingleLinePathSchema,
229
- repository: githubRepositoryIdentitySchema
230
- }).strict()]);
231
- const contextTreeConnectionSchema = z.object({
232
- projectPath: absoluteSingleLinePathSchema,
233
- tree: contextTreeStateSchema
234
- }).strict();
235
- const contextTreeConnectionResultSchema = z.object({
236
- schemaVersion: z.literal(1),
237
- tree: contextTreeStateSchema
238
- }).strict();
239
- const createProjectResultSchema = z.object({
240
- branch: z.string().trim().min(1),
241
- commitSha: z.string(),
242
- created: z.boolean(),
243
- schemaVersion: z.literal(1),
244
- title: z.string().trim().min(1),
245
- treePath: absoluteSingleLinePathSchema
246
- }).strict();
247
- const connectProjectResultSchema = contextTreeConnectionResultSchema;
248
- const managedTreeListingEntrySchema = z.object({
249
- name: treeNameSchema,
250
- tree: contextTreeStateSchema
251
- }).strict();
252
- const managedTreeListingResultSchema = z.object({
253
- schemaVersion: z.literal(1),
254
- trees: z.array(managedTreeListingEntrySchema)
255
- }).strict();
256
- const contextTreeSyncResultSchema = z.object({
257
- branch: z.string().trim().min(1),
258
- schemaVersion: z.literal(1),
259
- sha: z.string(),
260
- tree: contextTreeStateSchema
261
- }).strict();
262
- const prepareContextWriteResultSchema = z.object({
263
- schemaVersion: z.literal(1),
264
- worktreePath: absoluteSingleLinePathSchema
265
- }).strict();
266
- const finishContextWriteResultSchema = z.object({
267
- branch: z.string().trim().min(1),
268
- schemaVersion: z.literal(1),
269
- sha: z.string()
270
- }).strict();
271
- const contextTreePublishResultSchema = z.object({
272
- branch: z.string().trim().min(1),
273
- repository: githubRepositoryIdentitySchema,
274
- schemaVersion: z.literal(1),
275
- sha: z.string(),
276
- url: credentialFreeRepositoryUrlSchema
277
- }).strict();
278
- const contextTreeCliErrorCodeSchema = z.enum(CLI_ERROR_CODES);
279
- const contextTreeCliErrorSchema = z.object({
280
- code: contextTreeCliErrorCodeSchema,
281
- message: z.string()
282
- }).strict();
283
- const contextTreeCliErrorEnvelopeSchema = z.object({
284
- error: contextTreeCliErrorSchema,
285
- ok: z.literal(false),
286
- schemaVersion: z.literal(1)
287
- }).strict();
288
- //#endregion
289
- export { treeNameSchema as A, credentialFreeRepositoryUrlSchema as C, managedTreeListingResultSchema as D, managedTreeListingEntrySchema as E, isRecord as F, validationCodeSchema as M, verifyTreeReportSchema as N, parseContextTreeRootNode as O, parseMarkdownFrontmatter as P, createProjectResultSchema as S, githubRepositoryIdentitySchema as T, contextTreeReadResultSchema as _, connectProjectResultSchema as a, contextTreeStateSchema as b, contextTreeCliErrorCodeSchema as c, contextTreeConnectionResultSchema as d, contextTreeConnectionSchema as f, contextTreeReadNodeSchema as g, contextTreeReadChildSchema as h, VALIDATION_CODES as i, treeValidationFindingSchema as j, prepareContextWriteResultSchema as k, contextTreeCliErrorEnvelopeSchema as l, contextTreePublishResultSchema as m, CONTEXT_TREE_ROOT_NODE_MAX_BYTES as n, contextContentClassCountsSchema as o, contextTreePolicySchema as p, SCHEMA_VERSION as r, contextContentClassSchema as s, CLI_ERROR_CODES as t, contextTreeCliErrorSchema as u, contextTreeRootNodeFrontmatterSchema as v, finishContextWriteResultSchema as w, contextTreeSyncResultSchema as x, contextTreeRootNodeSchema as y };
@@ -1,2 +0,0 @@
1
- import { $ as prepareContextWriteResultSchema, A as contextContentClassCountsSchema, B as contextTreeReadNodeSchema, C as PrepareContextWriteResult, D as ValidationCode, E as VALIDATION_CODES, F as contextTreeConnectionResultSchema, G as contextTreeSyncResultSchema, H as contextTreeRootNodeFrontmatterSchema, I as contextTreeConnectionSchema, J as finishContextWriteResultSchema, K as createProjectResultSchema, L as contextTreePolicySchema, M as contextTreeCliErrorCodeSchema, N as contextTreeCliErrorEnvelopeSchema, O as VerifyTreeReport, P as contextTreeCliErrorSchema, Q as parseContextTreeRootNode, R as contextTreePublishResultSchema, S as ManagedTreeListingResult, T as TreeValidationFinding, U as contextTreeRootNodeSchema, V as contextTreeReadResultSchema, W as contextTreeStateSchema, X as managedTreeListingEntrySchema, Y as githubRepositoryIdentitySchema, Z as managedTreeListingResultSchema, _ as ContextTreeState, a as ContextContentClassCounts, b as FinishContextWriteResult, c as ContextTreeCliErrorEnvelope, d as ContextTreePolicy, et as treeNameSchema, f as ContextTreePublishResult, g as ContextTreeRootNode, h as ContextTreeReadResult, i as ContextContentClass, j as contextContentClassSchema, k as connectProjectResultSchema, l as ContextTreeConnection, m as ContextTreeReadNode, n as CONTEXT_TREE_ROOT_NODE_MAX_BYTES, nt as validationCodeSchema, o as ContextTreeCliError, p as ContextTreeReadChild, q as credentialFreeRepositoryUrlSchema, r as ConnectProjectResult, rt as verifyTreeReportSchema, s as ContextTreeCliErrorCode, t as CLI_ERROR_CODES, tt as treeValidationFindingSchema, u as ContextTreeConnectionResult, v as ContextTreeSyncResult, w as SCHEMA_VERSION, x as ManagedTreeListingEntry, y as CreateProjectResult, z as contextTreeReadChildSchema } from "./schemas-C_7izpsa.mjs";
2
- export { CLI_ERROR_CODES, CONTEXT_TREE_ROOT_NODE_MAX_BYTES, ConnectProjectResult, ContextContentClass, ContextContentClassCounts, ContextTreeCliError, ContextTreeCliErrorCode, ContextTreeCliErrorEnvelope, ContextTreeConnection, ContextTreeConnectionResult, ContextTreePolicy, ContextTreePublishResult, ContextTreeReadChild, ContextTreeReadNode, ContextTreeReadResult, ContextTreeRootNode, ContextTreeState, ContextTreeSyncResult, CreateProjectResult, FinishContextWriteResult, ManagedTreeListingEntry, ManagedTreeListingResult, PrepareContextWriteResult, SCHEMA_VERSION, TreeValidationFinding, VALIDATION_CODES, ValidationCode, VerifyTreeReport, connectProjectResultSchema, contextContentClassCountsSchema, contextContentClassSchema, contextTreeCliErrorCodeSchema, contextTreeCliErrorEnvelopeSchema, contextTreeCliErrorSchema, contextTreeConnectionResultSchema, contextTreeConnectionSchema, contextTreePolicySchema, contextTreePublishResultSchema, contextTreeReadChildSchema, contextTreeReadNodeSchema, contextTreeReadResultSchema, contextTreeRootNodeFrontmatterSchema, contextTreeRootNodeSchema, contextTreeStateSchema, contextTreeSyncResultSchema, createProjectResultSchema, credentialFreeRepositoryUrlSchema, finishContextWriteResultSchema, githubRepositoryIdentitySchema, managedTreeListingEntrySchema, managedTreeListingResultSchema, parseContextTreeRootNode, prepareContextWriteResultSchema, treeNameSchema, treeValidationFindingSchema, validationCodeSchema, verifyTreeReportSchema };