chore(cli): remove unused <thread-id> from CAS commands

CAS is global (not per-thread). The underlying cmdCas* functions
already dropped threadId in #103, but the CLI dispatch layer still
required it from users. Now cleaned up:

- cas get <hash> (was: cas get <thread-id> <hash>)
- cas put <content> (was: cas put <thread-id> <content>)
- cas list (was: cas list <thread-id>)
- cas rm <hash> (was: cas rm <thread-id> <hash>)
- skill.ts develop topic updated to match
This commit is contained in:
2026-05-08 09:23:39 +08:00
parent 661fdbb263
commit 7c3e14c473
2 changed files with 22 additions and 26 deletions
@@ -30,10 +30,9 @@ export async function dispatchGc(storageRoot: string, argv: string[]): Promise<n
} }
export async function dispatchCasGet(storageRoot: string, rest: string[]): Promise<number> { export async function dispatchCasGet(storageRoot: string, rest: string[]): Promise<number> {
const threadId = rest[0]; const hash = rest[0];
const hash = rest[1]; if (hash === undefined || rest.length > 1) {
if (threadId === undefined || hash === undefined || rest.length > 2) { printCliError(`${usageText()}\n\nerror: cas get requires <hash>`);
printCliError(`${usageText()}\n\nerror: cas get requires <thread-id> <hash>`);
return 1; return 1;
} }
const result = await cmdCasGet(storageRoot, hash); const result = await cmdCasGet(storageRoot, hash);
@@ -46,10 +45,9 @@ export async function dispatchCasGet(storageRoot: string, rest: string[]): Promi
} }
export async function dispatchCasPut(storageRoot: string, rest: string[]): Promise<number> { export async function dispatchCasPut(storageRoot: string, rest: string[]): Promise<number> {
const threadId = rest[0]; const content = rest[0];
const content = rest[1]; if (content === undefined || rest.length > 1) {
if (threadId === undefined || content === undefined || rest.length > 2) { printCliError(`${usageText()}\n\nerror: cas put requires <content>`);
printCliError(`${usageText()}\n\nerror: cas put requires <thread-id> <content>`);
return 1; return 1;
} }
const result = await cmdCasPut(storageRoot, content); const result = await cmdCasPut(storageRoot, content);
@@ -62,9 +60,8 @@ export async function dispatchCasPut(storageRoot: string, rest: string[]): Promi
} }
export async function dispatchCasList(storageRoot: string, rest: string[]): Promise<number> { export async function dispatchCasList(storageRoot: string, rest: string[]): Promise<number> {
const threadId = rest[0]; if (rest.length > 0) {
if (threadId === undefined || rest.length > 1) { printCliError(`${usageText()}\n\nerror: cas list takes no arguments`);
printCliError(`${usageText()}\n\nerror: cas list requires <thread-id>`);
return 1; return 1;
} }
const result = await cmdCasList(storageRoot); const result = await cmdCasList(storageRoot);
@@ -79,10 +76,9 @@ export async function dispatchCasList(storageRoot: string, rest: string[]): Prom
} }
export async function dispatchCasRm(storageRoot: string, rest: string[]): Promise<number> { export async function dispatchCasRm(storageRoot: string, rest: string[]): Promise<number> {
const threadId = rest[0]; const hash = rest[0];
const hash = rest[1]; if (hash === undefined || rest.length > 1) {
if (threadId === undefined || hash === undefined || rest.length > 2) { printCliError(`${usageText()}\n\nerror: cas rm requires <hash>`);
printCliError(`${usageText()}\n\nerror: cas rm requires <thread-id> <hash>`);
return 1; return 1;
} }
const result = await cmdCasRm(storageRoot, hash); const result = await cmdCasRm(storageRoot, hash);
@@ -97,20 +93,20 @@ export async function dispatchCasRm(storageRoot: string, rest: string[]): Promis
export const CAS_SUBCOMMAND_TABLE: Record<string, CommandEntry> = { export const CAS_SUBCOMMAND_TABLE: Record<string, CommandEntry> = {
get: { get: {
handler: dispatchCasGet, handler: dispatchCasGet,
args: "<thread-id> <hash>", args: "<hash>",
description: "Retrieve content by hash from a thread's CAS", description: "Retrieve content by hash from CAS",
}, },
put: { put: {
handler: dispatchCasPut, handler: dispatchCasPut,
args: "<thread-id> <content>", args: "<content>",
description: "Store content in a thread's CAS, returns hash", description: "Store content in CAS, prints hash",
}, },
list: { list: {
handler: dispatchCasList, handler: dispatchCasList,
args: "<thread-id>", args: "",
description: "List all CAS entries for a thread", description: "List all hashes in CAS",
}, },
rm: { handler: dispatchCasRm, args: "<thread-id> <hash>", description: "Remove a CAS entry" }, rm: { handler: dispatchCasRm, args: "<hash>", description: "Remove a CAS entry by hash" },
gc: { handler: dispatchGc, args: "", description: "Garbage-collect unreferenced CAS entries" }, gc: { handler: dispatchGc, args: "", description: "Garbage-collect unreferenced CAS entries" },
}; };
+4 -4
View File
@@ -126,13 +126,13 @@ uncaged-workflow thread list
## CAS (Content-Addressable Storage) ## CAS (Content-Addressable Storage)
Store and retrieve content by hash, scoped to the current thread. Store and retrieve content by hash in workflow storage (global CAS directory).
| Operation | Command | | Operation | Command |
|-----------|---------| |-----------|---------|
| **Store** | \`uncaged-workflow cas put <THREAD_ID> '<content>'\` → prints hash | | **Store** | \`uncaged-workflow cas put '<content>'\` → prints hash |
| **Read** | \`uncaged-workflow cas get <THREAD_ID> <HASH>\` → prints content | | **Read** | \`uncaged-workflow cas get <HASH>\` → prints content |
| **List** | \`uncaged-workflow cas list <THREAD_ID>\` | | **List** | \`uncaged-workflow cas list\` |
CAS is the **only** supported way to persist structured data (phase plans, review notes, etc.) within a thread. Do not use temp files. CAS is the **only** supported way to persist structured data (phase plans, review notes, etc.) within a thread. Do not use temp files.