@archme/cli 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +389 -207
- package/package.json +1 -1
- package/sandbox-image.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -18756,12 +18756,12 @@ function defaultReadFile(path7) {
|
|
|
18756
18756
|
return readFileSync4(path7, "utf8");
|
|
18757
18757
|
}
|
|
18758
18758
|
function findPackageRoot2(startDir, opts = {}) {
|
|
18759
|
-
const
|
|
18759
|
+
const readFile26 = opts.readFile ?? defaultReadFile;
|
|
18760
18760
|
const stopAt = parse(startDir).root;
|
|
18761
18761
|
let dir = startDir;
|
|
18762
18762
|
for (; ; ) {
|
|
18763
18763
|
try {
|
|
18764
|
-
const parsed = JSON.parse(
|
|
18764
|
+
const parsed = JSON.parse(readFile26(join14(dir, "package.json")));
|
|
18765
18765
|
if (parsed.name === PACKAGE_NAME) return dir;
|
|
18766
18766
|
} catch {
|
|
18767
18767
|
}
|
|
@@ -18895,15 +18895,15 @@ async function materializeDiff(dir, patch, rangeLabel) {
|
|
|
18895
18895
|
const files = splitPatchByFile(patch);
|
|
18896
18896
|
await mkdir8(dir);
|
|
18897
18897
|
await mkdir8(join16(dir, "by-file"));
|
|
18898
|
-
const
|
|
18898
|
+
const write2 = (path7, text) => writeFile7(join16(dir, path7), text.endsWith("\n") ? text : `${text}
|
|
18899
18899
|
`, { encoding: "utf8", flag: "wx" });
|
|
18900
|
-
await
|
|
18900
|
+
await write2("FULL.diff", patch);
|
|
18901
18901
|
for (const f of files) {
|
|
18902
18902
|
const rel = `by-file/${hashPath(f.path)}.diff`;
|
|
18903
18903
|
f.diffPath = rel;
|
|
18904
|
-
await
|
|
18904
|
+
await write2(rel, f.diff);
|
|
18905
18905
|
}
|
|
18906
|
-
await
|
|
18906
|
+
await write2("MANIFEST.md", buildManifest(files, rangeLabel));
|
|
18907
18907
|
return { dir, fileCount: files.length };
|
|
18908
18908
|
}
|
|
18909
18909
|
var STATUS_LABEL;
|
|
@@ -22418,6 +22418,24 @@ var init_claimDefaultProject = __esm({
|
|
|
22418
22418
|
}
|
|
22419
22419
|
});
|
|
22420
22420
|
|
|
22421
|
+
// ../shared/branchResolution.ts
|
|
22422
|
+
function resolveArchitectureBranchName(branches) {
|
|
22423
|
+
if (branches.length === 0) return null;
|
|
22424
|
+
const defaultBranch = branches.find((b) => b.isDefault);
|
|
22425
|
+
if (defaultBranch) {
|
|
22426
|
+
const scanName = `${defaultBranch.name}${SCAN_BRANCH_SUFFIX}`;
|
|
22427
|
+
const scan = branches.find((b) => b.name === scanName);
|
|
22428
|
+
return (scan ?? defaultBranch).name;
|
|
22429
|
+
}
|
|
22430
|
+
return branches[0].name;
|
|
22431
|
+
}
|
|
22432
|
+
var SCAN_BRANCH_SUFFIX;
|
|
22433
|
+
var init_branchResolution = __esm({
|
|
22434
|
+
"../shared/branchResolution.ts"() {
|
|
22435
|
+
SCAN_BRANCH_SUFFIX = "-scan";
|
|
22436
|
+
}
|
|
22437
|
+
});
|
|
22438
|
+
|
|
22421
22439
|
// src/scan/run-scan.ts
|
|
22422
22440
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
22423
22441
|
import { createWriteStream as createWriteStream2 } from "node:fs";
|
|
@@ -22712,12 +22730,15 @@ async function fetchExistingProject(supabase, org, projectSlug) {
|
|
|
22712
22730
|
supabase.from("branches").select("name, is_default").eq("project_id", projectId),
|
|
22713
22731
|
`branches lookup failed for project \`${org.slug}/${projectSlug}\``
|
|
22714
22732
|
);
|
|
22715
|
-
const
|
|
22733
|
+
const rows = branches ?? [];
|
|
22734
|
+
const defaultBranch = rows.find((b) => b.is_default)?.name ?? "main";
|
|
22735
|
+
const architectureBranch = resolveArchitectureBranchName(rows.map((b) => ({ name: b.name, isDefault: b.is_default }))) ?? defaultBranch;
|
|
22716
22736
|
return {
|
|
22717
22737
|
orgSlug: org.slug,
|
|
22718
22738
|
projectSlug,
|
|
22719
22739
|
projectId,
|
|
22720
22740
|
defaultBranch,
|
|
22741
|
+
architectureBranch,
|
|
22721
22742
|
created: false
|
|
22722
22743
|
};
|
|
22723
22744
|
}
|
|
@@ -23032,6 +23053,7 @@ var init_run_scan = __esm({
|
|
|
23032
23053
|
init_github_remote();
|
|
23033
23054
|
init_architectureCounts2();
|
|
23034
23055
|
init_claimDefaultProject();
|
|
23056
|
+
init_branchResolution();
|
|
23035
23057
|
init_architectureCounts2();
|
|
23036
23058
|
BOOTSTRAP_HEADLESS = `Run the \`scan\` MCP prompt now and follow it to completion. This is a non-interactive automated run \u2014 skip any steps that pause for user confirmation (e.g. "does this hierarchy look right?"). Proceed with your best-judgement decisions rather than waiting for human input.`;
|
|
23037
23059
|
BOOTSTRAP_INTERACTIVE = `Run the \`scan\` MCP prompt now and follow it to completion. The user is at an interactive terminal \u2014 ask them when the prompt says to, and wait for their answer.
|
|
@@ -26481,8 +26503,8 @@ async function defaultLoadSupabaseState(_deviceId) {
|
|
|
26481
26503
|
async function defaultLoadUptime(pid) {
|
|
26482
26504
|
if (process.platform === "linux") {
|
|
26483
26505
|
try {
|
|
26484
|
-
const { readFile:
|
|
26485
|
-
const stat15 = await
|
|
26506
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
26507
|
+
const stat15 = await readFile26(`/proc/${pid}/stat`, "utf8");
|
|
26486
26508
|
const parts = stat15.split(") ").pop()?.split(" ") ?? [];
|
|
26487
26509
|
const ticks = Number(parts[19]);
|
|
26488
26510
|
if (!Number.isFinite(ticks)) return null;
|
|
@@ -28180,12 +28202,6 @@ var init_saveArchitecture = __esm({
|
|
|
28180
28202
|
}
|
|
28181
28203
|
});
|
|
28182
28204
|
|
|
28183
|
-
// ../shared/branchResolution.ts
|
|
28184
|
-
var init_branchResolution = __esm({
|
|
28185
|
-
"../shared/branchResolution.ts"() {
|
|
28186
|
-
}
|
|
28187
|
-
});
|
|
28188
|
-
|
|
28189
28205
|
// ../shared/visibilityFlags.ts
|
|
28190
28206
|
function flagsFor(row) {
|
|
28191
28207
|
return {
|
|
@@ -29140,65 +29156,264 @@ function buildProjectMcpUrl(mcpBaseUrl, project, branch) {
|
|
|
29140
29156
|
url.searchParams.set("branch", branch);
|
|
29141
29157
|
return url.toString();
|
|
29142
29158
|
}
|
|
29143
|
-
function resolveAppOrigin(mcpBaseUrl, override) {
|
|
29144
|
-
if (override) return override.replace(/\/$/, "");
|
|
29145
|
-
return deriveWebOrigin(mcpBaseUrl, "fallback");
|
|
29146
|
-
}
|
|
29147
|
-
function buildInstallAgentUrl(appOrigin, mcpUrl) {
|
|
29148
|
-
const url = new URL("/api/install-agent", appOrigin);
|
|
29149
|
-
url.searchParams.set("mcp_url", mcpUrl);
|
|
29150
|
-
return url.toString();
|
|
29151
|
-
}
|
|
29152
29159
|
var init_plan = __esm({
|
|
29153
29160
|
"src/init/plan.ts"() {
|
|
29154
29161
|
"use strict";
|
|
29155
|
-
init_web_url();
|
|
29156
29162
|
}
|
|
29157
29163
|
});
|
|
29158
29164
|
|
|
29159
|
-
// src/
|
|
29160
|
-
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29165
|
+
// src/uninstall/edits.ts
|
|
29166
|
+
function stripArchmeClaudeBlock(content) {
|
|
29167
|
+
const start = content.indexOf(START_MARKER);
|
|
29168
|
+
if (start === -1) return UNCHANGED;
|
|
29169
|
+
const end = content.indexOf(END_MARKER, start);
|
|
29170
|
+
if (end === -1) return UNCHANGED;
|
|
29171
|
+
const before = content.slice(0, start).replace(/\n+$/, "");
|
|
29172
|
+
const after = content.slice(end + END_MARKER.length).replace(/^\n+/, "");
|
|
29173
|
+
if (!before.trim() && !after.trim()) return { kind: "delete" };
|
|
29174
|
+
if (!before.trim()) return { kind: "rewrite", content: `${after.replace(/\n*$/, "")}
|
|
29175
|
+
` };
|
|
29176
|
+
if (!after.trim()) return { kind: "rewrite", content: `${before}
|
|
29177
|
+
` };
|
|
29178
|
+
return { kind: "rewrite", content: `${before}
|
|
29179
|
+
|
|
29180
|
+
${after.replace(/\n*$/, "")}
|
|
29181
|
+
` };
|
|
29182
|
+
}
|
|
29183
|
+
function parseObject(raw) {
|
|
29184
|
+
try {
|
|
29185
|
+
const parsed = JSON.parse(raw);
|
|
29186
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
29187
|
+
return parsed;
|
|
29188
|
+
} catch {
|
|
29189
|
+
return null;
|
|
29167
29190
|
}
|
|
29168
|
-
return await resp.text();
|
|
29169
29191
|
}
|
|
29170
|
-
|
|
29171
|
-
|
|
29172
|
-
|
|
29192
|
+
function render(value) {
|
|
29193
|
+
return `${JSON.stringify(value, null, 2)}
|
|
29194
|
+
`;
|
|
29195
|
+
}
|
|
29196
|
+
function stripArchmeMcpServer(content) {
|
|
29197
|
+
const root = parseObject(content);
|
|
29198
|
+
if (!root) return UNCHANGED;
|
|
29199
|
+
const servers = root.mcpServers;
|
|
29200
|
+
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return UNCHANGED;
|
|
29201
|
+
const entries = servers;
|
|
29202
|
+
if (!(MCP_SERVER_NAME2 in entries)) return UNCHANGED;
|
|
29203
|
+
delete entries[MCP_SERVER_NAME2];
|
|
29204
|
+
const onlyKey = Object.keys(root).length === 1 && "mcpServers" in root;
|
|
29205
|
+
if (onlyKey && Object.keys(entries).length === 0) return { kind: "delete" };
|
|
29206
|
+
return { kind: "rewrite", content: render(root) };
|
|
29207
|
+
}
|
|
29208
|
+
function isArchmeHook(hook) {
|
|
29209
|
+
const command = hook?.command;
|
|
29210
|
+
return typeof command === "string" && command.includes(NUDGE_HOOK_FILE);
|
|
29211
|
+
}
|
|
29212
|
+
function stripArchmeHooks(content) {
|
|
29213
|
+
const root = parseObject(content);
|
|
29214
|
+
if (!root) return UNCHANGED;
|
|
29215
|
+
const hooks = root.hooks;
|
|
29216
|
+
if (!hooks || typeof hooks !== "object" || Array.isArray(hooks)) return UNCHANGED;
|
|
29217
|
+
const byEvent = hooks;
|
|
29218
|
+
const pre = byEvent.PreToolUse;
|
|
29219
|
+
if (!Array.isArray(pre)) return UNCHANGED;
|
|
29220
|
+
let changed = false;
|
|
29221
|
+
const kept = [];
|
|
29222
|
+
for (const entry of pre) {
|
|
29223
|
+
const inner = entry?.hooks;
|
|
29224
|
+
if (!Array.isArray(inner) || !inner.some(isArchmeHook)) {
|
|
29225
|
+
kept.push(entry);
|
|
29226
|
+
continue;
|
|
29227
|
+
}
|
|
29228
|
+
changed = true;
|
|
29229
|
+
const survivors = inner.filter((h2) => !isArchmeHook(h2));
|
|
29230
|
+
if (survivors.length > 0) kept.push({ ...entry, hooks: survivors });
|
|
29231
|
+
}
|
|
29232
|
+
if (!changed) return UNCHANGED;
|
|
29233
|
+
if (kept.length > 0) byEvent.PreToolUse = kept;
|
|
29234
|
+
else delete byEvent.PreToolUse;
|
|
29235
|
+
if (Object.keys(byEvent).length === 0) delete root.hooks;
|
|
29236
|
+
if (Object.keys(root).length === 0) return { kind: "delete" };
|
|
29237
|
+
return { kind: "rewrite", content: render(root) };
|
|
29238
|
+
}
|
|
29239
|
+
var UNCHANGED, START_MARKER, END_MARKER, NUDGE_HOOK_FILE, MCP_SERVER_NAME2;
|
|
29240
|
+
var init_edits = __esm({
|
|
29241
|
+
"src/uninstall/edits.ts"() {
|
|
29242
|
+
"use strict";
|
|
29243
|
+
UNCHANGED = { kind: "unchanged" };
|
|
29244
|
+
START_MARKER = "<!-- ARCHME-START -->";
|
|
29245
|
+
END_MARKER = "<!-- ARCHME-END -->";
|
|
29246
|
+
NUDGE_HOOK_FILE = "archme-search-nudge.mjs";
|
|
29247
|
+
MCP_SERVER_NAME2 = "archme";
|
|
29248
|
+
}
|
|
29249
|
+
});
|
|
29250
|
+
|
|
29251
|
+
// src/init/agentConfigEdits.ts
|
|
29252
|
+
function isLocalUrl(url) {
|
|
29173
29253
|
try {
|
|
29174
|
-
|
|
29175
|
-
|
|
29176
|
-
}
|
|
29177
|
-
|
|
29254
|
+
const host = new URL(url).hostname;
|
|
29255
|
+
return host === "localhost" || host === "127.0.0.1" || host === "0.0.0.0";
|
|
29256
|
+
} catch {
|
|
29257
|
+
return false;
|
|
29178
29258
|
}
|
|
29179
29259
|
}
|
|
29180
|
-
|
|
29260
|
+
function isObject2(v) {
|
|
29261
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
29262
|
+
}
|
|
29263
|
+
function render2(value) {
|
|
29264
|
+
return `${JSON.stringify(value, null, 2)}
|
|
29265
|
+
`;
|
|
29266
|
+
}
|
|
29267
|
+
function buildArchmeMcpServer(url) {
|
|
29268
|
+
return isLocalUrl(url) ? { type: "http", url, headers: { Authorization: LOCAL_DEV_AUTH } } : { type: "http", url };
|
|
29269
|
+
}
|
|
29270
|
+
function mergeArchmeMcpJson(existing, url) {
|
|
29271
|
+
if (existing === null) return { kind: "created", content: render2({ mcpServers: { [MCP_SERVER_NAME2]: buildArchmeMcpServer(url) } }) };
|
|
29272
|
+
const unparseable = { kind: "unparseable", snippet: render2({ mcpServers: { [MCP_SERVER_NAME2]: buildArchmeMcpServer(url) } }) };
|
|
29273
|
+
let root;
|
|
29274
|
+
try {
|
|
29275
|
+
root = JSON.parse(existing);
|
|
29276
|
+
} catch {
|
|
29277
|
+
return unparseable;
|
|
29278
|
+
}
|
|
29279
|
+
if (!isObject2(root)) return unparseable;
|
|
29280
|
+
const servers = root.mcpServers ?? {};
|
|
29281
|
+
if (!isObject2(servers)) return unparseable;
|
|
29282
|
+
root.mcpServers = servers;
|
|
29283
|
+
const current = servers[MCP_SERVER_NAME2];
|
|
29284
|
+
if (current === void 0) {
|
|
29285
|
+
servers[MCP_SERVER_NAME2] = buildArchmeMcpServer(url);
|
|
29286
|
+
return { kind: "added", content: render2(root) };
|
|
29287
|
+
}
|
|
29288
|
+
if (!isObject2(current)) return unparseable;
|
|
29289
|
+
const headersChanged = reconcileLocalDevAuth(current, url);
|
|
29290
|
+
if (current.url === url && !headersChanged) return { kind: "already-pinned" };
|
|
29291
|
+
const from = typeof current.url === "string" ? current.url : "(no url)";
|
|
29292
|
+
current.url = url;
|
|
29293
|
+
return { kind: "repinned", from, to: url, content: render2(root) };
|
|
29294
|
+
}
|
|
29295
|
+
function reconcileLocalDevAuth(server, url) {
|
|
29296
|
+
const headers = isObject2(server.headers) ? server.headers : {};
|
|
29297
|
+
const authKey = Object.keys(headers).find((k) => k.toLowerCase() === "authorization");
|
|
29298
|
+
if (isLocalUrl(url)) {
|
|
29299
|
+
if (authKey !== void 0) return false;
|
|
29300
|
+
server.headers = { ...headers, Authorization: LOCAL_DEV_AUTH };
|
|
29301
|
+
return true;
|
|
29302
|
+
}
|
|
29303
|
+
if (authKey === void 0 || headers[authKey] !== LOCAL_DEV_AUTH) return false;
|
|
29304
|
+
delete headers[authKey];
|
|
29305
|
+
if (Object.keys(headers).length === 0) delete server.headers;
|
|
29306
|
+
return true;
|
|
29307
|
+
}
|
|
29308
|
+
function upsertArchmeClaudeBlock(existing, block) {
|
|
29309
|
+
if (existing === null) return { kind: "created", content: `${block}
|
|
29310
|
+
` };
|
|
29311
|
+
const start = existing.indexOf(START_MARKER);
|
|
29312
|
+
if (start === -1) {
|
|
29313
|
+
const prose = existing.replace(/\s+$/, "");
|
|
29314
|
+
return { kind: "appended", content: prose ? `${prose}
|
|
29315
|
+
|
|
29316
|
+
${block}
|
|
29317
|
+
` : `${block}
|
|
29318
|
+
` };
|
|
29319
|
+
}
|
|
29320
|
+
const end = existing.indexOf(END_MARKER, start);
|
|
29321
|
+
if (end === -1) return { kind: "half-marked" };
|
|
29322
|
+
return {
|
|
29323
|
+
kind: "replaced",
|
|
29324
|
+
content: existing.slice(0, start) + block + existing.slice(end + END_MARKER.length)
|
|
29325
|
+
};
|
|
29326
|
+
}
|
|
29327
|
+
var LOCAL_DEV_AUTH;
|
|
29328
|
+
var init_agentConfigEdits = __esm({
|
|
29329
|
+
"src/init/agentConfigEdits.ts"() {
|
|
29330
|
+
"use strict";
|
|
29331
|
+
init_edits();
|
|
29332
|
+
LOCAL_DEV_AUTH = "Bearer am_local_dev";
|
|
29333
|
+
}
|
|
29334
|
+
});
|
|
29335
|
+
|
|
29336
|
+
// src/init/agentInstructions.ts
|
|
29337
|
+
var ARCHME_CLAUDE_BLOCK, ARCHME_SKILL;
|
|
29338
|
+
var init_agentInstructions = __esm({
|
|
29339
|
+
"src/init/agentInstructions.ts"() {
|
|
29340
|
+
"use strict";
|
|
29341
|
+
ARCHME_CLAUDE_BLOCK = (true ? "<!-- ARCHME-START -->\n## Architecture Awareness\n\nThis repository has a live ArchitectMe architecture connected through the `archme` MCP server.\n\nBefore broad code exploration, structural changes, new services, API/data-flow changes, or refactors:\n\n1. Use `read_architecture` or `find_components` to identify the relevant subsystem.\n2. Use `get_component` for the likely component before editing.\n3. Use `read_stories` and `check_impact` when behavior crosses component boundaries or when removing/renaming anything.\n4. Fall back to normal repo inspection if the architecture is missing, stale, or too vague.\n\nWhen working with a user on new features or large architecture changes, author a proposal (`create_proposal`) on its forked branch and let realization close it when the code lands \u2014 direct writes to the base branch are the daemon's incremental lane. See the `architecture` skill for the full flow.\n<!-- ARCHME-END -->" : fromSource("CLAUDE_BLOCK.md")).trimEnd();
|
|
29342
|
+
ARCHME_SKILL = true ? "---\nname: architecture\ndescription: Query ArchitectMe before broad code exploration, structural changes, refactors, API/data-flow work, or architecture updates. Author net-new/large design changes as proposals.\n---\n\n# Architecture Reference (ArchitectMe)\n\nThis repository's system design is managed in ArchitectMe. Use the `archme` MCP\nserver to read the live architecture while coding, and to author design changes as\nreviewable proposals. Reads and writes are scoped to the project + branch in `.mcp.json`.\n\n## Reading the architecture\n\nOrient in the map before broad repo exploration or structural edits:\n\n1. `query(\"<keyword>\")` \u2014 the one-call orientation verb. Keyword-matches components and\n returns, per match: kind/tech, a one-line description, **code anchors** (where it\n lives), direct connections, and the stories that touch it. A locator, not an\n answerer \u2014 open the anchored files yourself with Read.\n2. `read_architecture({ path: \"root\" })` \u2014 components + connections + structure at a\n scope (dot-paths: `root`, `root.api`, `root.api.db`).\n3. `get_component({ path })` \u2014 architecture + stories + context for one component.\n4. `read_stories({ path })` \u2014 user-flow stories with their Mermaid sequences.\n5. `check_impact` before removing, renaming, or moving a component boundary.\n\n**Anchors** bind a component to real code \u2014 `{ kind: \"file\" | \"directory\" | \"glob\" |\n\"symbol\", ... }`. They're how you jump from a component to its implementation: read the\nanchors, then `Read` those paths. Conceptual/external components (vendors, actors) carry\n`unanchored: true` instead. Every read surfaces a component's anchors.\n\nFor small local fixes in an already-known file, proceed normally. If ArchMe is stale,\nmissing, or too vague, fall back to regular repo inspection and mention the gap.\n\n## Proposing architecture changes (the default for net-new / large work)\n\nWhen you're about to build a net-new subsystem or make a large/structural design change,\nauthor it as a PROPOSAL \u2014 a reviewable spec against the source-of-truth branch \u2014 rather\nthan writing directly:\n\n1. `create_proposal({ title, description?, body? })` \u2014 forks a `proposal-<id>` working\n branch off the base and freezes a baseline. Returns the branch to author on, an\n `ArchMe-Proposal: <id>` trailer token, and a shareable link. **Surface the link to\n the user.** Filing a RUN of items (bugs from a triage, follow-ups from a design\n conversation)? Pass `proposals: [{ title, ... }, ...]` instead of `title` and create\n them in one call \u2014 the top-level `kind`, `parent_id`, `stage` and `base_branch` are\n defaults every item inherits and may override. Items are created in order and a\n failure part-way doesn't undo the ones before it, so retry only what the response\n reports as failed.\n Say what each one is **about** \u2014 `about: { component: 'root.\u2026' }` for the component a\n bug lives in, else `{ story: '<id>' }` for the flow, else `{ repo: 'owner/name' }`\n (null for nothing; `update_proposal` changes it later). The repo picker narrows the\n Issues and Proposals lists by it.\n2. **Author the delta on the graph \u2014 that delta IS the proposal.** On the returned\n branch, call `update_architecture` / `move_architecture` with\n `branch: \"proposal-<id>\"`: add or change the components and connections the design\n implies, and the user stories (each leaf carrying a Mermaid `sequence`) for the flows\n it introduces or changes. **Strongly prefer showing the change as a delta** \u2014 that's\n what reviewers actually read, so a representable design change described only in prose\n is close to invisible to them. Prose the graph and stories can't express \u2014 rationale,\n phased rollout, non-goals, a bug report, an ops/process change \u2014 goes in `body`. A\n prose-only proposal (populated `body`, empty delta) is valid when there's nothing\n representable to model; don't fabricate deltas to fill one out, and don't reach for\n prose to avoid modelling a change the graph could show.\n3. **Give a large proposal a walkthrough** \u2014 `set_walkthrough({ proposal: \"<id>\", steps: [...] })`.\n Each step names the stories, chapters, components and/or connections it covers,\n and the review surface filters the sequence diagram and the component graph down to\n just those, so a forty-element delta is read one bite-sized chunk at a time. Every\n step MUST reference at least one element: a step with only prose is rejected, because\n there is nothing to filter by and an explanation a reader can't check against the\n change is what this view exists to avoid. Steps go in **reading order, not build\n order** \u2014 this is not your sequencing plan restated. Titles are terse handles.\n **Every step gets a `description`**: two or three plain sentences on what this part of\n the change is and why it exists, at a high level \u2014 the narration a reviewer reads in\n guided mode while the diagrams move beside it. Not prescriptive, not a dense list of\n identifiers, and it never restates the elements the step already references.\n **Cover every change**: every story and component the delta touches must be named by\n a step, or `set_walkthrough` rejects the walkthrough and lists what is missing.\n Connections need no step of their own: they show up through the stories that draw\n them. A step that does name a connection inside a component writes it as\n `<component path>::<id>` (`daemon::session_auth->key_account`).\n Write it after the delta is in place, and skip it entirely for a small change \u2014 unless\n one already exists: when `update_architecture` warns that your writes left it out of\n date, rewrite it, or clear it with `set_walkthrough({ ..., steps: [] })`.\n4. Request review \u2014 run an automated lens yourself with `start_review` \u2192\n `submit_review` (self-contained, no user id needed), and/or `request_review` to ask a\n human teammate (needs their org-member user id).\n5. Implement in code with `ArchMe-Proposal: <id>` in the PR body. The daemon's\n realization auto-closes the proposal on merge. **Never merge the proposal branch into\n the base branch yourself.**\n\nUse `add_proposal_comment` to discuss a proposal **or a pull request** \u2014 free-form,\noptionally anchored to a component/story/connection (`anchor_kind` + `anchor_id`) or left\nas an entity-level thread, and `in_reply_to` to thread replies. Pass `proposal_id` OR\n`pr`, never both; a `pr` also takes `repo` (`\"owner/name\"`) when two watched repos in the\nproject share its number \u2014 the error names them. Distinct from `submit_review` (a typed lens verdict): use comments for\nconversation and questions on the delta.\n\nRead a PR back with `get_pr` \u2014 GitHub's own facts about it, ArchMe's description, its\nwalkthrough, and the whole comment thread. That is how you see a REPLY to a comment you\nleft, so check it before assuming a question went unanswered.\n\nA comment on a PR (or on a proposal some PR's `ArchMe-Proposal:` trailer names) is\nmirrored to that pull request on GitHub, so reviewers who live there see it. Write for\nthat audience: the first sentence is what they read.\n\n## Updating the architecture (update_architecture)\n\n`update_architecture` is additive \u2014 it merges components, connections, stories, and\nrequirements by id. Use it to author a proposal's spec on the fork; direct writes to the\nbase branch are reserved for the daemon's small incremental diffs.\n\nKeep the graph honest:\n\n- **Every component is anchored** to the code that implements it (`anchors`), or\n explicitly `unanchored: true` if it's conceptual/external. An unanchored internal\n component is drift.\n- **Connections reflect real data flow** \u2014 every call/dependency between components is a\n connection (`from`, `to`, `method`). Name the endpoints with `root.` paths; ArchMe\n stores each connection where its endpoints meet and the result says where (scope + id).\n- Add children with a separate entry using `at` (don't nest a `components` array).\n- Stories capture user flows; each leaf story carries a Mermaid `sequence` whose\n participants are `root.`-prefixed dot-paths.\n\nUse `move_architecture` to relocate components/stories (it rewrites sequences +\nconnections) and `update_node_context` for design decisions, references, and notes.\n\n## Scan\n\nUse the `/scan` MCP prompt to bootstrap or refresh the architecture from the local repo.\nFollow its setup, branch, and restart instructions.\n\n## Common Mistakes\n\n- Do not grep/read broadly first when a `query` or architecture lookup can narrow it.\n- Do not push net-new or large changes directly to the base branch \u2014 open a proposal.\n- Do not settle for a prose-only proposal when it adds or changes components,\n connections, or user flows \u2014 model those on the fork branch; `body` is for what the\n graph can't show.\n- Do not leave internal components unanchored or real connections missing.\n- Do not assume the architecture is complete; verify against code (via anchors) before\n risky edits.\n- Do not remove or rename architectural boundaries without `check_impact`.\n- Do not merge a proposal branch into the base \u2014 realization closes it when code lands.\n" : fromSource("architecture-skill.md");
|
|
29343
|
+
}
|
|
29344
|
+
});
|
|
29345
|
+
|
|
29346
|
+
// src/init/agentConfig.ts
|
|
29347
|
+
import { mkdir as mkdir18, readFile as readFile19, writeFile as writeFile17 } from "node:fs/promises";
|
|
29348
|
+
import { dirname as dirname20, join as join29 } from "node:path";
|
|
29349
|
+
async function readOrNull(path7) {
|
|
29350
|
+
try {
|
|
29351
|
+
return await readFile19(path7, "utf8");
|
|
29352
|
+
} catch (e) {
|
|
29353
|
+
if (e.code === "ENOENT") return null;
|
|
29354
|
+
throw e;
|
|
29355
|
+
}
|
|
29356
|
+
}
|
|
29357
|
+
async function write(path7, content) {
|
|
29358
|
+
await mkdir18(dirname20(path7), { recursive: true });
|
|
29359
|
+
await writeFile17(path7, content);
|
|
29360
|
+
}
|
|
29361
|
+
async function installAgentConfig(opts) {
|
|
29362
|
+
const log = opts.log ?? ((m) => console.log(m));
|
|
29363
|
+
const files = [];
|
|
29364
|
+
const warnings = [];
|
|
29365
|
+
const at = (rel) => join29(opts.repoRoot, rel);
|
|
29181
29366
|
const mcpUrl = buildProjectMcpUrl(opts.mcpBaseUrl, opts.project, opts.branch);
|
|
29182
|
-
const
|
|
29183
|
-
|
|
29184
|
-
|
|
29367
|
+
const mcp = mergeArchmeMcpJson(await readOrNull(at(".mcp.json")), mcpUrl);
|
|
29368
|
+
if (mcp.kind === "unparseable") {
|
|
29369
|
+
files.push({ path: ".mcp.json", outcome: "left alone: could not parse it" });
|
|
29370
|
+
warnings.push(`.mcp.json could not be parsed, so it was left untouched. Add the archme server yourself:
|
|
29371
|
+
${mcp.snippet}`);
|
|
29372
|
+
} else if (mcp.kind === "already-pinned") {
|
|
29373
|
+
files.push({ path: ".mcp.json", outcome: `already pinned to ${opts.project} (${opts.branch})` });
|
|
29374
|
+
} else {
|
|
29375
|
+
await write(at(".mcp.json"), mcp.content);
|
|
29376
|
+
files.push({
|
|
29377
|
+
path: ".mcp.json",
|
|
29378
|
+
outcome: mcp.kind === "repinned" ? `repinned archme: ${mcp.from} \u2192 ${mcp.to}` : mcp.kind === "added" ? "added the archme server" : "created"
|
|
29379
|
+
});
|
|
29380
|
+
}
|
|
29381
|
+
const block = upsertArchmeClaudeBlock(await readOrNull(at("CLAUDE.md")), ARCHME_CLAUDE_BLOCK);
|
|
29382
|
+
if (block.kind === "half-marked") {
|
|
29383
|
+
files.push({ path: "CLAUDE.md", outcome: "left alone: <!-- ARCHME-START --> with no <!-- ARCHME-END -->" });
|
|
29384
|
+
warnings.push(
|
|
29385
|
+
"CLAUDE.md has an ArchMe start marker but no end marker, so it was left untouched. Fix or remove the markers and re-run `archme init --agent-only`."
|
|
29386
|
+
);
|
|
29387
|
+
} else {
|
|
29388
|
+
await write(at("CLAUDE.md"), block.content);
|
|
29389
|
+
files.push({ path: "CLAUDE.md", outcome: block.kind === "created" ? "created" : block.kind === "replaced" ? "updated the ArchMe block" : "added the ArchMe block" });
|
|
29390
|
+
}
|
|
29391
|
+
await write(at(SKILL_PATH), ARCHME_SKILL);
|
|
29392
|
+
files.push({ path: SKILL_PATH, outcome: "installed" });
|
|
29393
|
+
for (const f of files) log(` ${f.outcome.startsWith("left alone") ? "\u26A0" : "\u2713"} ${f.path}: ${f.outcome}`);
|
|
29394
|
+
for (const w of warnings) log(`\u26A0 ${w}`);
|
|
29395
|
+
log("Next: open or restart Claude Code in this repo, and authenticate the MCP connection if prompted.");
|
|
29185
29396
|
await ignoreArchmeFiles(opts.repoRoot);
|
|
29397
|
+
return { files, warnings };
|
|
29186
29398
|
}
|
|
29399
|
+
var SKILL_PATH;
|
|
29187
29400
|
var init_agentConfig = __esm({
|
|
29188
29401
|
"src/init/agentConfig.ts"() {
|
|
29189
29402
|
"use strict";
|
|
29190
|
-
init_execa();
|
|
29191
29403
|
init_repoIgnore();
|
|
29192
29404
|
init_plan();
|
|
29405
|
+
init_agentConfigEdits();
|
|
29406
|
+
init_agentInstructions();
|
|
29407
|
+
SKILL_PATH = ".claude/skills/architecture/SKILL.md";
|
|
29193
29408
|
}
|
|
29194
29409
|
});
|
|
29195
29410
|
|
|
29196
29411
|
// src/init/workspace.ts
|
|
29197
|
-
import { dirname as
|
|
29412
|
+
import { dirname as dirname21, resolve as resolve4, sep as sep2 } from "node:path";
|
|
29198
29413
|
function initWorkspace(input) {
|
|
29199
29414
|
const tooBroad = (dir) => resolve4(dir) === resolve4(input.home) || resolve4(dir) === sep2;
|
|
29200
29415
|
if (input.startRepoRoot) {
|
|
29201
|
-
const parent =
|
|
29416
|
+
const parent = dirname21(input.startRepoRoot);
|
|
29202
29417
|
return tooBroad(parent) ? { ok: true, workspace: input.startRepoRoot, cloneDir: parent, searchDepth: 1 } : { ok: true, workspace: parent, cloneDir: parent, searchDepth: 3 };
|
|
29203
29418
|
}
|
|
29204
29419
|
if (tooBroad(input.startDir)) {
|
|
@@ -29233,7 +29448,7 @@ __export(run_exports3, {
|
|
|
29233
29448
|
watchedElsewhere: () => watchedElsewhere
|
|
29234
29449
|
});
|
|
29235
29450
|
import { readdir as readdir3, stat as stat11 } from "node:fs/promises";
|
|
29236
|
-
import { dirname as
|
|
29451
|
+
import { dirname as dirname22, join as join30, resolve as resolve5, sep as sep3 } from "node:path";
|
|
29237
29452
|
async function readLocalWatchedRepos(supabase, projectId) {
|
|
29238
29453
|
const { data, error } = await supabase.from("watched_repos").select("repo_owner, repo_name").eq("project_id", projectId).eq("source_kind", "local").is("deleted_at", null);
|
|
29239
29454
|
if (error) throw new Error(`could not read the project's locally polled repos: ${error.message}`);
|
|
@@ -29273,7 +29488,7 @@ async function listClones(dir) {
|
|
|
29273
29488
|
return out.sort();
|
|
29274
29489
|
}
|
|
29275
29490
|
function commonDir(paths) {
|
|
29276
|
-
const split = paths.map((p) =>
|
|
29491
|
+
const split = paths.map((p) => dirname22(p).split(sep3));
|
|
29277
29492
|
const common2 = [];
|
|
29278
29493
|
for (let i2 = 0; split.every((s) => s[i2] !== void 0 && s[i2] === split[0][i2]); i2++) common2.push(split[0][i2]);
|
|
29279
29494
|
return common2.join(sep3) || sep3;
|
|
@@ -29484,7 +29699,7 @@ async function prepareAddRepos(opts, deps = {}) {
|
|
|
29484
29699
|
mcpBaseUrl: cfg.archmeMcpBaseUrl,
|
|
29485
29700
|
project: opts.project,
|
|
29486
29701
|
branch: scanBranch,
|
|
29487
|
-
|
|
29702
|
+
log
|
|
29488
29703
|
});
|
|
29489
29704
|
} catch (e) {
|
|
29490
29705
|
log(` ! could not install agent config in ${c3.root}: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -29840,8 +30055,8 @@ var init_nearbyClones = __esm({
|
|
|
29840
30055
|
});
|
|
29841
30056
|
|
|
29842
30057
|
// src/init/handoff.ts
|
|
29843
|
-
import { mkdir as
|
|
29844
|
-
import { basename as basename3, dirname as
|
|
30058
|
+
import { mkdir as mkdir19, readFile as readFile20, rename as rename4, stat as stat13, writeFile as writeFile18 } from "node:fs/promises";
|
|
30059
|
+
import { basename as basename3, dirname as dirname23, join as join32, resolve as resolve6 } from "node:path";
|
|
29845
30060
|
function parseHandoffArgs(argv) {
|
|
29846
30061
|
const errors = [];
|
|
29847
30062
|
let to;
|
|
@@ -29870,7 +30085,7 @@ function parseHandoffArgs(argv) {
|
|
|
29870
30085
|
else repos.push(arg);
|
|
29871
30086
|
}
|
|
29872
30087
|
if (!to) errors.push("--to <path> is required: the handoff file archme init named in your instructions");
|
|
29873
|
-
else if (basename3(to) !== "handoff.json" || basename3(
|
|
30088
|
+
else if (basename3(to) !== "handoff.json" || basename3(dirname23(to)) !== "init" || basename3(dirname23(dirname23(to))) !== ".archme") {
|
|
29874
30089
|
errors.push(`--to must be archme init's handoff file (\u2026/${HANDOFF_FILE}), got \`${to}\``);
|
|
29875
30090
|
}
|
|
29876
30091
|
if (!project) errors.push("--project <org/slug> is required");
|
|
@@ -29935,7 +30150,7 @@ function isHandoff(v) {
|
|
|
29935
30150
|
async function readHandoff(file) {
|
|
29936
30151
|
let raw;
|
|
29937
30152
|
try {
|
|
29938
|
-
raw = await
|
|
30153
|
+
raw = await readFile20(file, "utf8");
|
|
29939
30154
|
} catch (e) {
|
|
29940
30155
|
if (e.code === "ENOENT") return null;
|
|
29941
30156
|
throw e;
|
|
@@ -29950,7 +30165,7 @@ async function readHandoff(file) {
|
|
|
29950
30165
|
return parsed;
|
|
29951
30166
|
}
|
|
29952
30167
|
async function writeHandoff(file, handoff) {
|
|
29953
|
-
await
|
|
30168
|
+
await mkdir19(dirname23(file), { recursive: true });
|
|
29954
30169
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
29955
30170
|
await writeFile18(tmp, JSON.stringify(handoff, null, 2) + "\n");
|
|
29956
30171
|
await rename4(tmp, file);
|
|
@@ -29987,11 +30202,11 @@ var init_handoff = __esm({
|
|
|
29987
30202
|
});
|
|
29988
30203
|
|
|
29989
30204
|
// src/init/conversation.ts
|
|
29990
|
-
import { mkdir as
|
|
29991
|
-
import { dirname as
|
|
30205
|
+
import { mkdir as mkdir20, readFile as readFile21, rename as rename5, rm as rm9, writeFile as writeFile19 } from "node:fs/promises";
|
|
30206
|
+
import { dirname as dirname24, join as join33 } from "node:path";
|
|
29992
30207
|
async function readInitSession(workspace) {
|
|
29993
30208
|
try {
|
|
29994
|
-
const parsed = JSON.parse(await
|
|
30209
|
+
const parsed = JSON.parse(await readFile21(join33(workspace, INIT_SESSION_FILE), "utf8"));
|
|
29995
30210
|
if (parsed.version !== 1 || typeof parsed.sessionId !== "string" || !SESSION_ID_RE2.test(parsed.sessionId)) return null;
|
|
29996
30211
|
if (parsed.phase !== "discovery" && parsed.phase !== "build" && parsed.phase !== "done") return null;
|
|
29997
30212
|
return { version: 1, sessionId: parsed.sessionId, phase: parsed.phase, updatedAt: String(parsed.updatedAt ?? "") };
|
|
@@ -30001,7 +30216,7 @@ async function readInitSession(workspace) {
|
|
|
30001
30216
|
}
|
|
30002
30217
|
async function writeInitSession(workspace, state) {
|
|
30003
30218
|
const file = join33(workspace, INIT_SESSION_FILE);
|
|
30004
|
-
await
|
|
30219
|
+
await mkdir20(dirname24(file), { recursive: true });
|
|
30005
30220
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
30006
30221
|
await writeFile19(tmp, JSON.stringify(state, null, 2) + "\n");
|
|
30007
30222
|
await rename5(tmp, file);
|
|
@@ -30011,7 +30226,7 @@ async function readFresh(file) {
|
|
|
30011
30226
|
}
|
|
30012
30227
|
async function runDiscoveryTurn(opts, deps = {}) {
|
|
30013
30228
|
const spawn2 = deps.spawn ?? spawnClaude;
|
|
30014
|
-
await
|
|
30229
|
+
await rm9(opts.handoffFile, { force: true });
|
|
30015
30230
|
const base = {
|
|
30016
30231
|
mcpConfigPath: opts.mcpConfigPath,
|
|
30017
30232
|
cwd: opts.workspace,
|
|
@@ -30254,7 +30469,7 @@ var init_facts = __esm({
|
|
|
30254
30469
|
});
|
|
30255
30470
|
|
|
30256
30471
|
// src/doctor/collect.ts
|
|
30257
|
-
import { readFile as
|
|
30472
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
30258
30473
|
import { join as join34 } from "node:path";
|
|
30259
30474
|
function binaryPresent(name) {
|
|
30260
30475
|
try {
|
|
@@ -30271,7 +30486,7 @@ async function git3(cwd, args) {
|
|
|
30271
30486
|
async function readMcpPin(repoRoot) {
|
|
30272
30487
|
const empty = { installed: false, pin: { project: null, branch: null } };
|
|
30273
30488
|
try {
|
|
30274
|
-
const raw = await
|
|
30489
|
+
const raw = await readFile22(join34(repoRoot, ".mcp.json"), "utf8");
|
|
30275
30490
|
const parsed = JSON.parse(raw);
|
|
30276
30491
|
const servers = parsed.mcpServers ?? {};
|
|
30277
30492
|
const entry = Object.entries(servers).find(([name]) => /archme/i.test(name));
|
|
@@ -30550,7 +30765,7 @@ async function runGuidedInit(opts, deps = {}) {
|
|
|
30550
30765
|
mcpBaseUrl: opts.mcpBaseUrl,
|
|
30551
30766
|
project: onBoard.project,
|
|
30552
30767
|
branch: onBoard.branch,
|
|
30553
|
-
|
|
30768
|
+
log
|
|
30554
30769
|
});
|
|
30555
30770
|
log(`
|
|
30556
30771
|
Your board: ${onBoard.webUrl}`);
|
|
@@ -30736,7 +30951,7 @@ async function runSetup(opts, deps, { workspace, cloneDir }, handoff) {
|
|
|
30736
30951
|
project: handoff.project,
|
|
30737
30952
|
local: handoff.access === "local",
|
|
30738
30953
|
yes: !!opts.scriptedReplies,
|
|
30739
|
-
agentConfig:
|
|
30954
|
+
agentConfig: true
|
|
30740
30955
|
},
|
|
30741
30956
|
{
|
|
30742
30957
|
cwd: cloneDir,
|
|
@@ -30805,7 +31020,7 @@ async function runSetup(opts, deps, { workspace, cloneDir }, handoff) {
|
|
|
30805
31020
|
mcpBaseUrl: opts.mcpBaseUrl,
|
|
30806
31021
|
project: handoff.project,
|
|
30807
31022
|
branch: scanBranch,
|
|
30808
|
-
|
|
31023
|
+
log
|
|
30809
31024
|
});
|
|
30810
31025
|
let watched = false;
|
|
30811
31026
|
if (handoff.access === "github-app") {
|
|
@@ -31026,6 +31241,50 @@ var init_guided = __esm({
|
|
|
31026
31241
|
}
|
|
31027
31242
|
});
|
|
31028
31243
|
|
|
31244
|
+
// src/init/agentOnly.ts
|
|
31245
|
+
async function runAgentOnly(opts, deps = {}) {
|
|
31246
|
+
const { log } = opts;
|
|
31247
|
+
const slug = opts.project ?? (await (deps.readPin ?? readMcpPin)(opts.repoRoot)).pin.project;
|
|
31248
|
+
if (!slug) {
|
|
31249
|
+
log("archme init --agent-only: this clone's .mcp.json pins no project \u2014 pass --project <org/slug>");
|
|
31250
|
+
return { exitCode: EX_USAGE2, project: "", branch: "" };
|
|
31251
|
+
}
|
|
31252
|
+
const notVisible = () => {
|
|
31253
|
+
log(`archme init --agent-only: project ${slug} does not exist or is not visible to ${opts.authed.identity}.`);
|
|
31254
|
+
log(" Check the slug, or run `archme login` to sign in as someone who can see it.");
|
|
31255
|
+
return { exitCode: EX_USAGE2, project: slug, branch: "" };
|
|
31256
|
+
};
|
|
31257
|
+
let project;
|
|
31258
|
+
try {
|
|
31259
|
+
project = await (deps.findProject ?? findProject)(opts.authed.supabase, slug);
|
|
31260
|
+
} catch (e) {
|
|
31261
|
+
if (e instanceof Error && /^org `.*` not found$/.test(e.message)) return notVisible();
|
|
31262
|
+
throw e;
|
|
31263
|
+
}
|
|
31264
|
+
if (!project) return notVisible();
|
|
31265
|
+
log(`\u2713 using existing project ${slug}`);
|
|
31266
|
+
const branch = project.architectureBranch ?? project.defaultBranch;
|
|
31267
|
+
log("\u2192 installing agent config (.mcp.json, CLAUDE.md, architecture skill)\u2026");
|
|
31268
|
+
await (deps.installAgentConfig ?? installAgentConfig)({
|
|
31269
|
+
repoRoot: opts.repoRoot,
|
|
31270
|
+
mcpBaseUrl: opts.mcpBaseUrl,
|
|
31271
|
+
project: slug,
|
|
31272
|
+
branch,
|
|
31273
|
+
log
|
|
31274
|
+
});
|
|
31275
|
+
return { exitCode: 0, project: slug, branch };
|
|
31276
|
+
}
|
|
31277
|
+
var EX_USAGE2;
|
|
31278
|
+
var init_agentOnly = __esm({
|
|
31279
|
+
"src/init/agentOnly.ts"() {
|
|
31280
|
+
"use strict";
|
|
31281
|
+
init_run_scan();
|
|
31282
|
+
init_collect();
|
|
31283
|
+
init_agentConfig();
|
|
31284
|
+
EX_USAGE2 = 78;
|
|
31285
|
+
}
|
|
31286
|
+
});
|
|
31287
|
+
|
|
31029
31288
|
// src/init/run-init.ts
|
|
31030
31289
|
async function defaultStartDaemon2() {
|
|
31031
31290
|
const { runStartFlow: runStartFlow2 } = await Promise.resolve().then(() => (init_install(), install_exports));
|
|
@@ -31074,8 +31333,6 @@ async function readBoardRepos2(supabase, projectId, branch) {
|
|
|
31074
31333
|
async function runInit(opts, deps = {}) {
|
|
31075
31334
|
const log = opts.log ?? ((msg) => console.log(msg));
|
|
31076
31335
|
const login = deps.login ?? runLogin;
|
|
31077
|
-
const fetchInstallScript = deps.fetchInstallScript ?? defaultFetchInstallScript;
|
|
31078
|
-
const runInstallScript = deps.runInstallScript ?? defaultRunInstallScript;
|
|
31079
31336
|
const scan = deps.scan ?? runScan;
|
|
31080
31337
|
const authenticate = deps.authenticate ?? createAuthedClient;
|
|
31081
31338
|
const resolveProject = deps.resolveProject ?? resolveOrCreateProject;
|
|
@@ -31088,7 +31345,7 @@ async function runInit(opts, deps = {}) {
|
|
|
31088
31345
|
const interactive = !opts.yes && (deps.interactive ?? stdinIsInteractive());
|
|
31089
31346
|
const openBoard = deps.openBoard ?? defaultOpenBoard2;
|
|
31090
31347
|
const cfg = resolveConfig();
|
|
31091
|
-
const guided = !!opts.scriptedReplies || interactive && !opts.skipScan;
|
|
31348
|
+
const guided = !opts.agentOnly && (!!opts.scriptedReplies || interactive && !opts.skipScan);
|
|
31092
31349
|
const git4 = guided ? null : await gitContext(opts.repoPath);
|
|
31093
31350
|
const { credentials } = await loadCreds(cfg.supabaseUrl);
|
|
31094
31351
|
const signedIn = credentials.length > 0;
|
|
@@ -31107,6 +31364,15 @@ async function runInit(opts, deps = {}) {
|
|
|
31107
31364
|
});
|
|
31108
31365
|
log(` signed in as ${authed2.identity} \u2014 not you? \`archme login\``);
|
|
31109
31366
|
const keyed = authed2.accountKind === "key";
|
|
31367
|
+
if (opts.agentOnly && git4) {
|
|
31368
|
+
const out = await runAgentOnly(
|
|
31369
|
+
{ authed: authed2, repoRoot: git4.root, ...opts.project ? { project: opts.project } : {}, mcpBaseUrl: cfg.archmeMcpBaseUrl, log },
|
|
31370
|
+
{ findProject: deps.findProject, readPin: deps.readPin, installAgentConfig: deps.installAgentConfig }
|
|
31371
|
+
);
|
|
31372
|
+
const ran2 = signedIn ? [] : ["login"];
|
|
31373
|
+
if (out.exitCode === 0) ran2.push("agent-config");
|
|
31374
|
+
return { exitCode: out.exitCode, project: out.project, branch: out.branch, webUrl: "", ran: ran2 };
|
|
31375
|
+
}
|
|
31110
31376
|
if (guided || !git4) {
|
|
31111
31377
|
const orgId = authed2.orgId;
|
|
31112
31378
|
if (!orgId) throw new Error("could not resolve your organization \u2014 run `archme login` again");
|
|
@@ -31120,7 +31386,6 @@ async function runInit(opts, deps = {}) {
|
|
|
31120
31386
|
mcpBaseUrl: cfg.archmeMcpBaseUrl,
|
|
31121
31387
|
supabaseUrl: cfg.supabaseUrl,
|
|
31122
31388
|
...opts.project ? { project: opts.project } : {},
|
|
31123
|
-
...opts.appOrigin ? { appOrigin: opts.appOrigin } : {},
|
|
31124
31389
|
...opts.force ? { force: true } : {},
|
|
31125
31390
|
...opts.scriptedReplies ? { scriptedReplies: opts.scriptedReplies } : {},
|
|
31126
31391
|
log
|
|
@@ -31164,9 +31429,8 @@ async function runInit(opts, deps = {}) {
|
|
|
31164
31429
|
const ran = signedIn ? [] : ["login"];
|
|
31165
31430
|
ran.push("project");
|
|
31166
31431
|
log("\u2192 installing agent config (.mcp.json, CLAUDE.md, architecture skill)\u2026");
|
|
31167
|
-
await installAgentConfig(
|
|
31168
|
-
{ repoRoot: repoPath, mcpBaseUrl: cfg.archmeMcpBaseUrl, project: fullSlug, branch: scanBranch,
|
|
31169
|
-
{ fetchInstallScript, runInstallScript }
|
|
31432
|
+
await (deps.installAgentConfig ?? installAgentConfig)(
|
|
31433
|
+
{ repoRoot: repoPath, mcpBaseUrl: cfg.archmeMcpBaseUrl, project: fullSlug, branch: scanBranch, log }
|
|
31170
31434
|
);
|
|
31171
31435
|
ran.push("agent-config");
|
|
31172
31436
|
const onBoard = await (deps.boardRepos ?? readBoardRepos2)(authed2.supabase, project.projectId, scanBranch);
|
|
@@ -31400,6 +31664,7 @@ var init_run_init = __esm({
|
|
|
31400
31664
|
init_run2();
|
|
31401
31665
|
init_watchRepo();
|
|
31402
31666
|
init_agentConfig();
|
|
31667
|
+
init_agentOnly();
|
|
31403
31668
|
init_scanBranch();
|
|
31404
31669
|
init_scanBranch();
|
|
31405
31670
|
DAEMON_QUESTION2 = "Keep the board updating in the background?";
|
|
@@ -31440,6 +31705,7 @@ function parseInitArgs(argv) {
|
|
|
31440
31705
|
const args = {
|
|
31441
31706
|
force: false,
|
|
31442
31707
|
skipScan: false,
|
|
31708
|
+
agentOnly: false,
|
|
31443
31709
|
yes: false,
|
|
31444
31710
|
noInteractive: false,
|
|
31445
31711
|
help: false
|
|
@@ -31474,6 +31740,7 @@ function parseInitArgs(argv) {
|
|
|
31474
31740
|
if (arg === "--force") args.force = true;
|
|
31475
31741
|
else if (arg === "--yes") args.yes = true;
|
|
31476
31742
|
else if (arg === "--no-interactive") args.noInteractive = true;
|
|
31743
|
+
else if (arg === "--agent-only") args.agentOnly = true;
|
|
31477
31744
|
else args.skipScan = true;
|
|
31478
31745
|
continue;
|
|
31479
31746
|
}
|
|
@@ -31497,8 +31764,6 @@ function parseInitArgs(argv) {
|
|
|
31497
31764
|
};
|
|
31498
31765
|
}
|
|
31499
31766
|
args.project = value;
|
|
31500
|
-
} else {
|
|
31501
|
-
args.appOrigin = value;
|
|
31502
31767
|
}
|
|
31503
31768
|
continue;
|
|
31504
31769
|
}
|
|
@@ -31514,6 +31779,11 @@ function parseInitArgs(argv) {
|
|
|
31514
31779
|
};
|
|
31515
31780
|
}
|
|
31516
31781
|
args.repoPath = positionals[0];
|
|
31782
|
+
if (args.agentOnly) {
|
|
31783
|
+
for (const [flag, set] of [["--force", args.force], ["--skip-scan", args.skipScan]]) {
|
|
31784
|
+
if (set) return { ok: false, error: `--agent-only cannot be combined with ${flag}: it never scans` };
|
|
31785
|
+
}
|
|
31786
|
+
}
|
|
31517
31787
|
return { ok: true, args };
|
|
31518
31788
|
}
|
|
31519
31789
|
var BOOLEAN_FLAGS, VALUE_FLAGS, HELP_FLAGS, LOGIN_FLAGS, PROJECT_SLUG_RE2;
|
|
@@ -31523,10 +31793,11 @@ var init_args = __esm({
|
|
|
31523
31793
|
BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
31524
31794
|
"--force",
|
|
31525
31795
|
"--skip-scan",
|
|
31796
|
+
"--agent-only",
|
|
31526
31797
|
"--yes",
|
|
31527
31798
|
"--no-interactive"
|
|
31528
31799
|
]);
|
|
31529
|
-
VALUE_FLAGS = /* @__PURE__ */ new Set(["--project"
|
|
31800
|
+
VALUE_FLAGS = /* @__PURE__ */ new Set(["--project"]);
|
|
31530
31801
|
HELP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "help"]);
|
|
31531
31802
|
LOGIN_FLAGS = {
|
|
31532
31803
|
"--no-account": "no-account",
|
|
@@ -31542,12 +31813,12 @@ var dispatch_exports4 = {};
|
|
|
31542
31813
|
__export(dispatch_exports4, {
|
|
31543
31814
|
EX_INFRA: () => EX_INFRA2,
|
|
31544
31815
|
EX_OK: () => EX_OK2,
|
|
31545
|
-
EX_USAGE: () =>
|
|
31816
|
+
EX_USAGE: () => EX_USAGE3,
|
|
31546
31817
|
dispatchInit: () => dispatchInit,
|
|
31547
31818
|
printInitHelp: () => printInitHelp,
|
|
31548
31819
|
readScriptedReplies: () => readScriptedReplies
|
|
31549
31820
|
});
|
|
31550
|
-
import { readFile as
|
|
31821
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
31551
31822
|
import { resolve as resolve7 } from "node:path";
|
|
31552
31823
|
function printInitHelp() {
|
|
31553
31824
|
console.log(`archme init \u2014 set up ArchMe for your product, one repo or several
|
|
@@ -31569,10 +31840,13 @@ Usage:
|
|
|
31569
31840
|
Options:
|
|
31570
31841
|
--project <org/slug> Use this project instead of agreeing one in the conversation
|
|
31571
31842
|
--skip-scan Set up agent config for this repo but do not scan
|
|
31843
|
+
--agent-only Join a project that already exists: write this clone's
|
|
31844
|
+
agent config (.mcp.json, CLAUDE.md block, architecture
|
|
31845
|
+
skill) and nothing else \u2014 no project, watching or scan.
|
|
31846
|
+
Uses --project, else the project .mcp.json pins
|
|
31572
31847
|
--force Re-scan a repo whose board already has an architecture
|
|
31573
31848
|
--yes Run unattended: this repo only, headless scan, no questions
|
|
31574
31849
|
--no-interactive Same as --yes; for automation
|
|
31575
|
-
--app-origin <url> Origin serving /api/install-agent (local development)
|
|
31576
31850
|
--no-account If not signed in: continue without an account (a key
|
|
31577
31851
|
saved on this machine signs you in; archme key show
|
|
31578
31852
|
prints it)
|
|
@@ -31592,7 +31866,7 @@ into your repos except .mcp.json is git-ignored.`);
|
|
|
31592
31866
|
async function readScriptedReplies(env) {
|
|
31593
31867
|
const path7 = env.ARCHME_E2E_INIT_REPLIES;
|
|
31594
31868
|
if (!path7) return void 0;
|
|
31595
|
-
const parsed = JSON.parse(await
|
|
31869
|
+
const parsed = JSON.parse(await readFile23(path7, "utf8"));
|
|
31596
31870
|
if (!Array.isArray(parsed) || !parsed.every((r) => typeof r === "string")) {
|
|
31597
31871
|
throw new Error(`ARCHME_E2E_INIT_REPLIES (${path7}) must hold a JSON array of strings`);
|
|
31598
31872
|
}
|
|
@@ -31611,7 +31885,7 @@ async function dispatchInit(argv) {
|
|
|
31611
31885
|
if (!parsed.ok) {
|
|
31612
31886
|
console.error(`archme init: ${parsed.error}`);
|
|
31613
31887
|
printInitHelp();
|
|
31614
|
-
return
|
|
31888
|
+
return EX_USAGE3;
|
|
31615
31889
|
}
|
|
31616
31890
|
if (parsed.args.help) {
|
|
31617
31891
|
printInitHelp();
|
|
@@ -31622,9 +31896,9 @@ async function dispatchInit(argv) {
|
|
|
31622
31896
|
const result = await runInit({
|
|
31623
31897
|
repoPath: resolve7(parsed.args.repoPath ?? process.cwd()),
|
|
31624
31898
|
project: parsed.args.project,
|
|
31625
|
-
appOrigin: parsed.args.appOrigin,
|
|
31626
31899
|
force: parsed.args.force,
|
|
31627
31900
|
skipScan: parsed.args.skipScan,
|
|
31901
|
+
agentOnly: parsed.args.agentOnly,
|
|
31628
31902
|
yes: parsed.args.yes || parsed.args.noInteractive,
|
|
31629
31903
|
login: parsed.args.login,
|
|
31630
31904
|
...scriptedReplies ? { scriptedReplies } : {}
|
|
@@ -31637,7 +31911,7 @@ async function dispatchInit(argv) {
|
|
|
31637
31911
|
return EX_INFRA2;
|
|
31638
31912
|
}
|
|
31639
31913
|
}
|
|
31640
|
-
var EX_OK2, EX_INFRA2,
|
|
31914
|
+
var EX_OK2, EX_INFRA2, EX_USAGE3;
|
|
31641
31915
|
var init_dispatch4 = __esm({
|
|
31642
31916
|
"src/init/dispatch.ts"() {
|
|
31643
31917
|
"use strict";
|
|
@@ -31647,93 +31921,7 @@ var init_dispatch4 = __esm({
|
|
|
31647
31921
|
init_args();
|
|
31648
31922
|
EX_OK2 = 0;
|
|
31649
31923
|
EX_INFRA2 = 3;
|
|
31650
|
-
|
|
31651
|
-
}
|
|
31652
|
-
});
|
|
31653
|
-
|
|
31654
|
-
// src/uninstall/edits.ts
|
|
31655
|
-
function stripArchmeClaudeBlock(content) {
|
|
31656
|
-
const start = content.indexOf(START_MARKER);
|
|
31657
|
-
if (start === -1) return UNCHANGED;
|
|
31658
|
-
const end = content.indexOf(END_MARKER, start);
|
|
31659
|
-
if (end === -1) return UNCHANGED;
|
|
31660
|
-
const before = content.slice(0, start).replace(/\n+$/, "");
|
|
31661
|
-
const after = content.slice(end + END_MARKER.length).replace(/^\n+/, "");
|
|
31662
|
-
if (!before.trim() && !after.trim()) return { kind: "delete" };
|
|
31663
|
-
if (!before.trim()) return { kind: "rewrite", content: `${after.replace(/\n*$/, "")}
|
|
31664
|
-
` };
|
|
31665
|
-
if (!after.trim()) return { kind: "rewrite", content: `${before}
|
|
31666
|
-
` };
|
|
31667
|
-
return { kind: "rewrite", content: `${before}
|
|
31668
|
-
|
|
31669
|
-
${after.replace(/\n*$/, "")}
|
|
31670
|
-
` };
|
|
31671
|
-
}
|
|
31672
|
-
function parseObject(raw) {
|
|
31673
|
-
try {
|
|
31674
|
-
const parsed = JSON.parse(raw);
|
|
31675
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
31676
|
-
return parsed;
|
|
31677
|
-
} catch {
|
|
31678
|
-
return null;
|
|
31679
|
-
}
|
|
31680
|
-
}
|
|
31681
|
-
function render(value) {
|
|
31682
|
-
return `${JSON.stringify(value, null, 2)}
|
|
31683
|
-
`;
|
|
31684
|
-
}
|
|
31685
|
-
function stripArchmeMcpServer(content) {
|
|
31686
|
-
const root = parseObject(content);
|
|
31687
|
-
if (!root) return UNCHANGED;
|
|
31688
|
-
const servers = root.mcpServers;
|
|
31689
|
-
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return UNCHANGED;
|
|
31690
|
-
const entries = servers;
|
|
31691
|
-
if (!(MCP_SERVER_NAME2 in entries)) return UNCHANGED;
|
|
31692
|
-
delete entries[MCP_SERVER_NAME2];
|
|
31693
|
-
const onlyKey = Object.keys(root).length === 1 && "mcpServers" in root;
|
|
31694
|
-
if (onlyKey && Object.keys(entries).length === 0) return { kind: "delete" };
|
|
31695
|
-
return { kind: "rewrite", content: render(root) };
|
|
31696
|
-
}
|
|
31697
|
-
function isArchmeHook(hook) {
|
|
31698
|
-
const command = hook?.command;
|
|
31699
|
-
return typeof command === "string" && command.includes(NUDGE_HOOK_FILE);
|
|
31700
|
-
}
|
|
31701
|
-
function stripArchmeHooks(content) {
|
|
31702
|
-
const root = parseObject(content);
|
|
31703
|
-
if (!root) return UNCHANGED;
|
|
31704
|
-
const hooks = root.hooks;
|
|
31705
|
-
if (!hooks || typeof hooks !== "object" || Array.isArray(hooks)) return UNCHANGED;
|
|
31706
|
-
const byEvent = hooks;
|
|
31707
|
-
const pre = byEvent.PreToolUse;
|
|
31708
|
-
if (!Array.isArray(pre)) return UNCHANGED;
|
|
31709
|
-
let changed = false;
|
|
31710
|
-
const kept = [];
|
|
31711
|
-
for (const entry of pre) {
|
|
31712
|
-
const inner = entry?.hooks;
|
|
31713
|
-
if (!Array.isArray(inner) || !inner.some(isArchmeHook)) {
|
|
31714
|
-
kept.push(entry);
|
|
31715
|
-
continue;
|
|
31716
|
-
}
|
|
31717
|
-
changed = true;
|
|
31718
|
-
const survivors = inner.filter((h2) => !isArchmeHook(h2));
|
|
31719
|
-
if (survivors.length > 0) kept.push({ ...entry, hooks: survivors });
|
|
31720
|
-
}
|
|
31721
|
-
if (!changed) return UNCHANGED;
|
|
31722
|
-
if (kept.length > 0) byEvent.PreToolUse = kept;
|
|
31723
|
-
else delete byEvent.PreToolUse;
|
|
31724
|
-
if (Object.keys(byEvent).length === 0) delete root.hooks;
|
|
31725
|
-
if (Object.keys(root).length === 0) return { kind: "delete" };
|
|
31726
|
-
return { kind: "rewrite", content: render(root) };
|
|
31727
|
-
}
|
|
31728
|
-
var UNCHANGED, START_MARKER, END_MARKER, NUDGE_HOOK_FILE, MCP_SERVER_NAME2;
|
|
31729
|
-
var init_edits = __esm({
|
|
31730
|
-
"src/uninstall/edits.ts"() {
|
|
31731
|
-
"use strict";
|
|
31732
|
-
UNCHANGED = { kind: "unchanged" };
|
|
31733
|
-
START_MARKER = "<!-- ARCHME-START -->";
|
|
31734
|
-
END_MARKER = "<!-- ARCHME-END -->";
|
|
31735
|
-
NUDGE_HOOK_FILE = "archme-search-nudge.mjs";
|
|
31736
|
-
MCP_SERVER_NAME2 = "archme";
|
|
31924
|
+
EX_USAGE3 = 78;
|
|
31737
31925
|
}
|
|
31738
31926
|
});
|
|
31739
31927
|
|
|
@@ -31863,7 +32051,7 @@ var init_backend = __esm({
|
|
|
31863
32051
|
var run_uninstall_exports = {};
|
|
31864
32052
|
__export(run_uninstall_exports, {
|
|
31865
32053
|
EX_OK: () => EX_OK3,
|
|
31866
|
-
EX_USAGE: () =>
|
|
32054
|
+
EX_USAGE: () => EX_USAGE4,
|
|
31867
32055
|
runUninstall: () => runUninstall
|
|
31868
32056
|
});
|
|
31869
32057
|
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync6, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
@@ -31995,7 +32183,7 @@ async function runUninstall(opts) {
|
|
|
31995
32183
|
error(
|
|
31996
32184
|
"archme uninstall: refusing to edit files without confirmation.\nThere is nobody to ask (stdin is not a terminal). Re-run with --yes."
|
|
31997
32185
|
);
|
|
31998
|
-
return { exitCode:
|
|
32186
|
+
return { exitCode: EX_USAGE4, removed: [], unwatched: [] };
|
|
31999
32187
|
}
|
|
32000
32188
|
const confirm = opts.confirm ?? (async (lines) => {
|
|
32001
32189
|
log(`This will change, in ${repoPath} and on your ArchMe account:
|
|
@@ -32104,7 +32292,7 @@ async function defaultBackend() {
|
|
|
32104
32292
|
const { createDefaultBackend: createDefaultBackend2 } = await Promise.resolve().then(() => (init_backend(), backend_exports));
|
|
32105
32293
|
return createDefaultBackend2();
|
|
32106
32294
|
}
|
|
32107
|
-
var EX_OK3,
|
|
32295
|
+
var EX_OK3, EX_USAGE4, PRUNABLE_DIRS;
|
|
32108
32296
|
var init_run_uninstall = __esm({
|
|
32109
32297
|
"src/uninstall/run-uninstall.ts"() {
|
|
32110
32298
|
"use strict";
|
|
@@ -32112,7 +32300,7 @@ var init_run_uninstall = __esm({
|
|
|
32112
32300
|
init_edits();
|
|
32113
32301
|
init_watching();
|
|
32114
32302
|
EX_OK3 = 0;
|
|
32115
|
-
|
|
32303
|
+
EX_USAGE4 = 78;
|
|
32116
32304
|
PRUNABLE_DIRS = [
|
|
32117
32305
|
".claude/skills/architecture",
|
|
32118
32306
|
".claude/skills",
|
|
@@ -32127,7 +32315,7 @@ var dispatch_exports5 = {};
|
|
|
32127
32315
|
__export(dispatch_exports5, {
|
|
32128
32316
|
EX_INFRA: () => EX_INFRA3,
|
|
32129
32317
|
EX_OK: () => EX_OK4,
|
|
32130
|
-
EX_USAGE: () =>
|
|
32318
|
+
EX_USAGE: () => EX_USAGE5,
|
|
32131
32319
|
dispatchUninstall: () => dispatchUninstall,
|
|
32132
32320
|
parseUninstallArgs: () => parseUninstallArgs,
|
|
32133
32321
|
printUninstallHelp: () => printUninstallHelp
|
|
@@ -32189,7 +32377,7 @@ async function dispatchUninstall(argv) {
|
|
|
32189
32377
|
if (parsed.kind === "error") {
|
|
32190
32378
|
console.error(`archme uninstall: ${parsed.message}`);
|
|
32191
32379
|
printUninstallHelp();
|
|
32192
|
-
return
|
|
32380
|
+
return EX_USAGE5;
|
|
32193
32381
|
}
|
|
32194
32382
|
try {
|
|
32195
32383
|
const { runUninstall: runUninstall2 } = await Promise.resolve().then(() => (init_run_uninstall(), run_uninstall_exports));
|
|
@@ -32204,13 +32392,13 @@ async function dispatchUninstall(argv) {
|
|
|
32204
32392
|
return EX_INFRA3;
|
|
32205
32393
|
}
|
|
32206
32394
|
}
|
|
32207
|
-
var EX_OK4, EX_INFRA3,
|
|
32395
|
+
var EX_OK4, EX_INFRA3, EX_USAGE5;
|
|
32208
32396
|
var init_dispatch5 = __esm({
|
|
32209
32397
|
"src/uninstall/dispatch.ts"() {
|
|
32210
32398
|
"use strict";
|
|
32211
32399
|
EX_OK4 = 0;
|
|
32212
32400
|
EX_INFRA3 = 3;
|
|
32213
|
-
|
|
32401
|
+
EX_USAGE5 = 78;
|
|
32214
32402
|
}
|
|
32215
32403
|
});
|
|
32216
32404
|
|
|
@@ -32219,7 +32407,7 @@ var localWatchDispatch_exports = {};
|
|
|
32219
32407
|
__export(localWatchDispatch_exports, {
|
|
32220
32408
|
EX_INFRA: () => EX_INFRA4,
|
|
32221
32409
|
EX_OK: () => EX_OK5,
|
|
32222
|
-
EX_USAGE: () =>
|
|
32410
|
+
EX_USAGE: () => EX_USAGE6,
|
|
32223
32411
|
dispatchLocalWatch: () => dispatchLocalWatch,
|
|
32224
32412
|
parseLocalWatchArgs: () => parseLocalWatchArgs,
|
|
32225
32413
|
printLocalWatchHelp: () => printLocalWatchHelp
|
|
@@ -32321,7 +32509,7 @@ async function dispatchLocalWatch(argv) {
|
|
|
32321
32509
|
if (parsed.kind === "error") {
|
|
32322
32510
|
console.error(parsed.message);
|
|
32323
32511
|
printLocalWatchHelp();
|
|
32324
|
-
return
|
|
32512
|
+
return EX_USAGE6;
|
|
32325
32513
|
}
|
|
32326
32514
|
const mod = await Promise.resolve().then(() => (init_localWatch(), localWatch_exports));
|
|
32327
32515
|
switch (parsed.kind) {
|
|
@@ -32335,13 +32523,13 @@ async function dispatchLocalWatch(argv) {
|
|
|
32335
32523
|
return await mod.runLocalWatch(parsed);
|
|
32336
32524
|
}
|
|
32337
32525
|
}
|
|
32338
|
-
var EX_OK5, EX_INFRA4,
|
|
32526
|
+
var EX_OK5, EX_INFRA4, EX_USAGE6, PROJECT_SLUG_RE3, REPO_SLUG_RE2;
|
|
32339
32527
|
var init_localWatchDispatch = __esm({
|
|
32340
32528
|
"src/daemon/localWatchDispatch.ts"() {
|
|
32341
32529
|
"use strict";
|
|
32342
32530
|
EX_OK5 = 0;
|
|
32343
32531
|
EX_INFRA4 = 3;
|
|
32344
|
-
|
|
32532
|
+
EX_USAGE6 = 78;
|
|
32345
32533
|
PROJECT_SLUG_RE3 = /^[^/\s]+\/[^/\s]+$/;
|
|
32346
32534
|
REPO_SLUG_RE2 = /^[^/\s]+\/[^/\s]+$/;
|
|
32347
32535
|
}
|
|
@@ -32479,7 +32667,6 @@ function parseAddReposArgs(argv) {
|
|
|
32479
32667
|
let project;
|
|
32480
32668
|
let local = false;
|
|
32481
32669
|
let yes = false;
|
|
32482
|
-
let appOrigin;
|
|
32483
32670
|
for (let i2 = 0; i2 < argv.length; i2++) {
|
|
32484
32671
|
const arg = argv[i2];
|
|
32485
32672
|
const next = argv[i2 + 1];
|
|
@@ -32487,10 +32674,6 @@ function parseAddReposArgs(argv) {
|
|
|
32487
32674
|
if (!next || !PROJECT_SLUG_RE5.test(next)) return err3("--project needs `org/slug`");
|
|
32488
32675
|
project = next;
|
|
32489
32676
|
i2++;
|
|
32490
|
-
} else if (arg === "--app-origin") {
|
|
32491
|
-
if (!next || next.startsWith("-")) return err3("--app-origin needs a URL");
|
|
32492
|
-
appOrigin = next;
|
|
32493
|
-
i2++;
|
|
32494
32677
|
} else if (arg === "--local") {
|
|
32495
32678
|
local = true;
|
|
32496
32679
|
} else if (arg === "--yes" || arg === "--no-interactive") {
|
|
@@ -32502,7 +32685,7 @@ function parseAddReposArgs(argv) {
|
|
|
32502
32685
|
}
|
|
32503
32686
|
}
|
|
32504
32687
|
if (!project) return err3("--project <org/slug> is required \u2014 the multi-repo project to add the repos to");
|
|
32505
|
-
return { kind: "run", opts: { targets, project, local, yes, agentConfig:
|
|
32688
|
+
return { kind: "run", opts: { targets, project, local, yes, agentConfig: true } };
|
|
32506
32689
|
}
|
|
32507
32690
|
function printAddReposHelp() {
|
|
32508
32691
|
console.log(`archme add-repos \u2014 add several repos to a multi-repo project in one run
|
|
@@ -32537,7 +32720,6 @@ Options:
|
|
|
32537
32720
|
--local Local watch: this machine checks for new commits, instead
|
|
32538
32721
|
of GitHub watch (the ArchMe GitHub App)
|
|
32539
32722
|
--yes Everything headless, no questions; the plan is approved
|
|
32540
|
-
--app-origin <url> Origin serving /api/install-agent (local development)
|
|
32541
32723
|
|
|
32542
32724
|
Every clone gets agent config (.mcp.json pinned to the project, a CLAUDE.md
|
|
32543
32725
|
block, the architecture skill); everything but .mcp.json is git-ignored.`);
|
|
@@ -32648,13 +32830,13 @@ var dispatch_exports8 = {};
|
|
|
32648
32830
|
__export(dispatch_exports8, {
|
|
32649
32831
|
EX_INFRA: () => EX_INFRA5,
|
|
32650
32832
|
EX_OK: () => EX_OK6,
|
|
32651
|
-
EX_USAGE: () =>
|
|
32833
|
+
EX_USAGE: () => EX_USAGE7,
|
|
32652
32834
|
dispatchDoctor: () => dispatchDoctor,
|
|
32653
32835
|
parseDoctorArgs: () => parseDoctorArgs,
|
|
32654
32836
|
printDoctorHelp: () => printDoctorHelp
|
|
32655
32837
|
});
|
|
32656
|
-
import { mkdtemp as
|
|
32657
|
-
import { tmpdir as
|
|
32838
|
+
import { mkdtemp as mkdtemp5, rm as rm10, writeFile as writeFile20 } from "node:fs/promises";
|
|
32839
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
32658
32840
|
import { join as join37 } from "node:path";
|
|
32659
32841
|
function parseDoctorArgs(argv) {
|
|
32660
32842
|
const args = { plain: false, help: false };
|
|
@@ -32687,7 +32869,7 @@ async function dispatchDoctor(argv) {
|
|
|
32687
32869
|
if (!parsed.ok) {
|
|
32688
32870
|
console.error(parsed.message);
|
|
32689
32871
|
printDoctorHelp();
|
|
32690
|
-
return
|
|
32872
|
+
return EX_USAGE7;
|
|
32691
32873
|
}
|
|
32692
32874
|
if (parsed.args.help) {
|
|
32693
32875
|
printDoctorHelp();
|
|
@@ -32716,7 +32898,7 @@ async function dispatchDoctor(argv) {
|
|
|
32716
32898
|
);
|
|
32717
32899
|
return EX_OK6;
|
|
32718
32900
|
}
|
|
32719
|
-
const dir = await
|
|
32901
|
+
const dir = await mkdtemp5(join37(tmpdir5(), "archme-doctor-"));
|
|
32720
32902
|
const mcpConfigPath = join37(dir, "mcp.json");
|
|
32721
32903
|
await writeFile20(mcpConfigPath, JSON.stringify({ mcpServers: {} }), { mode: 384 });
|
|
32722
32904
|
try {
|
|
@@ -32732,10 +32914,10 @@ async function dispatchDoctor(argv) {
|
|
|
32732
32914
|
});
|
|
32733
32915
|
return result.exitCode === 0 ? EX_OK6 : EX_INFRA5;
|
|
32734
32916
|
} finally {
|
|
32735
|
-
await
|
|
32917
|
+
await rm10(dir, { recursive: true, force: true });
|
|
32736
32918
|
}
|
|
32737
32919
|
}
|
|
32738
|
-
var EX_OK6, EX_INFRA5,
|
|
32920
|
+
var EX_OK6, EX_INFRA5, EX_USAGE7;
|
|
32739
32921
|
var init_dispatch8 = __esm({
|
|
32740
32922
|
"src/doctor/dispatch.ts"() {
|
|
32741
32923
|
"use strict";
|
|
@@ -32746,7 +32928,7 @@ var init_dispatch8 = __esm({
|
|
|
32746
32928
|
init_preflight();
|
|
32747
32929
|
EX_OK6 = 0;
|
|
32748
32930
|
EX_INFRA5 = 3;
|
|
32749
|
-
|
|
32931
|
+
EX_USAGE7 = 78;
|
|
32750
32932
|
}
|
|
32751
32933
|
});
|
|
32752
32934
|
|
|
@@ -32885,7 +33067,7 @@ var init_conciergeToken = __esm({
|
|
|
32885
33067
|
});
|
|
32886
33068
|
|
|
32887
33069
|
// src/daemon/sandboxJob/input.ts
|
|
32888
|
-
import { readFile as
|
|
33070
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
32889
33071
|
function isObj2(v) {
|
|
32890
33072
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
32891
33073
|
}
|
|
@@ -33138,7 +33320,7 @@ function parseInput(raw) {
|
|
|
33138
33320
|
if (data.kind === "triage") return parseTriage(data, job);
|
|
33139
33321
|
fail("kind must be clone, agent, digest, probe or triage");
|
|
33140
33322
|
}
|
|
33141
|
-
async function readInput(path7 = INPUT_PATH, read = (p) =>
|
|
33323
|
+
async function readInput(path7 = INPUT_PATH, read = (p) => readFile24(p, "utf8")) {
|
|
33142
33324
|
let raw;
|
|
33143
33325
|
try {
|
|
33144
33326
|
raw = await read(path7);
|
|
@@ -33296,7 +33478,7 @@ var init_probe = __esm({
|
|
|
33296
33478
|
});
|
|
33297
33479
|
|
|
33298
33480
|
// src/daemon/sandboxJob/digest.ts
|
|
33299
|
-
import { mkdir as
|
|
33481
|
+
import { mkdir as mkdir21, writeFile as writeFile21 } from "node:fs/promises";
|
|
33300
33482
|
import { join as join38 } from "node:path";
|
|
33301
33483
|
async function runDigestStep(input, deps = {}) {
|
|
33302
33484
|
const log = deps.log ?? (() => {
|
|
@@ -33308,7 +33490,7 @@ async function runDigestStep(input, deps = {}) {
|
|
|
33308
33490
|
const mcpDir = deps.mcpDir ?? BOX_MCP_DIR;
|
|
33309
33491
|
const workDir = deps.workDir ?? "/tmp/digest";
|
|
33310
33492
|
for (const d of [mcpDir, workDir, ...deps.homeDirs ?? [BOX_HOME, BOX_CLAUDE_CONFIG_DIR]]) {
|
|
33311
|
-
await
|
|
33493
|
+
await mkdir21(d, { recursive: true, mode: 448 });
|
|
33312
33494
|
}
|
|
33313
33495
|
const mcpConfigPath = join38(mcpDir, "mcp.json");
|
|
33314
33496
|
await writeFile21(mcpConfigPath, JSON.stringify(input.tools ? boxMcpConfig(input.gateway) : { mcpServers: {} }), { mode: 384 });
|
|
@@ -33354,7 +33536,7 @@ var init_digest2 = __esm({
|
|
|
33354
33536
|
});
|
|
33355
33537
|
|
|
33356
33538
|
// src/daemon/sandboxJob/triage.ts
|
|
33357
|
-
import { mkdir as
|
|
33539
|
+
import { mkdir as mkdir22, readFile as readFile25 } from "node:fs/promises";
|
|
33358
33540
|
async function runTriageStep(input, deps = {}) {
|
|
33359
33541
|
const repoDir = deps.repoDir ?? REPO_DIR;
|
|
33360
33542
|
const log = deps.log ?? (() => {
|
|
@@ -33365,7 +33547,7 @@ async function runTriageStep(input, deps = {}) {
|
|
|
33365
33547
|
const writeStderr = deps.writeStderr ?? ((c3) => {
|
|
33366
33548
|
process.stderr.write(c3);
|
|
33367
33549
|
});
|
|
33368
|
-
const diff = parsePersistedDiff(await
|
|
33550
|
+
const diff = parsePersistedDiff(await readFile25(deps.diffPath ?? DIFF_PATH, "utf8"));
|
|
33369
33551
|
mark("read_diff");
|
|
33370
33552
|
const { job } = input;
|
|
33371
33553
|
const prompt = buildTriagePrompt({
|
|
@@ -33384,7 +33566,7 @@ async function runTriageStep(input, deps = {}) {
|
|
|
33384
33566
|
});
|
|
33385
33567
|
const promptBytes = Buffer.byteLength(prompt, "utf8");
|
|
33386
33568
|
const mcpConfigPath = await writeBoxMcpConfig(input.gateway, deps.mcpDir);
|
|
33387
|
-
for (const d of deps.homeDirs ?? [BOX_HOME, BOX_CLAUDE_CONFIG_DIR]) await
|
|
33569
|
+
for (const d of deps.homeDirs ?? [BOX_HOME, BOX_CLAUDE_CONFIG_DIR]) await mkdir22(d, { recursive: true, mode: 448 });
|
|
33388
33570
|
log(`spawning triage claude (model ${input.model}, ${input.candidates.length} candidate(s), prompt ${promptBytes} bytes)`);
|
|
33389
33571
|
const proc = spawn2({
|
|
33390
33572
|
prompt,
|
|
@@ -33429,7 +33611,7 @@ __export(main_exports, {
|
|
|
33429
33611
|
readNonceLine: () => readNonceLine,
|
|
33430
33612
|
runSandboxJob: () => runSandboxJob
|
|
33431
33613
|
});
|
|
33432
|
-
import { mkdir as
|
|
33614
|
+
import { mkdir as mkdir23 } from "node:fs/promises";
|
|
33433
33615
|
function readNonceLine(stream = process.stdin) {
|
|
33434
33616
|
return new Promise((resolve9) => {
|
|
33435
33617
|
let buf = "";
|
|
@@ -33547,7 +33729,7 @@ async function runSandboxJob(argv, deps = {}) {
|
|
|
33547
33729
|
if (input.kind === "digest") {
|
|
33548
33730
|
log(`digest job=${input.jobId}`);
|
|
33549
33731
|
try {
|
|
33550
|
-
await
|
|
33732
|
+
await mkdir23(deps.homeDir ?? process.env.HOME ?? BOX_HOME, { recursive: true, mode: 448 });
|
|
33551
33733
|
const { result, exitCode } = await runDigestStep(input, { log, mark, ...deps.digest });
|
|
33552
33734
|
return emit2({ ...result, memoryPeakBytes: null, durations_ms: {} }, exitCode);
|
|
33553
33735
|
} catch (err4) {
|
|
@@ -33558,7 +33740,7 @@ async function runSandboxJob(argv, deps = {}) {
|
|
|
33558
33740
|
}
|
|
33559
33741
|
log(`${stepName} job=${input.job.id} repo=${input.job.repo_owner}/${input.job.repo_name} ${input.job.after_sha ? `after=${input.job.after_sha.slice(0, 8)}` : `scan=${(input.job.scan_ref ?? "").slice(0, 8)}`}`);
|
|
33560
33742
|
try {
|
|
33561
|
-
await
|
|
33743
|
+
await mkdir23(deps.homeDir ?? process.env.HOME ?? BOX_HOME, { recursive: true, mode: 448 });
|
|
33562
33744
|
if (input.kind === "clone") {
|
|
33563
33745
|
const { result: result2, exitCode: exitCode2 } = await runCloneStep(input, { log, mark, ...deps.clone });
|
|
33564
33746
|
return emit2({ ...result2, memoryPeakBytes: null, durations_ms: {} }, exitCode2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archme/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
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