Loading...
Loading...
AI Debugging Collaboration Solution. Convert console.log into HTTP requests to collect logs. After the user completes operations, AI can automatically view and analyze the logs without the need for screenshots or copying console content. Supports Claude Code, OpenCode, Cursor.
npx skill4agent add dimple-smile/agent-skills dev-logUser: Write a React counter component
Agent: I'll create a counter component and add logs to verify the functionality works properly.
[Start dev-log service, generate sessionId: sess_8x7k2p]
```jsx
function Counter() {
const [count, setCount] = useState(0);
const increment = () => {
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_8x7k2p',time:new Date().toTimeString().split(' ')[0],type:'before-increment',data:{count}})}).catch(()=>{});
setCount(c => c + 1);
};
return <button onClick={increment}>Count: {count}</button>;
}
### Example 2: Track Asynchronous Requests
```markdown
User: This async function sometimes fails, help me check it
Agent: [uses dev-log skill] Starting log service...
```javascript
async function fetchData(userId) {
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_a1b2c3',time:new Date().toTimeString().split(' ')[0],type:'fetch-start',data:{userId}})}).catch(()=>{});
try {
const response = await fetch(`/api/users/${userId}`);
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_a1b2c3',time:new Date().toTimeString().split(' ')[0],type:'fetch-response',data:{status:response.status,ok:response.ok}})}).catch(()=>{});
if (!response.ok) {
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_a1b2c3',time:new Date().toTimeString().split(' ')[0],type:'fetch-error',data:{status:response.status}})}).catch(()=>{});
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_a1b2c3',time:new Date().toTimeString().split(' ')[0],type:'fetch-success',data:{hasData:!!data}})}).catch(()=>{});
return data;
} catch (error) {
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_a1b2c3',time:new Date().toTimeString().split(' ')[0],type:'catch-error',data:{message:error.message}})}).catch(()=>{});
throw error;
}
}/api/users/${userId}
### Example 3: Form Validation Tracking
```markdown
User: Write validation logic for a login form
Agent: [Start dev-log, generate sessionId: sess_valid9]
```javascript
function validateLoginForm(form) {
const email = form.email.value;
const password = form.password.value;
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_valid9',time:new Date().toTimeString().split(' ')[0],type:'validate-input',data:{field:'email',value:email}})}).catch(()=>{});
const errors = {};
if (!email) {
errors.email = '邮箱不能为空';
}
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_valid9',time:new Date().toTimeString().split(' ')[0],type:'validate-result',data:{field:'email',valid:!!email}})}).catch(()=>{});
// ... More validation
fetch('http://localhost:54321',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'sess_valid9',time:new Date().toTimeString().split(' ')[0],type:'final-result',data:{errorCount:Object.keys(errors).length}})}).catch(()=>{});
return { valid: Object.keys(errors).length === 0, errors };
}
## Implementation
### Service Startup
**Startup Command:**
```bash
cd skills/dev-log && ./start.shport.txtport.txtpid.txt./skills/dev-log/
├── start.sh # Startup script (check/start service)
├── read-log.sh # Log reading script (supports filtering)
├── server.js # HTTP server (ESM module)
├── pid.txt # Service process ID
├── port.txt # Service port
└── dev-logs.json # Log file (JSON format)./skills/dev-log/read-log.sh./skills/dev-log/read-log.sh "$SESSION_ID"fetch('http://localhost:PORT',{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({
sessionId:'SESSION_ID',
time:'TIME',
type:'TYPE',
data:DATA
})
}).catch(()=>{})fetch('http://localhost:PORT',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'SID',time:'TIME',type:'TYPE',data:DATA})}).catch(()=>{})PORTskills/dev-log/port.txtSESSION_IDsess_TIME14:23:05new Date().toTimeString().split(' ')[0]TYPEstateerrorvalidationrequestresponsefetch-startDATAsess_xxxxxxxxport.txtdev-logs.json{"sessionId":"sess_abc123","time":"14:23:05","type":"state","data":{...}}.catch(()=>{})