Files
wehub-resource-sync 9b395f5cc3
Build Chrome Extension / build (push) Waiting to run
Trigger Website Rebuild (Docs Updated) / dispatch (push) Waiting to run
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

41 lines
1.3 KiB
JavaScript

import { cli, Strategy } from '@jackwener/opencli/registry';
export const readCommand = cli({
site: 'chatwise',
name: 'read',
access: 'read',
description: 'Read the current ChatWise conversation history',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [],
columns: ['Content'],
func: async (page) => {
const content = await page.evaluate(`
(function() {
// Try common chat message selectors
const selectors = [
'[data-message-id]',
'[class*="message"]',
'[class*="chat-item"]',
'[class*="bubble"]',
'[role="log"] > *',
];
for (const sel of selectors) {
const nodes = document.querySelectorAll(sel);
if (nodes.length > 0) {
return Array.from(nodes).map(n => (n.innerText || n.textContent).trim()).filter(Boolean).join('\\n\\n---\\n\\n');
}
}
// Fallback: main content area
const main = document.querySelector('main, [role="main"], [class*="chat-container"], [class*="conversation"]');
if (main) return main.innerText || main.textContent;
return document.body.innerText;
})()
`);
return [{ Content: content }];
},
});