mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-15 07:36:50 +03:00
* Add DeepSeek Harness as a supported skills provider npx impeccable install now detects ~/.dsh (or $DSH_HOME when it sits under home) and installs into ~/.dsh/skills, the user-level skill root DeepSeek Harness scans, with project-level .dsh/skills on the same layout as other providers. Aliases: dsh, deepseek, deepseek-harness. Engine: PROVIDER_DIRS / aliases / display / input order / global hint, $DSH_HOME-aware user skills dir, provider id resolution from the skill dir, pin harness dirs, bundle path normalization for hashing. Build: dsh transformer target emitting the frontmatter DeepSeek Harness reads (user-invocable, license, compatibility, metadata; unknown keys are ignored there) with no emitHooks (DSH hooks are in-process plugins, not on-disk manifests) and no agentFormat (no documented on-disk subagent format); placeholders (AGENTS.md config file, ask_user_question tool, / command prefix), provider block tags, universal README entry. Docs: HARNESSES.md row and frontmatter column, CLI-CONTRACT constants, README/DEVELOP/AGENTS provider lists. Validation: cargo test --workspace; node scripts/run-tests.mjs core (138 pass); bun run build (19 providers, dist/dsh artifact verified); engine smoke against a fake HOME with a local bundle: install --providers=dsh --scope=global, auto-detected install, and update all resolve the .dsh provider. Generated provider output intentionally omitted per repo policy; the sync workflow regenerates tracked .dsh/skills after merge. Prepared with AI assistance (DeepSeek Harness coding agent). * Address review: DSH_HOME-only detection, generated-output pathspecs - Detect DeepSeek Harness through the resolved $DSH_HOME (fallback ~/.dsh) instead of gating on a fixed ~/.dsh path, so a DSH_HOME-only setup is offered by a provider-less install; generalize the two env-relocated config-dir hints (OpenCode, DSH) into one shared probe. - Add .dsh to the sync workflow's GENERATED_PATHS and CI's generated drift check so the tracked .dsh/skills payload is committed and validated. - Cover both behaviors: new install_detection_tests (DSH_HOME-only, default ~/.dsh, refused outside-home override) and a CLI-CONTRACT note on the resolved detection path. Validation: cargo test --workspace; node scripts/run-tests.mjs core (138 pass); engine smoke: DSH_HOME-only fake HOME installs globally into the resolved skills dir. Prepared with AI assistance (DeepSeek Harness coding agent). * Fix DeepSeek Harness home paths on Windows Use native relative-path containment, cover case and drive boundaries, and verify relocated global install/update without changing project skills. Add DSH output coverage and correct the install documentation. AI assistance: Codex, under pbakaus maintainer direction. * Document the CLI limit on external DSH homes Clarify that outside-home manual copies are not detected or updated by the CLI. AI assistance: Codex, under pbakaus maintainer direction. --------- Co-authored-by: Paul Bakaus <paul.bakaus@gmail.com>
122 lines
4.4 KiB
Rust
122 lines
4.4 KiB
Rust
//! Provider identity and skill-directory resolution for the binary.
|
|
//!
|
|
//! The JS scripts learn their provider at build time (`lib/provider.mjs`,
|
|
//! rewritten per harness) and find `../reference/` and `../SKILL.md` relative
|
|
//! to their own file. One binary serves every harness, so both are resolved
|
|
//! at run time:
|
|
//!
|
|
//! - **Skill dir**: `IMPECCABLE_SKILL_DIR` when set; otherwise walk up from the
|
|
//! executable's path (the binary ships at `<skill>/scripts/bin/<target>/` or
|
|
//! is launched via `<skill>/scripts/impeccable`) until a directory holding
|
|
//! `reference/ios.md` is found. `None` when neither works (source checkouts
|
|
//! running `target/debug/impeccable` need the env var).
|
|
//! - **Provider id**: `IMPECCABLE_PROVIDER_ID` when set; otherwise derived from
|
|
//! the skill dir's harness folder (`<root>/.codex/skills/impeccable` ->
|
|
//! `codex`); otherwise `source`, exactly what the JS reads in a source
|
|
//! checkout. The command prefix is `$` for `codex`, `/` for everything else.
|
|
//! - **Self command**: the text a directive prints where the JS printed
|
|
//! `node <scripts>/<script>.mjs`. `IMPECCABLE_SELF` when set (the launcher
|
|
//! exports it), else the executable path. Printed as `<self> <verb>`.
|
|
|
|
use crate::jsp;
|
|
use crate::util::Env;
|
|
|
|
pub const SOURCE_PROVIDER: &str = "source";
|
|
|
|
pub struct Provider {
|
|
pub id: String,
|
|
pub command_prefix: String,
|
|
/// `<prefix>impeccable`
|
|
pub command: String,
|
|
pub skill_dir: Option<String>,
|
|
/// How to spell this binary in printed commands.
|
|
pub self_cmd: String,
|
|
}
|
|
|
|
fn exe_path() -> Option<String> {
|
|
let exe = std::env::current_exe().ok()?;
|
|
Some(exe.to_string_lossy().into_owned())
|
|
}
|
|
|
|
fn find_skill_dir_from(start: &str) -> Option<String> {
|
|
let mut dir = start.to_string();
|
|
loop {
|
|
if crate::util::exists(&jsp::join(&[&dir, "reference", "ios.md"])) {
|
|
return Some(dir);
|
|
}
|
|
let parent = jsp::dirname(&dir);
|
|
if parent == dir {
|
|
return None;
|
|
}
|
|
dir = parent;
|
|
}
|
|
}
|
|
|
|
fn provider_from_skill_dir(skill_dir: &str) -> Option<&'static str> {
|
|
// <root>/<harness>/skills/impeccable
|
|
let skills = jsp::dirname(skill_dir);
|
|
if jsp::basename(&skills) != "skills" {
|
|
return None;
|
|
}
|
|
let harness = jsp::basename(&jsp::dirname(&skills));
|
|
Some(match harness.as_str() {
|
|
".claude" => "claude-code",
|
|
".cursor" => "cursor",
|
|
".dsh" => "dsh",
|
|
".gemini" => "gemini",
|
|
".codex" => "codex",
|
|
".agents" => "agents",
|
|
".github" => "github",
|
|
".kiro" => "kiro",
|
|
".opencode" => "opencode",
|
|
".pi" => "pi",
|
|
".qoder" => "qoder",
|
|
".trae" => "trae",
|
|
".trae-cn" => "trae-cn",
|
|
".rovodev" => "rovo-dev",
|
|
".vibe" => "vibe",
|
|
".grok" => "grok",
|
|
".agent" => "antigravity",
|
|
".hermes" => "hermes",
|
|
_ => return None,
|
|
})
|
|
}
|
|
|
|
pub fn detect(env: &Env, cwd: &str) -> Provider {
|
|
let skill_dir = match env.get("IMPECCABLE_SKILL_DIR").filter(|v| !v.trim().is_empty()) {
|
|
Some(v) => Some(jsp::resolve(cwd, &[v.trim()])),
|
|
None => exe_path().and_then(|p| find_skill_dir_from(&jsp::dirname(&p))),
|
|
};
|
|
let id = match env.get("IMPECCABLE_PROVIDER_ID").filter(|v| !v.trim().is_empty()) {
|
|
Some(v) => v.trim().to_string(),
|
|
None => skill_dir
|
|
.as_deref()
|
|
.and_then(provider_from_skill_dir)
|
|
.unwrap_or(SOURCE_PROVIDER)
|
|
.to_string(),
|
|
};
|
|
let command_prefix = if id == "codex" { "$" } else { "/" }.to_string();
|
|
let command = format!("{}impeccable", command_prefix);
|
|
let self_cmd = match env.get("IMPECCABLE_SELF").filter(|v| !v.trim().is_empty()) {
|
|
Some(v) => v.trim().to_string(),
|
|
None => exe_path().unwrap_or_else(|| "impeccable".to_string()),
|
|
};
|
|
Provider { id, command_prefix, command, skill_dir, self_cmd }
|
|
}
|
|
|
|
impl Provider {
|
|
/// `<skill>/reference/<name>.md`
|
|
pub fn reference_path(&self, name: &str) -> Option<String> {
|
|
self.skill_dir.as_ref().map(|d| jsp::join(&[d, "reference", &format!("{}.md", name)]))
|
|
}
|
|
/// `<skill>/SKILL.md`
|
|
pub fn skill_md_path(&self) -> Option<String> {
|
|
self.skill_dir.as_ref().map(|d| jsp::join(&[d, "SKILL.md"]))
|
|
}
|
|
/// The command a directive should print for a sibling verb, in place of
|
|
/// `node <scripts>/<verb>.mjs`.
|
|
pub fn verb_cmd(&self, verb: &str) -> String {
|
|
format!("{} {}", self.self_cmd, verb)
|
|
}
|
|
}
|