feat: 更新 buddy 的一些功能
This commit is contained in:
parent
0d0304d6a5
commit
7dfbcd0e79
20
DEV-LOG.md
20
DEV-LOG.md
@ -1,5 +1,25 @@
|
||||
# DEV-LOG
|
||||
|
||||
## Buddy 命令合入 + Feature Flag 规范修正 (2026-04-02)
|
||||
|
||||
合入 `pr/smallflyingpig/36` 分支(支持 buddy 命令 + 修复 rehatch),并修正 feature flag 使用方式。
|
||||
|
||||
**合入内容(来自 PR):**
|
||||
- `src/commands/buddy/buddy.ts` — 新增 `/buddy` 命令,支持 hatch / rehatch / pet / mute / unmute 子命令
|
||||
- `src/commands/buddy/index.ts` — 从 stub 改为正确的 `Command` 类型导出
|
||||
- `src/buddy/companion.ts` — 新增 `generateSeed()`,`getCompanion()` 支持 seed 驱动的可复现 rolling
|
||||
- `src/buddy/types.ts` — `CompanionSoul` 增加 `seed?` 字段
|
||||
|
||||
**合并后修正:**
|
||||
- `src/entrypoints/cli.tsx` — PR 硬编码了 `const feature = (name) => name === "BUDDY"`,违反 feature flag 规范,恢复为标准 `import { feature } from 'bun:bundle'`
|
||||
- `src/commands.ts` — PR 用静态 `import buddy` 绕过了 feature gate,恢复为 `feature('BUDDY') ? require(...) : null` + 条件展开
|
||||
- `src/commands/buddy/buddy.ts` — 删除未使用的 `companionInfoText` 函数和多余的 `Roll`/`SPECIES` import
|
||||
- `CLAUDE.md` — 重写 Feature Flag System 章节,明确规范:代码中统一用 `import { feature } from 'bun:bundle'`,启用走环境变量 `FEATURE_<NAME>=1`
|
||||
|
||||
**用法:** `FEATURE_BUDDY=1 bun run dev`
|
||||
|
||||
---
|
||||
|
||||
## Auto Mode 补全 (2026-04-02)
|
||||
|
||||
反编译丢失了 auto mode 分类器的三个 prompt 模板文件,代码逻辑完整但无法运行。
|
||||
|
||||
@ -115,8 +115,11 @@ const forkCmd = feature('FORK_SUBAGENT')
|
||||
require('./commands/fork/index.js') as typeof import('./commands/fork/index.js')
|
||||
).default
|
||||
: null
|
||||
// buddy loaded directly (not feature-gated) for this build
|
||||
import buddy from './commands/buddy/index.js'
|
||||
const buddy = feature('BUDDY')
|
||||
? (
|
||||
require('./commands/buddy/index.js') as typeof import('./commands/buddy/index.js')
|
||||
).default
|
||||
: null
|
||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||
import thinkback from './commands/thinkback/index.js'
|
||||
import thinkbackPlay from './commands/thinkback-play/index.js'
|
||||
@ -316,7 +319,7 @@ const COMMANDS = memoize((): Command[] => [
|
||||
vim,
|
||||
...(webCmd ? [webCmd] : []),
|
||||
...(forkCmd ? [forkCmd] : []),
|
||||
buddy,
|
||||
...(buddy ? [buddy] : []),
|
||||
...(proactive ? [proactive] : []),
|
||||
...(briefCommand ? [briefCommand] : []),
|
||||
...(assistantCommand ? [assistantCommand] : []),
|
||||
|
||||
@ -2,13 +2,11 @@ import {
|
||||
getCompanion,
|
||||
rollWithSeed,
|
||||
generateSeed,
|
||||
type Roll,
|
||||
} from '../../buddy/companion.js'
|
||||
import {
|
||||
type StoredCompanion,
|
||||
RARITY_STARS,
|
||||
STAT_NAMES,
|
||||
SPECIES,
|
||||
} from '../../buddy/types.js'
|
||||
import { renderSprite } from '../../buddy/sprites.js'
|
||||
import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js'
|
||||
@ -71,25 +69,6 @@ function renderStats(stats: Record<string, number>): string {
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
function companionInfoText(roll: Roll): string {
|
||||
const { bones } = roll
|
||||
const sprite = renderSprite(bones, 0)
|
||||
const stars = RARITY_STARS[bones.rarity]
|
||||
const name = SPECIES_NAMES[bones.species] ?? 'Buddy'
|
||||
const shiny = bones.shiny ? ' ✨ Shiny!' : ''
|
||||
|
||||
return [
|
||||
sprite.join('\n'),
|
||||
'',
|
||||
` ${name} the ${speciesLabel(bones.species)}${shiny}`,
|
||||
` Rarity: ${stars} (${bones.rarity})`,
|
||||
` Eye: ${bones.eye} Hat: ${bones.hat}`,
|
||||
'',
|
||||
' Stats:',
|
||||
renderStats(bones.stats),
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
export const call: LocalCommandCall = async (args, _context) => {
|
||||
const sub = args.trim().toLowerCase()
|
||||
const config = getGlobalConfig()
|
||||
@ -177,7 +156,6 @@ export const call: LocalCommandCall = async (args, _context) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Import setAppState dynamically to update companionPetAt
|
||||
try {
|
||||
const { setAppState } = await import('../../state/AppStateStore.js')
|
||||
setAppState(prev => ({
|
||||
@ -185,7 +163,7 @@ export const call: LocalCommandCall = async (args, _context) => {
|
||||
companionPetAt: Date.now(),
|
||||
}))
|
||||
} catch {
|
||||
// If AppState is not available (non-interactive), just show text
|
||||
// non-interactive mode — AppState not available
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -1,22 +1,5 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
// Runtime polyfill for bun:bundle (build-time macros)
|
||||
const feature = (name: string) => name === "BUDDY";
|
||||
if (typeof globalThis.MACRO === "undefined") {
|
||||
(globalThis as any).MACRO = {
|
||||
VERSION: "2.1.888",
|
||||
BUILD_TIME: new Date().toISOString(),
|
||||
FEEDBACK_CHANNEL: "",
|
||||
ISSUES_EXPLAINER: "",
|
||||
NATIVE_PACKAGE_URL: "",
|
||||
PACKAGE_URL: "",
|
||||
VERSION_CHANGELOG: "",
|
||||
};
|
||||
}
|
||||
// Build-time constants — normally replaced by Bun bundler at compile time
|
||||
(globalThis as any).BUILD_TARGET = "external";
|
||||
(globalThis as any).BUILD_ENV = "production";
|
||||
(globalThis as any).INTERFACE_TYPE = "stdio";
|
||||
import { feature } from 'bun:bundle';
|
||||
|
||||
// Bugfix for corepack auto-pinning, which adds yarnpkg to peoples' package.jsons
|
||||
// eslint-disable-next-line custom-rules/no-top-level-side-effects
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user