$npx -y skills add shareAI-lab/shareAI-skills --skill extract-agent-sessionsRecover, export, or summarize recent human and assistant conversations from local agent session stores while excluding tool calls, reasoning, system injection, copied parent history, and subagent noise. Use for recent-session inventories, clean conversation recovery, or topic sum
| 1 | # Extract Agent Sessions |
| 2 | |
| 3 | Use this skill as a storage map and decision guide, not as a stable parser. Treat |
| 4 | all local session layouts as unversioned implementation details. Inspect the files |
| 5 | that exist now, adapt shell commands to their observed shape, and fail closed when |
| 6 | the shape is ambiguous. |
| 7 | |
| 8 | Do not create or install a persistent extraction script. Compose one-off commands |
| 9 | from the current filesystem and shell capabilities. |
| 10 | |
| 11 | ## Safety defaults |
| 12 | |
| 13 | - Treat every session log as sensitive. It may contain source code, personal data, |
| 14 | secrets typed by the user, absolute paths, or credentials echoed by tools. |
| 15 | - Keep discovery local. Never upload a log or extracted artifact unless the user |
| 16 | explicitly asks for that destination. |
| 17 | - List candidates as temporary aliases such as `S1` and `S2`. Do not display prompt |
| 18 | previews, project names, working directories, complete IDs, or absolute paths by |
| 19 | default. Truncation is not redaction. |
| 20 | - Read message bodies only after the requested scope identifies the relevant |
| 21 | session or the user selects an alias. If content would be sent to another service |
| 22 | or person, disclose that boundary and obtain confirmation. |
| 23 | - Write private intermediate artifacts only under an owner-restricted temporary |
| 24 | directory. Remove them on normal exit and interruption unless the user explicitly |
| 25 | requests a private export. |
| 26 | - Never inspect authentication files, credential stores, environment snapshots, |
| 27 | shell history, debug logs, telemetry, crash dumps, clipboard data, or browser |
| 28 | storage for this task. |
| 29 | |
| 30 | ## Output modes |
| 31 | |
| 32 | Choose one mode before reading conversation bodies: |
| 33 | |
| 34 | - **Inventory**: aliases, store family, UTC activity time, transcript availability, |
| 35 | state, and warnings. This is the default discovery mode. |
| 36 | - **Private full**: every persisted human message and visible assistant text block |
| 37 | in order. Keep this owner-only and do not claim to redact it. |
| 38 | - **Shareable summary**: themes and outcomes with paths, stable IDs, attachment |
| 39 | references, secrets, and unnecessary verbatim text removed. |
| 40 | |
| 41 | “Lossless” means lossless relative to persisted visible text. Preserve a stored |
| 42 | placeholder such as `[Pasted Content ...]` or `[Image #1]` in private-full mode, but |
| 43 | state that the externalized body is unavailable. |
| 44 | |
| 45 | ## Select the shell guidance |
| 46 | |
| 47 | Resolve the current user's home directory without guessing another user's account. |
| 48 | This version supports Linux and macOS hosts: |
| 49 | |
| 50 | - Read [references/posix-shell.md](references/posix-shell.md) and compose commands |
| 51 | for the shell and utilities actually present. |
| 52 | - Under WSL, treat the Linux distribution as a separate environment and inspect it |
| 53 | only when the agent client ran there. Native Windows session stores are outside |
| 54 | this version's supported scope. |
| 55 | |
| 56 | Read [references/session-layouts.md](references/session-layouts.md) for the relevant |
| 57 | store family before selecting identity or message fields. |
| 58 | |
| 59 | ## Workflow |
| 60 | |
| 61 | ### 1. Freeze a UTC window |
| 62 | |
| 63 | Interpret “recent two days” as a rolling 48-hour interval unless the user asks for |
| 64 | calendar days. Capture one `[start, end]` snapshot and apply both bounds throughout |
| 65 | the scan so new writes do not move the reported window. |
| 66 | |
| 67 | Use history or visible-message timestamps for discussion recency. Use file size and |
| 68 | mtime only to detect active writes or prioritize fallback inspection; never treat |
| 69 | mtime as the conversation time. |
| 70 | |
| 71 | ### 2. Discover from small indexes |
| 72 | |
| 73 | Inspect keys and timestamp units before filtering the small history indexes. Keep |
| 74 | only the latest in-window entry per session ID in a private candidate map. Display |
| 75 | anonymous aliases and metadata only. |
| 76 | |
| 77 | History is a discovery index, not canonical conversation text. It can contain slash |
| 78 | commands, local shell commands, or abbreviated pasted content. |
| 79 | |
| 80 | ### 3. Resolve and prove root identity |
| 81 | |
| 82 | Resolve transcripts only for selected candidates. Constrain every path to an |
| 83 | approved data root, reject symlinks and unsafe IDs, and compare basenames exactly. |
| 84 | |
| 85 | For tree-shaped stores, accept only root-level project transcripts and exclude |
| 86 | every `subagents/` descendant. For rollout-shaped stores, inspect the first |
| 87 | projected `session_meta` before reading later records; reject explicit subagents |
| 88 | before they can contribute copied parent history. |
| 89 | |
| 90 | ### 4. Fingerprint the schema without content |
| 91 | |
| 92 | Project only key names, value types, role/type enums, content-block type names, and |
| 93 | counts. Do not print IDs, paths, timestamps, or text values. Collapse unrecognized |
| 94 | enum strings to an `unknown-string` marker, then compare the fingerprint to the |
| 95 | observed patterns in the reference. |
| 96 | |
| 97 | If require |