@pedrocivita/tocket 2.5.0 → 2.6.4
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 +233 -18
- package/dist/commands/agents-md.cmd.d.ts +2 -0
- package/dist/commands/agents-md.cmd.js +166 -0
- package/dist/commands/agents-md.cmd.js.map +1 -0
- package/dist/commands/decide.cmd.d.ts +2 -0
- package/dist/commands/decide.cmd.js +70 -0
- package/dist/commands/decide.cmd.js.map +1 -0
- package/dist/commands/doctor.cmd.d.ts +13 -0
- package/dist/commands/doctor.cmd.js +135 -11
- package/dist/commands/doctor.cmd.js.map +1 -1
- package/dist/commands/eject.cmd.d.ts +1 -1
- package/dist/commands/eject.cmd.js +3 -1
- package/dist/commands/eject.cmd.js.map +1 -1
- package/dist/commands/init.cmd.js +67 -13
- package/dist/commands/init.cmd.js.map +1 -1
- package/dist/commands/scaffold.cmd.d.ts +2 -0
- package/dist/commands/scaffold.cmd.js +118 -0
- package/dist/commands/scaffold.cmd.js.map +1 -0
- package/dist/commands/suite.cmd.d.ts +2 -0
- package/dist/commands/suite.cmd.js +387 -0
- package/dist/commands/suite.cmd.js.map +1 -0
- package/dist/commands/validate.cmd.js +1 -0
- package/dist/commands/validate.cmd.js.map +1 -1
- package/dist/commands/work.cmd.d.ts +2 -0
- package/dist/commands/work.cmd.js +48 -0
- package/dist/commands/work.cmd.js.map +1 -0
- package/dist/eval/decide-eval.d.ts +28 -0
- package/dist/eval/decide-eval.js +34 -0
- package/dist/eval/decide-eval.js.map +1 -0
- package/dist/eval/triage-eval.d.ts +46 -0
- package/dist/eval/triage-eval.js +175 -0
- package/dist/eval/triage-eval.js.map +1 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +7 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +360 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/templates/memory-bank.d.ts +11 -0
- package/dist/templates/memory-bank.js +456 -329
- package/dist/templates/memory-bank.js.map +1 -1
- package/dist/tests/agents.test.js +73 -1
- package/dist/tests/agents.test.js.map +1 -1
- package/dist/tests/context.test.js +10 -1
- package/dist/tests/context.test.js.map +1 -1
- package/dist/tests/decide.test.d.ts +1 -0
- package/dist/tests/decide.test.js +483 -0
- package/dist/tests/decide.test.js.map +1 -0
- package/dist/tests/doctor.test.js +74 -1
- package/dist/tests/doctor.test.js.map +1 -1
- package/dist/tests/eject.test.js +3 -0
- package/dist/tests/eject.test.js.map +1 -1
- package/dist/tests/git.test.js +17 -0
- package/dist/tests/git.test.js.map +1 -1
- package/dist/tests/helpers.d.ts +6 -0
- package/dist/tests/helpers.js +13 -0
- package/dist/tests/helpers.js.map +1 -0
- package/dist/tests/helpers.test.d.ts +1 -0
- package/dist/tests/helpers.test.js +23 -0
- package/dist/tests/helpers.test.js.map +1 -0
- package/dist/tests/init.test.js +85 -5
- package/dist/tests/init.test.js.map +1 -1
- package/dist/tests/loop.test.d.ts +1 -0
- package/dist/tests/loop.test.js +153 -0
- package/dist/tests/loop.test.js.map +1 -0
- package/dist/tests/memory-bank.test.js +53 -1
- package/dist/tests/memory-bank.test.js.map +1 -1
- package/dist/tests/suite.test.d.ts +1 -0
- package/dist/tests/suite.test.js +199 -0
- package/dist/tests/suite.test.js.map +1 -0
- package/dist/tests/triage.test.d.ts +1 -0
- package/dist/tests/triage.test.js +152 -0
- package/dist/tests/triage.test.js.map +1 -0
- package/dist/tests/work.test.d.ts +1 -0
- package/dist/tests/work.test.js +276 -0
- package/dist/tests/work.test.js.map +1 -0
- package/dist/utils/agents.d.ts +25 -0
- package/dist/utils/agents.js +92 -0
- package/dist/utils/agents.js.map +1 -1
- package/dist/utils/appmaps.d.ts +65 -0
- package/dist/utils/appmaps.js +280 -0
- package/dist/utils/appmaps.js.map +1 -0
- package/dist/utils/context.d.ts +2 -0
- package/dist/utils/context.js +21 -0
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/decide.d.ts +178 -0
- package/dist/utils/decide.js +614 -0
- package/dist/utils/decide.js.map +1 -0
- package/dist/utils/git.js +8 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/jev.d.ts +83 -0
- package/dist/utils/jev.js +190 -0
- package/dist/utils/jev.js.map +1 -0
- package/dist/utils/triage.d.ts +87 -0
- package/dist/utils/triage.js +241 -0
- package/dist/utils/triage.js.map +1 -0
- package/dist/utils/work.d.ts +72 -0
- package/dist/utils/work.js +225 -0
- package/dist/utils/work.js.map +1 -0
- package/package.json +53 -50
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { describe, it, after } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtempSync, rmSync, mkdirSync, readFileSync, existsSync, copyFileSync, } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import { parseLastRun } from "../utils/appmaps.js";
|
|
8
|
+
import { heuristicJudge, naiveIfElseChoice, parseTriageReport, runTriage, selectResults, } from "../utils/triage.js";
|
|
9
|
+
import { evaluateTriage } from "../eval/triage-eval.js";
|
|
10
|
+
import { askJevTriage, buildTriageQuestions } from "../utils/jev.js";
|
|
11
|
+
const cliPath = join(import.meta.dirname, "..", "index.js");
|
|
12
|
+
const fixturesDir = join(import.meta.dirname, "..", "..", "fixtures");
|
|
13
|
+
const lastRunFixture = join(fixturesDir, "triage", "last-run.json");
|
|
14
|
+
const passFixture = join(fixturesDir, "triage", "tempestivita-pass.last-run.json");
|
|
15
|
+
const expectedFixture = join(fixturesDir, "triage-expected.json");
|
|
16
|
+
function runCli(args, cwd, env) {
|
|
17
|
+
try {
|
|
18
|
+
const stdout = execFileSync(process.execPath, [cliPath, ...args], {
|
|
19
|
+
cwd,
|
|
20
|
+
encoding: "utf-8",
|
|
21
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
22
|
+
env: { ...process.env, TYPESAFE_API_KEY: "", ...env },
|
|
23
|
+
});
|
|
24
|
+
return { stdout, stderr: "", status: 0 };
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
const failed = err;
|
|
28
|
+
return {
|
|
29
|
+
stdout: failed.stdout ?? "",
|
|
30
|
+
stderr: failed.stderr ?? "",
|
|
31
|
+
status: failed.status ?? 1,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
describe("last-run evidence objects", () => {
|
|
36
|
+
it("parses the real Tempestivita 8/8 pass snapshot", () => {
|
|
37
|
+
const run = parseLastRun(readFileSync(passFixture, "utf-8"));
|
|
38
|
+
assert.equal(run.app, "tempestivita");
|
|
39
|
+
assert.equal(run.all_ok, true);
|
|
40
|
+
assert.equal(run.results.length, 8);
|
|
41
|
+
assert.equal(typeof run.results[0].evidence, "object");
|
|
42
|
+
assert.equal(selectResults(run, false).length, 0);
|
|
43
|
+
assert.equal(selectResults(run, true).length, 2);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe("heuristicJudge", () => {
|
|
47
|
+
it("classifies timeout, locator, assertion, flake, and ignore flavors", () => {
|
|
48
|
+
assert.equal(heuristicJudge({ id: "a", name: "nav", ok: false, error: "TimeoutError: Navigation timeout of 30000 ms exceeded" }).choice, "retry");
|
|
49
|
+
assert.equal(heuristicJudge({ id: "b", name: "loc", ok: false, error: "LocatorError: locator('[data-testid=x]') not found" }).choice, "rewrite-locator");
|
|
50
|
+
assert.equal(heuristicJudge({ id: "c", name: "wait", ok: false, error: "Timeout 5000ms exceeded while waiting for getByText('Hi')" }).choice, "rewrite-locator");
|
|
51
|
+
assert.equal(heuristicJudge({ id: "d", name: "assert", ok: false, error: "AssertionError: expected 'a' to be 'b'" }).choice, "escalate");
|
|
52
|
+
assert.equal(heuristicJudge({ id: "e", name: "vis", ok: false, error: "expect(locator('.sheet')).toBeVisible() failed" }).choice, "escalate");
|
|
53
|
+
assert.equal(heuristicJudge({ id: "f", name: "pass", ok: true, error: null, jev_confidence: 0.52 }).choice, "ignore");
|
|
54
|
+
assert.equal(heuristicJudge({ id: "g", name: "noise", ok: false, error: "console warning: ResizeObserver loop (benign)" }).choice, "ignore");
|
|
55
|
+
});
|
|
56
|
+
it("is not keyed by fixture id", () => {
|
|
57
|
+
const first = heuristicJudge({
|
|
58
|
+
id: "never-seen-id",
|
|
59
|
+
name: "x",
|
|
60
|
+
ok: false,
|
|
61
|
+
error: "No such element: Unable to locate element: //a",
|
|
62
|
+
});
|
|
63
|
+
const second = heuristicJudge({
|
|
64
|
+
id: "also-new",
|
|
65
|
+
name: "y",
|
|
66
|
+
ok: false,
|
|
67
|
+
error: "No such element: Unable to locate element: //a",
|
|
68
|
+
});
|
|
69
|
+
assert.equal(first.choice, "rewrite-locator");
|
|
70
|
+
assert.equal(second.choice, first.choice);
|
|
71
|
+
});
|
|
72
|
+
it("beats naive if-else on locator failures", () => {
|
|
73
|
+
const input = { id: "z", name: "z", ok: false, error: "stale locator" };
|
|
74
|
+
assert.equal(naiveIfElseChoice(input), "escalate");
|
|
75
|
+
assert.equal(heuristicJudge(input).choice, "rewrite-locator");
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe("askJevTriage", () => {
|
|
79
|
+
it("parses Choice + Noul from a System One-shaped response", async () => {
|
|
80
|
+
const answers = await askJevTriage({
|
|
81
|
+
apiKey: "test-key",
|
|
82
|
+
state: { id: "T-1" },
|
|
83
|
+
fetchImpl: async () => new Response(JSON.stringify({
|
|
84
|
+
model: "jev-latest",
|
|
85
|
+
answers: {
|
|
86
|
+
action: { type: "choice", choice: "retry", confidence: 0.81 },
|
|
87
|
+
locator_drift: { type: "noul", noul: 0.12 },
|
|
88
|
+
},
|
|
89
|
+
}), { status: 200 }),
|
|
90
|
+
});
|
|
91
|
+
assert.equal(answers.choice, "retry");
|
|
92
|
+
assert.equal(answers.confidence, 0.81);
|
|
93
|
+
assert.equal(answers.locatorDrift, 0.12);
|
|
94
|
+
assert.ok(buildTriageQuestions().action);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe("tocket suite triage", () => {
|
|
98
|
+
const tempDir = mkdtempSync(join(tmpdir(), "tocket-suite-triage-"));
|
|
99
|
+
after(() => {
|
|
100
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
101
|
+
});
|
|
102
|
+
it("dry-run writes <app>.triage.json without TYPESAFE_API_KEY", async () => {
|
|
103
|
+
const incoming = join(tempDir, "last-run.json");
|
|
104
|
+
copyFileSync(lastRunFixture, incoming);
|
|
105
|
+
const result = runCli(["suite", "triage", "--from", incoming, "--include-low-confidence", "--dry-run"], tempDir);
|
|
106
|
+
assert.equal(result.status, 0, result.stderr);
|
|
107
|
+
assert.match(result.stdout, /AppMap triage/);
|
|
108
|
+
assert.match(result.stdout, /mode: dry-run/);
|
|
109
|
+
const outPath = join(tempDir, ".context", "appmaps", "tempestivita.triage.json");
|
|
110
|
+
assert.ok(existsSync(outPath));
|
|
111
|
+
const report = parseTriageReport(readFileSync(outPath, "utf-8"));
|
|
112
|
+
assert.equal(report.schema, "tocket.appmaps.triage/v0");
|
|
113
|
+
assert.equal(report.app, "tempestivita");
|
|
114
|
+
assert.equal(report.mode, "dry-run");
|
|
115
|
+
assert.ok(report.cases.some((item) => item.id === "T-locator-missing" && item.choice === "rewrite-locator"));
|
|
116
|
+
assert.ok(report.cases.some((item) => item.id === "T-lowconf-pass" && item.choice === "ignore"));
|
|
117
|
+
assert.ok(!report.cases.some((item) => item.id === "T-highconf-pass"));
|
|
118
|
+
});
|
|
119
|
+
it("heuristic runTriage is stable across two calls", async () => {
|
|
120
|
+
const cwd = join(tempDir, "stable");
|
|
121
|
+
mkdirSync(cwd, { recursive: true });
|
|
122
|
+
const incoming = join(cwd, "last-run.json");
|
|
123
|
+
copyFileSync(lastRunFixture, incoming);
|
|
124
|
+
const first = await runTriage({
|
|
125
|
+
fromPath: incoming,
|
|
126
|
+
cwd,
|
|
127
|
+
includeLowConfidence: true,
|
|
128
|
+
dryRun: true,
|
|
129
|
+
now: () => "2026-09-19T00:00:00.000Z",
|
|
130
|
+
});
|
|
131
|
+
const second = await runTriage({
|
|
132
|
+
fromPath: incoming,
|
|
133
|
+
cwd,
|
|
134
|
+
includeLowConfidence: true,
|
|
135
|
+
dryRun: true,
|
|
136
|
+
now: () => "2026-09-19T00:00:00.000Z",
|
|
137
|
+
});
|
|
138
|
+
assert.deepEqual(first.report.cases.map((item) => item.choice), second.report.cases.map((item) => item.choice));
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
describe("POC C eval", () => {
|
|
142
|
+
it("reports agreement, naive baseline, and stability", () => {
|
|
143
|
+
const result = evaluateTriage(lastRunFixture, expectedFixture);
|
|
144
|
+
assert.equal(result.total, 15);
|
|
145
|
+
assert.ok(result.agreement >= 0.8, `agreement ${result.agreement}`);
|
|
146
|
+
assert.ok(result.agreement > result.naiveAgreement);
|
|
147
|
+
assert.ok(result.agreement > result.chance);
|
|
148
|
+
assert.ok(result.unstableRate < 0.3);
|
|
149
|
+
assert.equal(result.verdict, "PASS");
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
//# sourceMappingURL=triage.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triage.test.js","sourceRoot":"","sources":["../../src/tests/triage.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EACL,WAAW,EACX,MAAM,EACN,SAAS,EACT,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oB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,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,IAAI,GAAG,EAAE,aAAa,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QACpE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;QACpD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { describe, it, after } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync, existsSync, copyFileSync, utimesSync, } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import { DECIDE_SCHEMA } from "../utils/decide.js";
|
|
8
|
+
import { WORK_APPLIED_SCHEMA, WorkError, appliedReceiptPath, findLatestQueueDecision, formatWorkProgressLine, isShadowDecision, loadDecision, runWork, } from "../utils/work.js";
|
|
9
|
+
import { parseDecideRecord } from "../utils/decide.js";
|
|
10
|
+
const cliPath = join(import.meta.dirname, "..", "index.js");
|
|
11
|
+
const fixturesDir = join(import.meta.dirname, "..", "..", "fixtures", "work");
|
|
12
|
+
const handoffFixture = join(fixturesDir, "handoff.json");
|
|
13
|
+
const shadowFixture = join(fixturesDir, "shadow.json");
|
|
14
|
+
const gateAllowFixture = join(fixturesDir, "gate-allow.json");
|
|
15
|
+
const gateBlockFixture = join(fixturesDir, "gate-block.json");
|
|
16
|
+
const gateAskFixture = join(fixturesDir, "gate-ask.json");
|
|
17
|
+
function runCli(args, cwd, env) {
|
|
18
|
+
try {
|
|
19
|
+
const stdout = execFileSync(process.execPath, [cliPath, ...args], {
|
|
20
|
+
cwd,
|
|
21
|
+
encoding: "utf-8",
|
|
22
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
23
|
+
env: { ...process.env, TYPESAFE_API_KEY: "", ...env },
|
|
24
|
+
});
|
|
25
|
+
return { stdout, stderr: "", status: 0 };
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
const failed = err;
|
|
29
|
+
return {
|
|
30
|
+
stdout: failed.stdout ?? "",
|
|
31
|
+
stderr: failed.stderr ?? "",
|
|
32
|
+
status: failed.status ?? 1,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
describe("work helpers", () => {
|
|
37
|
+
it("treats log-only / shadow / dry-run as shadow, not executes=false alone", () => {
|
|
38
|
+
const handoff = parseDecideRecord(readFileSync(handoffFixture, "utf-8"));
|
|
39
|
+
const shadow = parseDecideRecord(readFileSync(shadowFixture, "utf-8"));
|
|
40
|
+
assert.equal(handoff.executes, false);
|
|
41
|
+
assert.equal(isShadowDecision(handoff), false);
|
|
42
|
+
assert.equal(isShadowDecision(shadow), true);
|
|
43
|
+
assert.equal(isShadowDecision({ ...handoff, mode: "dry-run", semantics: "log-only" }), true);
|
|
44
|
+
assert.equal(appliedReceiptPath("/tmp/20260920T150130Z-next.json"), "/tmp/20260920T150130Z-next.applied.json");
|
|
45
|
+
assert.throws(() => appliedReceiptPath("/tmp/x.applied.json"), /receipt file/);
|
|
46
|
+
});
|
|
47
|
+
it("formats the progress line from the choice", () => {
|
|
48
|
+
const record = parseDecideRecord(readFileSync(handoffFixture, "utf-8"));
|
|
49
|
+
assert.equal(formatWorkProgressLine(record), "- worker applied: next=write dest=write confidence=0.91");
|
|
50
|
+
const shadow = parseDecideRecord(readFileSync(shadowFixture, "utf-8"));
|
|
51
|
+
assert.match(formatWorkProgressLine(shadow), /next=write dest=review confidence=0.78 gated/);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe("tocket work help", () => {
|
|
55
|
+
it("frames the reference worker and never-Jev rule", () => {
|
|
56
|
+
const result = runCli(["work", "--help"], process.cwd());
|
|
57
|
+
assert.equal(result.status, 0, result.stderr);
|
|
58
|
+
assert.match(result.stdout, /Never calls Jev/i);
|
|
59
|
+
assert.match(result.stdout, /TypeSafe/);
|
|
60
|
+
assert.match(result.stdout, /--apply/);
|
|
61
|
+
assert.match(result.stdout, /--force/);
|
|
62
|
+
assert.match(result.stdout, /2 refuse/);
|
|
63
|
+
assert.match(result.stdout, /does not re-decide/i);
|
|
64
|
+
assert.match(result.stdout, /tool_gate/);
|
|
65
|
+
assert.match(result.stdout, /escalate\/human/);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("tocket work", () => {
|
|
69
|
+
const tempDir = mkdtempSync(join(tmpdir(), "tocket-work-"));
|
|
70
|
+
after(() => {
|
|
71
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
72
|
+
});
|
|
73
|
+
it("dry-runs a fixture without writing or calling Jev", () => {
|
|
74
|
+
const cwd = join(tempDir, "dry");
|
|
75
|
+
mkdirSync(cwd, { recursive: true });
|
|
76
|
+
const result = runWork({
|
|
77
|
+
cwd,
|
|
78
|
+
fromPath: handoffFixture,
|
|
79
|
+
apply: false,
|
|
80
|
+
});
|
|
81
|
+
assert.equal(result.applied, false);
|
|
82
|
+
assert.equal(result.plan.record.schema, DECIDE_SCHEMA);
|
|
83
|
+
assert.equal(result.plan.record.choice, "write");
|
|
84
|
+
assert.equal(result.plan.record.destination, "write");
|
|
85
|
+
assert.equal(result.plan.shadow, false);
|
|
86
|
+
assert.match(result.summary, /work plan/);
|
|
87
|
+
assert.match(result.summary, /choice=write/);
|
|
88
|
+
assert.match(result.summary, /dest=write/);
|
|
89
|
+
assert.match(result.summary, /confidence=0.91/);
|
|
90
|
+
assert.match(result.summary, /semantics=handoff/);
|
|
91
|
+
assert.equal(existsSync(appliedReceiptPath(handoffFixture)), false);
|
|
92
|
+
assert.equal(existsSync(join(cwd, ".context", "progress.md")), false);
|
|
93
|
+
const cli = runCli(["work", "--from", handoffFixture], cwd, {
|
|
94
|
+
TYPESAFE_API_KEY: "must-not-be-used",
|
|
95
|
+
});
|
|
96
|
+
assert.equal(cli.status, 0, cli.stderr);
|
|
97
|
+
assert.match(cli.stdout, /work plan/);
|
|
98
|
+
assert.match(cli.stdout, /choice=write/);
|
|
99
|
+
assert.match(cli.stdout, /dest=write/);
|
|
100
|
+
assert.equal(existsSync(appliedReceiptPath(handoffFixture)), false);
|
|
101
|
+
});
|
|
102
|
+
it("applies a non-shadow fixture into a notebook receipt and progress line", () => {
|
|
103
|
+
const cwd = join(tempDir, "apply");
|
|
104
|
+
const destDir = join(cwd, ".context", "decisions", "write");
|
|
105
|
+
mkdirSync(destDir, { recursive: true });
|
|
106
|
+
const decision = join(destDir, "20260920T150130Z-next.json");
|
|
107
|
+
copyFileSync(handoffFixture, decision);
|
|
108
|
+
const result = runWork({
|
|
109
|
+
cwd,
|
|
110
|
+
fromPath: decision,
|
|
111
|
+
apply: true,
|
|
112
|
+
now: () => "2026-09-20T16:00:00.000Z",
|
|
113
|
+
});
|
|
114
|
+
assert.equal(result.applied, true);
|
|
115
|
+
assert.ok(result.receipt);
|
|
116
|
+
assert.equal(result.receipt.schema, WORK_APPLIED_SCHEMA);
|
|
117
|
+
assert.equal(result.receipt.choice, "write");
|
|
118
|
+
assert.equal(result.receipt.destination, "write");
|
|
119
|
+
assert.equal(result.receipt.applied_from_shadow, false);
|
|
120
|
+
assert.equal(result.receipt.applied_at, "2026-09-20T16:00:00.000Z");
|
|
121
|
+
assert.ok(result.receiptPath?.endsWith("20260920T150130Z-next.applied.json"));
|
|
122
|
+
assert.ok(existsSync(result.receiptPath));
|
|
123
|
+
const progress = readFileSync(join(cwd, ".context", "progress.md"), "utf-8");
|
|
124
|
+
assert.match(progress, /worker applied: next=write dest=write confidence=0.91/);
|
|
125
|
+
const cliCwd = join(tempDir, "apply-cli");
|
|
126
|
+
mkdirSync(join(cliCwd, ".context", "decisions", "write"), { recursive: true });
|
|
127
|
+
const cliDecision = join(cliCwd, ".context", "decisions", "write", "20260920T150130Z-next.json");
|
|
128
|
+
copyFileSync(handoffFixture, cliDecision);
|
|
129
|
+
const cliResult = runCli(["work", "--from", cliDecision, "--apply"], cliCwd);
|
|
130
|
+
assert.equal(cliResult.status, 0, cliResult.stderr);
|
|
131
|
+
assert.match(cliResult.stdout, /work applied/);
|
|
132
|
+
assert.ok(existsSync(appliedReceiptPath(cliDecision)));
|
|
133
|
+
assert.match(readFileSync(join(cliCwd, ".context", "progress.md"), "utf-8"), /worker applied: next=write/);
|
|
134
|
+
});
|
|
135
|
+
it("dry-runs shadow and refuses apply without --force (exit 2)", () => {
|
|
136
|
+
const cwd = join(tempDir, "shadow");
|
|
137
|
+
mkdirSync(cwd, { recursive: true });
|
|
138
|
+
const plan = runWork({ cwd, fromPath: shadowFixture });
|
|
139
|
+
assert.equal(plan.applied, false);
|
|
140
|
+
assert.equal(plan.plan.shadow, true);
|
|
141
|
+
assert.equal(plan.plan.wouldRefuse, true);
|
|
142
|
+
assert.match(plan.summary, /apply=refuse/);
|
|
143
|
+
const refused = runCli(["work", "--from", shadowFixture, "--apply"], cwd);
|
|
144
|
+
assert.equal(refused.status, 2);
|
|
145
|
+
assert.match(refused.stderr, /shadow\/log-only/);
|
|
146
|
+
assert.equal(existsSync(appliedReceiptPath(shadowFixture)), false);
|
|
147
|
+
assert.equal(existsSync(join(cwd, ".context", "progress.md")), false);
|
|
148
|
+
assert.throws(() => runWork({ cwd, fromPath: shadowFixture, apply: true }), (err) => err instanceof WorkError && err.exitCode === 2);
|
|
149
|
+
});
|
|
150
|
+
it("applies shadow only with --force and stamps applied_from_shadow", () => {
|
|
151
|
+
const cwd = join(tempDir, "shadow-force");
|
|
152
|
+
const destDir = join(cwd, ".context", "decisions", "review");
|
|
153
|
+
mkdirSync(destDir, { recursive: true });
|
|
154
|
+
const decision = join(destDir, "20260920T150000Z-next.json");
|
|
155
|
+
copyFileSync(shadowFixture, decision);
|
|
156
|
+
const result = runWork({
|
|
157
|
+
cwd,
|
|
158
|
+
fromPath: decision,
|
|
159
|
+
apply: true,
|
|
160
|
+
force: true,
|
|
161
|
+
now: () => "2026-09-20T16:05:00.000Z",
|
|
162
|
+
});
|
|
163
|
+
assert.equal(result.applied, true);
|
|
164
|
+
assert.equal(result.receipt.applied_from_shadow, true);
|
|
165
|
+
assert.equal(result.receipt.forced, true);
|
|
166
|
+
assert.match(result.summary, /applied_from_shadow/);
|
|
167
|
+
const receipt = JSON.parse(readFileSync(result.receiptPath, "utf-8"));
|
|
168
|
+
assert.equal(receipt.applied_from_shadow, true);
|
|
169
|
+
});
|
|
170
|
+
it("defaults to the newest queue decision and skips receipts", () => {
|
|
171
|
+
const cwd = join(tempDir, "latest");
|
|
172
|
+
const writeDir = join(cwd, ".context", "decisions", "write");
|
|
173
|
+
const reviewDir = join(cwd, ".context", "decisions", "review");
|
|
174
|
+
mkdirSync(writeDir, { recursive: true });
|
|
175
|
+
mkdirSync(reviewDir, { recursive: true });
|
|
176
|
+
const older = join(reviewDir, "20260920T140000Z-next.json");
|
|
177
|
+
const newer = join(writeDir, "20260920T150130Z-next.json");
|
|
178
|
+
const receipt = join(writeDir, "20260920T160000Z-next.applied.json");
|
|
179
|
+
copyFileSync(shadowFixture, older);
|
|
180
|
+
copyFileSync(handoffFixture, newer);
|
|
181
|
+
writeFileSync(receipt, "{\"schema\":\"tocket.work.applied/v0\"}\n", "utf-8");
|
|
182
|
+
const past = new Date("2026-09-20T14:00:00Z");
|
|
183
|
+
const later = new Date("2026-09-20T15:01:30Z");
|
|
184
|
+
const newestReceipt = new Date("2026-09-20T16:00:00Z");
|
|
185
|
+
utimesSync(older, past, past);
|
|
186
|
+
utimesSync(newer, later, later);
|
|
187
|
+
utimesSync(receipt, newestReceipt, newestReceipt);
|
|
188
|
+
assert.equal(findLatestQueueDecision(cwd), newer);
|
|
189
|
+
const loaded = loadDecision(cwd);
|
|
190
|
+
assert.equal(loaded.path, newer);
|
|
191
|
+
assert.equal(loaded.record.choice, "write");
|
|
192
|
+
assert.equal(loaded.record.semantics, "handoff");
|
|
193
|
+
const cli = runCli(["work"], cwd);
|
|
194
|
+
assert.equal(cli.status, 0, cli.stderr);
|
|
195
|
+
assert.match(cli.stdout, /from=.*write\/20260920T150130Z-next\.json/);
|
|
196
|
+
});
|
|
197
|
+
it("applies allow and no-gate; refuses block/ask unless --force", () => {
|
|
198
|
+
const cwd = join(tempDir, "gate");
|
|
199
|
+
mkdirSync(cwd, { recursive: true });
|
|
200
|
+
const allowPlan = runWork({ cwd, fromPath: gateAllowFixture });
|
|
201
|
+
assert.equal(allowPlan.applied, false);
|
|
202
|
+
assert.equal(allowPlan.plan.toolGate, "allow");
|
|
203
|
+
assert.equal(allowPlan.plan.wouldRefuse, false);
|
|
204
|
+
assert.match(allowPlan.summary, /tool_gate=allow/);
|
|
205
|
+
assert.match(allowPlan.summary, /apply=ok/);
|
|
206
|
+
const allowDir = join(cwd, "allow", ".context", "decisions", "review");
|
|
207
|
+
mkdirSync(allowDir, { recursive: true });
|
|
208
|
+
const allowDecision = join(allowDir, "20260921T001000Z-tool_gate.json");
|
|
209
|
+
copyFileSync(gateAllowFixture, allowDecision);
|
|
210
|
+
const allowed = runWork({
|
|
211
|
+
cwd: join(cwd, "allow"),
|
|
212
|
+
fromPath: allowDecision,
|
|
213
|
+
apply: true,
|
|
214
|
+
now: () => "2026-09-21T00:30:00.000Z",
|
|
215
|
+
});
|
|
216
|
+
assert.equal(allowed.applied, true);
|
|
217
|
+
assert.equal(allowed.receipt.tool_gate, "allow");
|
|
218
|
+
assert.equal(existsSync(appliedReceiptPath(allowDecision)), true);
|
|
219
|
+
const blocked = runCli(["work", "--from", gateBlockFixture, "--apply"], cwd);
|
|
220
|
+
assert.equal(blocked.status, 2);
|
|
221
|
+
assert.match(blocked.stderr, /tool_gate=block/);
|
|
222
|
+
assert.equal(existsSync(appliedReceiptPath(gateBlockFixture)), false);
|
|
223
|
+
const asked = runCli(["work", "--from", gateAskFixture, "--apply"], cwd);
|
|
224
|
+
assert.equal(asked.status, 2);
|
|
225
|
+
assert.match(asked.stderr, /tool_gate=ask/);
|
|
226
|
+
assert.match(asked.stderr, /Escalate to a human/);
|
|
227
|
+
assert.equal(existsSync(appliedReceiptPath(gateAskFixture)), false);
|
|
228
|
+
const askDir = join(cwd, "ask-force", ".context", "decisions", "review");
|
|
229
|
+
mkdirSync(askDir, { recursive: true });
|
|
230
|
+
const askDecision = join(askDir, "20260921T001200Z-tool_gate.json");
|
|
231
|
+
copyFileSync(gateAskFixture, askDecision);
|
|
232
|
+
const forced = runWork({
|
|
233
|
+
cwd: join(cwd, "ask-force"),
|
|
234
|
+
fromPath: askDecision,
|
|
235
|
+
apply: true,
|
|
236
|
+
force: true,
|
|
237
|
+
now: () => "2026-09-21T00:31:00.000Z",
|
|
238
|
+
});
|
|
239
|
+
assert.equal(forced.applied, true);
|
|
240
|
+
assert.equal(forced.receipt.tool_gate, "ask");
|
|
241
|
+
assert.equal(forced.receipt.forced, true);
|
|
242
|
+
assert.throws(() => runWork({ cwd, fromPath: gateBlockFixture, apply: true }), (err) => err instanceof WorkError && err.exitCode === 2);
|
|
243
|
+
});
|
|
244
|
+
it("still requires --force to apply a shadow allow", () => {
|
|
245
|
+
const cwd = join(tempDir, "shadow-allow");
|
|
246
|
+
mkdirSync(cwd, { recursive: true });
|
|
247
|
+
const destDir = join(cwd, ".context", "decisions", "review");
|
|
248
|
+
mkdirSync(destDir, { recursive: true });
|
|
249
|
+
const decision = join(destDir, "20260921T001000Z-tool_gate.json");
|
|
250
|
+
const shadowAllow = JSON.parse(readFileSync(gateAllowFixture, "utf-8"));
|
|
251
|
+
shadowAllow.mode = "shadow";
|
|
252
|
+
shadowAllow.semantics = "log-only";
|
|
253
|
+
shadowAllow.status = "logged";
|
|
254
|
+
writeFileSync(decision, `${JSON.stringify(shadowAllow, null, 2)}\n`, "utf-8");
|
|
255
|
+
const refused = runCli(["work", "--from", decision, "--apply"], cwd);
|
|
256
|
+
assert.equal(refused.status, 2);
|
|
257
|
+
assert.match(refused.stderr, /shadow\/log-only/);
|
|
258
|
+
assert.equal(existsSync(appliedReceiptPath(decision)), false);
|
|
259
|
+
});
|
|
260
|
+
it("exits 1 for a missing or invalid decision", () => {
|
|
261
|
+
const cwd = join(tempDir, "errors");
|
|
262
|
+
mkdirSync(cwd, { recursive: true });
|
|
263
|
+
const missing = runCli(["work"], cwd);
|
|
264
|
+
assert.equal(missing.status, 1);
|
|
265
|
+
assert.match(missing.stderr, /No decision found|--from/);
|
|
266
|
+
const gone = runCli(["work", "--from", join(cwd, "missing.json")], cwd);
|
|
267
|
+
assert.equal(gone.status, 1);
|
|
268
|
+
assert.match(gone.stderr, /not found/);
|
|
269
|
+
const bad = join(cwd, "bad.json");
|
|
270
|
+
writeFileSync(bad, "{\"no\":\"schema\"}\n", "utf-8");
|
|
271
|
+
const invalid = runCli(["work", "--from", bad], cwd);
|
|
272
|
+
assert.equal(invalid.status, 1);
|
|
273
|
+
assert.match(invalid.stderr, /Invalid decision record/);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
//# sourceMappingURL=work.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work.test.js","sourceRoot":"","sources":["../../src/tests/work.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EACL,WAAW,EACX,MAAM,EACN,SAAS,EACT,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAA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CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;QAEzD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACxE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAEvC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAClC,aAAa,CAAC,GAAG,EAAE,uBAAuB,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/utils/agents.d.ts
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
export declare const DEFAULT_EXECUTOR = "Claude Code";
|
|
2
2
|
export declare const DEFAULT_ARCHITECT = "Gemini";
|
|
3
|
+
export declare const EXECUTOR_CHOICES: readonly ["Claude Code", "Cursor", "Windsurf", "Copilot"];
|
|
4
|
+
export declare const ARCHITECT_CHOICES: readonly ["Gemini"];
|
|
3
5
|
export declare const EXECUTOR_FILE_MAP: Record<string, string>;
|
|
4
6
|
export declare const ARCHITECT_FILE_MAP: Record<string, string>;
|
|
5
7
|
export declare function getExecutorFileName(agentName?: string): string;
|
|
6
8
|
export declare function getArchitectFileName(agentName?: string): string;
|
|
7
9
|
export declare function getExecutorDisplayName(agentName?: string): string;
|
|
8
10
|
export declare function getArchitectDisplayName(agentName?: string): string;
|
|
11
|
+
export type AgentDetectSource = "flag" | "config" | "file" | "env" | "default";
|
|
12
|
+
export interface DetectedAgents {
|
|
13
|
+
executor?: string;
|
|
14
|
+
architect?: string;
|
|
15
|
+
executorSource: "file" | "env" | "none";
|
|
16
|
+
architectSource: "file" | "env" | "none";
|
|
17
|
+
}
|
|
18
|
+
/** Case-insensitive env lookup so Windows spawn/casing still detects Cursor / Claude. */
|
|
19
|
+
export declare function envFlag(env: NodeJS.ProcessEnv, name: string): boolean;
|
|
20
|
+
/** Detect preferred agents from existing instruction files or env (Cursor / Claude). */
|
|
21
|
+
export declare function detectPreferredAgents(cwd: string, env?: NodeJS.ProcessEnv): DetectedAgents;
|
|
22
|
+
export declare function resolveInitAgents(input: {
|
|
23
|
+
executorFlag?: string;
|
|
24
|
+
architectFlag?: string;
|
|
25
|
+
configExecutor?: string;
|
|
26
|
+
configArchitect?: string;
|
|
27
|
+
detected: DetectedAgents;
|
|
28
|
+
}): {
|
|
29
|
+
executor: string;
|
|
30
|
+
architect: string;
|
|
31
|
+
executorSource: AgentDetectSource;
|
|
32
|
+
architectSource: AgentDetectSource;
|
|
33
|
+
};
|
package/dist/utils/agents.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
1
3
|
export const DEFAULT_EXECUTOR = "Claude Code";
|
|
2
4
|
export const DEFAULT_ARCHITECT = "Gemini";
|
|
5
|
+
export const EXECUTOR_CHOICES = ["Claude Code", "Cursor", "Windsurf", "Copilot"];
|
|
6
|
+
export const ARCHITECT_CHOICES = ["Gemini"];
|
|
3
7
|
export const EXECUTOR_FILE_MAP = {
|
|
4
8
|
"claude code": "CLAUDE.md",
|
|
5
9
|
"claude": "CLAUDE.md",
|
|
@@ -26,4 +30,92 @@ export function getExecutorDisplayName(agentName) {
|
|
|
26
30
|
export function getArchitectDisplayName(agentName) {
|
|
27
31
|
return agentName || DEFAULT_ARCHITECT;
|
|
28
32
|
}
|
|
33
|
+
const EXECUTOR_FILE_HINTS = [
|
|
34
|
+
{ file: ".cursorrules", agent: "Cursor" },
|
|
35
|
+
{ file: ".github/copilot-instructions.md", agent: "Copilot" },
|
|
36
|
+
{ file: ".windsurfrules", agent: "Windsurf" },
|
|
37
|
+
{ file: "CLAUDE.md", agent: "Claude Code" },
|
|
38
|
+
];
|
|
39
|
+
/** Case-insensitive env lookup so Windows spawn/casing still detects Cursor / Claude. */
|
|
40
|
+
export function envFlag(env, name) {
|
|
41
|
+
const want = name.toUpperCase();
|
|
42
|
+
for (const [key, value] of Object.entries(env)) {
|
|
43
|
+
if (key.toUpperCase() === want) {
|
|
44
|
+
return Boolean(value && value.trim());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
/** Detect preferred agents from existing instruction files or env (Cursor / Claude). */
|
|
50
|
+
export function detectPreferredAgents(cwd, env = process.env) {
|
|
51
|
+
let executor;
|
|
52
|
+
let architect;
|
|
53
|
+
let executorSource = "none";
|
|
54
|
+
let architectSource = "none";
|
|
55
|
+
for (const hint of EXECUTOR_FILE_HINTS) {
|
|
56
|
+
if (existsSync(join(cwd, hint.file))) {
|
|
57
|
+
executor = hint.agent;
|
|
58
|
+
executorSource = "file";
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (existsSync(join(cwd, "GEMINI.md"))) {
|
|
63
|
+
architect = "Gemini";
|
|
64
|
+
architectSource = "file";
|
|
65
|
+
}
|
|
66
|
+
if (!executor) {
|
|
67
|
+
if (envFlag(env, "CURSOR_TRACE_ID") || envFlag(env, "CURSOR_AGENT") || envFlag(env, "CURSOR")) {
|
|
68
|
+
executor = "Cursor";
|
|
69
|
+
executorSource = "env";
|
|
70
|
+
}
|
|
71
|
+
else if (envFlag(env, "CLAUDECODE") || envFlag(env, "CLAUDE_CODE")) {
|
|
72
|
+
executor = "Claude Code";
|
|
73
|
+
executorSource = "env";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { executor, architect, executorSource, architectSource };
|
|
77
|
+
}
|
|
78
|
+
export function resolveInitAgents(input) {
|
|
79
|
+
const executorFlag = input.executorFlag?.trim();
|
|
80
|
+
const architectFlag = input.architectFlag?.trim();
|
|
81
|
+
const configExecutor = input.configExecutor?.trim();
|
|
82
|
+
const configArchitect = input.configArchitect?.trim();
|
|
83
|
+
let executor;
|
|
84
|
+
let executorSource;
|
|
85
|
+
if (executorFlag) {
|
|
86
|
+
executor = executorFlag;
|
|
87
|
+
executorSource = "flag";
|
|
88
|
+
}
|
|
89
|
+
else if (configExecutor) {
|
|
90
|
+
executor = configExecutor;
|
|
91
|
+
executorSource = "config";
|
|
92
|
+
}
|
|
93
|
+
else if (input.detected.executor) {
|
|
94
|
+
executor = input.detected.executor;
|
|
95
|
+
executorSource = input.detected.executorSource === "env" ? "env" : "file";
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
executor = DEFAULT_EXECUTOR;
|
|
99
|
+
executorSource = "default";
|
|
100
|
+
}
|
|
101
|
+
let architect;
|
|
102
|
+
let architectSource;
|
|
103
|
+
if (architectFlag) {
|
|
104
|
+
architect = architectFlag;
|
|
105
|
+
architectSource = "flag";
|
|
106
|
+
}
|
|
107
|
+
else if (configArchitect) {
|
|
108
|
+
architect = configArchitect;
|
|
109
|
+
architectSource = "config";
|
|
110
|
+
}
|
|
111
|
+
else if (input.detected.architect) {
|
|
112
|
+
architect = input.detected.architect;
|
|
113
|
+
architectSource = input.detected.architectSource === "env" ? "env" : "file";
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
architect = DEFAULT_ARCHITECT;
|
|
117
|
+
architectSource = "default";
|
|
118
|
+
}
|
|
119
|
+
return { executor, architect, executorSource, architectSource };
|
|
120
|
+
}
|
|
29
121
|
//# sourceMappingURL=agents.js.map
|
package/dist/utils/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/utils/agents.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/utils/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAU,CAAC;AAC1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAQ,CAAU,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAA2B;IACvD,aAAa,EAAE,WAAW;IAC1B,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,cAAc;IACxB,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,iCAAiC;CAC7C,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACxD,QAAQ,EAAE,WAAW;CACtB,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,SAAkB;IAC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