specstoryai/getspecstory / lore
lore
FlaggedSpecStory Lore - mine your SpecStory coding histories (any agent - Claude Code, Codex, Cursor, Gemini, and more) into a persistent corpus, surface your reproducible workflows with corroborated evidence, and interactively forge the chosen ones into skills installed across all your agent harnesses. Use when the user wants to turn past AI coding sessions into reusable skills, asks "what could I make into a skill", "mine my lore", "forge skills from my history", or points at a .specstory/history directory.
scripts/lib/discover.mjs
View on GitHub// discover.mjs - find projects and transcripts on disk; resolve stable project identity.
import { readFileSync, readdirSync, existsSync } from 'node:fs'
import { join, basename, dirname, resolve } from 'node:path'
import { FILE_DATE } from './patterns.mjs'
// Recursively list every *.md under a history dir (handles specstory-organize year/month layouts).
export function walkMd(dir) {
const out = []
let ents
try { ents = readdirSync(dir, { withFileTypes: true }) } catch { return out }
for (const e of ents) {
const p = join(dir, e.name)
if (e.isDirectory()) out.push(...walkMd(p))
else if (e.isFile() && e.name.endsWith('.md')) out.push(p)
}
return out
}
// Stable project identity from .specstory/.project.json: git_id (hash of normalized git remote -
// globally stable) preferred over workspace_id (path hash - machine-local), else the dir name.
export function readLabel(historyDir) {
const pj = join(historyDir, '..', '.project.json')
let id = null, name = null
try {
const j = JSON.parse(readFileSync(pj, 'utf8'))
id = j.git_id || j.workspace_id || null
name = j.project_name || null
} catch { /* not a .specstory layout */ }
const root = basename(dirname(dirname(historyDir))) || basename(historyDir)
return { id: id || root, name: name || root }
}
// Find every .specstory/history under a root, at ANY depth (monorepos nest histories in
// sub-packages). Skips dependency/build dirs and other dotdirs; bounded depth as a tripwire.
export function scanForHistories(root, maxDepth = 6) {
const SKIP = new Set(['node_modules', 'build', 'dist', 'out', 'target', 'vendor', 'Pods', 'DerivedData'])
const found = []
const walk = (dir, depth) => {
if (depth > maxDepth) return
let ents
try { ents = readdirSync(dir, { withFileTypes: true }) } catch { return }
for (const e of ents) {
if (!e.isDirectory()) continue
if (e.name === '.specstory') {
const hd = join(dir, '.specstory', 'history')
if (existsSync(hd)) found.push(hd)
continue
}
if (SKIP.has(e.name) || e.name.startsWith('.')) continue
walk(join(dir, e.name), depth + 1)
}
}
walk(resolve(root), 0)
return found
}
// Resolve --dir flags, a --projects parent, and/or a --scan root into [{historyDir, id, name}].
// Dirs are resolved to ABSOLUTE paths before anything is stored: the corpus carries session
// paths that must stay valid from any future working directory (prune, beats export,
// evidence refs). Relative input is a cwd-of-the-moment accident, never a contract.
export function discoverProjects(a) {
const out = [], seen = new Set()
const addHist = (hd) => {
if (!hd) return
hd = resolve(hd)
if (!existsSync(hd) || seen.has(hd)) return
seen.add(hd)
const lab = readLabel(hd)
out.push({ historyDir: hd, id: lab.id, name: lab.name })
}
if (a.scan) for (const hd of scanForHistories(a.scan)) addHist(hd)
if (a.projects) {
const parent = resolve(a.projects)
let kids = []
try { kids = readdirSync(parent) } catch { /* ignore */ }
for (const k of kids) addHist(join(parent, k, '.specstory', 'history'))
}
for (const d of a.dirs) addHist(d)
return out
}
export function fileDate(path, head) {
let m = FILE_DATE.exec(basename(path))
if (m) return m[1]
m = FILE_DATE.exec(head)
return m ? m[1] : null
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |