@memnexus-ai/mx-agent-cli 0.1.303 → 0.1.305
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/dist/agent-config/.mx-config-generation.json +2 -2
- package/dist/agent-config/AGENTS.md.template +1 -1
- package/dist/agent-config/agents/bar-raiser.md +41 -1
- package/dist/agent-config/agents/git-expert.md +58 -54
- package/dist/agent-config/claude-md/CLAUDE.core.md +1 -1
- package/dist/agent-config/hooks/session-idle-gate.sh +14 -1
- package/dist/agent-config/hooks/subagent-write-guard.sh +198 -12
- package/dist/agent-config/hooks/worktree-guard.sh +8 -6
- package/dist/agent-config/skills/mx-post-merge-sync/SKILL.md +59 -51
- package/dist/commands/codex-agent-gate.d.ts +1 -2
- package/dist/commands/codex-agent-gate.d.ts.map +1 -1
- package/dist/commands/codex-agent-gate.js +1 -2
- package/dist/commands/codex-agent-gate.js.map +1 -1
- package/dist/commands/codex-deploy-config.d.ts +6 -0
- package/dist/commands/codex-deploy-config.d.ts.map +1 -1
- package/dist/commands/codex-deploy-config.js +28 -8
- package/dist/commands/codex-deploy-config.js.map +1 -1
- package/dist/commands/codex-prove-guards.d.ts +2 -0
- package/dist/commands/codex-prove-guards.d.ts.map +1 -1
- package/dist/commands/codex-prove-guards.js +31 -3
- package/dist/commands/codex-prove-guards.js.map +1 -1
- package/dist/commands/codex-trust-keys.d.ts +2 -0
- package/dist/commands/codex-trust-keys.d.ts.map +1 -1
- package/dist/commands/codex-trust-keys.js +27 -7
- package/dist/commands/codex-trust-keys.js.map +1 -1
- package/dist/commands/coordination.d.ts +16 -0
- package/dist/commands/coordination.d.ts.map +1 -1
- package/dist/commands/coordination.js +24 -2
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/create.d.ts +164 -7
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +293 -91
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/doctor.d.ts +17 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +33 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/gh.d.ts +3 -2
- package/dist/commands/gh.d.ts.map +1 -1
- package/dist/commands/gh.js +3 -2
- package/dist/commands/gh.js.map +1 -1
- package/dist/commands/new.d.ts +132 -17
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +426 -74
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/start.d.ts +6 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +105 -17
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts +7 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +21 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-session.d.ts +11 -0
- package/dist/lib/agent-session.d.ts.map +1 -1
- package/dist/lib/agent-session.js +26 -7
- package/dist/lib/agent-session.js.map +1 -1
- package/dist/lib/behavioral-injection.d.ts.map +1 -1
- package/dist/lib/behavioral-injection.js +25 -7
- package/dist/lib/behavioral-injection.js.map +1 -1
- package/dist/lib/catalog-commit.d.ts.map +1 -1
- package/dist/lib/catalog-commit.js +17 -14
- package/dist/lib/catalog-commit.js.map +1 -1
- package/dist/lib/catalog.d.ts +93 -2
- package/dist/lib/catalog.d.ts.map +1 -1
- package/dist/lib/catalog.js +116 -9
- package/dist/lib/catalog.js.map +1 -1
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +28 -4
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/fleet-data.d.ts +98 -9
- package/dist/lib/fleet-data.d.ts.map +1 -1
- package/dist/lib/fleet-data.js +353 -34
- package/dist/lib/fleet-data.js.map +1 -1
- package/dist/lib/fleet-render.d.ts +8 -1
- package/dist/lib/fleet-render.d.ts.map +1 -1
- package/dist/lib/fleet-render.js +10 -3
- package/dist/lib/fleet-render.js.map +1 -1
- package/dist/lib/gh-remote.d.ts +15 -1
- package/dist/lib/gh-remote.d.ts.map +1 -1
- package/dist/lib/gh-remote.js +27 -2
- package/dist/lib/gh-remote.js.map +1 -1
- package/dist/lib/gh-token-run.d.ts +140 -14
- package/dist/lib/gh-token-run.d.ts.map +1 -1
- package/dist/lib/gh-token-run.js +187 -15
- package/dist/lib/gh-token-run.js.map +1 -1
- package/dist/lib/git-identity.d.ts +6 -2
- package/dist/lib/git-identity.d.ts.map +1 -1
- package/dist/lib/git-identity.js +17 -8
- package/dist/lib/git-identity.js.map +1 -1
- package/dist/lib/guarded-read.d.ts +15 -0
- package/dist/lib/guarded-read.d.ts.map +1 -0
- package/dist/lib/guarded-read.js +73 -0
- package/dist/lib/guarded-read.js.map +1 -0
- package/dist/lib/machine-setup.d.ts +165 -0
- package/dist/lib/machine-setup.d.ts.map +1 -0
- package/dist/lib/machine-setup.js +441 -0
- package/dist/lib/machine-setup.js.map +1 -0
- package/dist/lib/native-realpath.d.ts +70 -0
- package/dist/lib/native-realpath.d.ts.map +1 -0
- package/dist/lib/native-realpath.js +95 -0
- package/dist/lib/native-realpath.js.map +1 -0
- package/dist/lib/project-config.d.ts +2 -6
- package/dist/lib/project-config.d.ts.map +1 -1
- package/dist/lib/project-config.js.map +1 -1
- package/dist/lib/project-name.d.ts +15 -0
- package/dist/lib/project-name.d.ts.map +1 -0
- package/dist/lib/project-name.js +22 -0
- package/dist/lib/project-name.js.map +1 -0
- package/dist/lib/push-to.d.ts +113 -0
- package/dist/lib/push-to.d.ts.map +1 -0
- package/dist/lib/push-to.js +240 -0
- package/dist/lib/push-to.js.map +1 -0
- package/dist/lib/runtime/claude-gateway-routing.d.ts +161 -0
- package/dist/lib/runtime/claude-gateway-routing.d.ts.map +1 -0
- package/dist/lib/runtime/claude-gateway-routing.js +466 -0
- package/dist/lib/runtime/claude-gateway-routing.js.map +1 -0
- package/dist/lib/runtime/codex-adapter.d.ts +91 -5
- package/dist/lib/runtime/codex-adapter.d.ts.map +1 -1
- package/dist/lib/runtime/codex-adapter.js +204 -44
- package/dist/lib/runtime/codex-adapter.js.map +1 -1
- package/dist/lib/runtime/codex-config.d.ts +6 -12
- package/dist/lib/runtime/codex-config.d.ts.map +1 -1
- package/dist/lib/runtime/codex-config.js +17 -24
- package/dist/lib/runtime/codex-config.js.map +1 -1
- package/dist/lib/runtime/codex-guard-proof.d.ts +4 -7
- package/dist/lib/runtime/codex-guard-proof.d.ts.map +1 -1
- package/dist/lib/runtime/codex-guard-proof.js +16 -14
- package/dist/lib/runtime/codex-guard-proof.js.map +1 -1
- package/dist/lib/runtime/codex-hooks-list.d.ts +20 -0
- package/dist/lib/runtime/codex-hooks-list.d.ts.map +1 -1
- package/dist/lib/runtime/codex-hooks-list.js +20 -8
- package/dist/lib/runtime/codex-hooks-list.js.map +1 -1
- package/dist/lib/runtime/types.d.ts +1 -1
- package/dist/lib/runtime/types.d.ts.map +1 -1
- package/dist/lib/standards.d.ts +3 -0
- package/dist/lib/standards.d.ts.map +1 -1
- package/dist/lib/standards.js +1 -0
- package/dist/lib/standards.js.map +1 -1
- package/dist/lib/team-identity.d.ts.map +1 -1
- package/dist/lib/team-identity.js +18 -53
- package/dist/lib/team-identity.js.map +1 -1
- package/dist/lib/team-restore.d.ts +281 -0
- package/dist/lib/team-restore.d.ts.map +1 -0
- package/dist/lib/team-restore.js +533 -0
- package/dist/lib/team-restore.js.map +1 -0
- package/dist/lib/window-view.d.ts +5 -0
- package/dist/lib/window-view.d.ts.map +1 -1
- package/dist/lib/window-view.js +67 -6
- package/dist/lib/window-view.js.map +1 -1
- package/dist/lib/worktree-sync.d.ts +139 -11
- package/dist/lib/worktree-sync.d.ts.map +1 -1
- package/dist/lib/worktree-sync.js +327 -46
- package/dist/lib/worktree-sync.js.map +1 -1
- package/dist/standards/merge-gates.md +26 -0
- package/package.json +2 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a file that must be a regular file of bounded size, without following a
|
|
3
|
+
* symlink and without blocking on a FIFO (#902).
|
|
4
|
+
*
|
|
5
|
+
* A bare `readFileSync(path)` on a FIFO blocks in the kernel until a writer
|
|
6
|
+
* opens the other end, and nothing ever does, so the command hangs with no
|
|
7
|
+
* output. The red-team reproduced this on a FIFO named `<x>.md` in the teams
|
|
8
|
+
* directory at `4bfe9d5`: `readCatalog`, `listTeams` and `getTeam` all hung, and
|
|
9
|
+
* through them `start`, `provision` and every fleet command that lists teams.
|
|
10
|
+
*
|
|
11
|
+
* This is the descriptor-checked read `readFallbackFile` uses
|
|
12
|
+
* (`coordination-fallback.ts`, the security review of #525 at eba08f4), without
|
|
13
|
+
* its owner check and with a size cap:
|
|
14
|
+
*
|
|
15
|
+
* - opened `O_RDONLY | O_NOFOLLOW | O_NONBLOCK`, so a symlink in the final
|
|
16
|
+
* component is refused (ELOOP) and a FIFO open returns at once;
|
|
17
|
+
* - `fstatSync` on the descriptor that is read, so the check and the read are
|
|
18
|
+
* about the same file, and anything that is not a regular file is refused;
|
|
19
|
+
* - a file larger than `maxBytes` is refused, and the read itself stops at
|
|
20
|
+
* `maxBytes + 1` bytes, so a file that grows after the `fstat` is refused too
|
|
21
|
+
* rather than read whole;
|
|
22
|
+
* - the descriptor is closed in `finally`.
|
|
23
|
+
*
|
|
24
|
+
* It does not warn. The result says what happened and the caller decides what
|
|
25
|
+
* to print, because one caller skips the file and another stops the command.
|
|
26
|
+
* `coordination-fallback.ts` keeps its own copy: it also refuses a file another
|
|
27
|
+
* user owns, and its warnings name what it left in place.
|
|
28
|
+
*/
|
|
29
|
+
import { closeSync, constants as fsConstants, fstatSync, openSync, readSync } from 'fs';
|
|
30
|
+
// `?? 0`: Windows defines neither flag. There the open is a plain O_RDONLY, and
|
|
31
|
+
// the `isFile()` check on the descriptor still refuses what is not a file.
|
|
32
|
+
const OPEN_FLAGS = fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0) | (fsConstants.O_NONBLOCK ?? 0);
|
|
33
|
+
export function readRegularFileGuarded(path, maxBytes) {
|
|
34
|
+
let fd;
|
|
35
|
+
try {
|
|
36
|
+
fd = openSync(path, OPEN_FLAGS);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
const code = err.code;
|
|
40
|
+
if (code === 'ENOENT')
|
|
41
|
+
return { kind: 'absent' };
|
|
42
|
+
if (code === 'ELOOP')
|
|
43
|
+
return { kind: 'refused', reason: 'it is a symbolic link, which is not followed' };
|
|
44
|
+
return { kind: 'refused', reason: `it could not be opened (${code ?? 'error'})` };
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const st = fstatSync(fd);
|
|
48
|
+
if (!st.isFile())
|
|
49
|
+
return { kind: 'refused', reason: 'it is not a regular file' };
|
|
50
|
+
if (st.size > maxBytes) {
|
|
51
|
+
return { kind: 'refused', reason: `it is ${st.size} bytes, over the ${maxBytes}-byte limit` };
|
|
52
|
+
}
|
|
53
|
+
const buf = Buffer.alloc(maxBytes + 1);
|
|
54
|
+
let total = 0;
|
|
55
|
+
while (total < buf.length) {
|
|
56
|
+
const n = readSync(fd, buf, total, buf.length - total, null);
|
|
57
|
+
if (n === 0)
|
|
58
|
+
break;
|
|
59
|
+
total += n;
|
|
60
|
+
}
|
|
61
|
+
if (total > maxBytes) {
|
|
62
|
+
return { kind: 'refused', reason: `it grew past the ${maxBytes}-byte limit while it was read` };
|
|
63
|
+
}
|
|
64
|
+
return { kind: 'ok', bytes: buf.subarray(0, total) };
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
return { kind: 'refused', reason: `it could not be read (${err.code ?? 'error'})` };
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
closeSync(fd);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=guarded-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guarded-read.js","sourceRoot":"","sources":["../../src/lib/guarded-read.ts"],"names":[],"mappings":"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C;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;QACvC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,CAAC,GAAG,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC;YAC7D,IAAI,CAAC,KAAK,CAAC;gBAAE,MAAM;YACnB,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;QACD,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;YACrB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,QAAQ,+BAA+B,EAAE,CAAC;QAClG,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IACvD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,yBAA0B,GAA6B,CAAC,IAAI,IAAI,OAAO,GAAG,EAAE,CAAC;IACjH,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machine setup `mx-agent start` runs itself (#1155 slice 2).
|
|
3
|
+
*
|
|
4
|
+
* SPEC. Plan comment 6961512321 on #1155 and its amendment 1, comment
|
|
5
|
+
* 6961573086. The amendment governs where they differ.
|
|
6
|
+
*
|
|
7
|
+
* `ensureMachineSetup` checks three settings and returns exactly one result for
|
|
8
|
+
* each: `already-set`, `set`, `not-set` (with the one command that sets it) or
|
|
9
|
+
* `could-not-check` (with the reason). In `apply` mode it writes a setting only
|
|
10
|
+
* under that setting's rule below. In `report` mode it writes nothing.
|
|
11
|
+
*
|
|
12
|
+
* extensions.worktreeConfig The repository's own `.git/config`. Set only when
|
|
13
|
+
* the repository has no linked worktree other than
|
|
14
|
+
* the main one and the pre-flight passes.
|
|
15
|
+
* coordination-brief-enabled `~/.mx-agent/config.json`. Set to the string
|
|
16
|
+
* "true" only when the key is absent.
|
|
17
|
+
* project slug Tracked `mx-agent.config.json`. Report only.
|
|
18
|
+
*
|
|
19
|
+
* ONE WRITER PER SETTING. `setWorktreeConfigExtension` is the only code that
|
|
20
|
+
* writes `extensions.worktreeConfig`; `enableWorktreeConfig` in
|
|
21
|
+
* `commands/new.ts` calls it. `ensureBriefEnabled` is the only code that writes
|
|
22
|
+
* `coordination-brief-enabled` on its own initiative; `mx-agent config set`
|
|
23
|
+
* still writes it when an operator asks.
|
|
24
|
+
*/
|
|
25
|
+
export type MachineSetupMode = 'apply' | 'report';
|
|
26
|
+
export type SettingStatus = 'already-set' | 'set' | 'not-set' | 'could-not-check';
|
|
27
|
+
export type SettingName = 'extensions.worktreeConfig' | 'coordination-brief-enabled' | 'projectSlug';
|
|
28
|
+
/**
|
|
29
|
+
* Why a setting is `not-set` or `could-not-check`. `enableWorktreeConfig` maps
|
|
30
|
+
* these to its own three return values, so they are part of the contract.
|
|
31
|
+
*/
|
|
32
|
+
export type SettingCause = 'other-worktrees' | 'preflight' | 'write-failed' | 'unreadable' | 'report-mode' | 'present-value' | 'read-only';
|
|
33
|
+
export interface SettingResult {
|
|
34
|
+
setting: SettingName;
|
|
35
|
+
status: SettingStatus;
|
|
36
|
+
/** One clause: what is true now. Sanitized for a terminal. */
|
|
37
|
+
detail: string;
|
|
38
|
+
/** The one command an operator runs, for `not-set`. */
|
|
39
|
+
command?: string;
|
|
40
|
+
/** Set when `status` is `set`: the value before and after the write. */
|
|
41
|
+
change?: {
|
|
42
|
+
from: string;
|
|
43
|
+
to: string;
|
|
44
|
+
};
|
|
45
|
+
cause?: SettingCause;
|
|
46
|
+
/** For `extensions.worktreeConfig`: the main worktree the setting belongs to. */
|
|
47
|
+
repo?: string;
|
|
48
|
+
/** For `write-failed`: git's exit status and stderr, sanitized. */
|
|
49
|
+
writeError?: {
|
|
50
|
+
status: number | null;
|
|
51
|
+
why: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface MachineSetupResult {
|
|
55
|
+
mode: MachineSetupMode;
|
|
56
|
+
results: SettingResult[];
|
|
57
|
+
}
|
|
58
|
+
/** How the `extensions.worktreeConfig` write runs git. Injectable so a test can force a failure. */
|
|
59
|
+
export type GitConfigRunner = (args: string[]) => {
|
|
60
|
+
status: number | null;
|
|
61
|
+
stderr?: string | null;
|
|
62
|
+
error?: Error;
|
|
63
|
+
};
|
|
64
|
+
/** How the read-only git calls run. Injectable so a test can force a failure. */
|
|
65
|
+
export type GitReader = (args: string[]) => {
|
|
66
|
+
status: number | null;
|
|
67
|
+
stdout: string;
|
|
68
|
+
stderr: string;
|
|
69
|
+
};
|
|
70
|
+
export interface MachineSetupOptions {
|
|
71
|
+
projectRoot: string;
|
|
72
|
+
mode: MachineSetupMode;
|
|
73
|
+
/**
|
|
74
|
+
* The `~/.mx-agent/config.json` path. Defaults to the real one. Under the
|
|
75
|
+
* test runner a call without it throws (the #651 guard): no unit test of this
|
|
76
|
+
* module may read or write the operator's file.
|
|
77
|
+
*/
|
|
78
|
+
configPath?: string;
|
|
79
|
+
/** Test seams. */
|
|
80
|
+
runGitConfig?: GitConfigRunner;
|
|
81
|
+
readGit?: GitReader;
|
|
82
|
+
/** Called after the first read of config.json and before the re-read. Test seam for the race. */
|
|
83
|
+
beforeConfigWrite?: () => void;
|
|
84
|
+
}
|
|
85
|
+
export declare const BRIEF_KEY = "coordination-brief-enabled";
|
|
86
|
+
export declare const BRIEF_COMMAND = "mx-agent config set coordination-brief-enabled true";
|
|
87
|
+
/** The command that enables the extension on `repo`. */
|
|
88
|
+
export declare function worktreeConfigCommand(repo: string): string;
|
|
89
|
+
interface WorktreeCount {
|
|
90
|
+
/** Linked worktrees, every entry after the first. */
|
|
91
|
+
others: number;
|
|
92
|
+
/** True when the first entry is `bare`. */
|
|
93
|
+
bare: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Count the linked worktrees from `git worktree list --porcelain`.
|
|
97
|
+
*
|
|
98
|
+
* Skips the first entry, which is the main worktree or a `bare` entry. Counts
|
|
99
|
+
* every other entry, including `prunable`, `locked` and entries whose directory
|
|
100
|
+
* is gone, because each still has an admin directory that reads the shared
|
|
101
|
+
* config (amendment 1 section 2, red-team finding 2).
|
|
102
|
+
*/
|
|
103
|
+
export declare function countLinkedWorktrees(porcelain: string): WorktreeCount;
|
|
104
|
+
export interface WorktreeConfigOptions {
|
|
105
|
+
projectRoot: string;
|
|
106
|
+
mode: MachineSetupMode;
|
|
107
|
+
runGitConfig?: GitConfigRunner;
|
|
108
|
+
readGit?: GitReader;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Decide, and in `apply` mode set, `extensions.worktreeConfig`.
|
|
112
|
+
*
|
|
113
|
+
* Order (amendment 1 section 2):
|
|
114
|
+
* 1. already `true` locally: `already-set`, nothing more is read. Any other
|
|
115
|
+
* present value (`false`): `not-set` with the command, and no write.
|
|
116
|
+
* 2. count linked worktrees from the common directory.
|
|
117
|
+
* 3. a bare main entry, or any git failure: `could-not-check`.
|
|
118
|
+
* 4. count 0 and the pre-flight passes: set it and report the old and new value.
|
|
119
|
+
* Count above 0, or the pre-flight refuses: `not-set` with the command.
|
|
120
|
+
*
|
|
121
|
+
* THE GUARD IS STRICTER THAN GIT'S OWN HAZARD. With no `config.worktree` files,
|
|
122
|
+
* enabling the extension changes nothing for existing worktrees. It stays,
|
|
123
|
+
* because #919 is the precedent for refusing a shared git config change made
|
|
124
|
+
* from inside one worktree.
|
|
125
|
+
*/
|
|
126
|
+
export declare function setWorktreeConfigExtension(opts: WorktreeConfigOptions): SettingResult;
|
|
127
|
+
/**
|
|
128
|
+
* Set `coordination-brief-enabled` to the string "true" when the key is absent.
|
|
129
|
+
*
|
|
130
|
+
* Any present value is respected, `false`, `0` and an empty string included,
|
|
131
|
+
* and reported as `not-set` with the command (amendment 1 section 3). The write
|
|
132
|
+
* goes to a temp file in the same directory and is renamed over the target,
|
|
133
|
+
* after a re-read that confirms the key is still absent.
|
|
134
|
+
*
|
|
135
|
+
* ACCEPTED RISK. Two writers can still race: the window is the time between the
|
|
136
|
+
* re-read and the rename, and a writer outside this function is not covered.
|
|
137
|
+
*/
|
|
138
|
+
export declare function ensureBriefEnabled(opts: {
|
|
139
|
+
configPath: string;
|
|
140
|
+
mode: MachineSetupMode;
|
|
141
|
+
beforeConfigWrite?: () => void;
|
|
142
|
+
}): SettingResult;
|
|
143
|
+
/**
|
|
144
|
+
* Report `projectSlug` from the tracked `mx-agent.config.json`. Never written:
|
|
145
|
+
* a clone already carries it. `start` does not set `MX_PRODUCT_SLUG` either,
|
|
146
|
+
* because a process cannot set its parent shell's environment.
|
|
147
|
+
*/
|
|
148
|
+
export declare function reportProjectSlug(projectRoot: string): SettingResult;
|
|
149
|
+
/**
|
|
150
|
+
* Check every setting and, in `apply` mode, write the ones whose rule allows it.
|
|
151
|
+
* Never throws for a setting it cannot read: that is a `could-not-check` result.
|
|
152
|
+
*/
|
|
153
|
+
export declare function ensureMachineSetup(opts: MachineSetupOptions): MachineSetupResult;
|
|
154
|
+
/** One line for a result. */
|
|
155
|
+
export declare function describeSetting(r: SettingResult): string;
|
|
156
|
+
/**
|
|
157
|
+
* The lines `start` prints. `already-set` prints nothing, so a second start on
|
|
158
|
+
* a configured machine is quiet about these settings. Every other result prints
|
|
159
|
+
* one line, and a write prints its old and new value once.
|
|
160
|
+
*/
|
|
161
|
+
export declare function describeMachineSetupForStart(result: MachineSetupResult): string[];
|
|
162
|
+
/** The lines `doctor` prints: every setting, every time. */
|
|
163
|
+
export declare function describeMachineSetupForReport(result: MachineSetupResult): string[];
|
|
164
|
+
export {};
|
|
165
|
+
//# sourceMappingURL=machine-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine-setup.d.ts","sourceRoot":"","sources":["../../src/lib/machine-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAuBH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAClD,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAClF,MAAM,MAAM,WAAW,GAAG,2BAA2B,GAAG,4BAA4B,GAAG,aAAa,CAAC;AAErG;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,WAAW,GACX,cAAc,GACd,YAAY,GACZ,aAAa,GACb,eAAe,GACf,WAAW,CAAC;AAEhB,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,UAAU,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,oGAAoG;AACpG,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK;IAAE,MAAM,EAAE,MAAM,GAA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