MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / skill_history

Function skill_history

openkb/cli.py:2429–2473  ·  view source on GitHub ↗

List previous iterations of a skill.

(ctx, name)

Source from the content-addressed store, hash-verified

2427@click.argument("name")
2428@click.pass_context
2429def skill_history(ctx, name):
2430 """List previous iterations of a skill."""
2431 import datetime as _dt
2432
2433 from openkb.skill.workspace import list_iterations
2434
2435 kb_dir = _find_kb_dir(ctx.obj.get("kb_dir_override"))
2436 if kb_dir is None:
2437 click.echo("No knowledge base found. Run `openkb init` first.", err=True)
2438 ctx.exit(1)
2439
2440 err = _validate_skill_name(name)
2441 if err:
2442 click.echo(f"[ERROR] {err}", err=True)
2443 ctx.exit(1)
2444
2445 iters = list_iterations(kb_dir, name)
2446 if not iters:
2447 click.echo(f"No previous iterations for '{name}'.")
2448 return
2449
2450 click.echo(f"Iterations of '{name}' ({len(iters)} total):\n")
2451 click.echo(" N Path Created")
2452 click.echo(" - -------------------------------------------------- -------")
2453 for path in iters:
2454 n = int(path.name.split("-", 1)[1])
2455 rel = path.relative_to(kb_dir)
2456 try:
2457 mtime = _dt.datetime.fromtimestamp(path.stat().st_mtime)
2458 stamp = mtime.strftime("%Y-%m-%d %H:%M")
2459 except OSError:
2460 stamp = "-"
2461 click.echo(f" {n} {rel} {stamp}")
2462
2463 from openkb.skill import skill_dir
2464
2465 current = skill_dir(kb_dir, name)
2466 if current.is_dir():
2467 rel_curr = current.relative_to(kb_dir)
2468 click.echo(f"\n Current: {rel_curr}/")
2469
2470 latest_n = int(iters[-1].name.split("-", 1)[1])
2471 click.echo("\nRestore an iteration:")
2472 click.echo(f" openkb skill rollback {name} # restore latest (iteration-{latest_n})")
2473 click.echo(f" openkb skill rollback {name} --to 1 # restore iteration-1")
2474
2475
2476@skill.command("rollback")

Callers

nothing calls this directly

Calls 5

list_iterationsFunction · 0.90
skill_dirFunction · 0.90
_find_kb_dirFunction · 0.85
_validate_skill_nameFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected