contentbase 0.1.6 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentbase",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "repository": "https://github.com/soederpop/contentbase",
5
5
  "website": "https://contentbase.soederpop.com",
6
6
  "type": "module",
@@ -50,6 +50,11 @@
50
50
  "vitest": "^1.6.0"
51
51
  },
52
52
  "luca": {
53
- "aliases": ["contentbase", "content base", "content", "the orm"]
53
+ "aliases": [
54
+ "contentbase",
55
+ "content base",
56
+ "content",
57
+ "the orm"
58
+ ]
54
59
  }
55
60
  }
@@ -38,6 +38,7 @@ async function handler(options: z.infer<typeof argsSchema>, context: { container
38
38
 
39
39
  commands.register('action', {
40
40
  description: 'Run a named action on the collection',
41
+ usage: '<name>',
41
42
  help: `# cnotes action
42
43
 
43
44
  Run a named action registered on the collection. Actions are custom functions defined in your collection's entry point.
@@ -2,6 +2,7 @@ import { z } from 'zod'
2
2
  import fs from 'fs/promises'
3
3
  import path from 'path'
4
4
  import matter from 'gray-matter'
5
+ import { execSync } from 'child_process'
5
6
  import { commands } from '../registry.js'
6
7
  import { loadCollection } from '../load-collection.js'
7
8
  import { kebabCase } from '../../utils/inflect.js'
@@ -10,6 +11,7 @@ import { introspectMetaSchema } from '../../collection.js'
10
11
  const argsSchema = z.object({
11
12
  title: z.string().optional(),
12
13
  contentFolder: z.string().optional(),
14
+ openEditor: z.boolean().optional(),
13
15
  })
14
16
 
15
17
  async function handler(options: z.infer<typeof argsSchema>, context: { container: any }) {
@@ -125,10 +127,37 @@ async function handler(options: z.infer<typeof argsSchema>, context: { container
125
127
  await fs.writeFile(filePath, content, 'utf8')
126
128
 
127
129
  console.log(`Created ${filePath}`)
130
+
131
+ if (options.openEditor) {
132
+ const editor = process.env.EDITOR
133
+ if (editor) {
134
+ execSync(`${editor} ${filePath}`, { stdio: 'inherit' })
135
+ } else {
136
+ const candidates = ['cursor', 'code', 'vim']
137
+ let found = false
138
+ for (const cmd of candidates) {
139
+ try {
140
+ execSync(`which ${cmd}`, { stdio: 'ignore' })
141
+ execSync(`${cmd} ${filePath}`, { stdio: 'inherit' })
142
+ found = true
143
+ break
144
+ } catch {
145
+ // not available, try next
146
+ }
147
+ }
148
+ if (!found) {
149
+ console.error(
150
+ 'No editor found. Tried: cursor, code, vim. Set $EDITOR to your preferred editor.'
151
+ )
152
+ process.exit(1)
153
+ }
154
+ }
155
+ }
128
156
  }
129
157
 
130
158
  commands.register('create', {
131
159
  description: 'Create a new document for a model type',
160
+ usage: '<model>',
132
161
  help: `# cnotes create
133
162
 
134
163
  Create a new document for a registered model, with proper frontmatter defaults and section scaffolding.
@@ -151,6 +180,7 @@ cnotes create <model> --title "Document Title" [options]
151
180
  |--------|-------------|
152
181
  | \`--title\` | **Required.** Title for the new document (used as H1 and slug) |
153
182
  | \`--meta.*\` | Set frontmatter fields (e.g. \`--meta.status active\`) |
183
+ | \`--open-editor\` | Open the new file in your editor ($EDITOR, or tries cursor/code/vim) |
154
184
  | \`--contentFolder\` | Path to content folder |
155
185
 
156
186
  ## Template Lookup
@@ -123,6 +123,7 @@ async function handler(options: z.infer<typeof argsSchema>, context: { container
123
123
 
124
124
  commands.register('extract', {
125
125
  description: 'Extract specific sections from documents',
126
+ usage: '<glob>',
126
127
  help: `# cnotes extract
127
128
 
128
129
  Extract specific sections from one or more documents. Supports glob patterns for matching multiple documents and outputs clean markdown with normalized headings.
@@ -22,7 +22,8 @@ async function handler(_options: any, context: { container: any }) {
22
22
 
23
23
  for (const name of commands.available) {
24
24
  const def = commands.get(name)!
25
- lines.push(`| \`${name}\` | ${def.description} |`)
25
+ const label = def.usage ? `${name} ${def.usage}` : name
26
+ lines.push(`| \`${label}\` | ${def.description} |`)
26
27
  }
27
28
 
28
29
  lines.push(
@@ -60,6 +60,7 @@ collection.register(Post);
60
60
 
61
61
  commands.register('init', {
62
62
  description: 'Initialize a new contentbase project',
63
+ usage: '[name]',
63
64
  help: `# cnotes init
64
65
 
65
66
  Scaffold a new contentbase project with a sample model and document.
@@ -223,6 +223,7 @@ async function handler(options: z.infer<typeof argsSchema>, { container }: { con
223
223
 
224
224
  commands.register('search', {
225
225
  description: 'Semantic search across collection documents',
226
+ usage: '<query>',
226
227
  help: `# cnotes search
227
228
 
228
229
  Search documents in the collection using keyword, semantic, or hybrid search modes. Requires a search index — run \`cnotes embed\` first.
@@ -86,6 +86,7 @@ async function handler(options: z.infer<typeof argsSchema>, { container }: { con
86
86
 
87
87
  commands.register('text-search', {
88
88
  description: 'Search file contents with pattern matching',
89
+ usage: '<pattern>',
89
90
  help: `# cnotes text-search
90
91
 
91
92
  Search file contents within the collection using ripgrep. Returns matching files by default, or line-level detail with \`--expanded\`.
@@ -85,6 +85,7 @@ async function handler(options: z.infer<typeof argsSchema>, context: { container
85
85
 
86
86
  commands.register('validate', {
87
87
  description: 'Validate documents against their model schemas',
88
+ usage: '[model]',
88
89
  help: `# cnotes validate
89
90
 
90
91
  Validate documents against their model schemas. Check frontmatter types, required fields, and optionally fill in missing defaults.
@@ -2,6 +2,7 @@ import type { z } from 'zod'
2
2
 
3
3
  export interface CommandDefinition {
4
4
  description: string
5
+ usage?: string
5
6
  help?: string
6
7
  argsSchema?: z.ZodType<any>
7
8
  handler: (options: any, context: { container: any }) => Promise<void>