picocode-core 0.9.231 → 0.9.232

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 (2) hide show
  1. package/package.json +3 -2
  2. package/src/skills.js +16 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picocode-core",
3
- "version": "0.9.231",
3
+ "version": "0.9.232",
4
4
  "description": "The agent runtime behind pico: sessions, tools, subagents, MCP, memory, and model access",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,6 +30,7 @@
30
30
  "globby": "^16.2.4",
31
31
  "proper-lockfile": "^4.1.2",
32
32
  "sharp": "^0.34.5",
33
- "unpdf": "^1.8.1"
33
+ "unpdf": "^1.8.1",
34
+ "yaml": "^2.9.1"
34
35
  }
35
36
  }
package/src/skills.js CHANGED
@@ -1,17 +1,30 @@
1
+ import { parse as parseYaml } from 'yaml'
1
2
  import { readFile, readdir } from 'node:fs/promises'
2
3
  import { join } from 'node:path'
3
4
  import { globalSkillsDir, projectSkillsDir } from './paths.js'
4
5
 
6
+ // a file's frontmatter as YAML reads it, so multi-line and nested values keep their content; frontmatter that is not
7
+ // valid YAML (an unquoted "key: Use when: ...") is read a line at a time, as key: value
5
8
  export function parseFrontmatter(text) {
6
9
  const match = text.match(/^---\n([\s\S]*?)\n---\n?/)
7
10
  if (!match) return { meta: {}, body: text }
11
+ return { meta: readMeta(match[1]), body: text.slice(match[0].length) }
12
+ }
13
+
14
+ function readMeta(source) {
15
+ try {
16
+ const parsed = parseYaml(source)
17
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
18
+ return Object.fromEntries(Object.entries(parsed).map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value]))
19
+ }
20
+ } catch {}
8
21
  const meta = {}
9
- for (const line of match[1].split('\n')) {
22
+ for (const line of source.split('\n')) {
10
23
  const sep = line.indexOf(':')
11
- if (sep === -1) continue
24
+ if (sep === -1 || /^\s/.test(line)) continue
12
25
  meta[line.slice(0, sep).trim()] = line.slice(sep + 1).trim()
13
26
  }
14
- return { meta, body: text.slice(match[0].length) }
27
+ return meta
15
28
  }
16
29
 
17
30
  async function scanDir(dir, source) {