Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(cli): add multica doc folder commands (MUL-9817) (#11160)

Jiayuan Zhang03a65a541dd6
diff --git a/server/cmd/multica/cmd_doc.go b/server/cmd/multica/cmd_doc.go
index f91cf909cc..aac638c161 100644
--- a/server/cmd/multica/cmd_doc.go
+++ b/server/cmd/multica/cmd_doc.go
@@ -95,8 +95,49 @@ var docEditCmd = &cobra.Command{
RunE: runDocEdit,
}
+var docFolderCmd = &cobra.Command{
+ Use: "folder",
+ Short: "Manage knowledge base doc folders",
+ Long: "List, create, rename, and move folders in the workspace knowledge base.\n\n" +
+ "Folder arguments and --parent accept a full folder id or a unique prefix from " +
+ "`multica doc list` or `multica doc folder list`.",
+}
+
+var docFolderListCmd = &cobra.Command{
+ Use: "list",
+ Short: "List doc folders",
+ RunE: runDocFolderList,
+}
+
+var docFolderCreateCmd = &cobra.Command{
+ Use: "create",
+ Short: "Create a doc folder",
+ RunE: runDocFolderCreate,
+}
+
+var docFolderUpdateCmd = &cobra.Command{
+ Use: "update <folder-id>",
+ Aliases: []string{"rename"},
+ Short: "Rename a doc folder",
+ Long: "Rename a folder in the workspace knowledge base.\n\n" +
+ "<folder-id> accepts a full folder id or a unique prefix from `multica doc list` or `multica doc folder list`.",
+ Args: exactArgs(1),
+ RunE: runDocFolderUpdate,
+}
+
+var docFolderMoveCmd = &cobra.Command{
+ Use: "move <folder-id>",
+ Short: "Move a doc folder into another folder, or to the top level",
+ Long: "Move a folder into another folder of the workspace knowledge base.\n\n" +
+ "<folder-id> and --parent accept a full folder id or a unique prefix from `multica doc list` or `multica doc folder list`. " +
+ "Pass `--parent root` to move the folder to the top level.",
+ Args: exactArgs(1),
+ RunE: runDocFolderMove,
+}
+
func init() {
- docCmd.AddCommand(docListCmd, docSearchCmd, docGetCmd, docCreateCmd, docUpdateCmd, docEditCmd, docMoveCmd)
+ docCmd.AddCommand(docListCmd, docSearchCmd, docGetCmd, docCreateCmd, docUpdateCmd, docEditCmd, docMoveCmd, docFolderCmd)
+ docFolderCmd.AddCommand(docFolderListCmd, docFolderCreateCmd, docFolderUpdateCmd, docFolderMoveCmd)
docMoveCmd.Flags().String("folder", "", "Destination folder id, or `root` for the top level (required)")
docMoveCmd.Flags().String("output", "json", "Output format: table or json")
docListCmd.Flags().String("output", "table", "Output format: table or json")
@@ -120,6 +161,14 @@ func init() {
docEditCmd.Flags().Bool("replace-all", false, "Replace every occurrence of --old")
docEditCmd.Flags().String("message", "", "Change summary for history")
docEditCmd.Flags().String("output", "json", "Output format: table or json")
+ docFolderListCmd.Flags().String("output", "table", "Output format: table or json")
+ docFolderCreateCmd.Flags().String("title", "", "Folder title (required)")
+ docFolderCreateCmd.Flags().String("parent", "", "Parent folder id, or `root` for the top level (default: root)")
+ docFolderCreateCmd.Flags().String("output", "json", "Output format: table or json")
+ docFolderUpdateCmd.Flags().String("title", "", "Folder title (required)")
+ docFolderUpdateCmd.Flags().String("output", "json", "Output format: table or json")
+ docFolderMoveCmd.Flags().String("parent", "", "Destination parent folder id, or `root` for the top level (required)")
+ docFolderMoveCmd.Flags().String("output", "json", "Output format: table or json")
}
type docTree struct {
@@ -137,7 +186,15 @@ func fetchDocTree(ctx context.Context, client *cli.APIClient) (docTree, error) {
// resolveDocRef accepts a full id or an unambiguous id prefix from `doc list`.
func resolveDocRef(ctx context.Context, client *cli.APIClient, ref string, folders bool) (string, error) {
- if len(ref) == 36 {
+ kind := "doc"
+ if folders {
+ kind = "folder"
+ }
+ ref = strings.TrimSpace(ref)
+ if ref == "" {
+ return "", fmt.Errorf("%s id is required", kind)
+ }
+ if uuidRegexp.MatchString(ref) {
return ref, nil
}
tree, err := fetchDocTree(ctx, client)
@@ -145,10 +202,8 @@ func resolveDocRef(ctx context.Context, client *cli.APIClient, ref string, folde
return "", err
}
items := tree.Docs
- kind := "doc"
if folders {
items = tree.Folders
- kind = "folder"
}
var matches []string
for _, item := range items {
@@ -167,6 +222,7 @@ func resolveDocRef(ctx context.Context, client *cli.APIClient, ref string, folde
}
func resolveDocFolderTarget(ctx context.Context, client *cli.APIClient, ref string) (any, error) {
+ ref = strings.TrimSpace(ref)
if ref == "root" || ref == "" {
return nil, nil
}
@@ -506,3 +562,136 @@ func runDocEdit(cmd *cobra.Command, args []string) error {
output, _ := cmd.Flags().GetString("output")
return printDocSummary(doc, output)
}
+
+func printDocFolderSummary(folder map[string]any, output string) error {
+ if output == "table" {
+ parent := strVal(folder, "parent_id")
+ if parent == "" {
+ parent = "root"
+ }
+ cli.PrintTable(os.Stdout, []string{"ID", "TITLE", "PARENT"}, [][]string{{
+ strVal(folder, "id"), strVal(folder, "title"), parent,
+ }})
+ return nil
+ }
+ return cli.PrintJSON(os.Stdout, folder)
+}
+
+func runDocFolderList(cmd *cobra.Command, _ []string) error {
+ client, err := newAPIClient(cmd)
+ if err != nil {
+ return err
+ }
+ ctx, cancel := cli.APIContext(context.Background())
+ defer cancel()
+
+ tree, err := fetchDocTree(ctx, client)
+ if err != nil {
+ return err
+ }
+ folders := tree.Folders
+ if folders == nil {
+ folders = []map[string]any{}
+ }
+ output, _ := cmd.Flags().GetString("output")
+ if output == "json" {
+ return cli.PrintJSON(os.Stdout, folders)
+ }
+
+ paths := docFolderPaths(folders)
+ rows := make([][]string, 0, len(folders))
+ for _, f := range folders {
+ id := strVal(f, "id")
+ updated := strVal(f, "updated_at")
+ if len(updated) >= 10 {
+ updated = updated[:10]
+ }
+ rows = append(rows, []string{id, paths[id] + "/", updated})
+ }
+ sort.SliceStable(rows, func(i, j int) bool { return rows[i][1] < rows[j][1] })
+ cli.PrintTable(os.Stdout, []string{"ID", "PATH", "UPDATED"}, rows)
+ return nil
+}
+
+func runDocFolderCreate(cmd *cobra.Command, _ []string) error {
+ title, _ := cmd.Flags().GetString("title")
+ if strings.TrimSpace(title) == "" {
+ return fmt.Errorf("--title is required")
+ }
+
+ client, err := newAPIClient(cmd)
+ if err != nil {
+ return err
+ }
+ ctx, cancel := cli.APIContext(context.Background())
+ defer cancel()
+
+ body := map[string]any{"title": title}
+ if v, _ := cmd.Flags().GetString("parent"); strings.TrimSpace(v) != "" {
+ parent, err := resolveDocFolderTarget(ctx, client, v)
+ if err != nil {
+ return err
+ }
+ body["parent_id"] = parent
+ }
+ var folder map[string]any
+ if err := client.PostJSON(ctx, "/api/doc-folders", body, &folder); err != nil {
+ return fmt.Errorf("create doc folder: %w", err)
+ }
+ output, _ := cmd.Flags().GetString("output")
+ return printDocFolderSummary(folder, output)
+}
+
+func runDocFolderUpdate(cmd *cobra.Command, args []string) error {
+ title, _ := cmd.Flags().GetString("title")
+ if strings.TrimSpace(title) == "" {
+ return fmt.Errorf("--title is required")
+ }
+
+ client, err := newAPIClient(cmd)
+ if err != nil {
+ return err
+ }
+ ctx, cancel := cli.APIContext(context.Background())
+ defer cancel()
+
+ id, err := resolveDocRef(ctx, client, args[0], true)
+ if err != nil {
+ return err
+ }
+ var folder map[string]any
+ if err := client.PatchJSON(ctx, "/api/doc-folders/"+id, map[string]any{"title": title}, &folder); err != nil {
+ return fmt.Errorf("update doc folder: %w", err)
+ }
+ output, _ := cmd.Flags().GetString("output")
+ return printDocFolderSummary(folder, output)
+}
+
+func runDocFolderMove(cmd *cobra.Command, args []string) error {
+ destination, _ := cmd.Flags().GetString("parent")
+ if strings.TrimSpace(destination) == "" {
+ return fmt.Errorf("--parent is required: a folder id, or `root` for the top level")
+ }
+
+ client, err := newAPIClient(cmd)
+ if err != nil {
+ return err
+ }
+ ctx, cancel := cli.APIContext(context.Background())
+ defer cancel()
+
+ id, err := resolveDocRef(ctx, client, args[0], true)
+ if err != nil {
+ return err
+ }
+ parent, err := resolveDocFolderTarget(ctx, client, destination)
+ if err != nil {
+ return err
+ }
+ var folder map[string]any
+ if err := client.PostJSON(ctx, "/api/doc-folders/"+id+"/move", map[string]any{"parent_id": parent}, &folder); err != nil {
+ return fmt.Errorf("move doc folder: %w", err)
+ }
+ output, _ := cmd.Flags().GetString("output")
+ return printDocFolderSummary(folder, output)
+}
diff --git a/server/cmd/multica/cmd_doc_test.go b/server/cmd/multica/cmd_doc_test.go
index 93c5688249..5ad5765605 100644
--- a/server/cmd/multica/cmd_doc_test.go
+++ b/server/cmd/multica/cmd_doc_test.go
@@ -13,7 +13,10 @@ import (
)
func TestDocCommandsExposeOnlyAgentReadWrite(t *testing.T) {
- expected := map[string]bool{"list": true, "search": true, "get": true, "create": true, "edit": true, "update": true, "move": true}
+ expected := map[string]bool{
+ "list": true, "search": true, "get": true, "create": true,
+ "edit": true, "update": true, "move": true, "folder": true,
+ }
for _, command := range docCmd.Commands() {
if !expected[command.Name()] {
t.Fatalf("unexpected doc command: %s", command.Name())
@@ -21,7 +24,21 @@ func TestDocCommandsExposeOnlyAgentReadWrite(t *testing.T) {
delete(expected, command.Name())
}
if len(expected) != 0 {
- t.Fatalf("missing commands: %v", expected)
+ t.Fatalf("missing doc commands: %v", expected)
+ }
+
+ expectedFolder := map[string]bool{"list": true, "create": true, "update": true, "move": true}
+ for _, command := range docFolderCmd.Commands() {
+ if !expectedFolder[command.Name()] {
+ t.Fatalf("unexpected doc folder command: %s", command.Name())
+ }
+ delete(expectedFolder, command.Name())
+ }
+ if len(expectedFolder) != 0 {
+ t.Fatalf("missing doc folder commands: %v", expectedFolder)
+ }
+ if !docFolderUpdateCmd.HasAlias("rename") {
+ t.Fatal("doc folder update should accept rename as an alias")
}
}
@@ -100,3 +117,273 @@ func TestRunDocMoveSendsDestination(t *testing.T) {
t.Fatalf("missing --folder must explain itself: %v", err)
}
}
+
+func TestRunDocFolderListFormatsTableAndJSON(t *testing.T) {
+ const rootID = "11111111-2222-3333-4444-555555555555"
+ const childID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ var returnNilFolders bool
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/api/docs" {
+ http.NotFound(w, r)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ if returnNilFolders {
+ _ = json.NewEncoder(w).Encode(map[string]any{"docs": []any{}})
+ return
+ }
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "folders": []any{
+ map[string]any{"id": childID, "title": "Release", "parent_id": rootID, "updated_at": "2026-11-22T01:02:03Z"},
+ map[string]any{"id": rootID, "title": "Guides", "parent_id": nil, "updated_at": "2026-11-21T01:02:03Z"},
+ },
+ "docs": []any{},
+ })
+ }))
+ defer srv.Close()
+ t.Setenv("MULTICA_SERVER_URL", srv.URL)
+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+ t.Cleanup(func() { _ = docFolderListCmd.Flags().Set("output", "table") })
+
+ _ = docFolderListCmd.Flags().Set("output", "table")
+ out, err := captureStdout(t, func() error { return runDocFolderList(docFolderListCmd, nil) })
+ if err != nil {
+ t.Fatalf("runDocFolderList table: %v", err)
+ }
+ if !strings.Contains(out, "Guides/") || !strings.Contains(out, "Guides/Release/") {
+ t.Fatalf("table output missing folder paths: %q", out)
+ }
+ if strings.Index(out, rootID) > strings.Index(out, childID) {
+ t.Fatalf("table output should sort parent before child: %q", out)
+ }
+
+ _ = docFolderListCmd.Flags().Set("output", "json")
+ out, err = captureStdout(t, func() error { return runDocFolderList(docFolderListCmd, nil) })
+ if err != nil {
+ t.Fatalf("runDocFolderList json: %v", err)
+ }
+ var got []map[string]any
+ if err := json.Unmarshal([]byte(out), &got); err != nil || len(got) != 2 {
+ t.Fatalf("json output = %q (err=%v)", out, err)
+ }
+
+ returnNilFolders = true
+ out, err = captureStdout(t, func() error { return runDocFolderList(docFolderListCmd, nil) })
+ if err != nil {
+ t.Fatalf("runDocFolderList empty json: %v", err)
+ }
+ if strings.TrimSpace(out) != "[]" {
+ t.Fatalf("empty json output = %q, want []", out)
+ }
+}
+
+func TestRunDocFolderCreateSendsTitleAndParent(t *testing.T) {
+ const parentID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ const createdID = "11111111-2222-3333-4444-555555555555"
+ var gotMethod, gotPath string
+ var gotBody map[string]any
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ if r.Method == http.MethodGet && r.URL.Path == "/api/docs" {
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "folders": []any{map[string]any{"id": parentID, "title": "Guides", "parent_id": nil}},
+ "docs": []any{},
+ })
+ return
+ }
+ gotMethod, gotPath = r.Method, r.URL.Path
+ gotBody = nil
+ _ = json.NewDecoder(r.Body).Decode(&gotBody)
+ w.WriteHeader(http.StatusCreated)
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "id": createdID,
+ "title": gotBody["title"],
+ "parent_id": gotBody["parent_id"],
+ })
+ }))
+ defer srv.Close()
+ t.Setenv("MULTICA_SERVER_URL", srv.URL)
+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+ t.Cleanup(func() {
+ _ = docFolderCreateCmd.Flags().Set("title", "")
+ _ = docFolderCreateCmd.Flags().Set("parent", "")
+ _ = docFolderCreateCmd.Flags().Set("output", "json")
+ })
+
+ _ = docFolderCreateCmd.Flags().Set("title", "")
+ if err := runDocFolderCreate(docFolderCreateCmd, nil); err == nil || !strings.Contains(err.Error(), "--title is required") {
+ t.Fatalf("missing --title must fail: %v", err)
+ }
+
+ // Root folder (no --parent)
+ _ = docFolderCreateCmd.Flags().Set("title", "Guides")
+ _ = docFolderCreateCmd.Flags().Set("parent", "")
+ _ = docFolderCreateCmd.Flags().Set("output", "table")
+ out, err := captureStdout(t, func() error { return runDocFolderCreate(docFolderCreateCmd, nil) })
+ if err != nil {
+ t.Fatalf("runDocFolderCreate root: %v", err)
+ }
+ if gotMethod != http.MethodPost || gotPath != "/api/doc-folders" || gotBody["title"] != "Guides" {
+ t.Fatalf("root create sent %s %s %v", gotMethod, gotPath, gotBody)
+ }
+ if _, hasParent := gotBody["parent_id"]; hasParent {
+ t.Fatalf("root create should omit parent_id: %v", gotBody)
+ }
+ if !strings.Contains(out, createdID) || !strings.Contains(out, "root") {
+ t.Fatalf("table output missing summary: %q", out)
+ }
+
+ // Nested folder via unique ID prefix, plus explicit --parent root
+ _ = docFolderCreateCmd.Flags().Set("output", "json")
+ for _, tc := range []struct {
+ parent string
+ want any
+ }{
+ {parentID, parentID},
+ {"aaaaaaaa", parentID},
+ {"root", nil},
+ } {
+ _ = docFolderCreateCmd.Flags().Set("title", "Runbooks")
+ _ = docFolderCreateCmd.Flags().Set("parent", tc.parent)
+ if _, err := captureStdout(t, func() error { return runDocFolderCreate(docFolderCreateCmd, nil) }); err != nil {
+ t.Fatalf("runDocFolderCreate(--parent %s): %v", tc.parent, err)
+ }
+ if gotMethod != http.MethodPost || gotPath != "/api/doc-folders" || gotBody["parent_id"] != tc.want {
+ t.Fatalf("--parent %s sent %s %s %v", tc.parent, gotMethod, gotPath, gotBody)
+ }
+ }
+}
+
+func TestRunDocFolderUpdateRenamesFolder(t *testing.T) {
+ const folderID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ var gotMethod, gotPath string
+ var gotBody map[string]any
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ if r.Method == http.MethodGet && r.URL.Path == "/api/docs" {
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "folders": []any{map[string]any{"id": folderID, "title": "Guides", "parent_id": nil}},
+ "docs": []any{},
+ })
+ return
+ }
+ gotMethod, gotPath = r.Method, r.URL.Path
+ gotBody = nil
+ _ = json.NewDecoder(r.Body).Decode(&gotBody)
+ _ = json.NewEncoder(w).Encode(map[string]any{"id": folderID, "title": gotBody["title"], "parent_id": nil})
+ }))
+ defer srv.Close()
+ t.Setenv("MULTICA_SERVER_URL", srv.URL)
+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+ t.Cleanup(func() {
+ _ = docFolderUpdateCmd.Flags().Set("title", "")
+ _ = docFolderUpdateCmd.Flags().Set("output", "json")
+ })
+
+ _ = docFolderUpdateCmd.Flags().Set("title", "")
+ if err := runDocFolderUpdate(docFolderUpdateCmd, []string{folderID}); err == nil || !strings.Contains(err.Error(), "--title is required") {
+ t.Fatalf("missing --title must fail: %v", err)
+ }
+
+ _ = docFolderUpdateCmd.Flags().Set("title", "Engineering Guides")
+ if _, err := captureStdout(t, func() error { return runDocFolderUpdate(docFolderUpdateCmd, []string{"aaaaaaaa"}) }); err != nil {
+ t.Fatalf("runDocFolderUpdate prefix: %v", err)
+ }
+ if gotMethod != http.MethodPatch || gotPath != "/api/doc-folders/"+folderID || gotBody["title"] != "Engineering Guides" {
+ t.Fatalf("update sent %s %s %v", gotMethod, gotPath, gotBody)
+ }
+}
+
+func TestRunDocFolderMoveSendsParent(t *testing.T) {
+ const folderID = "11111111-2222-3333-4444-555555555555"
+ const parentID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ var gotMethod, gotPath string
+ var gotBody map[string]any
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ if r.Method == http.MethodGet && r.URL.Path == "/api/docs" {
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "folders": []any{
+ map[string]any{"id": folderID, "title": "Child", "parent_id": nil},
+ map[string]any{"id": parentID, "title": "Parent", "parent_id": nil},
+ },
+ "docs": []any{},
+ })
+ return
+ }
+ gotMethod, gotPath = r.Method, r.URL.Path
+ gotBody = nil
+ _ = json.NewDecoder(r.Body).Decode(&gotBody)
+ _ = json.NewEncoder(w).Encode(map[string]any{"id": folderID, "title": "Child", "parent_id": gotBody["parent_id"]})
+ }))
+ defer srv.Close()
+ t.Setenv("MULTICA_SERVER_URL", srv.URL)
+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+ t.Cleanup(func() {
+ _ = docFolderMoveCmd.Flags().Set("parent", "")
+ _ = docFolderMoveCmd.Flags().Set("output", "json")
+ })
+
+ for _, tc := range []struct {
+ ref string
+ parent string
+ want any
+ }{
+ {folderID, parentID, parentID},
+ {"11111111", "aaaaaaaa", parentID},
+ {folderID, "root", nil},
+ } {
+ _ = docFolderMoveCmd.Flags().Set("parent", tc.parent)
+ if _, err := captureStdout(t, func() error { return runDocFolderMove(docFolderMoveCmd, []string{tc.ref}) }); err != nil {
+ t.Fatalf("runDocFolderMove(%s, %s): %v", tc.ref, tc.parent, err)
+ }
+ if gotMethod != http.MethodPost || gotPath != "/api/doc-folders/"+folderID+"/move" || gotBody["parent_id"] != tc.want {
+ t.Fatalf("move(%s, --parent %s) sent %s %s %v", tc.ref, tc.parent, gotMethod, gotPath, gotBody)
+ }
+ }
+
+ _ = docFolderMoveCmd.Flags().Set("parent", "")
+ if err := runDocFolderMove(docFolderMoveCmd, []string{folderID}); err == nil || !strings.Contains(err.Error(), "--parent is required") {
+ t.Fatalf("missing --parent must explain itself: %v", err)
+ }
+}
+
+func TestRunDocFolderUpdateRejectsEmptyAndNonUUIDRefs(t *testing.T) {
+ const folderID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
+ var writes int
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ if r.Method == http.MethodGet && r.URL.Path == "/api/docs" {
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "folders": []any{map[string]any{"id": folderID, "title": "Guides", "parent_id": nil}},
+ "docs": []any{},
+ })
+ return
+ }
+ writes++
+ _ = json.NewEncoder(w).Encode(map[string]any{"id": folderID, "title": "X"})
+ }))
+ defer srv.Close()
+ t.Setenv("MULTICA_SERVER_URL", srv.URL)
+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+ t.Cleanup(func() { _ = docFolderUpdateCmd.Flags().Set("title", "") })
+
+ _ = docFolderUpdateCmd.Flags().Set("title", "X")
+ for _, ref := range []string{"", " "} {
+ if err := runDocFolderUpdate(docFolderUpdateCmd, []string{ref}); err == nil || !strings.Contains(err.Error(), "folder id is required") {
+ t.Fatalf("ref %q must be rejected: %v", ref, err)
+ }
+ }
+ nonUUID := "aaaaaaaa/../../../docs?x=1#yyyyyyyyyy"[:36]
+ if err := runDocFolderUpdate(docFolderUpdateCmd, []string{nonUUID}); err == nil || !strings.Contains(err.Error(), "no folder matches") {
+ t.Fatalf("36-char non-UUID ref must not be used as an id: %v", err)
+ }
+ if writes != 0 {
+ t.Fatalf("rejected refs must not reach a write endpoint, got %d writes", writes)
+ }
+}
diff --git a/server/internal/daemon/execenv/runtime_config_kind_test.go b/server/internal/daemon/execenv/runtime_config_kind_test.go
index ad585b2156..7dcf928324 100644
--- a/server/internal/daemon/execenv/runtime_config_kind_test.go
+++ b/server/internal/daemon/execenv/runtime_config_kind_test.go
@@ -84,7 +84,7 @@ func TestBuildMetaSkillContentDocsFollowFlag(t *testing.T) {
for _, enabled := range []bool{false, true} {
out := buildMetaSkillContent("claude", TaskContextForEnv{IssueID: "issue-1", DocsEnabled: enabled})
- for _, line := range []string{"`multica doc list|search|get|create|edit|update|move`", "mention://doc/<doc-id>"} {
+ for _, line := range []string{"`multica doc list|search|get|create|edit|update|move|folder`", "mention://doc/<doc-id>"} {
if got := strings.Contains(out, line); got != enabled {
t.Errorf("DocsEnabled=%v: brief contains %q = %v\n---\n%s", enabled, line, got, out)
}
diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.go
index 58ba9f10da..5c6c6dea67 100644
--- a/server/internal/daemon/execenv/runtime_config_sections.go
+++ b/server/internal/daemon/execenv/runtime_config_sections.go
@@ -282,7 +282,7 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {
b.WriteString("- `multica issue wakeup <create|list|get|update|disable|trigger|delete|runs|events>` — persist an event, condition or time wakeup on this issue, then finish the current run. When the platform can check the fact itself, use one `--until-*` condition so no run starts before it holds; check the rule's `last_error` for missing PR links or snapshots, which are retried automatically. Conditions, PR rules and actor filters: `multica issue wakeup create --help` and the multica-platform issues reference.\n")
b.WriteString("- `multica issue children <id> [--output json]` — list a parent's sub-issues grouped by stage.\n")
if ctx.DocsEnabled {
- b.WriteString("- `multica doc list|search|get|create|edit|update|move` — workspace docs; `doc search <query>` matches titles and content; people may be editing a doc live, so change part of it with `doc edit <id> --old <exact text> --new <text>`; `doc update` rewrites the whole doc and needs `--base-revision` from `multica doc get` (details: `multica doc --help`).\n")
+ b.WriteString("- `multica doc list|search|get|create|edit|update|move|folder` — workspace docs and folders (`doc folder list|create|update|move`); `doc search <query>` matches titles and content; people may be editing a doc live, so change part of it with `doc edit <id> --old <exact text> --new <text>`; `doc update` rewrites the whole doc and needs `--base-revision` from `multica doc get` (details: `multica doc --help`).\n")
}
b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file` with a file inside your working directory; full flags: `multica issue comment add --help`.\n")
b.WriteString("- `multica repo checkout <url> [--ref <branch-or-sha>] [--fresh]` — repository checkout on a dedicated branch; re-running it keeps a checkout that has uncommitted or unpushed work, or is already on this task's branch, and only fetches; a clean, fully pushed checkout on another branch starts over on a new branch. `--fresh` discards uncommitted and untracked files for a new branch; commits stay on the old branch, so push any you still need first.\n\n")