feat: add session intelligence — timeline, handoff, and lineage (#65)

* feat: add session intelligence — timeline, handoff, and lineage commands

Three new skill-centric session intelligence features:
- `skillkit timeline` — unified chronological event stream merging skill executions, git commits, observations, decisions, and snapshots
- `skillkit session handoff` — generates structured markdown for agent-to-agent context transfer with accomplished/pending tasks, key files, observations, and recommendations
- `skillkit lineage` — tracks skill impact graph connecting skills to files, commits, and observations with aggregate stats

Includes 44 tests, updated docs/website to reflect 44 agents, and CodeRabbit review fixes (defensive access, type validation, double-count prevention).

* fix: address CodeRabbit review round 2

- Fix primer.mdx example: "29 more agents" → "41 more agents"
- Validate invalid since date in timeline (return empty instead of silent filter-all)
- Guard hist.durationMs with Number.isFinite before formatting
- Fix misleading "commits" label → "changes" for activity log entries
This commit is contained in:
Rohit Ghumare
2026-02-14 07:11:44 +00:00
committed by GitHub
parent ff089429ae
commit 7e3b31b43b
25 changed files with 2626 additions and 16 deletions
+55
View File
@@ -0,0 +1,55 @@
import { Command, Option } from 'clipanion';
import { writeFileSync } from 'node:fs';
import chalk from 'chalk';
import { SessionHandoff } from '@skillkit/core';
export class SessionHandoffCommand extends Command {
static override paths = [['session', 'handoff']];
static override usage = Command.Usage({
description: 'Generate agent-to-agent session handoff document',
examples: [
['Print handoff to stdout', '$0 session handoff'],
['Target agent recommendations', '$0 session handoff --to cursor'],
['Save to file', '$0 session handoff --out handoff.md'],
['JSON output', '$0 session handoff --json'],
],
});
to = Option.String('--to', {
description: 'Target agent for recommendations',
});
out = Option.String('--out,-o', {
description: 'Save handoff to file',
});
json = Option.Boolean('--json,-j', false, {
description: 'Output as JSON',
});
async execute(): Promise<number> {
const projectPath = process.cwd();
const handoff = new SessionHandoff(projectPath);
const doc = handoff.generate({
targetAgent: this.to,
});
const output = this.json ? handoff.toJson(doc) : handoff.toMarkdown(doc);
if (this.out) {
try {
writeFileSync(this.out, output, 'utf-8');
console.log(chalk.green(`Handoff saved to ${this.out}`));
} catch (error) {
console.error(chalk.red(`Failed to write file: ${(error as Error).message}`));
return 1;
}
} else {
console.log(output);
}
return 0;
}
}
+3
View File
@@ -127,6 +127,9 @@ export { ServeCommand } from './serve.js';
export { ScanCommand } from './scan.js';
export { IssuePlanCommand, IssueListCommand } from './issue.js';
export { DoctorCommand } from './doctor.js';
export { TimelineCommand } from './timeline.js';
export { SessionHandoffCommand } from './handoff.js';
export { LineageCommand } from './lineage.js';
export { SaveCommand } from './save.js';
export {
AgentsMdCommand,
+66
View File
@@ -0,0 +1,66 @@
import { Command, Option } from 'clipanion';
import chalk from 'chalk';
import { SkillLineage } from '@skillkit/core';
export class LineageCommand extends Command {
static override paths = [['lineage']];
static override usage = Command.Usage({
description: 'Show skill impact lineage — which skills produced which changes',
examples: [
['Full overview', '$0 lineage'],
['Single skill', '$0 lineage --skill code-simplifier'],
['Single file', '$0 lineage --file src/index.ts'],
['Date filter + JSON', '$0 lineage --since 2026-02-01 --json'],
],
});
skill = Option.String('--skill,-s', {
description: 'Filter by skill name',
});
file = Option.String('--file,-f', {
description: 'Filter by file path',
});
since = Option.String('--since', {
description: 'Show lineage since date (YYYY-MM-DD)',
});
limit = Option.String('--limit,-l', {
description: 'Max entries to show',
});
json = Option.Boolean('--json,-j', false, {
description: 'Output as JSON',
});
async execute(): Promise<number> {
const projectPath = process.cwd();
const lineage = new SkillLineage(projectPath);
const parsed = this.limit ? parseInt(this.limit, 10) : undefined;
const limit = parsed && Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
const data = lineage.build({
skill: this.skill,
file: this.file,
since: this.since,
limit,
});
if (this.json) {
console.log(lineage.formatJson(data));
return 0;
}
if (data.skills.length === 0) {
console.log(chalk.yellow('No skill lineage found.'));
console.log(chalk.dim('Lineage is built from skill execution history and activity logs.'));
return 0;
}
console.log(lineage.formatText(data));
return 0;
}
}
+83
View File
@@ -0,0 +1,83 @@
import { Command, Option } from 'clipanion';
import chalk from 'chalk';
import { SessionTimeline } from '@skillkit/core';
import type { TimelineEventType } from '@skillkit/core';
export class TimelineCommand extends Command {
static override paths = [['timeline']];
static override usage = Command.Usage({
description: 'Show unified session event timeline',
examples: [
['Show last 50 events', '$0 timeline'],
['Filter by type', '$0 timeline --type git_commit'],
['Filter by skill', '$0 timeline --skill code-simplifier'],
['Date filter', '$0 timeline --since 2026-02-10'],
['JSON output with limit', '$0 timeline --limit 20 --json'],
],
});
type = Option.String('--type,-t', {
description: 'Filter by event type (skill_start, skill_complete, task_progress, git_commit, observation, decision, snapshot)',
});
skill = Option.String('--skill,-s', {
description: 'Filter by skill name',
});
since = Option.String('--since', {
description: 'Show events since date (YYYY-MM-DD)',
});
limit = Option.String('--limit,-l', {
description: 'Max events to show (default: 50)',
});
json = Option.Boolean('--json,-j', false, {
description: 'Output as JSON',
});
async execute(): Promise<number> {
const projectPath = process.cwd();
const timeline = new SessionTimeline(projectPath);
const parsed = this.limit ? parseInt(this.limit, 10) : 50;
const limit = Number.isFinite(parsed) && parsed > 0 ? parsed : 50;
const validTypes: TimelineEventType[] = [
'skill_start', 'skill_complete', 'task_progress',
'git_commit', 'observation', 'decision', 'snapshot',
];
let types: TimelineEventType[] | undefined;
if (this.type) {
if (!validTypes.includes(this.type as TimelineEventType)) {
console.log(chalk.red(`Invalid event type: ${this.type}`));
console.log(chalk.dim(`Valid types: ${validTypes.join(', ')}`));
return 1;
}
types = [this.type as TimelineEventType];
}
const data = timeline.build({
since: this.since,
types,
limit,
skillFilter: this.skill,
});
if (this.json) {
console.log(timeline.formatJson(data));
return 0;
}
if (data.events.length === 0) {
console.log(chalk.yellow('No timeline events found.'));
console.log(chalk.dim('Events are recorded during skill execution, git commits, and observations.'));
return 0;
}
console.log(timeline.formatText(data));
return 0;
}
}