refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名) - 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块) - docreader proto 描述符采用等长替换,保持序列化字节布局有效 - Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像 - 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
1 parent
9097ee699d
commit
9058149576
3136 files changed
+18018
-18004
No files matched your search
+22
-22
@@ -1,4 +1,4 @@
|
||||
// Package api implements the `weknora api` raw HTTP passthrough command.
|
||||
// Package api implements the `academy api` raw HTTP passthrough command.
|
||||
//
|
||||
// Shape: one positional (path) + `-X/--method` flag, default GET (auto-
|
||||
// promoted to POST when a body is supplied via -d/--input). Text mode writes
|
||||
@@ -22,9 +22,9 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
sdk "github.com/Tencent/WeKnora/client"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/iostreams"
|
||||
sdk "academy/client"
|
||||
)
|
||||
|
||||
// apiFields is intentionally a marker - api wraps arbitrary HTTP responses
|
||||
@@ -50,12 +50,12 @@ type Service interface {
|
||||
Raw(ctx context.Context, method, path string, body any) (*http.Response, error)
|
||||
}
|
||||
|
||||
// NewCmd returns the `weknora api` command.
|
||||
// NewCmd returns the `academy api` command.
|
||||
func NewCmd(f *cmdutil.Factory) *cobra.Command {
|
||||
opts := &Options{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "api <path>",
|
||||
Short: "Make a raw API request to the WeKnora server",
|
||||
Short: "Make a raw API request to the Academy server",
|
||||
Long: `Raw HTTP API access. JSON body via -d/--data (inline) or --input <file>/- (stdin).
|
||||
|
||||
The default method is GET; supplying a body (-d or --input) auto-promotes it
|
||||
@@ -71,11 +71,11 @@ With --paginate, text mode writes the merged {data, total} JSON object with a
|
||||
trailing newline and no envelope.
|
||||
|
||||
Examples:
|
||||
weknora api /api/v1/knowledge-bases # GET
|
||||
weknora api /api/v1/knowledge-bases -d '{"name":"foo"}' # POST (auto)
|
||||
weknora api /api/v1/knowledge-bases -F name=foo -F enabled=true # POST, typed body
|
||||
echo '{"name":"foo"}' | weknora api /api/v1/knowledge-bases --input - # POST via stdin
|
||||
weknora api /api/v1/knowledge-bases/kb_xxx -X DELETE`,
|
||||
academy api /api/v1/knowledge-bases # GET
|
||||
academy api /api/v1/knowledge-bases -d '{"name":"foo"}' # POST (auto)
|
||||
academy api /api/v1/knowledge-bases -F name=foo -F enabled=true # POST, typed body
|
||||
echo '{"name":"foo"}' | academy api /api/v1/knowledge-bases --input - # POST via stdin
|
||||
academy api /api/v1/knowledge-bases/kb_xxx -X DELETE`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
opts.Yes, _ = c.Flags().GetBool("yes")
|
||||
@@ -122,8 +122,8 @@ Examples:
|
||||
}
|
||||
}
|
||||
method := resolveMethod(opts)
|
||||
// Escape-hatch DELETE through `weknora api` is just as destructive
|
||||
// as `weknora kb delete` - exit-10 destructive protocol must apply
|
||||
// Escape-hatch DELETE through `academy api` is just as destructive
|
||||
// as `academy kb delete` - exit-10 destructive protocol must apply
|
||||
// (cli/README.md). PUT/PATCH mutate server state like a typed
|
||||
// `kb/agent/doc update`, so they get the same exit-10 WRITE gate;
|
||||
// without it the raw escape hatch bypassed the "an agent cannot
|
||||
@@ -131,7 +131,7 @@ Examples:
|
||||
// `create` (also ungated). GET/HEAD are reads.
|
||||
switch method {
|
||||
case http.MethodDelete:
|
||||
if err := cmdutil.ConfirmDestructive(f.Prompter(), opts.Yes, fopts.WantsJSON(), "delete", "endpoint", args[0], "api.delete", []string{"weknora", "api", "-X", "DELETE", args[0], "-y"}); err != nil {
|
||||
if err := cmdutil.ConfirmDestructive(f.Prompter(), opts.Yes, fopts.WantsJSON(), "delete", "endpoint", args[0], "api.delete", []string{"academy", "api", "-X", "DELETE", args[0], "-y"}); err != nil {
|
||||
return err
|
||||
}
|
||||
case http.MethodPut, http.MethodPatch:
|
||||
@@ -155,14 +155,14 @@ Examples:
|
||||
cmdutil.AddFormatFlag(cmd, apiFields...)
|
||||
cmdutil.AddDryRunFlag(cmd, &opts.DryRun)
|
||||
cmdutil.SetAgentHelp(cmd, cmdutil.AgentHelp{
|
||||
UsedFor: "raw HTTP passthrough to weknora-server API endpoints when typed subcommands are insufficient",
|
||||
UsedFor: "raw HTTP passthrough to academy-server API endpoints when typed subcommands are insufficient",
|
||||
RequiredFlags: []string{"path (positional)"},
|
||||
Examples: []string{
|
||||
"weknora api /api/v1/knowledge-bases",
|
||||
"weknora api /api/v1/knowledge-bases -d '{\"name\":\"foo\"}'",
|
||||
"weknora api -X POST /api/v1/knowledge-bases -F name=\"Eng Docs\" -F enabled=true",
|
||||
"weknora api -X DELETE /api/v1/knowledge-bases/kb_x -y",
|
||||
"echo '{\"name\":\"foo\"}' | weknora api /api/v1/knowledge-bases --input -",
|
||||
"academy api /api/v1/knowledge-bases",
|
||||
"academy api /api/v1/knowledge-bases -d '{\"name\":\"foo\"}'",
|
||||
"academy api -X POST /api/v1/knowledge-bases -F name=\"Eng Docs\" -F enabled=true",
|
||||
"academy api -X DELETE /api/v1/knowledge-bases/kb_x -y",
|
||||
"echo '{\"name\":\"foo\"}' | academy api /api/v1/knowledge-bases --input -",
|
||||
},
|
||||
Output: "text mode: the raw server response body on stdout. " +
|
||||
"json mode (default): the parsed server response is placed directly under envelope.data - " +
|
||||
@@ -311,11 +311,11 @@ func resolveMethod(opts *Options) string {
|
||||
return "GET"
|
||||
}
|
||||
|
||||
// apiRetryArgv reconstructs a directly-executable `weknora api` argv (with -y)
|
||||
// apiRetryArgv reconstructs a directly-executable `academy api` argv (with -y)
|
||||
// for the write-confirmation gate, preserving the method, path and body flags
|
||||
// the caller passed so an agent can re-run the exact mutation after approval.
|
||||
func apiRetryArgv(opts *Options, method, path string) []string {
|
||||
argv := []string{"weknora", "api", "-X", method, path}
|
||||
argv := []string{"academy", "api", "-X", method, path}
|
||||
switch {
|
||||
case opts.Data != "":
|
||||
argv = append(argv, "-d", opts.Data)
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/prompt"
|
||||
sdk "github.com/Tencent/WeKnora/client"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/prompt"
|
||||
sdk "academy/client"
|
||||
)
|
||||
|
||||
// apiDryRunFactory builds a Factory whose Client closure panics if invoked —
|
||||
|
||||
@@ -19,10 +19,10 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/prompt"
|
||||
sdk "github.com/Tencent/WeKnora/client"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/prompt"
|
||||
sdk "academy/client"
|
||||
)
|
||||
|
||||
// fakeAPISvc is a test double for Service that delegates each call to a
|
||||
@@ -306,12 +306,12 @@ func TestAPI_PathWithoutSlash(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// withRootHarness wraps `weknora api ...` under a synthetic root cmd that
|
||||
// withRootHarness wraps `academy api ...` under a synthetic root cmd that
|
||||
// registers the global persistent flags (mirrors addGlobalFlags in
|
||||
// cmd/root.go). Required because api's NewCmd doesn't register --yes /
|
||||
// --format / --jq itself — it inherits them from root in production.
|
||||
func withRootHarness(api *cobra.Command, args ...string) *cobra.Command {
|
||||
root := &cobra.Command{Use: "weknora"}
|
||||
root := &cobra.Command{Use: "academy"}
|
||||
pf := root.PersistentFlags()
|
||||
pf.BoolP("yes", "y", false, "")
|
||||
pf.String("format", "", "")
|
||||
@@ -325,7 +325,7 @@ func withRootHarness(api *cobra.Command, args ...string) *cobra.Command {
|
||||
}
|
||||
|
||||
// TestAPI_DELETE_RequiresConfirmation pins the exit-10 protocol on the
|
||||
// escape-hatch DELETE path: agent invokes `weknora api DELETE /...` without
|
||||
// escape-hatch DELETE path: agent invokes `academy api DELETE /...` without
|
||||
// -y/--yes, must get input.confirmation_required + exit 10. Confirmation is
|
||||
// enforced in NewCmd.RunE (not runAPI), so the test drives the cobra cmd.
|
||||
func TestAPI_DELETE_RequiresConfirmation(t *testing.T) {
|
||||
@@ -659,7 +659,7 @@ func TestAPI_PaginateServerCapsPageSize(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestAPI_PUT_RequiresConfirmation pins the exit-10 write gate on the
|
||||
// escape-hatch PUT path: `weknora api -X PUT /...` mutates server state the
|
||||
// escape-hatch PUT path: `academy api -X PUT /...` mutates server state the
|
||||
// same way a typed `kb update` does, so it must require -y (exit 10) rather
|
||||
// than silently writing. Regression: only DELETE was gated, letting an agent
|
||||
// bypass the write-confirmation protocol via raw PUT/PATCH.
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/cmd"
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
sdk "github.com/Tencent/WeKnora/client"
|
||||
"academy/cli/cmd"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/iostreams"
|
||||
sdk "academy/client"
|
||||
)
|
||||
|
||||
func TestAPI_PaginateFormats(t *testing.T) {
|
||||
@@ -110,8 +110,8 @@ func TestAPI_PaginateFormats(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Setenv("WEKNORA_FORMAT", tc.env)
|
||||
t.Setenv("WEKNORA_PROFILE", "")
|
||||
t.Setenv("ACADEMY_FORMAT", tc.env)
|
||||
t.Setenv("ACADEMY_PROFILE", "")
|
||||
out, errOut := iostreams.SetForTest(t)
|
||||
if tc.tty {
|
||||
out, errOut = iostreams.SetForTestWithTTY(t)
|
||||
@@ -209,7 +209,7 @@ func (w *paginationFailWriter) Write(p []byte) (int, error) {
|
||||
func TestAPI_PaginateTextWriteError(t *testing.T) {
|
||||
for _, tail := range []bool{false, true} {
|
||||
t.Run(strconv.FormatBool(tail), func(t *testing.T) {
|
||||
t.Setenv("WEKNORA_PROFILE", "")
|
||||
t.Setenv("ACADEMY_PROFILE", "")
|
||||
iostreams.SetForTest(t)
|
||||
sentinel := errors.New("synthetic output failure")
|
||||
out := &paginationFailWriter{err: sentinel, tail: tail}
|
||||
|
||||
Reference in new issue
Block a user