nanocoai/nanoclaw / .claude/skills/add-cursor
add-cursor
FlaggedUse Cursor (local Agent SDK) as a full agent provider — planning, tool orchestration, MCP tools, session resume — alongside or instead of Claude. Cursor-account sign-in or API key, held by the credential gateway. Per-group via `ncl groups config update --provider cursor`. Distinct from using Cursor as a cloud agent (those run on Cursor VMs and are not this provider).
payload/container/agent-runner/src/providers/cursor-hook.ts
View on GitHub/**
* Cursor sessionStart / preCompact hook adapter.
*
* Cursor hooks speak JSON on stdin/stdout. NanoClaw's shared memory hook
* prints plain text. This wrapper maps Cursor's lifecycle events onto
* `memoryContextForSessionStart`. sessionStart takes `additional_context`.
* preCompact only forwards `user_message`, so compact returns that field.
*
* Invoked as: `bun /app/src/providers/cursor-hook.ts` (sessionStart)
* or: `bun /app/src/providers/cursor-hook.ts --compact` (preCompact)
*/
import fs from 'fs';
import { memoryContextForSessionStart, type MemorySessionStartSource } from '../memory/session-hook.js';
export function resolveSource(argv: string[], stdin: string): MemorySessionStartSource {
if (argv.includes('--compact')) return 'compact';
try {
const parsed: unknown = JSON.parse(stdin);
if (parsed && typeof parsed === 'object' && 'source' in parsed) {
const source = (parsed as { source?: unknown }).source;
if (source === 'compact' || source === 'clear' || source === 'startup' || source === 'resume') {
return source;
}
}
} catch {
/* Cursor sessionStart has no `source` field — treat as a new window. */
}
return 'startup';
}
export function hookPayload(
source: MemorySessionStartSource,
baseDir?: string,
): { additional_context?: string; user_message?: string } {
const context = memoryContextForSessionStart(source, baseDir);
if (!context) return {};
// Cursor's preCompact response copies only user_message into the compaction
// request. additional_context is the sessionStart field and is dropped here.
if (source === 'compact') return { user_message: context };
return { additional_context: context };
}
function readStdin(): string {
try {
return fs.readFileSync(0, 'utf-8');
} catch {
return '';
}
}
if (import.meta.main) {
const source = resolveSource(process.argv.slice(2), readStdin());
process.stdout.write(JSON.stringify(hookPayload(source)) + '\n');
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |