mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -518,6 +518,13 @@ async function mkdirAction(sessionId, options) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Emit DIRECTORY_CREATED event
|
||||
notifyDashboard({
|
||||
type: 'DIRECTORY_CREATED',
|
||||
sessionId: sessionId,
|
||||
payload: { directories: result.result.directories_created }
|
||||
});
|
||||
|
||||
console.log(chalk.green(`✓ Directory created: ${result.result.directories_created.join(', ')}`));
|
||||
}
|
||||
|
||||
@@ -624,6 +631,28 @@ async function execAction(jsonParams) {
|
||||
}
|
||||
|
||||
const result = await executeTool('session_manager', params);
|
||||
|
||||
// Emit notification for write operations
|
||||
if (result.success && params.operation) {
|
||||
const writeOps = ['init', 'write', 'update', 'archive', 'mkdir', 'delete'];
|
||||
if (writeOps.includes(params.operation)) {
|
||||
const eventMap = {
|
||||
init: 'SESSION_CREATED',
|
||||
write: 'CONTENT_WRITTEN',
|
||||
update: 'SESSION_UPDATED',
|
||||
archive: 'SESSION_ARCHIVED',
|
||||
mkdir: 'DIRECTORY_CREATED',
|
||||
delete: 'FILE_DELETED'
|
||||
};
|
||||
notifyDashboard({
|
||||
type: eventMap[params.operation] || 'SESSION_UPDATED',
|
||||
sessionId: params.session_id,
|
||||
operation: params.operation,
|
||||
payload: result.result
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ const TEMPLATE_PATH = join(import.meta.dirname, '../templates/dashboard.html');
|
||||
const MODULE_CSS_DIR = join(import.meta.dirname, '../templates/dashboard-css');
|
||||
const JS_FILE = join(import.meta.dirname, '../templates/dashboard.js');
|
||||
const MODULE_JS_DIR = join(import.meta.dirname, '../templates/dashboard-js');
|
||||
const ASSETS_DIR = join(import.meta.dirname, '../templates/assets');
|
||||
|
||||
// Modular CSS files in load order
|
||||
const MODULE_CSS_FILES = [
|
||||
@@ -582,6 +583,34 @@ export async function startServer(options = {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Serve static assets (js, css)
|
||||
if (pathname.startsWith('/assets/')) {
|
||||
const assetPath = join(ASSETS_DIR, pathname.replace('/assets/', ''));
|
||||
if (existsSync(assetPath)) {
|
||||
const ext = assetPath.split('.').pop().toLowerCase();
|
||||
const mimeTypes = {
|
||||
'js': 'application/javascript',
|
||||
'css': 'text/css',
|
||||
'json': 'application/json',
|
||||
'png': 'image/png',
|
||||
'jpg': 'image/jpeg',
|
||||
'jpeg': 'image/jpeg',
|
||||
'svg': 'image/svg+xml',
|
||||
'woff': 'font/woff',
|
||||
'woff2': 'font/woff2',
|
||||
'ttf': 'font/ttf'
|
||||
};
|
||||
const contentType = mimeTypes[ext] || 'application/octet-stream';
|
||||
const content = readFileSync(assetPath);
|
||||
res.writeHead(200, {
|
||||
'Content-Type': contentType,
|
||||
'Cache-Control': 'public, max-age=31536000'
|
||||
});
|
||||
res.end(content);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 404
|
||||
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
||||
res.end('Not Found');
|
||||
|
||||
10
ccw/src/templates/assets/css/github-dark.min.css
vendored
Normal file
10
ccw/src/templates/assets/css/github-dark.min.css
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
|
||||
Theme: GitHub Dark
|
||||
Description: Dark theme as seen on github.com
|
||||
Author: github.com
|
||||
Maintainer: @Hirse
|
||||
Updated: 2021-05-15
|
||||
|
||||
Outdated base version: https://github.com/primer/github-syntax-dark
|
||||
Current colors taken from GitHub's CSS
|
||||
*/.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}
|
||||
10
ccw/src/templates/assets/css/github.min.css
vendored
Normal file
10
ccw/src/templates/assets/css/github.min.css
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
|
||||
Theme: GitHub
|
||||
Description: Light theme as seen on github.com
|
||||
Author: github.com
|
||||
Maintainer: @Hirse
|
||||
Updated: 2021-05-15
|
||||
|
||||
Outdated base version: https://github.com/primer/github-syntax-light
|
||||
Current colors taken from GitHub's CSS
|
||||
*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}
|
||||
2
ccw/src/templates/assets/js/d3.min.js
vendored
Normal file
2
ccw/src/templates/assets/js/d3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1244
ccw/src/templates/assets/js/highlight.min.js
vendored
Normal file
1244
ccw/src/templates/assets/js/highlight.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
ccw/src/templates/assets/js/lucide.min.js
vendored
Normal file
12
ccw/src/templates/assets/js/lucide.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
69
ccw/src/templates/assets/js/marked.min.js
vendored
Normal file
69
ccw/src/templates/assets/js/marked.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
83
ccw/src/templates/assets/js/tailwind.js
Normal file
83
ccw/src/templates/assets/js/tailwind.js
Normal file
File diff suppressed because one or more lines are too long
@@ -69,6 +69,8 @@ function handleNotification(data) {
|
||||
case 'PLAN_UPDATED':
|
||||
case 'REVIEW_UPDATED':
|
||||
case 'CONTENT_WRITTEN':
|
||||
case 'FILE_DELETED':
|
||||
case 'DIRECTORY_CREATED':
|
||||
// Route to state reducer for granular updates
|
||||
if (typeof handleWorkflowEvent === 'function') {
|
||||
handleWorkflowEvent({ type, ...payload });
|
||||
|
||||
@@ -177,6 +177,16 @@ function handleWorkflowEvent(event) {
|
||||
// Generic content write - just log for debugging
|
||||
console.log(`[State] Content written: ${event.contentType} for ${sessionId}`);
|
||||
break;
|
||||
|
||||
case 'FILE_DELETED':
|
||||
// File deleted from session - log and trigger refresh
|
||||
console.log(`[State] File deleted: ${payload?.file_path || payload?.deleted} from ${sessionId}`);
|
||||
break;
|
||||
|
||||
case 'DIRECTORY_CREATED':
|
||||
// Directory created in session - log and trigger refresh
|
||||
console.log(`[State] Directory created: ${payload?.directories?.join(', ') || 'unknown'} in ${sessionId}`);
|
||||
break;
|
||||
}
|
||||
|
||||
// Trigger UI updates
|
||||
|
||||
@@ -4,12 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>CCW Dashboard</title>
|
||||
<!-- Google Fonts: Inter -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<!-- Tailwind CSS CDN -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<!-- Tailwind CSS (本地) -->
|
||||
<script src="./assets/js/tailwind.js"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: ['class', '[data-theme="dark"]'],
|
||||
@@ -728,16 +724,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Lucide Icons -->
|
||||
<script src="https://unpkg.com/lucide@latest"></script>
|
||||
<!-- D3.js for Flowchart -->
|
||||
<script src="https://d3js.org/d3.v7.min.js"></script>
|
||||
<!-- Marked.js for Markdown rendering -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<!-- Highlight.js for Syntax Highlighting -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/styles/github-dark.min.css" id="hljs-theme-dark">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/styles/github.min.css" id="hljs-theme-light" disabled>
|
||||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/highlight.min.js"></script>
|
||||
<!-- Lucide Icons (本地) -->
|
||||
<script src="./assets/js/lucide.min.js"></script>
|
||||
<!-- D3.js for Flowchart (本地) -->
|
||||
<script src="./assets/js/d3.min.js"></script>
|
||||
<!-- Marked.js for Markdown rendering (本地) -->
|
||||
<script src="./assets/js/marked.min.js"></script>
|
||||
<!-- Highlight.js for Syntax Highlighting (本地) -->
|
||||
<link rel="stylesheet" href="./assets/css/github-dark.min.css" id="hljs-theme-dark">
|
||||
<link rel="stylesheet" href="./assets/css/github.min.css" id="hljs-theme-light" disabled>
|
||||
<script src="./assets/js/highlight.min.js"></script>
|
||||
|
||||
<script>
|
||||
{{JS_CONTENT}}
|
||||
|
||||
Reference in New Issue
Block a user