feat: define P2 host workspace command contract

This commit is contained in:
2026-08-11 00:24:31 +02:00
parent 38c8398bc1
commit ccaf8c1be0
12 changed files with 808 additions and 1 deletions
+13
View File
@@ -19,6 +19,7 @@ import (
"github.com/aritmolab/thothii/tools/thothctl/internal/output"
"github.com/aritmolab/thothii/tools/thothctl/internal/pi"
"github.com/aritmolab/thothii/tools/thothctl/internal/serverops"
"github.com/aritmolab/thothii/tools/thothctl/internal/workspaceops"
)
const usage = `Usage: thothctl --installation <absolute-path>/thothii-installation.yaml <command>
@@ -50,6 +51,10 @@ Commands:
pi maintenance recover --yes
Verify a terminal installation, remove stale lifecycle files, and clear maintenance.
pi logs Show the latest 200 sanitized core log lines (bounded; no follow mode).
workspace inspect --workspace ID [--json]
workspace preprocess dwh|evidence|run --workspace ID [options]
workspace schema suggest-fks|check --workspace ID [options]
workspace index-schema --workspace ID [--json]
`
func main() {
@@ -83,6 +88,14 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
}
runner := compose.NewRunner("")
if command == "workspace" {
workspaceCommand, parseErr := workspaceops.ParseWorkspaceCommand(append([]string{"workspace"}, commandArgs...))
if parseErr != nil { return commandUsageError(stderr, parseErr.Error()) }
result, operationErr := workspaceops.Run(ctx, installation, runner, workspaceCommand, nil)
if operationErr != nil { if errors.Is(operationErr, compose.ErrOutputLimit) || strings.Contains(operationErr.Error(), "unsafe") || strings.Contains(operationErr.Error(), "exceeds") { return commandUsageError(stderr, operationErr.Error()) }; fmt.Fprintf(stderr, "thothctl: %s\n", output.Sanitize(operationErr.Error(), secretValues)); return 1 }
if err := json.NewEncoder(stdout).Encode(result); err != nil { return 1 }
if result.Status == "blocked" { return 3 }; if result.Status == "failed" { return 1 }; return 0
}
var result compose.Result
switch command {
case "status":