Skip to content

Commit f9aefc9

Browse files
authored
Merge pull request #6 from comet-ml/feat/opik-cc-workspace-override
feat: plugin-scoped workspace & project overrides (cc_workspace / cc_project)
2 parents 0769c40 + 19bbfdd commit f9aefc9

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,28 @@ This creates `~/.opik.config` with your API URL, key, and workspace.
5757

5858
```bash
5959
export OPIK_CC_PROJECT="my-project" # Project name (default: claude-code)
60+
export OPIK_CC_WORKSPACE="my-workspace" # Workspace override (default: OPIK_WORKSPACE / ~/.opik.config)
6061
export OPIK_CC_TRUNCATE_FIELDS="false" # Don't truncate large fields
6162
```
6263

6364
All plugin env vars use the `OPIK_CC_` prefix to avoid conflicts with standard Opik SDK variables.
6465

66+
`OPIK_CC_WORKSPACE` and `OPIK_CC_PROJECT` let you send Claude Code traces to a different
67+
workspace/project than the rest of your Opik setup, without touching the global
68+
`OPIK_WORKSPACE` / `project_name` in `~/.opik.config` used by the Opik SDK. Both can also be
69+
set in `~/.opik.config` via the plugin-scoped `cc_workspace` and `cc_project` keys:
70+
71+
```ini
72+
[opik]
73+
workspace = my-sdk-workspace # used by the Opik SDK
74+
project_name = my-sdk-project # used by the Opik SDK
75+
cc_workspace = my-cc-workspace # used only by the Claude Code plugin
76+
cc_project_name = my-cc-project # used only by the Claude Code plugin
77+
```
78+
79+
> Note: for backward compatibility, if `cc_project_name` is not set the plugin still falls back
80+
> to the shared `project_name` key.
81+
6582
### External Trace Linking
6683

6784
Link Claude Code sessions to existing Opik traces (useful for embedding Claude Code in larger workflows):

src/config.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,19 @@ func LoadConfig() (*Config, error) {
4747
RootSpanID: os.Getenv("OPIK_CC_ROOT_SPAN_ID"),
4848
}
4949

50-
if proj := getEnvOrConfig("OPIK_CC_PROJECT", fileConfig, "project_name"); proj != "" {
50+
// OPIK_CC_PROJECT / cc_project are plugin-scoped and don't affect the Opik
51+
// SDK. project_name is kept as a fallback for backward compatibility, but it
52+
// is shared with the Opik SDK config in ~/.opik.config.
53+
if proj := getEnvOrConfig("OPIK_CC_PROJECT", fileConfig, "cc_project_name"); proj != "" {
5154
cfg.Project = proj
55+
} else if proj := fileConfig["project_name"]; proj != "" {
56+
cfg.Project = proj
57+
}
58+
59+
// Allow overriding the workspace for the Claude Code plugin only, without
60+
// affecting the global OPIK_WORKSPACE / ~/.opik.config used by the Opik SDK.
61+
if ws := getEnvOrConfig("OPIK_CC_WORKSPACE", fileConfig, "cc_workspace"); ws != "" {
62+
cfg.Workspace = ws
5263
}
5364

5465
return cfg, nil

0 commit comments

Comments
 (0)