1- import type { CliContract , ColumnSpec } from './types.js'
1+ import type { CliContract , ColumnSpec , CommandVariantSpec } from './types.js'
22
33const TABLE_NAME_HELP = 'Identifier: letters, numbers, and underscores; cannot start with a number'
44const TABLE_FILTER_HELP =
@@ -18,13 +18,29 @@ const FOLDER_DELETE_FLAGS = {
1818 path : FOLDER_PATH_INPUT ,
1919 recursive : { boolean : true , describe : 'Delete the folder and its descendants' } ,
2020} as const
21+ const KNOWLEDGE_DOCUMENT_SCOPE = {
22+ id : {
23+ name : 'kb' ,
24+ placeholder : 'knowledgeBaseId' ,
25+ describe : 'Knowledge base ID' ,
26+ } ,
27+ } as const
2128const FOLDER_LIST_COLUMNS : ColumnSpec [ ] = [
2229 { header : 'path' } ,
2330 { header : 'name' } ,
2431 { header : 'parent' , path : 'parentPath' } ,
2532 { header : 'updated' , path : 'updatedAt' , format : 'timestamp' } ,
2633]
2734
35+ function moveResource ( command : string , resource : string ) : CommandVariantSpec {
36+ return {
37+ command,
38+ positionals : [ 'folderPath' ] ,
39+ requestFields : [ 'folderPath' ] ,
40+ describe : `Move a ${ resource } to a folder` ,
41+ }
42+ }
43+
2844/**
2945 * The CLI contract for the v2 surface.
3046 *
@@ -34,7 +50,7 @@ const FOLDER_LIST_COLUMNS: ColumnSpec[] = [
3450 *
3551 * Derived by default:
3652 * listTables → sim tables list
37- * getKnowledgeDocument → sim knowledge documents get <id> <documentId >
53+ * getKnowledgeDocument → sim documents get <documentId> --kb <knowledgeBaseId >
3854 * upsertTableRow → sim tables upsert <tableId>
3955 */
4056export const CLI_CONTRACT : CliContract = {
@@ -54,6 +70,12 @@ export const CLI_CONTRACT: CliContract = {
5470 listUsageLogs : {
5571 command : 'billing logs' ,
5672 describe : 'List credit usage events' ,
73+ flags : {
74+ source : { describe : 'Filter by usage source' } ,
75+ period : { describe : 'Billing period' } ,
76+ startDate : { describe : 'Custom period start (ISO 8601)' } ,
77+ endDate : { describe : 'Custom period end (ISO 8601)' } ,
78+ } ,
5779 columns : [
5880 { header : 'at' , path : 'createdAt' , format : 'timestamp' } ,
5981 { header : 'source' } ,
@@ -99,7 +121,11 @@ export const CLI_CONTRACT: CliContract = {
99121 fields : [ { header : 'remaining columns' , path : 'columns' , format : 'count' } ] ,
100122 } ,
101123 deleteKnowledgeBase : { confirm : 'This deletes the knowledge base and every document in it.' } ,
102- deleteKnowledgeDocument : { confirm : 'This deletes the document and its embeddings.' } ,
124+ deleteKnowledgeDocument : {
125+ command : 'documents delete' ,
126+ pathFlags : KNOWLEDGE_DOCUMENT_SCOPE ,
127+ confirm : 'This deletes the document and its embeddings.' ,
128+ } ,
103129 deleteFile : { confirm : 'This archives the file.' } ,
104130 deleteSkill : { confirm : 'This deletes the skill.' } ,
105131 deleteCustomTool : { confirm : 'This deletes the custom tool.' } ,
@@ -223,17 +249,23 @@ export const CLI_CONTRACT: CliContract = {
223249 } ,
224250 } ,
225251 updateTable : {
226- aliases : [ ' mv'] ,
252+ variants : [ moveResource ( 'tables mv', 'table' ) ] ,
227253 flags : {
228254 name : { describe : TABLE_NAME_HELP } ,
229255 folderPath : FOLDER_PATH_FLAG ,
230256 } ,
231257 } ,
232258 createFile : { flags : { folderPath : FOLDER_PATH_FLAG } } ,
233259 createKnowledgeBase : { flags : { folderPath : FOLDER_PATH_FLAG } } ,
234- updateKnowledgeBase : { aliases : [ 'mv' ] , flags : { folderPath : FOLDER_PATH_FLAG } } ,
260+ updateKnowledgeBase : {
261+ variants : [ moveResource ( 'knowledge mv' , 'knowledge base' ) ] ,
262+ flags : { folderPath : FOLDER_PATH_FLAG } ,
263+ } ,
235264 createWorkflow : { flags : { folderPath : FOLDER_PATH_FLAG } } ,
236- updateWorkflow : { aliases : [ 'mv' ] , flags : { folderPath : FOLDER_PATH_FLAG } } ,
265+ updateWorkflow : {
266+ variants : [ moveResource ( 'workflows mv' , 'workflow' ) ] ,
267+ flags : { folderPath : FOLDER_PATH_FLAG } ,
268+ } ,
237269 importWorkflow : { flags : { folderPath : FOLDER_PATH_FLAG } } ,
238270 createCustomTool : { flags : { schema : { json : true , describe : CUSTOM_TOOL_SCHEMA_HELP } } } ,
239271 updateCustomTool : { flags : { schema : { json : true , describe : CUSTOM_TOOL_SCHEMA_HELP } } } ,
@@ -285,7 +317,13 @@ export const CLI_CONTRACT: CliContract = {
285317 { header : 'model' , path : 'embeddingModel' } ,
286318 ] ,
287319 } ,
320+ getKnowledgeDocument : {
321+ command : 'documents get' ,
322+ pathFlags : KNOWLEDGE_DOCUMENT_SCOPE ,
323+ } ,
288324 listKnowledgeDocuments : {
325+ command : 'documents list' ,
326+ pathFlags : KNOWLEDGE_DOCUMENT_SCOPE ,
289327 columns : [
290328 { header : 'id' } ,
291329 { header : 'filename' } ,
@@ -601,7 +639,7 @@ export const CLI_CONTRACT: CliContract = {
601639 } ,
602640
603641 // ─── Not a terminal-shaped operation ──────────────────────────────────────
604- // Multipart upload; `sim knowledge documents upload <id> <path >` needs its
642+ // Multipart upload; `sim documents upload <path> --kb <id >` needs its
605643 // own file-reading command rather than a generated flag surface.
606644 uploadKnowledgeDocument : { hidden : true } ,
607645 createKnowledgeDocumentUpload : { hidden : true } ,
0 commit comments