contentbase 0.0.2 → 0.0.4

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 (85) hide show
  1. package/.mcp.json +9 -0
  2. package/CLI.md +593 -0
  3. package/MCP-DESCRIPTIONS-REVIEW.md +122 -0
  4. package/MCP-SERVER-SPEC.md +453 -0
  5. package/PRIMER.md +540 -0
  6. package/README.md +289 -13
  7. package/bun.lock +43 -4
  8. package/dist/cnotes +0 -0
  9. package/docs/README.md +110 -0
  10. package/docs/TABLE-OF-CONTENTS.md +7 -0
  11. package/docs/models.ts +38 -0
  12. package/models.ts +38 -0
  13. package/package.json +12 -3
  14. package/public/web-demo/index.html +813 -0
  15. package/showcases/node_modules/.cache/.repl_history +3 -0
  16. package/showcases/vinyl-collection/artists/nina-simone.mdx +1 -1
  17. package/src/__tests__/semantic-search.integration.test.ts +284 -0
  18. package/src/api/endpoints/actions.ts +34 -0
  19. package/src/api/endpoints/doc.ts +187 -0
  20. package/src/api/endpoints/docs-index.ts +26 -0
  21. package/src/api/endpoints/document.ts +171 -0
  22. package/src/api/endpoints/documents.ts +71 -0
  23. package/src/api/endpoints/inspect.ts +16 -0
  24. package/src/api/endpoints/models.ts +10 -0
  25. package/src/api/endpoints/query.ts +88 -0
  26. package/src/api/endpoints/root.ts +7 -0
  27. package/src/api/endpoints/search-reindex.ts +65 -0
  28. package/src/api/endpoints/search-status.ts +55 -0
  29. package/src/api/endpoints/search.ts +104 -0
  30. package/src/api/endpoints/semantic-search.ts +120 -0
  31. package/src/api/endpoints/text-search.ts +63 -0
  32. package/src/api/endpoints/validate.ts +34 -0
  33. package/src/api/helpers.ts +97 -0
  34. package/src/base-model.ts +12 -0
  35. package/src/cli/commands/action.ts +82 -44
  36. package/src/cli/commands/console.ts +124 -0
  37. package/src/cli/commands/create.ts +179 -53
  38. package/src/cli/commands/embed.ts +323 -0
  39. package/src/cli/commands/export.ts +58 -24
  40. package/src/cli/commands/extract.ts +174 -0
  41. package/src/cli/commands/help.ts +81 -0
  42. package/src/cli/commands/index.ts +17 -0
  43. package/src/cli/commands/init.ts +72 -48
  44. package/src/cli/commands/inspect.ts +56 -46
  45. package/src/cli/commands/mcp.ts +1219 -0
  46. package/src/cli/commands/search.ts +285 -0
  47. package/src/cli/commands/serve.ts +348 -0
  48. package/src/cli/commands/summary.ts +60 -0
  49. package/src/cli/commands/teach.ts +86 -0
  50. package/src/cli/commands/text-search.ts +134 -0
  51. package/src/cli/commands/validate.ts +126 -64
  52. package/src/cli/index.ts +88 -19
  53. package/src/cli/load-collection.ts +144 -17
  54. package/src/cli/registry.ts +28 -0
  55. package/src/collection.ts +361 -10
  56. package/src/define-model.ts +101 -4
  57. package/src/document.ts +47 -1
  58. package/src/extract-sections.ts +1 -1
  59. package/src/index.ts +14 -2
  60. package/src/model-instance.ts +35 -5
  61. package/src/node-shortcuts.ts +1 -1
  62. package/src/query/collection-query.ts +96 -9
  63. package/src/query/index.ts +7 -0
  64. package/src/query/query-dsl.ts +259 -0
  65. package/src/relationships/has-many.ts +39 -0
  66. package/src/relationships/index.ts +7 -2
  67. package/src/section.ts +2 -0
  68. package/src/types.ts +23 -1
  69. package/src/utils/index.ts +1 -0
  70. package/src/utils/match-pattern.ts +65 -0
  71. package/src/validator.ts +18 -1
  72. package/test/collection.test.ts +118 -2
  73. package/test/fixtures/sdlc/MODELS.md +106 -0
  74. package/test/fixtures/sdlc/SKILL.md +404 -0
  75. package/test/fixtures/sdlc/index.ts +9 -0
  76. package/test/fixtures/sdlc/models.ts +8 -6
  77. package/test/fixtures/sdlc/stories/authentication/a-user-should-be-able-to-login.mdx +20 -0
  78. package/test/fixtures/sdlc/templates/epic.md +23 -0
  79. package/test/fixtures/sdlc/templates/story.md +19 -0
  80. package/test/pattern.test.ts +191 -0
  81. package/test/query-dsl.test.ts +431 -0
  82. package/test/query.test.ts +29 -0
  83. package/test/relationships.test.ts +130 -0
  84. package/test/section.test.ts +61 -0
  85. package/test/table-of-contents.test.ts +49 -5
