@moda-ai/cli 1.55.135 → 1.55.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/{agent-g7pg6qsk.js → agent-dxmbckx7.js} +4 -4
- package/dist/{change-impact-p73qj0vj.js → change-impact-b997srew.js} +2 -2
- package/dist/{cli-6qff9sy8.js → cli-0d3s9b42.js} +3 -3
- package/dist/{cli-8800mp37.js → cli-117eqfj5.js} +13 -18
- package/dist/{cli-q96h6rs9.js → cli-8ygykkqh.js} +1 -1
- package/dist/{cli-6hwyagze.js → cli-f3jwv55s.js} +4 -4
- package/dist/{cli-zh32cntw.js → cli-fc1rx0gw.js} +3 -3
- package/dist/{cli-aaxzwp8g.js → cli-fv22sck1.js} +3 -3
- package/dist/{cli-rpyepjwb.js → cli-jkv3y2bj.js} +3 -16
- package/dist/{cli-8qtxp95w.js → cli-jqabndfd.js} +1 -1
- package/dist/{cli-hcwdz9sd.js → cli-nec99rtj.js} +4 -1
- package/dist/cli.js +18 -49
- package/dist/{doctor-yy9bj65b.js → doctor-k6ej31sr.js} +3 -3
- package/dist/{harness-github-actions-ngy90m19.js → harness-github-actions-bhkr14q4.js} +2 -2
- package/dist/{harness-cpajrhyc.js → harness-pjxdvqk7.js} +2 -4
- package/dist/{index-an75v9ep.js → index-kmvy4nh6.js} +3 -3
- package/dist/{index-eb711ctt.js → index-sy1p2vp7.js} +2 -2
- package/dist/{index-z8dtmg06.js → index-xedkdchx.js} +148 -987
- package/dist/{prompt-attribution-9cr331df.js → prompt-attribution-94cgcj50.js} +2 -2
- package/dist/prompt-source-mcp.js +2 -2
- package/dist/{prompts-ybk6gc7y.js → prompts-yssnakd8.js} +1 -1
- package/dist/{rules-qddx5t0j.js → rules-jchrsc39.js} +6 -2
- package/dist/{skills-bundled-tcxpw88n.js → skills-bundled-4wkxnba0.js} +2 -2
- package/dist/{skills-4bbd6shr.js → skills-qfmm05ma.js} +1 -1
- package/dist/{sync-sjc0av1q.js → sync-by1sp44e.js} +4 -4
- package/package.json +1 -1
- package/skills/integration/index.json +2 -2
- package/skills/moda-cli/references/auth.md +1 -1
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
selectTenantAndCreateKey
|
|
3
3
|
} from "./cli-wkg8bwhs.js";
|
|
4
|
-
import {
|
|
5
|
-
agentsMdProblem,
|
|
6
|
-
runSkillSync
|
|
7
|
-
} from "./cli-6hwyagze.js";
|
|
8
4
|
import"./cli-d7039574.js";
|
|
9
5
|
import {
|
|
10
6
|
buildDoctorReport
|
|
11
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-fv22sck1.js";
|
|
12
8
|
import {
|
|
13
9
|
ConnectCodeError,
|
|
14
10
|
connectWithCode,
|
|
@@ -16,38 +12,30 @@ import {
|
|
|
16
12
|
loadToken,
|
|
17
13
|
login
|
|
18
14
|
} from "./cli-4fv2pthb.js";
|
|
19
|
-
import
|
|
20
|
-
initPrompts,
|
|
21
|
-
runPromptSync
|
|
22
|
-
} from "./cli-zh32cntw.js";
|
|
15
|
+
import"./cli-fc1rx0gw.js";
|
|
23
16
|
import {
|
|
24
17
|
bundledSkillsDir,
|
|
25
18
|
installIntegrationSkill,
|
|
26
19
|
readBundledIndex
|
|
27
|
-
} from "./cli-
|
|
20
|
+
} from "./cli-jqabndfd.js";
|
|
28
21
|
import"./cli-2fv0q9tx.js";
|
|
29
22
|
import {
|
|
30
23
|
detectAgents
|
|
31
24
|
} from "./cli-rjav0vj1.js";
|
|
32
25
|
import {
|
|
26
|
+
INSTALL_RECORD_PATH,
|
|
33
27
|
installRules,
|
|
28
|
+
skillInstallDirs,
|
|
34
29
|
summarizeInstall
|
|
35
|
-
} from "./cli-
|
|
30
|
+
} from "./cli-nec99rtj.js";
|
|
36
31
|
import"./cli-mm48br00.js";
|
|
37
32
|
import"./cli-764m5azg.js";
|
|
38
33
|
import {
|
|
39
34
|
codingAgentDisplayName,
|
|
40
35
|
describeCodingAgentEvent,
|
|
41
|
-
describeSyncIdentity,
|
|
42
|
-
describeSyncTenantLabel,
|
|
43
36
|
detectAvailableCodingAgents,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
pollRemoteAnalyzeUntilDone,
|
|
47
|
-
runCodingAgent,
|
|
48
|
-
runHarnessCommand,
|
|
49
|
-
startRemoteAnalyze
|
|
50
|
-
} from "./cli-8800mp37.js";
|
|
37
|
+
runCodingAgent
|
|
38
|
+
} from "./cli-117eqfj5.js";
|
|
51
39
|
import {
|
|
52
40
|
canonicalText,
|
|
53
41
|
renderInitBanner,
|
|
@@ -55,7 +43,7 @@ import {
|
|
|
55
43
|
renderInitNote,
|
|
56
44
|
renderInitSetupPlan,
|
|
57
45
|
renderInitStep
|
|
58
|
-
} from "./cli-
|
|
46
|
+
} from "./cli-jkv3y2bj.js";
|
|
59
47
|
import {
|
|
60
48
|
stripAnsi
|
|
61
49
|
} from "./cli-97fnztpy.js";
|
|
@@ -67,7 +55,6 @@ import"./cli-5vv062qj.js";
|
|
|
67
55
|
import"./cli-e0kbye4s.js";
|
|
68
56
|
import"./cli-6m24mgfn.js";
|
|
69
57
|
import {
|
|
70
|
-
VERSION,
|
|
71
58
|
recordApiRequest,
|
|
72
59
|
resolveIngestUrl,
|
|
73
60
|
resolveModaBaseUrl,
|
|
@@ -83,12 +70,10 @@ import"./cli-0semcakc.js";
|
|
|
83
70
|
import"./cli-0v6na3yp.js";
|
|
84
71
|
|
|
85
72
|
// src/init/index.ts
|
|
86
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
87
|
-
import { dirname as dirname3, join as join5 } from "node:path";
|
|
88
73
|
import { checkbox, confirm, select } from "@inquirer/prompts";
|
|
89
74
|
|
|
90
75
|
// src/init/sdk-guide.ts
|
|
91
|
-
import {
|
|
76
|
+
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
92
77
|
import { dirname, join as join2 } from "node:path";
|
|
93
78
|
|
|
94
79
|
// src/init/sdk-catalog.ts
|
|
@@ -288,66 +273,15 @@ function renderSdkIntegrationGuideContent() {
|
|
|
288
273
|
].join(`
|
|
289
274
|
`);
|
|
290
275
|
}
|
|
291
|
-
function readRuntimeSummary(cwd) {
|
|
292
|
-
const empty = {
|
|
293
|
-
runtimeAgents: 0,
|
|
294
|
-
agentFamilies: 0,
|
|
295
|
-
frameworks: [],
|
|
296
|
-
providers: [],
|
|
297
|
-
runtimeAgentNames: []
|
|
298
|
-
};
|
|
299
|
-
const path = join2(cwd, ".moda", "harness.json");
|
|
300
|
-
if (!existsSync2(path))
|
|
301
|
-
return empty;
|
|
302
|
-
try {
|
|
303
|
-
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
304
|
-
if (!isRecord(parsed))
|
|
305
|
-
return empty;
|
|
306
|
-
const runtimeAgents = Array.isArray(parsed.runtimeAgents) ? parsed.runtimeAgents : [];
|
|
307
|
-
const agentFamilies = Array.isArray(parsed.agentFamilies) ? parsed.agentFamilies : [];
|
|
308
|
-
const frameworks = Array.isArray(parsed.agentFrameworks) ? parsed.agentFrameworks : [];
|
|
309
|
-
const providers = Array.isArray(parsed.modelProviders) ? parsed.modelProviders : [];
|
|
310
|
-
return {
|
|
311
|
-
runtimeAgents: runtimeAgents.length,
|
|
312
|
-
agentFamilies: agentFamilies.length,
|
|
313
|
-
runtimeAgentNames: runtimeAgents.map((agent) => isRecord(agent) && typeof agent.name === "string" ? agent.name : undefined).filter((name) => Boolean(name)),
|
|
314
|
-
frameworks: frameworks.map((framework) => isRecord(framework) && typeof framework.name === "string" ? framework.name : undefined).filter((name) => Boolean(name)),
|
|
315
|
-
providers: providers.map((provider) => isRecord(provider) && typeof provider.name === "string" ? provider.name : undefined).filter((name) => Boolean(name))
|
|
316
|
-
};
|
|
317
|
-
} catch {
|
|
318
|
-
return empty;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
function renderRuntimeSummaryBlock(summary) {
|
|
322
|
-
const runtimeNames = summary.runtimeAgentNames.slice(0, 8);
|
|
323
|
-
const lines = [
|
|
324
|
-
`- Runtime agents: ${summary.runtimeAgents}`,
|
|
325
|
-
`- Agent families: ${summary.agentFamilies}`
|
|
326
|
-
];
|
|
327
|
-
if (summary.frameworks.length > 0) {
|
|
328
|
-
lines.push(`- Frameworks: ${summary.frameworks.join(", ")}`);
|
|
329
|
-
}
|
|
330
|
-
if (summary.providers.length > 0) {
|
|
331
|
-
lines.push(`- Providers: ${summary.providers.join(", ")}`);
|
|
332
|
-
}
|
|
333
|
-
if (runtimeNames.length > 0) {
|
|
334
|
-
lines.push(`- Runtime agent names: ${runtimeNames.join(", ")}`);
|
|
335
|
-
}
|
|
336
|
-
return lines.join(`
|
|
337
|
-
`);
|
|
338
|
-
}
|
|
339
|
-
function isRecord(value) {
|
|
340
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
341
|
-
}
|
|
342
276
|
|
|
343
277
|
// src/init/sdk-integration.ts
|
|
344
278
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
345
279
|
import {
|
|
346
280
|
closeSync,
|
|
347
|
-
existsSync as
|
|
281
|
+
existsSync as existsSync3,
|
|
348
282
|
mkdirSync as mkdirSync3,
|
|
349
283
|
openSync,
|
|
350
|
-
readFileSync as
|
|
284
|
+
readFileSync as readFileSync2,
|
|
351
285
|
readSync,
|
|
352
286
|
readdirSync as readdirSync2,
|
|
353
287
|
rmSync as rmSync2,
|
|
@@ -358,7 +292,7 @@ import { dirname as dirname2, join as join4, relative as relative2, resolve as r
|
|
|
358
292
|
import { spawnSync } from "node:child_process";
|
|
359
293
|
|
|
360
294
|
// src/init/sdk-protocol.ts
|
|
361
|
-
import { existsSync as
|
|
295
|
+
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
362
296
|
import { join as join3 } from "node:path";
|
|
363
297
|
import { z } from "zod";
|
|
364
298
|
var SDK_RESULT_SCHEMA_VERSION = "moda.sdk_integration_result.v1";
|
|
@@ -452,9 +386,9 @@ var SdkAgentResultSchema = z.object({
|
|
|
452
386
|
function extractSdkAgentResult(opts) {
|
|
453
387
|
const diagnostics = [];
|
|
454
388
|
const resultPath = join3(opts.cwd, SDK_RESULT_FILE);
|
|
455
|
-
if (
|
|
389
|
+
if (existsSync2(resultPath)) {
|
|
456
390
|
try {
|
|
457
|
-
const parsed = parseCandidate(
|
|
391
|
+
const parsed = parseCandidate(readFileSync(resultPath, "utf8"));
|
|
458
392
|
if (parsed.result)
|
|
459
393
|
return { result: parsed.result, source: "file" };
|
|
460
394
|
diagnostics.push(`result file: ${parsed.detail}`);
|
|
@@ -584,10 +518,10 @@ function resolveTimeoutFromEnv() {
|
|
|
584
518
|
return Math.min(MAX_TIMEOUT_MS, Math.max(MIN_TIMEOUT_MS, Math.trunc(parsed)));
|
|
585
519
|
}
|
|
586
520
|
function readAuditCounts(value) {
|
|
587
|
-
if (!
|
|
521
|
+
if (!isRecord(value) || !isRecord(value.summary))
|
|
588
522
|
return;
|
|
589
523
|
const summary = value.summary;
|
|
590
|
-
if (!isNonNegativeNumber(summary.total_spans) || !
|
|
524
|
+
if (!isNonNegativeNumber(summary.total_spans) || !isRecord(summary.by_type))
|
|
591
525
|
return;
|
|
592
526
|
return {
|
|
593
527
|
total_spans: summary.total_spans,
|
|
@@ -599,25 +533,25 @@ function readAuditCounts(value) {
|
|
|
599
533
|
ingest_rows: isNonNegativeNumber(summary.ingest_rows) ? summary.ingest_rows : 0
|
|
600
534
|
};
|
|
601
535
|
}
|
|
602
|
-
function
|
|
536
|
+
function isRecord(value) {
|
|
603
537
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
604
538
|
}
|
|
605
539
|
function isNonNegativeNumber(value) {
|
|
606
540
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
607
541
|
}
|
|
608
542
|
function isAI7Audit(value) {
|
|
609
|
-
return
|
|
543
|
+
return isRecord(value) && Array.isArray(value.spans) && value.spans.some((span) => isRecord(span) && isRecord(span.attributes) && ["cloudflare-think", "vercel-ai7"].includes(String(span.attributes["moda.integration.name"])));
|
|
610
544
|
}
|
|
611
545
|
function hasUnexpectedAuditDuplicates(value) {
|
|
612
|
-
if (!
|
|
546
|
+
if (!isRecord(value) || !isRecord(value.summary))
|
|
613
547
|
return true;
|
|
614
548
|
if (value.summary.duplicate_count === 0 || value.summary.duplicate_count === undefined)
|
|
615
549
|
return false;
|
|
616
550
|
if (!isAI7Audit(value) || !Array.isArray(value.duplicates) || !Array.isArray(value.spans) || value.duplicates.length !== value.summary.duplicate_count)
|
|
617
551
|
return true;
|
|
618
|
-
const spans = value.spans.filter(
|
|
552
|
+
const spans = value.spans.filter(isRecord);
|
|
619
553
|
return value.duplicates.some((group) => {
|
|
620
|
-
if (!
|
|
554
|
+
if (!isRecord(group) || group.type !== "duplicate_operation" || !Array.isArray(group.span_ids) || group.span_ids.length < 2 || new Set(group.span_ids).size !== group.span_ids.length)
|
|
621
555
|
return true;
|
|
622
556
|
const calls = [];
|
|
623
557
|
for (const id of group.span_ids) {
|
|
@@ -625,9 +559,9 @@ function hasUnexpectedAuditDuplicates(value) {
|
|
|
625
559
|
if (matches.length !== 1)
|
|
626
560
|
return true;
|
|
627
561
|
const span = matches[0];
|
|
628
|
-
if (span.type !== "tool" || !
|
|
562
|
+
if (span.type !== "tool" || !isRecord(span.tool) || typeof span.tool.call_id !== "string" || !span.tool.call_id)
|
|
629
563
|
return true;
|
|
630
|
-
if (!
|
|
564
|
+
if (!isRecord(span.attributes) || !["cloudflare-think", "vercel-ai7"].includes(String(span.attributes["moda.integration.name"])))
|
|
631
565
|
return true;
|
|
632
566
|
calls.push(span.tool.call_id);
|
|
633
567
|
}
|
|
@@ -636,33 +570,33 @@ function hasUnexpectedAuditDuplicates(value) {
|
|
|
636
570
|
}
|
|
637
571
|
function promptHasSystemMessage(prompt) {
|
|
638
572
|
if (Array.isArray(prompt))
|
|
639
|
-
return prompt.some((message) =>
|
|
640
|
-
return
|
|
573
|
+
return prompt.some((message) => isRecord(message) && message.role === "system");
|
|
574
|
+
return isRecord(prompt) && prompt.reason === "row_payload_cap" && Array.isArray(prompt.roles) && prompt.roles.includes("system");
|
|
641
575
|
}
|
|
642
576
|
function completeAI7Projection(value) {
|
|
643
577
|
if (!isAI7Audit(value))
|
|
644
578
|
return true;
|
|
645
|
-
if (!
|
|
579
|
+
if (!isRecord(value) || !Array.isArray(value.spans) || value.parse_errors !== 0 || !isRecord(value.summary) || value.summary.truncated !== false)
|
|
646
580
|
return false;
|
|
647
|
-
const spans = value.spans.filter(
|
|
581
|
+
const spans = value.spans.filter(isRecord);
|
|
648
582
|
for (const span of spans.filter((span2) => span2.type === "llm")) {
|
|
649
|
-
if (
|
|
583
|
+
if (isRecord(span.attributes) && span.attributes["gen_ai.system_instructions"]) {
|
|
650
584
|
if (!promptHasSystemMessage(span.prompt))
|
|
651
585
|
return false;
|
|
652
586
|
}
|
|
653
587
|
}
|
|
654
588
|
const transcript = value.conversationContext;
|
|
655
|
-
if (!
|
|
589
|
+
if (!isRecord(transcript) || !isRecord(transcript.context) || !Array.isArray(transcript.context.messages))
|
|
656
590
|
return false;
|
|
657
591
|
if (transcript.total_messages !== transcript.context.messages.length)
|
|
658
592
|
return false;
|
|
659
|
-
const expected = spans.filter((span) => span.type === "tool").map((span) =>
|
|
593
|
+
const expected = spans.filter((span) => span.type === "tool").map((span) => isRecord(span.tool) ? span.tool.call_id : undefined);
|
|
660
594
|
const actual = [];
|
|
661
595
|
for (const message of transcript.context.messages) {
|
|
662
|
-
if (!
|
|
596
|
+
if (!isRecord(message) || !Array.isArray(message.tool_calls))
|
|
663
597
|
return false;
|
|
664
598
|
for (const tool of message.tool_calls)
|
|
665
|
-
actual.push(
|
|
599
|
+
actual.push(isRecord(tool) ? tool.id : undefined);
|
|
666
600
|
}
|
|
667
601
|
return expected.every((id) => typeof id === "string") && actual.every((id) => typeof id === "string") && new Set(actual).size === actual.length && expected.length === actual.length && expected.every((id) => actual.includes(id));
|
|
668
602
|
}
|
|
@@ -679,7 +613,7 @@ async function fetchAuditWithApiKey(id, apiKey, baseUrl) {
|
|
|
679
613
|
throw new Error(`Audit fetch failed (${response.status}): ${body.slice(0, 200)}`);
|
|
680
614
|
}
|
|
681
615
|
const audit = JSON.parse(body);
|
|
682
|
-
if (isAI7Audit(audit) &&
|
|
616
|
+
if (isAI7Audit(audit) && isRecord(audit)) {
|
|
683
617
|
recordApiRequest();
|
|
684
618
|
const contextResponse = await fetch(`${baseUrl}/api/v1/data/conversations/${encodeURIComponent(id)}/context?window=20`, {
|
|
685
619
|
headers: { "x-api-key": apiKey },
|
|
@@ -785,13 +719,11 @@ async function runSdkIntegration(options = {}) {
|
|
|
785
719
|
classification: lastOutcome.repairable ?? "telemetry_not_observed",
|
|
786
720
|
previousResult: lastAgentResult,
|
|
787
721
|
verification: lastVerification,
|
|
788
|
-
securityFindings: lastSecurityFindings
|
|
789
|
-
harnessSummary: readRuntimeSummary(cwd)
|
|
722
|
+
securityFindings: lastSecurityFindings
|
|
790
723
|
}) : renderSdkIntegrationPrompt({
|
|
791
724
|
catalogDir: catalog.relativeDir,
|
|
792
725
|
catalogListing: renderCatalogListing(catalog.index),
|
|
793
|
-
verificationId
|
|
794
|
-
harnessSummary: readRuntimeSummary(cwd)
|
|
726
|
+
verificationId
|
|
795
727
|
});
|
|
796
728
|
const run = await invokeAgent(attemptCtx, prompt);
|
|
797
729
|
const extraction = await extractResultWithProtocolRetry(attemptCtx, run, protocolRetryUsed, () => {
|
|
@@ -861,13 +793,6 @@ async function runSdkIntegration(options = {}) {
|
|
|
861
793
|
}
|
|
862
794
|
}
|
|
863
795
|
function renderSdkIntegrationPrompt(opts) {
|
|
864
|
-
const summary = opts.harnessSummary;
|
|
865
|
-
const hasHarnessSignals = Boolean(summary && (summary.runtimeAgents > 0 || summary.frameworks.length > 0 || summary.providers.length > 0));
|
|
866
|
-
const harnessBlock = summary && hasHarnessSignals ? [
|
|
867
|
-
"Context from Moda's earlier harness discovery (may be incomplete):",
|
|
868
|
-
renderRuntimeSummaryBlock(summary),
|
|
869
|
-
""
|
|
870
|
-
] : [];
|
|
871
796
|
return [
|
|
872
797
|
canonicalText("init_prompt_line"),
|
|
873
798
|
"",
|
|
@@ -885,7 +810,6 @@ function renderSdkIntegrationPrompt(opts) {
|
|
|
885
810
|
" through the EXISTING integration with the provided verification id, then report",
|
|
886
811
|
" `nothing_to_integrate` with an honest summary and the `smoke` field set.",
|
|
887
812
|
"",
|
|
888
|
-
...harnessBlock,
|
|
889
813
|
"Skill catalog (read relevant skills; multiple may apply):",
|
|
890
814
|
opts.catalogListing,
|
|
891
815
|
"",
|
|
@@ -1106,7 +1030,7 @@ function scanForSecrets(cwd, paths, apiKey) {
|
|
|
1106
1030
|
const absPath = resolve2(cwd, relPath);
|
|
1107
1031
|
if (!absPath.startsWith(resolvedCwd + "/") && absPath !== resolvedCwd)
|
|
1108
1032
|
continue;
|
|
1109
|
-
if (!
|
|
1033
|
+
if (!existsSync3(absPath))
|
|
1110
1034
|
continue;
|
|
1111
1035
|
let stat;
|
|
1112
1036
|
try {
|
|
@@ -1118,7 +1042,7 @@ function scanForSecrets(cwd, paths, apiKey) {
|
|
|
1118
1042
|
continue;
|
|
1119
1043
|
let content;
|
|
1120
1044
|
try {
|
|
1121
|
-
content = stat.size > MAX_SCAN_FILE_BYTES ? readFilePrefix(absPath, MAX_SCAN_FILE_BYTES) :
|
|
1045
|
+
content = stat.size > MAX_SCAN_FILE_BYTES ? readFilePrefix(absPath, MAX_SCAN_FILE_BYTES) : readFileSync2(absPath, "utf8");
|
|
1122
1046
|
} catch {
|
|
1123
1047
|
continue;
|
|
1124
1048
|
}
|
|
@@ -1208,7 +1132,7 @@ function collectSecretScanFiles(cwd, paths) {
|
|
|
1208
1132
|
if (!isInsideRepo(absPath))
|
|
1209
1133
|
continue;
|
|
1210
1134
|
addEnvFiles(dirname2(absPath));
|
|
1211
|
-
if (!
|
|
1135
|
+
if (!existsSync3(absPath))
|
|
1212
1136
|
continue;
|
|
1213
1137
|
let stat;
|
|
1214
1138
|
try {
|
|
@@ -1299,7 +1223,7 @@ function renderProtocolRetryPrompt(catalogDir) {
|
|
|
1299
1223
|
function removeAgentResultFile(cwd) {
|
|
1300
1224
|
const path = join4(cwd, SDK_RESULT_FILE);
|
|
1301
1225
|
try {
|
|
1302
|
-
if (
|
|
1226
|
+
if (existsSync3(path))
|
|
1303
1227
|
rmSync2(path);
|
|
1304
1228
|
} catch {}
|
|
1305
1229
|
}
|
|
@@ -1562,13 +1486,11 @@ class InitProgressBoard {
|
|
|
1562
1486
|
}
|
|
1563
1487
|
finish(id, status, note) {
|
|
1564
1488
|
const lane = this.lanesById.get(id);
|
|
1565
|
-
if (!lane || this.stopped)
|
|
1566
|
-
return;
|
|
1567
|
-
if (lane.status !== "running" && lane.status === status && lane.detail === note)
|
|
1489
|
+
if (!lane || this.stopped || lane.status !== "running")
|
|
1568
1490
|
return;
|
|
1569
1491
|
lane.status = status;
|
|
1570
1492
|
lane.detail = note;
|
|
1571
|
-
lane.finishedAt
|
|
1493
|
+
lane.finishedAt = this.now();
|
|
1572
1494
|
if (this.tty) {
|
|
1573
1495
|
this.render();
|
|
1574
1496
|
return;
|
|
@@ -1624,32 +1546,29 @@ function visibleLength(value) {
|
|
|
1624
1546
|
}
|
|
1625
1547
|
|
|
1626
1548
|
// src/init/index.ts
|
|
1627
|
-
var HARNESS_PULL_RECOVERY = "moda harness pull --sync";
|
|
1628
|
-
var HARNESS_SKIP_NEXT = {
|
|
1629
|
-
unavailable: "retry",
|
|
1630
|
-
lost: "pull",
|
|
1631
|
-
unfetched: "pull",
|
|
1632
|
-
failed: "retry"
|
|
1633
|
-
};
|
|
1634
|
-
var HARNESS_SKIP_DETAILS = {
|
|
1635
|
-
unavailable: "hosted analysis unavailable",
|
|
1636
|
-
lost: "lost track of the hosted run",
|
|
1637
|
-
unfetched: "could not fetch the finished run",
|
|
1638
|
-
failed: "hosted run failed"
|
|
1639
|
-
};
|
|
1640
|
-
var HARNESS_SKIP_PLAN = {
|
|
1641
|
-
unavailable: "unavailable",
|
|
1642
|
-
lost: "status unknown",
|
|
1643
|
-
unfetched: "finished but not fetched",
|
|
1644
|
-
failed: "failed"
|
|
1645
|
-
};
|
|
1646
|
-
var HARNESS_SKIP_EVENT = {
|
|
1647
|
-
unavailable: "unavailable",
|
|
1648
|
-
lost: "could not be followed",
|
|
1649
|
-
unfetched: "finished but could not be fetched",
|
|
1650
|
-
failed: "failed on Moda"
|
|
1651
|
-
};
|
|
1652
1549
|
var LANE_EVENT_THROTTLE_MS = 2000;
|
|
1550
|
+
var REMOVED_INIT_FLAGS = [
|
|
1551
|
+
"analyst",
|
|
1552
|
+
"analyst-model",
|
|
1553
|
+
"assist",
|
|
1554
|
+
"concern",
|
|
1555
|
+
"allow-no-agents",
|
|
1556
|
+
"remote",
|
|
1557
|
+
"no-remote",
|
|
1558
|
+
"local",
|
|
1559
|
+
"tui",
|
|
1560
|
+
"no-tui",
|
|
1561
|
+
"ci-cd",
|
|
1562
|
+
"ci",
|
|
1563
|
+
"no-ci-cd",
|
|
1564
|
+
"autosync",
|
|
1565
|
+
"auto-sync",
|
|
1566
|
+
"no-autosync",
|
|
1567
|
+
"no-auto-sync",
|
|
1568
|
+
"harness-rescan",
|
|
1569
|
+
"no-harness-rescan",
|
|
1570
|
+
"harness-rescan-paths"
|
|
1571
|
+
];
|
|
1653
1572
|
async function runInit(flags, options = {}) {
|
|
1654
1573
|
const explicitYes = flags.yes === true || flags.yes === "true" || flags.y === true || flags.y === "true";
|
|
1655
1574
|
const json = flags.json === true || flags.json === "true";
|
|
@@ -1680,7 +1599,12 @@ async function runInit(flags, options = {}) {
|
|
|
1680
1599
|
emit(phase, message);
|
|
1681
1600
|
};
|
|
1682
1601
|
log(renderInitBanner());
|
|
1683
|
-
|
|
1602
|
+
const ignoredFlagsWarning = removedFlagsWarning(flags);
|
|
1603
|
+
if (ignoredFlagsWarning) {
|
|
1604
|
+
warn(renderInitNote(ignoredFlagsWarning, "warning"));
|
|
1605
|
+
emit("welcome", ignoredFlagsWarning, "warning");
|
|
1606
|
+
}
|
|
1607
|
+
emit("welcome", "Setting up Moda in this project.", "completed");
|
|
1684
1608
|
phases.push({ id: "welcome", title: "Welcome", status: "completed" });
|
|
1685
1609
|
const profile = stringFlag(flags.profile);
|
|
1686
1610
|
log(renderInitStep(1, 5, "Sign in", "No environment variable files are written. File changes are listed before completion."));
|
|
@@ -1750,7 +1674,7 @@ async function runInit(flags, options = {}) {
|
|
|
1750
1674
|
throw new CliInputError(`Invalid --verification-id ${JSON.stringify(verificationId).slice(0, 80)}`, "Pass the onb_ id shown in the Moda onboarding page, or omit the flag.");
|
|
1751
1675
|
}
|
|
1752
1676
|
const tenantIdEnv = stringFlag(process.env.MODA_TENANT_ID);
|
|
1753
|
-
const { apiKey,
|
|
1677
|
+
const { apiKey, tenantName } = await selectTenantAndCreateKey({
|
|
1754
1678
|
tenantId: tenantIdFlag ?? codeTenantId ?? tenantIdEnv,
|
|
1755
1679
|
tenantIdSource: tenantIdFlag || codeTenantId ? "flag" : tenantIdEnv ? "env" : undefined,
|
|
1756
1680
|
nonInteractive: json || agent || noPrompts,
|
|
@@ -1762,35 +1686,31 @@ async function runInit(flags, options = {}) {
|
|
|
1762
1686
|
emit("workspace", `Active workspace: ${tenantName}`, "completed");
|
|
1763
1687
|
phases.push({ id: "workspace", title: "Workspace", status: "completed", details: tenantName });
|
|
1764
1688
|
log(renderInitStep(3, 5, "Plan", "One confirmation covers everything below; setup then runs unattended."));
|
|
1765
|
-
let remote = resolveHarnessRemote(flags);
|
|
1766
|
-
const remotePinned = hasExplicitRemoteChoice(flags);
|
|
1767
1689
|
const sdkFlag = resolveSdkIntegrateFlag(flags);
|
|
1768
|
-
const
|
|
1769
|
-
const autosyncFlag = resolveAutosyncFlag(flags);
|
|
1770
|
-
const harnessRescanFlag = resolveHarnessRescanFlag(flags);
|
|
1771
|
-
const harnessRescanPaths = parseHarnessRescanPaths(flagValue(flags, "harness-rescan-paths", "harness_rescan_paths"));
|
|
1772
|
-
const harnessRescanChoice = harnessRescanFlag ?? (harnessRescanPaths !== undefined ? true : undefined);
|
|
1690
|
+
const agentSkillFlag = resolveAgentSkillFlag(flags);
|
|
1773
1691
|
const codingAgentAvailable = detectAvailableCodingAgents().length > 0;
|
|
1774
1692
|
let integrateSdk = sdkFlag !== undefined ? sdkFlag : yes ? false : codingAgentAvailable;
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
let
|
|
1693
|
+
const agents = detectAgents();
|
|
1694
|
+
const agentSkillDirs = skillInstallDirs(agents);
|
|
1695
|
+
let installAgentSkill = agentSkillFlag ?? true;
|
|
1696
|
+
const offlineValidation = isTruthyFlag(flagValue(flags, "offline"));
|
|
1778
1697
|
let setupPlan = [];
|
|
1779
1698
|
const renderPlan = () => {
|
|
1780
|
-
setupPlan = buildSetupPlan({
|
|
1781
|
-
|
|
1782
|
-
configureCiCd,
|
|
1783
|
-
configureAutosync,
|
|
1784
|
-
configureHarnessRescan,
|
|
1785
|
-
remote
|
|
1786
|
-
});
|
|
1787
|
-
log(renderInitSetupPlan(setupPlan, { snapshotConsent: remote }));
|
|
1699
|
+
setupPlan = buildSetupPlan({ installAgentSkill, agentSkillDirs, integrateSdk, offlineValidation });
|
|
1700
|
+
log(renderInitSetupPlan(setupPlan, { notes: planNotes(tenantName, integrateSdk) }));
|
|
1788
1701
|
};
|
|
1789
1702
|
renderPlan();
|
|
1790
1703
|
if (!yes) {
|
|
1791
1704
|
const proceed = await confirm({ message: "Proceed with this plan?", default: true });
|
|
1792
1705
|
if (!proceed) {
|
|
1793
1706
|
const choices = [];
|
|
1707
|
+
if (agentSkillFlag === undefined && agentSkillDirs.length > 0) {
|
|
1708
|
+
choices.push({
|
|
1709
|
+
name: `Install the moda-cli skill into your coding agents (${agentSkillDirs.join(", ")})`,
|
|
1710
|
+
value: "agent-skill",
|
|
1711
|
+
checked: installAgentSkill
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1794
1714
|
if (sdkFlag === undefined) {
|
|
1795
1715
|
choices.push({
|
|
1796
1716
|
name: "SDK integration via your coding agent (installs packages, edits source)",
|
|
@@ -1798,254 +1718,45 @@ async function runInit(flags, options = {}) {
|
|
|
1798
1718
|
checked: integrateSdk
|
|
1799
1719
|
});
|
|
1800
1720
|
}
|
|
1801
|
-
if (!remotePinned) {
|
|
1802
|
-
choices.push({
|
|
1803
|
-
name: "Harness analysis on Moda's servers (uncheck to run a local coding agent analyst)",
|
|
1804
|
-
value: "remote",
|
|
1805
|
-
checked: remote
|
|
1806
|
-
});
|
|
1807
|
-
}
|
|
1808
|
-
if (ciCdFlag === undefined) {
|
|
1809
|
-
choices.push({
|
|
1810
|
-
name: "CI/CD validation workflow (.github/workflows/moda-validation.yml)",
|
|
1811
|
-
value: "ci-cd",
|
|
1812
|
-
checked: configureCiCd
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
if (autosyncFlag === undefined) {
|
|
1816
|
-
choices.push({
|
|
1817
|
-
name: "Autosync prompts and skills on push to main (.github/workflows/moda-autosync.yml)",
|
|
1818
|
-
value: "autosync",
|
|
1819
|
-
checked: configureAutosync
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
if (harnessRescanChoice === undefined) {
|
|
1823
|
-
choices.push({
|
|
1824
|
-
name: "Re-scan the harness on push to main (.github/workflows/moda-harness-rescan.yml)",
|
|
1825
|
-
value: "harness-rescan",
|
|
1826
|
-
checked: configureHarnessRescan
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1829
1721
|
if (choices.length > 0) {
|
|
1830
1722
|
const selected = await checkbox({
|
|
1831
1723
|
message: "Choose what runs (space toggles, enter confirms)",
|
|
1832
1724
|
choices
|
|
1833
1725
|
});
|
|
1726
|
+
if (agentSkillFlag === undefined && agentSkillDirs.length > 0)
|
|
1727
|
+
installAgentSkill = selected.includes("agent-skill");
|
|
1834
1728
|
if (sdkFlag === undefined)
|
|
1835
1729
|
integrateSdk = selected.includes("sdk");
|
|
1836
|
-
if (!remotePinned)
|
|
1837
|
-
remote = selected.includes("remote");
|
|
1838
|
-
if (ciCdFlag === undefined)
|
|
1839
|
-
configureCiCd = selected.includes("ci-cd");
|
|
1840
|
-
if (autosyncFlag === undefined)
|
|
1841
|
-
configureAutosync = selected.includes("autosync");
|
|
1842
|
-
if (harnessRescanChoice === undefined)
|
|
1843
|
-
configureHarnessRescan = selected.includes("harness-rescan");
|
|
1844
1730
|
renderPlan();
|
|
1845
1731
|
}
|
|
1846
1732
|
}
|
|
1847
1733
|
}
|
|
1848
1734
|
if (json || agent) {
|
|
1849
|
-
const skipped = setupPlan.filter((action) =>
|
|
1735
|
+
const skipped = setupPlan.filter((action) => action.category === "sdk" && action.approved === false).map((action) => `${action.category}: ${action.command ?? "explicit flag required"}`);
|
|
1850
1736
|
if (skipped.length > 0) {
|
|
1851
1737
|
emit("plan", `Non-interactive init skipped optional actions (${skipped.join("; ")}).`, "warning");
|
|
1852
1738
|
}
|
|
1853
1739
|
}
|
|
1854
|
-
emit("plan",
|
|
1740
|
+
emit("plan", `Setup plan ready. ${planNotes(tenantName, integrateSdk).join(" ")}`, "completed");
|
|
1855
1741
|
phases.push({ id: "plan", title: "Plan", status: "completed" });
|
|
1856
|
-
log(renderInitStep(4, 5, "Set up",
|
|
1742
|
+
log(renderInitStep(4, 5, "Set up", "Runs unattended. No further input is needed."));
|
|
1857
1743
|
const rootDir = process.cwd();
|
|
1858
|
-
const allowLocalFallback = !isTruthyFlag(flagValue(flags, "remote"));
|
|
1859
|
-
const launchLocalAnalyst = human && !noPrompts || stringFlag(flags.analyst) !== undefined;
|
|
1860
|
-
const HARNESS_RETRY = "moda harness analyze --remote --summary --experimental";
|
|
1861
|
-
const nestedHarnessFlags = (extra) => commandFlags({
|
|
1862
|
-
summary: true,
|
|
1863
|
-
yes: true,
|
|
1864
|
-
experimental: true,
|
|
1865
|
-
json: json || agent,
|
|
1866
|
-
agent,
|
|
1867
|
-
quiet: true,
|
|
1868
|
-
"no-telemetry": true,
|
|
1869
|
-
profile,
|
|
1870
|
-
...extra
|
|
1871
|
-
});
|
|
1872
|
-
const runAnalyze = (useRemote) => runHarnessCommand(createCommandContext({
|
|
1873
|
-
command: "harness",
|
|
1874
|
-
positional: "analyze",
|
|
1875
|
-
positionals: ["analyze"],
|
|
1876
|
-
flags: nestedHarnessFlags({
|
|
1877
|
-
analyst: stringFlag(flags.analyst) ?? "auto",
|
|
1878
|
-
remote: useRemote ? true : undefined,
|
|
1879
|
-
"no-remote": useRemote ? undefined : true,
|
|
1880
|
-
progress: true
|
|
1881
|
-
})
|
|
1882
|
-
}));
|
|
1883
|
-
let board;
|
|
1884
|
-
const startBoard = () => {
|
|
1885
|
-
if (!human)
|
|
1886
|
-
return;
|
|
1887
|
-
board ??= new InitProgressBoard;
|
|
1888
|
-
return board;
|
|
1889
|
-
};
|
|
1890
|
-
const validationFailure = () => new CliInputError("Moda Analyst produced a harness report that did not pass validation.", "Review .moda/harness-report-validation.json, then rerun `moda init --local --analyst=claude|cursor|codex` or `moda harness analyze --analyst=local-scan --summary --experimental`.");
|
|
1891
|
-
let harnessPhase = { id: "harness", title: "Harness discovery", status: "completed" };
|
|
1892
|
-
let harnessDeferred = false;
|
|
1893
|
-
let harnessSkipped = false;
|
|
1894
|
-
let harnessSkip = "unavailable";
|
|
1895
|
-
const skipHarness = (error, kind = "unavailable") => {
|
|
1896
|
-
harnessSkipped = true;
|
|
1897
|
-
harnessDeferred = true;
|
|
1898
|
-
harnessSkip = kind;
|
|
1899
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
1900
|
-
const next = HARNESS_SKIP_NEXT[kind] === "pull" ? HARNESS_PULL_RECOVERY : HARNESS_RETRY;
|
|
1901
|
-
harnessPhase = {
|
|
1902
|
-
id: "harness",
|
|
1903
|
-
title: "Harness discovery",
|
|
1904
|
-
status: "warning",
|
|
1905
|
-
details: `skipped: ${HARNESS_SKIP_DETAILS[kind]}`
|
|
1906
|
-
};
|
|
1907
|
-
markApplied(setupPlan, "harness", `Hosted analysis ${HARNESS_SKIP_PLAN[kind]}; run \`${next}\` later.`);
|
|
1908
|
-
emit("harness", `Hosted harness discovery ${HARNESS_SKIP_EVENT[kind]} (${reason}); skipped. Continue with \`${next}\`.`, "warning");
|
|
1909
|
-
};
|
|
1910
|
-
const approveAndSyncHarness = async () => {
|
|
1911
|
-
const graphSignals = readHarnessQualitySignals(rootDir);
|
|
1912
|
-
const repoSignals = detectRepoLlmSignals(rootDir);
|
|
1913
|
-
const signals = graphSignals ? {
|
|
1914
|
-
runtimeAgents: graphSignals.runtimeAgents,
|
|
1915
|
-
frameworks: [...new Set([...graphSignals.frameworks, ...repoSignals.frameworks])],
|
|
1916
|
-
providers: [...new Set([...graphSignals.providers, ...repoSignals.providers])]
|
|
1917
|
-
} : undefined;
|
|
1918
|
-
if (signals && harnessLooksIncomplete(signals)) {
|
|
1919
|
-
const names = [...signals.frameworks, ...signals.providers].join(", ");
|
|
1920
|
-
const retryCommand = remote ? "moda harness analyze --remote --summary --experimental" : "moda harness analyze --analyst=claude|cursor|codex --summary --experimental";
|
|
1921
|
-
warn(renderInitNote(`Harness discovery found 0 runtime agents, but this repo has LLM framework signals (${names}). ` + "Discovery likely failed, so the result was NOT approved or synced.", "warning"));
|
|
1922
|
-
warn(` Retry with \`${retryCommand}\`, then \`moda harness approve --yes && moda harness sync --from-report\`.`);
|
|
1923
|
-
emit("harness", "Harness discovery found 0 agents despite LLM framework signals; sync withheld.", "warning");
|
|
1924
|
-
harnessPhase = {
|
|
1925
|
-
id: "harness",
|
|
1926
|
-
title: "Harness discovery",
|
|
1927
|
-
status: "warning",
|
|
1928
|
-
details: "0 agents detected; sync withheld"
|
|
1929
|
-
};
|
|
1930
|
-
return;
|
|
1931
|
-
}
|
|
1932
|
-
try {
|
|
1933
|
-
const identity = describeSyncIdentity({ profile, env: process.env });
|
|
1934
|
-
if (identity) {
|
|
1935
|
-
const tenantLabel = identity.tenantSource === "api-key" && identity.tenantId ? `${identity.tenantId}${identity.tenantId === selectedTenantId ? ` (${tenantName})` : ""}` : describeSyncTenantLabel(identity);
|
|
1936
|
-
log(renderInitNote(`Syncing as ${identity.credential} → tenant ${tenantLabel}`, "info"));
|
|
1937
|
-
}
|
|
1938
|
-
} catch {}
|
|
1939
|
-
try {
|
|
1940
|
-
await runHarnessCommand(createCommandContext({
|
|
1941
|
-
command: "harness",
|
|
1942
|
-
positional: "approve",
|
|
1943
|
-
positionals: ["approve"],
|
|
1944
|
-
flags: nestedHarnessFlags({})
|
|
1945
|
-
}));
|
|
1946
|
-
await runHarnessCommand(createCommandContext({
|
|
1947
|
-
command: "harness",
|
|
1948
|
-
positional: "sync",
|
|
1949
|
-
positionals: ["sync"],
|
|
1950
|
-
flags: nestedHarnessFlags({ "from-report": true })
|
|
1951
|
-
}));
|
|
1952
|
-
log(renderInitNote("Synced harness graph to Moda"));
|
|
1953
|
-
emit("harness", "Harness graph synced to Moda.", "completed");
|
|
1954
|
-
} catch (err) {
|
|
1955
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
1956
|
-
warn(renderInitNote(`Harness sync skipped: ${message}`, "warning"));
|
|
1957
|
-
warn(" Run `moda harness approve --yes && moda harness sync --from-report` later to upload.");
|
|
1958
|
-
emit("harness", "Harness sync skipped.", "warning");
|
|
1959
|
-
harnessPhase = { id: "harness", title: "Harness discovery", status: "warning", details: "sync skipped" };
|
|
1960
|
-
}
|
|
1961
|
-
};
|
|
1962
|
-
const finishLocalAnalyze = async () => {
|
|
1963
|
-
emit("harness", "Running Moda Analyst harness discovery.");
|
|
1964
|
-
const result = await runAnalyze(false);
|
|
1965
|
-
if (result.exitCode !== 0)
|
|
1966
|
-
throw validationFailure();
|
|
1967
|
-
log(renderInitNote("Wrote or verified .moda/harness-report.json, .moda/harness.json, and .moda/HARNESS.md"));
|
|
1968
|
-
if (human)
|
|
1969
|
-
printHarnessDetectionSummary();
|
|
1970
|
-
emit("harness", "Harness discovery complete.", "completed");
|
|
1971
|
-
await approveAndSyncHarness();
|
|
1972
|
-
};
|
|
1973
|
-
let pollPromise;
|
|
1974
|
-
let pollError;
|
|
1975
|
-
let remoteRunId;
|
|
1976
|
-
const onRemoteSigint = () => {
|
|
1977
|
-
board?.stop();
|
|
1978
|
-
process.stderr.write(`
|
|
1979
|
-
Harness analysis keeps running on Moda. Resume anytime with \`${HARNESS_PULL_RECOVERY}\`.
|
|
1980
|
-
`);
|
|
1981
|
-
process.exit(130);
|
|
1982
|
-
};
|
|
1983
|
-
if (remote) {
|
|
1984
|
-
emit("harness", "Running Moda-hosted harness discovery.");
|
|
1985
|
-
try {
|
|
1986
|
-
const harnessContext = createCommandContext({
|
|
1987
|
-
command: "harness",
|
|
1988
|
-
positional: "analyze",
|
|
1989
|
-
positionals: ["analyze"],
|
|
1990
|
-
flags: nestedHarnessFlags({
|
|
1991
|
-
analyst: stringFlag(flags.analyst) ?? "auto",
|
|
1992
|
-
remote: true
|
|
1993
|
-
})
|
|
1994
|
-
});
|
|
1995
|
-
const started = await startRemoteAnalyze({ context: harnessContext, rootDir });
|
|
1996
|
-
remoteRunId = started.runId;
|
|
1997
|
-
process.once("SIGINT", onRemoteSigint);
|
|
1998
|
-
emit("harness", `Moda accepted harness analysis run ${started.runId}.`);
|
|
1999
|
-
startBoard()?.startLane("harness", "Harness analysis on Moda", {
|
|
2000
|
-
detail: "waiting for the hosted analyst",
|
|
2001
|
-
expectation: "usually 2-4 min"
|
|
2002
|
-
});
|
|
2003
|
-
pollPromise = pollRemoteAnalyzeUntilDone({
|
|
2004
|
-
context: harnessContext,
|
|
2005
|
-
runId: started.runId,
|
|
2006
|
-
onProgress: ({ status, progress }) => {
|
|
2007
|
-
if (status === "completed" || status === "failed") {
|
|
2008
|
-
if (status === "completed") {
|
|
2009
|
-
board?.complete("harness", "analysis finished on Moda; finalizing after setup");
|
|
2010
|
-
} else {
|
|
2011
|
-
board?.warn("harness", "hosted run finished with issues; finalizing after setup");
|
|
2012
|
-
}
|
|
2013
|
-
emitLaneProgress("harness", "harness", `Hosted analysis ${status}; finalizing after setup.`);
|
|
2014
|
-
return;
|
|
2015
|
-
}
|
|
2016
|
-
const message = progress?.message ?? (typeof progress?.tool_calls === "number" ? `${progress.tool_calls} tool call(s) so far` : `analysis ${status}`);
|
|
2017
|
-
board?.update("harness", message);
|
|
2018
|
-
emitLaneProgress("harness", "harness", message);
|
|
2019
|
-
}
|
|
2020
|
-
}).catch((error) => {
|
|
2021
|
-
pollError = error;
|
|
2022
|
-
return;
|
|
2023
|
-
});
|
|
2024
|
-
} catch (error) {
|
|
2025
|
-
if (!allowLocalFallback)
|
|
2026
|
-
throw error;
|
|
2027
|
-
remote = false;
|
|
2028
|
-
if (launchLocalAnalyst) {
|
|
2029
|
-
warn(renderInitNote(`Server-side harness discovery unavailable (${error instanceof Error ? error.message : String(error)}); falling back to local analyst.`, "warning"));
|
|
2030
|
-
emit("harness", "Server-side discovery failed; falling back to local analyst.", "warning");
|
|
2031
|
-
} else {
|
|
2032
|
-
skipHarness(error);
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
if (!remote && !harnessSkipped) {
|
|
2037
|
-
await finishLocalAnalyze();
|
|
2038
|
-
}
|
|
2039
1744
|
emit("apply", "Applying approved setup changes.");
|
|
2040
|
-
const laneBoard =
|
|
1745
|
+
const laneBoard = human ? new InitProgressBoard : undefined;
|
|
2041
1746
|
const setupWarnings = [];
|
|
2042
1747
|
const addSetupWarning = (message) => {
|
|
2043
1748
|
setupWarnings.push(message);
|
|
2044
1749
|
emit("apply", message, "warning");
|
|
2045
1750
|
};
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2048
|
-
|
|
1751
|
+
const skillsAction = setupPlan.find((action) => action.category === "skills");
|
|
1752
|
+
let skillInstallResult;
|
|
1753
|
+
if (skillsAction?.approved === true) {
|
|
1754
|
+
laneBoard?.startLane("agent-skills", "Agent skills");
|
|
1755
|
+
skillInstallResult = await installRules(agents, { yes: true, silent: true });
|
|
1756
|
+
markApplied(setupPlan, "skills");
|
|
1757
|
+
} else {
|
|
1758
|
+
markApplied(setupPlan, "skills", skillsAction?.reason ?? "Skipped the moda-cli skill install.");
|
|
1759
|
+
}
|
|
2049
1760
|
const skillInstall = {
|
|
2050
1761
|
status: skillInstallResult?.status ?? "skipped",
|
|
2051
1762
|
agents: skillInstallResult?.agents ?? [],
|
|
@@ -2053,70 +1764,20 @@ Harness analysis keeps running on Moda. Resume anytime with \`${HARNESS_PULL_REC
|
|
|
2053
1764
|
warnings: skillInstallResult?.warnings ?? []
|
|
2054
1765
|
};
|
|
2055
1766
|
skillInstall.warnings.forEach(addSetupWarning);
|
|
2056
|
-
if (
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
const counts = skillInstallResult?.counts;
|
|
2062
|
-
const nothingInstalled = counts !== undefined && counts.written + counts.updated + counts.current === 0;
|
|
2063
|
-
const note = `moda-cli skill: ${skillInstall.summary}; ${skillInstall.warnings.length} warning(s), details below`;
|
|
2064
|
-
if (skillInstall.status === "failed" && nothingInstalled)
|
|
2065
|
-
laneBoard?.fail("agent-skills", note);
|
|
2066
|
-
else
|
|
2067
|
-
laneBoard?.warn("agent-skills", note);
|
|
2068
|
-
}
|
|
2069
|
-
await initPrompts({ silent: true });
|
|
2070
|
-
let promptSyncOutcome;
|
|
2071
|
-
let skillSyncOutcome;
|
|
2072
|
-
laneBoard?.startLane("prompts", "Prompts", { detail: "Created or verified .moda/prompts.yml" });
|
|
2073
|
-
try {
|
|
2074
|
-
const promptSync = await runPromptSync({}, { profile });
|
|
2075
|
-
promptSyncOutcome = { status: "ok", synced: promptSync.synced.map((prompt) => prompt.key) };
|
|
2076
|
-
laneBoard?.complete("prompts", promptSync.synced.length > 0 ? `${promptSync.synced.length} prompt(s) synced` : "manifest ready (no prompt files to sync yet)");
|
|
2077
|
-
} catch (err) {
|
|
2078
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2079
|
-
promptSyncOutcome = { status: "failed", synced: [], error: message };
|
|
2080
|
-
laneBoard?.warn("prompts", `sync skipped: ${message}`);
|
|
2081
|
-
}
|
|
2082
|
-
laneBoard?.startLane("skills", "Skills");
|
|
2083
|
-
try {
|
|
2084
|
-
const skillSync = await runSkillSync({}, { profile });
|
|
2085
|
-
const agentsMdWarning = agentsMdProblem(skillSync.agentsMd);
|
|
2086
|
-
skillSyncOutcome = {
|
|
2087
|
-
status: "ok",
|
|
2088
|
-
synced: skillSync.synced.map((skill) => skill.key),
|
|
2089
|
-
...agentsMdWarning ? { warnings: [agentsMdWarning] } : {}
|
|
2090
|
-
};
|
|
2091
|
-
const syncedNote = skillSync.synced.length > 0 ? `${skillSync.synced.length} skill(s) synced` : "no local skills to sync yet";
|
|
2092
|
-
if (agentsMdWarning) {
|
|
2093
|
-
addSetupWarning(agentsMdWarning);
|
|
2094
|
-
laneBoard?.warn("skills", `${syncedNote}; AGENTS.md block not updated, details below`);
|
|
1767
|
+
if (skillInstallResult) {
|
|
1768
|
+
if (skillInstall.agents.length === 0) {
|
|
1769
|
+
laneBoard?.complete("agent-skills", "no supported coding agents detected");
|
|
1770
|
+
} else if (skillInstall.status === "ok") {
|
|
1771
|
+
laneBoard?.complete("agent-skills", `moda-cli skill installed for ${skillInstall.agents.join(", ")}`);
|
|
2095
1772
|
} else {
|
|
2096
|
-
|
|
1773
|
+
const counts = skillInstallResult.counts;
|
|
1774
|
+
const nothingInstalled = counts.written + counts.updated + counts.current === 0;
|
|
1775
|
+
const note = `moda-cli skill: ${skillInstall.summary}; ${skillInstall.warnings.length} warning(s), details below`;
|
|
1776
|
+
if (skillInstall.status === "failed" && nothingInstalled)
|
|
1777
|
+
laneBoard?.fail("agent-skills", note);
|
|
1778
|
+
else
|
|
1779
|
+
laneBoard?.warn("agent-skills", note);
|
|
2097
1780
|
}
|
|
2098
|
-
} catch (err) {
|
|
2099
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2100
|
-
skillSyncOutcome = { status: "failed", synced: [], error: message };
|
|
2101
|
-
laneBoard?.warn("skills", `sync skipped: ${message}`);
|
|
2102
|
-
}
|
|
2103
|
-
if (setupPlan.find((action) => action.category === "ci-cd")?.approved === true) {
|
|
2104
|
-
const workflowPath = writeCiCdWorkflow();
|
|
2105
|
-
laneBoard?.startLane("ci-cd", "CI/CD workflow");
|
|
2106
|
-
laneBoard?.complete("ci-cd", `wrote ${workflowPath}`);
|
|
2107
|
-
markApplied(setupPlan, "ci-cd");
|
|
2108
|
-
}
|
|
2109
|
-
if (setupPlan.find((action) => action.category === "autosync")?.approved === true) {
|
|
2110
|
-
const workflowPath = writeAutosyncWorkflow();
|
|
2111
|
-
laneBoard?.startLane("autosync", "Autosync workflow");
|
|
2112
|
-
laneBoard?.complete("autosync", `wrote ${workflowPath}`);
|
|
2113
|
-
markApplied(setupPlan, "autosync");
|
|
2114
|
-
}
|
|
2115
|
-
if (setupPlan.find((action) => action.category === "harness-rescan")?.approved === true) {
|
|
2116
|
-
const workflowPath = writeHarnessRescanWorkflow(process.cwd(), harnessRescanPaths);
|
|
2117
|
-
laneBoard?.startLane("harness-rescan", "Harness rescan workflow");
|
|
2118
|
-
laneBoard?.complete("harness-rescan", `wrote ${workflowPath}`);
|
|
2119
|
-
markApplied(setupPlan, "harness-rescan");
|
|
2120
1781
|
}
|
|
2121
1782
|
const sdkAction = setupPlan.find((action) => action.category === "sdk");
|
|
2122
1783
|
let sdkIntegration;
|
|
@@ -2149,72 +1810,11 @@ Harness analysis keeps running on Moda. Resume anytime with \`${HARNESS_PULL_REC
|
|
|
2149
1810
|
} else {
|
|
2150
1811
|
markApplied(setupPlan, "sdk", "User skipped SDK integration.");
|
|
2151
1812
|
}
|
|
2152
|
-
|
|
2153
|
-
markApplied(setupPlan, "skills");
|
|
2154
|
-
if (remote && pollPromise && remoteRunId) {
|
|
2155
|
-
const final = await pollPromise;
|
|
2156
|
-
process.removeListener("SIGINT", onRemoteSigint);
|
|
2157
|
-
const fallBackToLocal = async (error, kind) => {
|
|
2158
|
-
board?.fail("harness", "hosted analysis failed");
|
|
2159
|
-
board?.stop();
|
|
2160
|
-
if (!allowLocalFallback)
|
|
2161
|
-
throw error;
|
|
2162
|
-
if (!launchLocalAnalyst) {
|
|
2163
|
-
skipHarness(error, kind);
|
|
2164
|
-
return;
|
|
2165
|
-
}
|
|
2166
|
-
warn(renderInitNote(`Server-side harness discovery failed (${error instanceof Error ? error.message : String(error)}); falling back to local analyst.`, "warning"));
|
|
2167
|
-
emit("harness", "Server-side discovery failed; falling back to local analyst.", "warning");
|
|
2168
|
-
await finishLocalAnalyze();
|
|
2169
|
-
};
|
|
2170
|
-
if (pollError !== undefined) {
|
|
2171
|
-
await fallBackToLocal(pollError, "lost");
|
|
2172
|
-
} else if (!final || final.status !== "completed" && final.status !== "failed") {
|
|
2173
|
-
harnessDeferred = true;
|
|
2174
|
-
harnessPhase = { id: "harness", title: "Harness discovery", status: "warning", details: "still running on Moda" };
|
|
2175
|
-
markApplied(setupPlan, "harness", `Analysis still running on Moda; run \`${HARNESS_PULL_RECOVERY}\` to fetch and sync it.`);
|
|
2176
|
-
board?.warn("harness", `still running on Moda; run \`${HARNESS_PULL_RECOVERY}\` in a few minutes`);
|
|
2177
|
-
board?.stop();
|
|
2178
|
-
log(renderInitNote(`Harness analysis is still running on Moda. Run \`${HARNESS_PULL_RECOVERY}\` in a few minutes to fetch and sync the result.`, "info"));
|
|
2179
|
-
emit("harness", `Harness analysis still running on Moda; resume with \`${HARNESS_PULL_RECOVERY}\`.`, "warning");
|
|
2180
|
-
} else {
|
|
2181
|
-
board?.update("harness", "writing local artifacts");
|
|
2182
|
-
let pullResult;
|
|
2183
|
-
try {
|
|
2184
|
-
pullResult = await runHarnessCommand(createCommandContext({
|
|
2185
|
-
command: "harness",
|
|
2186
|
-
positional: "pull",
|
|
2187
|
-
positionals: ["pull"],
|
|
2188
|
-
flags: nestedHarnessFlags({ "run-id": remoteRunId })
|
|
2189
|
-
}));
|
|
2190
|
-
} catch (error) {
|
|
2191
|
-
await fallBackToLocal(error, isRecoverableRemoteRun(final) ? "unfetched" : "failed");
|
|
2192
|
-
}
|
|
2193
|
-
if (pullResult) {
|
|
2194
|
-
if (pullResult.exitCode !== 0) {
|
|
2195
|
-
board?.fail("harness", "report validation failed");
|
|
2196
|
-
board?.stop();
|
|
2197
|
-
throw validationFailure();
|
|
2198
|
-
}
|
|
2199
|
-
board?.complete("harness", "report written to .moda/");
|
|
2200
|
-
board?.stop();
|
|
2201
|
-
log(renderInitNote("Wrote or verified .moda/harness-report.json, .moda/harness.json, and .moda/HARNESS.md"));
|
|
2202
|
-
if (human)
|
|
2203
|
-
printHarnessDetectionSummary();
|
|
2204
|
-
emit("harness", "Harness discovery complete.", "completed");
|
|
2205
|
-
await approveAndSyncHarness();
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
board?.stop();
|
|
1813
|
+
laneBoard?.stop();
|
|
2210
1814
|
for (const message of setupWarnings)
|
|
2211
1815
|
warn(renderInitNote(message, "warning"));
|
|
2212
|
-
if (!harnessDeferred)
|
|
2213
|
-
markApplied(setupPlan, "harness");
|
|
2214
|
-
phases.push(harnessPhase);
|
|
2215
1816
|
emit("apply", "Approved changes applied.", setupWarnings.length > 0 ? "warning" : "completed");
|
|
2216
1817
|
phases.push(setupWarnings.length > 0 ? { id: "apply", title: "Set up", status: "warning", details: `${setupWarnings.length} setup warning(s); see warnings.` } : { id: "apply", title: "Set up", status: "completed" });
|
|
2217
|
-
const offlineValidation = isTruthyFlag(flagValue(flags, "offline"));
|
|
2218
1818
|
log(renderInitStep(5, 5, "Verify", offlineValidation ? "Running local doctor checks so the setup leaves a clear state." : "Running Moda doctor online as a tenant health check (not proof of SDK integration)."));
|
|
2219
1819
|
emit("validate", `Running Moda doctor diagnostics (${offlineValidation ? "offline" : "online"}).`);
|
|
2220
1820
|
const doctorReport = await buildDoctorReport(createCommandContext({
|
|
@@ -2242,7 +1842,6 @@ Harness analysis keeps running on Moda. Resume anytime with \`${HARNESS_PULL_REC
|
|
|
2242
1842
|
log(renderInitComplete({
|
|
2243
1843
|
tenantName,
|
|
2244
1844
|
dashboardUrl: `${resolveModaBaseUrl({ profile })}/dashboard`,
|
|
2245
|
-
harness: harnessSkipped ? { state: "skipped", reason: harnessSkip, next: HARNESS_SKIP_NEXT[harnessSkip] === "pull" ? HARNESS_PULL_RECOVERY : HARNESS_RETRY } : harnessDeferred ? { state: "pending" } : { state: "mapped", ...readHarnessGraphCounts() },
|
|
2246
1845
|
filesChanged: changedFiles(setupPlan),
|
|
2247
1846
|
skipped: setupPlan.filter((item) => item.status === "skipped" || item.status === "manual"),
|
|
2248
1847
|
telemetrySeen
|
|
@@ -2252,87 +1851,47 @@ Harness analysis keeps running on Moda. Resume anytime with \`${HARNESS_PULL_REC
|
|
|
2252
1851
|
tenantName,
|
|
2253
1852
|
phases,
|
|
2254
1853
|
setupPlan,
|
|
2255
|
-
promptSync: promptSyncOutcome,
|
|
2256
|
-
skillSync: skillSyncOutcome,
|
|
2257
1854
|
skillInstall,
|
|
2258
|
-
...sdkIntegration ? { sdk_integration: sdkIntegration } : {}
|
|
1855
|
+
...sdkIntegration ? { sdk_integration: sdkIntegration } : {},
|
|
1856
|
+
...ignoredFlagsWarning ? { ignoredFlagsWarning } : {}
|
|
2259
1857
|
};
|
|
2260
1858
|
}
|
|
1859
|
+
function planNotes(tenantName, integrateSdk) {
|
|
1860
|
+
return [
|
|
1861
|
+
`API key: provisioned for ${tenantName} in the Workspace step and saved to ~/.moda/config.json (no .env files are written).`,
|
|
1862
|
+
`Nothing from this repository is uploaded to Moda by init itself.${integrateSdk ? " During SDK integration your coding agent runs one verification request, which sends a test trace to Moda." : ""}`
|
|
1863
|
+
];
|
|
1864
|
+
}
|
|
2261
1865
|
function buildSetupPlan(options) {
|
|
1866
|
+
const { agentSkillDirs, installAgentSkill } = options;
|
|
1867
|
+
const skillApproved = installAgentSkill && agentSkillDirs.length > 0;
|
|
2262
1868
|
return [
|
|
2263
|
-
{
|
|
2264
|
-
category: "harness",
|
|
2265
|
-
title: options.remote ? "Analyze the harness on Moda's servers, write the cited report, and sync the graph to Moda" : "Analyze the harness locally, write the cited report, and sync the graph to Moda",
|
|
2266
|
-
status: "planned",
|
|
2267
|
-
approved: true,
|
|
2268
|
-
files: [
|
|
2269
|
-
".moda/harness-report.json",
|
|
2270
|
-
".moda/harness-report-validation.json",
|
|
2271
|
-
".moda/HARNESS_REPORT.md",
|
|
2272
|
-
".moda/harness.json",
|
|
2273
|
-
".moda/HARNESS.md"
|
|
2274
|
-
],
|
|
2275
|
-
command: options.remote ? "moda harness analyze --remote --summary --experimental && moda harness approve --yes && moda harness sync --from-report" : "moda harness analyze --analyst=auto --summary --experimental && moda harness approve --yes && moda harness sync --from-report"
|
|
2276
|
-
},
|
|
2277
|
-
{
|
|
2278
|
-
category: "prompts",
|
|
2279
|
-
title: "Initialize the prompt registry manifest and sync prompts to Moda",
|
|
2280
|
-
status: "planned",
|
|
2281
|
-
approved: true,
|
|
2282
|
-
files: [".moda/prompts.yml"],
|
|
2283
|
-
command: "moda prompts init && moda prompts sync"
|
|
2284
|
-
},
|
|
2285
1869
|
{
|
|
2286
1870
|
category: "skills",
|
|
2287
|
-
title:
|
|
2288
|
-
status: "planned",
|
|
2289
|
-
approved:
|
|
2290
|
-
files: [
|
|
2291
|
-
command: "moda skills
|
|
1871
|
+
title: agentSkillDirs.length > 0 ? `Install the moda-cli skill into ${agentSkillDirs.join(" and ")}` : "Install the moda-cli skill into detected coding agents",
|
|
1872
|
+
status: skillApproved ? "planned" : "manual",
|
|
1873
|
+
approved: skillApproved,
|
|
1874
|
+
files: skillApproved ? [...agentSkillDirs, INSTALL_RECORD_PATH] : [],
|
|
1875
|
+
...skillApproved ? { command: "moda skills install moda-cli" } : {},
|
|
1876
|
+
reason: skillApproved ? "Lets your coding agent query Moda through the CLI. Copies you have edited locally are kept." : installAgentSkill ? "No supported coding agent found here (looked for a .claude or .cursor directory and Claude Code on PATH); nothing is installed." : "User declined the moda-cli skill install.",
|
|
1877
|
+
...installAgentSkill ? {} : { declined: true }
|
|
2292
1878
|
},
|
|
2293
1879
|
{
|
|
2294
1880
|
category: "sdk",
|
|
2295
|
-
title: "Launch your coding agent to
|
|
1881
|
+
title: "Launch your coding agent to edit your source and install the Moda SDK packages",
|
|
2296
1882
|
status: options.integrateSdk ? "planned" : "manual",
|
|
2297
1883
|
approved: options.integrateSdk,
|
|
2298
1884
|
files: [],
|
|
2299
1885
|
command: "moda init --sdk-integrate",
|
|
2300
|
-
reason: options.integrateSdk ? "Your agent investigates the repo, applies matching integration skill(s), installs packages, runs repo checks, sends one verification request, and Moda verifies the exact trace. Your Moda API key is provided to the agent's environment for the verification run." : `SDK integration stays manual; see ${SDK_GUIDE_PATH} if you generate the guide.`
|
|
2301
|
-
},
|
|
2302
|
-
{
|
|
2303
|
-
category: "ci-cd",
|
|
2304
|
-
title: "CI/CD validation workflow",
|
|
2305
|
-
status: options.configureCiCd ? "planned" : "manual",
|
|
2306
|
-
approved: options.configureCiCd,
|
|
2307
|
-
files: [".github/workflows/moda-validation.yml"],
|
|
2308
|
-
command: "moda doctor --online --json",
|
|
2309
|
-
reason: options.configureCiCd ? undefined : "No CI/CD files are changed until a project-specific plan is approved."
|
|
2310
|
-
},
|
|
2311
|
-
{
|
|
2312
|
-
category: "autosync",
|
|
2313
|
-
title: "Autosync prompts and skills to Moda on push to main",
|
|
2314
|
-
status: options.configureAutosync ? "planned" : "manual",
|
|
2315
|
-
approved: options.configureAutosync,
|
|
2316
|
-
files: [".github/workflows/moda-autosync.yml"],
|
|
2317
|
-
command: "moda prompts sync && moda skills push",
|
|
2318
|
-
reason: options.configureAutosync ? undefined : "No autosync workflow is written until it is explicitly approved (--autosync)."
|
|
2319
|
-
},
|
|
2320
|
-
{
|
|
2321
|
-
category: "harness-rescan",
|
|
2322
|
-
title: "Re-scan the harness on push to main so the synced graph never drifts from the code",
|
|
2323
|
-
status: options.configureHarnessRescan ? "planned" : "manual",
|
|
2324
|
-
approved: options.configureHarnessRescan,
|
|
2325
|
-
files: [".github/workflows/moda-harness-rescan.yml"],
|
|
2326
|
-
command: "moda harness analyze --remote --yes --experimental && moda harness approve --yes && moda harness sync --from-report",
|
|
2327
|
-
reason: options.configureHarnessRescan ? undefined : "No harness rescan workflow is written until it is explicitly approved (--harness-rescan)."
|
|
1886
|
+
reason: options.integrateSdk ? "Your agent investigates the repo, applies matching integration skill(s), edits source, installs packages, runs repo checks, sends one verification request, and Moda verifies the exact trace. Your Moda API key is provided to the agent's environment for the verification run." : `SDK integration stays manual; see ${SDK_GUIDE_PATH} if you generate the guide.`
|
|
2328
1887
|
},
|
|
2329
1888
|
{
|
|
2330
1889
|
category: "validation",
|
|
2331
|
-
title: "Run Moda doctor online as a tenant health check",
|
|
1890
|
+
title: options.offlineValidation ? "Run Moda doctor with local checks only" : "Run Moda doctor online as a tenant health check",
|
|
2332
1891
|
status: "planned",
|
|
2333
1892
|
approved: true,
|
|
2334
1893
|
files: [],
|
|
2335
|
-
command: "moda doctor --online"
|
|
1894
|
+
command: options.offlineValidation ? "moda doctor" : "moda doctor --online"
|
|
2336
1895
|
}
|
|
2337
1896
|
];
|
|
2338
1897
|
}
|
|
@@ -2422,354 +1981,6 @@ function applySdkIntegrationOutcome(setupPlan, outcome, deps) {
|
|
|
2422
1981
|
function changedFiles(setupPlan) {
|
|
2423
1982
|
return [...new Set(setupPlan.filter((action) => action.status === "applied").flatMap((action) => action.files))].filter((file) => !file.includes(".env"));
|
|
2424
1983
|
}
|
|
2425
|
-
var GENERATED_WORKFLOW_CLI = `@moda-ai/cli@${VERSION}`;
|
|
2426
|
-
var GENERATED_WORKFLOW_NPX = `npx -y --package=${GENERATED_WORKFLOW_CLI} moda`;
|
|
2427
|
-
function writeCiCdWorkflow(cwd = process.cwd()) {
|
|
2428
|
-
const relativePath = ".github/workflows/moda-validation.yml";
|
|
2429
|
-
const path = join5(cwd, relativePath);
|
|
2430
|
-
mkdirSync4(dirname3(path), { recursive: true });
|
|
2431
|
-
writeFileSync3(path, `${[
|
|
2432
|
-
"name: Moda Validation",
|
|
2433
|
-
"",
|
|
2434
|
-
"on:",
|
|
2435
|
-
" pull_request:",
|
|
2436
|
-
" push:",
|
|
2437
|
-
" branches: [main]",
|
|
2438
|
-
"",
|
|
2439
|
-
"# Least privilege: these jobs only read the checked-out repo and talk to",
|
|
2440
|
-
"# Moda over the API key; they never write back to the repository.",
|
|
2441
|
-
"permissions:",
|
|
2442
|
-
" contents: read",
|
|
2443
|
-
"",
|
|
2444
|
-
"jobs:",
|
|
2445
|
-
" moda-doctor:",
|
|
2446
|
-
" runs-on: ubuntu-latest",
|
|
2447
|
-
" env:",
|
|
2448
|
-
" MODA_API_KEY: ${{ secrets.MODA_API_KEY }}",
|
|
2449
|
-
" MODA_TENANT_ID: ${{ secrets.MODA_TENANT_ID }}",
|
|
2450
|
-
" steps:",
|
|
2451
|
-
" - uses: actions/checkout@v4",
|
|
2452
|
-
" - uses: actions/setup-node@v4",
|
|
2453
|
-
" with:",
|
|
2454
|
-
" node-version: 22",
|
|
2455
|
-
" - name: Validate Moda setup",
|
|
2456
|
-
` run: ${GENERATED_WORKFLOW_NPX} doctor --online --json`,
|
|
2457
|
-
""
|
|
2458
|
-
].join(`
|
|
2459
|
-
`)}`);
|
|
2460
|
-
return relativePath;
|
|
2461
|
-
}
|
|
2462
|
-
function writeAutosyncWorkflow(cwd = process.cwd()) {
|
|
2463
|
-
const relativePath = ".github/workflows/moda-autosync.yml";
|
|
2464
|
-
const path = join5(cwd, relativePath);
|
|
2465
|
-
mkdirSync4(dirname3(path), { recursive: true });
|
|
2466
|
-
writeFileSync3(path, `${[
|
|
2467
|
-
"name: Moda Autosync",
|
|
2468
|
-
"",
|
|
2469
|
-
"on:",
|
|
2470
|
-
" push:",
|
|
2471
|
-
" branches: [main]",
|
|
2472
|
-
"",
|
|
2473
|
-
"# Least privilege: this job only reads the checked-out repo and writes to",
|
|
2474
|
-
"# Moda over the API key; it never writes back to the repository.",
|
|
2475
|
-
"permissions:",
|
|
2476
|
-
" contents: read",
|
|
2477
|
-
"",
|
|
2478
|
-
"# A single in-flight sync at a time; newer pushes supersede older runs.",
|
|
2479
|
-
"concurrency:",
|
|
2480
|
-
" group: moda-autosync",
|
|
2481
|
-
" cancel-in-progress: true",
|
|
2482
|
-
"",
|
|
2483
|
-
"jobs:",
|
|
2484
|
-
" moda-sync:",
|
|
2485
|
-
" runs-on: ubuntu-latest",
|
|
2486
|
-
" env:",
|
|
2487
|
-
" MODA_API_KEY: ${{ secrets.MODA_API_KEY }}",
|
|
2488
|
-
" MODA_TENANT_ID: ${{ secrets.MODA_TENANT_ID }}",
|
|
2489
|
-
" steps:",
|
|
2490
|
-
" - uses: actions/checkout@v4",
|
|
2491
|
-
" - uses: actions/setup-node@v4",
|
|
2492
|
-
" with:",
|
|
2493
|
-
" node-version: 22",
|
|
2494
|
-
` - name: Sync prompts to Moda`,
|
|
2495
|
-
` run: ${GENERATED_WORKFLOW_NPX} prompts sync`,
|
|
2496
|
-
` - name: Sync skills to Moda`,
|
|
2497
|
-
` run: ${GENERATED_WORKFLOW_NPX} skills push`,
|
|
2498
|
-
""
|
|
2499
|
-
].join(`
|
|
2500
|
-
`)}`);
|
|
2501
|
-
return relativePath;
|
|
2502
|
-
}
|
|
2503
|
-
function writeHarnessRescanWorkflow(cwd = process.cwd(), paths) {
|
|
2504
|
-
const relativePath = ".github/workflows/moda-harness-rescan.yml";
|
|
2505
|
-
const path = join5(cwd, relativePath);
|
|
2506
|
-
mkdirSync4(dirname3(path), { recursive: true });
|
|
2507
|
-
const pathScope = paths !== undefined && paths.length > 0 ? [
|
|
2508
|
-
" # Only pushes touching these paths trigger a rescan.",
|
|
2509
|
-
" paths:",
|
|
2510
|
-
...paths.map((glob) => ` - '${glob.replace(/'/g, "''")}'`)
|
|
2511
|
-
] : [
|
|
2512
|
-
" # Optional: scope rescans to agent-relevant paths, e.g.",
|
|
2513
|
-
" # paths:",
|
|
2514
|
-
" # - 'src/agents/**'"
|
|
2515
|
-
];
|
|
2516
|
-
writeFileSync3(path, `${[
|
|
2517
|
-
"name: Moda Harness Rescan",
|
|
2518
|
-
"",
|
|
2519
|
-
"on:",
|
|
2520
|
-
" push:",
|
|
2521
|
-
" branches: [main]",
|
|
2522
|
-
...pathScope,
|
|
2523
|
-
" workflow_dispatch:",
|
|
2524
|
-
"",
|
|
2525
|
-
"# Least privilege: this job reads the checked-out repo, uploads a safe",
|
|
2526
|
-
"# source snapshot to Moda over the API key, and syncs the refreshed harness",
|
|
2527
|
-
"# graph; it never writes back to the repository.",
|
|
2528
|
-
"permissions:",
|
|
2529
|
-
" contents: read",
|
|
2530
|
-
"",
|
|
2531
|
-
"# One in-flight rescan at a time; newer pushes supersede older runs.",
|
|
2532
|
-
"concurrency:",
|
|
2533
|
-
" group: moda-harness-rescan",
|
|
2534
|
-
" cancel-in-progress: true",
|
|
2535
|
-
"",
|
|
2536
|
-
"jobs:",
|
|
2537
|
-
" moda-harness-rescan:",
|
|
2538
|
-
" runs-on: ubuntu-latest",
|
|
2539
|
-
" env:",
|
|
2540
|
-
" MODA_API_KEY: ${{ secrets.MODA_API_KEY }}",
|
|
2541
|
-
" MODA_TENANT_ID: ${{ secrets.MODA_TENANT_ID }}",
|
|
2542
|
-
" # `moda harness analyze` is opt-in (the Moda GitHub App is the default",
|
|
2543
|
-
" # path); this workflow drives the CLI analyze directly, so it opts in.",
|
|
2544
|
-
' MODA_HARNESS_ANALYZE_CLI: "1"',
|
|
2545
|
-
" steps:",
|
|
2546
|
-
" - uses: actions/checkout@v4",
|
|
2547
|
-
" - uses: actions/setup-node@v4",
|
|
2548
|
-
" with:",
|
|
2549
|
-
" node-version: 22",
|
|
2550
|
-
" - name: Re-analyze the harness on Moda",
|
|
2551
|
-
` run: ${GENERATED_WORKFLOW_NPX} harness analyze --remote --yes`,
|
|
2552
|
-
" - name: Approve the refreshed harness report",
|
|
2553
|
-
` run: ${GENERATED_WORKFLOW_NPX} harness approve --yes`,
|
|
2554
|
-
" - name: Sync the harness graph to Moda",
|
|
2555
|
-
` run: ${GENERATED_WORKFLOW_NPX} harness sync --from-report`,
|
|
2556
|
-
""
|
|
2557
|
-
].join(`
|
|
2558
|
-
`)}`);
|
|
2559
|
-
return relativePath;
|
|
2560
|
-
}
|
|
2561
|
-
function printHarnessDetectionSummary(cwd = process.cwd()) {
|
|
2562
|
-
const manifestPath = join5(cwd, ".moda", "harness.json");
|
|
2563
|
-
if (!existsSync5(manifestPath))
|
|
2564
|
-
return;
|
|
2565
|
-
try {
|
|
2566
|
-
const graph = JSON.parse(readFileSync4(manifestPath, "utf8"));
|
|
2567
|
-
const frameworkNames = (graph.agentFrameworks ?? []).map((framework) => typeof framework.name === "string" ? framework.name : undefined).filter((name) => Boolean(name));
|
|
2568
|
-
const providerNames = (graph.modelProviders ?? []).map((provider) => typeof provider.name === "string" ? provider.name : undefined).filter((name) => Boolean(name));
|
|
2569
|
-
console.log(` Detected harness: ${(graph.runtimeAgents ?? []).length} runtime agent(s), ` + `${(graph.artifacts ?? []).length} artifact(s), ${(graph.relationships ?? []).length} relationship(s)`);
|
|
2570
|
-
if (frameworkNames.length > 0)
|
|
2571
|
-
console.log(` Frameworks: ${frameworkNames.join(", ")}`);
|
|
2572
|
-
if (providerNames.length > 0)
|
|
2573
|
-
console.log(` Model providers: ${providerNames.join(", ")}`);
|
|
2574
|
-
} catch {
|
|
2575
|
-
console.log(" Detected harness summary is available in .moda/HARNESS.md");
|
|
2576
|
-
}
|
|
2577
|
-
}
|
|
2578
|
-
function signalsFromGraph(graph) {
|
|
2579
|
-
const names = (items) => (items ?? []).map((item) => typeof item.name === "string" ? item.name : undefined).filter((name) => Boolean(name));
|
|
2580
|
-
return {
|
|
2581
|
-
runtimeAgents: Array.isArray(graph.runtimeAgents) ? graph.runtimeAgents.length : 0,
|
|
2582
|
-
frameworks: names(graph.agentFrameworks),
|
|
2583
|
-
providers: names(graph.modelProviders)
|
|
2584
|
-
};
|
|
2585
|
-
}
|
|
2586
|
-
function readHarnessQualitySignals(cwd = process.cwd()) {
|
|
2587
|
-
const reportPath = join5(cwd, ".moda", "harness-report.json");
|
|
2588
|
-
if (existsSync5(reportPath)) {
|
|
2589
|
-
try {
|
|
2590
|
-
const report = JSON.parse(readFileSync4(reportPath, "utf8"));
|
|
2591
|
-
if (report.graph && typeof report.graph === "object") {
|
|
2592
|
-
return signalsFromGraph(report.graph);
|
|
2593
|
-
}
|
|
2594
|
-
} catch {}
|
|
2595
|
-
}
|
|
2596
|
-
const manifestPath = join5(cwd, ".moda", "harness.json");
|
|
2597
|
-
if (!existsSync5(manifestPath))
|
|
2598
|
-
return;
|
|
2599
|
-
try {
|
|
2600
|
-
return signalsFromGraph(JSON.parse(readFileSync4(manifestPath, "utf8")));
|
|
2601
|
-
} catch {
|
|
2602
|
-
return;
|
|
2603
|
-
}
|
|
2604
|
-
}
|
|
2605
|
-
function harnessLooksIncomplete(signals) {
|
|
2606
|
-
return signals.runtimeAgents === 0 && (signals.frameworks.length > 0 || signals.providers.length > 0);
|
|
2607
|
-
}
|
|
2608
|
-
var REPO_SIGNAL_MAX_DEPTH = 3;
|
|
2609
|
-
var REPO_SIGNAL_MAX_DIRS = 500;
|
|
2610
|
-
var REPO_SIGNAL_SKIPPED_DIRS = new Set([
|
|
2611
|
-
"node_modules",
|
|
2612
|
-
"dist",
|
|
2613
|
-
"build",
|
|
2614
|
-
"out",
|
|
2615
|
-
"coverage",
|
|
2616
|
-
"vendor",
|
|
2617
|
-
"target",
|
|
2618
|
-
"venv",
|
|
2619
|
-
"env",
|
|
2620
|
-
"__pycache__",
|
|
2621
|
-
"site-packages"
|
|
2622
|
-
]);
|
|
2623
|
-
var JS_LLM_DEPENDENCIES = {
|
|
2624
|
-
openai: { name: "OpenAI", kind: "provider" },
|
|
2625
|
-
"@anthropic-ai/sdk": { name: "Anthropic", kind: "provider" },
|
|
2626
|
-
"@google/generative-ai": { name: "Google Gemini", kind: "provider" },
|
|
2627
|
-
"@google/genai": { name: "Google Gemini", kind: "provider" },
|
|
2628
|
-
"cohere-ai": { name: "Cohere", kind: "provider" },
|
|
2629
|
-
"groq-sdk": { name: "Groq", kind: "provider" },
|
|
2630
|
-
"@mistralai/mistralai": { name: "Mistral", kind: "provider" },
|
|
2631
|
-
ollama: { name: "Ollama", kind: "provider" },
|
|
2632
|
-
"together-ai": { name: "Together", kind: "provider" },
|
|
2633
|
-
"@aws-sdk/client-bedrock-runtime": { name: "AWS Bedrock", kind: "provider" },
|
|
2634
|
-
ai: { name: "Vercel AI SDK", kind: "framework" },
|
|
2635
|
-
langchain: { name: "LangChain", kind: "framework" },
|
|
2636
|
-
llamaindex: { name: "LlamaIndex", kind: "framework" },
|
|
2637
|
-
"@anthropic-ai/claude-agent-sdk": { name: "Claude Agent SDK", kind: "framework" },
|
|
2638
|
-
"@openai/agents": { name: "OpenAI Agents", kind: "framework" },
|
|
2639
|
-
"@mastra/core": { name: "Mastra", kind: "framework" }
|
|
2640
|
-
};
|
|
2641
|
-
var JS_LLM_DEPENDENCY_PREFIXES = [
|
|
2642
|
-
["@langchain/", { name: "LangChain", kind: "framework" }],
|
|
2643
|
-
["@ai-sdk/", { name: "Vercel AI SDK", kind: "framework" }],
|
|
2644
|
-
["@llamaindex/", { name: "LlamaIndex", kind: "framework" }]
|
|
2645
|
-
];
|
|
2646
|
-
var PY_LLM_DEPENDENCIES = {
|
|
2647
|
-
openai: { name: "OpenAI", kind: "provider" },
|
|
2648
|
-
anthropic: { name: "Anthropic", kind: "provider" },
|
|
2649
|
-
"google-generativeai": { name: "Google Gemini", kind: "provider" },
|
|
2650
|
-
"google-genai": { name: "Google Gemini", kind: "provider" },
|
|
2651
|
-
cohere: { name: "Cohere", kind: "provider" },
|
|
2652
|
-
groq: { name: "Groq", kind: "provider" },
|
|
2653
|
-
mistralai: { name: "Mistral", kind: "provider" },
|
|
2654
|
-
ollama: { name: "Ollama", kind: "provider" },
|
|
2655
|
-
langgraph: { name: "LangGraph", kind: "framework" },
|
|
2656
|
-
litellm: { name: "LiteLLM", kind: "framework" },
|
|
2657
|
-
crewai: { name: "CrewAI", kind: "framework" },
|
|
2658
|
-
autogen: { name: "AutoGen", kind: "framework" },
|
|
2659
|
-
pyautogen: { name: "AutoGen", kind: "framework" },
|
|
2660
|
-
ag2: { name: "AutoGen", kind: "framework" },
|
|
2661
|
-
"pydantic-ai": { name: "Pydantic AI", kind: "framework" },
|
|
2662
|
-
"openai-agents": { name: "OpenAI Agents", kind: "framework" },
|
|
2663
|
-
"semantic-kernel": { name: "Semantic Kernel", kind: "framework" },
|
|
2664
|
-
dspy: { name: "DSPy", kind: "framework" },
|
|
2665
|
-
"haystack-ai": { name: "Haystack", kind: "framework" }
|
|
2666
|
-
};
|
|
2667
|
-
var PY_LLM_DEPENDENCY_PREFIXES = [
|
|
2668
|
-
["langchain", { name: "LangChain", kind: "framework" }],
|
|
2669
|
-
["llama-index", { name: "LlamaIndex", kind: "framework" }]
|
|
2670
|
-
];
|
|
2671
|
-
function jsDependencySignal(dep) {
|
|
2672
|
-
const exact = JS_LLM_DEPENDENCIES[dep];
|
|
2673
|
-
if (exact)
|
|
2674
|
-
return exact;
|
|
2675
|
-
for (const [prefix, signal] of JS_LLM_DEPENDENCY_PREFIXES) {
|
|
2676
|
-
if (dep.startsWith(prefix))
|
|
2677
|
-
return signal;
|
|
2678
|
-
}
|
|
2679
|
-
return;
|
|
2680
|
-
}
|
|
2681
|
-
function pyDependencySignal(dep) {
|
|
2682
|
-
const normalized = dep.toLowerCase().replace(/_/g, "-");
|
|
2683
|
-
const exact = PY_LLM_DEPENDENCIES[normalized];
|
|
2684
|
-
if (exact)
|
|
2685
|
-
return exact;
|
|
2686
|
-
for (const [prefix, signal] of PY_LLM_DEPENDENCY_PREFIXES) {
|
|
2687
|
-
if (normalized === prefix || normalized.startsWith(`${prefix}-`))
|
|
2688
|
-
return signal;
|
|
2689
|
-
}
|
|
2690
|
-
return;
|
|
2691
|
-
}
|
|
2692
|
-
function pythonRequirementNames(text, file) {
|
|
2693
|
-
const names = [];
|
|
2694
|
-
if (file === "requirements.txt") {
|
|
2695
|
-
for (const line of text.split(`
|
|
2696
|
-
`)) {
|
|
2697
|
-
const match = /^\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(line);
|
|
2698
|
-
if (match)
|
|
2699
|
-
names.push(match[1]);
|
|
2700
|
-
}
|
|
2701
|
-
return names;
|
|
2702
|
-
}
|
|
2703
|
-
for (const match of text.matchAll(/["']([A-Za-z0-9][A-Za-z0-9._-]*)[^"']*["']/g)) {
|
|
2704
|
-
names.push(match[1]);
|
|
2705
|
-
}
|
|
2706
|
-
return names;
|
|
2707
|
-
}
|
|
2708
|
-
function detectRepoLlmSignals(cwd = process.cwd()) {
|
|
2709
|
-
const frameworks = new Set;
|
|
2710
|
-
const providers = new Set;
|
|
2711
|
-
const record = (signal) => {
|
|
2712
|
-
if (!signal)
|
|
2713
|
-
return;
|
|
2714
|
-
(signal.kind === "framework" ? frameworks : providers).add(signal.name);
|
|
2715
|
-
};
|
|
2716
|
-
const scanDir = (dir) => {
|
|
2717
|
-
try {
|
|
2718
|
-
const pkg = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
2719
|
-
for (const dep of [
|
|
2720
|
-
...Object.keys(pkg.dependencies ?? {}),
|
|
2721
|
-
...Object.keys(pkg.devDependencies ?? {}),
|
|
2722
|
-
...Object.keys(pkg.peerDependencies ?? {})
|
|
2723
|
-
]) {
|
|
2724
|
-
record(jsDependencySignal(dep));
|
|
2725
|
-
}
|
|
2726
|
-
} catch {}
|
|
2727
|
-
for (const file of ["requirements.txt", "pyproject.toml"]) {
|
|
2728
|
-
try {
|
|
2729
|
-
const text = readFileSync4(join5(dir, file), "utf8");
|
|
2730
|
-
for (const name of pythonRequirementNames(text, file)) {
|
|
2731
|
-
record(pyDependencySignal(name));
|
|
2732
|
-
}
|
|
2733
|
-
} catch {}
|
|
2734
|
-
}
|
|
2735
|
-
};
|
|
2736
|
-
let visited = 0;
|
|
2737
|
-
const walk = (dir, depth) => {
|
|
2738
|
-
if (depth > REPO_SIGNAL_MAX_DEPTH || visited >= REPO_SIGNAL_MAX_DIRS)
|
|
2739
|
-
return;
|
|
2740
|
-
visited += 1;
|
|
2741
|
-
scanDir(dir);
|
|
2742
|
-
let entries;
|
|
2743
|
-
try {
|
|
2744
|
-
entries = readdirSync3(dir, { withFileTypes: true });
|
|
2745
|
-
} catch {
|
|
2746
|
-
return;
|
|
2747
|
-
}
|
|
2748
|
-
for (const entry of entries) {
|
|
2749
|
-
if (!entry.isDirectory() || entry.name.startsWith("."))
|
|
2750
|
-
continue;
|
|
2751
|
-
if (REPO_SIGNAL_SKIPPED_DIRS.has(entry.name))
|
|
2752
|
-
continue;
|
|
2753
|
-
walk(join5(dir, entry.name), depth + 1);
|
|
2754
|
-
}
|
|
2755
|
-
};
|
|
2756
|
-
walk(cwd, 0);
|
|
2757
|
-
return { frameworks: [...frameworks].sort(), providers: [...providers].sort() };
|
|
2758
|
-
}
|
|
2759
|
-
function readHarnessGraphCounts(cwd = process.cwd()) {
|
|
2760
|
-
const manifestPath = join5(cwd, ".moda", "harness.json");
|
|
2761
|
-
if (!existsSync5(manifestPath))
|
|
2762
|
-
return {};
|
|
2763
|
-
try {
|
|
2764
|
-
const graph = JSON.parse(readFileSync4(manifestPath, "utf8"));
|
|
2765
|
-
return {
|
|
2766
|
-
agents: Array.isArray(graph.runtimeAgents) ? graph.runtimeAgents.length : 0,
|
|
2767
|
-
artifacts: Array.isArray(graph.artifacts) ? graph.artifacts.length : 0
|
|
2768
|
-
};
|
|
2769
|
-
} catch {
|
|
2770
|
-
return {};
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2773
1984
|
function commandFlags(flags) {
|
|
2774
1985
|
return Object.fromEntries(Object.entries(flags).filter(([, value]) => value !== undefined && value !== false).map(([key, value]) => [key, value === true ? "true" : String(value)]));
|
|
2775
1986
|
}
|
|
@@ -2782,16 +1993,10 @@ function resumeFlagsForInit(flags) {
|
|
|
2782
1993
|
"tenant-id",
|
|
2783
1994
|
"verification-id",
|
|
2784
1995
|
"offline",
|
|
2785
|
-
"analyst",
|
|
2786
1996
|
"sdk-integrate",
|
|
2787
|
-
"ci-cd",
|
|
2788
|
-
"autosync",
|
|
2789
|
-
"harness-rescan",
|
|
2790
|
-
"harness-rescan-paths",
|
|
2791
1997
|
"no-sdk-integrate",
|
|
2792
|
-
"
|
|
2793
|
-
"no-
|
|
2794
|
-
"no-harness-rescan",
|
|
1998
|
+
"agent-skill",
|
|
1999
|
+
"no-agent-skill",
|
|
2795
2000
|
"yes",
|
|
2796
2001
|
"agent",
|
|
2797
2002
|
"json",
|
|
@@ -2808,41 +2013,19 @@ function resumeFlagsForInit(flags) {
|
|
|
2808
2013
|
else
|
|
2809
2014
|
out.push(flag, String(value));
|
|
2810
2015
|
}
|
|
2811
|
-
if (
|
|
2812
|
-
out.push("--no-
|
|
2016
|
+
if (resolveAgentSkillFlag(flags) === false && !out.includes("--no-agent-skill")) {
|
|
2017
|
+
out.push("--no-agent-skill");
|
|
2813
2018
|
}
|
|
2814
2019
|
return out;
|
|
2815
2020
|
}
|
|
2816
|
-
function
|
|
2817
|
-
const explicit = parseOptionalBoolean(flagValue(flags, "
|
|
2818
|
-
if (explicit !== undefined)
|
|
2819
|
-
return explicit;
|
|
2820
|
-
if (isTruthyFlag(flagValue(flags, "no-ci-cd", "no_ci_cd")))
|
|
2821
|
-
return false;
|
|
2822
|
-
return;
|
|
2823
|
-
}
|
|
2824
|
-
function resolveAutosyncFlag(flags) {
|
|
2825
|
-
const explicit = parseOptionalBoolean(flagValue(flags, "autosync", "auto-sync", "auto_sync"));
|
|
2021
|
+
function resolveAgentSkillFlag(flags) {
|
|
2022
|
+
const explicit = parseOptionalBoolean(flagValue(flags, "agent-skill", "agent_skill"));
|
|
2826
2023
|
if (explicit !== undefined)
|
|
2827
2024
|
return explicit;
|
|
2828
|
-
if (isTruthyFlag(flagValue(flags, "no-
|
|
2025
|
+
if (isTruthyFlag(flagValue(flags, "no-agent-skill", "no_agent_skill")))
|
|
2829
2026
|
return false;
|
|
2830
2027
|
return;
|
|
2831
2028
|
}
|
|
2832
|
-
function resolveHarnessRescanFlag(flags) {
|
|
2833
|
-
const explicit = parseOptionalBoolean(flagValue(flags, "harness-rescan", "harness_rescan"));
|
|
2834
|
-
if (explicit !== undefined)
|
|
2835
|
-
return explicit;
|
|
2836
|
-
if (isTruthyFlag(flagValue(flags, "no-harness-rescan", "no_harness_rescan")))
|
|
2837
|
-
return false;
|
|
2838
|
-
return;
|
|
2839
|
-
}
|
|
2840
|
-
function parseHarnessRescanPaths(value) {
|
|
2841
|
-
if (typeof value !== "string")
|
|
2842
|
-
return;
|
|
2843
|
-
const globs = value.split(",").map((glob) => glob.trim()).filter((glob) => glob.length > 0 && glob !== "true");
|
|
2844
|
-
return globs.length > 0 ? globs : undefined;
|
|
2845
|
-
}
|
|
2846
2029
|
function resolveSdkIntegrateFlag(flags) {
|
|
2847
2030
|
const explicit = parseOptionalBoolean(flagValue(flags, "sdk-integrate", "sdk_integrate", "sdk-guide", "sdk_guide", "sdk"));
|
|
2848
2031
|
if (explicit !== undefined)
|
|
@@ -2864,27 +2047,12 @@ function parseOptionalBoolean(value) {
|
|
|
2864
2047
|
function isTruthyFlag(value) {
|
|
2865
2048
|
return value === true || value === 1 || value === "true" || value === "1" || value === "yes";
|
|
2866
2049
|
}
|
|
2867
|
-
function
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
if (remote !== undefined)
|
|
2874
|
-
return remote;
|
|
2875
|
-
if (isDeterministicLocalAnalyst(stringFlag(flagValue(flags, "analyst")))) {
|
|
2876
|
-
return false;
|
|
2877
|
-
}
|
|
2878
|
-
return true;
|
|
2879
|
-
}
|
|
2880
|
-
function hasExplicitRemoteChoice(flags) {
|
|
2881
|
-
if (isTruthyFlag(flagValue(flags, "local")))
|
|
2882
|
-
return true;
|
|
2883
|
-
if (isTruthyFlag(flagValue(flags, "no-remote", "no_remote")))
|
|
2884
|
-
return true;
|
|
2885
|
-
if (parseOptionalBoolean(flagValue(flags, "remote")) !== undefined)
|
|
2886
|
-
return true;
|
|
2887
|
-
return isDeterministicLocalAnalyst(stringFlag(flagValue(flags, "analyst")));
|
|
2050
|
+
function removedFlagsWarning(flags) {
|
|
2051
|
+
const given = REMOVED_INIT_FLAGS.filter((flag) => flagValue(flags, flag, flag.replace(/-/g, "_")) !== undefined);
|
|
2052
|
+
if (given.length === 0)
|
|
2053
|
+
return;
|
|
2054
|
+
const names = given.map((flag) => `--${flag}`).join(", ");
|
|
2055
|
+
return `Ignoring flags \`moda init\` no longer uses: ${names}. ` + "For harness, prompts, and skills use `moda harness`, `moda prompts`, `moda skills`, or the Moda GitHub App.";
|
|
2888
2056
|
}
|
|
2889
2057
|
function flagValue(flags, ...keys) {
|
|
2890
2058
|
for (const key of keys) {
|
|
@@ -2894,13 +2062,6 @@ function flagValue(flags, ...keys) {
|
|
|
2894
2062
|
return;
|
|
2895
2063
|
}
|
|
2896
2064
|
export {
|
|
2897
|
-
writeHarnessRescanWorkflow,
|
|
2898
|
-
writeCiCdWorkflow,
|
|
2899
|
-
writeAutosyncWorkflow,
|
|
2900
2065
|
runInit,
|
|
2901
|
-
resumeFlagsForInit
|
|
2902
|
-
resolveHarnessRemote,
|
|
2903
|
-
readHarnessQualitySignals,
|
|
2904
|
-
harnessLooksIncomplete,
|
|
2905
|
-
detectRepoLlmSignals
|
|
2066
|
+
resumeFlagsForInit
|
|
2906
2067
|
};
|