sillyspec 3.20.3 â 3.20.5
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/.claude/skills/sillyspec-archive/SKILL.md +21 -17
- package/.claude/skills/sillyspec-auto/SKILL.md +83 -77
- package/.claude/skills/sillyspec-brainstorm/SKILL.md +44 -17
- package/.claude/skills/sillyspec-commit/SKILL.md +106 -105
- package/.claude/skills/sillyspec-continue/SKILL.md +45 -44
- package/.claude/skills/sillyspec-doctor/SKILL.md +31 -22
- package/.claude/skills/sillyspec-execute/SKILL.md +30 -17
- package/.claude/skills/sillyspec-explore/SKILL.md +109 -96
- package/.claude/skills/sillyspec-knowledge/SKILL.md +270 -0
- package/.claude/skills/sillyspec-plan/SKILL.md +21 -52
- package/.claude/skills/sillyspec-propose/SKILL.md +21 -17
- package/.claude/skills/sillyspec-quick/SKILL.md +21 -17
- package/.claude/skills/sillyspec-resume/SKILL.md +68 -111
- package/.claude/skills/sillyspec-scan/SKILL.md +21 -17
- package/.claude/skills/sillyspec-state/SKILL.md +54 -54
- package/.claude/skills/sillyspec-status/SKILL.md +21 -17
- package/.claude/skills/sillyspec-verify/SKILL.md +21 -17
- package/.claude/skills/sillyspec-workspace/SKILL.md +157 -149
- package/.husky/pre-push +13 -0
- package/CLAUDE.md +18 -0
- package/README.md +198 -186
- package/SKILL.md +90 -87
- package/bin/sillyspec.js +2 -2
- package/docs/brainstorm-plan-contract.md +64 -0
- package/docs/plan-execute-contract.md +123 -0
- package/docs/platform-scan-protocol.md +298 -0
- package/docs/revision-mode.md +115 -0
- package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +99 -0
- package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +218 -0
- package/docs/sillyspec/file-lifecycle/stage-artifacts.md +167 -0
- package/docs/sillyspec/file-lifecycle/storage-and-state.md +148 -0
- package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +211 -0
- package/docs/sillyspec/file-lifecycle.md +131 -0
- package/docs/workflow-contract-regression.md +106 -0
- package/docs/worktree-isolation.md +252 -0
- package/package.json +40 -34
- package/packages/dashboard/dist/assets/{index-D1EVTLmc.js â index-Bq_Z2hne.js} +7446 -7446
- package/packages/dashboard/dist/assets/index-O2W5RV4z.css +1 -0
- package/packages/dashboard/dist/index.html +16 -16
- package/packages/dashboard/dist/prototype-dashboard.html +836 -0
- package/packages/dashboard/dist/prototype-overview.html +256 -0
- package/packages/dashboard/index.html +15 -15
- package/packages/dashboard/package-lock.json +2384 -2384
- package/packages/dashboard/package.json +25 -25
- package/packages/dashboard/public/prototype-dashboard.html +836 -0
- package/packages/dashboard/public/prototype-overview.html +256 -0
- package/packages/dashboard/server/executor.js +86 -86
- package/packages/dashboard/server/index.js +588 -508
- package/packages/dashboard/server/parser.js +526 -458
- package/packages/dashboard/server/watcher.js +350 -342
- package/packages/dashboard/src/App.vue +558 -325
- package/packages/dashboard/src/components/ActionBar.vue +93 -84
- package/packages/dashboard/src/components/CommandPalette.vue +96 -92
- package/packages/dashboard/src/components/DetailPanel.vue +137 -137
- package/packages/dashboard/src/components/DocPreview.vue +105 -8
- package/packages/dashboard/src/components/DocTree.vue +75 -19
- package/packages/dashboard/src/components/HResizeHandle.vue +48 -0
- package/packages/dashboard/src/components/LogStream.vue +65 -65
- package/packages/dashboard/src/components/PipelineStage.vue +95 -75
- package/packages/dashboard/src/components/PipelineView.vue +156 -129
- package/packages/dashboard/src/components/ProjectCard.vue +187 -0
- package/packages/dashboard/src/components/ProjectList.vue +210 -210
- package/packages/dashboard/src/components/ProjectOverview.vue +113 -139
- package/packages/dashboard/src/components/StageBadge.vue +67 -53
- package/packages/dashboard/src/components/StepCard.vue +94 -89
- package/packages/dashboard/src/components/VResizeHandle.vue +61 -0
- package/packages/dashboard/src/components/detail/DocsDetail.vue +48 -48
- package/packages/dashboard/src/components/detail/GitDetail.vue +61 -61
- package/packages/dashboard/src/components/detail/TechDetail.vue +43 -43
- package/packages/dashboard/src/composables/useDashboard.js +192 -164
- package/packages/dashboard/src/composables/useKeyboard.js +119 -119
- package/packages/dashboard/src/composables/useLayout.js +131 -0
- package/packages/dashboard/src/composables/useWebSocket.js +129 -129
- package/packages/dashboard/src/main.js +8 -8
- package/packages/dashboard/src/style.css +132 -132
- package/packages/dashboard/vite.config.js +18 -18
- package/src/brainstorm-postcheck.js +158 -0
- package/src/change-list.js +52 -0
- package/src/change-risk-profile.js +352 -0
- package/src/classify-change.js +73 -0
- package/src/constants.js +70 -0
- package/src/contract-matrix.js +278 -0
- package/src/db.js +201 -0
- package/src/endpoint-extractor.js +315 -0
- package/src/hooks/claude-pre-tool-use.cjs +125 -0
- package/src/hooks/worktree-guard.js +761 -0
- package/src/index.js +922 -252
- package/src/init.js +470 -375
- package/src/knowledge-match.js +130 -0
- package/src/migrate.js +117 -117
- package/src/modules.js +482 -0
- package/src/progress.js +1734 -508
- package/src/run.js +3465 -652
- package/src/scan-postcheck.js +387 -0
- package/src/setup.js +398 -460
- package/src/stage-contract.js +700 -0
- package/src/stages/archive.js +160 -54
- package/src/stages/brainstorm-auto.js +229 -0
- package/src/stages/brainstorm.js +645 -239
- package/src/stages/doctor.js +365 -312
- package/src/stages/execute.js +634 -264
- package/src/stages/explore.js +34 -0
- package/src/stages/index.js +29 -35
- package/src/stages/knowledge.js +498 -0
- package/src/stages/plan-postcheck.js +518 -0
- package/src/stages/plan.js +582 -279
- package/src/stages/propose.js +174 -115
- package/src/stages/quick.js +102 -63
- package/src/stages/scan.js +558 -141
- package/src/stages/status.js +65 -65
- package/src/stages/verify.js +322 -135
- package/src/sync.js +497 -0
- package/src/task-review.js +346 -0
- package/src/workflow.js +785 -0
- package/src/worktree-apply.js +549 -0
- package/src/worktree-deps.js +185 -0
- package/src/worktree.js +982 -0
- package/templates/workflows/archive-impact.yaml +79 -0
- package/templates/workflows/scan-docs.yaml +132 -0
- package/test/brainstorm-plan-contract.test.mjs +273 -0
- package/test/check-syntax.mjs +26 -0
- package/test/cli-top-level-aliases.test.mjs +174 -0
- package/test/contract-artifacts.test.mjs +323 -0
- package/test/decision-supersede.test.mjs +277 -0
- package/test/knowledge-match.test.mjs +231 -0
- package/test/plan-execute-contract.test.mjs +357 -0
- package/test/plan-optimization.test.mjs +572 -0
- package/test/platform-artifacts.test.mjs +190 -0
- package/test/platform-failure-samples.test.mjs +199 -0
- package/test/platform-recovery-chain.test.mjs +179 -0
- package/test/platform-recovery.test.mjs +167 -0
- package/test/platform-scan-p0.test.mjs +175 -0
- package/test/revision-v1.test.mjs +1145 -0
- package/test/run-sanitize-project-name.test.mjs +51 -0
- package/test/run-scan-postcheck-fail.test.mjs +64 -0
- package/test/run-scan-project-parse.test.mjs +200 -0
- package/test/run-tests.mjs +48 -0
- package/test/runtime-cleanup-keeps-worktree.test.mjs +107 -0
- package/test/scan-docs-yaml-placeholders.test.mjs +84 -0
- package/test/scan-knowledge.test.mjs +175 -0
- package/test/scan-paths.test.mjs +68 -0
- package/test/scan-postcheck-project-priority.test.mjs +85 -0
- package/test/scan-postcheck.test.mjs +197 -0
- package/test/scan-workflow-anyfailed-block.test.mjs +52 -0
- package/test/spec-dir.test.mjs +206 -0
- package/test/stage-contract-failed-post-check.test.mjs +102 -0
- package/test/stage-contract.test.mjs +299 -0
- package/test/stage-definitions.test.mjs +39 -0
- package/test/wait-gates.test.mjs +501 -0
- package/test/workflow-spec-base.test.mjs +142 -0
- package/test/worktree-deps-provision.test.mjs +148 -0
- package/test/worktree-guard.test.mjs +136 -0
- package/test/worktree-native-overlay.test.mjs +188 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/design.md +0 -97
- package/.sillyspec/changes/archive/2026-04-08-derive-state/plan.md +0 -51
- package/.sillyspec/changes/archive/2026-04-08-derive-state/proposal.md +0 -29
- package/.sillyspec/changes/archive/2026-04-08-derive-state/requirements.md +0 -34
- package/.sillyspec/changes/archive/2026-04-08-derive-state/tasks.md +0 -13
- package/.sillyspec/changes/archive/2026-04-08-derive-state/verify-result.md +0 -43
- package/.sillyspec/changes/auto-mode/design.md +0 -50
- package/.sillyspec/changes/auto-mode/proposal.md +0 -19
- package/.sillyspec/changes/auto-mode/requirements.md +0 -21
- package/.sillyspec/changes/auto-mode/tasks.md +0 -7
- package/.sillyspec/changes/brainstorm-archive/2026-04-05-dashboard-design.md +0 -206
- package/.sillyspec/changes/brainstorm-archive/2026-04-05-unified-docs-design.md +0 -199
- package/.sillyspec/changes/dashboard/design.md +0 -219
- package/.sillyspec/changes/dashboard/design.md.braindraft +0 -206
- package/.sillyspec/changes/run-command-design/design.md +0 -1230
- package/.sillyspec/changes/unified-docs-design/design.md +0 -199
- package/.sillyspec/docs/sillyspec/scan/.gitkeep +0 -0
- package/.sillyspec/knowledge/INDEX.md +0 -8
- package/.sillyspec/knowledge/uncategorized.md +0 -3
- package/.sillyspec/plans/2026-04-05-dashboard.md +0 -737
- package/.sillyspec/projects/sillyspec.yaml +0 -3
- package/dist/steps/brainstorm/01-load-context.md +0 -30
- package/dist/steps/brainstorm/02-reuse-check.md +0 -6
- package/dist/steps/brainstorm/03-prototype-analysis.md +0 -11
- package/dist/steps/brainstorm/04-module-split.md +0 -23
- package/dist/steps/brainstorm/05-dialog-explore.md +0 -8
- package/dist/steps/brainstorm/06-propose-approaches.md +0 -3
- package/dist/steps/brainstorm/07-present-design.md +0 -3
- package/dist/steps/brainstorm/08-write-design.md +0 -21
- package/dist/steps/brainstorm/09-self-review.md +0 -15
- package/dist/steps/brainstorm/10-user-confirm.md +0 -3
- package/dist/steps/brainstorm/11-output-spec.md +0 -7
- package/dist/steps/brainstorm/manifest.yaml +0 -26
- package/dist/steps/execute/01-load-context.md +0 -41
- package/dist/steps/execute/02-scan-conventions.md +0 -47
- package/dist/steps/execute/03-skill-mcp.md +0 -19
- package/dist/steps/execute/04-assign-task.md +0 -22
- package/dist/steps/execute/04b-prompt-template.md +0 -54
- package/dist/steps/execute/05-write-test.md +0 -7
- package/dist/steps/execute/06-write-code.md +0 -8
- package/dist/steps/execute/07-run-test.md +0 -26
- package/dist/steps/execute/08-fix-issues.md +0 -28
- package/dist/steps/execute/09-next-task.md +0 -33
- package/dist/steps/execute/manifest.yaml +0 -28
- package/dist/steps/plan/01-load-context.md +0 -22
- package/dist/steps/plan/02-anchor-confirm.md +0 -1
- package/dist/steps/plan/03-expand-tasks.md +0 -33
- package/dist/steps/plan/04-mark-order.md +0 -15
- package/dist/steps/plan/05-e2e-planning.md +0 -17
- package/dist/steps/plan/06-self-check.md +0 -16
- package/dist/steps/plan/07-save.md +0 -1
- package/dist/steps/plan/manifest.yaml +0 -18
- package/dist/steps/scan/01-env-detect.md +0 -51
- package/dist/steps/scan/02-tech-stack.md +0 -16
- package/dist/steps/scan/03-conventions.md +0 -16
- package/dist/steps/scan/04-structure.md +0 -19
- package/dist/steps/scan/05-quality.md +0 -18
- package/dist/steps/scan/06-complete.md +0 -49
- package/dist/steps/scan/manifest.yaml +0 -16
- package/dist/steps/verify/01-load-specs.md +0 -28
- package/dist/steps/verify/02-check-tasks.md +0 -1
- package/dist/steps/verify/03-check-design.md +0 -6
- package/dist/steps/verify/04-run-tests.md +0 -7
- package/dist/steps/verify/05-e2e-tests.md +0 -27
- package/dist/steps/verify/05b-e2e-fix.md +0 -33
- package/dist/steps/verify/06-code-quality.md +0 -25
- package/dist/steps/verify/07-lint-check.md +0 -27
- package/dist/steps/verify/08-output-report.md +0 -14
- package/dist/steps/verify/manifest.yaml +0 -22
- package/packages/dashboard/dist/assets/index-DGe8CqeP.css +0 -1
- package/src/derive.js +0 -147
- package/src/step.js +0 -543
|
@@ -1,458 +1,526 @@
|
|
|
1
|
-
import { readFileSync, existsSync, readdirSync, statSync } from 'fs'
|
|
2
|
-
import { execSync } from 'child_process'
|
|
3
|
-
import { join } from 'path'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
|
-
import { dirname } from 'path'
|
|
6
|
-
|
|
7
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Parse docs tree for a project
|
|
11
|
-
* @param {string} projectPath - Path to the project directory
|
|
12
|
-
* @returns {object} Docs tree grouped by type
|
|
13
|
-
*/
|
|
14
|
-
// Known framework detection keywords in package.json dependencies
|
|
15
|
-
const FRAMEWORK_PATTERNS = [
|
|
16
|
-
{ keys: ['react', 'react-dom'], name: 'React' },
|
|
17
|
-
{ keys: ['vue'], name: 'Vue' },
|
|
18
|
-
{ keys: ['next'], name: 'Next.js' },
|
|
19
|
-
{ keys: ['nuxt'], name: 'Nuxt' },
|
|
20
|
-
{ keys: ['express'], name: 'Express' },
|
|
21
|
-
{ keys: ['koa'], name: 'Koa' },
|
|
22
|
-
{ keys: ['fastify'], name: 'Fastify' },
|
|
23
|
-
{ keys: ['nestjs', '@nestjs/core'], name: 'NestJS' },
|
|
24
|
-
{ keys: ['svelte'], name: 'Svelte' },
|
|
25
|
-
{ keys: ['astro'], name: 'Astro' },
|
|
26
|
-
{ keys: ['vite'], name: 'Vite' },
|
|
27
|
-
{ keys: ['webpack'], name: 'Webpack' },
|
|
28
|
-
{ keys: ['typescript'], name: 'TypeScript' },
|
|
29
|
-
{ keys: ['tailwindcss'], name: 'Tailwind' },
|
|
30
|
-
{ keys: ['prisma'], name: 'Prisma' },
|
|
31
|
-
{ keys: ['drizzle-orm'], name: 'Drizzle' },
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Parse project overview info
|
|
36
|
-
* @param {string} projectPath
|
|
37
|
-
* @returns {object} Overview data
|
|
38
|
-
*/
|
|
39
|
-
export function parseProjectOverview(projectPath) {
|
|
40
|
-
const result = {
|
|
41
|
-
techStack: [],
|
|
42
|
-
lastActive: null,
|
|
43
|
-
docStats: { design: 0, plan: 0, archive: 0, changes: 0, scan: 0, quicklog: 0, total: 0 },
|
|
44
|
-
git: { branch: '', lastCommit: '', dirtyCount: 0 }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// --- Tech stack ---
|
|
48
|
-
const pkgPath = join(projectPath, 'package.json')
|
|
49
|
-
if (existsSync(pkgPath)) {
|
|
50
|
-
try {
|
|
51
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
52
|
-
const deps = Object.keys({ ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) })
|
|
53
|
-
for (const pattern of FRAMEWORK_PATTERNS) {
|
|
54
|
-
if (pattern.keys.some(k => deps.includes(k))) {
|
|
55
|
-
result.techStack.push(pattern.name)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} catch {}
|
|
59
|
-
}
|
|
60
|
-
if (existsSync(join(projectPath, 'pom.xml'))) {
|
|
61
|
-
result.techStack.push('Java')
|
|
62
|
-
try {
|
|
63
|
-
const content = readFileSync(join(projectPath, 'pom.xml'), 'utf-8')
|
|
64
|
-
if (content.includes('spring-boot')) result.techStack.push('Spring Boot')
|
|
65
|
-
} catch {}
|
|
66
|
-
}
|
|
67
|
-
if (existsSync(join(projectPath, 'build.gradle')) || existsSync(join(projectPath, 'build.gradle.kts'))) {
|
|
68
|
-
if (!result.techStack.includes('Java')) result.techStack.push('Gradle')
|
|
69
|
-
}
|
|
70
|
-
if (existsSync(join(projectPath, 'requirements.txt')) || existsSync(join(projectPath, 'pyproject.toml'))) {
|
|
71
|
-
result.techStack.push('Python')
|
|
72
|
-
}
|
|
73
|
-
if (existsSync(join(projectPath, 'go.mod'))) {
|
|
74
|
-
result.techStack.push('Go')
|
|
75
|
-
}
|
|
76
|
-
if (result.techStack.length === 0) result.techStack = []
|
|
77
|
-
|
|
78
|
-
// --- Last active ---
|
|
79
|
-
const sillyspecDir = join(projectPath, '.sillyspec')
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
{ key: '
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
1
|
+
import { readFileSync, existsSync, readdirSync, statSync } from 'fs'
|
|
2
|
+
import { execSync } from 'child_process'
|
|
3
|
+
import { join, relative, sep } from 'path'
|
|
4
|
+
import { fileURLToPath } from 'url'
|
|
5
|
+
import { dirname } from 'path'
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parse docs tree for a project
|
|
11
|
+
* @param {string} projectPath - Path to the project directory
|
|
12
|
+
* @returns {object} Docs tree grouped by type
|
|
13
|
+
*/
|
|
14
|
+
// Known framework detection keywords in package.json dependencies
|
|
15
|
+
const FRAMEWORK_PATTERNS = [
|
|
16
|
+
{ keys: ['react', 'react-dom'], name: 'React' },
|
|
17
|
+
{ keys: ['vue'], name: 'Vue' },
|
|
18
|
+
{ keys: ['next'], name: 'Next.js' },
|
|
19
|
+
{ keys: ['nuxt'], name: 'Nuxt' },
|
|
20
|
+
{ keys: ['express'], name: 'Express' },
|
|
21
|
+
{ keys: ['koa'], name: 'Koa' },
|
|
22
|
+
{ keys: ['fastify'], name: 'Fastify' },
|
|
23
|
+
{ keys: ['nestjs', '@nestjs/core'], name: 'NestJS' },
|
|
24
|
+
{ keys: ['svelte'], name: 'Svelte' },
|
|
25
|
+
{ keys: ['astro'], name: 'Astro' },
|
|
26
|
+
{ keys: ['vite'], name: 'Vite' },
|
|
27
|
+
{ keys: ['webpack'], name: 'Webpack' },
|
|
28
|
+
{ keys: ['typescript'], name: 'TypeScript' },
|
|
29
|
+
{ keys: ['tailwindcss'], name: 'Tailwind' },
|
|
30
|
+
{ keys: ['prisma'], name: 'Prisma' },
|
|
31
|
+
{ keys: ['drizzle-orm'], name: 'Drizzle' },
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Parse project overview info
|
|
36
|
+
* @param {string} projectPath
|
|
37
|
+
* @returns {object} Overview data
|
|
38
|
+
*/
|
|
39
|
+
export function parseProjectOverview(projectPath) {
|
|
40
|
+
const result = {
|
|
41
|
+
techStack: [],
|
|
42
|
+
lastActive: null,
|
|
43
|
+
docStats: { design: 0, plan: 0, archive: 0, changes: 0, scan: 0, quicklog: 0, total: 0 },
|
|
44
|
+
git: { branch: '', lastCommit: '', dirtyCount: 0 }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// --- Tech stack ---
|
|
48
|
+
const pkgPath = join(projectPath, 'package.json')
|
|
49
|
+
if (existsSync(pkgPath)) {
|
|
50
|
+
try {
|
|
51
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
52
|
+
const deps = Object.keys({ ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) })
|
|
53
|
+
for (const pattern of FRAMEWORK_PATTERNS) {
|
|
54
|
+
if (pattern.keys.some(k => deps.includes(k))) {
|
|
55
|
+
result.techStack.push(pattern.name)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch {}
|
|
59
|
+
}
|
|
60
|
+
if (existsSync(join(projectPath, 'pom.xml'))) {
|
|
61
|
+
result.techStack.push('Java')
|
|
62
|
+
try {
|
|
63
|
+
const content = readFileSync(join(projectPath, 'pom.xml'), 'utf-8')
|
|
64
|
+
if (content.includes('spring-boot')) result.techStack.push('Spring Boot')
|
|
65
|
+
} catch {}
|
|
66
|
+
}
|
|
67
|
+
if (existsSync(join(projectPath, 'build.gradle')) || existsSync(join(projectPath, 'build.gradle.kts'))) {
|
|
68
|
+
if (!result.techStack.includes('Java')) result.techStack.push('Gradle')
|
|
69
|
+
}
|
|
70
|
+
if (existsSync(join(projectPath, 'requirements.txt')) || existsSync(join(projectPath, 'pyproject.toml'))) {
|
|
71
|
+
result.techStack.push('Python')
|
|
72
|
+
}
|
|
73
|
+
if (existsSync(join(projectPath, 'go.mod'))) {
|
|
74
|
+
result.techStack.push('Go')
|
|
75
|
+
}
|
|
76
|
+
if (result.techStack.length === 0) result.techStack = []
|
|
77
|
+
|
|
78
|
+
// --- Last active ---
|
|
79
|
+
const sillyspecDir = join(projectPath, '.sillyspec')
|
|
80
|
+
// Progress is stored in SQLite (.sillyspec/.runtime/sillyspec.db), not progress.json
|
|
81
|
+
// Use mtime of the DB file as a fallback for lastActive
|
|
82
|
+
const dbPath = join(sillyspecDir, '.runtime', 'sillyspec.db')
|
|
83
|
+
if (existsSync(dbPath)) {
|
|
84
|
+
try {
|
|
85
|
+
const s = statSync(dbPath)
|
|
86
|
+
result.lastActive = s.mtime.toISOString()
|
|
87
|
+
} catch {}
|
|
88
|
+
}
|
|
89
|
+
if (!result.lastActive) {
|
|
90
|
+
// Fallback: most recently modified file in .sillyspec
|
|
91
|
+
try {
|
|
92
|
+
const findRecent = (dir) => {
|
|
93
|
+
let latest = null
|
|
94
|
+
if (!existsSync(dir)) return latest
|
|
95
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
96
|
+
const p = join(dir, entry.name)
|
|
97
|
+
try {
|
|
98
|
+
const s = statSync(p)
|
|
99
|
+
if (entry.isDirectory()) {
|
|
100
|
+
const sub = findRecent(p)
|
|
101
|
+
if (sub && (!latest || sub > latest)) latest = sub
|
|
102
|
+
} else if (!latest || s.mtimeMs > latest) {
|
|
103
|
+
latest = s.mtimeMs
|
|
104
|
+
}
|
|
105
|
+
} catch {}
|
|
106
|
+
}
|
|
107
|
+
return latest
|
|
108
|
+
}
|
|
109
|
+
const ts = findRecent(sillyspecDir)
|
|
110
|
+
if (ts) result.lastActive = new Date(ts).toISOString()
|
|
111
|
+
} catch {}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// --- Doc stats ---
|
|
115
|
+
const docsDir = join(sillyspecDir, 'docs')
|
|
116
|
+
if (existsSync(docsDir)) {
|
|
117
|
+
const typeMap = { brainstorm: 'design', plan: 'plan', archive: 'archive', changes: 'changes', scan: 'scan', quicklog: 'quicklog' }
|
|
118
|
+
try {
|
|
119
|
+
for (const projDir of readdirSync(docsDir, { withFileTypes: true }).filter(d => d.isDirectory())) {
|
|
120
|
+
for (const typeDir of readdirSync(join(docsDir, projDir.name), { withFileTypes: true }).filter(d => d.isDirectory())) {
|
|
121
|
+
const key = typeMap[typeDir.name]
|
|
122
|
+
if (!key) continue
|
|
123
|
+
const count = countMdFiles(join(docsDir, projDir.name, typeDir.name))
|
|
124
|
+
result.docStats[key] += count
|
|
125
|
+
result.docStats.total += count
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch {}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// --- Git info ---
|
|
132
|
+
try {
|
|
133
|
+
result.git.lastCommit = execSync('git log -1 --format=%s', { cwd: projectPath, encoding: 'utf-8' }).trim()
|
|
134
|
+
} catch {}
|
|
135
|
+
try {
|
|
136
|
+
result.git.branch = execSync('git branch --show-current', { cwd: projectPath, encoding: 'utf-8' }).trim()
|
|
137
|
+
} catch {}
|
|
138
|
+
try {
|
|
139
|
+
result.git.dirtyCount = parseInt(execSync('git status --porcelain', { cwd: projectPath, encoding: 'utf-8' }).trim().split('\n').filter(Boolean).length, 10) || 0
|
|
140
|
+
} catch {}
|
|
141
|
+
|
|
142
|
+
return result
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function parseGitDetail(projectPath) {
|
|
146
|
+
const result = { branch: '', commits: [], untracked: [] }
|
|
147
|
+
try {
|
|
148
|
+
result.branch = execSync('git branch --show-current', { cwd: projectPath, encoding: 'utf-8' }).trim()
|
|
149
|
+
} catch {}
|
|
150
|
+
try {
|
|
151
|
+
const log = execSync('git log -5 --format=%h|%s|%an|%aI', { cwd: projectPath, encoding: 'utf-8' }).trim()
|
|
152
|
+
result.commits = log.split('\n').filter(Boolean).map(line => {
|
|
153
|
+
const [hash, message, author, date] = line.split('|')
|
|
154
|
+
return { hash, message, author, date }
|
|
155
|
+
})
|
|
156
|
+
} catch {}
|
|
157
|
+
try {
|
|
158
|
+
const status = execSync('git status --porcelain', { cwd: projectPath, encoding: 'utf-8' }).trim()
|
|
159
|
+
result.untracked = status.split('\n').filter(Boolean).map(line => ({
|
|
160
|
+
status: line.slice(0, 2).trim(),
|
|
161
|
+
file: line.slice(3)
|
|
162
|
+
}))
|
|
163
|
+
} catch {}
|
|
164
|
+
return result
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function parseTechStackDetail(projectPath) {
|
|
168
|
+
const result = { frameworks: [], dependencies: {}, devDependencies: {} }
|
|
169
|
+
const pkgPath = join(projectPath, 'package.json')
|
|
170
|
+
if (existsSync(pkgPath)) {
|
|
171
|
+
try {
|
|
172
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
173
|
+
result.dependencies = pkg.dependencies || {}
|
|
174
|
+
result.devDependencies = pkg.devDependencies || {}
|
|
175
|
+
const allDeps = Object.keys({ ...result.dependencies, ...result.devDependencies })
|
|
176
|
+
for (const pattern of FRAMEWORK_PATTERNS) {
|
|
177
|
+
if (pattern.keys.some(k => allDeps.includes(k))) {
|
|
178
|
+
result.frameworks.push(pattern.name)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
} catch {}
|
|
182
|
+
}
|
|
183
|
+
return result
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function parseDocsList(projectPath) {
|
|
187
|
+
const sillyspecDir = join(projectPath, '.sillyspec')
|
|
188
|
+
const docsDir = join(sillyspecDir, 'docs')
|
|
189
|
+
const groups = []
|
|
190
|
+
if (!existsSync(docsDir)) return groups
|
|
191
|
+
const typeMap = {
|
|
192
|
+
brainstorm: { label: '莞莥ć楣', icon: 'đ' },
|
|
193
|
+
plan: { label: 'ĺŽç°čŽĄĺ', icon: 'đ' },
|
|
194
|
+
archive: { label: '塲ĺ˝ćĄŁ', icon: 'đŚ' },
|
|
195
|
+
changes: { label: 'ĺ˝ĺĺć´', icon: 'âď¸' },
|
|
196
|
+
scan: { label: 'ćśćć楣', icon: 'đ' },
|
|
197
|
+
quicklog: { label: '忍é俎ĺ¤', icon: 'âĄ' }
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
for (const projDir of readdirSync(docsDir, { withFileTypes: true }).filter(d => d.isDirectory())) {
|
|
201
|
+
for (const typeDir of readdirSync(join(docsDir, projDir.name), { withFileTypes: true }).filter(d => d.isDirectory())) {
|
|
202
|
+
const cfg = typeMap[typeDir.name]
|
|
203
|
+
if (!cfg) continue
|
|
204
|
+
const files = listFilesRecursive(join(docsDir, projDir.name, typeDir.name))
|
|
205
|
+
if (files.length) {
|
|
206
|
+
groups.push({ key: typeDir.name, label: cfg.label, icon: cfg.icon, files })
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
} catch {}
|
|
211
|
+
return groups
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function listFilesRecursive(dir) {
|
|
215
|
+
const files = []
|
|
216
|
+
try {
|
|
217
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
218
|
+
const p = join(dir, entry.name)
|
|
219
|
+
if (entry.isDirectory()) {
|
|
220
|
+
const sub = listFilesRecursive(p)
|
|
221
|
+
for (const f of sub) f.name = entry.name + '/' + f.name
|
|
222
|
+
files.push(...sub)
|
|
223
|
+
} else if (entry.name.endsWith('.md')) {
|
|
224
|
+
const s = statSync(p)
|
|
225
|
+
files.push({ name: entry.name, path: p, size: s.size, mtime: s.mtime.toISOString() })
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} catch {}
|
|
229
|
+
return files
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function countMdFiles(dir) {
|
|
233
|
+
let count = 0
|
|
234
|
+
try {
|
|
235
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
236
|
+
if (entry.isDirectory()) {
|
|
237
|
+
count += countMdFiles(join(dir, entry.name))
|
|
238
|
+
} else if (entry.name.endsWith('.md')) {
|
|
239
|
+
count++
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} catch {}
|
|
243
|
+
return count
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function parseDocsTree(projectPath) {
|
|
247
|
+
const sillyspecDir = join(projectPath, '.sillyspec')
|
|
248
|
+
const docsDir = join(sillyspecDir, 'docs')
|
|
249
|
+
|
|
250
|
+
if (!existsSync(docsDir)) {
|
|
251
|
+
return { groups: [] }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const groupConfig = [
|
|
255
|
+
{ key: 'brainstorm', label: 'đ 莞莥ć楣', icon: 'đ', dir: 'brainstorm' },
|
|
256
|
+
{ key: 'plan', label: 'đ ĺŽç°čŽĄĺ', icon: 'đ', dir: 'plan' },
|
|
257
|
+
{ key: 'changes', label: 'âď¸ ĺ˝ĺĺć´', icon: 'âď¸', dir: 'changes' },
|
|
258
|
+
{ key: 'archive', label: 'đŚ ĺˇ˛ĺ˝ćĄŁ', icon: 'đŚ', dir: 'archive' },
|
|
259
|
+
{ key: 'scan', label: 'đ ćśćć楣', icon: 'đ', dir: 'scan' },
|
|
260
|
+
{ key: 'quicklog', label: '⥠忍é俎ĺ¤', icon: 'âĄ', dir: 'quicklog' },
|
|
261
|
+
]
|
|
262
|
+
|
|
263
|
+
const groups = []
|
|
264
|
+
|
|
265
|
+
// Find project dirs under docs/
|
|
266
|
+
const projectDirs = existsSync(docsDir) ? readdirSync(docsDir, { withFileTypes: true })
|
|
267
|
+
.filter(d => d.isDirectory()).map(d => d.name) : []
|
|
268
|
+
|
|
269
|
+
for (const projName of projectDirs) {
|
|
270
|
+
const projDocsDir = join(docsDir, projName)
|
|
271
|
+
|
|
272
|
+
for (const group of groupConfig) {
|
|
273
|
+
const groupDir = join(projDocsDir, group.dir)
|
|
274
|
+
if (!existsSync(groupDir)) continue
|
|
275
|
+
|
|
276
|
+
const files = []
|
|
277
|
+
try {
|
|
278
|
+
const entries = readdirSync(groupDir, { withFileTypes: true })
|
|
279
|
+
for (const entry of entries) {
|
|
280
|
+
if (entry.isDirectory()) {
|
|
281
|
+
// For changes/ and archive/ subdirs
|
|
282
|
+
const subDir = join(groupDir, entry.name)
|
|
283
|
+
try {
|
|
284
|
+
const subFiles = readdirSync(subDir).filter(f => f.endsWith('.md'))
|
|
285
|
+
for (const sf of subFiles) {
|
|
286
|
+
const filePath = join(subDir, sf)
|
|
287
|
+
files.push({
|
|
288
|
+
name: `${entry.name}/${sf}`,
|
|
289
|
+
path: filePath,
|
|
290
|
+
title: sf.replace('.md', '')
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
} catch {}
|
|
294
|
+
} else if (entry.name.endsWith('.md')) {
|
|
295
|
+
const filePath = join(groupDir, entry.name)
|
|
296
|
+
let title = entry.name.replace('.md', '')
|
|
297
|
+
try {
|
|
298
|
+
const content = readFileSync(filePath, 'utf-8')
|
|
299
|
+
const titleMatch = content.match(/^#\s+(.+)$/m)
|
|
300
|
+
if (titleMatch) title = titleMatch[1]
|
|
301
|
+
} catch {}
|
|
302
|
+
files.push({ name: entry.name, path: filePath, title })
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
} catch {}
|
|
306
|
+
|
|
307
|
+
if (files.length > 0) {
|
|
308
|
+
groups.push({
|
|
309
|
+
key: `${projName}::${group.key}`,
|
|
310
|
+
label: group.label,
|
|
311
|
+
project: projName,
|
|
312
|
+
files
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return { groups }
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const VIEWABLE_SILLYSPEC_DOC_EXTENSIONS = new Set([
|
|
322
|
+
'.md', '.markdown', '.mdx',
|
|
323
|
+
'.html', '.htm',
|
|
324
|
+
'.txt', '.log',
|
|
325
|
+
'.json', '.yaml', '.yml', '.toml',
|
|
326
|
+
'.xml', '.csv'
|
|
327
|
+
])
|
|
328
|
+
|
|
329
|
+
const SILLYSPEC_DOC_GROUPS = [
|
|
330
|
+
{ key: 'docs', label: 'đ docs', dir: 'docs' },
|
|
331
|
+
{ key: 'changes', label: 'âď¸ changes', dir: 'changes' },
|
|
332
|
+
{ key: 'plans', label: 'đ§ž plans', dir: 'plans' },
|
|
333
|
+
{ key: 'quicklog', label: '⥠quicklog', dir: 'quicklog' },
|
|
334
|
+
{ key: 'knowledge', label: 'đ§ knowledge', dir: 'knowledge' },
|
|
335
|
+
{ key: 'projects', label: 'đ projects', dir: 'projects' },
|
|
336
|
+
{ key: 'workspace', label: 'đď¸ workspace', dir: 'workspace' },
|
|
337
|
+
{ key: 'shared', label: 'đ shared', dir: 'shared' },
|
|
338
|
+
{ key: 'runtime', label: 'đ§° .runtime', dir: '.runtime' }
|
|
339
|
+
]
|
|
340
|
+
|
|
341
|
+
function sillyspecDocExt(fileName) {
|
|
342
|
+
const index = fileName.lastIndexOf('.')
|
|
343
|
+
return index === -1 ? '' : fileName.slice(index).toLowerCase()
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function isViewableSillyspecDoc(fileName) {
|
|
347
|
+
return VIEWABLE_SILLYSPEC_DOC_EXTENSIONS.has(sillyspecDocExt(fileName))
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function titleFromSillyspecDoc(filePath, fileName) {
|
|
351
|
+
const ext = sillyspecDocExt(fileName)
|
|
352
|
+
if (ext === '.md' || ext === '.markdown' || ext === '.mdx') {
|
|
353
|
+
try {
|
|
354
|
+
const content = readFileSync(filePath, 'utf-8')
|
|
355
|
+
const titleMatch = content.match(/^#\s+(.+)$/m)
|
|
356
|
+
if (titleMatch) return titleMatch[1]
|
|
357
|
+
} catch {}
|
|
358
|
+
}
|
|
359
|
+
return fileName.replace(/\.(md|markdown|mdx|html?|txt|log|json|ya?ml|toml|xml|csv)$/i, '')
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function listSillyspecDocsRecursive(dir, rootDir) {
|
|
363
|
+
const files = []
|
|
364
|
+
try {
|
|
365
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
366
|
+
const filePath = join(dir, entry.name)
|
|
367
|
+
if (entry.isDirectory()) {
|
|
368
|
+
files.push(...listSillyspecDocsRecursive(filePath, rootDir))
|
|
369
|
+
} else if (entry.isFile() && isViewableSillyspecDoc(entry.name)) {
|
|
370
|
+
const s = statSync(filePath)
|
|
371
|
+
files.push({
|
|
372
|
+
name: relative(rootDir, filePath).split(sep).join('/'),
|
|
373
|
+
path: filePath,
|
|
374
|
+
title: titleFromSillyspecDoc(filePath, entry.name),
|
|
375
|
+
extension: sillyspecDocExt(entry.name).slice(1),
|
|
376
|
+
size: s.size,
|
|
377
|
+
mtime: s.mtime.toISOString()
|
|
378
|
+
})
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
} catch {}
|
|
382
|
+
return files
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export function parseSillyspecDocsTree(projectPath) {
|
|
386
|
+
const sillyspecDir = join(projectPath, '.sillyspec')
|
|
387
|
+
if (!existsSync(sillyspecDir)) return { groups: [] }
|
|
388
|
+
|
|
389
|
+
const groups = []
|
|
390
|
+
const seen = new Set()
|
|
391
|
+
|
|
392
|
+
for (const group of SILLYSPEC_DOC_GROUPS) {
|
|
393
|
+
const groupDir = join(sillyspecDir, group.dir)
|
|
394
|
+
if (!existsSync(groupDir)) continue
|
|
395
|
+
|
|
396
|
+
const files = listSillyspecDocsRecursive(groupDir, groupDir)
|
|
397
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
398
|
+
|
|
399
|
+
if (files.length === 0) continue
|
|
400
|
+
for (const file of files) seen.add(file.path)
|
|
401
|
+
groups.push({ key: group.key, label: group.label, project: '.sillyspec', files })
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const rootFiles = []
|
|
405
|
+
try {
|
|
406
|
+
for (const entry of readdirSync(sillyspecDir, { withFileTypes: true })) {
|
|
407
|
+
if (!entry.isFile() || !isViewableSillyspecDoc(entry.name)) continue
|
|
408
|
+
const filePath = join(sillyspecDir, entry.name)
|
|
409
|
+
if (seen.has(filePath)) continue
|
|
410
|
+
const s = statSync(filePath)
|
|
411
|
+
rootFiles.push({
|
|
412
|
+
name: entry.name,
|
|
413
|
+
path: filePath,
|
|
414
|
+
title: titleFromSillyspecDoc(filePath, entry.name),
|
|
415
|
+
extension: sillyspecDocExt(entry.name).slice(1),
|
|
416
|
+
size: s.size,
|
|
417
|
+
mtime: s.mtime.toISOString()
|
|
418
|
+
})
|
|
419
|
+
}
|
|
420
|
+
} catch {}
|
|
421
|
+
|
|
422
|
+
if (rootFiles.length > 0) {
|
|
423
|
+
groups.unshift({ key: 'root', label: 'đ .sillyspec', project: '.sillyspec', files: rootFiles })
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return { groups }
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Parse project state from .sillyspec SQLite database via CLI.
|
|
431
|
+
* Progress data is stored in SQLite (.sillyspec/.runtime/sillyspec.db),
|
|
432
|
+
* accessed through `sillyspec progress show`.
|
|
433
|
+
* @param {string} projectPath - Path to the project directory
|
|
434
|
+
* @returns {object|null} Project state with currentStage, stages, lastActive
|
|
435
|
+
*/
|
|
436
|
+
export function parseProjectState(projectPath) {
|
|
437
|
+
const sillyspecDir = join(projectPath, '.sillyspec')
|
|
438
|
+
const dbPath = join(sillyspecDir, '.runtime', 'sillyspec.db')
|
|
439
|
+
|
|
440
|
+
if (!existsSync(sillyspecDir) || !existsSync(dbPath)) {
|
|
441
|
+
return null
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let currentStage = ''
|
|
445
|
+
let lastActive = null
|
|
446
|
+
|
|
447
|
+
// Use DB file mtime as lastActive indicator
|
|
448
|
+
try {
|
|
449
|
+
const s = statSync(dbPath)
|
|
450
|
+
lastActive = s.mtime.toISOString()
|
|
451
|
+
} catch {}
|
|
452
|
+
|
|
453
|
+
// Use CLI to read current stage from SQLite
|
|
454
|
+
try {
|
|
455
|
+
const output = execSync('sillyspec progress show 2>/dev/null', {
|
|
456
|
+
cwd: projectPath, encoding: 'utf-8', timeout: 5000
|
|
457
|
+
})
|
|
458
|
+
const stageMatch = output.match(/ĺ˝ĺéśćŽľ:\s*(\S+)/)
|
|
459
|
+
if (stageMatch) currentStage = stageMatch[1]
|
|
460
|
+
} catch {
|
|
461
|
+
// CLI unavailable or no active change
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return {
|
|
465
|
+
currentStage,
|
|
466
|
+
nextStep: null,
|
|
467
|
+
progress: { stages: {} },
|
|
468
|
+
stages: [],
|
|
469
|
+
specs: [],
|
|
470
|
+
lastActive
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Parse spec file content
|
|
476
|
+
* @param {string} specPath - Path to the spec file
|
|
477
|
+
* @returns {object} Parsed spec with title, sections, and metadata
|
|
478
|
+
*/
|
|
479
|
+
export function parseSpecFile(specPath) {
|
|
480
|
+
if (!existsSync(specPath)) {
|
|
481
|
+
return null
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
try {
|
|
485
|
+
const content = readFileSync(specPath, 'utf-8')
|
|
486
|
+
const lines = content.split('\n')
|
|
487
|
+
|
|
488
|
+
const titleMatch = content.match(/^#\s+(.+)$/m)
|
|
489
|
+
const title = titleMatch ? titleMatch[1] : 'Unknown'
|
|
490
|
+
|
|
491
|
+
const sections = []
|
|
492
|
+
let currentSection = null
|
|
493
|
+
let currentContent = []
|
|
494
|
+
|
|
495
|
+
for (let i = 0; i < lines.length; i++) {
|
|
496
|
+
const line = lines[i]
|
|
497
|
+
const headingMatch = line.match(/^(#{2,4})\s+(.+)$/)
|
|
498
|
+
|
|
499
|
+
if (headingMatch) {
|
|
500
|
+
if (currentSection) {
|
|
501
|
+
sections.push({
|
|
502
|
+
level: currentSection.level,
|
|
503
|
+
title: currentSection.title,
|
|
504
|
+
content: currentContent.join('\n').trim()
|
|
505
|
+
})
|
|
506
|
+
}
|
|
507
|
+
currentSection = { level: headingMatch[1].length, title: headingMatch[2] }
|
|
508
|
+
currentContent = []
|
|
509
|
+
} else if (currentSection) {
|
|
510
|
+
currentContent.push(line)
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (currentSection) {
|
|
515
|
+
sections.push({
|
|
516
|
+
level: currentSection.level,
|
|
517
|
+
title: currentSection.title,
|
|
518
|
+
content: currentContent.join('\n').trim()
|
|
519
|
+
})
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return { title, sections, content }
|
|
523
|
+
} catch (err) {
|
|
524
|
+
return null
|
|
525
|
+
}
|
|
526
|
+
}
|