package/docs/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # Models
2
+
3
+ Models define the structure of markdown documents in this collection. Each document is a markdown file with YAML frontmatter (metadata attributes) and a heading-based structure (sections). Models specify the expected frontmatter fields via a schema, named sections that map to `##` headings in the document body, relationships to other models, and computed properties derived at query time.
4
+
5
+ ## Examples
6
+
7
+ An Example has metadata (tags).
8
+
9
+ **Prefix:** `examples`
10
+
11
+ ### Attributes
12
+
13
+ | Field | Type | Required | Default | Description |
14
+ |-------|------|----------|---------|-------------|
15
+ | tags | string[] | optional | `[]` | Arbitrary tags for categorizing the example |
16
+
17
+ ### Example
18
+
19
+ ```markdown
20
+ ---
21
+ tags: []
22
+ ---
23
+ # Example Title
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Ideas
29
+
30
+ An Idea has metadata (goal, tags, status).
31
+
32
+ **Prefix:** `ideas`
33
+
34
+ ### Attributes
35
+
36
+ | Field | Type | Required | Default | Description |
37
+ |-------|------|----------|---------|-------------|
38
+ | goal | string | optional | — | Slug of the goal this idea is aligned to |
39
+ | tags | string[] | optional | `[]` | Arbitrary tags for categorizing the idea |
40
+ | status | enum(`spark`, `exploring`, `parked`, `promoted`) | optional | `"spark"` | spark is a new raw idea, exploring means actively thinking about it, parked means on hold, promoted means it became a plan |
41
+
42
+ ### Example
43
+
44
+ ```markdown
45
+ ---
46
+ tags: []
47
+ status: spark
48
+ ---
49
+ # Idea Title
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Reports
55
+
56
+ A Report has metadata (tags).
57
+
58
+ **Prefix:** `reports`
59
+
60
+ ### Attributes
61
+
62
+ | Field | Type | Required | Default | Description |
63
+ |-------|------|----------|---------|-------------|
64
+ | tags | string[] | optional | `[]` | Arbitrary tags for categorizing the report |
65
+
66
+ ### Example
67
+
68
+ ```markdown
69
+ ---
70
+ tags: []
71
+ ---
72
+ # Report Title
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Tutorials
78
+
79
+ A Tutorial has metadata (tags).
80
+
81
+ **Prefix:** `tutorials`
82
+
83
+ ### Attributes
84
+
85
+ | Field | Type | Required | Default | Description |
86
+ |-------|------|----------|---------|-------------|
87
+ | tags | string[] | optional | `[]` | Arbitrary tags for categorizing the tutorial |
88
+
89
+ ### Example
90
+
91
+ ```markdown
92
+ ---
93
+ tags: []
94
+ ---
95
+ # Tutorial Title
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Bases
101
+
102
+ A Base document.
103
+
104
+ **Prefix:** ``
105
+
106
+ ### Example
107
+
108
+ ```markdown
109
+ # Base Title
110
+ ```
@@ -0,0 +1,7 @@
1
+ # Table of Contents
2
+
3
+ ## Ideas
4
+
5
+ - [Changelogs](./ideas/changelogs.md)
6
+ - [Content model collections](./ideas/content-model-collections.md)
7
+ - [Semantic Search Integration](./ideas/semantic-search.md)
package/docs/models.ts ADDED
@@ -0,0 +1,38 @@
1
+ import {
2
+ defineModel,
3
+ section,
4
+ hasMany,
5
+ belongsTo,
6
+ AstQuery,
7
+ z,
8
+ } from "contentbase";
9
+
10
+ export const Idea = defineModel("Idea", {
11
+ prefix: "ideas",
12
+ meta: z.object({
13
+ goal: z.string().optional().describe("Slug of the goal this idea is aligned to"),
14
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the idea"),
15
+ status: z.enum(["spark", "exploring", "parked", "promoted"]).default("spark").describe("spark is a new raw idea, exploring means actively thinking about it, parked means on hold, promoted means it became a plan"),
16
+ }),
17
+ });
18
+
19
+ export const Tutorial = defineModel("Tutorial", {
20
+ prefix: "tutorials",
21
+ meta: z.object({
22
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the tutorial"),
23
+ }),
24
+ })
25
+
26
+ export const Report = defineModel("Report", {
27
+ prefix: "reports",
28
+ meta: z.object({
29
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the report"),
30
+ }),
31
+ })
32
+
33
+ export const Example = defineModel("Example", {
34
+ prefix: "examples",
35
+ meta: z.object({
36
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the example"),
37
+ }),
38
+ })
package/models.ts ADDED
@@ -0,0 +1,38 @@
1
+ import {
2
+ defineModel,
3
+ section,
4
+ hasMany,
5
+ belongsTo,
6
+ AstQuery,
7
+ z,
8
+ } from "contentbase";
9
+
10
+ export const Idea = defineModel("Idea", {
11
+ prefix: "ideas",
12
+ meta: z.object({
13
+ goal: z.string().optional().describe("Slug of the goal this idea is aligned to"),
14
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the idea"),
15
+ status: z.enum(["spark", "exploring", "parked", "promoted"]).default("spark").describe("spark is a new raw idea, exploring means actively thinking about it, parked means on hold, promoted means it became a plan"),
16
+ }),
17
+ });
18
+
19
+ export const Tutorial = defineModel("Tutorial", {
20
+ prefix: "tutorials",
21
+ meta: z.object({
22
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the tutorial"),
23
+ }),
24
+ })
25
+
26
+ export const Report = defineModel("Report", {
27
+ prefix: "reports",
28
+ meta: z.object({
29
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the report"),
30
+ }),
31
+ })
32
+
33
+ export const Example = defineModel("Example", {
34
+ prefix: "examples",
35
+ meta: z.object({
36
+ tags: z.array(z.string()).default([]).describe("Arbitrary tags for categorizing the example"),
37
+ }),
38
+ })
package/package.json CHANGED
@@ -1,27 +1,32 @@
1
1
  {
2
2
  "name": "contentbase",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
7
7
  "bin": {
8
+ "cnotes": "./src/cli/index.ts",
8
9
  "contentbase": "./src/cli/index.ts"
9
10
  },
10
11
  "scripts": {
11
12
  "test": "vitest run",
12
13
  "test:watch": "vitest",
13
14
  "typecheck": "tsc --noEmit",
14
- "examples": "bun run scripts/examples/run-all.ts"
15
+ "examples": "bun run scripts/examples/run-all.ts",
16
+ "compile": "bun build ./src/cli/index.ts --compile --outfile dist/cnotes --external @node-llama-cpp/*"
15
17
  },
16
18
  "dependencies": {
17
- "citty": "^0.1.6",
19
+ "@soederpop/luca": "^0.0.2",
18
20
  "gray-matter": "^4.0.3",
19
21
  "js-yaml": "^4.1.0",
20
22
  "mdast-util-mdxjs-esm": "^2.0.1",
21
23
  "mdast-util-to-markdown": "^2.1.2",
22
24
  "mdast-util-to-string": "^4.0.0",
25
+ "picomatch": "^4.0.3",
26
+ "rehype-stringify": "^10.0.1",
23
27
  "remark-gfm": "^4.0.0",
24
28
  "remark-parse": "^11.0.0",
29
+ "remark-rehype": "^11.1.2",
25
30
  "remark-stringify": "^11.0.0",
26
31
  "unified": "^11.0.5",
27
32
  "unist-util-find-after": "^5.0.0",
@@ -35,8 +40,12 @@
35
40
  "devDependencies": {
36
41
  "@types/js-yaml": "^4.0.9",
37
42
  "@types/mdast": "^4.0.4",
43
+ "@types/picomatch": "^4.0.2",
38
44
  "bun-types": "^1.1.0",
39
45
  "typescript": "^5.4.0",
40
46
  "vitest": "^1.6.0"
47
+ },
48
+ "luca": {
49
+ "aliases": ["contentbase", "content base", "content", "the orm"]
41
50
  }
42
51
  }