mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -41,7 +41,7 @@
|
||||
</ul>
|
||||
<p><strong>Phase 3: Planning</strong></p>
|
||||
<ul>
|
||||
<li class="">Load plan schema: <code>~/.claude/workflows/cli-templates/schemas/plan-json-schema.json</code></li>
|
||||
<li class="">Load plan schema: <code>~/.ccw/workflows/cli-templates/schemas/plan-json-schema.json</code></li>
|
||||
<li class="">Generate plan.json following schema</li>
|
||||
</ul>
|
||||
<p><strong>Phase 4: Confirmation & Selection</strong></p>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -128,7 +128,7 @@ Level 2 workflows provide lightweight planning or single analysis with fast iter
|
||||
- Medium/High: Use cli-lite-planning-agent
|
||||
|
||||
**Phase 3: Planning**
|
||||
- Load plan schema: `~/.claude/workflows/cli-templates/schemas/plan-json-schema.json`
|
||||
- Load plan schema: `~/.ccw/workflows/cli-templates/schemas/plan-json-schema.json`
|
||||
- Generate plan.json following schema
|
||||
|
||||
**Phase 4: Confirmation & Selection**
|
||||
|
||||
@@ -128,7 +128,7 @@ Level 2 工作流提供轻量级规划或单次分析,支持快速迭代。它
|
||||
- 中/高: 使用 cli-lite-planning-agent
|
||||
|
||||
**阶段 3: 规划**
|
||||
- 加载计划 schema: `~/.claude/workflows/cli-templates/schemas/plan-json-schema.json`
|
||||
- 加载计划 schema: `~/.ccw/workflows/cli-templates/schemas/plan-json-schema.json`
|
||||
- 按照生成计划 schema 生成 plan.json
|
||||
|
||||
**阶段 4: 确认与选择**
|
||||
|
||||
@@ -162,7 +162,6 @@ export function AppShell({
|
||||
<div className="flex flex-col min-h-screen bg-background">
|
||||
{/* Header - fixed at top */}
|
||||
<Header
|
||||
onMenuClick={handleMenuClick}
|
||||
onRefresh={onRefresh}
|
||||
isRefreshing={isRefreshing}
|
||||
onCliMonitorClick={handleCliMonitorClick}
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
Zap,
|
||||
GitFork,
|
||||
Shield,
|
||||
History,
|
||||
Server,
|
||||
Layers,
|
||||
Wrench,
|
||||
@@ -89,7 +88,6 @@ const navGroupDefinitions: NavGroupDef[] = [
|
||||
icon: Brain,
|
||||
items: [
|
||||
{ path: '/memory', labelKey: 'navigation.main.memory', icon: Brain },
|
||||
{ path: '/prompts', labelKey: 'navigation.main.prompts', icon: History },
|
||||
{ path: '/skills', labelKey: 'navigation.main.skills', icon: Sparkles },
|
||||
{ path: '/commands', labelKey: 'navigation.main.commands', icon: Terminal },
|
||||
{ path: '/settings/rules', labelKey: 'navigation.main.rules', icon: Shield },
|
||||
|
||||
@@ -49,6 +49,8 @@ export interface UseCommandsReturn {
|
||||
totalCount: number;
|
||||
enabledCount: number;
|
||||
disabledCount: number;
|
||||
projectCount: number;
|
||||
userCount: number;
|
||||
isLoading: boolean;
|
||||
isFetching: boolean;
|
||||
error: Error | null;
|
||||
@@ -136,8 +138,12 @@ export function useCommands(options: UseCommandsOptions = {}): UseCommandsReturn
|
||||
|
||||
const allCommands = query.data?.commands ?? [];
|
||||
|
||||
// Apply filters
|
||||
const filteredCommands = (() => {
|
||||
// Per-location total counts (unfiltered, for tab badges)
|
||||
const projectCount = allCommands.filter(c => c.location === 'project').length;
|
||||
const userCount = allCommands.filter(c => c.location === 'user').length;
|
||||
|
||||
// Apply filters (except showDisabled) for counts and grouping
|
||||
const baseFiltered = (() => {
|
||||
let commands = allCommands;
|
||||
|
||||
if (filter?.search) {
|
||||
@@ -166,14 +172,15 @@ export function useCommands(options: UseCommandsOptions = {}): UseCommandsReturn
|
||||
commands = commands.filter((c) => c.location === filter.location);
|
||||
}
|
||||
|
||||
if (filter?.showDisabled === false) {
|
||||
commands = commands.filter((c) => c.enabled !== false);
|
||||
}
|
||||
|
||||
return commands;
|
||||
})();
|
||||
|
||||
// Group by category
|
||||
// Apply showDisabled filter for the returned commands list
|
||||
const filteredCommands = filter?.showDisabled === false
|
||||
? baseFiltered.filter((c) => c.enabled !== false)
|
||||
: baseFiltered;
|
||||
|
||||
// Group by category (from allCommands for global view)
|
||||
const commandsByCategory: Record<string, Command[]> = {};
|
||||
const categories = new Set<string>();
|
||||
|
||||
@@ -186,13 +193,13 @@ export function useCommands(options: UseCommandsOptions = {}): UseCommandsReturn
|
||||
commandsByCategory[category].push(command);
|
||||
}
|
||||
|
||||
// Group by group
|
||||
// Group by group (from baseFiltered - respects location filter, includes disabled for accordion)
|
||||
const groupedCommands: Record<string, Command[]> = {};
|
||||
const groups = new Set<string>();
|
||||
const enabledCount = allCommands.filter(c => c.enabled !== false).length;
|
||||
const disabledCount = allCommands.length - enabledCount;
|
||||
const enabledCount = baseFiltered.filter(c => c.enabled !== false).length;
|
||||
const disabledCount = baseFiltered.length - enabledCount;
|
||||
|
||||
for (const command of allCommands) {
|
||||
for (const command of baseFiltered) {
|
||||
const group = command.group || 'other';
|
||||
groups.add(group);
|
||||
if (!groupedCommands[group]) {
|
||||
@@ -217,6 +224,8 @@ export function useCommands(options: UseCommandsOptions = {}): UseCommandsReturn
|
||||
groups: Array.from(groups).sort(),
|
||||
enabledCount,
|
||||
disabledCount,
|
||||
projectCount,
|
||||
userCount,
|
||||
totalCount: allCommands.length,
|
||||
isLoading: query.isLoading,
|
||||
isFetching: query.isFetching,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// ========================================
|
||||
// Manage custom slash commands with search/filter
|
||||
|
||||
import { useState, useMemo } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import {
|
||||
Terminal,
|
||||
@@ -46,6 +46,8 @@ export function CommandsManagerPage() {
|
||||
groups,
|
||||
enabledCount,
|
||||
disabledCount,
|
||||
projectCount,
|
||||
userCount,
|
||||
isLoading,
|
||||
isFetching,
|
||||
error,
|
||||
@@ -93,16 +95,6 @@ export function CommandsManagerPage() {
|
||||
toggleGroup(groupName, enable, locationFilter);
|
||||
};
|
||||
|
||||
// Calculate command counts per location
|
||||
const projectCount = useMemo(
|
||||
() => commands.filter((c) => c.location === 'project').length,
|
||||
[commands]
|
||||
);
|
||||
const userCount = useMemo(
|
||||
() => commands.filter((c) => c.location === 'user').length,
|
||||
[commands]
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Page Header */}
|
||||
@@ -159,25 +151,6 @@ export function CommandsManagerPage() {
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* Show Disabled Controls */}
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<Button
|
||||
variant={showDisabledCommands ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setShowDisabledCommands((prev) => !prev)}
|
||||
disabled={isToggling}
|
||||
>
|
||||
{showDisabledCommands ? (
|
||||
<Eye className="w-4 h-4 mr-2" />
|
||||
) : (
|
||||
<EyeOff className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{showDisabledCommands
|
||||
? formatMessage({ id: 'commands.actions.hideDisabled' })
|
||||
: formatMessage({ id: 'commands.actions.showDisabled' })}
|
||||
<span className="ml-1 text-xs opacity-70">({disabledCount})</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Summary Stats */}
|
||||
@@ -223,6 +196,22 @@ export function CommandsManagerPage() {
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant={showDisabledCommands ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setShowDisabledCommands((prev) => !prev)}
|
||||
disabled={isToggling}
|
||||
>
|
||||
{showDisabledCommands ? (
|
||||
<Eye className="w-4 h-4 mr-2" />
|
||||
) : (
|
||||
<EyeOff className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{showDisabledCommands
|
||||
? formatMessage({ id: 'commands.actions.hideDisabled' })
|
||||
: formatMessage({ id: 'commands.actions.showDisabled' })}
|
||||
<span className="ml-1 text-xs opacity-70">({disabledCount})</span>
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={expandAll} disabled={groups.length === 0}>
|
||||
{formatMessage({ id: 'commands.actions.expandAll' })}
|
||||
</Button>
|
||||
|
||||
@@ -167,7 +167,7 @@ export function QueuePage() {
|
||||
{formatMessage({ id: 'issues.queue.pageTitle' })}
|
||||
</h1>
|
||||
<p className="text-muted-foreground mt-1">
|
||||
{formatMessage({ id: 'issues.queue.pageDescription' })}
|
||||
{formatMessage({ id: 'issues.queue.description' })}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
|
||||
@@ -982,10 +982,10 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
|
||||
const userGuidelinesPath = join(homedir(), '.claude', 'workflows', 'chinese-response.md');
|
||||
|
||||
if (!existsSync(userGuidelinesPath)) {
|
||||
return { error: 'Chinese response guidelines file not found at ~/.claude/workflows/chinese-response.md', status: 404 };
|
||||
return { error: 'Chinese response guidelines file not found at ~/.ccw/workflows/chinese-response.md', status: 404 };
|
||||
}
|
||||
|
||||
const guidelinesRef = '~/.claude/workflows/chinese-response.md';
|
||||
const guidelinesRef = '~/.ccw/workflows/chinese-response.md';
|
||||
|
||||
// Configure based on target
|
||||
const isCodex = target === 'codex';
|
||||
@@ -1177,7 +1177,7 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
|
||||
if (existsSync(cliToolsUsagePath)) {
|
||||
cliToolsUsageContent = readFileSync(cliToolsUsagePath, 'utf8');
|
||||
} else {
|
||||
return { error: 'CLI tools usage guidelines file not found at ~/.claude/workflows/cli-tools-usage.md', status: 404 };
|
||||
return { error: 'CLI tools usage guidelines file not found at ~/.ccw/workflows/cli-tools-usage.md', status: 404 };
|
||||
}
|
||||
|
||||
const cliToolsJsonPath = join(homedir(), '.claude', 'cli-tools.json');
|
||||
@@ -1213,7 +1213,7 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
|
||||
if (existsSync(cliToolsUsagePath)) {
|
||||
cliToolsUsageContent = readFileSync(cliToolsUsagePath, 'utf8');
|
||||
} else {
|
||||
return { error: 'CLI tools usage guidelines file not found at ~/.claude/workflows/cli-tools-usage.md', status: 404 };
|
||||
return { error: 'CLI tools usage guidelines file not found at ~/.ccw/workflows/cli-tools-usage.md', status: 404 };
|
||||
}
|
||||
|
||||
// Read and format cli-tools.json
|
||||
@@ -1304,10 +1304,10 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
|
||||
const userGuidelinesPath = join(homedir(), '.claude', 'workflows', 'windows-platform.md');
|
||||
|
||||
if (!existsSync(userGuidelinesPath)) {
|
||||
return { error: 'Windows platform guidelines file not found at ~/.claude/workflows/windows-platform.md', status: 404 };
|
||||
return { error: 'Windows platform guidelines file not found at ~/.ccw/workflows/windows-platform.md', status: 404 };
|
||||
}
|
||||
|
||||
const guidelinesRef = '~/.claude/workflows/windows-platform.md';
|
||||
const guidelinesRef = '~/.ccw/workflows/windows-platform.md';
|
||||
|
||||
const windowsRefLine = `- **Windows Platform**: @${guidelinesRef}`;
|
||||
const windowsRefPattern = /^- \*\*Windows Platform\*\*:.*windows-platform\.md.*$/gm;
|
||||
|
||||
@@ -955,10 +955,10 @@ export function updateCodeIndexMcp(
|
||||
|
||||
// Determine target file based on provider
|
||||
const targetFile = provider === 'ace'
|
||||
? '@~/.claude/workflows/context-tools-ace.md'
|
||||
? '@~/.ccw/workflows/context-tools-ace.md'
|
||||
: provider === 'none'
|
||||
? '@~/.claude/workflows/context-tools-none.md'
|
||||
: '@~/.claude/workflows/context-tools.md';
|
||||
? '@~/.ccw/workflows/context-tools-none.md'
|
||||
: '@~/.ccw/workflows/context-tools.md';
|
||||
|
||||
if (!fs.existsSync(globalClaudeMdPath)) {
|
||||
// If global CLAUDE.md doesn't exist, check project-level
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Template Discovery Module
|
||||
*
|
||||
* Provides auto-discovery and loading of CLI templates from
|
||||
* ~/.claude/workflows/cli-templates/
|
||||
* ~/.ccw/workflows/cli-templates/
|
||||
*
|
||||
* Features:
|
||||
* - Scan prompts/ directory (flat structure with category-function.txt naming)
|
||||
|
||||
Reference in New Issue
Block a user