feat: uwf cas put-text for storing plain text in CAS
- Register built-in text schema ({type: 'string'}) alongside workflow schemas
- Add cmdCasPutText command: uwf cas put-text <text>
- Update CLI reference in workflow-util
- Update solve-issue.yaml procedure to use put-text
Refs #380
This commit is contained in:
@@ -20,7 +20,7 @@ roles:
|
|||||||
2. Revise the test spec accordingly
|
2. Revise the test spec accordingly
|
||||||
|
|
||||||
After producing the test spec:
|
After producing the test spec:
|
||||||
1. Store it via `uwf cas put "<markdown content>"` and capture the returned hash
|
1. Store it via `uwf cas put-text "<markdown content>"` and capture the returned hash
|
||||||
2. Put the hash in meta.plan (required when status=ready)
|
2. Put the hash in meta.plan (required when status=ready)
|
||||||
output: "Output a brief summary of the test spec. Frontmatter must include: status (ready or insufficient_info) and plan (CAS hash of the test spec, required when status=ready)."
|
output: "Output a brief summary of the test spec. Frontmatter must include: status (ready or insufficient_info) and plan (CAS hash of the test spec, required when status=ready)."
|
||||||
frontmatter:
|
frontmatter:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
cmdCasGet,
|
cmdCasGet,
|
||||||
cmdCasHas,
|
cmdCasHas,
|
||||||
cmdCasPut,
|
cmdCasPut,
|
||||||
|
cmdCasPutText,
|
||||||
cmdCasRefs,
|
cmdCasRefs,
|
||||||
cmdCasReindex,
|
cmdCasReindex,
|
||||||
cmdCasSchemaGet,
|
cmdCasSchemaGet,
|
||||||
@@ -295,6 +296,17 @@ cas
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cas
|
||||||
|
.command("put-text")
|
||||||
|
.description("Store a plain text string, print its hash")
|
||||||
|
.argument("<text>", "Text content to store")
|
||||||
|
.action((text: string) => {
|
||||||
|
const storageRoot = resolveStorageRoot();
|
||||||
|
runAction(async () => {
|
||||||
|
writeOutput(await cmdCasPutText(storageRoot, text));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
cas
|
cas
|
||||||
.command("has")
|
.command("has")
|
||||||
.description("Check if a hash exists")
|
.description("Check if a hash exists")
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { readFileSync } from "node:fs";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import type { JSONSchema, Store } from "@uncaged/json-cas";
|
import type { JSONSchema, Store } from "@uncaged/json-cas";
|
||||||
import { bootstrap, getSchema, refs, walk } from "@uncaged/json-cas";
|
import { bootstrap, getSchema, putSchema, refs, walk } from "@uncaged/json-cas";
|
||||||
import { createFsStore } from "@uncaged/json-cas-fs";
|
import { createFsStore } from "@uncaged/json-cas-fs";
|
||||||
|
|
||||||
|
import { TEXT_SCHEMA } from "../schemas.js";
|
||||||
|
|
||||||
// ---- Helpers ----
|
// ---- Helpers ----
|
||||||
|
|
||||||
function openStore(storageRoot: string): Store {
|
function openStore(storageRoot: string): Store {
|
||||||
@@ -121,3 +123,10 @@ export async function cmdCasSchemaGet(storageRoot: string, hash: string): Promis
|
|||||||
}
|
}
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function cmdCasPutText(storageRoot: string, text: string): Promise<{ hash: string }> {
|
||||||
|
const store = openStore(storageRoot);
|
||||||
|
const typeHash = await putSchema(store, TEXT_SCHEMA);
|
||||||
|
const hash = await store.put(typeHash, text);
|
||||||
|
return { hash };
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ import type { Hash, Store } from "@uncaged/json-cas";
|
|||||||
import { putSchema } from "@uncaged/json-cas";
|
import { putSchema } from "@uncaged/json-cas";
|
||||||
import { START_NODE_SCHEMA, STEP_NODE_SCHEMA, WORKFLOW_SCHEMA } from "@uncaged/workflow-protocol";
|
import { START_NODE_SCHEMA, STEP_NODE_SCHEMA, WORKFLOW_SCHEMA } from "@uncaged/workflow-protocol";
|
||||||
|
|
||||||
|
export const TEXT_SCHEMA = { type: "string" as const };
|
||||||
|
|
||||||
export type UwfSchemaHashes = {
|
export type UwfSchemaHashes = {
|
||||||
workflow: Hash;
|
workflow: Hash;
|
||||||
startNode: Hash;
|
startNode: Hash;
|
||||||
stepNode: Hash;
|
stepNode: Hash;
|
||||||
|
text: Hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,10 +16,11 @@ export type UwfSchemaHashes = {
|
|||||||
* Idempotent: safe to call on every CLI invocation.
|
* Idempotent: safe to call on every CLI invocation.
|
||||||
*/
|
*/
|
||||||
export async function registerUwfSchemas(store: Store): Promise<UwfSchemaHashes> {
|
export async function registerUwfSchemas(store: Store): Promise<UwfSchemaHashes> {
|
||||||
const [workflow, startNode, stepNode] = await Promise.all([
|
const [workflow, startNode, stepNode, text] = await Promise.all([
|
||||||
putSchema(store, WORKFLOW_SCHEMA),
|
putSchema(store, WORKFLOW_SCHEMA),
|
||||||
putSchema(store, START_NODE_SCHEMA),
|
putSchema(store, START_NODE_SCHEMA),
|
||||||
putSchema(store, STEP_NODE_SCHEMA),
|
putSchema(store, STEP_NODE_SCHEMA),
|
||||||
|
putSchema(store, TEXT_SCHEMA),
|
||||||
]);
|
]);
|
||||||
return { workflow, startNode, stepNode };
|
return { workflow, startNode, stepNode, text };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ uwf cas get <hash> # read a CAS node (type + payload)
|
|||||||
[--timestamp] # include timestamp in output
|
[--timestamp] # include timestamp in output
|
||||||
uwf cas put <type-hash> <data> # store a node, print its hash
|
uwf cas put <type-hash> <data> # store a node, print its hash
|
||||||
# <data>: JSON file path or inline JSON string
|
# <data>: JSON file path or inline JSON string
|
||||||
|
uwf cas put-text <text> # store a plain text string, print its hash
|
||||||
|
# shortcut for put with the built-in text schema
|
||||||
uwf cas has <hash> # check if a hash exists
|
uwf cas has <hash> # check if a hash exists
|
||||||
uwf cas refs <hash> # list direct CAS references from a node
|
uwf cas refs <hash> # list direct CAS references from a node
|
||||||
uwf cas walk <hash> # recursive traversal from a node
|
uwf cas walk <hash> # recursive traversal from a node
|
||||||
|
|||||||
Reference in New Issue
Block a user