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
@@ -14,11 +14,11 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"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/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/prompt"
|
||||
sdk "academy/client"
|
||||
)
|
||||
|
||||
// linkDryRunFactory builds a Factory whose Client closure panics if invoked —
|
||||
@@ -41,7 +41,7 @@ func linkDryRunFactory(t *testing.T, cfg *config.Config) *cmdutil.Factory {
|
||||
// withRootHarnessLink wraps a link subcommand under a synthetic root cmd
|
||||
// that registers the global persistent flags.
|
||||
func withRootHarnessLink(sub *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", "", "")
|
||||
@@ -85,7 +85,7 @@ func TestLink_DryRun_RejectsNoKBNoTTY(t *testing.T) {
|
||||
assert.Equal(t, cmdutil.CodeKBIDRequired, typed.Code)
|
||||
}
|
||||
|
||||
// TestUnlink_DryRun_RejectsMissingLink: cwd has no .weknora/project.yaml →
|
||||
// TestUnlink_DryRun_RejectsMissingLink: cwd has no .academy/project.yaml →
|
||||
// live path returns input.invalid_argument; --dry-run must do the same.
|
||||
func TestUnlink_DryRun_RejectsMissingLink(t *testing.T) {
|
||||
iostreams.SetForTest(t)
|
||||
|
||||
+20
-20
@@ -1,5 +1,5 @@
|
||||
// Package linkcmd implements `weknora link` - binds the current working
|
||||
// directory to a knowledge base by writing .weknora/project.yaml. Always
|
||||
// Package linkcmd implements `academy link` - binds the current working
|
||||
// directory to a knowledge base by writing .academy/project.yaml. Always
|
||||
// overwrites an existing link silently rather than refusing when one is
|
||||
// already present. The cobra Long: text covers the user-facing modes
|
||||
// (--kb / TTY / non-TTY).
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/projectlink"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/projectlink"
|
||||
)
|
||||
|
||||
// linkFields enumerates the fields surfaced for `--format json` discovery on
|
||||
@@ -36,28 +36,28 @@ type linkResult struct {
|
||||
ProjectLinkPath string `json:"project_link_path"`
|
||||
}
|
||||
|
||||
// NewCmd builds the `weknora link` command.
|
||||
// NewCmd builds the `academy link` command.
|
||||
func NewCmd(f *cmdutil.Factory) *cobra.Command {
|
||||
opts := &Options{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "link [kb]",
|
||||
Short: "Bind the current directory to a knowledge base",
|
||||
Long: `Writes .weknora/project.yaml in the current working directory pointing
|
||||
Long: `Writes .academy/project.yaml in the current working directory pointing
|
||||
at the supplied knowledge base. Subsequent commands run from this directory
|
||||
(or any subdirectory) automatically resolve --kb from the link unless
|
||||
overridden by the --kb flag or WEKNORA_KB_ID env var.
|
||||
overridden by the --kb flag or ACADEMY_KB_ID env var.
|
||||
|
||||
Pass the knowledge base as a positional argument (weknora link <id-or-name>) or
|
||||
Pass the knowledge base as a positional argument (academy link <id-or-name>) or
|
||||
via --kb — the two are equivalent — for non-interactive use (scripts, CI). Run
|
||||
on a TTY without either to be prompted from the list of available KBs. Always
|
||||
overwrites any existing link - re-run to switch.
|
||||
|
||||
AI agents: link writes to the user's working directory. Only run it when the
|
||||
user explicitly asked to bind this directory; don't run it as a side effect.`,
|
||||
Example: ` weknora link a32a63ff-fb36-4874-bcaa-30f48570a694 # positional UUID
|
||||
weknora link engineering # positional name → id
|
||||
weknora link --kb engineering # --kb form (equivalent)
|
||||
weknora link # interactive (TTY)`,
|
||||
Example: ` academy link a32a63ff-fb36-4874-bcaa-30f48570a694 # positional UUID
|
||||
academy link engineering # positional name → id
|
||||
academy link --kb engineering # --kb form (equivalent)
|
||||
academy link # interactive (TTY)`,
|
||||
// The knowledge base may be given as a positional arg (matching every
|
||||
// other <id> command) or via --kb; the two are equivalent.
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
@@ -101,9 +101,9 @@ user explicitly asked to bind this directory; don't run it as a side effect.`,
|
||||
cmdutil.AddFormatFlag(cmd, linkFields...)
|
||||
cmdutil.AddDryRunFlag(cmd, &opts.DryRun)
|
||||
cmdutil.SetAgentHelp(cmd, cmdutil.AgentHelp{
|
||||
UsedFor: "Bind the current directory to a knowledge base by writing .weknora/project.yaml. Give the KB as a positional arg or --kb (non-interactive); only run when the user explicitly asks to link this directory.",
|
||||
UsedFor: "Bind the current directory to a knowledge base by writing .academy/project.yaml. Give the KB as a positional arg or --kb (non-interactive); only run when the user explicitly asks to link this directory.",
|
||||
RequiredFlags: []string{"<kb> positional or --kb (required when no TTY)"},
|
||||
Examples: []string{"weknora link engineering", "weknora link --kb a32a63ff-fb36-4874-bcaa-30f48570a694"},
|
||||
Examples: []string{"academy link engineering", "academy link --kb a32a63ff-fb36-4874-bcaa-30f48570a694"},
|
||||
Output: "envelope.data has profile, kb_id, kb_name, project_link_path",
|
||||
})
|
||||
return cmd
|
||||
@@ -153,8 +153,8 @@ func runLink(ctx context.Context, opts *Options, fopts *cmdutil.FormatOptions, f
|
||||
}
|
||||
|
||||
// resolveProfile picks the active profile to record in the link. There is no
|
||||
// per-invocation override flag on `weknora link` itself - to record under a
|
||||
// different profile, use the global persistent flag (`weknora --profile
|
||||
// per-invocation override flag on `academy link` itself - to record under a
|
||||
// different profile, use the global persistent flag (`academy --profile
|
||||
// staging link --kb my-kb`); the active profile at link time is what gets
|
||||
// written.
|
||||
func resolveProfile(f *cmdutil.Factory) (string, error) {
|
||||
@@ -164,14 +164,14 @@ func resolveProfile(f *cmdutil.Factory) (string, error) {
|
||||
}
|
||||
if cfg.CurrentProfile == "" {
|
||||
// `link` binds a directory to a profile+KB, so it needs a configured
|
||||
// profile — env credentials (WEKNORA_API_KEY) alone have no profile to
|
||||
// profile — env credentials (ACADEMY_API_KEY) alone have no profile to
|
||||
// record. Point at profile setup (not `auth login`, which loops with no
|
||||
// profile) and name the headless alternative so an env-cred agent isn't
|
||||
// stranded on a misleading hint.
|
||||
return "", cmdutil.NewError(cmdutil.CodeAuthUnauthenticated,
|
||||
"`link` records an active profile, but none is configured").
|
||||
WithHint("register one with `weknora profile add <name> --host <url> --use`; for a headless (WEKNORA_API_KEY) workflow, skip `link` and pass --kb per command or set WEKNORA_KB_ID").
|
||||
WithRetryArgv([]string{"weknora", "profile", "add", "--help"})
|
||||
WithHint("register one with `academy profile add <name> --host <url> --use`; for a headless (ACADEMY_API_KEY) workflow, skip `link` and pass --kb per command or set ACADEMY_KB_ID").
|
||||
WithRetryArgv([]string{"academy", "profile", "add", "--help"})
|
||||
}
|
||||
return cfg.CurrentProfile, nil
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/config"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/projectlink"
|
||||
sdk "github.com/Tencent/WeKnora/client"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/config"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/projectlink"
|
||||
sdk "academy/client"
|
||||
)
|
||||
|
||||
func chdir(t *testing.T, dir string) {
|
||||
@@ -67,7 +67,7 @@ func TestLink_ByID(t *testing.T) {
|
||||
opts := &Options{KB: "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"}
|
||||
require.NoError(t, runLink(context.Background(), opts, &cmdutil.FormatOptions{Mode: cmdutil.FormatText}, f))
|
||||
|
||||
linkPath := filepath.Join(dir, ".weknora", "project.yaml")
|
||||
linkPath := filepath.Join(dir, ".academy", "project.yaml")
|
||||
p, err := projectlink.Load(linkPath)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa", p.KBID)
|
||||
@@ -89,7 +89,7 @@ func TestLink_ByName(t *testing.T) {
|
||||
opts := &Options{KB: "foo"}
|
||||
require.NoError(t, runLink(context.Background(), opts, &cmdutil.FormatOptions{Mode: cmdutil.FormatText}, f))
|
||||
|
||||
p, err := projectlink.Load(filepath.Join(dir, ".weknora", "project.yaml"))
|
||||
p, err := projectlink.Load(filepath.Join(dir, ".academy", "project.yaml"))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "kb_a", p.KBID)
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func TestLink_OverwritesExisting(t *testing.T) {
|
||||
_, _ = iostreams.SetForTest(t)
|
||||
|
||||
// Pre-existing link.
|
||||
linkPath := filepath.Join(dir, ".weknora", "project.yaml")
|
||||
linkPath := filepath.Join(dir, ".academy", "project.yaml")
|
||||
require.NoError(t, projectlink.Save(linkPath, &projectlink.Project{
|
||||
Profile: "default", KBID: "11111111-1111-4111-8111-111111111111",
|
||||
}))
|
||||
|
||||
+11
-11
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/projectlink"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/projectlink"
|
||||
)
|
||||
|
||||
// unlinkFields enumerates the fields surfaced for `--format json` discovery on
|
||||
@@ -24,22 +24,22 @@ type unlinkResult struct {
|
||||
ProjectLinkPath string `json:"project_link_path"`
|
||||
}
|
||||
|
||||
// NewCmdUnlink builds `weknora unlink`. Walks up from cwd so a user in
|
||||
// NewCmdUnlink builds `academy unlink`. Walks up from cwd so a user in
|
||||
// a subdirectory of a linked project can unlink without cd-ing up first.
|
||||
func NewCmdUnlink() *cobra.Command {
|
||||
opts := &UnlinkOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "unlink",
|
||||
Short: "Remove the directory's knowledge-base binding",
|
||||
Long: `Removes the .weknora/project.yaml that ` + "`weknora link`" + ` previously
|
||||
Long: `Removes the .academy/project.yaml that ` + "`academy link`" + ` previously
|
||||
wrote, so subsequent commands no longer auto-resolve --kb from the link.
|
||||
|
||||
Walks up from the current directory until a link is found, mirroring the
|
||||
discovery that ` + "`--kb`" + ` resolution uses; you do not need to cd to the
|
||||
project root to unlink. Errors with input.invalid_argument when no link
|
||||
is present anywhere in the parent chain.`,
|
||||
Example: ` weknora unlink # remove the binding for this project
|
||||
weknora unlink --format json # bare JSON (CI / agents)`,
|
||||
Example: ` academy unlink # remove the binding for this project
|
||||
academy unlink --format json # bare JSON (CI / agents)`,
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(c *cobra.Command, _ []string) error {
|
||||
fopts, err := cmdutil.CheckFormatFlag(c)
|
||||
@@ -62,7 +62,7 @@ is present anywhere in the parent chain.`,
|
||||
return &cmdutil.Error{
|
||||
Code: cmdutil.CodeInputInvalidArgument,
|
||||
Message: fmt.Sprintf("no %s/%s found at or above %s", projectlink.DirName, projectlink.FileName, cwd),
|
||||
Hint: "run `weknora link --kb <id>` first, or check you're in the right directory",
|
||||
Hint: "run `academy link --kb <id>` first, or check you're in the right directory",
|
||||
}
|
||||
}
|
||||
if handled, err := cmdutil.HandleDryRun(c, opts.DryRun, cmdutil.DryRunPlan{
|
||||
@@ -77,10 +77,10 @@ is present anywhere in the parent chain.`,
|
||||
cmdutil.AddFormatFlag(cmd, unlinkFields...)
|
||||
cmdutil.AddDryRunFlag(cmd, &opts.DryRun)
|
||||
cmdutil.SetAgentHelp(cmd, cmdutil.AgentHelp{
|
||||
UsedFor: "Remove the .weknora/project.yaml KB binding from the current directory tree. No flags required; walks up from cwd to find the link.",
|
||||
UsedFor: "Remove the .academy/project.yaml KB binding from the current directory tree. No flags required; walks up from cwd to find the link.",
|
||||
Output: "envelope.data has project_link_path of the removed file",
|
||||
Examples: []string{
|
||||
"weknora unlink",
|
||||
"academy unlink",
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
@@ -99,7 +99,7 @@ func runUnlink(opts *UnlinkOptions, fopts *cmdutil.FormatOptions) error {
|
||||
return &cmdutil.Error{
|
||||
Code: cmdutil.CodeInputInvalidArgument,
|
||||
Message: fmt.Sprintf("no %s/%s found at or above %s", projectlink.DirName, projectlink.FileName, cwd),
|
||||
Hint: "run `weknora link --kb <id>` first, or check you're in the right directory",
|
||||
Hint: "run `academy link --kb <id>` first, or check you're in the right directory",
|
||||
}
|
||||
}
|
||||
if err := projectlink.Remove(linkPath); err != nil {
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
||||
"github.com/Tencent/WeKnora/cli/internal/iostreams"
|
||||
"github.com/Tencent/WeKnora/cli/internal/projectlink"
|
||||
"academy/cli/internal/cmdutil"
|
||||
"academy/cli/internal/iostreams"
|
||||
"academy/cli/internal/projectlink"
|
||||
)
|
||||
|
||||
// mkLinkFile seeds .weknora/project.yaml in dir so the unlink path has
|
||||
// mkLinkFile seeds .academy/project.yaml in dir so the unlink path has
|
||||
// something to remove. Returns the absolute file path.
|
||||
func mkLinkFile(t *testing.T, dir string) string {
|
||||
t.Helper()
|
||||
|
||||
Reference in new issue
Block a user