docs(comments): rewrite comments across all crates to the guidelines
Sweep every first-party crate source (1956 .rs files) to the project comment guidelines: delete redundant restatements, decorative banners, change narration, and end-of-line comments; keep and tighten the crucial ones (invariants, bug rationale, SAFETY blocks, ported-source attribution). No functional code changed. Every edit is proven comment-only against the prior tree by a comment-stripping lexer (string/char/raw-string aware) plus a separate doctest-fence check. Where removing a comment made rustfmt or clippy want to re-lay-out adjacent code, the minimal triggering comment is restored so code tokens stay byte-identical. Gates green: cargo fmt --all --check (0 diffs), cargo check and cargo clippy --workspace --all-targets (0 warnings). Adds scripts/check_codegen_comment_guidelines.py — the enforcement gate for these guidelines (flags banners, end-of-line comments, change narration, and commented-out code).
This commit is contained in:
1 parent
ff0fb56c67
commit
a02b555e66
1458 files changed
+10729
-21750
No files matched your search
@@ -4,7 +4,6 @@ use agent_client_protocol as acp;
|
||||
use kigi_tools::implementations::skills::skill::format_skill_name;
|
||||
use kigi_tools::implementations::skills::types::SkillInfo;
|
||||
|
||||
/// A built-in slash command.
|
||||
pub(crate) struct BuiltinCommand {
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
@@ -545,8 +544,8 @@ pub(super) fn available_commands(
|
||||
}))
|
||||
.meta(meta.clone())
|
||||
};
|
||||
// Always advertise the qualified name for plugin skills.
|
||||
// Also advertise the bare name if it doesn't collide.
|
||||
// Collision: advertise the qualified name only.
|
||||
// No collision: advertise the bare name only.
|
||||
if bare_collides {
|
||||
vec![make_entry(qualified)]
|
||||
} else {
|
||||
@@ -587,8 +586,6 @@ pub(crate) fn builtin_commands(availability: CommandAvailability) -> Vec<acp::Av
|
||||
.collect()
|
||||
}
|
||||
|
||||
// ── kigi/commands/list ext method ────────────────────────────────
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub(crate) struct ListCommandsRequest {
|
||||
pub cwd: Option<String>,
|
||||
@@ -621,8 +618,6 @@ pub(crate) async fn list_commands(
|
||||
}
|
||||
}
|
||||
|
||||
// ── Slash command resolution ────────────────────────────────────
|
||||
|
||||
/// A parsed skill reference from user input.
|
||||
///
|
||||
/// Produced by `parse_skill_references()` when scanning user text for known
|
||||
@@ -850,7 +845,8 @@ pub(crate) fn parse_skill_references(
|
||||
if let SlashCommand::Skill(s) = cmd {
|
||||
skill_map
|
||||
.entry(&s.name)
|
||||
.and_modify(|v| *v = None) // duplicate → mark ambiguous
|
||||
// duplicate → mark ambiguous
|
||||
.and_modify(|v| *v = None)
|
||||
.or_insert(Some(s));
|
||||
}
|
||||
}
|
||||
@@ -863,7 +859,6 @@ pub(crate) fn parse_skill_references(
|
||||
offset: usize,
|
||||
/// The text as typed by the user (e.g. "commit", "user:commit").
|
||||
typed_name: String,
|
||||
/// Resolved skill info.
|
||||
skill: &'a SkillInfo,
|
||||
}
|
||||
|
||||
@@ -881,11 +876,11 @@ pub(crate) fn parse_skill_references(
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
let start = i + 1; // skip '/'
|
||||
let start = i + 1;
|
||||
if start >= bytes.len() {
|
||||
break;
|
||||
}
|
||||
// Grab the word: everything until whitespace, '/' or end.
|
||||
// Grab the word: everything until whitespace or end.
|
||||
let end = trimmed[start..]
|
||||
.find(|c: char| c.is_whitespace())
|
||||
.map(|rel| start + rel)
|
||||
@@ -948,7 +943,8 @@ pub(crate) fn parse_skill_references(
|
||||
// Compute args for each hit: text from end-of-skill-token to start of next hit (or end).
|
||||
let mut refs = Vec::with_capacity(hits.len());
|
||||
for (idx, hit) in hits.iter().enumerate() {
|
||||
let word_end = hit.offset + 1 + hit.typed_name.len(); // past the /word
|
||||
// past the /word
|
||||
let word_end = hit.offset + 1 + hit.typed_name.len();
|
||||
let args_end = if idx + 1 < hits.len() {
|
||||
hits[idx + 1].offset
|
||||
} else {
|
||||
@@ -1237,8 +1233,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// ── description fallback ────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn skill_description_falls_back_when_no_short_description() {
|
||||
let skill = SkillInfo {
|
||||
@@ -1249,8 +1243,6 @@ mod tests {
|
||||
assert_eq!(cmd.description(), "A skill called deploy");
|
||||
}
|
||||
|
||||
// ── parse_slash_prefix ──────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn parse_slash_prefix_extracts_name_and_args() {
|
||||
assert_eq!(
|
||||
@@ -1281,8 +1273,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
// ── builtin resolve fns ─────────────────────────────────────────
|
||||
|
||||
fn resolve_builtin(name: &str, args: &str) -> Option<BuiltinAction> {
|
||||
BUILTIN_COMMANDS
|
||||
.iter()
|
||||
@@ -1327,7 +1317,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn yolo_alias_resolves_to_always_approve() {
|
||||
// /yolo should resolve via alias to the always-approve command
|
||||
let blocks = vec![text_block("/yolo on")];
|
||||
let outcome = resolve(blocks, &[], all_gated(), SkillSlashRewrite::default()).unwrap_err();
|
||||
assert!(matches!(
|
||||
@@ -1336,8 +1325,6 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
// ── resolve ─────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn resolve_routes_builtin() {
|
||||
let outcome = resolve(
|
||||
@@ -1510,7 +1497,6 @@ mod tests {
|
||||
SkillSlashRewrite::Passthrough,
|
||||
)
|
||||
.unwrap_err();
|
||||
// Original text is preserved in blocks.
|
||||
assert_eq!(invoke_text(outcome), "/commit fix typo");
|
||||
|
||||
let outcome = resolve(
|
||||
@@ -1573,8 +1559,6 @@ mod tests {
|
||||
assert!(matches!(outcome, SlashCommandOutcome::Builtin(_)));
|
||||
}
|
||||
|
||||
// ── available_commands (ACP) ─────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn available_commands_orders_builtins_first() {
|
||||
let skills = vec![make_skill("commit", true), make_skill("deploy", true)];
|
||||
@@ -1932,14 +1916,13 @@ mod tests {
|
||||
assert!(builtin.input.is_some());
|
||||
|
||||
let flush = commands.iter().find(|c| c.name == "flush").unwrap();
|
||||
assert!(flush.input.is_none()); // no argument_hint
|
||||
// no argument_hint
|
||||
assert!(flush.input.is_none());
|
||||
|
||||
let skill = commands.iter().find(|c| c.name == "commit").unwrap();
|
||||
assert_eq!(skill.description, "Short: commit");
|
||||
}
|
||||
|
||||
// ── /flush ─────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn flush_resolves_to_builtin_action() {
|
||||
assert!(matches!(
|
||||
@@ -1981,8 +1964,6 @@ mod tests {
|
||||
assert!(matches!(outcome, SlashCommandOutcome::Builtin(_)));
|
||||
}
|
||||
|
||||
// ── /dream ─────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn dream_resolves_to_builtin_action() {
|
||||
assert!(matches!(
|
||||
@@ -2023,8 +2004,6 @@ mod tests {
|
||||
assert!(matches!(outcome, SlashCommandOutcome::Builtin(_)));
|
||||
}
|
||||
|
||||
// ── ambiguous skill names ─────────────────────────────────────
|
||||
|
||||
fn make_scoped_skill(name: &str, scope: SkillScope) -> SkillInfo {
|
||||
SkillInfo {
|
||||
name: name.to_string(),
|
||||
@@ -2129,8 +2108,6 @@ mod tests {
|
||||
assert!(!names.contains(&"commit"));
|
||||
}
|
||||
|
||||
// ── builtin/skill name collisions ─────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn available_commands_qualifies_builtin_colliding_skill() {
|
||||
// A skill named "compact" collides with the builtin /compact.
|
||||
@@ -2212,7 +2189,6 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
/// Collect the advertised command names for the given availability.
|
||||
fn advertised_names_with(availability: CommandAvailability) -> Vec<String> {
|
||||
available_commands(&[], availability)
|
||||
.into_iter()
|
||||
@@ -2282,8 +2258,6 @@ mod tests {
|
||||
assert!(on.iter().any(|n| n == "memory"), "got: {on:?}");
|
||||
}
|
||||
|
||||
// ── /memory ─────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn memory_bare_resolves_to_browse() {
|
||||
assert!(matches!(
|
||||
@@ -2388,8 +2362,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
// ── parse_skill_references ──────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn parse_skill_refs_single_skill() {
|
||||
let skills = vec![make_skill("commit", true)];
|
||||
@@ -2479,8 +2451,6 @@ mod tests {
|
||||
assert_eq!(refs[0].args, "fix typo");
|
||||
}
|
||||
|
||||
// ── /goal command resolution ─────────────────────────────────
|
||||
|
||||
fn resolve_goal(args: &str) -> BuiltinAction {
|
||||
let blocks = vec![text_block(&format!("/goal {args}"))];
|
||||
match resolve(blocks, &[], all_gated(), SkillSlashRewrite::default()).unwrap_err() {
|
||||
@@ -2635,7 +2605,6 @@ mod tests {
|
||||
assert!(!BuiltinAction::GoalClear.args_provided());
|
||||
}
|
||||
|
||||
// ── GoalTracker handler-level interaction tests ──────────────
|
||||
// These test the exact tracker state transitions that the slash
|
||||
// command handlers perform, without constructing a full SessionActor.
|
||||
|
||||
|
||||
Reference in new issue
Block a user