@integrity-labs/agt-cli 0.28.208 → 0.28.209
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/bin/agt.js +230 -146
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-ELBYWACS.js → chunk-WFCCBTA6.js} +8463 -6842
- package/dist/chunk-WFCCBTA6.js.map +1 -0
- package/dist/{chunk-3MHPMBN4.js → chunk-Z62QHIR3.js} +792 -38
- package/dist/chunk-Z62QHIR3.js.map +1 -0
- package/dist/{claude-pair-runtime-Q4Q2OTTV.js → claude-pair-runtime-UUTPSE2V.js} +2 -2
- package/dist/lib/manager-worker.js +84 -796
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/{persistent-session-6662WBSH.js → persistent-session-Z46SCCQM.js} +2 -3
- package/dist/{responsiveness-probe-TOLTTG6I.js → responsiveness-probe-4MUX7FBH.js} +2 -3
- package/dist/{responsiveness-probe-TOLTTG6I.js.map → responsiveness-probe-4MUX7FBH.js.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-3MHPMBN4.js.map +0 -1
- package/dist/chunk-ELBYWACS.js.map +0 -1
- package/dist/chunk-GWBOA7ZY.js +0 -1634
- package/dist/chunk-GWBOA7ZY.js.map +0 -1
- /package/dist/{claude-pair-runtime-Q4Q2OTTV.js.map → claude-pair-runtime-UUTPSE2V.js.map} +0 -0
- /package/dist/{persistent-session-6662WBSH.js.map → persistent-session-Z46SCCQM.js.map} +0 -0
package/dist/bin/agt.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
exchangeApiKey,
|
|
13
13
|
executeConnectivityProbe,
|
|
14
14
|
flagsCacheAgeSeconds,
|
|
15
|
+
gatherSessionToolBindProbe,
|
|
15
16
|
getActiveTeam,
|
|
16
17
|
getApiKey,
|
|
17
18
|
getHost,
|
|
@@ -37,7 +38,7 @@ import {
|
|
|
37
38
|
success,
|
|
38
39
|
table,
|
|
39
40
|
warn
|
|
40
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-Z62QHIR3.js";
|
|
41
42
|
import {
|
|
42
43
|
CHANNEL_REGISTRY,
|
|
43
44
|
DEFAULT_FRAMEWORK,
|
|
@@ -48,6 +49,7 @@ import {
|
|
|
48
49
|
createSlackApp,
|
|
49
50
|
deriveConsoleUrl,
|
|
50
51
|
detectDrift,
|
|
52
|
+
directChatSessionStatePath,
|
|
51
53
|
extractFrontmatter,
|
|
52
54
|
generateCharterMd,
|
|
53
55
|
generateSlackAppManifest,
|
|
@@ -65,11 +67,12 @@ import {
|
|
|
65
67
|
renderTemplate,
|
|
66
68
|
resolveChannels,
|
|
67
69
|
serializeManifestForSlackCli
|
|
68
|
-
} from "../chunk-
|
|
70
|
+
} from "../chunk-WFCCBTA6.js";
|
|
71
|
+
import "../chunk-XWVM4KPK.js";
|
|
69
72
|
|
|
70
73
|
// src/bin/agt.ts
|
|
71
|
-
import { join as
|
|
72
|
-
import { homedir as
|
|
74
|
+
import { join as join23 } from "path";
|
|
75
|
+
import { homedir as homedir12 } from "os";
|
|
73
76
|
import { Command } from "commander";
|
|
74
77
|
|
|
75
78
|
// src/commands/whoami.ts
|
|
@@ -202,6 +205,84 @@ function flagsResolveCommand(opts) {
|
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
207
|
|
|
208
|
+
// src/commands/probe-tools.ts
|
|
209
|
+
import { homedir as homedir2 } from "os";
|
|
210
|
+
import { join as join2 } from "path";
|
|
211
|
+
import { readFileSync } from "fs";
|
|
212
|
+
async function probeToolsCommand(opts) {
|
|
213
|
+
const agentId = opts.agentId;
|
|
214
|
+
const codeName = opts.codeName;
|
|
215
|
+
const emit = (obj) => {
|
|
216
|
+
process.stdout.write(`${JSON.stringify(obj)}
|
|
217
|
+
`);
|
|
218
|
+
};
|
|
219
|
+
if (!agentId || !codeName) {
|
|
220
|
+
emit({ ok: false, error: "agent-id and code-name are required" });
|
|
221
|
+
process.exitCode = 2;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const data = await api.post("/host/agent-integrations", {
|
|
226
|
+
agent_id: agentId
|
|
227
|
+
});
|
|
228
|
+
const integrations = data.integrations ?? [];
|
|
229
|
+
if (integrations.length === 0) {
|
|
230
|
+
emit({ ok: true, agent_id: agentId, code_name: codeName, probed: 0, reported: 0, due: 0, skipped: 0, results: [] });
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
let sessionStartedMs = null;
|
|
234
|
+
try {
|
|
235
|
+
const raw = JSON.parse(readFileSync(directChatSessionStatePath(agentId), "utf-8"));
|
|
236
|
+
sessionStartedMs = typeof raw.startedAtMs === "number" ? raw.startedAtMs : null;
|
|
237
|
+
} catch {
|
|
238
|
+
}
|
|
239
|
+
const projectDir = join2(homedir2(), ".augmented", codeName, "project");
|
|
240
|
+
const result = await gatherSessionToolBindProbe(
|
|
241
|
+
{ agent_id: agentId, code_name: codeName },
|
|
242
|
+
integrations,
|
|
243
|
+
projectDir,
|
|
244
|
+
{ sessionStartedMs, intervalMs: 0, maxPerRun: integrations.length }
|
|
245
|
+
);
|
|
246
|
+
if (!result) {
|
|
247
|
+
emit({
|
|
248
|
+
ok: true,
|
|
249
|
+
agent_id: agentId,
|
|
250
|
+
code_name: codeName,
|
|
251
|
+
probed: 0,
|
|
252
|
+
reported: 0,
|
|
253
|
+
due: 0,
|
|
254
|
+
skipped: 0,
|
|
255
|
+
results: [],
|
|
256
|
+
note: "no .mcp.json to probe"
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (result.reports.length > 0) {
|
|
261
|
+
await api.post("/host/session-tool-bind", { agent_id: agentId, results: result.reports });
|
|
262
|
+
}
|
|
263
|
+
const defById = new Map(integrations.map((i) => [i.id, i.definition_id]));
|
|
264
|
+
emit({
|
|
265
|
+
ok: true,
|
|
266
|
+
agent_id: agentId,
|
|
267
|
+
code_name: codeName,
|
|
268
|
+
probed: result.probed,
|
|
269
|
+
reported: result.reports.length,
|
|
270
|
+
due: result.due,
|
|
271
|
+
skipped: result.skipped,
|
|
272
|
+
session_started_ms: sessionStartedMs,
|
|
273
|
+
results: result.reports.map((r) => ({
|
|
274
|
+
integration_id: r.integration_id,
|
|
275
|
+
definition_id: defById.get(r.integration_id) ?? null,
|
|
276
|
+
scope: r.scope,
|
|
277
|
+
status: r.status
|
|
278
|
+
}))
|
|
279
|
+
});
|
|
280
|
+
} catch (err) {
|
|
281
|
+
emit({ ok: false, agent_id: agentId, code_name: codeName, error: err.message });
|
|
282
|
+
process.exitCode = 1;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
205
286
|
// src/commands/team.ts
|
|
206
287
|
import chalk2 from "chalk";
|
|
207
288
|
import ora2 from "ora";
|
|
@@ -328,7 +409,7 @@ import ora3 from "ora";
|
|
|
328
409
|
import { input, select, checkbox } from "@inquirer/prompts";
|
|
329
410
|
import { randomUUID } from "crypto";
|
|
330
411
|
import { mkdirSync, writeFileSync } from "fs";
|
|
331
|
-
import { join as
|
|
412
|
+
import { join as join3 } from "path";
|
|
332
413
|
function toSlug(name) {
|
|
333
414
|
return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
334
415
|
}
|
|
@@ -530,10 +611,10 @@ async function initCommand(opts) {
|
|
|
530
611
|
process.exitCode = 1;
|
|
531
612
|
return;
|
|
532
613
|
}
|
|
533
|
-
const agentDir =
|
|
614
|
+
const agentDir = join3(process.cwd(), ".augmented", codeName);
|
|
534
615
|
mkdirSync(agentDir, { recursive: true });
|
|
535
|
-
writeFileSync(
|
|
536
|
-
writeFileSync(
|
|
616
|
+
writeFileSync(join3(agentDir, "CHARTER.md"), charterMd);
|
|
617
|
+
writeFileSync(join3(agentDir, "TOOLS.md"), toolsMd);
|
|
537
618
|
spinner.succeed(`Agent "${chalk3.bold(displayName)}" created.`);
|
|
538
619
|
if (json) {
|
|
539
620
|
jsonOutput({
|
|
@@ -585,8 +666,8 @@ async function initCommand(opts) {
|
|
|
585
666
|
// src/commands/lint.ts
|
|
586
667
|
import chalk4 from "chalk";
|
|
587
668
|
import ora4 from "ora";
|
|
588
|
-
import { readFileSync, existsSync } from "fs";
|
|
589
|
-
import { join as
|
|
669
|
+
import { readFileSync as readFileSync2, existsSync } from "fs";
|
|
670
|
+
import { join as join4, resolve } from "path";
|
|
590
671
|
function printDiagnostics2(diagnostics) {
|
|
591
672
|
for (const d of diagnostics) {
|
|
592
673
|
const prefix = d.severity === "error" ? chalk4.red("ERR") : chalk4.yellow("WARN");
|
|
@@ -625,7 +706,7 @@ async function lintCommand(path) {
|
|
|
625
706
|
}
|
|
626
707
|
dirs.push({ name: path, dir: resolved });
|
|
627
708
|
} else {
|
|
628
|
-
const augmentedDir =
|
|
709
|
+
const augmentedDir = join4(process.cwd(), ".augmented");
|
|
629
710
|
if (!existsSync(augmentedDir)) {
|
|
630
711
|
if (json) {
|
|
631
712
|
jsonOutput({ ok: false, error: "No .augmented/ directory found" });
|
|
@@ -638,7 +719,7 @@ async function lintCommand(path) {
|
|
|
638
719
|
const { readdirSync: readdirSync7, statSync: statSync5 } = await import("fs");
|
|
639
720
|
const entries = readdirSync7(augmentedDir);
|
|
640
721
|
for (const entry of entries) {
|
|
641
|
-
const entryPath =
|
|
722
|
+
const entryPath = join4(augmentedDir, entry);
|
|
642
723
|
if (statSync5(entryPath).isDirectory()) {
|
|
643
724
|
dirs.push({ name: entry, dir: entryPath });
|
|
644
725
|
}
|
|
@@ -679,8 +760,8 @@ async function lintCommand(path) {
|
|
|
679
760
|
for (const { name, dir } of dirs) {
|
|
680
761
|
if (!json) console.log(chalk4.bold(`
|
|
681
762
|
Linting ${name}:`));
|
|
682
|
-
const charterPath =
|
|
683
|
-
const toolsPath =
|
|
763
|
+
const charterPath = join4(dir, "CHARTER.md");
|
|
764
|
+
const toolsPath = join4(dir, "TOOLS.md");
|
|
684
765
|
const hasCharter = existsSync(charterPath);
|
|
685
766
|
const hasTools = existsSync(toolsPath);
|
|
686
767
|
if (!hasCharter && !hasTools) {
|
|
@@ -688,8 +769,8 @@ Linting ${name}:`));
|
|
|
688
769
|
if (json) jsonResults.push({ agent: name, skipped: true });
|
|
689
770
|
continue;
|
|
690
771
|
}
|
|
691
|
-
const charterContent = hasCharter ?
|
|
692
|
-
const toolsContent = hasTools ?
|
|
772
|
+
const charterContent = hasCharter ? readFileSync2(charterPath, "utf-8") : void 0;
|
|
773
|
+
const toolsContent = hasTools ? readFileSync2(toolsPath, "utf-8") : void 0;
|
|
693
774
|
let result;
|
|
694
775
|
if (charterContent && toolsContent) {
|
|
695
776
|
result = lintAll(charterContent, toolsContent, { orgChannelPolicy: orgPolicy });
|
|
@@ -848,7 +929,7 @@ import chalk6 from "chalk";
|
|
|
848
929
|
import ora6 from "ora";
|
|
849
930
|
import { checkbox as checkbox2, confirm as confirm2, input as input2 } from "@inquirer/prompts";
|
|
850
931
|
import { writeFile } from "fs/promises";
|
|
851
|
-
import { join as
|
|
932
|
+
import { join as join5 } from "path";
|
|
852
933
|
import { tmpdir } from "os";
|
|
853
934
|
async function channelSlackSetupCommand(agentCodeName, options) {
|
|
854
935
|
const teamSlug = requireTeam();
|
|
@@ -920,7 +1001,7 @@ async function channelSlackSetupCommand(agentCodeName, options) {
|
|
|
920
1001
|
});
|
|
921
1002
|
const manifestObj = serializeManifestForSlackCli(manifest);
|
|
922
1003
|
const manifestJson = JSON.stringify(manifestObj, null, 2);
|
|
923
|
-
const manifestPath =
|
|
1004
|
+
const manifestPath = join5(tmpdir(), `augmented-slack-manifest-${agentCodeName}.json`);
|
|
924
1005
|
await writeFile(manifestPath, manifestJson, "utf-8");
|
|
925
1006
|
success(`Manifest written to ${manifestPath}`);
|
|
926
1007
|
console.log(chalk6.dim(manifestJson));
|
|
@@ -1273,7 +1354,7 @@ import chalk8 from "chalk";
|
|
|
1273
1354
|
import ora8 from "ora";
|
|
1274
1355
|
import { select as select2, input as input3 } from "@inquirer/prompts";
|
|
1275
1356
|
import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
1276
|
-
import { join as
|
|
1357
|
+
import { join as join6 } from "path";
|
|
1277
1358
|
async function deployCommand(opts) {
|
|
1278
1359
|
const teamSlug = requireTeam();
|
|
1279
1360
|
if (!teamSlug) return;
|
|
@@ -1383,9 +1464,9 @@ async function deployCommand(opts) {
|
|
|
1383
1464
|
spinner.stop();
|
|
1384
1465
|
if (!json) info(`Warning: could not record deployment in database: ${deployErr.message}`);
|
|
1385
1466
|
}
|
|
1386
|
-
const outDir =
|
|
1467
|
+
const outDir = join6(process.cwd(), ".augmented", "deploy");
|
|
1387
1468
|
mkdirSync2(outDir, { recursive: true });
|
|
1388
|
-
const outPath =
|
|
1469
|
+
const outPath = join6(outDir, "docker-compose.yaml");
|
|
1389
1470
|
writeFileSync2(outPath, rendered);
|
|
1390
1471
|
spinner.succeed("Deployment config generated.");
|
|
1391
1472
|
if (json) {
|
|
@@ -1410,7 +1491,7 @@ async function deployCommand(opts) {
|
|
|
1410
1491
|
import chalk9 from "chalk";
|
|
1411
1492
|
import ora9 from "ora";
|
|
1412
1493
|
import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
1413
|
-
import { join as
|
|
1494
|
+
import { join as join7 } from "path";
|
|
1414
1495
|
function printDiagnostics3(diagnostics) {
|
|
1415
1496
|
for (const d of diagnostics) {
|
|
1416
1497
|
const prefix = d.severity === "error" ? chalk9.red("ERR") : chalk9.yellow("WARN");
|
|
@@ -1423,7 +1504,7 @@ async function provisionCommand(codeName, options) {
|
|
|
1423
1504
|
if (!teamSlug) return;
|
|
1424
1505
|
const json = isJsonMode();
|
|
1425
1506
|
const target = options.target ?? "local_docker";
|
|
1426
|
-
const outputDir = options.output ??
|
|
1507
|
+
const outputDir = options.output ?? join7(process.cwd(), ".augmented", codeName, "provision");
|
|
1427
1508
|
const dryRun = options.dryRun ?? false;
|
|
1428
1509
|
if (!json) console.log(chalk9.bold("\nAugmented \u2014 Provision\n"));
|
|
1429
1510
|
const spinner = ora9({ text: "Fetching agent data\u2026", isSilent: json });
|
|
@@ -1612,10 +1693,10 @@ async function provisionCommand(codeName, options) {
|
|
|
1612
1693
|
spinner.text = "Writing files\u2026";
|
|
1613
1694
|
mkdirSync3(outputDir, { recursive: true });
|
|
1614
1695
|
for (const artifact of provisionOutput.artifacts) {
|
|
1615
|
-
writeFileSync3(
|
|
1696
|
+
writeFileSync3(join7(outputDir, artifact.relativePath), artifact.content);
|
|
1616
1697
|
}
|
|
1617
1698
|
if (deploymentYaml) {
|
|
1618
|
-
writeFileSync3(
|
|
1699
|
+
writeFileSync3(join7(outputDir, "docker-compose.yaml"), deploymentYaml);
|
|
1619
1700
|
}
|
|
1620
1701
|
spinner.text = "Storing provision snapshot\u2026";
|
|
1621
1702
|
try {
|
|
@@ -1667,8 +1748,8 @@ async function provisionCommand(codeName, options) {
|
|
|
1667
1748
|
import chalk10 from "chalk";
|
|
1668
1749
|
import ora10 from "ora";
|
|
1669
1750
|
import { spawn } from "child_process";
|
|
1670
|
-
import { existsSync as existsSync6, readFileSync as
|
|
1671
|
-
import { delimiter, dirname as dirname3, join as
|
|
1751
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "fs";
|
|
1752
|
+
import { delimiter, dirname as dirname3, join as join12 } from "path";
|
|
1672
1753
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1673
1754
|
|
|
1674
1755
|
// src/lib/impersonate-flag.ts
|
|
@@ -1707,21 +1788,21 @@ import {
|
|
|
1707
1788
|
existsSync as existsSync2,
|
|
1708
1789
|
mkdirSync as mkdirSync4,
|
|
1709
1790
|
readdirSync,
|
|
1710
|
-
readFileSync as
|
|
1791
|
+
readFileSync as readFileSync3,
|
|
1711
1792
|
renameSync,
|
|
1712
1793
|
rmSync,
|
|
1713
1794
|
writeFileSync as writeFileSync4
|
|
1714
1795
|
} from "fs";
|
|
1715
|
-
import { homedir as
|
|
1716
|
-
import { join as
|
|
1717
|
-
var IMPERSONATE_ROOT =
|
|
1718
|
-
var ACTIVE_DIR =
|
|
1719
|
-
var ACTIVE_MANIFEST_PATH =
|
|
1796
|
+
import { homedir as homedir3 } from "os";
|
|
1797
|
+
import { join as join8 } from "path";
|
|
1798
|
+
var IMPERSONATE_ROOT = join8(homedir3(), ".augmented-impersonate");
|
|
1799
|
+
var ACTIVE_DIR = join8(IMPERSONATE_ROOT, "active");
|
|
1800
|
+
var ACTIVE_MANIFEST_PATH = join8(ACTIVE_DIR, "manifest.json");
|
|
1720
1801
|
var SESSION_FILE_PREFIX = "session-";
|
|
1721
1802
|
var SESSION_FILE_SUFFIX = ".json";
|
|
1722
1803
|
function sessionManifestPath(projectCwd) {
|
|
1723
1804
|
const hash = createHash("sha256").update(projectCwd).digest("hex").slice(0, 16);
|
|
1724
|
-
return
|
|
1805
|
+
return join8(ACTIVE_DIR, `${SESSION_FILE_PREFIX}${hash}${SESSION_FILE_SUFFIX}`);
|
|
1725
1806
|
}
|
|
1726
1807
|
var CODE_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
1727
1808
|
function assertValidCodeName(codeName) {
|
|
@@ -1733,7 +1814,7 @@ function assertValidCodeName(codeName) {
|
|
|
1733
1814
|
}
|
|
1734
1815
|
function getImpersonateCodeNameDir(codeName) {
|
|
1735
1816
|
assertValidCodeName(codeName);
|
|
1736
|
-
return
|
|
1817
|
+
return join8(IMPERSONATE_ROOT, codeName);
|
|
1737
1818
|
}
|
|
1738
1819
|
function ensureCodeNameDir(codeName) {
|
|
1739
1820
|
assertValidCodeName(codeName);
|
|
@@ -1742,7 +1823,7 @@ function ensureCodeNameDir(codeName) {
|
|
|
1742
1823
|
return dir;
|
|
1743
1824
|
}
|
|
1744
1825
|
function ensureImpersonateWorkdir(codeName) {
|
|
1745
|
-
const dir =
|
|
1826
|
+
const dir = join8(ensureCodeNameDir(codeName), "workdir");
|
|
1746
1827
|
mkdirSync4(dir, { recursive: true });
|
|
1747
1828
|
return dir;
|
|
1748
1829
|
}
|
|
@@ -1764,7 +1845,7 @@ function validateManifest(parsed) {
|
|
|
1764
1845
|
function readManifestFile(path) {
|
|
1765
1846
|
if (!existsSync2(path)) return null;
|
|
1766
1847
|
try {
|
|
1767
|
-
return validateManifest(JSON.parse(
|
|
1848
|
+
return validateManifest(JSON.parse(readFileSync3(path, "utf-8")));
|
|
1768
1849
|
} catch {
|
|
1769
1850
|
return null;
|
|
1770
1851
|
}
|
|
@@ -1805,7 +1886,7 @@ function listActiveManifests() {
|
|
|
1805
1886
|
if (!entry.startsWith(SESSION_FILE_PREFIX) || !entry.endsWith(SESSION_FILE_SUFFIX)) {
|
|
1806
1887
|
continue;
|
|
1807
1888
|
}
|
|
1808
|
-
const manifest = readManifestFile(
|
|
1889
|
+
const manifest = readManifestFile(join8(ACTIVE_DIR, entry));
|
|
1809
1890
|
if (manifest) out.push(manifest);
|
|
1810
1891
|
}
|
|
1811
1892
|
return out;
|
|
@@ -1840,14 +1921,14 @@ import {
|
|
|
1840
1921
|
symlinkSync,
|
|
1841
1922
|
unlinkSync
|
|
1842
1923
|
} from "fs";
|
|
1843
|
-
import { homedir as
|
|
1844
|
-
import { dirname, join as
|
|
1924
|
+
import { homedir as homedir4 } from "os";
|
|
1925
|
+
import { dirname, join as join9, parse, sep } from "path";
|
|
1845
1926
|
var BACKUP_SUFFIX = ".pre-impersonate-backup";
|
|
1846
1927
|
function findGitWorkTreeRoot(startDir) {
|
|
1847
1928
|
const { root } = parse(startDir);
|
|
1848
1929
|
let dir = startDir;
|
|
1849
1930
|
for (; ; ) {
|
|
1850
|
-
if (existsSync3(
|
|
1931
|
+
if (existsSync3(join9(dir, ".git"))) return dir;
|
|
1851
1932
|
if (dir === root) return null;
|
|
1852
1933
|
const parent = dirname(dir);
|
|
1853
1934
|
if (parent === dir) return null;
|
|
@@ -1862,7 +1943,7 @@ function swapInPersonaFile(projectPath, personaPath) {
|
|
|
1862
1943
|
const stat = lstatSync(projectPath);
|
|
1863
1944
|
if (stat.isSymbolicLink()) {
|
|
1864
1945
|
const target = readlinkSync(projectPath);
|
|
1865
|
-
const ourRoot = realpathSync(
|
|
1946
|
+
const ourRoot = realpathSync(homedir4()) + sep + ".augmented-impersonate" + sep;
|
|
1866
1947
|
let resolvedTarget;
|
|
1867
1948
|
try {
|
|
1868
1949
|
resolvedTarget = realpathSync(projectPath);
|
|
@@ -1924,20 +2005,20 @@ import {
|
|
|
1924
2005
|
existsSync as existsSync4,
|
|
1925
2006
|
mkdirSync as mkdirSync5,
|
|
1926
2007
|
readdirSync as readdirSync2,
|
|
1927
|
-
readFileSync as
|
|
2008
|
+
readFileSync as readFileSync4,
|
|
1928
2009
|
renameSync as renameSync3,
|
|
1929
2010
|
rmdirSync,
|
|
1930
2011
|
unlinkSync as unlinkSync2,
|
|
1931
2012
|
writeFileSync as writeFileSync5
|
|
1932
2013
|
} from "fs";
|
|
1933
|
-
import { join as
|
|
2014
|
+
import { join as join10 } from "path";
|
|
1934
2015
|
var INTRODUCE_HOOK_COMMAND = "agt impersonate introduce";
|
|
1935
2016
|
var SESSION_START_MATCHER = "startup";
|
|
1936
2017
|
function registerIntroduceHook(projectCwd, command = INTRODUCE_HOOK_COMMAND) {
|
|
1937
|
-
const claudeDir =
|
|
2018
|
+
const claudeDir = join10(projectCwd, ".claude");
|
|
1938
2019
|
const createdClaudeDir = !existsSync4(claudeDir);
|
|
1939
2020
|
mkdirSync5(claudeDir, { recursive: true });
|
|
1940
|
-
const settingsPath =
|
|
2021
|
+
const settingsPath = join10(claudeDir, "settings.local.json");
|
|
1941
2022
|
const settingsExisted = existsSync4(settingsPath);
|
|
1942
2023
|
const backupPath = settingsPath + BACKUP_SUFFIX;
|
|
1943
2024
|
let settings = {};
|
|
@@ -1945,7 +2026,7 @@ function registerIntroduceHook(projectCwd, command = INTRODUCE_HOOK_COMMAND) {
|
|
|
1945
2026
|
if (!existsSync4(backupPath)) {
|
|
1946
2027
|
copyFileSync(settingsPath, backupPath);
|
|
1947
2028
|
}
|
|
1948
|
-
settings = asPlainObject(safeParseJson(
|
|
2029
|
+
settings = asPlainObject(safeParseJson(readFileSync4(settingsPath, "utf-8")));
|
|
1949
2030
|
}
|
|
1950
2031
|
const hooks = asPlainObject(settings["hooks"]);
|
|
1951
2032
|
const existing = Array.isArray(hooks[SESSION_START_KEY]) ? [...hooks[SESSION_START_KEY]] : [];
|
|
@@ -2018,17 +2099,17 @@ import {
|
|
|
2018
2099
|
existsSync as existsSync5,
|
|
2019
2100
|
mkdirSync as mkdirSync6,
|
|
2020
2101
|
readdirSync as readdirSync3,
|
|
2021
|
-
readFileSync as
|
|
2102
|
+
readFileSync as readFileSync5,
|
|
2022
2103
|
renameSync as renameSync4,
|
|
2023
2104
|
rmdirSync as rmdirSync2,
|
|
2024
2105
|
unlinkSync as unlinkSync3,
|
|
2025
2106
|
writeFileSync as writeFileSync6
|
|
2026
2107
|
} from "fs";
|
|
2027
|
-
import { homedir as
|
|
2028
|
-
import { dirname as dirname2, join as
|
|
2108
|
+
import { homedir as homedir5 } from "os";
|
|
2109
|
+
import { dirname as dirname2, join as join11 } from "path";
|
|
2029
2110
|
import { fileURLToPath } from "url";
|
|
2030
|
-
var INSTALLED_STATUSLINE_PATH =
|
|
2031
|
-
|
|
2111
|
+
var INSTALLED_STATUSLINE_PATH = join11(
|
|
2112
|
+
homedir5(),
|
|
2032
2113
|
".augmented-impersonate",
|
|
2033
2114
|
"statusline.sh"
|
|
2034
2115
|
);
|
|
@@ -2037,7 +2118,7 @@ var STATUS_LINE_COMMAND_TYPE = "command";
|
|
|
2037
2118
|
function installStatusLineAsset(targetPath = INSTALLED_STATUSLINE_PATH) {
|
|
2038
2119
|
mkdirSync6(dirname2(targetPath), { recursive: true });
|
|
2039
2120
|
const source = resolveBundledAssetPath();
|
|
2040
|
-
const needsCopy = !existsSync5(targetPath) ||
|
|
2121
|
+
const needsCopy = !existsSync5(targetPath) || readFileSync5(source, "utf-8") !== readFileSync5(targetPath, "utf-8");
|
|
2041
2122
|
if (needsCopy) {
|
|
2042
2123
|
copyFileSync2(source, targetPath);
|
|
2043
2124
|
chmodSync2(targetPath, 493);
|
|
@@ -2047,10 +2128,10 @@ function registerStatusLine(projectCwd, options = {}) {
|
|
|
2047
2128
|
if (options.installAsset !== false) {
|
|
2048
2129
|
installStatusLineAsset();
|
|
2049
2130
|
}
|
|
2050
|
-
const claudeDir =
|
|
2131
|
+
const claudeDir = join11(projectCwd, ".claude");
|
|
2051
2132
|
const createdClaudeDir = !existsSync5(claudeDir);
|
|
2052
2133
|
mkdirSync6(claudeDir, { recursive: true });
|
|
2053
|
-
const settingsPath =
|
|
2134
|
+
const settingsPath = join11(claudeDir, "settings.local.json");
|
|
2054
2135
|
const settingsExisted = existsSync5(settingsPath);
|
|
2055
2136
|
const backupPath = settingsPath + BACKUP_SUFFIX;
|
|
2056
2137
|
let settings = {};
|
|
@@ -2058,7 +2139,7 @@ function registerStatusLine(projectCwd, options = {}) {
|
|
|
2058
2139
|
if (!existsSync5(backupPath)) {
|
|
2059
2140
|
copyFileSync2(settingsPath, backupPath);
|
|
2060
2141
|
}
|
|
2061
|
-
settings = asPlainObject2(safeParseJson2(
|
|
2142
|
+
settings = asPlainObject2(safeParseJson2(readFileSync5(settingsPath, "utf-8")));
|
|
2062
2143
|
}
|
|
2063
2144
|
settings[STATUS_LINE_KEY] = {
|
|
2064
2145
|
type: STATUS_LINE_COMMAND_TYPE,
|
|
@@ -2098,11 +2179,11 @@ function resolveBundledAssetPath() {
|
|
|
2098
2179
|
const moduleDir = dirname2(fileURLToPath(import.meta.url));
|
|
2099
2180
|
const candidates = [
|
|
2100
2181
|
// Built output: dist/<chunk>.js → dist/assets/...
|
|
2101
|
-
|
|
2182
|
+
join11(moduleDir, "assets", "impersonate-statusline.sh"),
|
|
2102
2183
|
// Built output sibling case: dist/<sub>/<chunk>.js → dist/assets/...
|
|
2103
|
-
|
|
2184
|
+
join11(moduleDir, "..", "assets", "impersonate-statusline.sh"),
|
|
2104
2185
|
// Dev source: src/lib/impersonate-statusline.ts → ../../assets/...
|
|
2105
|
-
|
|
2186
|
+
join11(moduleDir, "..", "..", "assets", "impersonate-statusline.sh")
|
|
2106
2187
|
];
|
|
2107
2188
|
for (const candidate of candidates) {
|
|
2108
2189
|
if (existsSync5(candidate)) return candidate;
|
|
@@ -2113,7 +2194,7 @@ function resolveBundledAssetPath() {
|
|
|
2113
2194
|
);
|
|
2114
2195
|
}
|
|
2115
2196
|
function stripStatusLineKey(settingsPath) {
|
|
2116
|
-
const settings = asPlainObject2(safeParseJson2(
|
|
2197
|
+
const settings = asPlainObject2(safeParseJson2(readFileSync5(settingsPath, "utf-8")));
|
|
2117
2198
|
if (!(STATUS_LINE_KEY in settings)) return;
|
|
2118
2199
|
delete settings[STATUS_LINE_KEY];
|
|
2119
2200
|
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
@@ -2310,11 +2391,11 @@ async function impersonateConnectCommand(token, options = {}) {
|
|
|
2310
2391
|
spinner.text = "Writing persona files\u2026";
|
|
2311
2392
|
const personaDir = ensureCodeNameDir(bundle.agent.code_name);
|
|
2312
2393
|
writeFileSync7(
|
|
2313
|
-
|
|
2394
|
+
join12(personaDir, "CLAUDE.md"),
|
|
2314
2395
|
bundle.artifacts["CLAUDE.md"]
|
|
2315
2396
|
);
|
|
2316
2397
|
writeFileSync7(
|
|
2317
|
-
|
|
2398
|
+
join12(personaDir, ".mcp.json"),
|
|
2318
2399
|
rewriteMcpJsonForImpersonation(bundle.artifacts[".mcp.json"], {
|
|
2319
2400
|
operatorHome: process.env.HOME ?? "",
|
|
2320
2401
|
operatorPath: resolveOperatorPath(),
|
|
@@ -2343,8 +2424,8 @@ async function impersonateConnectCommand(token, options = {}) {
|
|
|
2343
2424
|
let statusLineBackup;
|
|
2344
2425
|
try {
|
|
2345
2426
|
for (const file of SWAP_FILES) {
|
|
2346
|
-
const projectPath =
|
|
2347
|
-
const kind = swapInPersonaFile(projectPath,
|
|
2427
|
+
const projectPath = join12(projectCwd, file);
|
|
2428
|
+
const kind = swapInPersonaFile(projectPath, join12(personaDir, file));
|
|
2348
2429
|
backups[file] = kind;
|
|
2349
2430
|
swapped.push({ file, kind });
|
|
2350
2431
|
}
|
|
@@ -2380,7 +2461,7 @@ async function impersonateConnectCommand(token, options = {}) {
|
|
|
2380
2461
|
}
|
|
2381
2462
|
for (const { file, kind } of [...swapped].reverse()) {
|
|
2382
2463
|
try {
|
|
2383
|
-
restoreSwapped(
|
|
2464
|
+
restoreSwapped(join12(projectCwd, file), kind);
|
|
2384
2465
|
} catch {
|
|
2385
2466
|
}
|
|
2386
2467
|
}
|
|
@@ -2588,7 +2669,7 @@ async function performImpersonateExit(manifest, opts) {
|
|
|
2588
2669
|
}
|
|
2589
2670
|
const restored = [];
|
|
2590
2671
|
for (const [file, kind] of Object.entries(manifest.backups)) {
|
|
2591
|
-
const projectPath =
|
|
2672
|
+
const projectPath = join12(manifest.project_cwd, file);
|
|
2592
2673
|
try {
|
|
2593
2674
|
restoreSwapped(projectPath, kind);
|
|
2594
2675
|
restored.push(file);
|
|
@@ -2666,8 +2747,8 @@ async function impersonateIntroduceCommand() {
|
|
|
2666
2747
|
const manifest = readActiveManifest(process.cwd());
|
|
2667
2748
|
if (!manifest || isExpired(manifest)) return;
|
|
2668
2749
|
const cwd = manifest.project_cwd;
|
|
2669
|
-
const identity = readClaudeMdIdentity(
|
|
2670
|
-
const integrations = readMcpIntegrations(
|
|
2750
|
+
const identity = readClaudeMdIdentity(join12(cwd, "CLAUDE.md"));
|
|
2751
|
+
const integrations = readMcpIntegrations(join12(cwd, ".mcp.json"));
|
|
2671
2752
|
const intro = buildIntroduction({
|
|
2672
2753
|
displayName: identity.displayName,
|
|
2673
2754
|
codeName: manifest.code_name,
|
|
@@ -2680,14 +2761,14 @@ async function impersonateIntroduceCommand() {
|
|
|
2680
2761
|
}
|
|
2681
2762
|
function readClaudeMdIdentity(path) {
|
|
2682
2763
|
try {
|
|
2683
|
-
return parseIdentityFromClaudeMd(
|
|
2764
|
+
return parseIdentityFromClaudeMd(readFileSync6(path, "utf-8"));
|
|
2684
2765
|
} catch {
|
|
2685
2766
|
return { displayName: null, role: null };
|
|
2686
2767
|
}
|
|
2687
2768
|
}
|
|
2688
2769
|
function readMcpIntegrations(path) {
|
|
2689
2770
|
try {
|
|
2690
|
-
return parseIntegrationsFromMcpJson(
|
|
2771
|
+
return parseIntegrationsFromMcpJson(readFileSync6(path, "utf-8"));
|
|
2691
2772
|
} catch {
|
|
2692
2773
|
return [];
|
|
2693
2774
|
}
|
|
@@ -2695,12 +2776,12 @@ function readMcpIntegrations(path) {
|
|
|
2695
2776
|
function resolveCliMcpBundleDir() {
|
|
2696
2777
|
const moduleDir = dirname3(fileURLToPath2(import.meta.url));
|
|
2697
2778
|
const candidates = [
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2779
|
+
join12(moduleDir, "mcp"),
|
|
2780
|
+
join12(moduleDir, "..", "mcp"),
|
|
2781
|
+
join12(moduleDir, "..", "..", "mcp")
|
|
2701
2782
|
];
|
|
2702
2783
|
for (const candidate of candidates) {
|
|
2703
|
-
if (existsSync6(
|
|
2784
|
+
if (existsSync6(join12(candidate, "index.js"))) return candidate;
|
|
2704
2785
|
}
|
|
2705
2786
|
return candidates[candidates.length - 1];
|
|
2706
2787
|
}
|
|
@@ -2729,7 +2810,7 @@ function buildImpersonateClaudeLaunch(projectCwd, inheritEnv = process.env, agen
|
|
|
2729
2810
|
args: [
|
|
2730
2811
|
"--strict-mcp-config",
|
|
2731
2812
|
"--mcp-config",
|
|
2732
|
-
|
|
2813
|
+
join12(projectCwd, ".mcp.json")
|
|
2733
2814
|
],
|
|
2734
2815
|
env
|
|
2735
2816
|
};
|
|
@@ -2742,7 +2823,7 @@ import ora11 from "ora";
|
|
|
2742
2823
|
// ../../packages/core/dist/drift/live-state-reader.js
|
|
2743
2824
|
import { readFile } from "fs/promises";
|
|
2744
2825
|
import { createHash as createHash2 } from "crypto";
|
|
2745
|
-
import { join as
|
|
2826
|
+
import { join as join13 } from "path";
|
|
2746
2827
|
import JSON5 from "json5";
|
|
2747
2828
|
async function hashFile(filePath) {
|
|
2748
2829
|
try {
|
|
@@ -2766,8 +2847,8 @@ async function readLiveState(options) {
|
|
|
2766
2847
|
const toolsFile = trackedFiles.find((f) => f.includes("TOOLS")) ?? "TOOLS.md";
|
|
2767
2848
|
const [frameworkConfig, charterHash, toolsHash] = await Promise.all([
|
|
2768
2849
|
readJsonFile(options.configPath),
|
|
2769
|
-
hashFile(
|
|
2770
|
-
hashFile(
|
|
2850
|
+
hashFile(join13(options.teamDir, charterFile)),
|
|
2851
|
+
hashFile(join13(options.teamDir, toolsFile))
|
|
2771
2852
|
]);
|
|
2772
2853
|
return {
|
|
2773
2854
|
frameworkConfig,
|
|
@@ -3467,15 +3548,15 @@ function terminate(child) {
|
|
|
3467
3548
|
// src/commands/manager-watch.tsx
|
|
3468
3549
|
import { useEffect, useState, useMemo } from "react";
|
|
3469
3550
|
import { render, Box, Text, useApp, useInput } from "ink";
|
|
3470
|
-
import { existsSync as existsSync7, readFileSync as
|
|
3471
|
-
import { homedir as
|
|
3472
|
-
import { join as
|
|
3551
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, statSync, openSync, readSync, closeSync } from "fs";
|
|
3552
|
+
import { homedir as homedir6 } from "os";
|
|
3553
|
+
import { join as join14 } from "path";
|
|
3473
3554
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3474
3555
|
var REFRESH_MS = 1e3;
|
|
3475
3556
|
var LOG_TAIL_LINES = 200;
|
|
3476
3557
|
var DETAIL_RECENT_LINES = 50;
|
|
3477
3558
|
function managerWatchCommand(opts = {}) {
|
|
3478
|
-
const configDir = opts.configDir ??
|
|
3559
|
+
const configDir = opts.configDir ?? join14(homedir6(), ".augmented");
|
|
3479
3560
|
const paths = getManagerPaths(configDir);
|
|
3480
3561
|
const isTty = process.stdout.isTTY === true && process.stdin.isTTY === true;
|
|
3481
3562
|
if (opts.noTui || !isTty) {
|
|
@@ -3500,7 +3581,7 @@ function managerWatchCommand(opts = {}) {
|
|
|
3500
3581
|
function readState(stateFile) {
|
|
3501
3582
|
try {
|
|
3502
3583
|
if (!existsSync7(stateFile)) return null;
|
|
3503
|
-
const raw =
|
|
3584
|
+
const raw = readFileSync7(stateFile, "utf-8");
|
|
3504
3585
|
return JSON.parse(raw);
|
|
3505
3586
|
} catch {
|
|
3506
3587
|
return null;
|
|
@@ -3757,7 +3838,7 @@ Start the manager first: agt manager start
|
|
|
3757
3838
|
}
|
|
3758
3839
|
let lastSize = 0;
|
|
3759
3840
|
try {
|
|
3760
|
-
const initial =
|
|
3841
|
+
const initial = readFileSync7(logFile, "utf-8");
|
|
3761
3842
|
process.stdout.write(initial);
|
|
3762
3843
|
lastSize = statSync(logFile).size;
|
|
3763
3844
|
} catch (err) {
|
|
@@ -3793,12 +3874,12 @@ Start the manager first: agt manager start
|
|
|
3793
3874
|
|
|
3794
3875
|
// src/commands/agent.ts
|
|
3795
3876
|
import chalk14 from "chalk";
|
|
3796
|
-
import { readFileSync as
|
|
3797
|
-
import { join as
|
|
3877
|
+
import { readFileSync as readFileSync8, existsSync as existsSync8 } from "fs";
|
|
3878
|
+
import { join as join15 } from "path";
|
|
3798
3879
|
async function agentShowCommand(codeName, opts) {
|
|
3799
3880
|
const json = isJsonMode();
|
|
3800
|
-
const unifiedDir =
|
|
3801
|
-
const legacyDir =
|
|
3881
|
+
const unifiedDir = join15(opts.configDir, codeName, "provision");
|
|
3882
|
+
const legacyDir = join15(opts.configDir, codeName, "claudecode", "provision");
|
|
3802
3883
|
const agentDir = existsSync8(unifiedDir) ? unifiedDir : legacyDir;
|
|
3803
3884
|
const hasLocalConfig = existsSync8(agentDir);
|
|
3804
3885
|
let apiChannels = null;
|
|
@@ -3832,26 +3913,26 @@ async function agentShowCommand(codeName, opts) {
|
|
|
3832
3913
|
let tools = null;
|
|
3833
3914
|
let agentState = null;
|
|
3834
3915
|
if (hasLocalConfig) {
|
|
3835
|
-
const charterPath =
|
|
3916
|
+
const charterPath = join15(agentDir, "CHARTER.md");
|
|
3836
3917
|
if (existsSync8(charterPath)) {
|
|
3837
|
-
const raw =
|
|
3918
|
+
const raw = readFileSync8(charterPath, "utf-8");
|
|
3838
3919
|
const parsed = extractFrontmatter(raw);
|
|
3839
3920
|
if (parsed.frontmatter) {
|
|
3840
3921
|
charter = parsed.frontmatter;
|
|
3841
3922
|
}
|
|
3842
3923
|
}
|
|
3843
|
-
const toolsPath =
|
|
3924
|
+
const toolsPath = join15(agentDir, "TOOLS.md");
|
|
3844
3925
|
if (existsSync8(toolsPath)) {
|
|
3845
|
-
const raw =
|
|
3926
|
+
const raw = readFileSync8(toolsPath, "utf-8");
|
|
3846
3927
|
const parsed = extractFrontmatter(raw);
|
|
3847
3928
|
if (parsed.frontmatter) {
|
|
3848
3929
|
tools = parsed.frontmatter;
|
|
3849
3930
|
}
|
|
3850
3931
|
}
|
|
3851
|
-
const statePath =
|
|
3932
|
+
const statePath = join15(opts.configDir, "manager-state.json");
|
|
3852
3933
|
if (existsSync8(statePath)) {
|
|
3853
3934
|
try {
|
|
3854
|
-
const raw =
|
|
3935
|
+
const raw = readFileSync8(statePath, "utf-8");
|
|
3855
3936
|
const state = JSON.parse(raw);
|
|
3856
3937
|
agentState = state.agents?.find((a) => a.codeName === codeName) ?? null;
|
|
3857
3938
|
} catch {
|
|
@@ -4170,24 +4251,24 @@ async function kanbanRecurringDisableCommand(titleOrId, opts) {
|
|
|
4170
4251
|
}
|
|
4171
4252
|
|
|
4172
4253
|
// src/commands/setup.ts
|
|
4173
|
-
import { existsSync as existsSync9, readFileSync as
|
|
4174
|
-
import { join as
|
|
4175
|
-
import { homedir as
|
|
4254
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, accessSync, constants as fsConstants } from "fs";
|
|
4255
|
+
import { join as join16, dirname as dirname4 } from "path";
|
|
4256
|
+
import { homedir as homedir7 } from "os";
|
|
4176
4257
|
import chalk16 from "chalk";
|
|
4177
4258
|
import ora14 from "ora";
|
|
4178
4259
|
function detectShellProfile() {
|
|
4179
4260
|
const shell = process.env["SHELL"] ?? "";
|
|
4180
|
-
const home =
|
|
4261
|
+
const home = homedir7();
|
|
4181
4262
|
if (shell.includes("zsh")) {
|
|
4182
|
-
return
|
|
4263
|
+
return join16(home, ".zshrc");
|
|
4183
4264
|
}
|
|
4184
4265
|
if (shell.includes("fish")) {
|
|
4185
|
-
const fishConfig =
|
|
4266
|
+
const fishConfig = join16(home, ".config", "fish", "config.fish");
|
|
4186
4267
|
return fishConfig;
|
|
4187
4268
|
}
|
|
4188
|
-
const bashrc =
|
|
4269
|
+
const bashrc = join16(home, ".bashrc");
|
|
4189
4270
|
if (existsSync9(bashrc)) return bashrc;
|
|
4190
|
-
return
|
|
4271
|
+
return join16(home, ".bash_profile");
|
|
4191
4272
|
}
|
|
4192
4273
|
function maybeWriteSystemWideEnv(apiUrl, apiKey, consoleUrl) {
|
|
4193
4274
|
const empty = { etcEnvironment: false, profileD: false, bashrc: false };
|
|
@@ -4220,7 +4301,7 @@ function writeEtcEnvironment(apiUrl, apiKey, consoleUrl) {
|
|
|
4220
4301
|
return false;
|
|
4221
4302
|
}
|
|
4222
4303
|
try {
|
|
4223
|
-
const current =
|
|
4304
|
+
const current = readFileSync9(envPath, "utf-8");
|
|
4224
4305
|
const stripped = current.split(/\r?\n/).filter((line) => !/^\s*(?:export\s+)?AGT_(?:HOST|API_KEY|CONSOLE_URL)=/.test(line)).join("\n");
|
|
4225
4306
|
const base = stripped.endsWith("\n") || stripped.length === 0 ? stripped : `${stripped}
|
|
4226
4307
|
`;
|
|
@@ -4269,7 +4350,7 @@ function ensureBashrcSourcesProfileD() {
|
|
|
4269
4350
|
return false;
|
|
4270
4351
|
}
|
|
4271
4352
|
try {
|
|
4272
|
-
const current =
|
|
4353
|
+
const current = readFileSync9(bashrc, "utf-8");
|
|
4273
4354
|
const marker = "# Augmented (agt) \u2014 source system-wide AGT env";
|
|
4274
4355
|
if (current.includes(marker)) return true;
|
|
4275
4356
|
const snippet = [
|
|
@@ -4413,7 +4494,7 @@ async function setupCommand(token, options = {}) {
|
|
|
4413
4494
|
mkdirSync7(profileDir, { recursive: true });
|
|
4414
4495
|
}
|
|
4415
4496
|
const marker = "# Augmented (agt) host configuration";
|
|
4416
|
-
const current = existsSync9(profilePath) ?
|
|
4497
|
+
const current = existsSync9(profilePath) ? readFileSync9(profilePath, "utf-8") : "";
|
|
4417
4498
|
let updated;
|
|
4418
4499
|
if (current.includes(marker)) {
|
|
4419
4500
|
updated = current.replace(
|
|
@@ -4444,7 +4525,7 @@ async function setupCommand(token, options = {}) {
|
|
|
4444
4525
|
const managerSpinner = ora14({ text: "Starting manager daemon\u2026", isSilent: json });
|
|
4445
4526
|
managerSpinner.start();
|
|
4446
4527
|
try {
|
|
4447
|
-
const configDir =
|
|
4528
|
+
const configDir = join16(homedir7(), ".augmented");
|
|
4448
4529
|
const { pid } = startWatchdog({ intervalMs: 1e4, configDir, detached: true });
|
|
4449
4530
|
managerSpinner.succeed(`Manager started (PID ${pid})`);
|
|
4450
4531
|
} catch (err) {
|
|
@@ -4749,7 +4830,7 @@ import { execFileSync, execSync } from "child_process";
|
|
|
4749
4830
|
import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
|
|
4750
4831
|
import chalk18 from "chalk";
|
|
4751
4832
|
import ora16 from "ora";
|
|
4752
|
-
var cliVersion = true ? "0.28.
|
|
4833
|
+
var cliVersion = true ? "0.28.209" : "dev";
|
|
4753
4834
|
async function fetchLatestVersion() {
|
|
4754
4835
|
const host2 = getHost();
|
|
4755
4836
|
if (!host2) return null;
|
|
@@ -4981,12 +5062,12 @@ async function checkForUpdateOnStartup() {
|
|
|
4981
5062
|
}
|
|
4982
5063
|
|
|
4983
5064
|
// src/commands/audit-subagents.ts
|
|
4984
|
-
import { homedir as
|
|
4985
|
-
import { join as
|
|
5065
|
+
import { homedir as homedir8 } from "os";
|
|
5066
|
+
import { join as join18 } from "path";
|
|
4986
5067
|
|
|
4987
5068
|
// src/lib/subagent-mcp-audit.ts
|
|
4988
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
4989
|
-
import { join as
|
|
5069
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync2 } from "fs";
|
|
5070
|
+
import { join as join17 } from "path";
|
|
4990
5071
|
function parseFrontmatter(content) {
|
|
4991
5072
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
4992
5073
|
if (!match) return null;
|
|
@@ -5036,7 +5117,7 @@ function findSubagentFiles(dir, depth = 0) {
|
|
|
5036
5117
|
const out = [];
|
|
5037
5118
|
const isAgentsDir = dir.endsWith("/agents") || dir.endsWith("\\agents");
|
|
5038
5119
|
for (const entry of entries) {
|
|
5039
|
-
const full =
|
|
5120
|
+
const full = join17(dir, entry);
|
|
5040
5121
|
let s;
|
|
5041
5122
|
try {
|
|
5042
5123
|
s = statSync2(full);
|
|
@@ -5060,7 +5141,7 @@ function auditSubagentMcpBindings(rootDirs) {
|
|
|
5060
5141
|
seen.add(file);
|
|
5061
5142
|
let content;
|
|
5062
5143
|
try {
|
|
5063
|
-
content =
|
|
5144
|
+
content = readFileSync10(file, "utf-8");
|
|
5064
5145
|
} catch {
|
|
5065
5146
|
continue;
|
|
5066
5147
|
}
|
|
@@ -5083,11 +5164,11 @@ function formatFinding(f) {
|
|
|
5083
5164
|
|
|
5084
5165
|
// src/commands/audit-subagents.ts
|
|
5085
5166
|
function defaultRoots() {
|
|
5086
|
-
const home =
|
|
5167
|
+
const home = homedir8();
|
|
5087
5168
|
return [
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5169
|
+
join18(home, ".claude", "agents"),
|
|
5170
|
+
join18(home, ".claude", "plugins"),
|
|
5171
|
+
join18(process.cwd(), ".claude", "agents")
|
|
5091
5172
|
];
|
|
5092
5173
|
}
|
|
5093
5174
|
async function auditSubagentsCommand(options = {}) {
|
|
@@ -5122,9 +5203,9 @@ async function auditSubagentsCommand(options = {}) {
|
|
|
5122
5203
|
}
|
|
5123
5204
|
|
|
5124
5205
|
// src/lib/mcp-render-allowlist-audit.ts
|
|
5125
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
5126
|
-
import { homedir as
|
|
5127
|
-
import { join as
|
|
5206
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync11, statSync as statSync3 } from "fs";
|
|
5207
|
+
import { homedir as homedir9 } from "os";
|
|
5208
|
+
import { join as join19 } from "path";
|
|
5128
5209
|
function expectedWildcard(serverKey) {
|
|
5129
5210
|
return `mcp__${serverKey.replace(/-/g, "_")}__*`;
|
|
5130
5211
|
}
|
|
@@ -5137,13 +5218,13 @@ function parseMcpWildcardsFromToolsLine(content) {
|
|
|
5137
5218
|
}
|
|
5138
5219
|
function readMcpServerKeys(mcpJsonPath) {
|
|
5139
5220
|
try {
|
|
5140
|
-
const config = JSON.parse(
|
|
5221
|
+
const config = JSON.parse(readFileSync11(mcpJsonPath, "utf-8"));
|
|
5141
5222
|
return Object.keys(config.mcpServers ?? {});
|
|
5142
5223
|
} catch {
|
|
5143
5224
|
return null;
|
|
5144
5225
|
}
|
|
5145
5226
|
}
|
|
5146
|
-
function auditMcpRenderAllowlist(rootDir =
|
|
5227
|
+
function auditMcpRenderAllowlist(rootDir = join19(homedir9(), ".augmented")) {
|
|
5147
5228
|
const findings = [];
|
|
5148
5229
|
let entries;
|
|
5149
5230
|
try {
|
|
@@ -5152,7 +5233,7 @@ function auditMcpRenderAllowlist(rootDir = join18(homedir8(), ".augmented")) {
|
|
|
5152
5233
|
return findings;
|
|
5153
5234
|
}
|
|
5154
5235
|
for (const entry of entries) {
|
|
5155
|
-
const agentDir =
|
|
5236
|
+
const agentDir = join19(rootDir, entry);
|
|
5156
5237
|
let s;
|
|
5157
5238
|
try {
|
|
5158
5239
|
s = statSync3(agentDir);
|
|
@@ -5161,15 +5242,15 @@ function auditMcpRenderAllowlist(rootDir = join18(homedir8(), ".augmented")) {
|
|
|
5161
5242
|
}
|
|
5162
5243
|
if (!s.isDirectory() || entry.startsWith("_") || entry.startsWith(".")) continue;
|
|
5163
5244
|
for (const scope of ["provision", "project"]) {
|
|
5164
|
-
const mcpJsonPath = scope === "provision" ?
|
|
5245
|
+
const mcpJsonPath = scope === "provision" ? join19(agentDir, "provision", ".mcp.json") : join19(agentDir, "project", ".mcp.json");
|
|
5165
5246
|
const keys = readMcpServerKeys(mcpJsonPath);
|
|
5166
5247
|
if (keys === null || keys.length === 0) continue;
|
|
5167
5248
|
const expected = new Set(keys.map(expectedWildcard));
|
|
5168
5249
|
for (const subagent of ["channel-message-handler", "augmented-worker"]) {
|
|
5169
|
-
const mdPath = scope === "provision" ?
|
|
5250
|
+
const mdPath = scope === "provision" ? join19(agentDir, ".claude", "agents", `${subagent}.md`) : join19(agentDir, "project", ".claude", "agents", `${subagent}.md`);
|
|
5170
5251
|
let content;
|
|
5171
5252
|
try {
|
|
5172
|
-
content =
|
|
5253
|
+
content = readFileSync11(mdPath, "utf-8");
|
|
5173
5254
|
} catch {
|
|
5174
5255
|
continue;
|
|
5175
5256
|
}
|
|
@@ -5227,12 +5308,12 @@ async function auditMcpRenderCommand(options = {}) {
|
|
|
5227
5308
|
}
|
|
5228
5309
|
|
|
5229
5310
|
// src/commands/audit-secrets.ts
|
|
5230
|
-
import { homedir as
|
|
5231
|
-
import { join as
|
|
5311
|
+
import { homedir as homedir10 } from "os";
|
|
5312
|
+
import { join as join21 } from "path";
|
|
5232
5313
|
|
|
5233
5314
|
// src/lib/secret-leak-audit.ts
|
|
5234
|
-
import { readdirSync as readdirSync6, readFileSync as
|
|
5235
|
-
import { join as
|
|
5315
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync12, statSync as statSync4 } from "fs";
|
|
5316
|
+
import { join as join20 } from "path";
|
|
5236
5317
|
var SECRET_KEY_NAME_RE = /TOKEN|KEY|SECRET|BEARER|PASSWORD/i;
|
|
5237
5318
|
function isTemplated(value) {
|
|
5238
5319
|
return value.includes("${");
|
|
@@ -5258,7 +5339,7 @@ function scanMcpFile(file, agent2, findings) {
|
|
|
5258
5339
|
}
|
|
5259
5340
|
let parsed;
|
|
5260
5341
|
try {
|
|
5261
|
-
parsed = JSON.parse(
|
|
5342
|
+
parsed = JSON.parse(readFileSync12(file, "utf-8"));
|
|
5262
5343
|
} catch {
|
|
5263
5344
|
return;
|
|
5264
5345
|
}
|
|
@@ -5302,15 +5383,15 @@ function auditSecretLeaks(augmentedRoot) {
|
|
|
5302
5383
|
return findings;
|
|
5303
5384
|
}
|
|
5304
5385
|
for (const agent2 of agents) {
|
|
5305
|
-
const agentDir =
|
|
5386
|
+
const agentDir = join20(augmentedRoot, agent2);
|
|
5306
5387
|
try {
|
|
5307
5388
|
if (!statSync4(agentDir).isDirectory()) continue;
|
|
5308
5389
|
} catch {
|
|
5309
5390
|
continue;
|
|
5310
5391
|
}
|
|
5311
|
-
scanMcpFile(
|
|
5312
|
-
scanMcpFile(
|
|
5313
|
-
scanEnvIntegrations(
|
|
5392
|
+
scanMcpFile(join20(agentDir, "provision", ".mcp.json"), agent2, findings);
|
|
5393
|
+
scanMcpFile(join20(agentDir, "project", ".mcp.json"), agent2, findings);
|
|
5394
|
+
scanEnvIntegrations(join20(agentDir, ".env.integrations"), agent2, findings);
|
|
5314
5395
|
}
|
|
5315
5396
|
return findings;
|
|
5316
5397
|
}
|
|
@@ -5336,7 +5417,7 @@ function describe(f) {
|
|
|
5336
5417
|
return `secret file is mode ${f.mode} (expected 0600)`;
|
|
5337
5418
|
}
|
|
5338
5419
|
async function auditSecretsCommand(options = {}) {
|
|
5339
|
-
const root = options.root ??
|
|
5420
|
+
const root = options.root ?? join21(homedir10(), ".augmented");
|
|
5340
5421
|
const findings = auditSecretLeaks(root);
|
|
5341
5422
|
if (options.json) {
|
|
5342
5423
|
process.stdout.write(`${JSON.stringify({ findings, root }, null, 2)}
|
|
@@ -5372,8 +5453,8 @@ async function auditSecretsCommand(options = {}) {
|
|
|
5372
5453
|
}
|
|
5373
5454
|
|
|
5374
5455
|
// src/commands/integration.ts
|
|
5375
|
-
import { homedir as
|
|
5376
|
-
import { join as
|
|
5456
|
+
import { homedir as homedir11 } from "os";
|
|
5457
|
+
import { join as join22 } from "path";
|
|
5377
5458
|
import chalk19 from "chalk";
|
|
5378
5459
|
import ora17 from "ora";
|
|
5379
5460
|
async function fetchAgents() {
|
|
@@ -5476,7 +5557,7 @@ async function integrationProbeCommand(agentCodeName, slug) {
|
|
|
5476
5557
|
process.exitCode = 1;
|
|
5477
5558
|
return;
|
|
5478
5559
|
}
|
|
5479
|
-
const projectDir =
|
|
5560
|
+
const projectDir = join22(homedir11(), ".augmented", agentCodeName, "project");
|
|
5480
5561
|
const probeEnv = buildProbeEnv(projectDir);
|
|
5481
5562
|
const probeDeps = buildConnectivityProbeDeps(projectDir, probeEnv);
|
|
5482
5563
|
const sourceType = integ.source_type ?? null;
|
|
@@ -5763,7 +5844,7 @@ function handleError(err) {
|
|
|
5763
5844
|
}
|
|
5764
5845
|
|
|
5765
5846
|
// src/bin/agt.ts
|
|
5766
|
-
var cliVersion2 = true ? "0.28.
|
|
5847
|
+
var cliVersion2 = true ? "0.28.209" : "dev";
|
|
5767
5848
|
var program = new Command();
|
|
5768
5849
|
program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
|
|
5769
5850
|
program.hook("preAction", async (thisCommand, actionCommand) => {
|
|
@@ -5783,6 +5864,9 @@ var flags = program.command("flags").description("Inspect feature flags resolved
|
|
|
5783
5864
|
flags.command("resolve").description("Print each flag\u2019s effective value and source layer (env / heartbeat-cache / compiled default)").option("--flag <key>", "Resolve a single flag by key instead of all registered flags").option("--host", "Show host-cache diagnostics (unrecognised cached keys from a newer API)").option("--config-dir <path>", "Manager config dir holding flags-cache.json (default ~/.augmented)").action((opts) => {
|
|
5784
5865
|
flagsResolveCommand(opts);
|
|
5785
5866
|
});
|
|
5867
|
+
program.command("probe-tools", { hidden: true }).description("Run a one-shot session-tool-bind probe for one agent and print JSON verdicts").requiredOption("--agent-id <uuid>", "Agent UUID to probe").requiredOption("--code-name <name>", "Agent code_name (resolves its project dir)").option("--json", "Emit JSON (always on; accepted for symmetry)").action((opts) => {
|
|
5868
|
+
return probeToolsCommand(opts);
|
|
5869
|
+
});
|
|
5786
5870
|
program.command("setup <token>").description("One-command host setup: exchange provisioning token, configure env vars, verify, and start manager").option(
|
|
5787
5871
|
"--api-host <url>",
|
|
5788
5872
|
// ENG-5831: required when AGT_HOST is not set in the shell — the setup
|
|
@@ -5860,16 +5944,16 @@ host.command("pair <host-name>").description("Start an SSM port-forward + shell
|
|
|
5860
5944
|
})
|
|
5861
5945
|
);
|
|
5862
5946
|
var manager = program.command("manager").description("Host config sync daemon \u2014 keeps local agent files in sync with API");
|
|
5863
|
-
manager.command("start").description("Start the manager daemon (polls API for config changes and detects local drift)").option("--interval <seconds>", "Poll interval in seconds (min 5)", "10").option("--config-dir <dir>", "Config directory for agent files",
|
|
5864
|
-
manager.command("stop").description("Stop the running manager daemon").option("--config-dir <dir>", "Config directory for agent files",
|
|
5865
|
-
manager.command("status").description("Show the current manager daemon status and discovered agents").option("--config-dir <dir>", "Config directory for agent files",
|
|
5866
|
-
manager.command("watch").description("Live TUI dashboard \u2014 per-agent boxes, drill-in, log tail. Read-only (ENG-4555).").option("--config-dir <dir>", "Config directory for agent files",
|
|
5867
|
-
manager.command("install").description("Install OS-level supervisor (launchd LaunchAgent on macOS) so the manager auto-restarts after crash, reboot, or self-update (ENG-4593)").option("--interval <seconds>", "Poll interval in seconds (min 5)", "10").option("--config-dir <dir>", "Config directory for agent files",
|
|
5947
|
+
manager.command("start").description("Start the manager daemon (polls API for config changes and detects local drift)").option("--interval <seconds>", "Poll interval in seconds (min 5)", "10").option("--config-dir <dir>", "Config directory for agent files", join23(homedir12(), ".augmented")).option("--supervise", "Wrap the manager in a respawn-on-clean-exit loop so auto-upgrades can restart it transparently (ENG-4488)", false).action(managerStartCommand);
|
|
5948
|
+
manager.command("stop").description("Stop the running manager daemon").option("--config-dir <dir>", "Config directory for agent files", join23(homedir12(), ".augmented")).action(managerStopCommand);
|
|
5949
|
+
manager.command("status").description("Show the current manager daemon status and discovered agents").option("--config-dir <dir>", "Config directory for agent files", join23(homedir12(), ".augmented")).action(managerStatusCommand);
|
|
5950
|
+
manager.command("watch").description("Live TUI dashboard \u2014 per-agent boxes, drill-in, log tail. Read-only (ENG-4555).").option("--config-dir <dir>", "Config directory for agent files", join23(homedir12(), ".augmented")).option("--no-tui", "Skip the TUI and stream the manager log to stdout instead (CI / scripts)").action(managerWatchCommand);
|
|
5951
|
+
manager.command("install").description("Install OS-level supervisor (launchd LaunchAgent on macOS) so the manager auto-restarts after crash, reboot, or self-update (ENG-4593)").option("--interval <seconds>", "Poll interval in seconds (min 5)", "10").option("--config-dir <dir>", "Config directory for agent files", join23(homedir12(), ".augmented")).action(managerInstallCommand);
|
|
5868
5952
|
manager.command("uninstall").description("Remove the OS-level supervisor (launchctl unload + delete plist on macOS). Idempotent.").action(managerUninstallCommand);
|
|
5869
5953
|
manager.command("install-system-unit").description("Install a system-level systemd unit (Linux, root) so the manager auto-starts on every boot. For headless EC2 hosts \u2014 survives reboot without `loginctl enable-linger`. (ENG-4706)").option("--interval <seconds>", "Poll interval in seconds (min 5)", "10").option("--config-dir <dir>", "Config directory for agent files (defaults to /root/.augmented or /home/<user>/.augmented)").option("--user <name>", "Unix user the manager runs as", "root").action(managerInstallSystemUnitCommand);
|
|
5870
5954
|
manager.command("uninstall-system-unit").description("Remove the system-level systemd unit (Linux, root). Idempotent. (ENG-4706)").action(managerUninstallSystemUnitCommand);
|
|
5871
5955
|
var agent = program.command("agent").description("Inspect and manage agents");
|
|
5872
|
-
agent.command("show <code-name>").description("Display an agent's provisioned configuration").option("--config-dir <dir>", "Config directory",
|
|
5956
|
+
agent.command("show <code-name>").description("Display an agent's provisioned configuration").option("--config-dir <dir>", "Config directory", join23(homedir12(), ".augmented")).option("--all-channels", "Show all channels (including disabled)").action(agentShowCommand);
|
|
5873
5957
|
var kanban = program.command("kanban").description("Manage agent kanban boards");
|
|
5874
5958
|
kanban.command("list").description("List kanban board items for an agent").requiredOption("--agent <code-name>", "Agent code name").action(kanbanListCommand);
|
|
5875
5959
|
kanban.command("add <title>").description("Add a new item to an agent kanban board").requiredOption("--agent <code-name>", "Agent code name").option("--priority <1|2|3>", "Priority: 1=high, 2=medium, 3=low", "2").option("--status <status>", "Initial status: backlog | todo | in_progress", "todo").option("--description <text>", "Item description").option("--estimate <minutes>", "Estimated time in minutes").option("--deliverable <text>", "Expected output/deliverable").action(kanbanAddCommand);
|