@archme/cli 0.25.1 → 0.25.3
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/cli.js +74 -31
- package/package.json +1 -1
- package/sandbox-image.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -22776,6 +22776,7 @@ async function resolveOrCreateProject(supabase, userId, fullSlug) {
|
|
|
22776
22776
|
);
|
|
22777
22777
|
}
|
|
22778
22778
|
return {
|
|
22779
|
+
orgId: org.id,
|
|
22779
22780
|
orgSlug: org.slug,
|
|
22780
22781
|
projectSlug,
|
|
22781
22782
|
projectId,
|
|
@@ -22810,6 +22811,7 @@ async function claimSignupDefaultProject(supabase, org, projectSlug) {
|
|
|
22810
22811
|
const { error: renameErr } = await supabase.from("projects").update({ name: projectSlug, slug: projectSlug }).eq("id", row.id);
|
|
22811
22812
|
if (renameErr) return null;
|
|
22812
22813
|
return {
|
|
22814
|
+
orgId: org.id,
|
|
22813
22815
|
orgSlug: org.slug,
|
|
22814
22816
|
projectSlug,
|
|
22815
22817
|
projectId: row.id,
|
|
@@ -22830,6 +22832,16 @@ async function findProject(supabase, fullSlug) {
|
|
|
22830
22832
|
if (!org) throw new Error(`org \`${orgSlug}\` not found`);
|
|
22831
22833
|
return fetchExistingProject(supabase, org, projectSlug);
|
|
22832
22834
|
}
|
|
22835
|
+
async function findOrgId(supabase, fullSlug) {
|
|
22836
|
+
const orgSlug = fullSlug.split("/")[0];
|
|
22837
|
+
if (!orgSlug) throw new Error(`invalid project slug \`${fullSlug}\` \u2014 expected \`org/project\``);
|
|
22838
|
+
const org = await mustQuery(
|
|
22839
|
+
supabase.from("organizations").select("id").eq("slug", orgSlug).maybeSingle(),
|
|
22840
|
+
"org lookup failed"
|
|
22841
|
+
);
|
|
22842
|
+
if (!org) throw new Error(`org \`${orgSlug}\` not found`);
|
|
22843
|
+
return org.id;
|
|
22844
|
+
}
|
|
22833
22845
|
async function fetchExistingProject(supabase, org, projectSlug) {
|
|
22834
22846
|
const project = await mustQuery(
|
|
22835
22847
|
supabase.from("projects").select("id, slug").eq("org_id", org.id).eq("slug", projectSlug).is("deleted_at", null).maybeSingle(),
|
|
@@ -22845,6 +22857,7 @@ async function fetchExistingProject(supabase, org, projectSlug) {
|
|
|
22845
22857
|
const defaultBranch = rows.find((b) => b.is_default)?.name ?? DEFAULT_BRANCH_NAME;
|
|
22846
22858
|
const architectureBranch = resolveArchitectureBranchName(rows.map((b) => ({ name: b.name, isDefault: b.is_default }))) ?? defaultBranch;
|
|
22847
22859
|
return {
|
|
22860
|
+
orgId: org.id,
|
|
22848
22861
|
orgSlug: org.slug,
|
|
22849
22862
|
projectSlug,
|
|
22850
22863
|
projectId,
|
|
@@ -24565,7 +24578,7 @@ async function completeClaudeRun(ctx, job, deviceId, run) {
|
|
|
24565
24578
|
}
|
|
24566
24579
|
async function spawnTriage(jobId, mcpConfigPath, cwd, opts) {
|
|
24567
24580
|
if (shuttingDown) return { ok: false, summary: "skipped: the daemon is shutting down" };
|
|
24568
|
-
const proc = spawnClaude({
|
|
24581
|
+
const proc = spawnClaude(hostSpawnOpts({
|
|
24569
24582
|
prompt: opts.prompt,
|
|
24570
24583
|
mcpConfigPath,
|
|
24571
24584
|
cwd,
|
|
@@ -24574,10 +24587,9 @@ async function spawnTriage(jobId, mcpConfigPath, cwd, opts) {
|
|
|
24574
24587
|
allowedTools: TRIAGE_ALLOWED_TOOLS,
|
|
24575
24588
|
builtinTools: TRIAGE_BUILTIN_TOOLS,
|
|
24576
24589
|
jsonOutput: true,
|
|
24577
|
-
settingSources: "user"
|
|
24590
|
+
settingSources: "user"
|
|
24578
24591
|
// the checkout is the customer's; see runJob's spawn
|
|
24579
|
-
|
|
24580
|
-
});
|
|
24592
|
+
}));
|
|
24581
24593
|
inFlight.set(jobId, proc);
|
|
24582
24594
|
const result = await proc;
|
|
24583
24595
|
const parsed = parseClaudeResult(result.stdout ? String(result.stdout) : "");
|
|
@@ -24615,8 +24627,11 @@ async function rpcStoreLogs(ctx, jobId, deviceId, logs) {
|
|
|
24615
24627
|
}), ctx.reLogin);
|
|
24616
24628
|
if (error) console.error(`[${jobId}] store logs error:`, error.message);
|
|
24617
24629
|
}
|
|
24630
|
+
function hostSpawnOpts(opts) {
|
|
24631
|
+
return { ...opts, agentEnv: true, promptViaStdin: true };
|
|
24632
|
+
}
|
|
24618
24633
|
function hostDigestSpawnOpts(o2) {
|
|
24619
|
-
return
|
|
24634
|
+
return hostSpawnOpts(digestSpawnOpts(o2));
|
|
24620
24635
|
}
|
|
24621
24636
|
async function runDigest(ctx, job, claimDeviceId) {
|
|
24622
24637
|
const log = (msg) => console.log(`[${job.id}] ${msg}`);
|
|
@@ -25179,7 +25194,7 @@ async function runJob(ctx, job, claimDeviceId) {
|
|
|
25179
25194
|
return;
|
|
25180
25195
|
}
|
|
25181
25196
|
log(`spawning claude (mcp config at ${configPath}, model ${model})`);
|
|
25182
|
-
const proc = spawnClaude({
|
|
25197
|
+
const proc = spawnClaude(hostSpawnOpts({
|
|
25183
25198
|
prompt,
|
|
25184
25199
|
mcpConfigPath: configPath,
|
|
25185
25200
|
cwd: worktreeDir,
|
|
@@ -25194,11 +25209,8 @@ async function runJob(ctx, job, claimDeviceId) {
|
|
|
25194
25209
|
jsonOutput: true,
|
|
25195
25210
|
// The checkout is the customer's: never load its .claude/settings.json
|
|
25196
25211
|
// (hooks there would run as shell commands on this host).
|
|
25197
|
-
settingSources: "user"
|
|
25198
|
-
|
|
25199
|
-
// sees only the agent env, never the daemon's other tokens.
|
|
25200
|
-
agentEnv: true
|
|
25201
|
-
});
|
|
25212
|
+
settingSources: "user"
|
|
25213
|
+
}));
|
|
25202
25214
|
inFlight.set(job.id, proc);
|
|
25203
25215
|
const getStdout = teeStream(proc.stdout, `[${job.id}] claude> `, { silent: true });
|
|
25204
25216
|
const getStderr = teeStream(proc.stderr, `[${job.id}] claude! `);
|
|
@@ -27034,6 +27046,24 @@ var init_githubInstallations = __esm({
|
|
|
27034
27046
|
}
|
|
27035
27047
|
});
|
|
27036
27048
|
|
|
27049
|
+
// src/auth/machineOrgs.ts
|
|
27050
|
+
async function readMachineOrgIds() {
|
|
27051
|
+
try {
|
|
27052
|
+
const { credentials } = await loadAllCredentials(resolveConfig().supabaseUrl);
|
|
27053
|
+
const orgs = credentials.flatMap((c3) => c3.bindings?.length ? c3.bindings.map((b) => b.org_id) : [c3.org_id]);
|
|
27054
|
+
return orgs.length ? new Set(orgs) : null;
|
|
27055
|
+
} catch {
|
|
27056
|
+
return null;
|
|
27057
|
+
}
|
|
27058
|
+
}
|
|
27059
|
+
var init_machineOrgs = __esm({
|
|
27060
|
+
"src/auth/machineOrgs.ts"() {
|
|
27061
|
+
"use strict";
|
|
27062
|
+
init_defaults();
|
|
27063
|
+
init_credentials();
|
|
27064
|
+
}
|
|
27065
|
+
});
|
|
27066
|
+
|
|
27037
27067
|
// src/init/watchRepo.ts
|
|
27038
27068
|
async function findInstallation(supabase, orgId, owner) {
|
|
27039
27069
|
const { data: installs, error: installErr } = await supabase.from("org_github_installations").select("installation_id").eq("org_id", orgId);
|
|
@@ -27103,12 +27133,18 @@ async function watchRepoForProject(input) {
|
|
|
27103
27133
|
reason: `the repo is linked but commit-driven updates could not be switched on (${enableErr.message}). Pushes will not reach your daemon until they are.`
|
|
27104
27134
|
};
|
|
27105
27135
|
}
|
|
27136
|
+
if ((await readMachineOrgIds())?.has(orgId) === false) {
|
|
27137
|
+
input.log?.(
|
|
27138
|
+
" ! This machine isn't paired with the board's org, so its daemon won't run these updates.\n Run `archme login` and tick that org, or have a teammate's daemon or ArchMe's managed daemon run them."
|
|
27139
|
+
);
|
|
27140
|
+
}
|
|
27106
27141
|
return { watched: true };
|
|
27107
27142
|
}
|
|
27108
27143
|
var init_watchRepo = __esm({
|
|
27109
27144
|
"src/init/watchRepo.ts"() {
|
|
27110
27145
|
"use strict";
|
|
27111
27146
|
init_githubInstallations();
|
|
27147
|
+
init_machineOrgs();
|
|
27112
27148
|
}
|
|
27113
27149
|
});
|
|
27114
27150
|
|
|
@@ -27420,7 +27456,7 @@ async function runLocalWatch(opts) {
|
|
|
27420
27456
|
log(` project: ${project.orgSlug}/${project.projectSlug}${project.created ? " (created)" : ""}`);
|
|
27421
27457
|
const registered = await registerLocalWatch({
|
|
27422
27458
|
supabase,
|
|
27423
|
-
orgId,
|
|
27459
|
+
orgId: project.orgId,
|
|
27424
27460
|
projectId: project.projectId,
|
|
27425
27461
|
repoPath,
|
|
27426
27462
|
originUrl,
|
|
@@ -27453,6 +27489,12 @@ async function runLocalWatch(opts) {
|
|
|
27453
27489
|
return 0;
|
|
27454
27490
|
}
|
|
27455
27491
|
async function watchLocalRepoRow(args) {
|
|
27492
|
+
if ((await readMachineOrgIds())?.has(args.orgId) === false) {
|
|
27493
|
+
return {
|
|
27494
|
+
ok: false,
|
|
27495
|
+
reason: "this machine isn't paired with the board's org, so its daemon could never run this repo's updates. Run `archme login`, tick that org, and try again."
|
|
27496
|
+
};
|
|
27497
|
+
}
|
|
27456
27498
|
const { data, error } = await args.supabase.rpc("watch_local_repo", {
|
|
27457
27499
|
p_org_id: args.orgId,
|
|
27458
27500
|
p_project_id: args.projectId,
|
|
@@ -27632,6 +27674,7 @@ var init_localWatch = __esm({
|
|
|
27632
27674
|
init_localGit();
|
|
27633
27675
|
init_localRepos();
|
|
27634
27676
|
init_branchMarker();
|
|
27677
|
+
init_machineOrgs();
|
|
27635
27678
|
init_localWatchList();
|
|
27636
27679
|
init_localWatchResolve();
|
|
27637
27680
|
init_prompt();
|
|
@@ -28658,7 +28701,7 @@ async function runAddRepo(opts, deps = {}) {
|
|
|
28658
28701
|
const project = await (deps.resolveProject ?? resolveOrCreateProject)(authed2.supabase, authed2.userId, opts.project);
|
|
28659
28702
|
const scanBranch = initScanBranch(project.defaultBranch);
|
|
28660
28703
|
const added = await addRepoToBoard(
|
|
28661
|
-
{ authed: authed2, orgId:
|
|
28704
|
+
{ authed: authed2, orgId: project.orgId, projectId: project.projectId, project: opts.project, scanBranch },
|
|
28662
28705
|
{
|
|
28663
28706
|
root: inspected.root,
|
|
28664
28707
|
originUrl: inspected.originUrl,
|
|
@@ -29771,10 +29814,11 @@ async function prepareAddRepos(opts, deps = {}) {
|
|
|
29771
29814
|
if (unscannable.length) return fail2(78, `${unscannable.join("\n ")}
|
|
29772
29815
|
Nothing was changed.`);
|
|
29773
29816
|
const watching = [...todo, ...toWatch];
|
|
29817
|
+
const orgId = existing?.orgId ?? await (deps.findOrgId ?? findOrgId)(supabase, opts.project);
|
|
29774
29818
|
const elsewhere = [];
|
|
29775
29819
|
for (const c3 of watching) {
|
|
29776
29820
|
const holder = await (deps.watchedElsewhere ?? watchedElsewhere)(supabase, {
|
|
29777
|
-
orgId
|
|
29821
|
+
orgId,
|
|
29778
29822
|
projectId: existing?.projectId ?? null,
|
|
29779
29823
|
target: c3.target
|
|
29780
29824
|
});
|
|
@@ -29787,7 +29831,7 @@ async function prepareAddRepos(opts, deps = {}) {
|
|
|
29787
29831
|
if (!opts.local) {
|
|
29788
29832
|
const missing = [];
|
|
29789
29833
|
for (const c3 of watching) {
|
|
29790
|
-
const found = await (deps.findInstallation ?? findInstallation)(supabase,
|
|
29834
|
+
const found = await (deps.findInstallation ?? findInstallation)(supabase, orgId, c3.target.repoOwner);
|
|
29791
29835
|
if (!found.ok) missing.push(`${c3.target.repo}: ${found.reason}`);
|
|
29792
29836
|
}
|
|
29793
29837
|
if (missing.length) {
|
|
@@ -29796,7 +29840,7 @@ async function prepareAddRepos(opts, deps = {}) {
|
|
|
29796
29840
|
}
|
|
29797
29841
|
}
|
|
29798
29842
|
const project = existing ?? await (deps.resolveProject ?? resolveOrCreateProject)(supabase, authed2.userId, opts.project);
|
|
29799
|
-
const board = { authed: authed2, orgId:
|
|
29843
|
+
const board = { authed: authed2, orgId: project.orgId, projectId: project.projectId, project: opts.project, scanBranch };
|
|
29800
29844
|
if (roster.fold) {
|
|
29801
29845
|
const failed = await foldForRepos({ supabase, projectId: project.projectId, scanBranch }, roster.fold, "multi-repo add-repos", {
|
|
29802
29846
|
foldBoard: deps.foldBoard,
|
|
@@ -29843,7 +29887,7 @@ async function prepareAddRepos(opts, deps = {}) {
|
|
|
29843
29887
|
for (const clone of toPoll) {
|
|
29844
29888
|
const out = await (deps.registerLocalWatch ?? register)({
|
|
29845
29889
|
supabase,
|
|
29846
|
-
orgId:
|
|
29890
|
+
orgId: project.orgId,
|
|
29847
29891
|
projectId: project.projectId,
|
|
29848
29892
|
repoPath: clone.root,
|
|
29849
29893
|
originUrl: clone.originUrl,
|
|
@@ -30993,8 +31037,7 @@ async function alreadyOnBoard(opts, deps, root, repo) {
|
|
|
30993
31037
|
return null;
|
|
30994
31038
|
}
|
|
30995
31039
|
}
|
|
30996
|
-
async function ensureAppInstalled(opts, deps, owners2) {
|
|
30997
|
-
const orgId = opts.authed.orgId;
|
|
31040
|
+
async function ensureAppInstalled(opts, deps, orgId, owners2) {
|
|
30998
31041
|
const missing = async () => {
|
|
30999
31042
|
const out = [];
|
|
31000
31043
|
for (const owner of owners2) {
|
|
@@ -31030,7 +31073,6 @@ async function ensureAppInstalled(opts, deps, owners2) {
|
|
|
31030
31073
|
async function runSetup(opts, deps, { workspace, cloneDir }, handoff) {
|
|
31031
31074
|
const { authed: authed2, log } = opts;
|
|
31032
31075
|
const supabase = authed2.supabase;
|
|
31033
|
-
const orgId = authed2.orgId;
|
|
31034
31076
|
if (opts.keyed && handoff.access === "github-app") {
|
|
31035
31077
|
return { ok: false, reason: "this login has no account, so GitHub watch is not available (the GitHub App links to an account); use local watch (--local-watch)" };
|
|
31036
31078
|
}
|
|
@@ -31054,7 +31096,8 @@ async function runSetup(opts, deps, { workspace, cloneDir }, handoff) {
|
|
|
31054
31096
|
}
|
|
31055
31097
|
if (handoff.access === "github-app") {
|
|
31056
31098
|
const owners2 = [...new Set(handoff.repos.map((r) => r.repo.split("/")[0]))];
|
|
31057
|
-
const
|
|
31099
|
+
const orgId = existing?.orgId ?? await (deps.findOrgId ?? findOrgId)(supabase, handoff.project);
|
|
31100
|
+
const notInstalled = await ensureAppInstalled(opts, deps, orgId, owners2);
|
|
31058
31101
|
if (notInstalled) return { ok: false, reason: notInstalled };
|
|
31059
31102
|
}
|
|
31060
31103
|
if (shape === "multi") {
|
|
@@ -31140,7 +31183,7 @@ async function runSetup(opts, deps, { workspace, cloneDir }, handoff) {
|
|
|
31140
31183
|
if (handoff.access === "github-app") {
|
|
31141
31184
|
const w = await (deps.watchRepo ?? watchRepoForProject)({
|
|
31142
31185
|
supabase,
|
|
31143
|
-
orgId,
|
|
31186
|
+
orgId: project.orgId,
|
|
31144
31187
|
projectId: project.projectId,
|
|
31145
31188
|
repoSlug: target.target.repo,
|
|
31146
31189
|
branch: target.target.repoBranch,
|
|
@@ -31237,7 +31280,7 @@ The scan did not finish (exit ${exitCode}). Run \`archme init\` here again to co
|
|
|
31237
31280
|
if (target.ok) {
|
|
31238
31281
|
const res = await (deps.registerLocalWatch ?? registerLocalWatch)({
|
|
31239
31282
|
supabase: authed2.supabase,
|
|
31240
|
-
orgId:
|
|
31283
|
+
orgId: project.orgId,
|
|
31241
31284
|
projectId: project.projectId,
|
|
31242
31285
|
repoPath: repo.root,
|
|
31243
31286
|
originUrl: repo.originUrl,
|
|
@@ -31558,10 +31601,10 @@ ${fullSlug} already holds other repos, so ${git4.repoSlug} needs its own contain
|
|
|
31558
31601
|
const target = resolveInitTarget({ originUrl: git4.originUrl, detectedDefaultBranch: git4.branch, archmeBranchOverride: scanBranch });
|
|
31559
31602
|
if (!target.ok) throw new Error(target.error);
|
|
31560
31603
|
const owner = git4.repoSlug.split("/")[0];
|
|
31561
|
-
const app = !keyed &&
|
|
31604
|
+
const app = !keyed && project.orgId ? (await (deps.findInstallation ?? findInstallation)(authed2.supabase, project.orgId, owner)).ok : false;
|
|
31562
31605
|
log(`\u2192 ${fullSlug} already holds other repos: adding ${git4.repoSlug} in its own container (${app ? "GitHub watch" : "local watch"})`);
|
|
31563
31606
|
const added = await (deps.addRepoToBoard ?? addRepoToBoard)(
|
|
31564
|
-
{ authed: authed2, orgId:
|
|
31607
|
+
{ authed: authed2, orgId: project.orgId, projectId: project.projectId, project: fullSlug, scanBranch },
|
|
31565
31608
|
{ root: repoPath, originUrl: git4.originUrl, target: target.target, local: !app, interactive },
|
|
31566
31609
|
{ log }
|
|
31567
31610
|
);
|
|
@@ -31584,7 +31627,7 @@ ${fullSlug} already holds other repos, so ${git4.repoSlug} needs its own contain
|
|
|
31584
31627
|
}
|
|
31585
31628
|
const watched = await watchRepo({
|
|
31586
31629
|
supabase: authed2.supabase,
|
|
31587
|
-
orgId:
|
|
31630
|
+
orgId: project.orgId,
|
|
31588
31631
|
projectId: project.projectId,
|
|
31589
31632
|
repoSlug: git4.repoSlug,
|
|
31590
31633
|
branch: git4.branch,
|
|
@@ -31653,10 +31696,10 @@ Your board: ${webUrl}`);
|
|
|
31653
31696
|
startGitHubAppInstall: () => (deps.buildInstallUrl ?? buildInstallUrl)({
|
|
31654
31697
|
supabaseUrl: cfg.supabaseUrl,
|
|
31655
31698
|
accessToken: getCurrentAccessToken() ?? "",
|
|
31656
|
-
orgId:
|
|
31699
|
+
orgId: project.orgId
|
|
31657
31700
|
}),
|
|
31658
31701
|
waitForInstallation: () => (deps.waitForInstallation ?? waitForInstallation)({
|
|
31659
|
-
hasInstallation: () => (deps.orgHasInstallation ?? orgHasInstallation)(authed2.supabase,
|
|
31702
|
+
hasInstallation: () => (deps.orgHasInstallation ?? orgHasInstallation)(authed2.supabase, project.orgId),
|
|
31660
31703
|
sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
31661
31704
|
now: () => Date.now(),
|
|
31662
31705
|
log
|
|
@@ -31664,7 +31707,7 @@ Your board: ${webUrl}`);
|
|
|
31664
31707
|
watchRepo: async () => {
|
|
31665
31708
|
const w = await watchRepo({
|
|
31666
31709
|
supabase: authed2.supabase,
|
|
31667
|
-
orgId:
|
|
31710
|
+
orgId: project.orgId,
|
|
31668
31711
|
projectId: project.projectId,
|
|
31669
31712
|
repoSlug: git4.repoSlug,
|
|
31670
31713
|
branch: git4.branch,
|
|
@@ -31687,7 +31730,7 @@ Your board: ${webUrl}`);
|
|
|
31687
31730
|
if (!target.ok) return { ok: false, reason: target.error };
|
|
31688
31731
|
const res = await (deps.registerLocalWatch ?? registerLocalWatch)({
|
|
31689
31732
|
supabase: authed2.supabase,
|
|
31690
|
-
orgId:
|
|
31733
|
+
orgId: project.orgId,
|
|
31691
31734
|
projectId: project.projectId,
|
|
31692
31735
|
repoPath: git4.root,
|
|
31693
31736
|
originUrl: git4.originUrl,
|
|
@@ -31705,7 +31748,7 @@ Your board: ${webUrl}`);
|
|
|
31705
31748
|
if (outcome.localWatchRegistered && registered.watchedRepoId && deps.offerPrReviews) {
|
|
31706
31749
|
await deps.offerPrReviews({
|
|
31707
31750
|
supabase: authed2.supabase,
|
|
31708
|
-
orgId:
|
|
31751
|
+
orgId: project.orgId,
|
|
31709
31752
|
projectId: project.projectId,
|
|
31710
31753
|
watchedRepoId: registered.watchedRepoId,
|
|
31711
31754
|
repoSlug: git4.repoSlug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archme/cli",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.3",
|
|
4
4
|
"description": "Map your codebase into a living architecture diagram: run `archme init` in a repo to scan it, `archme daemon start` to keep it current on every commit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
package/sandbox-image.json
CHANGED