mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-04 01:40:45 +08:00
- Implemented CliCommandNode component for executing CLI tools with AI models. - Implemented PromptNode component for constructing AI prompts with context. - Added styling for mode and tool badges in both components. - Enhanced user experience with command and argument previews, execution status, and error handling. test: add comprehensive tests for ask_question tool - Created direct test for ask_question tool execution. - Developed end-to-end tests to validate ask_question tool integration with WebSocket and A2UI surfaces. - Implemented simple and integrated WebSocket tests to ensure proper message handling and surface reception. - Added tool registration test to verify ask_question tool is correctly registered. chore: add WebSocket listener and simulation tests - Added WebSocket listener for A2UI surfaces to facilitate testing. - Implemented frontend simulation test to validate complete flow from backend to frontend. - Created various test scripts to ensure robust testing of ask_question tool functionality.
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"use strict";(globalThis.webpackChunkccw_docs=globalThis.webpackChunkccw_docs||[]).push([[934],{1184(e,n,r){r.d(n,{R:()=>o,x:()=>c});var s=r(3696);const t={},i=s.createContext(t);function o(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:o(e.components),s.createElement(i.Provider,{value:n},e.children)}},5792(e,n,r){r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>c,default:()=>m,frontMatter:()=>o,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"commands/memory/memory-compact","title":"/memory:compact","description":"Compact session memory into structured text for recovery","source":"@site/docs/commands/memory/memory-compact.mdx","sourceDirName":"commands/memory","slug":"/commands/memory/memory-compact","permalink":"/docs/docs/commands/memory/memory-compact","draft":false,"unlisted":false,"editUrl":"https://github.com/ccw/docs/tree/main/docs/commands/memory/memory-compact.mdx","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{"title":"/memory:compact","sidebar_label":"/memory:compact","sidebar_position":6,"description":"Compact session memory into structured text for recovery"},"sidebar":"docs","previous":{"title":"/memory:docs-related-cli","permalink":"/docs/docs/commands/memory/memory-docs-related-cli"},"next":{"title":"/memory:update-full","permalink":"/docs/docs/commands/memory/memory-update-full"}}');var t=r(2540),i=r(1184);const o={title:"/memory:compact",sidebar_label:"/memory:compact",sidebar_position:6,description:"Compact session memory into structured text for recovery"},c="/memory",a={},l=[{value:"Overview",id:"overview",level:2},{value:"Features",id:"features",level:2},{value:"Usage",id:"usage",level:2},{value:"Execution Flow",id:"execution-flow",level:2},{value:"Phase 1: Session Analysis",id:"phase-1-session-analysis",level:3},{value:"Phase 2: Structure Extraction",id:"phase-2-structure-extraction",level:3},{value:"Phase 3: Structured Text Generation",id:"phase-3-structured-text-generation",level:3},{value:"Phase 4: MCP Import",id:"phase-4-mcp-import",level:3},{value:"Output Format",id:"output-format",level:2},{value:"Structured Text Template",id:"structured-text-template",level:2},{value:"Examples",id:"examples",level:2},{value:"Basic Usage",id:"basic-usage",level:3},{value:"With Custom Description",id:"with-custom-description",level:3},{value:"With Tags",id:"with-tags",level:3},{value:"Recovery",id:"recovery",level:2},{value:"Use Cases",id:"use-cases",level:2},{value:"Related Commands",id:"related-commands",level:2},{value:"Notes",id:"notes",level:2}];function d(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsxs)(n.h1,{id:"memory",children:["/memory",":compact"]})}),"\n",(0,t.jsx)(n.p,{children:"Compress current session working memory into structured text optimized for session recovery and persistent storage."}),"\n",(0,t.jsx)(n.h2,{id:"overview",children:"Overview"}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"/memory:compact"})," command compresses the current session's working memory into structured text, extracting critical information and saving it to persistent storage via MCP ",(0,t.jsx)(n.code,{children:"core_memory"})," tool."]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:'--description="..."'}),": Custom session description"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"--tags=<tag1,tag2>"}),": Add custom tags"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"--force"}),": Override existing memory without confirmation"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Execution Flow"}),":"]}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"Session Analysis \u2192 2. Structure Extraction \u2192 3. Text Generation \u2192 4. MCP Import"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"features",children:"Features"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Session Compression"})," - Extracts key information from working memory"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Structured Format"})," - Organizes content for easy recovery"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Critical State Capture"})," - Preserves objectives, plans, and decisions"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Tag Support"})," - Add custom tags for organization"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Persistent Storage"})," - Saves via MCP core_memory tool"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Session Recovery"})," - Enables resuming from compacted state"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'# Compact current session\r\n/memory:compact\r\n\r\n# With custom description\r\n/memory:compact --description="User authentication implementation"\r\n\r\n# With tags\r\n/memory:compact --tags=auth,security,api\r\n\r\n# Force overwrite\r\n/memory:compact --force\n'})}),"\n",(0,t.jsx)(n.h2,{id:"execution-flow",children:"Execution Flow"}),"\n",(0,t.jsx)(n.h3,{id:"phase-1-session-analysis",children:"Phase 1: Session Analysis"}),"\n",(0,t.jsx)(n.p,{children:"Analyze current session state to extract:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"Session objectives and goals"}),"\n",(0,t.jsx)(n.li,{children:"Implementation plan"}),"\n",(0,t.jsx)(n.li,{children:"Files modified"}),"\n",(0,t.jsx)(n.li,{children:"Key decisions made"}),"\n",(0,t.jsx)(n.li,{children:"Constraints and requirements"}),"\n",(0,t.jsx)(n.li,{children:"Current state"}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"phase-2-structure-extraction",children:"Phase 2: Structure Extraction"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-javascript",children:"const sessionAnalysis = {\r\n objective: extract_objective(session),\r\n plan: extract_plan(session),\r\n files: extract_files(session),\r\n decisions: extract_decisions(session),\r\n constraints: extract_constraints(session),\r\n state: extract_state(session),\r\n notes: extract_notes(session)\r\n};\n"})}),"\n",(0,t.jsx)(n.h3,{id:"phase-3-structured-text-generation",children:"Phase 3: Structured Text Generation"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"# Session: {session_id}\r\n\r\n## Objective\r\n{objective}\r\n\r\n## Implementation Plan\r\n{plan}\r\n\r\n## Files Modified\r\n{files}\r\n\r\n## Key Decisions\r\n{decisions}\r\n\r\n## Constraints\r\n{constraints}\r\n\r\n## Current State\r\n{state}\r\n\r\n## Notes\r\n{notes}\n"})}),"\n",(0,t.jsx)(n.h3,{id:"phase-4-mcp-import",children:"Phase 4: MCP Import"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-javascript",children:'mcp__ccw-tools__core_memory({\r\n operation: "import",\r\n text: structuredText\r\n})\n'})}),"\n",(0,t.jsx)(n.h2,{id:"output-format",children:"Output Format"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",children:'{\r\n "operation": "import",\r\n "id": "CMEM-YYYYMMDD-HHMMSS",\r\n "message": "Created memory: CMEM-YYYYMMDD-HHMMSS"\r\n}\n'})}),"\n",(0,t.jsx)(n.h2,{id:"structured-text-template",children:"Structured Text Template"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-markdown",children:"# Session: {session_id}\r\n\r\n**Date**: {timestamp}\r\n**Description**: {custom_description or auto-generated}\r\n**Tags**: {tags}\r\n\r\n---\r\n\r\n## Objective\r\n\r\n{session_objective}\r\n\r\n---\r\n\r\n## Implementation Plan\r\n\r\n{implementation_plan}\r\n\r\n---\r\n\r\n## Files Modified\r\n\r\n| File | Changes |\r\n|------|---------|\r\n| {file1} | {changes1} |\r\n| {file2} | {changes2} |\r\n\r\n---\r\n\r\n## Key Decisions\r\n\r\n1. {decision1}\r\n2. {decision2}\r\n3. {decision3}\r\n\r\n---\r\n\r\n## Constraints\r\n\r\n- {constraint1}\r\n- {constraint2}\r\n\r\n---\r\n\r\n## Current State\r\n\r\n{current_state}\r\n\r\n---\r\n\r\n## Notes\r\n\r\n{additional_notes}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"examples",children:"Examples"}),"\n",(0,t.jsx)(n.h3,{id:"basic-usage",children:"Basic Usage"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"# Compact current session\r\n/memory:compact\r\n\r\n# Output:\r\n# Analyzing session...\r\n# Extracting key information...\r\n# Generating structured text...\r\n# Importing to core memory...\r\n# \u2705 Memory compacted: CMEM-20250203-143022\n"})}),"\n",(0,t.jsx)(n.h3,{id:"with-custom-description",children:"With Custom Description"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'# Compact with description\r\n/memory:compact --description="OAuth2 implementation"\r\n\r\n# Description is saved with the memory\n'})}),"\n",(0,t.jsx)(n.h3,{id:"with-tags",children:"With Tags"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"# Compact with tags\r\n/memory:compact --tags=oauth,authentication,security\r\n\r\n# Tags help with organization and retrieval\n"})}),"\n",(0,t.jsx)(n.h2,{id:"recovery",children:"Recovery"}),"\n",(0,t.jsx)(n.p,{children:"To recover a compacted session:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'# List available memories\r\nmcp__ccw-tools__core_memory({ operation: "list" })\r\n\r\n# Export specific memory\r\nmcp__ccw-tools__core_memory({ operation: "export", id: "CMEM-YYYYMMDD-HHMMSS" })\r\n\r\n# Search for memories\r\nmcp__ccw-tools__core_memory({ operation: "search", query: "oauth" })\n'})}),"\n",(0,t.jsx)(n.h2,{id:"use-cases",children:"Use Cases"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Session Handoff"})," - Preserve context for later continuation"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Knowledge Base"})," - Store insights and decisions for reference"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Team Sharing"})," - Share session state with team members"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Documentation"})," - Generate structured records of work sessions"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Recovery"})," - Restore session state after interruption"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"related-commands",children:"Related Commands"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsxs)(n.strong,{children:["/memory",":load"]})," - Load project context into memory"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsxs)(n.strong,{children:["/memory",":update-full"]})," - Update all CLAUDE.md files"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsxs)(n.strong,{children:["/memory",":update-related"]})," - Update changed CLAUDE.md files"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Persistent storage"})," - Saved via MCP core_memory tool"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Structured format"})," - Optimized for readability and parsing"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Automatic ID generation"})," - Format: CMEM-YYYYMMDD-HHMMSS"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Force option"})," - Override existing memory without confirmation"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Tag support"})," - Add custom tags for organization and search"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"Custom description"})," - Add meaningful description for easy identification"]}),"\n"]})]})}function m(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}}}]); |