Files
Regolith/skills-engine/types.ts
gavrielc 51788de3b9 Skills engine v0.1 + multi-channel infrastructure (#307)
* refactor: multi-channel infrastructure with explicit channel/is_group tracking

- Add channels[] array and findChannel() routing in index.ts, replacing
  hardcoded whatsapp.* calls with channel-agnostic callbacks
- Add channel TEXT and is_group INTEGER columns to chats table with
  COALESCE upsert to protect existing values from null overwrites
- is_group defaults to 0 (safe: unknown chats excluded from groups)
- WhatsApp passes explicit channel='whatsapp' and isGroup to onChatMetadata
- getAvailableGroups filters on is_group instead of JID pattern matching
- findChannel logs warnings instead of silently dropping unroutable JIDs
- Migration backfills channel/is_group from JID patterns for existing DBs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: skills engine v0.1 — deterministic skill packages with rerere resolution

Three-way merge engine for applying skill packages on top of a core
codebase. Skills declare which files they add/modify, and the engine
uses git merge-file for conflict detection with git rerere for
automatic resolution of previously-seen conflicts.

Key components:
- apply: three-way merge with backup/rollback safety net
- replay: clean-slate replay for uninstall and rebase
- update: core version updates with deletion detection
- rebase: bake applied skills into base (one-way)
- manifest: validation with path traversal protection
- resolution-cache: pre-computed rerere resolutions
- structured: npm deps, env vars, docker-compose merging
- CI: per-skill test matrix with conflict detection

151 unit tests covering merge, rerere, backup, replay, uninstall,
update, rebase, structured ops, and edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add Discord and Telegram skill packages

Skill packages for adding Discord and Telegram channels to NanoClaw.
Each package includes:
- Channel implementation (add/src/channels/)
- Three-way merge targets for index.ts, config.ts, routing.test.ts
- Intent docs explaining merge invariants
- Standalone integration tests
- manifest.yaml with dependency/conflict declarations

Applied via: npx tsx scripts/apply-skill.ts .claude/skills/add-discord
These are inert until applied — no runtime impact.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* remove unused docs (skills-system-status, implementation-guide)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 01:55:00 +02:00

135 lines
3.0 KiB
TypeScript

export interface SkillManifest {
skill: string;
version: string;
description: string;
core_version: string;
adds: string[];
modifies: string[];
structured?: {
npm_dependencies?: Record<string, string>;
env_additions?: string[];
docker_compose_services?: Record<string, unknown>;
};
file_ops?: FileOperation[];
conflicts: string[];
depends: string[];
test?: string;
author?: string;
license?: string;
min_skills_system_version?: string;
tested_with?: string[];
post_apply?: string[];
}
export interface SkillState {
skills_system_version: string;
core_version: string;
applied_skills: AppliedSkill[];
custom_modifications?: CustomModification[];
path_remap?: Record<string, string>;
rebased_at?: string;
}
export interface AppliedSkill {
name: string;
version: string;
applied_at: string;
file_hashes: Record<string, string>;
structured_outcomes?: Record<string, unknown>;
custom_patch?: string;
custom_patch_description?: string;
}
export interface ApplyResult {
success: boolean;
skill: string;
version: string;
mergeConflicts?: string[];
backupPending?: boolean;
untrackedChanges?: string[];
error?: string;
}
export interface MergeResult {
clean: boolean;
exitCode: number;
}
export interface FileOperation {
type: 'rename' | 'delete' | 'move';
from?: string;
to?: string;
path?: string;
}
export interface FileOpsResult {
success: boolean;
executed: FileOperation[];
warnings: string[];
errors: string[];
}
export interface CustomModification {
description: string;
applied_at: string;
files_modified: string[];
patch_file: string;
}
export interface FileInputHashes {
base: string; // SHA-256 of .nanoclaw/base/<relPath>
current: string; // SHA-256 of working tree <relPath> before this merge
skill: string; // SHA-256 of skill's modify/<relPath>
}
export interface ResolutionMeta {
skills: string[];
apply_order: string[];
core_version: string;
resolved_at: string;
tested: boolean;
test_passed: boolean;
resolution_source: 'maintainer' | 'user' | 'claude';
input_hashes: Record<string, string>;
output_hash: string;
file_hashes: Record<string, FileInputHashes>;
}
export interface UpdatePreview {
currentVersion: string;
newVersion: string;
filesChanged: string[];
filesDeleted: string[];
conflictRisk: string[];
customPatchesAtRisk: string[];
}
export interface UpdateResult {
success: boolean;
previousVersion: string;
newVersion: string;
mergeConflicts?: string[];
backupPending?: boolean;
customPatchFailures?: string[];
skillReapplyResults?: Record<string, boolean>;
error?: string;
}
export interface UninstallResult {
success: boolean;
skill: string;
customPatchWarning?: string;
replayResults?: Record<string, boolean>;
error?: string;
}
export interface RebaseResult {
success: boolean;
patchFile?: string;
filesInPatch: number;
rebased_at?: string;
mergeConflicts?: string[];
backupPending?: boolean;
error?: string;
}