You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2026/09/17 05:04:16 UTC
(skywalking-ai-sessionizer) branch plugin-from-path created (now 5fc9065)
This is an automated email from the ASF dual-hosted git repository.
wu-sheng pushed a change to branch plugin-from-path
in repository https://gitbox.apache.org/repos/asf/skywalking-ai-sessionizer.git
at 5fc9065 Run the install pages with Claude Code on every package platform in CI
This branch includes the following new commits:
new 4145531 Install the Claude Code plugin from a marketplace, and its binary beside asz
new 5fc9065 Run the install pages with Claude Code on every package platform in CI
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(skywalking-ai-sessionizer) 02/02: Run the install pages with Claude Code on every package platform in CI
Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wu-sheng pushed a commit to branch plugin-from-path
in repository https://gitbox.apache.org/repos/asf/skywalking-ai-sessionizer.git
commit 5fc9065129b322fc65d07beb052e203a992ff5fd
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Thu Sep 17 13:04:07 2026 +0800
Run the install pages with Claude Code on every package platform in CI
Claude Code had run the plugin's hooks on macOS only, and never on Linux
or Windows. On Windows it is unknown whether a hook naming
asz-claude-plugin finds asz-claude-plugin.exe.
tools/claudecodecheck follows the install pages on the machine it runs
on. It reads each block from the page and points only its download
addresses at a server on 127.0.0.1, which holds the package, a git
repository with the marketplace at two tags, and a stand-in for the
model's API. It runs the Quick install block in every shell there is for
it, the plugin's install commands, a headless session the plugin must
record and asz must collect, a session without asz-claude-plugin on PATH,
and the Upgrade block, after which the plugin's data must remain and the
next session must be recorded.
The new claude-code job runs it with Claude Code 2.1.274 on the six
runners the packages job uses. The version is fixed, so a Claude Code
release cannot fail a pull request that did not change. The prerelease
and the required check wait for the job.
On 2026-09-17 the check passed on macOS on Apple silicon, and on Linux on
ARM 64 in Debian 13.6 and in Alpine 3.22.5, with Claude Code's musl build.
---
.github/workflows/ci.yaml | 76 +++-
docs/en/changes/changes.md | 6 +
docs/en/guides/how-to-release.md | 4 +-
docs/en/setup/claude-code-plugin.md | 11 +
tools/claudecodecheck/main.go | 848 ++++++++++++++++++++++++++++++++++++
5 files changed, 942 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 5bfab0a..3506e9d 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -315,6 +315,78 @@ jobs:
esac
tools/package-smoke.sh "dist/apache-skywalking-ai-sessionizer-$VERSION-bin-$PLATFORM.$EXT" "$VERSION"
+ # Each binary package with Claude Code, on its own platform, the way the
+ # install pages tell a person to use it. The Quick install block installs
+ # the package, the plugin's install commands add the marketplace at a tag,
+ # and a headless session must be recorded by the plugin and collected by
+ # asz. tools/claudecodecheck says what else it runs. The package, the
+ # marketplace repository and the model's API are served on the runner, so
+ # the job needs no secret. Claude Code has run the hooks on no platform but
+ # the ones this job covers.
+ claude-code:
+ name: Claude Code ${{ matrix.platform }}
+ if: github.event_name != 'release'
+ needs: binaries
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 30
+ env:
+ # A fixed version, so a new Claude Code release cannot fail a pull
+ # request that did not change. Move it on purpose.
+ CLAUDE_CODE_VERSION: '2.1.274'
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - { platform: linux-amd64, runner: ubuntu-latest, ext: tgz }
+ - { platform: linux-arm64, runner: ubuntu-24.04-arm, ext: tgz }
+ - { platform: darwin-arm64, runner: macos-latest, ext: tgz }
+ - { platform: darwin-amd64, runner: macos-15-intel, ext: tgz }
+ - { platform: windows-amd64, runner: windows-latest, ext: zip }
+ - { platform: windows-arm64, runner: windows-11-arm, ext: zip }
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.sha }}
+ - uses: actions/setup-go@v5
+ with:
+ go-version: '1.27'
+ cache: true
+ - uses: actions/download-artifact@v4
+ with:
+ name: binaries-${{ needs.binaries.outputs.version }}
+ path: dist
+ - name: Install Claude Code
+ if: runner.os != 'Windows'
+ run: |
+ curl -fsSL https://claude.ai/install.sh | bash -s "$CLAUDE_CODE_VERSION"
+ echo "$HOME/.local/bin" >> "$GITHUB_PATH"
+ - name: Install Claude Code
+ if: runner.os == 'Windows'
+ shell: pwsh
+ run: |
+ & ([scriptblock]::Create((Invoke-RestMethod https://claude.ai/install.ps1))) $env:CLAUDE_CODE_VERSION
+ Join-Path $env:USERPROFILE ".local\bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
+ # Run by hand for a tag older than this job, the tag has no check.
+ - name: Follow the install pages with Claude Code
+ shell: bash
+ env:
+ VERSION: ${{ needs.binaries.outputs.version }}
+ PLATFORM: ${{ matrix.platform }}
+ EXT: ${{ matrix.ext }}
+ run: |
+ if [ ! -d tools/claudecodecheck ]; then
+ echo "::notice::this tag has no tools/claudecodecheck, so Claude Code is not run"
+ exit 0
+ fi
+ platforms=$(sed -nE 's/^PLATFORMS[[:space:]]*:?=[[:space:]]*//p' Makefile)
+ case " $platforms " in
+ *" ${PLATFORM%-*}/${PLATFORM#*-} "*) ;;
+ *)
+ echo "::notice::the Makefile of this tag builds no package for $PLATFORM, so there is nothing to run"
+ exit 0 ;;
+ esac
+ go run ./tools/claudecodecheck "dist/apache-skywalking-ai-sessionizer-$VERSION-bin-$PLATFORM.$EXT" "$VERSION"
+
lint:
name: Lint
if: github.event_name != 'release'
@@ -332,7 +404,7 @@ jobs:
candidate-assets:
name: Prerelease binaries
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- needs: [license, build, source-package, lint, binaries, packages, collector, conversation-view]
+ needs: [license, build, source-package, lint, binaries, packages, claude-code, collector, conversation-view]
runs-on: ubuntu-latest
permissions:
contents: write
@@ -449,7 +521,7 @@ jobs:
result:
name: Required
if: always()
- needs: [license, build, source-package, lint, docker, binaries, packages, collector, conversation-view, candidate-assets]
+ needs: [license, build, source-package, lint, docker, binaries, packages, claude-code, collector, conversation-view, candidate-assets]
runs-on: ubuntu-latest
steps:
- name: Fail if any job failed
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 24dd9fd..8355681 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -94,6 +94,12 @@
package smoke test finds the plugin's binary by name on `PATH`. The candidate check in
`tools/release.sh`, the Homebrew formula, and the Scoop and winget manifests follow the new
layout, and put both binaries on the path.
+- **CI runs the install pages with Claude Code.** A new `claude-code` job runs
+ `tools/claudecodecheck` with Claude Code 2.1.274 on each binary package's platform, Linux, macOS
+ and Windows on x86-64 and ARM 64. It follows the Quick install block, the plugin's install
+ commands and the Upgrade block as written, with only their download addresses pointed at the
+ runner, and a headless session must be recorded by the plugin and collected by asz. Before, no
+ platform ran the plugin's hooks inside Claude Code in CI, and Windows never had.
- **Quick install.** [Install](../setup/install.md#quick-install) gives one block for macOS and Linux
and one for Windows. Each takes the version the reader sets, downloads the package through the
mirror selector and its `.sha512` from downloads.apache.org, stops unless they match, checks that
diff --git a/docs/en/guides/how-to-release.md b/docs/en/guides/how-to-release.md
index a73d6db..d66b0fe 100644
--- a/docs/en/guides/how-to-release.md
+++ b/docs/en/guides/how-to-release.md
@@ -393,7 +393,9 @@ The tag's `PLATFORMS` names macOS, Linux and Windows, each on x86-64 and ARM 64.
without cgo on Linux with its configured Go toolchain and packages with GNU tar, gzip and zip.
It uses `GOWORK=off` and `GOFLAGS=-mod=readonly`. Both binaries report `$VERSION` and the Go
version used to build them. The run must pass the whole CI workflow, including package smoke
-tests on all six platforms, before its archives are eligible for the candidate.
+tests on all six platforms, and on the same six the Claude Code check, which installs each package
+and the plugin as the install pages say and runs a session the plugin must record. Only then are
+its archives eligible for the candidate.
`make binaries` remains useful for local build checks. Those archives are not the release
candidate. GNU and macOS archive tools can produce different bytes even from the same files, so
diff --git a/docs/en/setup/claude-code-plugin.md b/docs/en/setup/claude-code-plugin.md
index 3023c84..6f8a9e8 100644
--- a/docs/en/setup/claude-code-plugin.md
+++ b/docs/en/setup/claude-code-plugin.md
@@ -481,6 +481,17 @@ plugin and deleted its data directory, with its `settings.yaml` and an output fi
Uninstalling with `--keep-data` first, then removing the marketplace, adding it at the second tag
and installing, kept both files, and the cache then held the changed hooks.
+`tools/claudecodecheck` repeats all of this on the machine it runs on, the way a person follows the
+install pages. It reads each block from the page and changes only the download addresses, to a
+server on the same machine that holds the package, the marketplace repository at two tags, and a
+stand-in for the model's API. It runs the Quick install block in every shell there is for it, the
+plugin's install commands, a session the plugin must record and asz must collect, a session with no
+`asz-claude-plugin` on `PATH`, and the Upgrade block, after which the data must still be there and
+the next session must be recorded. CI's `claude-code` job runs it with Claude Code 2.1.274 on each
+binary package's own platform: Linux, macOS and Windows, each on x86-64 and ARM 64. On 2026-09-17 it
+passed on macOS on Apple silicon, and on Linux on ARM 64 in a Debian 13.6 container and in an Alpine
+3.22.5 container, which runs Claude Code's build for musl.
+
On Windows the plugin has run only outside Claude Code. CI's `packages` job runs
`tools/package-smoke.sh` on each binary package, on a runner of the package's own platform. On
2026-09-11, the CI of pull request #6 ran it on `windows-latest`, x86-64, and on `windows-11-arm`,
diff --git a/tools/claudecodecheck/main.go b/tools/claudecodecheck/main.go
new file mode 100644
index 0000000..b5fd26a
--- /dev/null
+++ b/tools/claudecodecheck/main.go
@@ -0,0 +1,848 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Command claudecodecheck follows the install pages on this machine, with
+// the Claude Code that is on PATH, and fails where a person following them
+// would:
+//
+// 1. The Quick install block of docs/en/setup/install.md installs asz and
+// asz-claude-plugin from PACKAGE. On Windows that is the PowerShell block,
+// in every PowerShell there is; elsewhere the shell block, in every
+// shell there is.
+// 2. The commands under Install in docs/en/setup/claude-code-plugin.md add
+// the marketplace at the version's tag and install the plugin.
+// 3. A headless Claude Code session runs one shell command. The plugin must
+// record the file it wrote, and asz collect must land the record.
+// 4. The same session without asz-claude-plugin on PATH must still run the
+// command, and leave no record.
+// 5. The Upgrade block moves the plugin to a second tag. The plugin's data
+// must stay, and the next session must be recorded again.
+//
+// Each block is read from the page, and only its download addresses are
+// changed, to a server on 127.0.0.1 that holds PACKAGE, a git repository with
+// the marketplace at two tags, and a stand-in for the model's API. The
+// Windows block adds a directory to the user's Path, so on Windows this runs
+// only in GitHub Actions. CI runs it on each binary package's own platform.
+//
+// go run ./tools/claudecodecheck PACKAGE VERSION
+package main
+
+import (
+ "bufio"
+ "bytes"
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net"
+ "net/http"
+ "net/http/cgi"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "regexp"
+ "runtime"
+ "strings"
+ "sync"
+ "time"
+)
+
+const (
+ marketplace = "skywalking-ai-sessionizer"
+ plugin = "asz-changes"
+ // The file the stand-in model asks the shell command to write.
+ written = "claudecodecheck.txt"
+ // A settings value the plugin reads, equal to its default, so the file
+ // changes nothing and its survival across the upgrade can be checked.
+ settings = "scan_timeout: 30s\n"
+)
+
+var windows = runtime.GOOS == "windows"
+
+func main() {
+ if len(os.Args) != 3 {
+ fmt.Fprintln(os.Stderr, "usage: go run ./tools/claudecodecheck PACKAGE VERSION")
+ os.Exit(2)
+ }
+ c := &check{pkg: os.Args[1], version: os.Args[2]}
+ if err := c.run(); err != nil {
+ fmt.Fprintf(os.Stderr, "\nclaudecodecheck: %v\n", err)
+ if c.work != "" {
+ fmt.Fprintf(os.Stderr, "claudecodecheck: the files of this run are kept in %s\n", c.work)
+ }
+ os.Exit(1)
+ }
+ os.RemoveAll(c.work)
+ fmt.Printf("\n%s works with Claude Code on this machine\n", filepath.Base(c.pkg))
+}
+
+type check struct {
+ pkg, version string
+ tree string // the repository, the working directory
+ work string
+ base string // the address of the local server
+ claude string
+ bin string // where the install block put the two binaries
+ config string // Claude Code's configuration directory for this run
+ api *stand
+}
+
+func step(format string, args ...any) { fmt.Printf("\n== "+format+"\n", args...) }
+
+func (c *check) run() error {
+ var err error
+ if c.tree, err = os.Getwd(); err != nil {
+ return err
+ }
+ if _, err := os.Stat(filepath.Join(c.tree, "docs", "en", "setup", "install.md")); err != nil {
+ return errors.New("run it from the root of the repository")
+ }
+ if windows && os.Getenv("GITHUB_ACTIONS") != "true" {
+ return errors.New("the Windows install block adds a directory to the user's Path, so on Windows this runs only in GitHub Actions")
+ }
+ if c.claude, err = exec.LookPath("claude"); err != nil {
+ return errors.New("claude is not on PATH. Install Claude Code first")
+ }
+ if _, err := os.Stat(c.pkg + ".sha512"); err != nil {
+ return fmt.Errorf("%s.sha512 must be beside the package: %w", c.pkg, err)
+ }
+ if c.work, err = os.MkdirTemp("", "claudecodecheck-"); err != nil {
+ return err
+ }
+ c.config = filepath.Join(c.work, "config")
+ out, err := exec.Command(c.claude, "--version").CombinedOutput()
+ if err != nil {
+ return fmt.Errorf("claude --version: %w: %s", err, out)
+ }
+ fmt.Printf("claude: %s (%s)\n", strings.TrimSpace(string(out)), c.claude)
+
+ if err := c.serve(); err != nil {
+ return err
+ }
+ for _, s := range []func() error{c.install, c.installPlugin, c.recorded, c.collect, c.missing, c.upgrade} {
+ if err := s(); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// serve starts the local server: the package under the path the download
+// site uses, the marketplace repository over git's HTTP protocol, and the
+// stand-in model. Claude Code refuses a file:// marketplace, and git cannot
+// clone shallowly over plain file serving, so the repository needs
+// git http-backend.
+func (c *check) serve() error {
+ step("The local server")
+ git, err := exec.LookPath("git")
+ if err != nil {
+ return errors.New("git is not on PATH")
+ }
+ repos := filepath.Join(c.work, "git")
+ if err := c.repository(git, filepath.Join(repos, "asz.git")); err != nil {
+ return err
+ }
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ return err
+ }
+ c.base = "http://" + ln.Addr().String()
+ c.api = &stand{}
+ mux := http.NewServeMux()
+ site := "/skywalking/ai-sessionizer/" + c.version + "/"
+ mux.Handle(site, http.StripPrefix(site, http.FileServer(http.Dir(filepath.Dir(c.pkg)))))
+ mux.Handle("/git/", &cgi.Handler{
+ Path: git,
+ Root: "/git",
+ Args: []string{"http-backend"},
+ Env: []string{"GIT_PROJECT_ROOT=" + repos, "GIT_HTTP_EXPORT_ALL=1"},
+ InheritEnv: []string{"PATH", "SYSTEMROOT", "TEMP", "TMP", "HOME", "USERPROFILE"},
+ })
+ mux.Handle("/v1/", c.api)
+ // The server lives as long as the check, which ends the process.
+ go func() { _ = http.Serve(ln, mux) }()
+ fmt.Printf("serving %s, the marketplace at v%s and v%s, and the model on %s\n", filepath.Base(c.pkg), c.version, c.next(), c.base)
+ return nil
+}
+
+func (c *check) next() string { return c.version + "-next" }
+
+// repository commits the marketplace and the plugin at the version's tag,
+// then a changed plugin at a second tag for the upgrade. It also commits a
+// file outside the plugin's directory, which the plugin cache must not get.
+func (c *check) repository(git, bare string) error {
+ src := filepath.Join(c.work, "repository")
+ for _, rel := range []string{".claude-plugin", filepath.Join("plugins", "claude-code", "plugin"), filepath.Join("plugins", "claude-code", "main.go")} {
+ if err := copyPath(filepath.Join(c.tree, rel), filepath.Join(src, rel)); err != nil {
+ return err
+ }
+ }
+ gitIn := func(dir string, args ...string) error {
+ cmd := exec.Command(git, append([]string{"-c", "user.name=claudecodecheck", "-c", "user.email=claudecodecheck@invalid", "-c", "init.defaultBranch=main"}, args...)...)
+ cmd.Dir = dir
+ if out, err := cmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("git %s: %w: %s", strings.Join(args, " "), err, out)
+ }
+ return nil
+ }
+ manifest := filepath.Join(src, "plugins", "claude-code", "plugin", ".claude-plugin", "plugin.json")
+ for _, s := range []func() error{
+ func() error { return gitIn(src, "init", "-q") },
+ func() error { return gitIn(src, "add", "-A") },
+ func() error { return gitIn(src, "commit", "-q", "-m", "the version") },
+ func() error { return gitIn(src, "tag", "v"+c.version) },
+ func() error { return appendTo(manifest, "\n") },
+ func() error { return gitIn(src, "commit", "-q", "-am", "the next version") },
+ func() error { return gitIn(src, "tag", "v"+c.next()) },
+ func() error { return gitIn(c.work, "clone", "-q", "--bare", src, bare) },
+ } {
+ if err := s(); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// install runs the Quick install block in every shell this machine has for
+// it, each into a home of its own, and keeps the last one's binaries.
+func (c *check) install() error {
+ lang, shells := "sh", []string{"sh", "bash", "zsh"}
+ if windows {
+ lang, shells = "powershell", []string{"powershell", "pwsh"}
+ }
+ block, err := c.block(filepath.Join("docs", "en", "setup", "install.md"), "## Quick install", lang, "VERSION")
+ if err != nil {
+ return err
+ }
+ block, err = c.rewriteDownloads(block)
+ if err != nil {
+ return err
+ }
+ ran := 0
+ for _, shell := range shells {
+ path, err := exec.LookPath(shell)
+ if err != nil {
+ continue
+ }
+ step("Quick install in %s", shell)
+ home := filepath.Join(c.work, "home-"+shell)
+ if err := os.MkdirAll(home, 0o755); err != nil {
+ return err
+ }
+ bin := filepath.Join(home, ".local", "bin")
+ env := withEnv(os.Environ(), "HOME="+home, "USERPROFILE="+home, "PATH="+bin+string(os.PathListSeparator)+os.Getenv("PATH"),
+ "NO_PROXY=127.0.0.1", "no_proxy=127.0.0.1")
+ out, err := c.script(path, block, env, c.work)
+ fmt.Print(out)
+ if err != nil {
+ return fmt.Errorf("the Quick install block failed in %s: %w", shell, err)
+ }
+ for _, name := range []string{"asz", "asz-claude-plugin"} {
+ got, err := exec.Command(filepath.Join(bin, name+exe()), "version").CombinedOutput()
+ if err != nil || !strings.Contains(string(got), c.version) {
+ return fmt.Errorf("%s from the Quick install block in %s does not report %s: %w %s", name, shell, c.version, err, got)
+ }
+ }
+ c.bin = bin
+ ran++
+ }
+ if ran == 0 {
+ return fmt.Errorf("no shell here runs the %s block", lang)
+ }
+ return nil
+}
+
+// installPlugin runs the commands under Install that add the marketplace
+// and install the plugin, then checks what Claude Code copied.
+func (c *check) installPlugin() error {
+ step("Install the plugin")
+ if err := c.pluginBlock("## Install", "claude plugin marketplace add", c.version); err != nil {
+ return err
+ }
+ list, err := c.claudeRun(nil, "plugin", "list")
+ if err != nil {
+ return err
+ }
+ if !strings.Contains(list, plugin+"@"+marketplace) {
+ return fmt.Errorf("claude plugin list does not show %s@%s:\n%s", plugin, marketplace, list)
+ }
+ dirs, _ := filepath.Glob(filepath.Join(c.config, "plugins", "cache", marketplace, plugin, "*"))
+ if len(dirs) != 1 {
+ return fmt.Errorf("the plugin cache holds %d versions of %s, want 1: %v", len(dirs), plugin, dirs)
+ }
+ for _, rel := range []string{".claude-plugin/plugin.json", "hooks/hooks.json", "LICENSE", "NOTICE"} {
+ if _, err := os.Stat(filepath.Join(dirs[0], filepath.FromSlash(rel))); err != nil {
+ return fmt.Errorf("the plugin cache lacks %s: %w", rel, err)
+ }
+ }
+ if matches, _ := filepath.Glob(filepath.Join(dirs[0], "*.go")); len(matches) > 0 {
+ return fmt.Errorf("the plugin cache holds Go source: %v", matches)
+ }
+ fmt.Printf("installed; the cache holds the manifest, the hooks, LICENSE and NOTICE in %s\n", filepath.Base(dirs[0]))
+ return nil
+}
+
+func (c *check) pluginBlock(heading, contains, version string) error {
+ lang, shell := "sh", "sh"
+ if windows {
+ lang, shell = "powershell", "pwsh"
+ if _, err := exec.LookPath(shell); err != nil {
+ shell = "powershell"
+ }
+ }
+ block, err := c.block(filepath.Join("docs", "en", "setup", "claude-code-plugin.md"), heading, lang, contains)
+ if err != nil {
+ return err
+ }
+ const github = "https://github.com/apache/skywalking-ai-sessionizer.git"
+ if !strings.Contains(block, github) {
+ return fmt.Errorf("the %s block under %s no longer names %s", lang, heading, github)
+ }
+ block = strings.ReplaceAll(block, github, c.base+"/git/asz.git")
+ path, err := exec.LookPath(shell)
+ if err != nil {
+ return err
+ }
+ env := c.claudeEnv(nil)
+ env = withEnv(env, "VERSION="+version)
+ out, err := c.script(path, block, env, c.work, version)
+ fmt.Print(out)
+ if err != nil {
+ return fmt.Errorf("the %s block under %s failed: %w", lang, heading, err)
+ }
+ return nil
+}
+
+// recorded runs a session with asz-claude-plugin on PATH. The plugin must
+// record the file the shell command wrote.
+func (c *check) recorded() error {
+ step("A session with asz-claude-plugin on PATH")
+ id, err := c.session("with", []string{c.bin})
+ if err != nil {
+ return err
+ }
+ return c.hasRecord(id)
+}
+
+func (c *check) hasRecord(id string) error {
+ file := filepath.Join(c.data(), "output", id, "main.jsonl")
+ f, err := os.Open(file)
+ if err != nil {
+ c.showPluginLog()
+ return fmt.Errorf("the plugin wrote no record for session %s: %w", id, err)
+ }
+ defer f.Close()
+ sc := bufio.NewScanner(f)
+ sc.Buffer(nil, 16<<20)
+ for sc.Scan() {
+ var rec struct {
+ Changes []struct {
+ Path string `json:"path"`
+ Operation string `json:"operation"`
+ } `json:"changes"`
+ }
+ if json.Unmarshal(sc.Bytes(), &rec) != nil {
+ continue
+ }
+ for _, ch := range rec.Changes {
+ if ch.Path == written && ch.Operation == "create" {
+ fmt.Printf("the plugin recorded %s as created, in %s\n", written, file)
+ return nil
+ }
+ }
+ }
+ c.showPluginLog()
+ return fmt.Errorf("no record in %s names %s as created", file, written)
+}
+
+// collect lands the plugin's records with the installed asz.
+func (c *check) collect() error {
+ step("asz collect")
+ cfg, err := os.ReadFile(filepath.Join(c.tree, "asz.yaml"))
+ if err != nil {
+ return err
+ }
+ root := filepath.Join(c.work, "root")
+ text := string(cfg)
+ if !strings.Contains(text, " root: ./data\n") {
+ return errors.New("asz.yaml no longer sets root: ./data, which this check replaces")
+ }
+ text = strings.Replace(text, " root: ./data\n", " root: '"+filepath.ToSlash(root)+"'\n", 1)
+ // The default leaves out sessions under /private/tmp, where a macOS
+ // temporary directory can resolve.
+ text = strings.ReplaceAll(text, " exclude:\n - /private/tmp/**\n", " exclude: []\n")
+ file := filepath.Join(c.work, "asz.yaml")
+ if err := os.WriteFile(file, []byte(text), 0o644); err != nil {
+ return err
+ }
+ cmd := exec.Command(filepath.Join(c.bin, "asz"+exe()), "collect", "-once", "-config", file)
+ cmd.Env = c.claudeEnv(nil)
+ out, err := cmd.CombinedOutput()
+ fmt.Print(string(out))
+ if err != nil {
+ return fmt.Errorf("asz collect: %w", err)
+ }
+ landed, _ := filepath.Glob(filepath.Join(root, "*", "streams", "main", "changes-*.sd"))
+ if len(landed) == 0 {
+ return fmt.Errorf("asz collect landed no changes file under %s", root)
+ }
+ fmt.Printf("asz landed %s\n", filepath.Base(landed[0]))
+ return nil
+}
+
+// missing runs a session without asz-claude-plugin on PATH. The shell
+// command must still run, and no record may be written.
+func (c *check) missing() error {
+ step("A session without asz-claude-plugin on PATH")
+ id, err := c.session("without", nil)
+ if err != nil {
+ return err
+ }
+ if _, err := os.Stat(filepath.Join(c.data(), "output", id)); err == nil {
+ return fmt.Errorf("the plugin wrote output for session %s with no asz-claude-plugin on PATH", id)
+ }
+ log, _ := os.ReadFile(filepath.Join(c.work, "session-without.log"))
+ if bytes.Contains(log, []byte("Executable not found")) {
+ fmt.Println("Claude Code reported the missing executable, the command ran, and nothing was recorded")
+ } else {
+ fmt.Println("the command ran and nothing was recorded; Claude Code's output does not say \"Executable not found\"")
+ }
+ return nil
+}
+
+// upgrade runs the Upgrade block to the second tag. The settings and the
+// output must stay, and the next session must be recorded.
+func (c *check) upgrade() error {
+ step("Upgrade to v%s", c.next())
+ before, err := c.claudeRun(nil, "plugin", "list")
+ if err != nil {
+ return err
+ }
+ if err := os.WriteFile(filepath.Join(c.data(), "settings.yaml"), []byte(settings), 0o644); err != nil {
+ return err
+ }
+ outputs, _ := filepath.Glob(filepath.Join(c.data(), "output", "*", "main.jsonl"))
+ if len(outputs) == 0 {
+ return errors.New("there is no output to keep across the upgrade")
+ }
+ if err := c.pluginBlock("### Upgrade", "--keep-data", c.next()); err != nil {
+ return err
+ }
+ got, err := os.ReadFile(filepath.Join(c.data(), "settings.yaml"))
+ if err != nil {
+ return fmt.Errorf("the upgrade lost the plugin's settings.yaml: %w", err)
+ }
+ if string(got) != settings {
+ return fmt.Errorf("the upgrade changed the plugin's settings.yaml to %q", got)
+ }
+ for _, f := range outputs {
+ if _, err := os.Stat(f); err != nil {
+ return fmt.Errorf("the upgrade lost %s: %w", f, err)
+ }
+ }
+ after, err := c.claudeRun(nil, "plugin", "list")
+ if err != nil {
+ return err
+ }
+ if !strings.Contains(after, plugin+"@"+marketplace) || versionLine(after) == versionLine(before) {
+ return fmt.Errorf("the plugin did not move to v%s:\nbefore:\n%s\nafter:\n%s", c.next(), before, after)
+ }
+ fmt.Printf("moved from %s to %s, and kept settings.yaml and %d output files\n", versionLine(before), versionLine(after), len(outputs))
+ step("A session after the upgrade")
+ id, err := c.session("upgraded", []string{c.bin})
+ if err != nil {
+ return err
+ }
+ return c.hasRecord(id)
+}
+
+var versionRe = regexp.MustCompile(`Version:\s*(\S+)`)
+
+func versionLine(list string) string {
+ if m := versionRe.FindStringSubmatch(list); m != nil {
+ return m[1]
+ }
+ return ""
+}
+
+func (c *check) data() string {
+ return filepath.Join(c.config, "plugins", "data", plugin+"-"+marketplace)
+}
+
+func (c *check) showPluginLog() {
+ if b, err := os.ReadFile(filepath.Join(c.data(), "log", "plugin.log")); err == nil && len(b) > 0 {
+ fmt.Printf("-- the plugin's log\n%s\n", b)
+ }
+}
+
+var sessionRe = regexp.MustCompile(`"session_id":"([0-9a-f-]{36})"`)
+
+// session runs Claude Code headless in a new workspace, with the given
+// directories in front of PATH. The stand-in model has it run one shell
+// command that writes a file, and the file must be there afterwards.
+func (c *check) session(name string, path []string) (string, error) {
+ ws := filepath.Join(c.work, "workspace-"+name)
+ if err := os.MkdirAll(ws, 0o755); err != nil {
+ return "", err
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, c.claude, "-p", "Write the file.", "--allowedTools", "Bash,PowerShell",
+ "--output-format", "stream-json", "--verbose", "--model", "claude-opus-5")
+ cmd.Dir = ws
+ cmd.Env = c.claudeEnv(path)
+ asked := c.api.requests()
+ out, err := cmd.CombinedOutput()
+ logFile := filepath.Join(c.work, "session-"+name+".log")
+ _ = os.WriteFile(logFile, out, 0o644)
+ if err != nil {
+ return "", fmt.Errorf("claude -p: %w\n%s", err, tail(out, 40))
+ }
+ if _, err := os.Stat(filepath.Join(ws, written)); err != nil {
+ return "", fmt.Errorf("the session's shell command did not write %s\n%s", written, tail(out, 40))
+ }
+ m := sessionRe.FindSubmatch(out)
+ if m == nil {
+ return "", fmt.Errorf("claude -p printed no session id\n%s", tail(out, 40))
+ }
+ fmt.Printf("session %s wrote %s in %d requests to the model\n", m[1], written, c.api.requests()-asked)
+ return string(m[1]), nil
+}
+
+// claudeRun runs one claude command in this run's configuration.
+func (c *check) claudeRun(path []string, args ...string) (string, error) {
+ cmd := exec.Command(c.claude, args...)
+ cmd.Env = c.claudeEnv(path)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ return "", fmt.Errorf("claude %s: %w\n%s", strings.Join(args, " "), err, out)
+ }
+ return string(out), nil
+}
+
+// claudeEnv is this process's environment without what would point Claude
+// Code elsewhere. Run from inside Claude Code, the inherited CLAUDECODE and
+// CLAUDE_CODE_* variables made a child claude -p ask for a login.
+func (c *check) claudeEnv(path []string) []string {
+ var env []string
+ for _, kv := range os.Environ() {
+ i := strings.Index(kv, "=")
+ key := strings.ToUpper(kv[:max(i, 0)])
+ if i > 0 && (strings.HasPrefix(key, "CLAUDE") || strings.HasPrefix(key, "ANTHROPIC_") || key == "PATH") {
+ continue
+ }
+ env = append(env, kv)
+ }
+ dirs := append(append([]string{}, path...), filepath.Dir(c.claude), os.Getenv("PATH"))
+ return append(env,
+ "PATH="+strings.Join(dirs, string(os.PathListSeparator)),
+ "CLAUDE_CONFIG_DIR="+c.config,
+ "ANTHROPIC_BASE_URL="+c.base,
+ "ANTHROPIC_API_KEY=sk-ant-claudecodecheck",
+ "DISABLE_AUTOUPDATER=1",
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1",
+ "NO_PROXY=127.0.0.1", "no_proxy=127.0.0.1")
+}
+
+// script runs a block from a page the way a person pastes it, with the
+// version set first. A PowerShell block runs from a file, whose exit code
+// is the last command's.
+func (c *check) script(shell, block string, env []string, dir string, version ...string) (string, error) {
+ v := c.version
+ if len(version) > 0 {
+ v = version[0]
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
+ defer cancel()
+ var cmd *exec.Cmd
+ if windows {
+ file := filepath.Join(c.work, fmt.Sprintf("block-%d.ps1", time.Now().UnixNano()))
+ text := "$Version = '" + v + "'\n" + block + "\nexit $LASTEXITCODE\n"
+ if err := os.WriteFile(file, []byte(text), 0o644); err != nil {
+ return "", err
+ }
+ cmd = exec.CommandContext(ctx, shell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file)
+ } else {
+ cmd = exec.CommandContext(ctx, shell, "-c", "VERSION='"+v+"'\n"+block)
+ }
+ cmd.Env = env
+ cmd.Dir = dir
+ out, err := cmd.CombinedOutput()
+ return string(out), err
+}
+
+// block reads the one fenced block of lang under heading whose text holds
+// contains. The section ends at the next heading of any level, so a
+// subsection's blocks are not its parent's. A block indented under a list
+// item loses that indentation.
+func (c *check) block(page, heading, lang, contains string) (string, error) {
+ b, err := os.ReadFile(filepath.Join(c.tree, page))
+ if err != nil {
+ return "", err
+ }
+ found := blocks(section(string(b), heading), lang, contains)
+ if len(found) != 1 {
+ return "", fmt.Errorf("%s has %d %s blocks under %q holding %q, want 1", page, len(found), lang, heading, contains)
+ }
+ return found[0], nil
+}
+
+func section(text, heading string) string {
+ var out []string
+ in, fence := false, false
+ for _, l := range strings.Split(text, "\n") {
+ if strings.HasPrefix(strings.TrimLeft(l, " "), "```") {
+ fence = !fence
+ }
+ if !fence && strings.HasPrefix(l, "#") {
+ if in {
+ break
+ }
+ if l == heading {
+ in = true
+ continue
+ }
+ }
+ if in {
+ out = append(out, l)
+ }
+ }
+ return strings.Join(out, "\n")
+}
+
+func blocks(text, lang, contains string) []string {
+ var found []string
+ lines := strings.Split(text, "\n")
+ for i := 0; i < len(lines); i++ {
+ indent := lines[i][:len(lines[i])-len(strings.TrimLeft(lines[i], " "))]
+ if strings.TrimSpace(lines[i]) != "```"+lang {
+ continue
+ }
+ var body []string
+ for i++; i < len(lines) && strings.TrimSpace(lines[i]) != "```"; i++ {
+ body = append(body, strings.TrimPrefix(lines[i], indent))
+ }
+ b := strings.Join(body, "\n") + "\n"
+ if strings.Contains(b, contains) {
+ found = append(found, b)
+ }
+ }
+ return found
+}
+
+var closer = regexp.MustCompile(`https://www\.apache\.org/dyn/closer\.lua\?path=([^"&]+)&action=download`)
+
+// rewriteDownloads points a Quick install block at the local server: the
+// mirror selector and the download site each become its address, and
+// nothing else in the block may leave the machine.
+func (c *check) rewriteDownloads(block string) (string, error) {
+ if len(closer.FindAllString(block, -1)) != 1 || strings.Count(block, "https://downloads.apache.org/") != 1 {
+ return "", errors.New("the Quick install block no longer downloads once through closer.lua and once from downloads.apache.org, which this check replaces")
+ }
+ block = closer.ReplaceAllString(block, c.base+"/${1}")
+ block = strings.ReplaceAll(block, "https://downloads.apache.org/", c.base+"/")
+ if strings.Contains(block, "https://") {
+ return "", errors.New("the Quick install block downloads from an address this check does not replace")
+ }
+ return block, nil
+}
+
+// stand answers as the Messages API does, enough for one tool call: while
+// no message holds a tool result, it asks for the shell tool the request
+// offers, and then it ends the turn. Checking only the last message for a
+// tool result looped, because Claude Code sends more after it.
+type stand struct {
+ mu sync.Mutex
+ n int
+}
+
+func (s *stand) requests() int {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return s.n
+}
+
+func (s *stand) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if strings.HasSuffix(r.URL.Path, "/count_tokens") {
+ writeJSON(w, map[string]any{"input_tokens": 10})
+ return
+ }
+ if r.Method != http.MethodPost || !strings.HasSuffix(r.URL.Path, "/messages") {
+ http.NotFound(w, r)
+ return
+ }
+ var req struct {
+ Model string `json:"model"`
+ Stream bool `json:"stream"`
+ Tools []struct{ Name string } `json:"tools"`
+ Messages []struct {
+ Content json.RawMessage `json:"content"`
+ } `json:"messages"`
+ }
+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+ s.mu.Lock()
+ s.n++
+ id := s.n
+ s.mu.Unlock()
+
+ tool := ""
+ for _, t := range req.Tools {
+ if t.Name == "Bash" {
+ tool = "Bash"
+ break
+ }
+ if t.Name == "PowerShell" {
+ tool = "PowerShell"
+ }
+ }
+ answered := false
+ for _, m := range req.Messages {
+ var parts []struct{ Type string }
+ if json.Unmarshal(m.Content, &parts) == nil {
+ for _, p := range parts {
+ answered = answered || p.Type == "tool_result"
+ }
+ }
+ }
+ block := map[string]any{"type": "text", "text": "done"}
+ stop := "end_turn"
+ if tool != "" && !answered {
+ command := "echo hello > " + written
+ if tool == "PowerShell" {
+ command = "Set-Content -Path " + written + " -Value hello"
+ }
+ block = map[string]any{"type": "tool_use", "id": fmt.Sprintf("toolu_claudecodecheck_%d", id), "name": tool,
+ "input": map[string]any{"command": command, "description": "Write the file"}}
+ stop = "tool_use"
+ }
+ msg := map[string]any{"id": fmt.Sprintf("msg_claudecodecheck_%d", id), "type": "message", "role": "assistant",
+ "model": req.Model, "content": []any{block}, "stop_reason": stop, "stop_sequence": nil,
+ "usage": map[string]any{"input_tokens": 10, "output_tokens": 5}}
+ if !req.Stream {
+ writeJSON(w, msg)
+ return
+ }
+ w.Header().Set("Content-Type", "text/event-stream")
+ event := func(name string, data any) {
+ b, _ := json.Marshal(data)
+ fmt.Fprintf(w, "event: %s\ndata: %s\n\n", name, b)
+ }
+ start := map[string]any{}
+ for k, v := range msg {
+ start[k] = v
+ }
+ start["content"], start["stop_reason"] = []any{}, nil
+ event("message_start", map[string]any{"type": "message_start", "message": start})
+ if block["type"] == "tool_use" {
+ input, _ := json.Marshal(block["input"])
+ event("content_block_start", map[string]any{"type": "content_block_start", "index": 0,
+ "content_block": map[string]any{"type": "tool_use", "id": block["id"], "name": block["name"], "input": map[string]any{}}})
+ event("content_block_delta", map[string]any{"type": "content_block_delta", "index": 0,
+ "delta": map[string]any{"type": "input_json_delta", "partial_json": string(input)}})
+ } else {
+ event("content_block_start", map[string]any{"type": "content_block_start", "index": 0,
+ "content_block": map[string]any{"type": "text", "text": ""}})
+ event("content_block_delta", map[string]any{"type": "content_block_delta", "index": 0,
+ "delta": map[string]any{"type": "text_delta", "text": block["text"]}})
+ }
+ event("content_block_stop", map[string]any{"type": "content_block_stop", "index": 0})
+ event("message_delta", map[string]any{"type": "message_delta", "delta": map[string]any{"stop_reason": stop, "stop_sequence": nil},
+ "usage": map[string]any{"output_tokens": 5}})
+ event("message_stop", map[string]any{"type": "message_stop"})
+}
+
+func writeJSON(w http.ResponseWriter, v any) {
+ w.Header().Set("Content-Type", "application/json")
+ _ = json.NewEncoder(w).Encode(v)
+}
+
+func exe() string {
+ if windows {
+ return ".exe"
+ }
+ return ""
+}
+
+// withEnv sets each key=value in env, replacing an earlier value of the key.
+// Windows compares keys without case.
+func withEnv(env []string, set ...string) []string {
+ for _, kv := range set {
+ key := kv[:strings.Index(kv, "=")+1]
+ out := env[:0:0]
+ for _, e := range env {
+ if !strings.HasPrefix(strings.ToUpper(e), strings.ToUpper(key)) {
+ out = append(out, e)
+ }
+ }
+ env = append(out, kv)
+ }
+ return env
+}
+
+func copyPath(src, dst string) error {
+ return filepath.Walk(src, func(p string, info os.FileInfo, err error) error {
+ if err != nil {
+ return err
+ }
+ rel, _ := filepath.Rel(src, p)
+ target := filepath.Join(dst, rel)
+ if info.IsDir() {
+ return os.MkdirAll(target, 0o755)
+ }
+ if err := os.MkdirAll(filepath.Dir(target), 0o755); err != nil {
+ return err
+ }
+ in, err := os.Open(p)
+ if err != nil {
+ return err
+ }
+ defer in.Close()
+ out, err := os.Create(target)
+ if err != nil {
+ return err
+ }
+ if _, err := io.Copy(out, in); err != nil {
+ out.Close()
+ return err
+ }
+ return out.Close()
+ })
+}
+
+func appendTo(file, text string) error {
+ f, err := os.OpenFile(file, os.O_APPEND|os.O_WRONLY, 0)
+ if err != nil {
+ return err
+ }
+ if _, err := f.WriteString(text); err != nil {
+ f.Close()
+ return err
+ }
+ return f.Close()
+}
+
+func tail(b []byte, n int) string {
+ lines := strings.Split(strings.TrimRight(string(b), "\n"), "\n")
+ if len(lines) > n {
+ lines = lines[len(lines)-n:]
+ }
+ return strings.Join(lines, "\n")
+}
(skywalking-ai-sessionizer) 01/02: Install the Claude Code plugin from a marketplace, and its binary beside asz
Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wu-sheng pushed a commit to branch plugin-from-path
in repository https://gitbox.apache.org/repos/asf/skywalking-ai-sessionizer.git
commit 41455316894658a9cbd2ca90f225e16d7ff49918
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Thu Sep 17 12:01:32 2026 +0800
Install the Claude Code plugin from a marketplace, and its binary beside asz
0.3.0 told users to run claude --plugin-dir on the packaged plugin.
Claude Code keeps --plugin-dir for one session, so the next plain claude
recorded no change and reported nothing.
The repository now has .claude-plugin/marketplace.json. Users add it at a
version's tag and install asz-changes from it, which lasts across
sessions. The manifest and the hooks move to plugins/claude-code/plugin/,
with their own LICENSE and NOTICE, so a marketplace install copies no Go
source. Neither manifest sets a version: a version pins the plugin until
someone changes it, and without one Claude Code uses the tag's commit.
The hooks run asz-claude-plugin by name from PATH, as Anthropic's language
server plugins run their servers. A binary inside the plugin would have to
be committed for every platform, and a source release carries no compiled
file. So each binary package holds asz and asz-claude-plugin side by side,
make build writes both to bin/, and the package smoke test, the release
candidate check, CI and the Homebrew, Scoop and winget manifests follow.
Install gives two copy-and-run blocks, one for macOS and Linux and one for
Windows. The reader sets the version. Each block checks the package against
its sha512 from downloads.apache.org, checks that both binaries start, and
installs them where the Claude Code installer puts claude.
Measured with Claude Code 2.1.274 in its own configuration directory:
- The marketplace installs from a git URL at a tag with --sparse, and the
plugin cache holds only the manifest, the hooks and the legal files.
- With the binary on PATH, a headless session recorded a shell command's
file, and asz collect landed it. Without it, Claude Code reported
"Executable not found in $PATH" and the command still ran.
- Removing the marketplace deletes the plugin's data directory, and with
it the records asz has not collected. The documented upgrade uninstalls
with --keep-data first, which kept them.
Neither install block has run on Windows.
---
.claude-plugin/marketplace.json | 13 ++
.github/workflows/ci.yaml | 4 +-
.gitignore | 1 -
.licenserc.yaml | 4 +-
Makefile | 19 +-
docs/en/changes/changes.md | 29 +++
docs/en/guides/how-to-release.md | 20 +-
docs/en/setup/claude-code-plugin.md | 217 +++++++++++++++++----
docs/en/setup/install.md | 211 ++++++++++++++++----
plugins/claude-code/hooks/hooks.json | 20 --
plugins/claude-code/hooks_test.go | 96 ++++++++-
.../{ => plugin}/.claude-plugin/plugin.json | 3 +-
plugins/claude-code/plugin/LICENSE | 202 +++++++++++++++++++
plugins/claude-code/plugin/NOTICE | 5 +
plugins/claude-code/plugin/hooks/hooks.json | 20 ++
tools/install-manifests.sh | 67 ++++---
tools/package-smoke.sh | 25 ++-
tools/release.sh | 6 +-
tools/releasecandidate/candidate_test.go | 2 +-
19 files changed, 799 insertions(+), 165 deletions(-)
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
new file mode 100644
index 0000000..b089141
--- /dev/null
+++ b/.claude-plugin/marketplace.json
@@ -0,0 +1,13 @@
+{
+ "name": "skywalking-ai-sessionizer",
+ "owner": {"name": "Apache SkyWalking", "url": "https://skywalking.apache.org/"},
+ "description": "Claude Code plugins of Apache SkyWalking AI Sessionizer.",
+ "plugins": [
+ {
+ "name": "asz-changes",
+ "source": "./plugins/claude-code/plugin",
+ "description": "Records which files each tool call changed, for Apache SkyWalking AI Sessionizer. Needs asz-claude-plugin on PATH.",
+ "license": "Apache-2.0"
+ }
+ ]
+}
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index dcdd034..5bfab0a 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -98,7 +98,7 @@ jobs:
- name: Build
run: |
go build -o bin/ ./cmd/asz
- go build -o plugins/claude-code/bin/ ./plugins/claude-code
+ go build -o bin/ ./plugins/claude-code
# The suite is split so a failure names which layer broke. The race
# detector needs a C toolchain, which the Windows runner does not put on
# its path, so Windows runs without it. The tests of the command and of
@@ -241,7 +241,7 @@ jobs:
run: |
dist/build/linux-amd64/asz version
if [ -d plugins/claude-code ]; then
- dist/build/linux-amd64/claude-code-plugin/bin/asz-claude-plugin version
+ dist/build/linux-amd64/asz-claude-plugin version
else
echo "::notice::this tree has no Claude Code plugin, so no plugin binary was run"
fi
diff --git a/.gitignore b/.gitignore
index b199f2b..5aa0a8b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,6 @@
# Build output
/bin/
/dist/
-/plugins/claude-code/bin/
*.exe
*.test
*.out
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 0c752a7..a2f766f 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -52,8 +52,10 @@ header:
- 'go.mod'
- 'go.sum'
- '**/*.md'
- # Claude Code reads the plugin's manifest and hooks as plain JSON, which has no comment to carry a header in.
+ # Claude Code reads the plugin's manifest and hooks, and the marketplace
+ # that lists the plugin, as plain JSON, which has no comment to carry a header in.
- 'plugins/claude-code/**/*.json'
+ - '.claude-plugin/marketplace.json'
- '**/testdata/**'
# The complete example document on the asz.view format page is what
# the command prints, byte for byte, and a test holds it to that.
diff --git a/Makefile b/Makefile
index d621876..5bc831c 100644
--- a/Makefile
+++ b/Makefile
@@ -29,8 +29,10 @@ LDFLAGS := -X main.version=$(VERSION)
RELEASE_NAME := apache-skywalking-ai-sessionizer-$(VERSION)-src
-# The Claude Code plugin: its manifest and hooks live in the tree, and its
-# binary is built beside them, where the hooks find it.
+# The Claude Code plugin's binary. Its hooks run it by name from PATH, so it
+# is built and packaged beside asz. The plugin itself, the manifest and the
+# hooks under plugins/claude-code/plugin, is installed from the marketplace
+# and is not packaged.
PLUGIN_DIR := plugins/claude-code
PLUGIN_BINARY := asz-claude-plugin
@@ -52,11 +54,11 @@ LICENSE_EYE_VERSION := v0.9.0
$(BIN_DIR):
@mkdir -p $(BIN_DIR)
-## build: compile the binary into ./bin
+## build: compile asz and the Claude Code plugin's binary into ./bin
.PHONY: build
build: $(BIN_DIR)
$(GO) build -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(BINARY) ./cmd/$(BINARY)
- $(GO) build -ldflags "$(LDFLAGS)" -o $(PLUGIN_DIR)/bin/$(PLUGIN_BINARY) ./$(PLUGIN_DIR)
+ $(GO) build -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(PLUGIN_BINARY) ./$(PLUGIN_DIR)
## test: run the whole suite, unit and end-to-end
.PHONY: test
@@ -187,7 +189,7 @@ tidy:
docker: ## Build the container image, as CI builds and publishes it
docker build --build-arg VERSION=$(VERSION) -t skywalking-ai-sessionizer:dev .
-## binaries: cross-compile every platform in PLATFORMS and package each, with the Claude Code plugin, the LICENSE, the NOTICE and the dependency licenses, into dist/
+## binaries: cross-compile every platform in PLATFORMS and package each, with the Claude Code plugin's binary, the LICENSE, the NOTICE and the dependency licenses, into dist/
.PHONY: binaries
# Two builds of one tag give the same bytes when they use the same Go, the
# same tar and the same gzip. Go records the tag in each binary as the
@@ -219,15 +221,14 @@ binaries:
for t in $(PLATFORMS); do \
os=$${t%/*}; arch=$${t#*/}; out=$(DIST)/build/$$os-$$arch; ext=""; \
if [ "$$os" = windows ]; then ext=.exe; fi; \
- rm -rf $$out && mkdir -p $$out/claude-code-plugin/bin && \
+ rm -rf $$out && mkdir -p $$out && \
cp dist-material/LICENSE dist-material/NOTICE $$out/ && cp -R dist-material/licenses $$out/licenses && \
echo "building $$os/$$arch" && \
CGO_ENABLED=0 GOWORK=off GOFLAGS=-mod=readonly GOOS=$$os GOARCH=$$arch $(GO) build -trimpath -ldflags "-s -w $(LDFLAGS)" -o $$out/$(BINARY)$$ext ./cmd/$(BINARY) || exit 1; \
- cp -R $(PLUGIN_DIR)/.claude-plugin $(PLUGIN_DIR)/hooks $$out/claude-code-plugin/ && \
- CGO_ENABLED=0 GOWORK=off GOFLAGS=-mod=readonly GOOS=$$os GOARCH=$$arch $(GO) build -trimpath -ldflags "-s -w $(LDFLAGS)" -o $$out/claude-code-plugin/bin/$(PLUGIN_BINARY)$$ext ./$(PLUGIN_DIR) || exit 1; \
+ CGO_ENABLED=0 GOWORK=off GOFLAGS=-mod=readonly GOOS=$$os GOARCH=$$arch $(GO) build -trimpath -ldflags "-s -w $(LDFLAGS)" -o $$out/$(PLUGIN_BINARY)$$ext ./$(PLUGIN_DIR) || exit 1; \
chmod -R u=rwX,go=rX $$out || exit 1; \
if [ -n "$$stamp" ]; then find $$out -exec env TZ=UTC0 touch -t $$stamp {} + || exit 1; fi; \
- (cd $$out && find $(BINARY)$$ext claude-code-plugin LICENSE NOTICE licenses | LC_ALL=C sort > ../$$os-$$arch.list) || exit 1; \
+ (cd $$out && find $(BINARY)$$ext $(PLUGIN_BINARY)$$ext LICENSE NOTICE licenses | LC_ALL=C sort > ../$$os-$$arch.list) || exit 1; \
if [ "$$os" = windows ]; then \
rm -f $(DIST)/$(PKG_BASE)-$$os-$$arch.zip && \
(cd $$out && TZ=UTC0 zip -X -q ../../$(PKG_BASE)-$$os-$$arch.zip -@ < ../$$os-$$arch.list) || exit 1; \
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index b4f7d6a..24dd9fd 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -72,6 +72,35 @@
feed still picks up each session as it arrives. A directory an earlier build wrote without an
interval is brought up to date instead of refused.
+## Install
+
+- **The Claude Code plugin installs from a marketplace.** 0.3.0 told users to run
+ `claude --plugin-dir` on the packaged plugin, which Claude Code keeps for one session only, so the
+ next plain `claude` recorded nothing and said nothing. The repository now carries
+ `.claude-plugin/marketplace.json`, and `claude plugin marketplace add` at a version's tag, then
+ `claude plugin install asz-changes@skywalking-ai-sessionizer`, keeps the plugin installed across
+ sessions. The manifest and the hooks moved to `plugins/claude-code/plugin/`, which holds only what
+ Claude Code reads and its own `LICENSE` and `NOTICE`, so no Go source reaches a user's plugin
+ cache. The manifest names no version, so the version is the tag's commit and no release can leave
+ a stale one behind. [Claude Code Plugin](../setup/claude-code-plugin.md#install) gives the commands, and
+ how to upgrade without losing records asz has not collected yet: removing the marketplace deletes
+ the plugin's data directory unless the plugin is first uninstalled with `--keep-data`.
+- **The hooks run `asz-claude-plugin` by name from `PATH`**, as Anthropic's language server plugins
+ run their servers. A binary inside the plugin would have to be committed for every platform, and
+ a source release carries no compiled file. With no binary on `PATH`, Claude Code 2.1.274 reported
+ `Executable not found in $PATH` for the hook, and the tool still ran.
+- **Each binary package holds `asz` and `asz-claude-plugin` side by side**, with `LICENSE`, `NOTICE`
+ and `licenses/`, and no `claude-code-plugin/` directory. `make build` writes both to `bin/`. The
+ package smoke test finds the plugin's binary by name on `PATH`. The candidate check in
+ `tools/release.sh`, the Homebrew formula, and the Scoop and winget manifests follow the new
+ layout, and put both binaries on the path.
+- **Quick install.** [Install](../setup/install.md#quick-install) gives one block for macOS and Linux
+ and one for Windows. Each takes the version the reader sets, downloads the package through the
+ mirror selector and its `.sha512` from downloads.apache.org, stops unless they match, checks that
+ both binaries start, and installs them where the Claude Code installer puts `claude`: `~/.local/bin`,
+ or `%USERPROFILE%\.local\bin`. The shell block ran in zsh, bash and sh on macOS, and in Debian and
+ Alpine containers. The PowerShell block ran in PowerShell 7.4.7 on Linux, not yet on Windows.
+
## Release
- `publish` asks whether the version becomes the latest GitHub release before anything moves, and
diff --git a/docs/en/guides/how-to-release.md b/docs/en/guides/how-to-release.md
index 784d97f..a73d6db 100644
--- a/docs/en/guides/how-to-release.md
+++ b/docs/en/guides/how-to-release.md
@@ -326,8 +326,7 @@ The command takes these steps and stops at the first failure:
6. **Verify before signing.** All expected archives must exist and pass the metadata checker and
their SHA-512 checksums. The source archive must have one top directory with `LICENSE` and
`NOTICE`, no font file and no compiled file named by the tag's Makefile. Each binary package
- must contain both binaries, the plugin manifest and hooks, `LICENSE`, `NOTICE` and
- `licenses/`. The command then signs every verified archive and verifies each signature
+ must contain both binaries, `LICENSE`, `NOTICE` and `licenses/`. The command then signs every verified archive and verifies each signature
against the SkyWalking KEYS keyring. The CI binary checksums remain unchanged.
7. **Run the package for this machine again.** The command unpacks the source archive in a
temporary directory and runs its `tools/package-smoke.sh` on the signed CI package for the
@@ -379,11 +378,17 @@ writes nothing into `dist/$VERSION/`. The plan does not claim that prerelease as
tagged source under `apache-skywalking-ai-sessionizer-$VERSION-src/`, with the fonts and local
metadata excluded by `.gitattributes`. A build from it uses system fonts.
- Each binary package is `apache-skywalking-ai-sessionizer-$VERSION-bin-<os>-<arch>.tgz`, or
- `.zip` for Windows. It contains `asz`, the complete `claude-code-plugin/`, and the binary
- distribution's `LICENSE`, `NOTICE` and `licenses/`. Both binaries end in `.exe` on Windows.
- These packages include the renderer's two OFL fonts and their license texts.
+ `.zip` for Windows. It contains `asz`, `asz-claude-plugin`, which is the binary of the Claude
+ Code plugin, and the binary distribution's `LICENSE`, `NOTICE` and `licenses/`. Both binaries
+ end in `.exe` on Windows. These packages include the renderer's two OFL fonts and their license
+ texts.
- Every archive has a `.sha512` checksum and an ASCII-armored detached `.asc` signature.
+No package carries the Claude Code plugin's manifest and hooks. Users install them from the
+marketplace at the release tag: `.claude-plugin/marketplace.json` and `plugins/claude-code/plugin/`
+in the tagged source, which is what the source package holds. The install instructions name the
+tag, so the plugin a user installs is the one the vote approved, once the version is released.
+
The tag's `PLATFORMS` names macOS, Linux and Windows, each on x86-64 and ARM 64. CI cross-compiles
without cgo on Linux with its configured Go toolchain and packages with GNU tar, gzip and zip.
It uses `GOWORK=off` and `GOFLAGS=-mod=readonly`. Both binaries report `$VERSION` and the Go
@@ -916,8 +921,9 @@ are conveniences.
The Homebrew formula installs the voted binary package for the machine: macOS or Linux, on ARM 64
or x86-64. It names a URL, a mirror and a sha256 for each of the four packages. It builds nothing,
-so it needs no Go. It installs `asz`, the Claude Code plugin under `libexec/claude-code-plugin`,
-and `LICENSE`, `NOTICE` and `licenses/`, and its test runs both binaries. It goes to a tap only.
+so it needs no Go. It installs `asz` and `asz-claude-plugin` on the path, and `LICENSE`, `NOTICE`
+and `licenses/`, and its test runs both binaries. Its caveats give the two commands that install
+the plugin from the marketplace at the version's tag. It goes to a tap only.
Homebrew/homebrew-core takes a formula only when it builds from source or installs output that is
the same on every platform, and this formula installs a binary built for each platform.
diff --git a/docs/en/setup/claude-code-plugin.md b/docs/en/setup/claude-code-plugin.md
index fc7321e..3023c84 100644
--- a/docs/en/setup/claude-code-plugin.md
+++ b/docs/en/setup/claude-code-plugin.md
@@ -5,8 +5,9 @@ as a set of hooks, needs nothing from asz, and leaves one JSON line per observed
data directory. asz collects those lines the way it collects Claude Code's own transcripts, and
the conversation page shows each change beside the step that made it.
-The plugin is named `asz-changes`. Its code is under `plugins/claude-code/` in the repository,
-and its binary, `asz-claude-plugin`, ships beside `asz` in every binary package.
+The plugin is named `asz-changes`. Its code is under `plugins/claude-code/` in the repository, and
+what Claude Code installs, the manifest and the hooks, is under `plugins/claude-code/plugin/`. Its
+binary, `asz-claude-plugin`, ships beside `asz` in every binary package.
## What is recorded, and by whom
@@ -34,22 +35,138 @@ window open at the same time sees it as shared with the edit and names it.
## Install
-The binary package for your platform holds `claude-code-plugin/`: the plugin's manifest, its
-hooks, and its binary under `bin/`. [Install](install.md) says where to get the package, and
-where each package manager puts this directory. Point Claude Code at it:
+The plugin comes in two parts, and each has its own step. Both steps use the same version.
+
+1. **The binary.** `asz-claude-plugin` is in every binary package beside `asz`, and
+ [Quick install](install.md#quick-install) puts both on your `PATH`. The hooks run the binary by
+ its name, so Claude Code must find it on the `PATH` it starts with.
+2. **The plugin.** Claude Code installs the manifest and the hooks from the marketplace in the asz
+ repository. Set the version first, the same one as the binary: `VERSION=<version>` in a shell,
+ or `$Version = "<version>"` in PowerShell. Then, in a shell:
+
+ ```sh
+ claude plugin marketplace add "https://github.com/apache/skywalking-ai-sessionizer.git#v$VERSION" --sparse .claude-plugin plugins/claude-code/plugin &&
+ claude plugin install asz-changes@skywalking-ai-sessionizer
+ ```
+
+ or in PowerShell:
+
+ ```powershell
+ claude plugin marketplace add "https://github.com/apache/skywalking-ai-sessionizer.git#v$Version" --sparse .claude-plugin plugins/claude-code/plugin
+ if ($LASTEXITCODE -eq 0) { claude plugin install asz-changes@skywalking-ai-sessionizer }
+ ```
+
+The address ends with the version's tag, so the hooks Claude Code installs are the ones released
+with that binary, not whatever the default branch holds later. It is an HTTPS address because
+Claude Code clones a GitHub `owner/repo` shorthand over SSH, which fails on a machine with no SSH
+key for GitHub. `--sparse` keeps most of the repository out of the clone, though git still checks
+out the files beside each directory it names. What Claude Code copies into its plugin cache is the
+plugin's own directory alone: the manifest, the hooks, `LICENSE` and `NOTICE`, and no binary. The manifest names no version, so Claude Code shows the tag's commit as
+the plugin's version.
+
+Claude Code sets `CLAUDE_PLUGIN_DATA` for the plugin's hooks and creates the directory it names,
+`~/.claude/plugins/data/asz-changes-skywalking-ai-sessionizer/`, under `CLAUDE_CONFIG_DIR` when that
+is set. The plugin keeps its state and its output there. Nothing else is configured, and asz need
+not be installed for the plugin to record. asz collects the output when it runs.
+
+To check the two parts:
```sh
-claude --plugin-dir /path/to/claude-code-plugin
+asz-claude-plugin version
+claude plugin list
```
-or add it to your Claude Code settings the way the Claude Code documentation describes for a
-local plugin. Claude Code sets `CLAUDE_PLUGIN_DATA` for the plugin's hooks and creates the
-directory it names, `~/.claude/plugins/data/asz-changes-<marketplace>/`, which is where the
-plugin keeps its state and its output. Nothing else is configured, and asz need not be installed.
+A hook whose binary Claude Code cannot find never stops a tool, and records nothing. Claude Code
+2.1.274 reported `Executable not found in $PATH: "asz-claude-plugin"` for the session's start and
+end hooks, and the shell command in that session ran. When Claude Code reports that while
+`asz-claude-plugin version` works in your terminal, Claude Code started with another `PATH`. Restart
+it from that terminal. When no hook error is reported and a shell command still leaves no record,
+look in the plugin's `log/plugin.log` in its data directory: a hook that fails inside the plugin
+writes there and exits 0. An `Edit` or `Write` on the main stream leaves no plugin record by design,
+because Claude Code records that change itself.
-To build the plugin from a checkout, `make build` puts the binary at
-`plugins/claude-code/bin/asz-claude-plugin`, where `hooks/hooks.json` expects it, so
-`claude --plugin-dir plugins/claude-code` runs the checkout's plugin.
+### Upgrade
+
+Install the binary of the new version first, with [Quick install](install.md#quick-install) and the
+new version set. Then move the plugin to the same version, in a shell:
+
+```sh
+(
+ set -eu
+ : "${VERSION:?set VERSION to the version to move to}"
+ claude plugin uninstall asz-changes@skywalking-ai-sessionizer --keep-data
+ claude plugin marketplace remove skywalking-ai-sessionizer
+ claude plugin marketplace add "https://github.com/apache/skywalking-ai-sessionizer.git#v$VERSION" --sparse .claude-plugin plugins/claude-code/plugin
+ claude plugin install asz-changes@skywalking-ai-sessionizer
+)
+```
+
+or in PowerShell:
+
+```powershell
+& {
+ if (-not $Version) { throw "set `$Version to the version to move to" }
+ $Steps = @(
+ @("plugin", "uninstall", "asz-changes@skywalking-ai-sessionizer", "--keep-data"),
+ @("plugin", "marketplace", "remove", "skywalking-ai-sessionizer"),
+ @("plugin", "marketplace", "add", "https://github.com/apache/skywalking-ai-sessionizer.git#v$Version", "--sparse", ".claude-plugin", "plugins/claude-code/plugin"),
+ @("plugin", "install", "asz-changes@skywalking-ai-sessionizer"))
+ foreach ($Step in $Steps) {
+ & claude @Step
+ if ($LASTEXITCODE -ne 0) { throw "claude $Step failed, so the steps after it did not run" }
+ }
+}
+```
+
+Each step is needed, in this order, and each block stops at the first step that fails. Claude Code
+2.1.274 refused to add the marketplace again at another tag while it was declared at the first one.
+Removing a marketplace uninstalls its plugins, and uninstalling a plugin deletes its data directory,
+which holds the plugin's settings and every record asz has not collected yet. `--keep-data` keeps
+that directory, and the new version goes on writing into it. If adding the marketplace fails, for
+example with no network, the plugin stays uninstalled with its data kept. Run the last two steps
+again.
+
+The blocks move a plugin installed at the default scope, `user`, which is where [Install](#install)
+puts it. Removing the marketplace removes it from every scope. If you also installed the plugin at
+the `project` or `local` scope, uninstall it there with `--keep-data` and `--scope` first.
+
+### Remove
+
+```sh
+claude plugin uninstall asz-changes@skywalking-ai-sessionizer
+claude plugin marketplace remove skywalking-ai-sessionizer
+```
+
+The uninstall deletes the data directory. Let asz collect first, or pass `--keep-data`.
+
+### From 0.3.0
+
+0.3.0 packaged the whole plugin and ran it with `claude --plugin-dir`, which lasts for one session.
+Its data directory is `asz-changes-inline`. asz still collects that directory, because it collects
+every directory named `asz-changes` or `asz-changes-<marketplace>`. The settings do not move by
+themselves. If you wrote a `settings.yaml` for 0.3.0, copy it before the first session with the
+installed plugin:
+
+```sh
+(
+ D=${CLAUDE_CONFIG_DIR:-$HOME/.claude}/plugins/data
+ if [ -f "$D/asz-changes-inline/settings.yaml" ] && [ ! -e "$D/asz-changes-skywalking-ai-sessionizer/settings.yaml" ]; then
+ mkdir -p "$D/asz-changes-skywalking-ai-sessionizer"
+ cp "$D/asz-changes-inline/settings.yaml" "$D/asz-changes-skywalking-ai-sessionizer/"
+ fi
+)
+```
+
+### From a checkout
+
+`make build` writes `bin/asz` and `bin/asz-claude-plugin`. To run the checkout's plugin, put `bin`
+first on `PATH` and load the plugin's directory for one session:
+
+```sh
+PATH="$PWD/bin:$PATH" claude --plugin-dir plugins/claude-code/plugin
+```
+
+Its data directory is `asz-changes-inline`.
`asz-claude-plugin status`, with `CLAUDE_PLUGIN_DATA` set, prints the settings in force and the
exclusion rules they expand to.
@@ -272,20 +389,27 @@ It never stops the tool.
## The hook command
-`hooks/hooks.json` gives every hook the binary as its command and `hook` as its one argument:
+`hooks/hooks.json` gives every hook the binary's name as its command and `hook` as its one argument:
```json
-{"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin", "args": ["hook"], "timeout": 60}
+{"type": "command", "command": "asz-claude-plugin", "args": ["hook"], "timeout": 60}
```
The Claude Code [hooks reference](https://code.claude.com/docs/en/hooks#exec-form-and-shell-form)
-says that when a hook has `args`, Claude Code starts `command` directly, with `args` as its
-arguments and no shell, and that no shell splits the command into words on any platform. It also
-says the plugin's directory replaces `${CLAUDE_PLUGIN_ROOT}` as plain text that no shell reads, so
-a space, an apostrophe or a `$` in that path passes through unchanged. Claude Code 2.1.260 ran the
-hooks in this form on macOS. It has not run them on Windows.
-
-The plugin used to give one command line and no `args`:
+says that when a hook has `args`, Claude Code resolves `command` as an executable on `PATH` and
+starts it directly, with `args` as its arguments and no shell, and that no shell splits the command
+into words on any platform. Claude Code 2.1.274 ran the hooks in this form on macOS. It has not run
+them on Windows.
+
+The command is a name and not a path inside the plugin, because the binary is installed with asz
+and the plugin holds none. Anthropic's language server plugins for Claude Code name their servers
+the same way, `gopls` for Go, and ask for the server to be installed on `PATH` first. Up to 0.3.0,
+the package carried the binary inside the plugin, and the command was
+`${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin`. A marketplace installs a plugin from the repository,
+so a plugin that held the binary would need a built copy for every platform committed there, and
+an Apache source release carries no compiled file.
+
+Before that, the plugin gave one command line and no `args`:
`"${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin" hook`. The hooks reference says Claude Code runs
such a line in a shell, and that on Windows without Git Bash the shell is PowerShell. PowerShell's
own documentation, in `about_Operators`, says a quoted path is shown as a string, not run, unless
@@ -307,7 +431,7 @@ unavailable.
Each of these was read from a run of Claude Code 2.1.260 with a logging plugin, not from
documentation:
-- `hooks/hooks.json` with `${CLAUDE_PLUGIN_ROOT}` loads and fires.
+- A `hooks/hooks.json` that names `${CLAUDE_PLUGIN_ROOT}` loads and fires.
- Every tool event carries `session_id`, `tool_use_id`, `tool_input` and `cwd`.
- Every event inside a subagent carries `agent_id`. It is the id in the subagent transcript's file
name.
@@ -336,6 +460,27 @@ hook ran the binary with no argument. A binary without the no-argument rule abov
text and exited 2, and Claude Code blocked the shell command. The current binary ran as `hook` and
recorded the change. In both forms, Claude Code handed each hook its event on a socket.
+On 2026-09-17, Claude Code 2.1.274 on macOS installed the plugin the way [Install](#install) says,
+with a configuration directory of its own. The repository was served from the same machine over
+HTTP with a tag on the change, because Claude Code refused a `file://` address as a marketplace
+source. The marketplace was added at the tag with `--sparse`, and the plugin installed. The plugin
+cache held `.claude-plugin/plugin.json`, `hooks/hooks.json`, `LICENSE` and `NOTICE`, under a
+directory named for the tag's commit. A headless session, with a local program answering as the
+Messages API does, ran one shell command that wrote a file:
+
+- With `asz-claude-plugin` on `PATH`, the hooks ran it by name. Its record in
+ `asz-changes-skywalking-ai-sessionizer/output/<session-id>/main.jsonl` named the file as created,
+ and `asz collect` landed the record under the session's main stream.
+- With no `asz-claude-plugin` on `PATH`, the session's start hook reported
+ `Executable not found in $PATH: "asz-claude-plugin"`, and so did its end hook. The shell command
+ ran, and no record was written.
+
+For an upgrade, a second tag was made on a changed `hooks/hooks.json`. Adding the marketplace at the
+second tag was refused while it was declared at the first. Removing the marketplace uninstalled the
+plugin and deleted its data directory, with its `settings.yaml` and an output file in it.
+Uninstalling with `--keep-data` first, then removing the marketplace, adding it at the second tag
+and installing, kept both files, and the cache then held the changed hooks.
+
On Windows the plugin has run only outside Claude Code. CI's `packages` job runs
`tools/package-smoke.sh` on each binary package, on a runner of the package's own platform. On
2026-09-11, the CI of pull request #6 ran it on `windows-latest`, x86-64, and on `windows-11-arm`,
@@ -350,19 +495,21 @@ plugin's own tests on each system. Neither has run on Windows yet.
Claude Code itself has not run the hooks on Windows. The hooks reference says a hook with `args`
uses no shell and ignores `shell`, so whether Git Bash is installed should not matter. That has
-not been tried. It is also unknown whether the binary starts at all. The Windows packages hold
-`bin\asz-claude-plugin.exe`, and `hooks/hooks.json` names `bin/asz-claude-plugin`. The hooks
-reference says that on Windows, `command` must resolve to a real executable, such as a `.exe`. It
-does not say whether a path without `.exe` resolves to one.
+not been tried. It is also unknown whether the binary starts at all. `hooks/hooks.json` names
+`asz-claude-plugin`, and the file on Windows is `asz-claude-plugin.exe`. The hooks reference says
+that on Windows, `command` must resolve to a real executable, such as a `.exe`. It does not say
+whether a name without `.exe` resolves to one. The package smoke test now looks the binary up by
+that name, through Git Bash on Windows, which is not how Claude Code looks it up, and it has not
+run on Windows yet.
To find out, on Windows x86-64 or ARM 64:
-1. Unpack the package for the machine, and start Claude Code with
- `claude --plugin-dir <package>\claude-code-plugin`.
+1. Install the binary and the plugin as [Install](#install) says, and restart Claude Code.
2. Ask for one shell command that writes a file.
-3. Look in the plugin's data directory. For a plugin loaded with `--plugin-dir`, Claude Code 2.1.260
- on macOS put it at `plugins/data/asz-changes-inline` under its configuration directory. A record
- in `output\<session-id>\main.jsonl` there that names the file means the hooks work. If
- `log\plugin.log` does not exist, the binary never started. The likely cause is that the name did
- not resolve, and then the Windows packages need a `hooks/hooks.json` of their own that names
- `asz-claude-plugin.exe`.
+3. Look in `%USERPROFILE%\.claude\plugins\data\asz-changes-skywalking-ai-sessionizer`. A record in
+ `output\<session-id>\main.jsonl` there that names the file means the hooks work.
+4. Without a record, start Claude Code with `claude --debug hooks` from a terminal where
+ `Get-Command asz-claude-plugin` finds `asz-claude-plugin.exe`, and repeat step 2. If Claude Code
+ still reports `Executable not found in $PATH` for `asz-claude-plugin`, the name without `.exe` did
+ not resolve, and the plugin would need a hooks file for Windows that names `asz-claude-plugin.exe`.
+ If it reports no hook error, read `log\plugin.log` in the data directory.
diff --git a/docs/en/setup/install.md b/docs/en/setup/install.md
index 2baee99..207414c 100644
--- a/docs/en/setup/install.md
+++ b/docs/en/setup/install.md
@@ -1,8 +1,132 @@
# Install
asz is one binary, `asz`. This page lists the ways to get it, and says when each one is available.
-Every way gives the same program. The binary packages also carry the
-[Claude Code plugin](claude-code-plugin.md).
+Every way gives the same program. The binary packages also carry `asz-claude-plugin`, the binary
+of the [Claude Code plugin](claude-code-plugin.md).
+
+## Quick install
+
+Each block below installs the binary package of one released version, 0.4.0 or later, for the
+machine it runs on. It downloads the package through the Apache mirror selector and its `.sha512`
+from downloads.apache.org itself, and stops unless the two match. It checks that both binaries
+start, and only then puts `asz` and `asz-claude-plugin` in the directory where the Claude Code
+installer puts `claude`. It checks the checksum and not the signature.
+[Verify a package](#verify-a-package) says how to check both by hand.
+
+First set the version to install, one the [downloads page](https://skywalking.apache.org/downloads/)
+lists as released: `VERSION=<version>` in a shell, or `$Version = "<version>"` in PowerShell. A block
+with no version set stops and says so. Run the block again with another version to install that
+one over it.
+
+On macOS or Linux, paste it into zsh, bash or any other POSIX shell. It runs in a subshell, so a
+failure stops the block and leaves your terminal open:
+
+```sh
+(
+ set -eu
+ : "${VERSION:?set VERSION to a released version first}"
+ case "$(uname -s)" in Darwin) OS=darwin ;; Linux) OS=linux ;; *) echo "no package for $(uname -s)" >&2; exit 1 ;; esac
+ case "$(uname -m)" in arm64|aarch64) ARCH=arm64 ;; x86_64|amd64) ARCH=amd64 ;; *) echo "no package for $(uname -m)" >&2; exit 1 ;; esac
+ PKG=apache-skywalking-ai-sessionizer-$VERSION-bin-$OS-$ARCH.tgz
+ BIN=$HOME/.local/bin
+ mkdir -p "$BIN"
+ TMP=$(mktemp -d "$BIN/.asz-install.XXXXXX")
+ trap 'rm -rf "$TMP"' EXIT
+ cd "$TMP"
+ curl -fsSL -o "$PKG" "https://www.apache.org/dyn/closer.lua?path=skywalking/ai-sessionizer/$VERSION/$PKG&action=download"
+ curl -fsSL -o "$PKG.sha512" "https://downloads.apache.org/skywalking/ai-sessionizer/$VERSION/$PKG.sha512"
+ WANT=$(cut -d ' ' -f 1 "$PKG.sha512")
+ if command -v sha512sum >/dev/null 2>&1; then GOT=$(sha512sum "$PKG"); else GOT=$(shasum -a 512 "$PKG"); fi
+ [ "${#WANT}" -eq 128 ] && [ "${GOT%% *}" = "$WANT" ] || { echo "the sha512 of $PKG does not match $PKG.sha512" >&2; exit 1; }
+ tar -xzf "$PKG" asz asz-claude-plugin
+ ./asz version
+ ./asz-claude-plugin version
+ mv -f asz asz-claude-plugin "$BIN/"
+ echo "installed asz and asz-claude-plugin into $BIN"
+ [ "$(command -v asz-claude-plugin || true)" = "$BIN/asz-claude-plugin" ] ||
+ echo "Put $BIN first on your PATH, in your shell profile, then restart Claude Code. The plugin's hooks look for asz-claude-plugin there." >&2
+)
+```
+
+It installs into `~/.local/bin`. When the `asz-claude-plugin` your shell finds is not the one it
+installed, because `~/.local/bin` is not on `PATH` or another copy comes first, the block says so.
+Then put `~/.local/bin` first on `PATH` in your shell profile, as the Claude Code installer asks
+for `claude`, and restart Claude Code. Claude Code runs the plugin's hooks with its own `PATH`.
+
+On Windows, in PowerShell:
+
+```powershell
+& {
+ $ErrorActionPreference = "Stop"
+ $ProgressPreference = "SilentlyContinue"
+ if (-not $Version) { throw "set `$Version to a released version first" }
+ $Arch = switch ((Get-CimInstance Win32_Processor | Select-Object -First 1).Architecture) {
+ 9 { "amd64" } 12 { "arm64" } default { throw "no package for this processor" } }
+ $Pkg = "apache-skywalking-ai-sessionizer-$Version-bin-windows-$Arch.zip"
+ $Bin = Join-Path $env:USERPROFILE ".local\bin"
+ $Tmp = Join-Path ([IO.Path]::GetTempPath()) ("asz-install-" + [guid]::NewGuid())
+ New-Item -ItemType Directory -Path $Tmp | Out-Null
+ try {
+ $Zip = Join-Path $Tmp $Pkg
+ Invoke-WebRequest -UseBasicParsing -OutFile $Zip "https://www.apache.org/dyn/closer.lua?path=skywalking/ai-sessionizer/$Version/$Pkg&action=download"
+ Invoke-WebRequest -UseBasicParsing -OutFile "$Zip.sha512" "https://downloads.apache.org/skywalking/ai-sessionizer/$Version/$Pkg.sha512"
+ $Want = (Get-Content -LiteralPath "$Zip.sha512" -Raw).Trim().Split(" ")[0]
+ if ($Want.Length -ne 128 -or (Get-FileHash -LiteralPath $Zip -Algorithm SHA512).Hash -ne $Want) {
+ throw "the sha512 of $Pkg does not match $Pkg.sha512" }
+ Expand-Archive -LiteralPath $Zip -DestinationPath (Join-Path $Tmp "pkg")
+ foreach ($Exe in "asz.exe", "asz-claude-plugin.exe") {
+ & (Join-Path (Join-Path $Tmp "pkg") $Exe) version
+ if ($LASTEXITCODE -ne 0) { throw "$Exe does not run" } }
+ New-Item -ItemType Directory -Force -Path $Bin | Out-Null
+ foreach ($Exe in "asz.exe", "asz-claude-plugin.exe") {
+ $Old = Join-Path $Bin $Exe
+ if (Test-Path -LiteralPath $Old) {
+ try { [IO.File]::Open($Old, "Open", "ReadWrite", "None").Dispose() }
+ catch { throw "$Old is in use. Stop asz and Claude Code, then run this again." } } }
+ foreach ($Exe in "asz.exe", "asz-claude-plugin.exe") {
+ Copy-Item -LiteralPath (Join-Path (Join-Path $Tmp "pkg") $Exe) -Destination $Bin -Force }
+ } finally {
+ Remove-Item -LiteralPath $Tmp -Recurse -Force -ErrorAction SilentlyContinue
+ }
+ Write-Host "installed asz and asz-claude-plugin into $Bin"
+ $Sep = [IO.Path]::PathSeparator
+ $UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
+ if (-not (($UserPath -split $Sep) -contains $Bin)) {
+ [Environment]::SetEnvironmentVariable("Path", $(if ($UserPath) { "$UserPath$Sep$Bin" } else { $Bin }), "User")
+ Write-Host "added $Bin to your user Path" }
+ if (-not (($env:PATH -split $Sep) -contains $Bin)) { $env:PATH = "$env:PATH$Sep$Bin" }
+ $Found = (Get-Command asz-claude-plugin.exe -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1).Source
+ if ($Found -ne (Join-Path $Bin "asz-claude-plugin.exe")) {
+ Write-Warning "asz-claude-plugin.exe on this Path is $(if ($Found) { $Found } else { 'not found' }), not the one in $Bin. Put $Bin before it in your Path." }
+ Write-Host "Restart Claude Code from a new terminal, so its hooks find asz-claude-plugin."
+}
+```
+
+It installs into `%USERPROFILE%\.local\bin`, where the Claude Code installer puts `claude.exe`. It
+adds that directory to your user `Path` when it is not there, and to the `Path` of the terminal it
+runs in. When the `asz-claude-plugin.exe` that terminal finds is not the one it installed, it warns.
+Restart Claude Code from a new terminal afterwards, so its hooks see the new `Path`. Stop `asz` and
+Claude Code before you install over them. Windows does not replace the file of a running program,
+so the block checks both files first, and stops before it copies either when one is in use.
+
+On 2026-09-17 both blocks ran against packages built from the development tree and served from
+the same machine, with only the two download addresses changed:
+
+- The macOS and Linux block ran in zsh, bash and sh on macOS on Apple silicon. There, a wrong
+ checksum, a version that is not on the site and no version at all each stopped the block before
+ anything was installed, left no temporary directory, and left the shell that ran it running. A
+ second run installed over the first. On Linux on ARM 64 the block installed both binaries in a
+ Debian container, with GNU tar and `sha512sum`, and in an Alpine container, with BusyBox.
+- The Windows block ran in PowerShell 7.4.7 on Linux. The package there held Linux binaries named
+ `.exe`, and a stub answered the processor query. It installed both binaries, added the directory
+ to the terminal's path, and installed again over them. With another `asz-claude-plugin.exe`
+ earlier on the path, it warned. With the installed `asz-claude-plugin.exe` held open, a wrong
+ checksum, or no version, it stopped with nothing copied and no temporary directory left. The
+ user `Path`, which Linux does not keep, and a running program's file, which Linux does not lock,
+ were not tested. It has not run on Windows or in Windows PowerShell 5.1.
+
+The plugin itself is installed into Claude Code with two more commands, which
+[Claude Code Plugin](claude-code-plugin.md#install) gives.
## Binary package
@@ -23,8 +147,10 @@ SkyWalking AI Sessionizer.
Every package holds:
- `asz`, or `asz.exe` on Windows.
-- `claude-code-plugin/`, the Claude Code plugin: its manifest, its hooks, and its binary under
- `bin/`. [Claude Code Plugin](claude-code-plugin.md) says how to point Claude Code at it.
+- `asz-claude-plugin`, or `asz-claude-plugin.exe`, the binary the Claude Code plugin's hooks run.
+ The plugin's manifest and hooks are not in the package. Claude Code installs them from the
+ marketplace at the version's tag, as [Claude Code Plugin](claude-code-plugin.md#install) says.
+ Up to 0.3.0, the package held the whole plugin under `claude-code-plugin/`.
- `LICENSE`, `NOTICE`, and `licenses/` with the license of every module built into the binaries.
The same files are in three places:
@@ -42,10 +168,11 @@ The same files are in three places:
The GitHub releases of 0.1.0 and 0.2.0 were made before the project's first Apache vote. They are
not Apache releases, and their packages, which CI built, are not signed.
+The commands below use the version you set, as in [Quick install](#quick-install).
+
On macOS or Linux, download a package with its checksum and its signature:
```sh
-VERSION=0.3.0
PKG=apache-skywalking-ai-sessionizer-$VERSION-bin-linux-amd64.tgz
curl -fL -o "$PKG" "https://www.apache.org/dyn/closer.lua?path=skywalking/ai-sessionizer/$VERSION/$PKG&action=download"
curl -fLO "https://downloads.apache.org/skywalking/ai-sessionizer/$VERSION/$PKG.sha512"
@@ -60,8 +187,8 @@ tar -xzf "$PKG" -C asz
./asz/asz version
```
-Put the directory on your `PATH`, or copy `asz` into a directory that is on it. If you use the
-plugin, keep `claude-code-plugin/` whole, because its hooks run the binary under its own `bin/`.
+Put the directory on your `PATH`, or copy `asz` and `asz-claude-plugin` into a directory that is on
+it. The plugin's hooks run `asz-claude-plugin` by name, so Claude Code must find it on its `PATH`.
The binaries are not notarized by Apple. A browser marks the files it downloads, and macOS may
refuse to start a marked binary that is not notarized. `curl` does not mark what it downloads. If
@@ -70,7 +197,6 @@ macOS refuses, remove the mark: `xattr -dr com.apple.quarantine asz`.
On Windows, in PowerShell:
```powershell
-$Version = "0.3.0"
$Pkg = "apache-skywalking-ai-sessionizer-$Version-bin-windows-amd64.zip"
Invoke-WebRequest -OutFile $Pkg "https://www.apache.org/dyn/closer.lua?path=skywalking/ai-sessionizer/$Version/$Pkg&action=download"
Invoke-WebRequest -OutFile "$Pkg.sha512" "https://downloads.apache.org/skywalking/ai-sessionizer/$Version/$Pkg.sha512"
@@ -84,11 +210,10 @@ Expand-Archive $Pkg -DestinationPath asz
.\asz\asz.exe version
```
-Claude Code has not yet run the plugin's hooks on Windows, so the command line in `hooks/hooks.json`
-has not run there. CI unpacks each Windows package on a Windows runner of its processor, outside
-Claude Code. It runs the packaged plugin with a `SessionStart`, a `PreToolUse`, a `PostToolUse` and
-a `SessionEnd` event on standard input.
-[Claude Code Plugin](claude-code-plugin.md#what-was-verified) says what was verified.
+Claude Code has not yet run the plugin's hooks on Windows. CI unpacks each Windows package on a
+Windows runner of its processor, outside Claude Code. It finds `asz-claude-plugin` by name on the
+path, and runs it with a `SessionStart`, a `PreToolUse`, a `PostToolUse` and a `SessionEnd` event on
+standard input. [Claude Code Plugin](claude-code-plugin.md#what-was-verified) says what was verified.
## Verify a package
@@ -139,9 +264,8 @@ The formula downloads the binary package for your machine from the GitHub releas
That release carries the voted packages, and its URL keeps working after a newer version comes
out. When GitHub fails, Homebrew takes the same package from archive.apache.org, which keeps every
version. Either way, Homebrew checks the download against the sha256 of the voted package. The
-formula builds nothing, so it needs no Go. It installs `asz`, the Claude Code plugin under the
-formula's `libexec/claude-code-plugin`, and `LICENSE`, `NOTICE` and `licenses/` at the root of the
-formula's prefix. Because it installs the binary package, `asz view` draws the page with the
+formula builds nothing, so it needs no Go. It installs `asz` and `asz-claude-plugin` on your
+`PATH`, and `LICENSE`, `NOTICE` and `licenses/` at the root of the formula's prefix. Because it installs the binary package, `asz view` draws the page with the
renderer's fonts.
Once the tap is named here, install by the formula's full name:
@@ -151,15 +275,10 @@ brew install <owner>/<tap>/skywalking-ai-sessionizer
```
Since Homebrew 6.0.0, a formula from a tap that is not Homebrew's own must be trusted before it is
-loaded. Installing by the full name trusts that one formula only. Point Claude Code at the plugin
-with:
-
-```sh
-claude --plugin-dir "$(brew --prefix skywalking-ai-sessionizer)/libexec/claude-code-plugin"
-```
-
-`brew --prefix skywalking-ai-sessionizer` prints the formula's `opt` directory, which stays the
-same across upgrades. `brew info skywalking-ai-sessionizer` prints the same plugin path.
+loaded. Installing by the full name trusts that one formula only. The formula's caveats, which
+`brew info skywalking-ai-sessionizer` prints again, give the two commands that install the plugin
+into Claude Code at the formula's version. [Claude Code Plugin](claude-code-plugin.md#install)
+gives the same commands.
## Scoop, on Windows
@@ -168,9 +287,8 @@ same across upgrades. `brew info skywalking-ai-sessionizer` prints the same plug
Each release writes a Scoop manifest for Windows on x86-64 and ARM 64. The release manager submits
it to a Scoop bucket, and this section will name the bucket once the manifest is published. The
manifest downloads the binary package from dlcdn.apache.org, the delivery network in front of the
-download site, checks its sha512, and puts `asz` on the path. The plugin is the
-`claude-code-plugin` folder in the app's directory, which `scoop prefix skywalking-ai-sessionizer`
-prints.
+download site, checks its sha512, and puts `asz` and `asz-claude-plugin` on the path. The plugin
+itself is installed into Claude Code as [Claude Code Plugin](claude-code-plugin.md#install) says.
## winget, on Windows
@@ -186,8 +304,8 @@ winget install --id Apache.SkyWalkingAISessionizer
The manifest downloads the binary package from the GitHub release of the version, which carries
the voted packages and keeps its URL after a newer version comes out. It checks the package's
-sha256, and adds `asz` as a command. The plugin is the `claude-code-plugin` folder beside
-`asz.exe`, in the folder winget installs the package into.
+sha256, and adds `asz` and `asz-claude-plugin` as commands. The plugin itself is installed into
+Claude Code as [Claude Code Plugin](claude-code-plugin.md#install) says.
## Build from the source package
@@ -198,8 +316,9 @@ pinned Horizon commit. The source package does not carry the renderer's two font
are under the SIL Open Font License, which the ASF keeps out of source releases. A binary built
from it draws the page with system fonts. The binary packages carry the fonts.
+With `VERSION` set to a released version:
+
```sh
-VERSION=0.3.0
SRC=apache-skywalking-ai-sessionizer-$VERSION-src.tgz
curl -fL -o "$SRC" "https://www.apache.org/dyn/closer.lua?path=skywalking/ai-sessionizer/$VERSION/$SRC&action=download"
curl -fLO "https://downloads.apache.org/skywalking/ai-sessionizer/$VERSION/$SRC.sha512"
@@ -215,17 +334,26 @@ make build VERSION=$VERSION
./bin/asz version
```
-`make build` writes `bin/asz`. It writes the plugin's binary to
-`plugins/claude-code/bin/asz-claude-plugin`, where the plugin's hooks expect it, so
-`claude --plugin-dir plugins/claude-code` runs the plugin from the source. Pass `VERSION`. The
-Makefile reads the version from git, and an unpacked source package has no git history, so without
-it `asz version` prints an empty version.
+`make build` writes `bin/asz` and `bin/asz-claude-plugin`. Pass `VERSION`. The Makefile reads the
+version from git, and an unpacked source package has no git history, so without it `asz version`
+prints an empty version. Up to 0.3.0, `make build` wrote the plugin's binary to
+`plugins/claude-code/bin/` instead.
+
+To run the plugin from the source of 0.4.0 or later, put `bin` first on `PATH` and load the plugin's
+directory:
+
+```sh
+PATH="$PWD/bin:$PATH" claude --plugin-dir plugins/claude-code/plugin
+```
+
+`--plugin-dir` lasts for that one session. Its data directory is `asz-changes-inline`, not the
+`asz-changes-skywalking-ai-sessionizer` of an installed plugin.
Without make, on Windows for example, run the two commands `make build` runs:
```sh
-go build -ldflags "-X main.version=0.3.0" -o bin/asz.exe ./cmd/asz
-go build -ldflags "-X main.version=0.3.0" -o plugins/claude-code/bin/asz-claude-plugin.exe ./plugins/claude-code
+go build -ldflags "-X main.version=$VERSION" -o bin/asz.exe ./cmd/asz
+go build -ldflags "-X main.version=$VERSION" -o bin/asz-claude-plugin.exe ./plugins/claude-code
```
Leave out `.exe` on macOS and Linux. `make binaries VERSION=$VERSION` cross-compiles every
@@ -243,7 +371,7 @@ you accept a build of the tagged source that no vote checked.
For Go users, with Go 1.27 or later:
```sh
-go install github.com/apache/skywalking-ai-sessionizer/cmd/asz@v0.3.0
+go install "github.com/apache/skywalking-ai-sessionizer/cmd/asz@v$VERSION"
```
It installs `asz` into Go's `bin` directory, `$(go env GOPATH)/bin` unless `GOBIN` is set. It
@@ -256,8 +384,9 @@ differs from a package in four ways:
the project's first Apache vote.
- `asz version` prints `dev`. The Makefile sets the version at build time, and `go install` does
not.
-- The Claude Code plugin is not installed. Take it from a binary package, or build it from the
- source package.
+- The Claude Code plugin's binary is not installed. Take it from a binary package, or build it from
+ the source package. `go install` of `./plugins/claude-code` would name the binary `claude-code`,
+ which the plugin's hooks do not run.
Measured on 2026-09-11 on macOS: `go install github.com/apache/skywalking-ai-sessionizer/cmd/asz@main`
built commit `dd083cc`, through the Go module proxy and again from GitHub directly. The module Go
diff --git a/plugins/claude-code/hooks/hooks.json b/plugins/claude-code/hooks/hooks.json
deleted file mode 100644
index a8b4c35..0000000
--- a/plugins/claude-code/hooks/hooks.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "description": "asz-changes: a scan around each shell command, the runtime's own patch for each edit inside a subagent, and the retention rules at the session's start and end.",
- "hooks": {
- "PreToolUse": [
- {"matcher": "Bash|PowerShell|Monitor", "hooks": [{"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin", "args": ["hook"], "timeout": 60}]}
- ],
- "PostToolUse": [
- {"matcher": "Bash|PowerShell|Monitor|Edit|Write|NotebookEdit", "hooks": [{"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin", "args": ["hook"], "timeout": 60}]}
- ],
- "PostToolUseFailure": [
- {"matcher": "Bash|PowerShell|Monitor", "hooks": [{"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin", "args": ["hook"], "timeout": 60}]}
- ],
- "SessionStart": [
- {"hooks": [{"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin", "args": ["hook"], "timeout": 30}]}
- ],
- "SessionEnd": [
- {"hooks": [{"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin", "args": ["hook"], "timeout": 30}]}
- ]
- }
-}
diff --git a/plugins/claude-code/hooks_test.go b/plugins/claude-code/hooks_test.go
index dd0d90f..15d77ef 100644
--- a/plugins/claude-code/hooks_test.go
+++ b/plugins/claude-code/hooks_test.go
@@ -37,14 +37,24 @@ func jsonString(s string) string {
return string(b)
}
+// pluginDir is the directory a marketplace installs. It holds only what
+// Claude Code reads and the legal files, so no Go source is copied into a
+// user's plugin cache.
+const pluginDir = "plugin"
+
// TestHooksRunTheBinaryWithoutAShell holds hooks/hooks.json to the exec
// form: the binary as the command and hook as its one argument. Without
// "args", Claude Code hands the command to a shell, and on Windows without
// Git Bash that shell is PowerShell. PowerShell cannot parse a quoted path
// followed by a word, so every hook failed before the plugin started. With
// "args", Claude Code starts the binary itself, on every platform.
+//
+// The command is the bare name, which Claude Code looks up on PATH, as
+// Anthropic's own language server plugins do. The binary is installed with
+// asz, not inside the plugin, so one package installs both and the plugin
+// directory holds no binary.
func TestHooksRunTheBinaryWithoutAShell(t *testing.T) {
- data, err := os.ReadFile(filepath.Join("hooks", "hooks.json"))
+ data, err := os.ReadFile(filepath.Join(pluginDir, "hooks", "hooks.json"))
if err != nil {
t.Fatal(err)
}
@@ -66,7 +76,7 @@ func TestHooksRunTheBinaryWithoutAShell(t *testing.T) {
for _, g := range groups {
for _, h := range g.Hooks {
n++
- if h["type"] != "command" || h["command"] != "${CLAUDE_PLUGIN_ROOT}/bin/asz-claude-plugin" || !reflect.DeepEqual(h["args"], []any{"hook"}) {
+ if h["type"] != "command" || h["command"] != "asz-claude-plugin" || !reflect.DeepEqual(h["args"], []any{"hook"}) {
t.Errorf("%s: %v is not the binary with the one argument hook", event, h)
}
// Claude Code ignores a shell when args is set, so naming one
@@ -82,6 +92,88 @@ func TestHooksRunTheBinaryWithoutAShell(t *testing.T) {
}
}
+// TestTheMarketplaceInstallsThePlugin reads .claude-plugin/marketplace.json
+// at the repository root, which is what claude plugin marketplace add reads.
+// A marketplace without owner.name, or an entry whose source is not the
+// plugin directory, fails when a user adds it, and nothing here would run.
+//
+// Neither file sets a version. A version pins the plugin to that string, and
+// Claude Code then offers no update until the string changes, so a version
+// left behind by a release would hold every user on it. Without one, the
+// version is the commit the marketplace was added at, which is the release
+// tag the install instructions name.
+func TestTheMarketplaceInstallsThePlugin(t *testing.T) {
+ root := filepath.Join("..", "..")
+ var market struct {
+ Name string `json:"name"`
+ Owner struct {
+ Name string `json:"name"`
+ } `json:"owner"`
+ Plugins []map[string]any `json:"plugins"`
+ }
+ readJSON(t, filepath.Join(root, ".claude-plugin", "marketplace.json"), &market)
+ if market.Name != "skywalking-ai-sessionizer" || market.Owner.Name == "" {
+ t.Errorf("marketplace %q, owner %q: the documented install names skywalking-ai-sessionizer, and Claude Code requires an owner", market.Name, market.Owner.Name)
+ }
+ if len(market.Plugins) != 1 {
+ t.Fatalf("the marketplace lists %d plugins, want asz-changes alone", len(market.Plugins))
+ }
+ entry := market.Plugins[0]
+ if entry["name"] != "asz-changes" || entry["source"] != "./plugins/claude-code/"+pluginDir {
+ t.Errorf("entry %v is not asz-changes from ./plugins/claude-code/%s", entry, pluginDir)
+ }
+ if _, ok := entry["version"]; ok {
+ t.Errorf("the marketplace entry sets a version")
+ }
+
+ var manifest map[string]any
+ readJSON(t, filepath.Join(pluginDir, ".claude-plugin", "plugin.json"), &manifest)
+ if manifest["name"] != "asz-changes" {
+ t.Errorf("plugin.json names %v, and the marketplace entry names asz-changes", manifest["name"])
+ }
+ if _, ok := manifest["version"]; ok {
+ t.Errorf("plugin.json sets a version")
+ }
+
+ // A marketplace install copies this directory alone, so it carries its
+ // own copy of the project's license and notice.
+ for _, name := range []string{"LICENSE", "NOTICE"} {
+ want, err := os.ReadFile(filepath.Join(root, name))
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err := os.ReadFile(filepath.Join(pluginDir, name))
+ if err != nil || string(got) != string(want) {
+ t.Errorf("%s/%s is not the repository's %s: %v", pluginDir, name, name, err)
+ }
+ }
+
+ // Anything else in the directory would be copied into every user's
+ // plugin cache.
+ entries, err := os.ReadDir(pluginDir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, e := range entries {
+ switch e.Name() {
+ case ".claude-plugin", "hooks", "LICENSE", "NOTICE":
+ default:
+ t.Errorf("%s holds %s, which a marketplace install would copy", pluginDir, e.Name())
+ }
+ }
+}
+
+func readJSON(t *testing.T, path string, v any) {
+ t.Helper()
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := json.Unmarshal(data, v); err != nil {
+ t.Fatalf("%s: %v", path, err)
+ }
+}
+
// TestNoArgumentWithAnEventIsAHook: a Claude Code that drops the hook's
// args runs the binary with no argument and the event on standard input.
// It must run as a hook, which exits 0, and not print the usage text,
diff --git a/plugins/claude-code/.claude-plugin/plugin.json b/plugins/claude-code/plugin/.claude-plugin/plugin.json
similarity index 77%
rename from plugins/claude-code/.claude-plugin/plugin.json
rename to plugins/claude-code/plugin/.claude-plugin/plugin.json
index e0232e4..82f6def 100644
--- a/plugins/claude-code/.claude-plugin/plugin.json
+++ b/plugins/claude-code/plugin/.claude-plugin/plugin.json
@@ -1,7 +1,6 @@
{
"name": "asz-changes",
- "description": "Records which files each tool call changed, for Apache SkyWalking AI Sessionizer. Runs standalone; asz collects its output.",
- "version": "0.1.0",
+ "description": "Records which files each tool call changed, for Apache SkyWalking AI Sessionizer. Runs asz-claude-plugin from PATH; asz collects its output.",
"author": {"name": "Apache SkyWalking"},
"homepage": "https://github.com/apache/skywalking-ai-sessionizer",
"repository": "https://github.com/apache/skywalking-ai-sessionizer",
diff --git a/plugins/claude-code/plugin/LICENSE b/plugins/claude-code/plugin/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/plugins/claude-code/plugin/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/plugins/claude-code/plugin/NOTICE b/plugins/claude-code/plugin/NOTICE
new file mode 100644
index 0000000..3da6f81
--- /dev/null
+++ b/plugins/claude-code/plugin/NOTICE
@@ -0,0 +1,5 @@
+Apache SkyWalking AI Sessionizer
+Copyright 2026 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/plugins/claude-code/plugin/hooks/hooks.json b/plugins/claude-code/plugin/hooks/hooks.json
new file mode 100644
index 0000000..ba5bfb9
--- /dev/null
+++ b/plugins/claude-code/plugin/hooks/hooks.json
@@ -0,0 +1,20 @@
+{
+ "description": "asz-changes: a scan around each shell command, the runtime's own patch for each edit inside a subagent, and the retention rules at the session's start and end.",
+ "hooks": {
+ "PreToolUse": [
+ {"matcher": "Bash|PowerShell|Monitor", "hooks": [{"type": "command", "command": "asz-claude-plugin", "args": ["hook"], "timeout": 60}]}
+ ],
+ "PostToolUse": [
+ {"matcher": "Bash|PowerShell|Monitor|Edit|Write|NotebookEdit", "hooks": [{"type": "command", "command": "asz-claude-plugin", "args": ["hook"], "timeout": 60}]}
+ ],
+ "PostToolUseFailure": [
+ {"matcher": "Bash|PowerShell|Monitor", "hooks": [{"type": "command", "command": "asz-claude-plugin", "args": ["hook"], "timeout": 60}]}
+ ],
+ "SessionStart": [
+ {"hooks": [{"type": "command", "command": "asz-claude-plugin", "args": ["hook"], "timeout": 30}]}
+ ],
+ "SessionEnd": [
+ {"hooks": [{"type": "command", "command": "asz-claude-plugin", "args": ["hook"], "timeout": 30}]}
+ ]
+ }
+}
diff --git a/tools/install-manifests.sh b/tools/install-manifests.sh
index d153cc0..2251134 100755
--- a/tools/install-manifests.sh
+++ b/tools/install-manifests.sh
@@ -118,12 +118,11 @@ trap 'rm -rf "$tmp"' EXIT
# GNU tar and in bsdtar.
for f in $tgz; do
tar -tvzf "$pkg_dir/$f" > "$tmp/tgz.list" 2>/dev/null || fail "$f is not a gzip tar archive"
- for p in asz claude-code-plugin/bin/asz-claude-plugin LICENSE NOTICE \
- claude-code-plugin/.claude-plugin/plugin.json claude-code-plugin/hooks/hooks.json; do
+ for p in asz asz-claude-plugin LICENSE NOTICE; do
awk -v p="$p" '$NF == p { found = 1 } END { exit !found }' "$tmp/tgz.list" ||
fail "$f does not hold $p at its root, where the Homebrew formula expects it"
done
- for p in asz claude-code-plugin/bin/asz-claude-plugin; do
+ for p in asz asz-claude-plugin; do
awk -v p="$p" '$NF == p && $1 ~ /^-rwx/ { found = 1 } END { exit !found }' "$tmp/tgz.list" ||
fail "$f holds $p without its executable bit. The formula installs it as it is, so nobody could run it."
done
@@ -131,18 +130,17 @@ for f in $tgz; do
fail "$f holds no file under licenses/, which the formula installs beside LICENSE"
done
-# Scoop runs asz.exe from the root of the package, and winget names it by
-# that relative path. The plugin notes point at claude-code-plugin beside it.
+# Scoop runs asz.exe and asz-claude-plugin.exe from the root of the package,
+# and winget names each by that relative path.
if command -v unzip >/dev/null 2>&1; then
for f in "$win_x64" "$win_arm64"; do
unzip -Z1 "$pkg_dir/$f" > "$tmp/zip.list" 2>/dev/null || fail "$f is not a zip archive"
- for p in asz.exe claude-code-plugin/bin/asz-claude-plugin.exe \
- claude-code-plugin/.claude-plugin/plugin.json claude-code-plugin/hooks/hooks.json; do
+ for p in asz.exe asz-claude-plugin.exe; do
grep -Fqx "$p" "$tmp/zip.list" || fail "$f does not hold $p at its root, where the Scoop and winget manifests expect it"
done
done
else
- printf '%s: unzip is not installed, so the check that each Windows package holds asz.exe at its root was skipped\n' "$me" >&2
+ printf '%s: unzip is not installed, so the check that each Windows package holds both binaries at its root was skipped\n' "$me" >&2
fi
# The winget manifest schema. 1.12.0 is the version microsoft/winget-pkgs'
@@ -262,10 +260,9 @@ class SkywalkingAiSessionizer < Formula
end
def install
- bin.install "asz"
- # The plugin stays whole, because hooks/hooks.json runs the binary under
- # its own bin/.
- libexec.install "claude-code-plugin"
+ # The Claude Code plugin's hooks run asz-claude-plugin by name, so it
+ # goes on PATH beside asz.
+ bin.install "asz", "asz-claude-plugin"
# Homebrew keeps a formula's license files at the root of its prefix. It
# moves LICENSE and NOTICE there by itself, but not a directory, so
# licenses/ goes with them here. It holds the license of every module
@@ -274,18 +271,16 @@ class SkywalkingAiSessionizer < Formula
end
def caveats
- # The opt path stays the same across upgrades, so the directory given to
- # Claude Code keeps working after brew upgrade.
+ # The plugin comes from the marketplace at the tag of this version, so
+ # its hooks are the ones this binary was released with.
<<~EOS
- The Claude Code plugin, which records which files each tool call
- changed, is installed in:
- #{opt_libexec}/claude-code-plugin
+ asz-claude-plugin, the binary of the Claude Code plugin that records
+ which files each tool call changed, is on your PATH. To install the
+ plugin itself into Claude Code:
+ claude plugin marketplace add "https://github.com/apache/skywalking-ai-sessionizer.git#v#{version}" --sparse .claude-plugin plugins/claude-code/plugin
+ claude plugin install asz-changes@skywalking-ai-sessionizer
- Point Claude Code at that directory:
- claude --plugin-dir #{opt_libexec}/claude-code-plugin
-
- or add it to your Claude Code settings the way the Claude Code
- documentation describes for a local plugin. See:
+ See:
https://github.com/apache/skywalking-ai-sessionizer/blob/v#{version}/docs/en/setup/claude-code-plugin.md
EOS
end
@@ -296,20 +291,21 @@ class SkywalkingAiSessionizer < Formula
# agent.call, so the program does real work, not only print its version.
assert_match "agent.call", shell_output("#{bin}/asz glossary")
- plugin = libexec/"claude-code-plugin"
- assert_path_exists plugin/".claude-plugin/plugin.json"
- assert_path_exists plugin/"hooks/hooks.json"
- assert_match version.to_s, shell_output("#{plugin}/bin/asz-claude-plugin version")
+ assert_match version.to_s, shell_output("#{bin}/asz-claude-plugin version")
# Claude Code names the plugin's data directory in CLAUDE_PLUGIN_DATA.
# status reads the settings there and compiles the exclusion rules. With
# no settings file it takes the defaults, the set named standard-v1.
ENV["CLAUDE_PLUGIN_DATA"] = (testpath/"plugin-data").to_s
- assert_match "standard-v1", shell_output("#{plugin}/bin/asz-claude-plugin status")
+ assert_match "standard-v1", shell_output("#{bin}/asz-claude-plugin status")
end
end
EOF
# --------------------------------------------------------------------- Scoop
+# The notes name the plugin's tag as VERSION for the reader to fill in. Scoop
+# replaces only $dir, $original_dir and $persist_dir in notes, and
+# autoupdate moves the manifest to a new version without writing its notes
+# again, so a version written here would soon name an older release.
fill > "$out_dir/scoop/skywalking-ai-sessionizer.json" <<'EOF'
{
"##": [
@@ -331,11 +327,15 @@ fill > "$out_dir/scoop/skywalking-ai-sessionizer.json" <<'EOF'
"hash": "sha512:@ARM64_SHA512@"
}
},
- "bin": "asz.exe",
+ "bin": [
+ "asz.exe",
+ "asz-claude-plugin.exe"
+ ],
"notes": [
- "The Claude Code plugin is in $dir\\claude-code-plugin.",
- "Point Claude Code at it with: claude --plugin-dir \"$dir\\claude-code-plugin\"",
- "Claude Code has not yet run the plugin's hooks on Windows, so the command line in hooks/hooks.json has not run there. CI unpacks each Windows package on a Windows runner of its processor, outside Claude Code. It runs the packaged plugin with a SessionStart, a PreToolUse, a PostToolUse and a SessionEnd event on standard input. See https://github.com/apache/skywalking-ai-sessionizer/blob/main/docs/en/setup/claude-code-plugin.md"
+ "asz-claude-plugin, the binary of the Claude Code plugin, is on the path. Install the plugin itself into Claude Code with the two commands below, with VERSION replaced by the version asz version prints.",
+ "claude plugin marketplace add \"https://github.com/apache/skywalking-ai-sessionizer.git#vVERSION\" --sparse .claude-plugin plugins/claude-code/plugin",
+ "claude plugin install asz-changes@skywalking-ai-sessionizer",
+ "Claude Code has not yet run the plugin's hooks on Windows. CI unpacks each Windows package on a Windows runner of its processor, outside Claude Code, and runs the packaged plugin by name from the path with a SessionStart, a PreToolUse, a PostToolUse and a SessionEnd event on standard input. See https://github.com/apache/skywalking-ai-sessionizer/blob/main/docs/en/setup/claude-code-plugin.md"
],
"checkver": {
"url": "https://downloads.apache.org/skywalking/ai-sessionizer/?C=N;O=D;V=1",
@@ -382,8 +382,11 @@ NestedInstallerType: portable
NestedInstallerFiles:
- RelativeFilePath: asz.exe
PortableCommandAlias: asz
+- RelativeFilePath: asz-claude-plugin.exe
+ PortableCommandAlias: asz-claude-plugin
Commands:
- asz
+- asz-claude-plugin
Installers:
- Architecture: x64
InstallerUrl: https://github.com/apache/skywalking-ai-sessionizer/releases/download/v@VERSION@/apache-skywalking-ai-sessionizer-@VERSION@-bin-windows-amd64.zip
@@ -419,7 +422,7 @@ Tags:
- observability
- skywalking
ReleaseNotesUrl: https://github.com/apache/skywalking-ai-sessionizer/blob/v@VERSION@/docs/en/changes/changes.md
-InstallationNotes: The Claude Code plugin is the claude-code-plugin folder beside asz.exe in the package's install folder. Claude Code has not yet run the plugin's hooks on Windows, so the command line in hooks/hooks.json has not run there. CI unpacks each Windows package on a Windows runner of its processor, outside Claude Code. It runs the packaged plugin with a SessionStart, a PreToolUse, a PostToolUse and a SessionEnd event on standard input. See https://github.com/apache/skywalking- [...]
+InstallationNotes: asz-claude-plugin, the binary of the Claude Code plugin, is added as a command. Install the plugin itself into Claude Code with claude plugin marketplace add "https://github.com/apache/skywalking-ai-sessionizer.git#v@VERSION@" --sparse .claude-plugin plugins/claude-code/plugin, then claude plugin install asz-changes@skywalking-ai-sessionizer. Claude Code has not yet run the plugin's hooks on Windows. CI unpacks each Windows package on a Windows runner of its processor, [...]
Documentations:
- DocumentLabel: Documentation
DocumentUrl: https://github.com/apache/skywalking-ai-sessionizer/blob/v@VERSION@/docs/README.md
diff --git a/tools/package-smoke.sh b/tools/package-smoke.sh
index 71f9a8f..611c8e9 100755
--- a/tools/package-smoke.sh
+++ b/tools/package-smoke.sh
@@ -128,19 +128,17 @@ else
fi
step "Contents"
-for f in "asz$exe" LICENSE NOTICE \
- claude-code-plugin/.claude-plugin/plugin.json claude-code-plugin/hooks/hooks.json \
- "claude-code-plugin/bin/asz-claude-plugin$exe"; do
+for f in "asz$exe" "asz-claude-plugin$exe" LICENSE NOTICE; do
[ -f "$dir/$f" ] || fail "the package lacks $f"
done
[ -n "$(ls -A "$dir/licenses" 2>/dev/null)" ] || fail "the package's licenses directory is empty"
if [ -z "$exe" ]; then
# A tar that drops the mode leaves a binary nobody can start.
[ -x "$dir/asz" ] || fail "asz lost its executable bit in the archive"
- [ -x "$dir/claude-code-plugin/bin/asz-claude-plugin" ] || fail "the plugin lost its executable bit in the archive"
+ [ -x "$dir/asz-claude-plugin" ] || fail "the plugin lost its executable bit in the archive"
fi
asz="$dir/asz$exe"
-plugin="$dir/claude-code-plugin/bin/asz-claude-plugin$exe"
+plugin="$dir/asz-claude-plugin$exe"
echo "every file is there"
cd "$work"
@@ -214,11 +212,20 @@ view_pid=
echo "the list page and the conversation page answered"
# The hooks run the packaged plugin the way hooks/hooks.json has Claude Code
-# run it: the binary with the one argument hook and no shell, the event on
-# standard input, the plugin's own directory and data directory in the
-# environment. A shell command that writes a file must come out as a change.
+# run it: the binary by its name, found on PATH, with the one argument hook,
+# the event on standard input, the plugin's own directory and data
+# directory in the environment. On Windows the name has no .exe, and the
+# lookup must still find the binary. A shell command that writes a file
+# must come out as a change.
step "The Claude Code plugin"
-CLAUDE_PLUGIN_ROOT=$(native "$dir/claude-code-plugin")
+PATH="$dir:$PATH"
+found=$(command -v asz-claude-plugin || true)
+case "$found" in
+ "$dir/asz-claude-plugin" | "$dir/asz-claude-plugin$exe") ;;
+ *) fail "asz-claude-plugin on PATH is ${found:-nothing}, not the one in $dir" ;;
+esac
+plugin=asz-claude-plugin
+CLAUDE_PLUGIN_ROOT=$(native "$tree/plugins/claude-code/plugin")
CLAUDE_PLUGIN_DATA=$(native "$work/plugin-data")
export CLAUDE_PLUGIN_ROOT CLAUDE_PLUGIN_DATA
"$plugin" status >/dev/null
diff --git a/tools/release.sh b/tools/release.sh
index a295053..48130c2 100755
--- a/tools/release.sh
+++ b/tools/release.sh
@@ -783,13 +783,13 @@ $found"
*.zip) listing=$(unzip -Z1 "$out/$b") || fail "cannot list $b" ;;
*) listing=$(tar -tzf "$out/$b") || fail "cannot list $b" ;;
esac
- for f in "asz$exe" "claude-code-plugin/bin/asz-claude-plugin$exe" LICENSE NOTICE; do
+ for f in "asz$exe" "asz-claude-plugin$exe" LICENSE NOTICE; do
has_line "$listing" "$f" || fail "$b has no $f"
done
- for d in licenses/ claude-code-plugin/.claude-plugin/ claude-code-plugin/hooks/; do
+ for d in licenses/; do
has_prefix "$listing" "$d" || fail "$b has no $d"
done
- say "ok $b: asz$exe, the Claude Code plugin, LICENSE, NOTICE and licenses/"
+ say "ok $b: asz$exe, asz-claude-plugin$exe, LICENSE, NOTICE and licenses/"
done
step "Sign the verified archives"
diff --git a/tools/releasecandidate/candidate_test.go b/tools/releasecandidate/candidate_test.go
index ccf9839..743cbbb 100644
--- a/tools/releasecandidate/candidate_test.go
+++ b/tools/releasecandidate/candidate_test.go
@@ -163,7 +163,7 @@ echo 'ci-binaries: artifact 456, sha256:fixture, commit fixture'
var packed bytes.Buffer
gz := gzip.NewWriter(&packed)
tw := tar.NewWriter(gz)
- for _, name := range []string{"asz", "claude-code-plugin/bin/asz-claude-plugin", "claude-code-plugin/.claude-plugin/plugin.json", "claude-code-plugin/hooks/hooks.json", "LICENSE", "NOTICE", "licenses/license.txt"} {
+ for _, name := range []string{"asz", "asz-claude-plugin", "LICENSE", "NOTICE", "licenses/license.txt"} {
body := []byte("CI bytes for " + name + "\n")
if err := tw.WriteHeader(&tar.Header{Name: name, Mode: 0o644, Size: int64(len(body))}); err != nil {
t.Fatal(err)