@mainwave/cli 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,65 +1,64 @@
1
1
  # @mainwave/cli
2
2
 
3
- Setup wizard for connecting third-party coding tools to [Mainwave AI](https://mainwave.com).
3
+ Setup wizard that connects third-party coding tools to [Mainwave AI](https://mainwave.com), so their
4
+ OpenTelemetry traces land in your dashboard tagged to a use case.
4
5
 
5
- Installs as the `mainwave-cli` command.
6
+ Installs as the `mainwave-cli` command. Requires Node 20 or newer.
6
7
 
7
- ## Use
8
+ ## Supported tools
8
9
 
9
- ```bash
10
- npx @mainwave/cli setup claude-code
11
- ```
10
+ | Adapter | Tool |
11
+ | -------------- | ------------------------------ |
12
+ | `claude-code` | Claude Code |
13
+ | `codex` | Codex CLI |
14
+ | `copilot-cli` | GitHub Copilot CLI |
15
+ | `copilot-chat` | GitHub Copilot Chat in VS Code |
12
16
 
13
- The wizard collects a use-case id, collector URL, API key, and sensitive-data
14
- opt-ins, then writes a Claude-Code-shaped `env` block to `.claude/settings.json`
15
- and validates that the configuration authenticates against the configured
16
- collector.
17
-
18
- To inspect the current state without changing anything:
17
+ ## Setup
19
18
 
20
19
  ```bash
21
- npx @mainwave/cli doctor claude-code # static report
22
- npx @mainwave/cli doctor claude-code --validate # also check auth against collector
20
+ npx @mainwave/cli setup claude-code
23
21
  ```
24
22
 
25
- `doctor` walks the full Claude Code settings hierarchy (managed → project-local
26
- → project → user), prints the effective env block tagged by source, and runs
27
- health checks for known gotchas (kill-switches in shell env, missing trace
28
- beta flag, managed-tier overrides).
23
+ The wizard prompts for a use-case id, collector URL, API key, and sensitive-data opt-ins, writes the
24
+ configuration in the format that tool expects, and checks that it authenticates against your
25
+ collector before exiting.
29
26
 
30
- Run `mainwave-cli --help` for the full command list and the coding tools currently supported.
27
+ Re-run it any time. Existing values pre-fill the prompts, and opting back out of a setting removes it
28
+ rather than leaving it stale.
31
29
 
32
- ## Develop
30
+ ## Other commands
33
31
 
34
32
  ```bash
35
- make install # pnpm install
36
- make ready # format-check + lint + typecheck + tests
37
- make build # tsc → dist/
33
+ mainwave-cli status [<adapter>] # on-disk config for every tool, or just one
34
+ mainwave-cli doctor <adapter> # settings hierarchy + health checks
35
+ mainwave-cli doctor <adapter> --validate # also auth-check against the collector
36
+ mainwave-cli edit <adapter> # open the settings file in $EDITOR
37
+ mainwave-cli env <adapter> # print shell export lines
38
+ mainwave-cli --help
38
39
  ```
39
40
 
40
- Node 20+ is required at runtime.
41
+ `doctor` walks the tool's full settings hierarchy (managed → project-local → project → user), prints
42
+ the effective configuration tagged by which file each value came from, and flags the gotchas that
43
+ silently drop telemetry — a kill-switch set in your shell environment, a missing endpoint, or a
44
+ managed-tier policy overriding what you just wrote.
41
45
 
42
- ### Try it locally
43
-
44
- Two ways to run the wizard against your dev collector before publishing.
45
-
46
- **Symlink onto your PATH (best for iteration):**
46
+ Some tools read their configuration from the environment rather than from a file. For those, `env`
47
+ prints the export lines to source:
47
48
 
48
49
  ```bash
49
- cd clients/cli
50
- pnpm build
51
- pnpm link --global # one-time; exposes `mainwave-cli` globally
52
- cd ~/some-other-folder
53
- mainwave-cli setup claude-code
50
+ eval "$(mainwave-cli env copilot-cli)"
54
51
  ```
55
52
 
56
- Subsequent edits only need `pnpm build` — the symlink keeps pointing at `dist/`, so the rebuild is picked up automatically. Remove with `pnpm rm -g @mainwave/cli`.
53
+ ## Where your API key ends up
57
54
 
58
- **Direct invocation, no install:**
55
+ The file the wizard writes contains your API key in plain text, so it is created with `0600`
56
+ permissions. If you pick repo-local scope, that file lands inside your repository — the wizard
57
+ deliberately never edits your `.gitignore`, so excluding it is your call.
59
58
 
60
- ```bash
61
- cd clients/cli && pnpm build
62
- node /full/path/to/clients/cli/dist/cli.js setup claude-code
63
- ```
59
+ Not every tool accepts credentials from a repo-local file. Where that applies, the wizard says so at
60
+ the scope prompt and defaults you to a user-global location instead.
61
+
62
+ ## License
64
63
 
65
- Works from any cwd; no global state.
64
+ Apache-2.0
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mainwave/cli",
3
- "version": "0.0.0",
3
+ "version": "0.1.0",
4
4
  "description": "Setup wizard for connecting third-party coding tools to Mainwave AI.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "mainwave-cli": "./dist/cli.js"
7
+ "mainwave-cli": "dist/cli.js"
8
8
  },
9
9
  "files": [
10
10
  "dist",
@@ -58,7 +58,7 @@
58
58
  "license": "Apache-2.0",
59
59
  "repository": {
60
60
  "type": "git",
61
- "url": "https://github.com/mainwaveai/mainwave.git",
61
+ "url": "git+https://github.com/mainwaveai/mainwave.git",
62
62
  "directory": "clients/cli"
63
63
  }
64
64
  }
@@ -1,155 +0,0 @@
1
- /**
2
- * JSONC codec for tools whose settings file allows comments and trailing
3
- * commas — GitHub Copilot CLI's `~/.copilot/settings.json` and VS Code's
4
- * `settings.json`. Both upstream sources officially declare JSONC.
5
- *
6
- * The flat env-record exposed to the wizard is the top-level string-valued
7
- * keys of the document. Object/array/number/boolean values are preserved
8
- * verbatim on round-trip but are not surfaced to `readEnv` (they're not
9
- * env-style configuration). Comments are dropped on first re-serialize —
10
- * matches how VS Code's own settings editor behaves. Document this in the
11
- * adapter when adopting this codec.
12
- *
13
- * No new runtime deps: hand-rolled comment / trailing-comma stripper sits
14
- * in front of `JSON.parse`. The stripper is string-state aware so `//` or
15
- * `/* *\/` inside a JSON string is preserved.
16
- */
17
- const isPlainObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
18
- /**
19
- * Removes line comments (`// ...`), block comments (`/* ... *\/`), and
20
- * trailing commas before `}` / `]`. String contents are passed through
21
- * verbatim so `"//"` or `","` inside a string survives unmangled. Escape
22
- * sequences (`\"`, `\\`) are honored when scanning strings.
23
- */
24
- const stripJsonc = (input) => {
25
- const stripComments = (src) => {
26
- let out = '';
27
- let i = 0;
28
- const n = src.length;
29
- while (i < n) {
30
- const ch = src[i];
31
- if (ch === '"') {
32
- out += ch;
33
- i++;
34
- while (i < n) {
35
- const c = src[i];
36
- if (c === '\\' && i + 1 < n) {
37
- out += c + src[i + 1];
38
- i += 2;
39
- continue;
40
- }
41
- out += c;
42
- i++;
43
- if (c === '"')
44
- break;
45
- }
46
- continue;
47
- }
48
- if (ch === '/' && i + 1 < n) {
49
- const next = src[i + 1];
50
- if (next === '/') {
51
- i += 2;
52
- while (i < n && src[i] !== '\n')
53
- i++;
54
- continue;
55
- }
56
- if (next === '*') {
57
- i += 2;
58
- while (i < n - 1 && !(src[i] === '*' && src[i + 1] === '/'))
59
- i++;
60
- i += 2;
61
- continue;
62
- }
63
- }
64
- out += ch;
65
- i++;
66
- }
67
- return out;
68
- };
69
- const stripTrailingCommas = (src) => {
70
- let out = '';
71
- let i = 0;
72
- const n = src.length;
73
- while (i < n) {
74
- const ch = src[i];
75
- if (ch === '"') {
76
- out += ch;
77
- i++;
78
- while (i < n) {
79
- const c = src[i];
80
- if (c === '\\' && i + 1 < n) {
81
- out += c + src[i + 1];
82
- i += 2;
83
- continue;
84
- }
85
- out += c;
86
- i++;
87
- if (c === '"')
88
- break;
89
- }
90
- continue;
91
- }
92
- if (ch === ',') {
93
- let j = i + 1;
94
- while (j < n && (src[j] === ' ' || src[j] === '\t' || src[j] === '\n' || src[j] === '\r')) {
95
- j++;
96
- }
97
- if (j < n && (src[j] === '}' || src[j] === ']')) {
98
- i++;
99
- continue;
100
- }
101
- }
102
- out += ch;
103
- i++;
104
- }
105
- return out;
106
- };
107
- return stripTrailingCommas(stripComments(input));
108
- };
109
- const parse = (body, path) => {
110
- const stripped = stripJsonc(body);
111
- let parsed;
112
- try {
113
- parsed = JSON.parse(stripped);
114
- }
115
- catch (err) {
116
- throw new Error(`failed to parse ${path} as JSONC: ${err.message}`);
117
- }
118
- if (!isPlainObject(parsed)) {
119
- throw new Error(`expected ${path} to contain a JSON object at the top level`);
120
- }
121
- return parsed;
122
- };
123
- const serialize = (doc) => JSON.stringify(doc, null, 2) + '\n';
124
- const empty = () => ({});
125
- const readEnv = (doc) => {
126
- if (!isPlainObject(doc)) {
127
- throw new Error('expected the top-level value to be a JSON object');
128
- }
129
- const out = {};
130
- for (const [k, v] of Object.entries(doc)) {
131
- if (typeof v === 'string')
132
- out[k] = v;
133
- }
134
- return out;
135
- };
136
- const applyEnv = (doc, newEnv, managedKeys) => {
137
- const base = isPlainObject(doc) ? { ...doc } : {};
138
- for (const key of managedKeys) {
139
- if (key in base)
140
- delete base[key];
141
- }
142
- for (const [k, v] of Object.entries(newEnv)) {
143
- base[k] = v;
144
- }
145
- return base;
146
- };
147
- export const jsoncSettingsCodec = {
148
- format: 'json',
149
- parse,
150
- serialize,
151
- empty,
152
- readEnv,
153
- applyEnv,
154
- };
155
- //# sourceMappingURL=jsonc-settings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonc-settings.js","sourceRoot":"","sources":["../../../src/core/codecs/jsonc-settings.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,aAAa,GAAG,CAAC,CAAU,EAAgC,EAAE,CACjE,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3C,MAAM,aAAa,GAAG,CAAC,GAAW,EAAU,EAAE;QAC5C,IAAI,GAAG,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAA;QACpB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACb,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAE,CAAA;YAClB,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;gBACf,GAAG,IAAI,EAAE,CAAA;gBACT,CAAC,EAAE,CAAA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