@mainwave/cli 0.7.1 → 0.8.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 +4 -1
- package/dist/adapters/claude-code.js +10 -3
- package/dist/adapters/claude-desktop.js +0 -1
- package/dist/adapters/codex-cli.js +0 -1
- package/dist/adapters/copilot-chat.js +0 -1
- package/dist/adapters/copilot-cli.js +0 -1
- package/dist/adapters/cursor-enterprise.js +0 -1
- package/dist/adapters/cursor.js +13 -2
- package/dist/adapters/index.js +0 -1
- package/dist/adapters/types.js +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/types.gen.js +0 -1
- package/dist/cli.js +0 -1
- package/dist/core/apply.js +0 -1
- package/dist/core/auth-commands.js +0 -1
- package/dist/core/behaviour-hooks.js +0 -1
- package/dist/core/browser.js +0 -1
- package/dist/core/codecs/cursor-hooks-json.js +0 -1
- package/dist/core/codecs/env-file.js +0 -1
- package/dist/core/codecs/json-env.js +0 -1
- package/dist/core/codecs/json-flat.js +0 -1
- package/dist/core/codecs/json-managed.js +0 -1
- package/dist/core/codecs/toml-otel.js +0 -1
- package/dist/core/codecs/types.js +0 -1
- package/dist/core/detect.js +0 -1
- package/dist/core/device-login.js +0 -1
- package/dist/core/doctor.js +19 -1
- package/dist/core/edit.js +9 -5
- package/dist/core/effective-settings.js +61 -20
- package/dist/core/env-command.js +0 -1
- package/dist/core/errors.js +0 -1
- package/dist/core/flags.js +0 -1
- package/dist/core/format.js +0 -1
- package/dist/core/git.js +0 -1
- package/dist/core/headers.js +0 -1
- package/dist/core/install-hooks.js +3 -3
- package/dist/core/interview.js +0 -1
- package/dist/core/keys.js +0 -1
- package/dist/core/layer-policy.js +2 -1
- package/dist/core/markers.js +170 -15
- package/dist/core/pinned-use-case.js +0 -1
- package/dist/core/platform.js +0 -1
- package/dist/core/post-setup.js +0 -1
- package/dist/core/prompts.js +0 -1
- package/dist/core/settings.js +16 -3
- package/dist/core/skills.js +5 -2
- package/dist/core/status.js +5 -4
- package/dist/core/store.js +0 -1
- package/dist/core/tty.js +0 -1
- package/dist/core/ucid.js +0 -1
- package/dist/core/ui.js +0 -1
- package/dist/core/use-case.js +0 -1
- package/dist/core/validate.js +0 -1
- package/dist/core/verify.js +0 -1
- package/dist/core/version.js +0 -1
- package/dist/core/wizard.js +3 -7
- package/dist/main.js +0 -1
- package/hooks/cursor-otlp.mjs +13 -15
- package/hooks/github-pr-marker.mjs +22 -11
- package/hooks/jira-ticket-marker.mjs +9 -9
- package/hooks/linear-ticket-marker.mjs +9 -7
- package/hooks/managed-entry.mjs +42 -0
- package/hooks/marker-core.mjs +123 -29
- package/package.json +4 -3
- package/skills/mainwave-instrument-node/SKILL.md +420 -0
- package/skills/mainwave-instrument-node/reference/api.md +96 -0
- package/skills/mainwave-instrument-node/reference/frameworks.md +82 -0
- package/skills/mainwave-instrument-node/reference/troubleshooting.md +152 -0
- package/dist/adapters/claude-code.js.map +0 -1
- package/dist/adapters/claude-desktop.js.map +0 -1
- package/dist/adapters/codex-cli.js.map +0 -1
- package/dist/adapters/copilot-chat.js.map +0 -1
- package/dist/adapters/copilot-cli.js.map +0 -1
- package/dist/adapters/cursor-enterprise.js.map +0 -1
- package/dist/adapters/cursor.js.map +0 -1
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/types.js.map +0 -1
- package/dist/api/index.js.map +0 -1
- package/dist/api/types.gen.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/core/apply.js.map +0 -1
- package/dist/core/auth-commands.js.map +0 -1
- package/dist/core/behaviour-hooks.js.map +0 -1
- package/dist/core/browser.js.map +0 -1
- package/dist/core/codecs/cursor-hooks-json.js.map +0 -1
- package/dist/core/codecs/env-file.js.map +0 -1
- package/dist/core/codecs/json-env.js.map +0 -1
- package/dist/core/codecs/json-flat.js.map +0 -1
- package/dist/core/codecs/json-managed.js.map +0 -1
- package/dist/core/codecs/toml-otel.js.map +0 -1
- package/dist/core/codecs/types.js.map +0 -1
- package/dist/core/detect.js.map +0 -1
- package/dist/core/device-login.js.map +0 -1
- package/dist/core/doctor.js.map +0 -1
- package/dist/core/edit.js.map +0 -1
- package/dist/core/effective-settings.js.map +0 -1
- package/dist/core/env-command.js.map +0 -1
- package/dist/core/errors.js.map +0 -1
- package/dist/core/flags.js.map +0 -1
- package/dist/core/format.js.map +0 -1
- package/dist/core/git.js.map +0 -1
- package/dist/core/headers.js.map +0 -1
- package/dist/core/install-hooks.js.map +0 -1
- package/dist/core/interview.js.map +0 -1
- package/dist/core/keys.js.map +0 -1
- package/dist/core/layer-policy.js.map +0 -1
- package/dist/core/markers.js.map +0 -1
- package/dist/core/pinned-use-case.js.map +0 -1
- package/dist/core/platform.js.map +0 -1
- package/dist/core/post-setup.js.map +0 -1
- package/dist/core/prompts.js.map +0 -1
- package/dist/core/settings.js.map +0 -1
- package/dist/core/skills.js.map +0 -1
- package/dist/core/status.js.map +0 -1
- package/dist/core/store.js.map +0 -1
- package/dist/core/tty.js.map +0 -1
- package/dist/core/ucid.js.map +0 -1
- package/dist/core/ui.js.map +0 -1
- package/dist/core/use-case.js.map +0 -1
- package/dist/core/validate.js.map +0 -1
- package/dist/core/verify.js.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/core/wizard.js.map +0 -1
- package/dist/main.js.map +0 -1
package/README.md
CHANGED
|
@@ -147,12 +147,15 @@ flag it needed. `status` and `doctor` also take `--json`.
|
|
|
147
147
|
|
|
148
148
|
## Agent skills
|
|
149
149
|
|
|
150
|
-
Setup installs
|
|
150
|
+
Setup installs three skills alongside the telemetry config — one detection, one pass, two outputs:
|
|
151
151
|
|
|
152
152
|
- **`mainwave-setup`** — lets your coding agent run this whole flow itself: sign in, configure a
|
|
153
153
|
tool, verify. It knows the flags, so you can just ask it to connect you.
|
|
154
154
|
- **`mainwave-instrument`** — wires the `mainwave` Python SDK into an application, so an agent or
|
|
155
155
|
service of your own reports runs, tokens, and cost.
|
|
156
|
+
- **`mainwave-instrument-node`** — wires the `@mainwave/sdk` Node.js SDK into a Node or TypeScript
|
|
157
|
+
application (eve, the Vercel AI SDK, OpenAI, Anthropic), so it reports runs, tokens, and cost.
|
|
158
|
+
Your agent picks it for a Node repository and `mainwave-instrument` for a Python one.
|
|
156
159
|
|
|
157
160
|
The bundles are copied to `~/.mainwave/skills/`, then registered on each tool's own instruction
|
|
158
161
|
surface: a native skill directory for Claude Code, `AGENTS.md` for Codex, `copilot-instructions.md`
|
|
@@ -278,13 +278,20 @@ const isManagedTelemetryUnitKey = (key) => key.startsWith('OTEL_EXPORTER_OTLP_')
|
|
|
278
278
|
key === 'OTEL_LOGS_EXPORTER' ||
|
|
279
279
|
key === 'ENABLE_BETA_TRACING_DETAILED' ||
|
|
280
280
|
key === 'BETA_TRACING_ENDPOINT';
|
|
281
|
+
const OTEL_HEADERS_HELPER = 'otelHeadersHelper';
|
|
282
|
+
const claimsManagedTelemetryUnit = (settings) => {
|
|
283
|
+
const helper = settings[OTEL_HEADERS_HELPER];
|
|
284
|
+
return typeof helper === 'string' && helper.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/g, '') !== ''
|
|
285
|
+
? OTEL_HEADERS_HELPER
|
|
286
|
+
: undefined;
|
|
287
|
+
};
|
|
281
288
|
const TRUTHY = new Set(['1', 'true', 'yes', 'on']);
|
|
282
289
|
const OTLP = 'OTEL_EXPORTER_OTLP_';
|
|
283
290
|
const OTLP_SIGNALS = ['TRACES', 'METRICS', 'LOGS'];
|
|
284
291
|
const OTLP_CREDENTIALS = ['HEADERS', 'CLIENT_KEY', 'CLIENT_CERTIFICATE'];
|
|
285
292
|
const perSignal = (suffix) => OTLP_SIGNALS.map((s) => `${OTLP}${s}_${suffix}`);
|
|
286
293
|
const OFF_SELECTOR_VALUES = new Set(['none', 'console', '']);
|
|
287
|
-
const isManagedLockedKey = (key, managed) => {
|
|
294
|
+
const isManagedLockedKey = (key, managed, unitClaim) => {
|
|
288
295
|
const set = (k) => (managed[k] ?? '') !== '';
|
|
289
296
|
if (set(`${OTLP}ENDPOINT`) && perSignal('ENDPOINT').includes(key))
|
|
290
297
|
return true;
|
|
@@ -315,7 +322,7 @@ const isManagedLockedKey = (key, managed) => {
|
|
|
315
322
|
const signalOff = ['OTEL_LOGS_EXPORTER', 'OTEL_TRACES_EXPORTER'].some((k) => k in managed && OFF_SELECTOR_VALUES.has(managed[k].trim().toLowerCase()));
|
|
316
323
|
const telemetryOff = 'CLAUDE_CODE_ENABLE_TELEMETRY' in managed &&
|
|
317
324
|
!TRUTHY.has(managed.CLAUDE_CODE_ENABLE_TELEMETRY.trim().toLowerCase());
|
|
318
|
-
return decides || signalOff || telemetryOff;
|
|
325
|
+
return decides || unitClaim === OTEL_HEADERS_HELPER || signalOff || telemetryOff;
|
|
319
326
|
}
|
|
320
327
|
return false;
|
|
321
328
|
};
|
|
@@ -418,6 +425,7 @@ export const claudeCode = {
|
|
|
418
425
|
hierarchy: HIERARCHY,
|
|
419
426
|
layerKeyPolicy: CLAUDE_CODE_LAYER_POLICY,
|
|
420
427
|
managedUnitKey: isManagedTelemetryUnitKey,
|
|
428
|
+
managedUnitClaim: claimsManagedTelemetryUnit,
|
|
421
429
|
managedLock: isManagedLockedKey,
|
|
422
430
|
inactiveLayers: (env) => serverManagedBypassed(env)
|
|
423
431
|
? [
|
|
@@ -441,4 +449,3 @@ export const claudeCode = {
|
|
|
441
449
|
disclosure: 'Sends Linear/Jira issue ids and GitHub PR urls to the collector — never ticket bodies or diff content.',
|
|
442
450
|
},
|
|
443
451
|
};
|
|
444
|
-
//# sourceMappingURL=claude-code.js.map
|
package/dist/adapters/cursor.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import { homedir } from 'node:os';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import { cursorHooksJsonCodec } from '../core/codecs/cursor-hooks-json.js';
|
|
@@ -5,6 +6,7 @@ import { envFileCodec } from '../core/codecs/env-file.js';
|
|
|
5
6
|
import { hasBinary, hasPath } from '../core/detect.js';
|
|
6
7
|
import { buildHeaders, HEADER_NAME, headerBearerToken, kvPairsHeaders } from '../core/headers.js';
|
|
7
8
|
import { buildHookCommand, installedHooksDir } from '../core/markers.js';
|
|
9
|
+
import { isSamePath } from '../core/settings.js';
|
|
8
10
|
import { VERSION } from '../core/version.js';
|
|
9
11
|
const SOURCE_VALUE = 'coding_agent.cursor';
|
|
10
12
|
const CONFIG_MANAGED_KEYS = ['OTEL_EXPORTER_OTLP_ENDPOINT', 'OTEL_EXPORTER_OTLP_HEADERS'];
|
|
@@ -107,9 +109,17 @@ const hooksWrite = {
|
|
|
107
109
|
},
|
|
108
110
|
};
|
|
109
111
|
const HIERARCHY = [
|
|
110
|
-
{ id: 'projectLocal', label: 'Project (local)', path: CONFIG_LOCAL, kind: 'file' },
|
|
111
112
|
{ id: 'user', label: 'User (global)', path: CONFIG_GLOBAL, kind: 'file' },
|
|
112
113
|
];
|
|
114
|
+
const LOCAL_IGNORED = `The Cursor hook ignores ${CONFIG_LOCAL}: it reads only ~/.mainwave/cursor.env`;
|
|
115
|
+
const collectFileChecks = () => !isSamePath(CONFIG_LOCAL, CONFIG_GLOBAL) && existsSync(CONFIG_LOCAL)
|
|
116
|
+
? [
|
|
117
|
+
{
|
|
118
|
+
level: 'warn',
|
|
119
|
+
message: `${LOCAL_IGNORED}, so this file has no effect. Remove it.`,
|
|
120
|
+
},
|
|
121
|
+
]
|
|
122
|
+
: [];
|
|
113
123
|
export const cursor = {
|
|
114
124
|
name: 'cursor',
|
|
115
125
|
displayName: 'Cursor',
|
|
@@ -122,6 +132,7 @@ export const cursor = {
|
|
|
122
132
|
paths: {
|
|
123
133
|
local: CONFIG_LOCAL,
|
|
124
134
|
global: CONFIG_GLOBAL,
|
|
135
|
+
localIgnored: LOCAL_IGNORED,
|
|
125
136
|
},
|
|
126
137
|
runInstruction: 'cursor (restart any open window so the hooks reload)',
|
|
127
138
|
detect: () => hasPath(join(homedir(), '.cursor')) || hasBinary('cursor'),
|
|
@@ -131,6 +142,7 @@ export const cursor = {
|
|
|
131
142
|
buildEnv,
|
|
132
143
|
parseEnv,
|
|
133
144
|
collectChecks,
|
|
145
|
+
collectFileChecks,
|
|
134
146
|
normalizeForGenericChecks,
|
|
135
147
|
additionalWrites: [hooksWrite],
|
|
136
148
|
bundledHookScripts: ['marker-core.mjs', 'vocabulary.mjs', 'cursor-otlp.mjs'],
|
|
@@ -140,4 +152,3 @@ export const cursor = {
|
|
|
140
152
|
script: 'cursor-otlp.mjs',
|
|
141
153
|
},
|
|
142
154
|
};
|
|
143
|
-
//# sourceMappingURL=cursor.js.map
|
package/dist/adapters/index.js
CHANGED
package/dist/adapters/types.js
CHANGED
package/dist/api/index.js
CHANGED
package/dist/api/types.gen.js
CHANGED
package/dist/cli.js
CHANGED
package/dist/core/apply.js
CHANGED
package/dist/core/browser.js
CHANGED
package/dist/core/detect.js
CHANGED
package/dist/core/doctor.js
CHANGED
|
@@ -283,6 +283,25 @@ const collectIssues = (effective, adapter, secondary = {}) => {
|
|
|
283
283
|
"collector they didn't choose.",
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
|
+
const claim = effective.unitClaim;
|
|
287
|
+
if (claim) {
|
|
288
|
+
const where = `${claim.scan.layer.label} (${claim.scan.path})`;
|
|
289
|
+
issues.push(claim.lands
|
|
290
|
+
? {
|
|
291
|
+
level: adapter.markers ? 'warn' : 'info',
|
|
292
|
+
message: `${where} sets ${claim.setting}, so ${adapter.displayName} generates its OTLP headers ` +
|
|
293
|
+
'with that command.' +
|
|
294
|
+
(adapter.markers
|
|
295
|
+
? " The ticket and PR marker hooks don't run it, so they send no markers."
|
|
296
|
+
: ''),
|
|
297
|
+
}
|
|
298
|
+
: {
|
|
299
|
+
level: 'info',
|
|
300
|
+
message: `${where} sets ${claim.setting} but isn't the managed source ${adapter.displayName} uses, ` +
|
|
301
|
+
'so it supplies none of the managed OTLP settings and lower managed sources are ignored ' +
|
|
302
|
+
'for them too.',
|
|
303
|
+
});
|
|
304
|
+
}
|
|
286
305
|
for (const { layer, reason } of effective.skipped ?? []) {
|
|
287
306
|
issues.push({
|
|
288
307
|
level: 'info',
|
|
@@ -556,4 +575,3 @@ const runDoctorJson = async (adapter, options) => {
|
|
|
556
575
|
emitJson(await doctorJson(adapter, effective, issues, validation));
|
|
557
576
|
return issues.some((i) => i.level === 'error') || validation?.ok === false ? 1 : 0;
|
|
558
577
|
};
|
|
559
|
-
//# sourceMappingURL=doctor.js.map
|
package/dist/core/edit.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { select } from '@inquirer/prompts';
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { promises as fs } from 'node:fs';
|
|
4
|
-
import { resolve } from 'node:path';
|
|
5
4
|
import { WizardAbort } from './errors.js';
|
|
6
5
|
import { color } from './format.js';
|
|
7
6
|
import { policyState } from './layer-policy.js';
|
|
7
|
+
import { isSamePath } from './settings.js';
|
|
8
8
|
const candidatesFor = (adapter) => {
|
|
9
9
|
const out = [
|
|
10
10
|
{ label: 'Global', path: adapter.paths.global },
|
|
@@ -102,10 +102,15 @@ const spawnEditor = (editor, path) => new Promise((resolve, reject) => {
|
|
|
102
102
|
});
|
|
103
103
|
const isInteractive = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
104
104
|
export const ignoredKeysEditNote = (adapter, target) => {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
if (target !== adapter.paths.local)
|
|
106
|
+
return null;
|
|
107
|
+
if (isSamePath(target, adapter.paths.global))
|
|
107
108
|
return null;
|
|
108
|
-
if (
|
|
109
|
+
if (adapter.paths.localIgnored !== undefined) {
|
|
110
|
+
return `${adapter.paths.localIgnored}. To change where telemetry goes, run \`mainwave-cli edit ${adapter.name} --global\`.`;
|
|
111
|
+
}
|
|
112
|
+
const policy = adapter.layerKeyPolicy;
|
|
113
|
+
if (!policy)
|
|
109
114
|
return null;
|
|
110
115
|
const layerId = adapter.hierarchy.find((l) => l.path === target)?.id;
|
|
111
116
|
if (!layerId || !policy.layers.includes(layerId) || policyState(policy) !== 'active')
|
|
@@ -140,4 +145,3 @@ export const runEdit = async (adapter, opts) => {
|
|
|
140
145
|
console.error(color.yellow(`⚠ ${note}`));
|
|
141
146
|
return spawnEditor(resolveEditor(), target);
|
|
142
147
|
};
|
|
143
|
-
//# sourceMappingURL=edit.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
3
|
-
import { ignoredKeysAt, isManagedLayer, policyState } from './layer-policy.js';
|
|
3
|
+
import { ignoredKeysAt, isManagedLayer, isPolicyKey, policyState, } from './layer-policy.js';
|
|
4
4
|
import { readExistingEnv } from './settings.js';
|
|
5
5
|
const extensionFor = (codec) => {
|
|
6
6
|
if (codec.format === 'toml')
|
|
@@ -9,12 +9,32 @@ const extensionFor = (codec) => {
|
|
|
9
9
|
return '.env';
|
|
10
10
|
return '.json';
|
|
11
11
|
};
|
|
12
|
-
const
|
|
12
|
+
const managedFactsOf = async (path, unitClaim) => {
|
|
13
|
+
let doc;
|
|
14
|
+
try {
|
|
15
|
+
doc = JSON.parse(await fs.readFile(path, 'utf8'));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
if (doc === null || typeof doc !== 'object' || Array.isArray(doc))
|
|
21
|
+
return undefined;
|
|
22
|
+
const settings = doc;
|
|
23
|
+
const claim = unitClaim?.(settings);
|
|
24
|
+
return {
|
|
25
|
+
hasPolicyKey: Object.keys(settings).some(isPolicyKey),
|
|
26
|
+
...(claim !== undefined ? { unitClaim: claim } : {}),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const scanFile = async (layer, path, codec, unitClaim) => {
|
|
13
30
|
try {
|
|
14
31
|
const env = await readExistingEnv(path, codec);
|
|
15
32
|
if (env === null)
|
|
16
33
|
return { layer, path, status: 'missing', env: {} };
|
|
17
|
-
|
|
34
|
+
const facts = layer.managedSource !== undefined && codec.format === 'json'
|
|
35
|
+
? await managedFactsOf(path, unitClaim)
|
|
36
|
+
: undefined;
|
|
37
|
+
return { layer, path, status: 'present', env, ...(facts ? { managedFacts: facts } : {}) };
|
|
18
38
|
}
|
|
19
39
|
catch (err) {
|
|
20
40
|
return {
|
|
@@ -27,7 +47,7 @@ const scanFile = async (layer, path, codec) => {
|
|
|
27
47
|
}
|
|
28
48
|
};
|
|
29
49
|
export const dropInNames = (entries, ext = '.json') => entries.filter((e) => e.endsWith(ext) && !e.startsWith('.')).sort();
|
|
30
|
-
const scanDir = async (layer, codec) => {
|
|
50
|
+
const scanDir = async (layer, codec, unitClaim) => {
|
|
31
51
|
let entries;
|
|
32
52
|
try {
|
|
33
53
|
entries = await fs.readdir(layer.path);
|
|
@@ -50,9 +70,11 @@ const scanDir = async (layer, codec) => {
|
|
|
50
70
|
if (matching.length === 0) {
|
|
51
71
|
return [{ layer, path: layer.path, status: 'missing', env: {} }];
|
|
52
72
|
}
|
|
53
|
-
return Promise.all(matching.map((name) => scanFile(layer, join(layer.path, name), codec)));
|
|
73
|
+
return Promise.all(matching.map((name) => scanFile(layer, join(layer.path, name), codec, unitClaim)));
|
|
54
74
|
};
|
|
55
|
-
const scanLayer = (codec) => async (layer) => layer.kind === 'dir'
|
|
75
|
+
const scanLayer = (codec, unitClaim) => async (layer) => layer.kind === 'dir'
|
|
76
|
+
? scanDir(layer, codec, unitClaim)
|
|
77
|
+
: [await scanFile(layer, layer.path, codec, unitClaim)];
|
|
56
78
|
const inactiveLayers = async (adapter, scans) => {
|
|
57
79
|
if (!adapter.inactiveLayers)
|
|
58
80
|
return [];
|
|
@@ -94,7 +116,7 @@ export const nativeIdentityReason = async (adapter, effective) => {
|
|
|
94
116
|
return adapter.nativeIdentityAbsent({ ...process.env, ...flattenEffective(e) }, e.scans.filter((s) => s.status === 'present').map((s) => s.path));
|
|
95
117
|
};
|
|
96
118
|
export const computeEffective = async (adapter, policyOverride) => {
|
|
97
|
-
const allScans = await Promise.all(adapter.hierarchy.map(scanLayer(adapter.codec)));
|
|
119
|
+
const allScans = await Promise.all(adapter.hierarchy.map(scanLayer(adapter.codec, adapter.managedUnitClaim)));
|
|
98
120
|
const skip = await inactiveLayers(adapter, allScans.flat());
|
|
99
121
|
const skipped = adapter.hierarchy.flatMap((layer) => {
|
|
100
122
|
const reason = skip.find((s) => s.id === layer.id)?.reason;
|
|
@@ -105,6 +127,25 @@ export const computeEffective = async (adapter, policyOverride) => {
|
|
|
105
127
|
const scans = flat.filter((scan, i) => !flat.slice(i + 1).some((later) => resolve(later.path) === resolve(scan.path)));
|
|
106
128
|
return { ...effectiveFrom(adapter, scans, policyOverride), skipped };
|
|
107
129
|
};
|
|
130
|
+
const isManagedSourceScan = (scan) => isManagedLayer(scan.layer) && scan.layer.managedSource !== undefined;
|
|
131
|
+
const managedUnit = (adapter, scans) => {
|
|
132
|
+
const unitKey = adapter.managedUnitKey;
|
|
133
|
+
if (!unitKey)
|
|
134
|
+
return {};
|
|
135
|
+
const managed = scans.filter(isManagedSourceScan);
|
|
136
|
+
const unitSource = managed.find((scan) => Object.keys(scan.env).some((k) => unitKey(k)) || scan.managedFacts?.unitClaim !== undefined)?.layer.managedSource;
|
|
137
|
+
if (unitSource === undefined)
|
|
138
|
+
return {};
|
|
139
|
+
const claiming = managed.find((scan) => scan.layer.managedSource === unitSource && scan.managedFacts?.unitClaim !== undefined);
|
|
140
|
+
const setting = claiming?.managedFacts?.unitClaim;
|
|
141
|
+
if (claiming === undefined || setting === undefined)
|
|
142
|
+
return { unitSource };
|
|
143
|
+
const inEffect = managed.find((scan) => scan.managedFacts?.hasPolicyKey ?? Object.keys(scan.env).length > 0)?.layer.managedSource;
|
|
144
|
+
return { unitSource, unitClaim: { setting, lands: inEffect === unitSource, scan: claiming } };
|
|
145
|
+
};
|
|
146
|
+
export const isManagedUnitDrop = (adapter, { unitSource, unitClaim }, scan, key) => unitSource !== undefined &&
|
|
147
|
+
adapter.managedUnitKey?.(key) === true &&
|
|
148
|
+
(scan.layer.managedSource !== unitSource || unitClaim?.lands === false);
|
|
108
149
|
export const effectiveFrom = (adapter, scans, policyOverride) => {
|
|
109
150
|
const ignored = [];
|
|
110
151
|
if (adapter.layerKeyPolicy) {
|
|
@@ -118,16 +159,8 @@ export const effectiveFrom = (adapter, scans, policyOverride) => {
|
|
|
118
159
|
(adapter.layerKeyPolicy && ignored.length > 0
|
|
119
160
|
? policyState(adapter.layerKeyPolicy)
|
|
120
161
|
: 'inactive');
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
? scans.find((scan) => isManagedLayer(scan.layer) &&
|
|
124
|
-
scan.layer.managedSource !== undefined &&
|
|
125
|
-
Object.keys(scan.env).some((k) => unitKey(k)))?.layer.managedSource
|
|
126
|
-
: undefined;
|
|
127
|
-
const droppedInManaged = (scan, key) => unitSource !== undefined &&
|
|
128
|
-
unitKey !== undefined &&
|
|
129
|
-
unitKey(key) &&
|
|
130
|
-
scan.layer.managedSource !== unitSource;
|
|
162
|
+
const { unitSource, unitClaim } = managedUnit(adapter, scans);
|
|
163
|
+
const droppedInManaged = (scan, key) => isManagedUnitDrop(adapter, { unitSource, unitClaim }, scan, key);
|
|
131
164
|
const managedEnv = {};
|
|
132
165
|
for (const scan of scans) {
|
|
133
166
|
if (!isManagedLayer(scan.layer))
|
|
@@ -144,7 +177,8 @@ export const effectiveFrom = (adapter, scans, policyOverride) => {
|
|
|
144
177
|
for (const scan of scans) {
|
|
145
178
|
if (isManagedLayer(scan.layer))
|
|
146
179
|
continue;
|
|
147
|
-
const keys = Object.keys(scan.env).filter((k) => !policyIgnores(scan, k) &&
|
|
180
|
+
const keys = Object.keys(scan.env).filter((k) => !policyIgnores(scan, k) &&
|
|
181
|
+
adapter.managedLock(k, managedEnv, unitClaim?.lands ? unitClaim.setting : undefined));
|
|
148
182
|
if (keys.length > 0)
|
|
149
183
|
locked.push({ scan, keys });
|
|
150
184
|
}
|
|
@@ -160,6 +194,13 @@ export const effectiveFrom = (adapter, scans, policyOverride) => {
|
|
|
160
194
|
effective[k] = { key: k, value: v, source: scan };
|
|
161
195
|
}
|
|
162
196
|
}
|
|
163
|
-
return {
|
|
197
|
+
return {
|
|
198
|
+
scans,
|
|
199
|
+
effective,
|
|
200
|
+
policy,
|
|
201
|
+
ignored,
|
|
202
|
+
unitSource,
|
|
203
|
+
...(unitClaim ? { unitClaim } : {}),
|
|
204
|
+
locked,
|
|
205
|
+
};
|
|
164
206
|
};
|
|
165
|
-
//# sourceMappingURL=effective-settings.js.map
|
package/dist/core/env-command.js
CHANGED
package/dist/core/errors.js
CHANGED
package/dist/core/flags.js
CHANGED
package/dist/core/format.js
CHANGED
package/dist/core/git.js
CHANGED
package/dist/core/headers.js
CHANGED
|
@@ -2,8 +2,9 @@ import { basename } from 'node:path';
|
|
|
2
2
|
import { hasPath } from './detect.js';
|
|
3
3
|
import { activeHierarchy } from './effective-settings.js';
|
|
4
4
|
import { isManagedLayer } from './layer-policy.js';
|
|
5
|
-
import { buildHookCommand,
|
|
5
|
+
import { buildHookCommand, installHooksCommand, managedHooksDir, managedMarkerScripts, packagedHooksDir, PAYLOAD_CLI_SPEC, prepareMarkersFile, readPackagedMatchers, scanForMarkers, scriptPathFromCommand, syncManagedHooks, } from './markers.js';
|
|
6
6
|
import { applyUpdate } from './settings.js';
|
|
7
|
+
import { VERSION } from './version.js';
|
|
7
8
|
const PAYLOAD_HOOKS_DIR = '$HOME/.mainwave/hooks/managed';
|
|
8
9
|
export const managedPayloadHooks = (matchers) => ({
|
|
9
10
|
SessionStart: [
|
|
@@ -35,7 +36,7 @@ const defaultPaths = () => ({
|
|
|
35
36
|
});
|
|
36
37
|
export const installHooks = async (adapter, paths = defaultPaths()) => {
|
|
37
38
|
const matchers = await readPackagedMatchers(paths.srcDir);
|
|
38
|
-
const updated = await
|
|
39
|
+
const updated = await syncManagedHooks(matchers, paths.srcDir, paths.destDir, paths.version ?? VERSION);
|
|
39
40
|
const managedLayers = (await activeHierarchy(adapter)).filter(isManagedLayer);
|
|
40
41
|
const delivered = managedMarkerScripts(await scanForMarkers(managedLayers));
|
|
41
42
|
const managedDelivers = delivered.size > 0;
|
|
@@ -78,4 +79,3 @@ export const runInstallHooks = async (adapter, options = {}, paths) => {
|
|
|
78
79
|
}
|
|
79
80
|
return 0;
|
|
80
81
|
};
|
|
81
|
-
//# sourceMappingURL=install-hooks.js.map
|
package/dist/core/interview.js
CHANGED
package/dist/core/keys.js
CHANGED
|
@@ -29,6 +29,7 @@ export const ignoredKeysAt = (policy, layerId, env) => policy.layers.includes(la
|
|
|
29
29
|
.filter(([k, v]) => policy.ignores(k, v))
|
|
30
30
|
.map(([k]) => k)
|
|
31
31
|
: [];
|
|
32
|
+
const NON_POLICY_KEYS = new Set(['wslInheritsWindowsSettings', 'managedSourcesBehavior']);
|
|
33
|
+
export const isPolicyKey = (key) => !NON_POLICY_KEYS.has(key);
|
|
32
34
|
export const isManagedLayer = (layer) => layer.managedSource !== undefined || layer.id === 'managed';
|
|
33
35
|
export const isManagedIdentityConfig = (attrs) => /(^|,)\s*mainwave\.source=coding_agent\./.test(attrs ?? '');
|
|
34
|
-
//# sourceMappingURL=layer-policy.js.map
|