fix: strip AI reasoning blocks from commit messages

Adds a `_strip_think` function using `awk` to buffer stdin and track the last `</think>` tag, emitting only the subsequent content. This utility is now piped after `aichat` calls to remove AI reasoning blocks before commit message generation. Also applies minor whitespace and indentation adjustments throughout the script.
This commit is contained in:
Eric Coissac
2026-05-02 18:01:31 +02:00
parent 0b784242cf
commit 602f414957
4 changed files with 65 additions and 33 deletions
+2
View File
@@ -12,6 +12,7 @@ pub mod kmer;
mod revcomp_lookup;
/// Routable super-kmer: canonical sequence paired with its minimizer for scatter routing.
pub mod routable;
mod sequence;
pub mod superkmer;
pub mod unitig;
@@ -19,4 +20,5 @@ pub mod unitig;
pub use annotations::Annotation;
pub use kmer::CanonicalKmer;
pub use routable::RoutableSuperKmer;
pub use sequence::Sequence;
pub use superkmer::SuperKmer;
+5 -2
View File
@@ -1,5 +1,8 @@
use crate::Annotation;
pub trait Sequence {
fn sequence(&self) -> &[u8];
fn canonical(&self) -> Self;
fn sequence(&self) -> Box<[u8]>;
fn canonical(&self) -> &Self;
fn seq_hash(&self) -> u64;
fn annotation(&self) -> Annotation;
}
+20 -8
View File
@@ -1,13 +1,14 @@
//! Compact 2-bit DNA super-kmer with in-place reverse complement and canonical form.
use std::io::{self, Write};
use bitvec::prelude::*;
use serde::Serialize;
use xxhash_rust::xxh3::xxh3_64;
use crate::Sequence;
use crate::encoding::{DEC4, encode_base};
use crate::kmer::{CanonicalKmer, Kmer, KmerError};
use crate::revcomp_lookup::REVCOMP4;
use bitvec::prelude::*;
use xxhash_rust::xxh3::xxh3_64;
// ── SuperKmerHeader ───────────────────────────────────────────────────────────
@@ -53,7 +54,7 @@ impl SuperKmerHeader {
}
#[derive(Serialize)]
struct CountAnnotation {
struct SKAnnotation {
seq_length: usize,
kmer_size: usize,
minimizer_size: usize,
@@ -90,6 +91,22 @@ impl std::hash::Hash for SuperKmer {
}
}
impl Sequence for SuperKmer {
fn sequence(&self) -> Box<[u8]> {
self.seq.clone()
}
fn canonical(&self) -> &Self {
&self
}
/// Returns the XXH3-64 hash of the packed sequence bytes.
fn seq_hash(&self) -> u64 {
xxh3_64(&self.seq)
}
fn annotation(&self) -> Annotation {}
}
impl SuperKmer {
/// `seql` is the raw stored byte: 1255 for lengths 1255, 0 for length 256.
pub fn new(seql: u8, seq: Box<[u8]>) -> Self {
@@ -315,11 +332,6 @@ impl SuperKmer {
pub fn iter_canonical_kmers(&self, k: usize) -> impl Iterator<Item = CanonicalKmer> + '_ {
self.iter_kmers(k).map(move |km| km.canonical(k))
}
/// Returns the XXH3-64 hash of the packed sequence bytes.
pub fn seq_hash(&self) -> u64 {
xxh3_64(&self.seq)
}
}
struct SKKmerIter<'a> {