diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8eed2e9..6bb3598 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -110,6 +110,7 @@ Codex does not have an in-session reload for installed plugins. To see your chan #### Asymmetry to be aware of - Claude skills reach the command as `${CLAUDE_PLUGIN_ROOT}/bin/clp ` (resolved at agent startup). Codex skills hard-code the marketplace install path (`~/.codex/marketplaces/yscope/plugins/clp/bin/clp`). When you add a new subcommand, both skill trees need the matching reference. +- OpenCode loads `skills-opencode/clp/SKILL.md` through a native skill directory. It resolves the plugin root from the physical skill location and reuses the shared guides with explicit tool/model/path adaptations. Review those adaptations when a shared workflow changes. See [README.md](README.md#local-install-for-development) for local registration and [LOCAL_TESTING.md](LOCAL_TESTING.md#opencode-discovery) for native discovery checks. - Claude has in-session reload (`claude plugin update` or `/plugin` UI); Codex currently needs a new session and (for manifest changes) a `version` bump in the Codex manifest. - The `version` field must match between `plugins/clp/.claude-plugin/plugin.json` and `plugins/clp/.codex-plugin/plugin.json`. `scripts/validate-codex-plugin.sh` enforces this locally and the release workflow runs it as part of CI, so a tag with version drift will fail the release build. diff --git a/LOCAL_TESTING.md b/LOCAL_TESTING.md index 542df55..1a6daf4 100644 --- a/LOCAL_TESTING.md +++ b/LOCAL_TESTING.md @@ -8,6 +8,22 @@ Everything below runs `./plugins/clp/bin/clp` straight out of the checkout. That Command smoke tests: run `bin/clp` directly from the checkout against a real `clp-s` binary. +## OpenCode discovery + +Register `plugins/clp/skills-opencode/clp` as described in [README.md](README.md#local-install-for-development). Verify with the installed OpenCode version, without making a model call: + +```bash +# OpenCode 1 +opencode debug skill + +# OpenCode 2, using a running server +opencode api GET /api/skill +``` + +The result should contain one `clp` entry whose source is the registered `skills/clp/SKILL.md`, and no entries from this plugin's `skills-claude` or `skills-codex` trees. OpenCode 2 loads skills asynchronously: if the first request starts the server and returns only built-in skills, repeat it once loading finishes. A fresh `--standalone` process for each request can exit before discovery completes. + +Resolve the registered skill directory physically, go up two directories, and run the command-level smoke tests below with that plugin's `bin/clp`. Use a temporary `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, `XDG_CACHE_HOME`, and `XDG_STATE_HOME` to test an isolated installation; supply the same values to the installer and OpenCode. Include an install path containing spaces to check command quoting. + This file does not cover installer testing. The installer and deploy tooling live in the private repository [`y-scope/coding-agent-integration-installer`](https://github.com/y-scope/coding-agent-integration-installer); see its `LOCAL_TESTING.md` for `bun run dev`, `bun run build:binary`, bootstrap invocation, and deploy dry-runs. ## Prerequisites diff --git a/README.md b/README.md index 7189c65..434512a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # YScope CLP Coding-Agent Plugins -Open-source Claude Code and Codex plugins for analyzing logs with [CLP](https://github.com/y-scope/clp) (Compressed Log Processor): compress raw logs or coding-agent sessions, search them with KQL, and write an insights report. +Open-source integrations for Claude Code, Codex, and OpenCode to analyze logs with [CLP](https://github.com/y-scope/clp) (Compressed Log Processor): compress raw logs or coding-agent sessions, search them with KQL, and write an insights report. This repo contains the **plugin payload only**. The compiled installer that ships the `clp-s` binary and the deploy tooling live in a separate private repository. @@ -43,6 +43,8 @@ plugins/clp/skills-claude/ plugins/clp/skills-codex/ Codex skills: compress, compress-folder, search, log-insights, decompress, codex-trajectory. +plugins/clp/skills-opencode/clp/ + OpenCode entry point, using the same commands and analysis guides. scripts/validate-codex-plugin.sh Validates the Codex plugin manifest and SKILL.md frontmatter. @@ -58,7 +60,11 @@ The repository root is the marketplace root for both products. Claude Code reads ## Install -End users install via the compiled installer at `https://installer.yscope.ai/coding-agent-plugin.sh`. The installer and deploy tooling live in the private repository [`y-scope/coding-agent-integration-installer`](https://github.com/y-scope/coding-agent-integration-installer); see its `DEPLOY.md` for build and deploy instructions. +End users install via the compiled installer at `https://installer.yscope.ai/coding-agent-integration/main/install.sh`. The installer and deploy tooling live in the private repository [`y-scope/coding-agent-integration-installer`](https://github.com/y-scope/coding-agent-integration-installer); see its `DEPLOY.md` for build and deploy instructions. OpenCode support requires an installer build and plugin ref that both include the OpenCode target. + +OpenCode loads a native `clp` skill backed by the shared `bin/clp` tools. The installer registers that entry under `${XDG_CONFIG_HOME:-~/.config}/opencode/skills/clp` and installs the payload under `opencode/marketplaces/yscope`. It does not require a Claude Code or Codex installation, or edit `opencode.json`. Restart OpenCode and ask: “Use CLP to analyze the logs in `/path/to/logs`.” + +The host agent and log source are independent: all three integrations can work with system/application logs and supported Claude Code or Codex JSONL histories. Automatic session discovery does not import OpenCode's session database. The specialised session measurements and cross-agent execution graph currently apply to Claude Code records. ### Local install for development @@ -84,6 +90,15 @@ claude --plugin-dir ./plugins/clp See [LOCAL_TESTING.md](LOCAL_TESTING.md) for more on local testing. +For OpenCode development, register only its entry point (the destination must not already exist): + +```bash +mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/opencode/skills" +ln -s "$PWD/plugins/clp/skills-opencode/clp" "${XDG_CONFIG_HOME:-$HOME/.config}/opencode/skills/clp" +``` + +Supply `clp-s` using one of the resolution paths below, then restart OpenCode. The skill resolves its command and shared guides from the checkout even through the symlink. Do not register the whole plugin tree as a skill source: OpenCode 1 would also discover the Claude and Codex skills nested inside it. + ## The `clp` command `bin/clp` is the only command in the plugin. Its first argument is either a subcommand or a target to analyse: diff --git a/plugins/clp/.claude-plugin/plugin.json b/plugins/clp/.claude-plugin/plugin.json index 2707ec1..c684116 100644 --- a/plugins/clp/.claude-plugin/plugin.json +++ b/plugins/clp/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "clp", "displayName": "CLP", - "version": "0.25.0", + "version": "0.26.0", "description": "Analyze logs with CLP: compress raw logs or Claude Code and Codex sessions, search them with KQL, and write an insights report.", "skills": "./skills-claude/", "author": { diff --git a/plugins/clp/.codex-plugin/plugin.json b/plugins/clp/.codex-plugin/plugin.json index 7cdb632..22afbdb 100644 --- a/plugins/clp/.codex-plugin/plugin.json +++ b/plugins/clp/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "clp", - "version": "0.25.0", + "version": "0.26.0", "description": "Analyze logs with CLP: compress raw logs or Claude Code and Codex sessions, search them with KQL, and write an insights report.", "author": { "name": "YScope" diff --git a/plugins/clp/README.md b/plugins/clp/README.md index 93546fa..c1fc786 100644 --- a/plugins/clp/README.md +++ b/plugins/clp/README.md @@ -2,6 +2,8 @@ Plugin for analyzing logs with [CLP](https://github.com/y-scope/clp) (Compressed Log Processor): compress raw logs or Claude Code and Codex sessions, search them with KQL, and write an insights report. +Runs in Claude Code, Codex, and OpenCode. OpenCode uses `skills-opencode/clp/SKILL.md` as its native entry point, backed by the same `bin/clp` command and shared analysis guides. See the repository [installation instructions](../../README.md#install). OpenCode is a supported host; importing its own session database is not implemented. + CLP is the open-source platform for log archive storage, search, and analytics. Pre-release builds may also include licensed YScope extensions. ## API Surface @@ -28,8 +30,9 @@ It does not expose reducers, network/file output handlers, results-cache writes, | `analyze-logs` | The one entry point for log analysis. `clp TARGET` identifies which application wrote the logs and reports the route; the skill follows it. Specialised route (a Claude Code session): end-to-end session analysis over the bundle, checking seven lightly pre-trained areas, with optional 0–10 scoring. General route (anything else): trained on the spot, driven by the archive's log shape dictionary — dump the templates, classify them (cached), then run targeted queries derived from templates that are known to exist. | | `decompress` | Decompress a CLP archive directory for raw inspection. | | `codex-trajectory` | Same workflow for Codex session logs, plus Codex-specific query starters. | +| `clp` (OpenCode) | Log and session analysis, compression, search, and decompression using the shared commands and guides with OpenCode tool and model conventions. | -Future use-cases will add their own skill directories under `skills-claude/` (or `skills-codex/` if the use-case is agent-specific). +Shared analysis changes belong in the existing guides; review the OpenCode adapter when changing host-specific tools, models, paths, or publishing behavior. ## Writing guide @@ -42,7 +45,7 @@ Only the report's shape lives in `skills-claude/references/report-style.md`: the Hosted installer: ```bash -curl -fsSL https://installer.yscope.ai/coding-agent-plugin.sh | bash +curl -fsSL https://installer.yscope.ai/coding-agent-integration/main/install.sh | bash ``` Local marketplace: diff --git a/plugins/clp/skills-opencode/clp/SKILL.md b/plugins/clp/skills-opencode/clp/SKILL.md new file mode 100644 index 0000000..6c5de5e --- /dev/null +++ b/plugins/clp/skills-opencode/clp/SKILL.md @@ -0,0 +1,62 @@ +--- +name: clp +description: Analyze system and application logs and Claude Code or Codex session histories with CLP. Use for log investigations, session debugging, usage questions, compression, KQL search, and decompression of local archives. +--- + +# CLP in OpenCode + +Use the shared CLP commands to prepare logs, query compressed archives, and support findings with retrievable records. OpenCode is the host for this skill; it does not determine the format of the logs. Session discovery supports Claude Code and Codex JSONL histories, not OpenCode's session database. + +## Locate the command + +The directory containing this loaded `SKILL.md` is `skills-opencode/clp/` inside the CLP plugin. Resolve that directory's symlinks first, then go up two directories to obtain the plugin root. OpenCode supplies the skill's base directory when loading it. Use that location, never the current project directory or a Claude/Codex installation. + +For example, replacing the example path with the loaded skill's actual base directory: + +```bash +CLP_PLUGIN_ROOT="$(cd -P "/absolute/path/to/loaded/clp/../.." && pwd)" +"${CLP_PLUGIN_ROOT}/bin/clp" --help +``` + +Use the resolved absolute path in subsequent tool calls; shell variables do not necessarily persist between calls. All operations go through `bin/clp`; do not invoke `clp-s` or internal Python modules directly. The installer supplies the engine beside the command. If a command fails, report its error and exit code. Do not silently install dependencies or change configuration. + +## Choose the workflow + +For a specific question, run only the preparation and queries it needs. For an investigation or report, use the full analysis workflow below. Honor the user's requested scope, report depth, and output destination. + +**Find a session.** When the user has not supplied a path or session ID, list available sessions: + +```bash +"${CLP_PLUGIN_ROOT}/bin/clp" list-sessions +``` + +Present the index, source agent, timestamp, size, session name, project, and session ID; let the user choose. Retain the printed selection manifest. `--agent claude` or `--agent codex` restricts the source. A session index is not a session ID. + +**Prepare and analyze.** Pass the selected log path, session ID, log folder, CLP archive, or session bundle to the router: + +```bash +"${CLP_PLUGIN_ROOT}/bin/clp" /absolute/path/to/logs +``` + +Read `APP`, `ROUTE`, `ARCHIVE`, `BUNDLE`, `NEXT`, and the classification evidence in its output. The router reuses prepared archives and gathers neighboring subagent/workflow files for a Claude Code session. Do not separately compress the main log first. Do not execute output as shell code. + +For a full investigation, read `skills-claude/analyze-logs/SKILL.md` relative to the resolved plugin root and follow the route it names. Its reference documents and commands are shared with this integration. Apply the OpenCode adaptations below before following it. `ROUTE=specialised` supplies Claude Code session measurements and task relationships; `ROUTE=general` discovers fields and string shapes for other logs, including Codex. Never apply Claude-specific measurement or counting rules to another application's records. + +**Compress, search, or decompress only.** Read the corresponding shared guide under `skills-claude/compress/`, `skills-claude/compress-folder/`, `skills-claude/search/`, or `skills-claude/decompress/` (`SKILL.md` in each), applying the same adaptations. For Codex-specific fields and counting caveats, read `skills-codex/codex-trajectory/SKILL.md` as a reference, using this installation's command path. + +## OpenCode adaptations for shared guides + +These rules replace host-specific instructions in the shared guides; their analysis and evidence rules still apply. + +- Replace every `${CLAUDE_PLUGIN_ROOT}` and hard-coded `~/.codex/marketplaces/yscope/plugins/clp` prefix with the resolved plugin root. Translate references to another CLP skill into reading its file here; Claude's `/clp:...` commands are not OpenCode commands. +- Use OpenCode's shell and file-reading tools for `Bash` and file reads. Shared frontmatter lists Claude tools, not permissions for OpenCode. Respect the active OpenCode permissions. +- Use the available question tool for `AskUserQuestion`, or ask in conversation. Preserve answers already given. In a noninteractive run, use the documented defaults. +- Use OpenCode's task tool and configured agent/model for the limited classification, extras, or report-writing tasks the workflow calls for. Do not request Claude-specific `opus` or `sonnet` aliases. If delegation is unavailable or prohibited, perform those steps in the main agent with the same evidence rules. Pass resolved command and reference paths to any delegated task. +- If background execution or monitoring is unavailable, run the query pools sequentially. Collect the focus and close the inbox with `clp focus` before starting a pool that waits on it; otherwise a foreground pool can wait for an answer the agent cannot request. +- Save reports locally through `clp report save`, passing the report path explicitly. Offer only formats returned by `clp report save --list-formats`. Claude Artifact publishing is unavailable unless an equivalent publishing tool is explicitly present and the user requests it. + +## Keep answers checkable and context small + +Read `skills-claude/references/evidence-tiers.md` before reporting measurements. Inspect the schema and string shapes, then query fields and patterns that actually exist. Count with `clp search --count`, project only necessary columns with `--projection`, and bound retrieval. Use `--tge` and `--tle` with epoch milliseconds for time ranges. Avoid flooding the model with full records. + +Keep observations separate from inferred causes. Cite archive/bundle paths, queries, record IDs, and time windows so a finding can be checked. Distinguish missing data from zero, cumulative token counters from per-event usage, and overlapping agent time from wall-clock time. Preserve the facts and query results alongside any report for follow-up questions.