@miketromba/issy-core 0.7.3 → 0.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miketromba/issy-core",
3
- "version": "0.7.3",
3
+ "version": "0.8.0",
4
4
  "description": "Issue storage, search, and parsing for issy",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/lib/index.ts CHANGED
@@ -35,6 +35,8 @@ export {
35
35
  getNextIssue,
36
36
  getNextIssueNumber,
37
37
  getOnCloseContent,
38
+ getOnCreateContent,
39
+ getOnUpdateContent,
38
40
  getOpenIssuesByOrder,
39
41
  hasLegacyIssuesDir,
40
42
  parseFrontmatter,
package/src/lib/issues.ts CHANGED
@@ -189,7 +189,8 @@ export function parseFrontmatter(content: string): {
189
189
  const colonIdx = line.indexOf(':')
190
190
  if (colonIdx > 0) {
191
191
  const key = line.slice(0, colonIdx).trim()
192
- const value = line.slice(colonIdx + 1).trim()
192
+ const rawValue = line.slice(colonIdx + 1).trim()
193
+ const value = key === 'title' ? yamlUnquote(rawValue) : rawValue
193
194
  ;(frontmatter as Record<string, string>)[key] = value
194
195
  }
195
196
  }
@@ -197,9 +198,31 @@ export function parseFrontmatter(content: string): {
197
198
  return { frontmatter, body }
198
199
  }
199
200
 
201
+ function yamlQuote(value: string): string {
202
+ if (/[:#\[\]{}&*!|>'"%@`,\n]/.test(value) || value !== value.trim()) {
203
+ const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
204
+ return `"${escaped}"`
205
+ }
206
+ return value
207
+ }
208
+
209
+ function yamlUnquote(value: string): string {
210
+ if (
211
+ (value.startsWith('"') && value.endsWith('"')) ||
212
+ (value.startsWith("'") && value.endsWith("'"))
213
+ ) {
214
+ const inner = value.slice(1, -1)
215
+ if (value.startsWith('"')) {
216
+ return inner.replace(/\\"/g, '"').replace(/\\\\/g, '\\')
217
+ }
218
+ return inner
219
+ }
220
+ return value
221
+ }
222
+
200
223
  export function generateFrontmatter(data: IssueFrontmatter): string {
201
224
  const lines = ['---']
202
- lines.push(`title: ${data.title}`)
225
+ lines.push(`title: ${yamlQuote(data.title)}`)
203
226
  lines.push(`priority: ${data.priority}`)
204
227
  if (data.scope) {
205
228
  lines.push(`scope: ${data.scope}`)
@@ -510,18 +533,26 @@ export async function deleteIssue(id: string): Promise<void> {
510
533
 
511
534
  // --- Hooks ---
512
535
 
513
- /**
514
- * Read the on_close.md hook content if it exists.
515
- */
516
- export async function getOnCloseContent(): Promise<string | null> {
536
+ async function readHookFile(filename: string): Promise<string | null> {
517
537
  try {
518
- const onClosePath = join(getIssyDir(), 'on_close.md')
519
- return await readFile(onClosePath, 'utf-8')
538
+ return await readFile(join(getIssyDir(), filename), 'utf-8')
520
539
  } catch {
521
540
  return null
522
541
  }
523
542
  }
524
543
 
544
+ export async function getOnCloseContent(): Promise<string | null> {
545
+ return readHookFile('on_close.md')
546
+ }
547
+
548
+ export async function getOnCreateContent(): Promise<string | null> {
549
+ return readHookFile('on_create.md')
550
+ }
551
+
552
+ export async function getOnUpdateContent(): Promise<string | null> {
553
+ return readHookFile('on_update.md')
554
+ }
555
+
525
556
  // --- Next issue ---
526
557
 
527
558
  /**