头脑风暴、续聊、实施三套 prompt(vscode / jetbrains / tui 同步)从 superpowers 的 brainstorming 与 /goal 换成 /ecc:plan-prd、/ecc:plan、/ecc:tdd-workflow。spec/plan 路径固定为 .claude/prds/<slug>.prd.md 与 .claude/plans/<slug>.plan.md,slug 派生去掉 .prd.md / .plan.md 后缀;worktreePath 测试挪到 test/ 目录。 Claude-Session: https://claude.ai/code/session_01QWxLb6X8Vd2G5vHnp6R7qm
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import * as os from 'node:os'
|
|
import * as path from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { DEFAULT_WORKTREE_TEMPLATE, deriveSlug, resolveWorktreeDir, slugFromBranch } from '../../src/git/worktreePath'
|
|
|
|
describe('deriveSlug', () => {
|
|
it('plans/ 后一段去掉 .plan.md', () => {
|
|
expect(deriveSlug('.claude/plans/app-entity.plan.md')).toBe('app-entity')
|
|
})
|
|
it('prds/ 后一段去掉 .prd.md', () => {
|
|
expect(deriveSlug('.claude/prds/app-entity.prd.md')).toBe('app-entity')
|
|
})
|
|
it('目录形式取 plans/ 后的目录名', () => {
|
|
expect(deriveSlug('docs/superpowers/plans/x/plan.md')).toBe('x')
|
|
})
|
|
it('没有 plans/prds/specs 锚点时退回父目录名', () => {
|
|
expect(deriveSlug('foo/bar/notes.md')).toBe('bar')
|
|
})
|
|
it('没有父目录时退回路径 hash 前 8 位', () => {
|
|
expect(deriveSlug('notes.md')).toMatch(/^[0-9a-f]{8}$/)
|
|
})
|
|
})
|
|
|
|
describe('slugFromBranch', () => {
|
|
it('去掉 feature/ 前缀', () => {
|
|
expect(slugFromBranch('feature/app-entity')).toBe('app-entity')
|
|
})
|
|
it('无前缀原样返回', () => {
|
|
expect(slugFromBranch('hotfix-1')).toBe('hotfix-1')
|
|
})
|
|
})
|
|
|
|
describe('resolveWorktreeDir', () => {
|
|
it('展开三个占位符与 ~', () => {
|
|
const out = resolveWorktreeDir(DEFAULT_WORKTREE_TEMPLATE, '/w/proj', 'slug')
|
|
expect(out).toBe(path.join(os.homedir(), 'Sources', 'worktree', 'proj', 'slug'))
|
|
})
|
|
it('$project_root 展开为工作区绝对路径', () => {
|
|
expect(resolveWorktreeDir('$project_root/.wt/$feature_name', '/w/proj', 's')).toBe('/w/proj/.wt/s')
|
|
})
|
|
})
|