summaryrefslogtreecommitdiff
path: root/internal/askcli
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-27 06:19:31 +0200
committerPaul Buetow <paul@buetow.org>2026-03-27 06:19:31 +0200
commit6b964400deb653d2c47aa8932ab5444346833b0d (patch)
treefdb9166624b91fa11cfa1e9b4a2ca3ad63bf9739 /internal/askcli
parentb67069c110c210b05507fca839d45b43431f5e86 (diff)
askcli: show task aliases in output (cd322ed1-882d-40e9-ab98-689acd5f161e)
Diffstat (limited to 'internal/askcli')
-rw-r--r--internal/askcli/command_delete.go2
-rw-r--r--internal/askcli/command_delete_test.go21
-rw-r--r--internal/askcli/command_dep.go13
-rw-r--r--internal/askcli/command_dep_test.go45
-rw-r--r--internal/askcli/command_info_add.go8
-rw-r--r--internal/askcli/command_info_add_test.go42
-rw-r--r--internal/askcli/command_list.go7
-rw-r--r--internal/askcli/command_list_test.go91
-rw-r--r--internal/askcli/command_urgency.go7
-rw-r--r--internal/askcli/command_urgency_test.go28
-rw-r--r--internal/askcli/command_write.go16
-rw-r--r--internal/askcli/command_write_test.go84
-rw-r--r--internal/askcli/dispatch.go26
-rw-r--r--internal/askcli/formatter.go66
-rw-r--r--internal/askcli/formatter_test.go54
-rw-r--r--internal/askcli/task_alias_cache.go11
16 files changed, 426 insertions, 95 deletions
diff --git a/internal/askcli/command_delete.go b/internal/askcli/command_delete.go
index 64bcdfc..24753d5 100644
--- a/internal/askcli/command_delete.go
+++ b/internal/askcli/command_delete.go
@@ -21,6 +21,6 @@ func (d Dispatcher) handleDelete(ctx context.Context, args []string, stdin io.Re
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
diff --git a/internal/askcli/command_delete_test.go b/internal/askcli/command_delete_test.go
index ff3f435..7d049c6 100644
--- a/internal/askcli/command_delete_test.go
+++ b/internal/askcli/command_delete_test.go
@@ -11,6 +11,23 @@ import (
)
func TestHandleDelete_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "test-uuid-123", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) == 2 && args[0] == "uuid:test-uuid-123" && args[1] == "export" {
io.WriteString(stdout, `[{"uuid":"test-uuid-123","description":"Task","status":"pending","priority":"M","tags":[],"urgency":0,"depends":[]}]`)
@@ -26,8 +43,8 @@ func TestHandleDelete_Success(t *testing.T) {
if err != nil {
t.Fatalf("delete returned error: %v", err)
}
- if !strings.Contains(stdout.String(), "ok") || !strings.Contains(stdout.String(), "test-uuid-123") {
- t.Fatalf("stdout = %q, want ok + uuid", stdout.String())
+ if !strings.Contains(stdout.String(), "ok 0") || strings.Contains(stdout.String(), "test-uuid-123") {
+ t.Fatalf("stdout = %q, want ok + alias only", stdout.String())
}
if stderr.Len() > 0 {
t.Fatalf("stderr should be empty, got %q", stderr.String())
diff --git a/internal/askcli/command_dep.go b/internal/askcli/command_dep.go
index 403afee..0508b39 100644
--- a/internal/askcli/command_dep.go
+++ b/internal/askcli/command_dep.go
@@ -53,7 +53,7 @@ func (d Dispatcher) handleDepAddRm(ctx context.Context, args []string, stdout, s
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -75,7 +75,16 @@ func (d Dispatcher) handleDepList(ctx context.Context, args []string, stdout, st
if len(task.Depends) == 0 {
io.WriteString(stdout, "no dependencies\n")
} else {
- io.WriteString(stdout, strings.Join(task.Depends, "\n")+"\n")
+ aliases, err := ensureTaskAliasesForUUIDs(task.Depends)
+ if err != nil {
+ fmt.Fprintf(stderr, "error: failed to load task aliases: %v\n", err)
+ return 1, nil
+ }
+ ids := make([]string, 0, len(task.Depends))
+ for _, uuid := range task.Depends {
+ ids = append(ids, displayTaskAlias(uuid, aliases))
+ }
+ io.WriteString(stdout, strings.Join(ids, "\n")+"\n")
}
return 0, nil
}
diff --git a/internal/askcli/command_dep_test.go b/internal/askcli/command_dep_test.go
index 8045df3..408ef86 100644
--- a/internal/askcli/command_dep_test.go
+++ b/internal/askcli/command_dep_test.go
@@ -11,6 +11,24 @@ import (
)
func TestHandleDep_AddSuccess(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 2,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-1", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ {UUID: "uuid-2", Alias: "1", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
var capturedArgs []string
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) == 2 && args[1] == "export" {
@@ -30,8 +48,8 @@ func TestHandleDep_AddSuccess(t *testing.T) {
if code != 0 {
t.Fatalf("dep add code = %d, want 0", code)
}
- if !strings.Contains(stdout.String(), "ok") || !strings.Contains(stdout.String(), "uuid-1") {
- t.Fatalf("stdout = %q, want ok + uuid", stdout.String())
+ if !strings.Contains(stdout.String(), "ok 0") || strings.Contains(stdout.String(), "uuid-1") {
+ t.Fatalf("stdout = %q, want ok + alias only", stdout.String())
}
// Verify uuid:<uuid> is the filter (not a modification argument).
if len(capturedArgs) < 3 || capturedArgs[0] != "uuid:uuid-1" || capturedArgs[1] != "modify" {
@@ -60,6 +78,25 @@ func TestHandleDep_RmSuccess(t *testing.T) {
}
func TestHandleDep_ListSuccess(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 3,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "dep-1", Alias: "1", CreatedAt: nowTaskAliasCache()},
+ {UUID: "dep-2", Alias: "2", CreatedAt: nowTaskAliasCache()},
+ {UUID: "uuid-1", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"uuid-1","description":"Task","status":"pending","priority":"M","tags":[],"urgency":10,"depends":["dep-1","dep-2"]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
io.WriteString(stdout, jsonData)
@@ -71,8 +108,8 @@ func TestHandleDep_ListSuccess(t *testing.T) {
t.Fatalf("dep list code = %d, want 0", code)
}
output := stdout.String()
- if !strings.Contains(output, "dep-1") || !strings.Contains(output, "dep-2") {
- t.Fatalf("stdout = %q, want deps", output)
+ if !strings.Contains(output, "1") || !strings.Contains(output, "2") || strings.Contains(output, "dep-1") || strings.Contains(output, "dep-2") {
+ t.Fatalf("stdout = %q, want alias deps only", output)
}
}
diff --git a/internal/askcli/command_info_add.go b/internal/askcli/command_info_add.go
index 030cf62..5332e71 100644
--- a/internal/askcli/command_info_add.go
+++ b/internal/askcli/command_info_add.go
@@ -24,7 +24,13 @@ func (d Dispatcher) handleInfo(ctx context.Context, args []string, stdout, stder
stdout.Write(data)
io.WriteString(stdout, "\n")
} else {
- io.WriteString(stdout, FormatTaskInfo(tasks[0]))
+ allUUIDs := append([]string{tasks[0].UUID}, tasks[0].Depends...)
+ aliases, err := ensureTaskAliasesForUUIDs(allUUIDs)
+ if err != nil {
+ fmt.Fprintf(stderr, "error: failed to load task aliases: %v\n", err)
+ return 1, nil
+ }
+ io.WriteString(stdout, FormatTaskInfo(tasks[0], displayTaskAlias(tasks[0].UUID, aliases), aliases))
}
return 0, nil
}
diff --git a/internal/askcli/command_info_add_test.go b/internal/askcli/command_info_add_test.go
index 46996f7..a7a7bc2 100644
--- a/internal/askcli/command_info_add_test.go
+++ b/internal/askcli/command_info_add_test.go
@@ -11,6 +11,24 @@ import (
)
func TestHandleInfo_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 2,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "dep-1", Alias: "1", CreatedAt: nowTaskAliasCache()},
+ {UUID: "test-uuid", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"test-uuid","description":"Test task","status":"pending","priority":"H","tags":["cli","agent"],"urgency":15.0,"depends":["dep-1"],"annotations":[{"description":"Note 1","entry":"2026-03-22T10:00:00Z"}]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
// args[0] is "uuid:<uuid>" (the filter); emit data for any export call
@@ -25,6 +43,9 @@ func TestHandleInfo_Success(t *testing.T) {
t.Fatalf("info code = %d, want 0", code)
}
output := stdout.String()
+ if !strings.Contains(output, "ID: 0") {
+ t.Fatalf("output missing alias ID: %s", output)
+ }
if !strings.Contains(output, "test-uuid") {
t.Fatalf("output missing UUID: %s", output)
}
@@ -34,6 +55,9 @@ func TestHandleInfo_Success(t *testing.T) {
if !strings.Contains(output, "Started: no") {
t.Fatalf("output missing explicit started state: %s", output)
}
+ if !strings.Contains(output, "Depends: 1 (dep-1)") {
+ t.Fatalf("output missing formatted dependency alias: %s", output)
+ }
}
func TestHandleInfo_AliasSelector(t *testing.T) {
@@ -67,8 +91,8 @@ func TestHandleInfo_AliasSelector(t *testing.T) {
if code != 0 {
t.Fatalf("info code = %d, want 0", code)
}
- if !strings.Contains(stdout.String(), "test-uuid") {
- t.Fatalf("stdout = %q, want resolved UUID", stdout.String())
+ if !strings.Contains(stdout.String(), "ID: 0") || !strings.Contains(stdout.String(), "UUID: test-uuid") {
+ t.Fatalf("stdout = %q, want alias and UUID", stdout.String())
}
}
@@ -84,6 +108,16 @@ func TestHandleInfo_NumericID(t *testing.T) {
}
func TestHandleInfo_MissingUUID(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
jsonData := `[{"uuid":"started-uuid","description":"Started task","status":"pending","priority":"M","start":"2026-03-26T10:00:00Z","urgency":5.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) == 2 && args[0] == "started" && args[1] == "export" {
@@ -96,8 +130,8 @@ func TestHandleInfo_MissingUUID(t *testing.T) {
if code != 0 {
t.Fatalf("info code = %d, want 0 for implicit started task", code)
}
- if !strings.Contains(stdout.String(), "started-uuid") {
- t.Fatalf("output missing started task UUID: %s", stdout.String())
+ if !strings.Contains(stdout.String(), "ID: 0") || !strings.Contains(stdout.String(), "UUID: started-uuid") {
+ t.Fatalf("output missing alias and started task UUID: %s", stdout.String())
}
}
diff --git a/internal/askcli/command_list.go b/internal/askcli/command_list.go
index ef8c22f..c95707e 100644
--- a/internal/askcli/command_list.go
+++ b/internal/askcli/command_list.go
@@ -61,7 +61,12 @@ func (d Dispatcher) handleListWithFilters(ctx context.Context, initialFilters, e
stdout.Write(data)
io.WriteString(stdout, "\n")
} else {
- io.WriteString(stdout, FormatTaskList(tasks))
+ aliases, err := ensureTaskAliases(tasks)
+ if err != nil {
+ fmt.Fprintf(stderr, "error: failed to load task aliases: %v\n", err)
+ return 1, nil
+ }
+ io.WriteString(stdout, FormatTaskList(tasks, aliases))
}
return 0, nil
}
diff --git a/internal/askcli/command_list_test.go b/internal/askcli/command_list_test.go
index dade889..83dc1b8 100644
--- a/internal/askcli/command_list_test.go
+++ b/internal/askcli/command_list_test.go
@@ -4,11 +4,31 @@ import (
"bytes"
"context"
"io"
+ "path/filepath"
"strings"
"testing"
+ "time"
)
func TestHandleList_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 2,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-1", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ {UUID: "uuid-2", Alias: "1", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"uuid-1","description":"Task 1","status":"pending","priority":"H","tags":["cli"],"start":"2026-03-26T10:00:00Z","urgency":15.0,"depends":[]},{"uuid":"uuid-2","description":"Task 2","status":"completed","priority":"M","tags":["agent"],"urgency":10.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
for _, arg := range args {
@@ -25,8 +45,11 @@ func TestHandleList_Success(t *testing.T) {
t.Fatalf("list code = %d, want 0", code)
}
output := stdout.String()
- if !strings.Contains(output, "uuid-1") || !strings.Contains(output, "uuid-2") {
- t.Fatalf("output missing UUIDs: %s", output)
+ if !strings.Contains(output, "ID") || strings.Contains(output, "UUID") {
+ t.Fatalf("output should use ID column: %s", output)
+ }
+ if !strings.Contains(output, "0") || !strings.Contains(output, "1") || strings.Contains(output, "uuid-1") || strings.Contains(output, "uuid-2") {
+ t.Fatalf("output missing aliases or leaking UUIDs: %s", output)
}
if !strings.Contains(output, "Started") || !strings.Contains(output, "yes") || !strings.Contains(output, "no") {
t.Fatalf("output missing explicit started state: %s", output)
@@ -34,6 +57,24 @@ func TestHandleList_Success(t *testing.T) {
}
func TestHandleList_SortedByPriority(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 2,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-1", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ {UUID: "uuid-2", Alias: "1", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"uuid-2","description":"Task 2","status":"pending","priority":"M","tags":[],"urgency":10.0,"depends":[]},{"uuid":"uuid-1","description":"Task 1","status":"pending","priority":"H","tags":[],"urgency":5.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
for _, arg := range args {
@@ -49,8 +90,8 @@ func TestHandleList_SortedByPriority(t *testing.T) {
output := stdout.String()
lines := strings.Split(strings.TrimSpace(output), "\n")
taskLine1 := lines[2]
- if !strings.Contains(taskLine1, "uuid-1") {
- t.Fatalf("first task should be H priority (uuid-1), got: %s", taskLine1)
+ if !strings.Contains(taskLine1, "0") || strings.Contains(taskLine1, "uuid-1") {
+ t.Fatalf("first task should be H priority alias 0, got: %s", taskLine1)
}
}
@@ -72,6 +113,23 @@ func TestHandleList_EmptyList(t *testing.T) {
}
func TestHandleAll_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-1", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"uuid-1","description":"Done task","status":"completed","priority":"M","tags":[],"urgency":0.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
for _, arg := range args {
@@ -87,12 +145,29 @@ func TestHandleAll_Success(t *testing.T) {
if code != 0 {
t.Fatalf("all code = %d, want 0", code)
}
- if !strings.Contains(stdout.String(), "uuid-1") {
- t.Fatalf("output missing uuid-1: %s", stdout.String())
+ if !strings.Contains(stdout.String(), "0") || strings.Contains(stdout.String(), "uuid-1") {
+ t.Fatalf("output should show alias only: %s", stdout.String())
}
}
func TestHandleReady_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-ready", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"uuid-ready","description":"Ready task","status":"pending","priority":"H","tags":["READY"],"urgency":20.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
for _, arg := range args {
@@ -108,8 +183,8 @@ func TestHandleReady_Success(t *testing.T) {
if code != 0 {
t.Fatalf("ready code = %d, want 0", code)
}
- if !strings.Contains(stdout.String(), "uuid-ready") {
- t.Fatalf("output missing uuid-ready: %s", stdout.String())
+ if !strings.Contains(stdout.String(), "0") || strings.Contains(stdout.String(), "uuid-ready") {
+ t.Fatalf("output should show alias only: %s", stdout.String())
}
}
diff --git a/internal/askcli/command_urgency.go b/internal/askcli/command_urgency.go
index a228f27..0a6bf65 100644
--- a/internal/askcli/command_urgency.go
+++ b/internal/askcli/command_urgency.go
@@ -32,7 +32,12 @@ func (d Dispatcher) handleUrgency(ctx context.Context, stdout, stderr io.Writer)
stdout.Write(data)
io.WriteString(stdout, "\n")
} else {
- io.WriteString(stdout, FormatTaskList(tasks))
+ aliases, err := ensureTaskAliases(tasks)
+ if err != nil {
+ fmt.Fprintf(stderr, "error: failed to load task aliases: %v\n", err)
+ return 1, nil
+ }
+ io.WriteString(stdout, FormatTaskList(tasks, aliases))
}
return 0, nil
}
diff --git a/internal/askcli/command_urgency_test.go b/internal/askcli/command_urgency_test.go
index 45ec5f5..dd6262d 100644
--- a/internal/askcli/command_urgency_test.go
+++ b/internal/askcli/command_urgency_test.go
@@ -4,11 +4,31 @@ import (
"bytes"
"context"
"io"
+ "path/filepath"
"strings"
"testing"
+ "time"
)
func TestHandleUrgency_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 2,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-1", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ {UUID: "uuid-2", Alias: "1", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"uuid-2","description":"Task 2","status":"pending","priority":"M","tags":["agent"],"urgency":10.0,"depends":[]},{"uuid":"uuid-1","description":"Task 1","status":"pending","priority":"H","tags":["cli"],"urgency":15.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
io.WriteString(stdout, jsonData)
@@ -26,11 +46,11 @@ func TestHandleUrgency_Success(t *testing.T) {
}
taskLine1 := lines[2]
taskLine2 := lines[3]
- if !strings.Contains(taskLine1, "uuid-1") {
- t.Fatalf("first task line should contain uuid-1 (urgency 15.0), got: %s", taskLine1)
+ if !strings.Contains(taskLine1, "0") || strings.Contains(taskLine1, "uuid-1") {
+ t.Fatalf("first task line should contain alias 0 (urgency 15.0), got: %s", taskLine1)
}
- if !strings.Contains(taskLine2, "uuid-2") {
- t.Fatalf("second task line should contain uuid-2 (urgency 10.0), got: %s", taskLine2)
+ if !strings.Contains(taskLine2, "1") || strings.Contains(taskLine2, "uuid-2") {
+ t.Fatalf("second task line should contain alias 1 (urgency 10.0), got: %s", taskLine2)
}
}
diff --git a/internal/askcli/command_write.go b/internal/askcli/command_write.go
index afa1475..643f74e 100644
--- a/internal/askcli/command_write.go
+++ b/internal/askcli/command_write.go
@@ -23,7 +23,7 @@ func (d Dispatcher) handleDenotate(ctx context.Context, args []string, stdout, s
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -43,7 +43,7 @@ func (d Dispatcher) handleModify(ctx context.Context, args []string, stdout, std
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -63,7 +63,7 @@ func (d Dispatcher) handleAnnotate(ctx context.Context, args []string, stdout, s
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -84,7 +84,7 @@ func (d Dispatcher) handleStart(ctx context.Context, args []string, stdout, stde
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -103,7 +103,7 @@ func (d Dispatcher) handleStop(ctx context.Context, args []string, stdout, stder
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -122,7 +122,7 @@ func (d Dispatcher) handleDone(ctx context.Context, args []string, stdout, stder
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -142,7 +142,7 @@ func (d Dispatcher) handlePriority(ctx context.Context, args []string, stdout, s
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
@@ -162,6 +162,6 @@ func (d Dispatcher) handleTag(ctx context.Context, args []string, stdout, stderr
if code != 0 {
return code, err
}
- io.WriteString(stdout, FormatSuccess(resolved.UUID))
+ io.WriteString(stdout, FormatSuccess(displayResolvedTaskID(resolved)))
return 0, nil
}
diff --git a/internal/askcli/command_write_test.go b/internal/askcli/command_write_test.go
index 2ed5fc9..31ea25a 100644
--- a/internal/askcli/command_write_test.go
+++ b/internal/askcli/command_write_test.go
@@ -49,6 +49,23 @@ func TestHandleStart_AliasSelector(t *testing.T) {
}
func TestHandleDenotate_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "test-uuid", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) == 2 && args[0] == "uuid:test-uuid" && args[1] == "export" {
io.WriteString(stdout, `[{"uuid":"test-uuid","description":"Task","status":"pending","priority":"M","tags":[],"urgency":0,"depends":[]}]`)
@@ -64,8 +81,8 @@ func TestHandleDenotate_Success(t *testing.T) {
if err != nil {
t.Fatalf("denotate returned error: %v", err)
}
- if !strings.Contains(stdout.String(), "ok") || !strings.Contains(stdout.String(), "test-uuid") {
- t.Fatalf("stdout = %q, want ok + uuid", stdout.String())
+ if !strings.Contains(stdout.String(), "ok 0") || strings.Contains(stdout.String(), "test-uuid") {
+ t.Fatalf("stdout = %q, want ok + alias only", stdout.String())
}
}
@@ -94,6 +111,23 @@ func TestHandleDenotate_MissingArgs(t *testing.T) {
}
func TestHandleModify_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "test-uuid", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) == 2 && args[0] == "uuid:test-uuid" && args[1] == "export" {
io.WriteString(stdout, `[{"uuid":"test-uuid","description":"Task","status":"pending","priority":"M","tags":[],"urgency":0,"depends":[]}]`)
@@ -106,8 +140,8 @@ func TestHandleModify_Success(t *testing.T) {
if code != 0 {
t.Fatalf("modify code = %d, want 0", code)
}
- if !strings.Contains(stdout.String(), "ok") || !strings.Contains(stdout.String(), "test-uuid") {
- t.Fatalf("stdout = %q, want ok + uuid", stdout.String())
+ if !strings.Contains(stdout.String(), "ok 0") || strings.Contains(stdout.String(), "test-uuid") {
+ t.Fatalf("stdout = %q, want ok + alias only", stdout.String())
}
}
@@ -124,6 +158,23 @@ func TestHandleModify_NumericID(t *testing.T) {
}
func TestHandleAnnotate_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "test-uuid", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) == 2 && args[0] == "uuid:test-uuid" && args[1] == "export" {
io.WriteString(stdout, `[{"uuid":"test-uuid","description":"Task","status":"pending","priority":"M","tags":[],"urgency":0,"depends":[]}]`)
@@ -136,8 +187,8 @@ func TestHandleAnnotate_Success(t *testing.T) {
if code != 0 {
t.Fatalf("annotate code = %d, want 0", code)
}
- if !strings.Contains(stdout.String(), "ok") || !strings.Contains(stdout.String(), "test-uuid") {
- t.Fatalf("stdout = %q, want ok + uuid", stdout.String())
+ if !strings.Contains(stdout.String(), "ok 0") || strings.Contains(stdout.String(), "test-uuid") {
+ t.Fatalf("stdout = %q, want ok + alias only", stdout.String())
}
}
@@ -154,6 +205,23 @@ func TestHandleAnnotate_MissingArgs(t *testing.T) {
}
func TestHandleStart_Success(t *testing.T) {
+ dir := t.TempDir()
+ oldRoot := taskAliasCacheRoot
+ oldNow := nowTaskAliasCache
+ taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil }
+ nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "test-uuid", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) == 2 && args[0] == "uuid:test-uuid" && args[1] == "export" {
io.WriteString(stdout, `[{"uuid":"test-uuid","description":"Task","status":"pending","priority":"M","tags":[],"urgency":0,"depends":[]}]`)
@@ -166,8 +234,8 @@ func TestHandleStart_Success(t *testing.T) {
if code != 0 {
t.Fatalf("start code = %d, want 0", code)
}
- if !strings.Contains(stdout.String(), "ok") {
- t.Fatalf("stdout = %q, want ok", stdout.String())
+ if !strings.Contains(stdout.String(), "ok 0") || strings.Contains(stdout.String(), "test-uuid") {
+ t.Fatalf("stdout = %q, want ok + alias only", stdout.String())
}
}
diff --git a/internal/askcli/dispatch.go b/internal/askcli/dispatch.go
index b361111..7cb217b 100644
--- a/internal/askcli/dispatch.go
+++ b/internal/askcli/dispatch.go
@@ -92,20 +92,20 @@ func (d Dispatcher) help(w io.Writer) (int, error) {
io.WriteString(w, " ask list [filters] List active tasks (default)\n")
io.WriteString(w, " ask ready List READY tasks (not blocked)\n")
io.WriteString(w, " ask all [filters] List all tasks including completed/deleted\n")
- io.WriteString(w, " ask info [uuid] Show task details or current started task\n")
- io.WriteString(w, " ask annotate <uuid> \"note\" Add annotation to task\n")
- io.WriteString(w, " ask start <uuid> Start working on task\n")
- io.WriteString(w, " ask stop <uuid> Stop working on task\n")
- io.WriteString(w, " ask done <uuid> Mark task complete\n")
- io.WriteString(w, " ask priority <uuid> <P> Set priority (H/M/L)\n")
- io.WriteString(w, " ask tag <uuid> +/-<tag> Add or remove tag\n")
- io.WriteString(w, " ask dep add <uuid> <dep-uuid> Add dependency\n")
- io.WriteString(w, " ask dep rm <uuid> <dep-uuid> Remove dependency\n")
- io.WriteString(w, " ask dep list <uuid> List dependencies\n")
+ io.WriteString(w, " ask info [id|uuid] Show task details or current started task\n")
+ io.WriteString(w, " ask annotate <id|uuid> \"note\" Add annotation to task\n")
+ io.WriteString(w, " ask start <id|uuid> Start working on task\n")
+ io.WriteString(w, " ask stop <id|uuid> Stop work on a task\n")
+ io.WriteString(w, " ask done <id|uuid> Mark task complete\n")
+ io.WriteString(w, " ask priority <id|uuid> <P> Set priority (H/M/L)\n")
+ io.WriteString(w, " ask tag <id|uuid> +/-<tag> Add or remove tag\n")
+ io.WriteString(w, " ask dep add <id|uuid> <dep> Add dependency\n")
+ io.WriteString(w, " ask dep rm <id|uuid> <dep> Remove dependency\n")
+ io.WriteString(w, " ask dep list <id|uuid> List dependencies\n")
io.WriteString(w, " ask urgency List tasks sorted by urgency\n")
- io.WriteString(w, " ask modify <uuid> <args...> Modify task fields\n")
- io.WriteString(w, " ask denotate <uuid> \"text\" Remove annotation\n")
- io.WriteString(w, " ask delete <uuid> Delete task\n")
+ io.WriteString(w, " ask modify <id|uuid> <args...> Modify task fields\n")
+ io.WriteString(w, " ask denotate <id|uuid> \"text\" Remove annotation\n")
+ io.WriteString(w, " ask delete <id|uuid> Delete a task\n")
io.WriteString(w, " ask fish Emit Fish shell completion script\n")
return 0, nil
}
diff --git a/internal/askcli/formatter.go b/internal/askcli/formatter.go
index f4c0104..7ca9225 100644
--- a/internal/askcli/formatter.go
+++ b/internal/askcli/formatter.go
@@ -3,16 +3,17 @@ package askcli
import (
"fmt"
"io"
+ "slices"
"strings"
)
-func FormatTaskList(tasks []TaskExport) string {
- widths := taskListWidthsFor(tasks)
+func FormatTaskList(tasks []TaskExport, aliases map[string]string) string {
+ widths := taskListWidthsFor(tasks, aliases)
var b strings.Builder
writeTaskListHeader(&b, widths)
writeTaskListSeparator(&b, widths)
for _, t := range tasks {
- writeTaskListRow(&b, widths, t)
+ writeTaskListRow(&b, widths, t, aliases)
}
return b.String()
}
@@ -20,18 +21,18 @@ func FormatTaskList(tasks []TaskExport) string {
type taskListWidths struct {
Urgency int
Priority int
- UUID int
+ ID int
Status int
Started int
Tags int
Description int
}
-func taskListWidthsFor(tasks []TaskExport) taskListWidths {
+func taskListWidthsFor(tasks []TaskExport, aliases map[string]string) taskListWidths {
widths := taskListWidths{
Urgency: len("Urgency"),
Priority: len("Priority"),
- UUID: len("UUID"),
+ ID: len("ID"),
Status: len("Status"),
Started: len("Started"),
Tags: len("Tags"),
@@ -40,7 +41,7 @@ func taskListWidthsFor(tasks []TaskExport) taskListWidths {
for _, t := range tasks {
widths.Urgency = maxInt(widths.Urgency, len(fmt.Sprintf("%.1f", t.Urgency)))
widths.Priority = maxInt(widths.Priority, len(t.Priority))
- widths.UUID = maxInt(widths.UUID, len(t.UUID))
+ widths.ID = maxInt(widths.ID, len(displayTaskAlias(t.UUID, aliases)))
widths.Status = maxInt(widths.Status, len(t.Status))
widths.Started = maxInt(widths.Started, len(formatTaskStarted(t)))
widths.Tags = maxInt(widths.Tags, len(formatTaskTags(t.Tags)))
@@ -53,7 +54,7 @@ func writeTaskListHeader(b *strings.Builder, widths taskListWidths) {
fmt.Fprintf(b, "%-*s | %-*s | %-*s | %-*s | %-*s | %-*s | %-*s\n",
widths.Urgency, "Urgency",
widths.Priority, "Priority",
- widths.UUID, "UUID",
+ widths.ID, "ID",
widths.Status, "Status",
widths.Started, "Started",
widths.Tags, "Tags",
@@ -62,15 +63,15 @@ func writeTaskListHeader(b *strings.Builder, widths taskListWidths) {
}
func writeTaskListSeparator(b *strings.Builder, widths taskListWidths) {
- total := widths.Urgency + widths.Priority + widths.UUID + widths.Status + widths.Started + widths.Tags + widths.Description + 18
+ total := widths.Urgency + widths.Priority + widths.ID + widths.Status + widths.Started + widths.Tags + widths.Description + 18
io.WriteString(b, strings.Repeat("-", total)+"\n")
}
-func writeTaskListRow(b *strings.Builder, widths taskListWidths, t TaskExport) {
+func writeTaskListRow(b *strings.Builder, widths taskListWidths, t TaskExport, aliases map[string]string) {
fmt.Fprintf(b, "%-*s | %-*s | %-*s | %-*s | %-*s | %-*s | %-*s\n",
widths.Urgency, fmt.Sprintf("%.1f", t.Urgency),
widths.Priority, t.Priority,
- widths.UUID, t.UUID,
+ widths.ID, displayTaskAlias(t.UUID, aliases),
widths.Status, t.Status,
widths.Started, formatTaskStarted(t),
widths.Tags, formatTaskTags(t.Tags),
@@ -106,8 +107,9 @@ func maxInt(a, b int) int {
return b
}
-func FormatTaskInfo(t TaskExport) string {
+func FormatTaskInfo(t TaskExport, alias string, dependencyAliases map[string]string) string {
var b strings.Builder
+ fmt.Fprintf(&b, "ID: %s\n", alias)
fmt.Fprintf(&b, "UUID: %s\n", t.UUID)
fmt.Fprintf(&b, "Description: %s\n", t.Description)
fmt.Fprintf(&b, "Status: %s\n", t.Status)
@@ -121,7 +123,7 @@ func FormatTaskInfo(t TaskExport) string {
fmt.Fprintf(&b, "Start time: %s\n", t.Start)
}
if len(t.Depends) > 0 {
- fmt.Fprintf(&b, "Depends: %s\n", strings.Join(t.Depends, ", "))
+ fmt.Fprintf(&b, "Depends: %s\n", formatTaskDependencies(t.Depends, dependencyAliases))
}
if len(t.Annotations) > 0 {
io.WriteString(&b, "Annotations:\n")
@@ -132,17 +134,45 @@ func FormatTaskInfo(t TaskExport) string {
return b.String()
}
-func FormatSuccess(uuid string) string {
- return fmt.Sprintf("ok %s\n", uuid)
+func FormatSuccess(alias string) string {
+ return fmt.Sprintf("ok %s\n", alias)
}
-func FormatError(err error, uuid string) string {
- if uuid != "" {
- return fmt.Sprintf("error %s: %v\n", uuid, err)
+func FormatError(err error, taskID string) string {
+ if taskID != "" {
+ return fmt.Sprintf("error %s: %v\n", taskID, err)
}
return fmt.Sprintf("error: %v\n", err)
}
+func displayResolvedTaskID(resolved resolvedTaskSelector) string {
+ return displayTaskAlias(resolved.UUID, map[string]string{resolved.UUID: resolved.Alias})
+}
+
+func displayTaskAlias(uuid string, aliases map[string]string) string {
+ if alias := strings.TrimSpace(aliases[uuid]); alias != "" {
+ return alias
+ }
+ return uuid
+}
+
+func formatTaskDependencies(depends []string, aliases map[string]string) string {
+ items := make([]string, 0, len(depends))
+ for _, uuid := range depends {
+ items = append(items, formatTaskReference(uuid, aliases))
+ }
+ slices.Sort(items)
+ return strings.Join(items, ", ")
+}
+
+func formatTaskReference(uuid string, aliases map[string]string) string {
+ alias := strings.TrimSpace(aliases[uuid])
+ if alias == "" || alias == uuid {
+ return uuid
+ }
+ return fmt.Sprintf("%s (%s)", alias, uuid)
+}
+
// NormalizeUUID strips any leading "uuid:" prefix so callers can accept
// both "uuid:<value>" and bare UUID strings interchangeably. The returned
// value is always a plain UUID ready to be prefixed again when building
diff --git a/internal/askcli/formatter_test.go b/internal/askcli/formatter_test.go
index 52632f5..c99effd 100644
--- a/internal/askcli/formatter_test.go
+++ b/internal/askcli/formatter_test.go
@@ -12,22 +12,23 @@ func TestFormatTaskList(t *testing.T) {
{UUID: "uuid-2", Description: strings.Repeat("a", 100), Status: "completed", Priority: "M", Tags: []string{"agent", "test"}, Urgency: 5.0},
{UUID: "uuid-3", Description: "No tags task", Status: "waiting", Priority: "L", Tags: []string{}, Urgency: 8.0},
}
- output := FormatTaskList(tasks)
+ aliases := map[string]string{"uuid-1": "0", "uuid-2": "1", "uuid-3": "2"}
+ output := FormatTaskList(tasks, aliases)
lines := strings.Split(strings.TrimSpace(output), "\n")
if len(lines) < 3 {
t.Fatalf("FormatTaskList produced too few lines: %d", len(lines))
}
- if !strings.Contains(lines[0], "UUID") || !strings.Contains(lines[0], "Priority") {
- t.Fatalf("header missing UUID or Priority column: %s", lines[0])
+ if !strings.Contains(lines[0], "ID") || !strings.Contains(lines[0], "Priority") {
+ t.Fatalf("header missing ID or Priority column: %s", lines[0])
}
if !strings.Contains(lines[0], "Started") {
t.Fatalf("header missing Started column: %s", lines[0])
}
- if !strings.Contains(lines[2], "uuid-1") {
- t.Fatalf("first task line missing uuid-1: %s", lines[2])
+ if !strings.Contains(lines[2], "0") || strings.Contains(lines[2], "uuid-1") {
+ t.Fatalf("first task line should show alias only: %s", lines[2])
}
- if strings.Contains(lines[2], "...") {
- t.Fatalf("long description should be truncated with ...: %s", lines[2])
+ if !strings.Contains(lines[3], "...") {
+ t.Fatalf("long description should be truncated with ...: %s", lines[3])
}
}
@@ -51,17 +52,18 @@ func TestFormatTaskList_AlignsHeaderAndSeparator(t *testing.T) {
},
}
- output := FormatTaskList(tasks)
+ aliases := map[string]string{"uuid-short": "0", "uuid-with-a-longer-value": "00"}
+ output := FormatTaskList(tasks, aliases)
lines := strings.Split(strings.TrimSuffix(output, "\n"), "\n")
if len(lines) != 4 {
t.Fatalf("FormatTaskList produced %d lines, want 4: %q", len(lines), output)
}
- widths := taskListWidthsFor(tasks)
+ widths := taskListWidthsFor(tasks, aliases)
wantHeader := fmt.Sprintf("%-*s | %-*s | %-*s | %-*s | %-*s | %-*s | %-*s",
widths.Urgency, "Urgency",
widths.Priority, "Priority",
- widths.UUID, "UUID",
+ widths.ID, "ID",
widths.Status, "Status",
widths.Started, "Started",
widths.Tags, "Tags",
@@ -75,6 +77,15 @@ func TestFormatTaskList_AlignsHeaderAndSeparator(t *testing.T) {
}
}
+func TestFormatTaskList_FallsBackToUUIDWithoutAlias(t *testing.T) {
+ tasks := []TaskExport{{UUID: "uuid-1", Description: "Task", Status: "pending", Priority: "H", Urgency: 1.0}}
+
+ output := FormatTaskList(tasks, nil)
+ if !strings.Contains(output, "uuid-1") {
+ t.Fatalf("FormatTaskList should fall back to UUID when alias is unavailable: %s", output)
+ }
+}
+
func TestFormatTaskInfo(t *testing.T) {
task := TaskExport{
UUID: "test-uuid",
@@ -92,7 +103,10 @@ func TestFormatTaskInfo(t *testing.T) {
{Description: "First note", Entry: "2026-03-22T11:00:00Z"},
},
}
- output := FormatTaskInfo(task)
+ output := FormatTaskInfo(task, "0", map[string]string{"dep-1": "1", "dep-2": "2"})
+ if !strings.Contains(output, "ID: 0") {
+ t.Fatalf("FormatTaskInfo missing alias ID: %s", output)
+ }
if !strings.Contains(output, "test-uuid") {
t.Fatalf("FormatTaskInfo missing UUID: %s", output)
}
@@ -108,8 +122,8 @@ func TestFormatTaskInfo(t *testing.T) {
if !strings.Contains(output, "cli, agent") {
t.Fatalf("FormatTaskInfo missing tags: %s", output)
}
- if !strings.Contains(output, "dep-1") {
- t.Fatalf("FormatTaskInfo missing depends: %s", output)
+ if !strings.Contains(output, "1 (dep-1)") || !strings.Contains(output, "2 (dep-2)") {
+ t.Fatalf("FormatTaskInfo missing formatted depends: %s", output)
}
if !strings.Contains(output, "First note") {
t.Fatalf("FormatTaskInfo missing annotation: %s", output)
@@ -117,17 +131,17 @@ func TestFormatTaskInfo(t *testing.T) {
}
func TestFormatSuccess(t *testing.T) {
- output := FormatSuccess("test-uuid")
- if !strings.Contains(output, "ok") || !strings.Contains(output, "test-uuid") {
- t.Fatalf("FormatSuccess = %q, want ok + uuid", output)
+ output := FormatSuccess("0")
+ if !strings.Contains(output, "ok") || !strings.Contains(output, "0") {
+ t.Fatalf("FormatSuccess = %q, want ok + alias", output)
}
}
func TestFormatError(t *testing.T) {
err := &testError{msg: "something went wrong"}
- output := FormatError(err, "uuid-123")
- if !strings.Contains(output, "error") || !strings.Contains(output, "uuid-123") || !strings.Contains(output, "something went wrong") {
- t.Fatalf("FormatError = %q, want error + uuid + message", output)
+ output := FormatError(err, "0")
+ if !strings.Contains(output, "error") || !strings.Contains(output, "0") || !strings.Contains(output, "something went wrong") {
+ t.Fatalf("FormatError = %q, want error + alias + message", output)
}
}
@@ -195,7 +209,7 @@ func TestFormatTaskInfo_NoOptionalFields(t *testing.T) {
Tags: []string{},
Urgency: 0,
}
- output := FormatTaskInfo(task)
+ output := FormatTaskInfo(task, "0", nil)
if !strings.Contains(output, "simple-uuid") {
t.Fatalf("FormatTaskInfo missing UUID: %s", output)
}
diff --git a/internal/askcli/task_alias_cache.go b/internal/askcli/task_alias_cache.go
index c6a0ba2..e8243f0 100644
--- a/internal/askcli/task_alias_cache.go
+++ b/internal/askcli/task_alias_cache.go
@@ -57,6 +57,17 @@ func ensureTaskAliases(tasks []TaskExport) (map[string]string, error) {
return aliases, nil
}
+func ensureTaskAliasesForUUIDs(uuids []string) (map[string]string, error) {
+ tasks := make([]TaskExport, 0, len(uuids))
+ for _, uuid := range uuids {
+ if uuid == "" {
+ continue
+ }
+ tasks = append(tasks, TaskExport{UUID: uuid})
+ }
+ return ensureTaskAliases(tasks)
+}
+
func loadTaskAliasCache() (taskAliasCache, string, error) {
path, err := taskAliasCachePath()
if err != nil {