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

45 lines
1.6 KiB
JavaScript

import { cli, Strategy } from '@jackwener/opencli/registry';
export const historyCommand = cli({
site: 'cursor',
name: 'history',
access: 'read',
description: 'List recent chat sessions from the Cursor sidebar',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [],
columns: ['Index', 'Title'],
func: async (page) => {
const items = await page.evaluate(`
(function() {
const results = [];
// Cursor chat history lives in sidebar items
const entries = document.querySelectorAll('.agent-sidebar-list-item, [data-testid="chat-history-item"], .chat-history-item, .tree-item');
entries.forEach((item, i) => {
const title = (item.textContent || item.innerText || '').trim().substring(0, 100);
if (title) results.push({ Index: i + 1, Title: title });
});
// Fallback: try to find sidebar text items
if (results.length === 0) {
const sidebar = document.querySelector('.sidebar, [class*="sidebar"], .agent-sidebar, .side-bar-container');
if (sidebar) {
const links = sidebar.querySelectorAll('a, [role="treeitem"], [role="option"]');
links.forEach((link, i) => {
const text = (link.textContent || '').trim().substring(0, 100);
if (text) results.push({ Index: i + 1, Title: text });
});
}
}
return results;
})()
`);
if (items.length === 0) {
return [{ Index: 0, Title: 'No chat history found. Open the AI sidebar first.' }];
}
return items;
},
});