about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-11-14 03:39:03 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-11-14 03:39:03 +0000
commitdb19435f20857ee39fd5ef97d954a2de1cebe391 (patch)
tree252f6837c437983febf19cc41c964198e960fbbe
parent5d00a06d8c7eeacc0a1058217e9c9e5676657605 (diff)
downloadai-memory-db19435f20857ee39fd5ef97d954a2de1cebe391.tar.gz
dates: dd/mm next to every hash in gist listings
list, why, search and log printed either nothing or a full ISO timestamp, and
a stamp that wide pushes the hash and the gist apart.  One helper, fmt_date,
renders UTC dd/mm and adds the year only when it is not the current one; an
unattached entry is dated by when it was written, since it has no commit date.
-rw-r--r--doc/SKILL.md10
-rw-r--r--main.odin44
2 files changed, 38 insertions, 16 deletions
diff --git a/doc/SKILL.md b/doc/SKILL.md
index 28edce1..a39a230 100644
--- a/doc/SKILL.md
+++ b/doc/SKILL.md
@@ -242,10 +242,12 @@ nothing.  Amending *before* recording is cheaper than repairing afterwards.
   `symbols.basename` (`compute_gemma`), then a `LIKE '%…%'` scan for partial names.
 - `log` prints how many reasoning entries each commit carries — commits with `(0)`
   are the ones worth annotating later.
-- `list` is the inventory view: one line per entry, `short-hash  #id  kind  gist`.
-  Unattached entries come first (labelled `uncommitted`), then the newest commit's,
-  and a superseded entry reads `kind->#N`.  `--session`, `--kind` and `--commit`
-  narrow it; skim `list` before opening entries with `why`.
+- `list` is the inventory view: one line per entry, `short-hash  dd/mm  #id  kind  gist`.
+  Unattached entries come first (labelled `uncommitted`, dated by when they were
+  written), then the newest commit's, and a superseded entry reads `kind->#N`.
+  Dates are UTC and carry the year only when it is not the current one, so a
+  listing stays narrow without becoming ambiguous after a year.  `--session`,
+  `--kind` and `--commit` narrow it; skim `list` before opening entries with `why`.
 - `why SYMBOL` and `search TEXT` print the gist per entry; `--full` adds the body
   indented beneath it, and `--all` admits superseded entries.  Gist-first is the
   default because a listing of twenty bodies is not read.
diff --git a/main.odin b/main.odin
index 5f5ab9a..782d47b 100644
--- a/main.odin
+++ b/main.odin
@@ -428,7 +428,7 @@ cmd_why :: proc(args: []string) -> bool {
 	}
 	for row in rows {
 		fmt.printfln("%s  %s  %s  [%s %s, %s]",
-		             short_hash(row.commit_hash), fmt_ts(row.author_ts),
+		             short_hash(row.commit_hash), fmt_date(row.author_ts),
 		             row.subject, row.kind, row.symbol, row.change)
 		print_reasoning(reasoning_for(&db, row.commit_hash), show_all, full)
 	}
@@ -451,7 +451,8 @@ cmd_search :: proc(args: []string) -> bool {
 	defer db_close(&db)
 
 	s, sok := stmt(&db, `select r.id, r.kind, r.basis, r.gist, r.body, r.created_at, c.subject,
-	                         (select min(s.id) from reasoning s where s.supersedes = r.id)
+	                         (select min(s.id) from reasoning s where s.supersedes = r.id),
+	                         r.commit_hash
 	                     from reasoning_fts f
 	                       join reasoning r on r.id = f.rowid
 	                       left join commits c on c.hash = r.commit_hash
@@ -487,7 +488,13 @@ cmd_search :: proc(args: []string) -> bool {
 			hidden += 1
 			continue
 		}
-		label := fmt.tprintf("%s  #%d %s", fmt_ts(stmt_col_i64(&s, 5)), r.id, r.kind)
+		hash := stmt_col_text(&s, 8)
+		origin := "uncommitted"
+		if len(hash) > 0 {
+			origin = short_hash(hash)
+		}
+		label := fmt.tprintf("%s  %s  #%d %s", origin,
+		                     fmt_date(stmt_col_i64(&s, 5)), r.id, r.kind)
 		if len(r.basis) > 0 {
 			label = fmt.tprintf("%s (%s)", label, r.basis)
 		}
@@ -548,7 +555,7 @@ cmd_log :: proc(args: []string) -> bool {
 			return false
 		}
 		fmt.printfln("%s  %s  %s  (%d)",
-		             short_hash(stmt_col_text(&s, 0)), fmt_ts(stmt_col_i64(&s, 1)),
+		             short_hash(stmt_col_text(&s, 0)), fmt_date(stmt_col_i64(&s, 1)),
 		             stmt_col_text(&s, 2), stmt_col_i64(&s, 3))
 	}
 	return true
@@ -865,13 +872,19 @@ short_hash :: proc(hash: string) -> string {
 	return hash[:7]
 }
 
-fmt_ts :: proc(ts: i64) -> string {
+// fmt_date renders a timestamp as dd/mm, in UTC.  The year appears only when it
+// is not the current one: listings are read for order and recency, and a full
+// ISO stamp next to every hash drowns the hash.
+fmt_date :: proc(ts: i64) -> string {
+	if ts == 0 {
+		return "--/--"
+	}
 	t := time.unix(ts, 0)
-	s, ok := time.time_to_rfc3339(t, 0, false, context.temp_allocator)
-	if !ok {
-		return fmt.tprintf("%d", ts)
+	year, month, day := time.date(t)
+	if year != time.year(time.now()) {
+		return fmt.tprintf("%02d/%02d/%02d", day, int(month), year %% 100)
 	}
-	return s
+	return fmt.tprintf("%02d/%02d", day, int(month))
 }
 
 // indent_rest keeps multi-line reasoning readable under its commit line.
@@ -966,7 +979,8 @@ cmd_list :: proc(args: []string) -> bool {
 
 	// Anonymous placeholders, bound in the order they appear.
 	query := `select r.id, r.kind, r.gist, r.body, r.commit_hash, coalesce(c.author_ts, 0),
-	                 (select min(s.id) from reasoning s where s.supersedes = r.id)
+	                 (select min(s.id) from reasoning s where s.supersedes = r.id),
+	                 r.created_at
 	          from reasoning r
 	            left join commits c on c.hash = r.commit_hash`
 
@@ -1038,8 +1052,14 @@ cmd_list :: proc(args: []string) -> bool {
 		if len(text) == 0 {
 			text = one_line(stmt_col_text(&s, 3), 96)
 		}
-		fmt.printfln("%s  #%d  %s  %s",
-		             label, stmt_col_i64(&s, 0), kind_text, text)
+		// An unattached entry has no commit date; its own created_at is the date
+		// that means something for it.
+		ts := stmt_col_i64(&s, 5)
+		if ts == 0 {
+			ts = stmt_col_i64(&s, 7)
+		}
+		fmt.printfln("%s  %s  #%d  %s  %s",
+		             label, fmt_date(ts), stmt_col_i64(&s, 0), kind_text, text)
 	}
 	return true
 }