@ddtcorex/dsh-maestro-review 0.1.0 → 0.1.1
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/lib/config-store.d.ts +2 -0
- package/lib/config-store.d.ts.map +1 -1
- package/lib/config-store.js.map +1 -1
- package/lib/git-worktree-tool.d.ts +11 -0
- package/lib/git-worktree-tool.d.ts.map +1 -0
- package/lib/git-worktree-tool.js +162 -0
- package/lib/git-worktree-tool.js.map +1 -0
- package/lib/govard-audit-lint-tool.d.ts +14 -0
- package/lib/govard-audit-lint-tool.d.ts.map +1 -0
- package/lib/govard-audit-lint-tool.js +171 -0
- package/lib/govard-audit-lint-tool.js.map +1 -0
- package/lib/hyva-csp-scan-tool.d.ts +11 -0
- package/lib/hyva-csp-scan-tool.d.ts.map +1 -0
- package/lib/hyva-csp-scan-tool.js +193 -0
- package/lib/hyva-csp-scan-tool.js.map +1 -0
- package/lib/hyva-theme-inspect-tool.d.ts +10 -0
- package/lib/hyva-theme-inspect-tool.d.ts.map +1 -0
- package/lib/hyva-theme-inspect-tool.js +299 -0
- package/lib/hyva-theme-inspect-tool.js.map +1 -0
- package/lib/incremental.d.ts +28 -0
- package/lib/incremental.d.ts.map +1 -0
- package/lib/incremental.js +60 -0
- package/lib/incremental.js.map +1 -0
- package/lib/layout-xml-tool.d.ts +11 -0
- package/lib/layout-xml-tool.d.ts.map +1 -0
- package/lib/layout-xml-tool.js +240 -0
- package/lib/layout-xml-tool.js.map +1 -0
- package/lib/module-check-tool.d.ts +11 -0
- package/lib/module-check-tool.d.ts.map +1 -0
- package/lib/module-check-tool.js +304 -0
- package/lib/module-check-tool.js.map +1 -0
- package/lib/orchestrator.d.ts +2 -0
- package/lib/orchestrator.d.ts.map +1 -1
- package/lib/orchestrator.js +203 -78
- package/lib/orchestrator.js.map +1 -1
- package/lib/perf-log-stats-tool.d.ts +13 -0
- package/lib/perf-log-stats-tool.d.ts.map +1 -0
- package/lib/perf-log-stats-tool.js +245 -0
- package/lib/perf-log-stats-tool.js.map +1 -0
- package/lib/phtml-escape-scan-tool.d.ts +11 -0
- package/lib/phtml-escape-scan-tool.d.ts.map +1 -0
- package/lib/phtml-escape-scan-tool.js +170 -0
- package/lib/phtml-escape-scan-tool.js.map +1 -0
- package/lib/plan-track-tool.d.ts +11 -0
- package/lib/plan-track-tool.d.ts.map +1 -0
- package/lib/plan-track-tool.js +143 -0
- package/lib/plan-track-tool.js.map +1 -0
- package/lib/review-history.d.ts +4 -0
- package/lib/review-history.d.ts.map +1 -1
- package/lib/review-history.js +4 -0
- package/lib/review-history.js.map +1 -1
- package/lib/scope-split-tool.d.ts +42 -0
- package/lib/scope-split-tool.d.ts.map +1 -0
- package/lib/scope-split-tool.js +109 -0
- package/lib/scope-split-tool.js.map +1 -0
- package/lib/search-tool.d.ts +15 -0
- package/lib/search-tool.d.ts.map +1 -0
- package/lib/search-tool.js +144 -0
- package/lib/search-tool.js.map +1 -0
- package/lib/settings-rpc.d.ts.map +1 -1
- package/lib/settings-rpc.js +47 -8
- package/lib/settings-rpc.js.map +1 -1
- package/lib/skills-tool.d.ts +1 -1
- package/lib/skills-tool.d.ts.map +1 -1
- package/lib/skills-tool.js +5 -1
- package/lib/skills-tool.js.map +1 -1
- package/lib/tdd-evidence-tool.d.ts +11 -0
- package/lib/tdd-evidence-tool.d.ts.map +1 -0
- package/lib/tdd-evidence-tool.js +114 -0
- package/lib/tdd-evidence-tool.js.map +1 -0
- package/lib/tool-policy.d.ts +20 -0
- package/lib/tool-policy.d.ts.map +1 -0
- package/lib/tool-policy.js +42 -0
- package/lib/tool-policy.js.map +1 -0
- package/lib/workspace-tool.d.ts.map +1 -1
- package/lib/workspace-tool.js +15 -9
- package/lib/workspace-tool.js.map +1 -1
- package/package.json +3 -2
- package/src/augment.d.ts +4 -0
- package/src/config-store.ts +2 -0
- package/src/git-worktree-tool.ts +130 -0
- package/src/govard-audit-lint-tool.ts +147 -0
- package/src/hyva-csp-scan-tool.ts +165 -0
- package/src/hyva-theme-inspect-tool.ts +258 -0
- package/src/incremental.ts +84 -0
- package/src/layout-xml-tool.ts +191 -0
- package/src/module-check-tool.ts +188 -0
- package/src/orchestrator.ts +189 -75
- package/src/perf-log-stats-tool.ts +224 -0
- package/src/phtml-escape-scan-tool.ts +117 -0
- package/src/plan-track-tool.ts +118 -0
- package/src/review-history.ts +8 -0
- package/src/scope-split-tool.ts +110 -0
- package/src/search-tool.ts +153 -0
- package/src/settings-rpc.ts +53 -10
- package/src/skills-tool.ts +5 -1
- package/src/tdd-evidence-tool.ts +85 -0
- package/src/tool-policy.ts +49 -0
- package/src/workspace-tool.ts +27 -9
- package/lib/pin-store.d.ts +0 -5
- package/lib/pin-store.d.ts.map +0 -1
- package/lib/pin-store.js +0 -5
- package/lib/pin-store.js.map +0 -1
- package/src/pin-store.ts +0 -4
package/lib/skills-tool.js
CHANGED
|
@@ -10,6 +10,10 @@ export const REVIEW_PROFILE_SKILLS = {
|
|
|
10
10
|
'govard-toolbox',
|
|
11
11
|
'govard-magento',
|
|
12
12
|
'magento2-dev-core',
|
|
13
|
+
// Frontend passes: without these a Hyvä/Tailwind MR is reviewed on model
|
|
14
|
+
// priors alone (utility-class claims were unverifiable and wrong in practice).
|
|
15
|
+
'magento2-frontend-dev',
|
|
16
|
+
'magento2-hyva-dev',
|
|
13
17
|
'magento2-code-review',
|
|
14
18
|
'magento2-linter',
|
|
15
19
|
'magento2-security-scan',
|
|
@@ -18,7 +22,7 @@ export const REVIEW_PROFILE_SKILLS = {
|
|
|
18
22
|
/** Diff review against general best practices; no project skill set required. */
|
|
19
23
|
generic: [],
|
|
20
24
|
};
|
|
21
|
-
export const MAESTRO_SKILLS_INSTALL_COMMAND = 'curl -fsSL https://raw.githubusercontent.com/ddtcorex/maestro-skills/master/install.sh | bash -s -- --scope personal --target dsh --skills govard-toolbox,govard-magento,magento2-dev-core,magento2-code-review,magento2-linter,magento2-security-scan,magento2-performance-audit -y';
|
|
25
|
+
export const MAESTRO_SKILLS_INSTALL_COMMAND = 'curl -fsSL https://raw.githubusercontent.com/ddtcorex/maestro-skills/master/install.sh | bash -s -- --scope personal --target dsh --skills govard-toolbox,govard-magento,magento2-dev-core,magento2-frontend-dev,magento2-hyva-dev,magento2-code-review,magento2-linter,magento2-security-scan,magento2-performance-audit -y';
|
|
22
26
|
// This is deliberately process-local and keyed by the reviewer Agent object,
|
|
23
27
|
// which every Cordis child context inherits. Preset mounting inserts child
|
|
24
28
|
// contexts, so keying on the plugin's context would make a successful load
|
package/lib/skills-tool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills-tool.js","sourceRoot":"","sources":["../src/skills-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGnD,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAA;AACzC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AAIzC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAkD;IAClF,QAAQ,EAAE;QACR,gBAAgB;QAChB,gBAAgB;QAChB,mBAAmB;QACnB,sBAAsB;QACtB,iBAAiB;QACjB,wBAAwB;QACxB,4BAA4B;KAC7B;IACD,iFAAiF;IACjF,OAAO,EAAE,EAAE;CACZ,CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,
|
|
1
|
+
{"version":3,"file":"skills-tool.js","sourceRoot":"","sources":["../src/skills-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGnD,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAA;AACzC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AAIzC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAkD;IAClF,QAAQ,EAAE;QACR,gBAAgB;QA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AO,EAAE,CAAC,CAAC;aAChF,CAAA;QACH,CAAC;KACF,CAAC,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
export declare const name = "maestro-tdd-evidence-tool";
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
export declare const Config: z<{
|
|
6
|
+
rootPath?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function apply(ctx: Context, config?: {
|
|
9
|
+
rootPath?: string;
|
|
10
|
+
}): void;
|
|
11
|
+
//# sourceMappingURL=tdd-evidence-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tdd-evidence-tool.d.ts","sourceRoot":"","sources":["../src/tdd-evidence-tool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,eAAO,MAAM,IAAI,8BAA4B,CAAA;AAC7C,eAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,eAAO,MAAM,MAAM,EAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAC,MAAM,CAAA;CAAC,CAAmC,CAAA;AAY3E,wBAAgB,KAAK,CAAC,GAAG,EAAC,OAAO,EAAE,MAAM,GAAC;IAAC,QAAQ,CAAC,EAAC,MAAM,CAAA;CAAI,GAAE,IAAI,CA8DpE"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { resolve, sep } from 'node:path';
|
|
2
|
+
import { readFile, stat, realpath } from 'node:fs/promises';
|
|
3
|
+
import { execFile } from 'node:child_process';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
6
|
+
import z from '@deepseek-ai/schemastery';
|
|
7
|
+
export const name = 'maestro-tdd-evidence-tool';
|
|
8
|
+
export const inject = ['tools'];
|
|
9
|
+
export const Config = z.object({ rootPath: z.string() });
|
|
10
|
+
function workspaceRootFor(c, e) { if (c !== undefined)
|
|
11
|
+
return c; const cwd = e?.agent?.session?.header?.cwd; return typeof cwd === 'string' && cwd !== '' ? cwd : process.cwd(); }
|
|
12
|
+
async function isInsideRoot(r, t) {
|
|
13
|
+
const ar = resolve(r);
|
|
14
|
+
const rs = resolve(ar, t);
|
|
15
|
+
if (rs !== ar && !rs.startsWith(ar + sep))
|
|
16
|
+
return false;
|
|
17
|
+
try {
|
|
18
|
+
const rr = await realpath(ar);
|
|
19
|
+
const rt = await realpath(rs);
|
|
20
|
+
return rt === rr || rt.startsWith(rr + sep);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
try {
|
|
24
|
+
const rr = await realpath(ar);
|
|
25
|
+
const parent = resolve(rs, '..');
|
|
26
|
+
const rp = await realpath(parent);
|
|
27
|
+
return rp === rr || rp.startsWith(rr + sep);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return rs === ar || rs.startsWith(ar + sep);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const execFileAsync = promisify(execFile);
|
|
35
|
+
export function apply(ctx, config = {}) {
|
|
36
|
+
const configuredRoot = config.rootPath;
|
|
37
|
+
// simple in-memory red evidence store per process
|
|
38
|
+
const redEvidence = new Set();
|
|
39
|
+
ctx.effect(() => ctx.tools.register(defineTool({
|
|
40
|
+
name: 'maestro_tdd_evidence',
|
|
41
|
+
description: 'Capture TDD evidence: red (failing test), green (passing), verify (pnpm verify). Enforces red-before-green.',
|
|
42
|
+
parameters: {
|
|
43
|
+
op: { type: 'string', enum: ['red', 'green', 'verify'], required: true },
|
|
44
|
+
testFile: { type: 'string' },
|
|
45
|
+
evidence: { type: 'string' },
|
|
46
|
+
},
|
|
47
|
+
output: {
|
|
48
|
+
schema: {
|
|
49
|
+
type: 'object', additionalProperties: true,
|
|
50
|
+
properties: {
|
|
51
|
+
ok: { type: 'boolean', required: true },
|
|
52
|
+
phase: { type: 'string' },
|
|
53
|
+
error: { type: 'string' },
|
|
54
|
+
verify: { type: 'object', additionalProperties: true },
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
render: (_a, v) => [{ type: 'text', text: v.ok ? 'ok' : (v.error ?? 'error') }],
|
|
58
|
+
},
|
|
59
|
+
async execute(args, exec) {
|
|
60
|
+
const op = args.op;
|
|
61
|
+
const rawTest = args.testFile;
|
|
62
|
+
const root = workspaceRootFor(configuredRoot, exec);
|
|
63
|
+
if (rawTest && !(await isInsideRoot(root, rawTest)))
|
|
64
|
+
return { text: `Path "${rawTest}" escapes the workspace root.`, truncated: false };
|
|
65
|
+
if (op === 'red') {
|
|
66
|
+
if (!rawTest)
|
|
67
|
+
return { text: 'testFile required for red', truncated: false };
|
|
68
|
+
const abs = resolve(root, rawTest);
|
|
69
|
+
try {
|
|
70
|
+
const s = await stat(abs);
|
|
71
|
+
if (!s.isFile())
|
|
72
|
+
return { ok: false, phase: 'red', error: 'test file not found' };
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return { ok: false, phase: 'red', error: 'test file not found' };
|
|
76
|
+
}
|
|
77
|
+
const content = await readFile(abs, 'utf-8').catch(() => '');
|
|
78
|
+
// red evidence is that file contains failing expectation (throw, expect fail, etc.)
|
|
79
|
+
redEvidence.add(rawTest);
|
|
80
|
+
return { ok: true, phase: 'red', testFile: rawTest, evidence: content.slice(0, 500), redEvidenceSize: redEvidence.size };
|
|
81
|
+
}
|
|
82
|
+
if (op === 'green') {
|
|
83
|
+
if (!rawTest)
|
|
84
|
+
return { text: 'testFile required for green', truncated: false };
|
|
85
|
+
if (!redEvidence.has(rawTest)) {
|
|
86
|
+
// also check file exists? If not in redEvidence, error must contain 'red'
|
|
87
|
+
return { ok: false, phase: 'green', error: 'red evidence required before green — run op:red first' };
|
|
88
|
+
}
|
|
89
|
+
const abs = resolve(root, rawTest);
|
|
90
|
+
try {
|
|
91
|
+
await stat(abs);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return { ok: false, phase: 'green', error: 'test file not found' };
|
|
95
|
+
}
|
|
96
|
+
return { ok: true, phase: 'green', testFile: rawTest };
|
|
97
|
+
}
|
|
98
|
+
if (op === 'verify') {
|
|
99
|
+
// try to run pnpm verify -- if not available, return ok false but with verify object
|
|
100
|
+
try {
|
|
101
|
+
const { stdout } = await execFileAsync('pnpm', ['verify'], { cwd: root, timeout: 30000 });
|
|
102
|
+
return { ok: true, phase: 'verify', verify: { passed: true, output: String(stdout).slice(0, 2000) } };
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
const out = (e.stdout ?? '') + (e.stderr ?? '') + String(e.message);
|
|
106
|
+
const passed = out.includes('Tests') && !out.includes('FAIL');
|
|
107
|
+
return { ok: passed, phase: 'verify', verify: { passed, output: out.slice(0, 2000) }, error: passed ? undefined : 'verify failed' };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return { text: `unknown op ${op}`, truncated: false };
|
|
111
|
+
}
|
|
112
|
+
}), 'tdd evidence'));
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=tdd-evidence-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tdd-evidence-tool.js","sourceRoot":"","sources":["../src/tdd-evidence-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,MAAM,CAAC,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ToolDecision, ToolExecution } from '@deepseek-ai/dsh-tools';
|
|
3
|
+
export declare const name = "maestro-review-tool-policy";
|
|
4
|
+
/**
|
|
5
|
+
* Host-level tools that leak into every agent but make no sense for a review
|
|
6
|
+
* agent: review sessions must stay read-only on the worktree and side-effect
|
|
7
|
+
* free on the harness (no personal memory writes, no todo lists, no plugin
|
|
8
|
+
* marketplace suggestions, no sidebar UI, no nested subagents).
|
|
9
|
+
*
|
|
10
|
+
* Deny-listed rather than allow-listed on purpose: DSH has no per-agent tool
|
|
11
|
+
* scoping yet, and a reviewer genuinely needs the shared search/read/gitlab
|
|
12
|
+
* surface — an allow-list would break on every new host capability.
|
|
13
|
+
*/
|
|
14
|
+
export declare const REVIEW_DENIED_TOOLS: readonly string[];
|
|
15
|
+
/** Pure predicate: returns the denial reason for denied tools, else undefined. */
|
|
16
|
+
export declare function deniedToolForReview(toolName: string): string | undefined;
|
|
17
|
+
export declare function createReviewToolPolicyHandler(): (exec: ToolExecution, next: () => Promise<PreToolDecision>) => Promise<PreToolDecision>;
|
|
18
|
+
/** Agent-scoped: register inside an agent setup fiber so the policy dies with that agent. */
|
|
19
|
+
export declare function apply(ctx: Context): void;
|
|
20
|
+
//# sourceMappingURL=tool-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-policy.d.ts","sourceRoot":"","sources":["../src/tool-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE5E,eAAO,MAAM,IAAI,+BAA+B,CAAA;AAEhD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAShD,CAAA;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED,wBAAgB,6BAA6B,IAAI,CAC/C,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,KACjC,OAAO,CAAC,eAAe,CAAC,CAO5B;AAED,6FAA6F;AAC7F,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAGxC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const name = 'maestro-review-tool-policy';
|
|
2
|
+
/**
|
|
3
|
+
* Host-level tools that leak into every agent but make no sense for a review
|
|
4
|
+
* agent: review sessions must stay read-only on the worktree and side-effect
|
|
5
|
+
* free on the harness (no personal memory writes, no todo lists, no plugin
|
|
6
|
+
* marketplace suggestions, no sidebar UI, no nested subagents).
|
|
7
|
+
*
|
|
8
|
+
* Deny-listed rather than allow-listed on purpose: DSH has no per-agent tool
|
|
9
|
+
* scoping yet, and a reviewer genuinely needs the shared search/read/gitlab
|
|
10
|
+
* surface — an allow-list would break on every new host capability.
|
|
11
|
+
*/
|
|
12
|
+
export const REVIEW_DENIED_TOOLS = [
|
|
13
|
+
'memory',
|
|
14
|
+
'memory_suggest',
|
|
15
|
+
'dtodo',
|
|
16
|
+
'find_dsh_plugin',
|
|
17
|
+
'sidebar_open',
|
|
18
|
+
'subagent_claude_code',
|
|
19
|
+
'subagent_codex',
|
|
20
|
+
'maestro_write_file',
|
|
21
|
+
];
|
|
22
|
+
/** Pure predicate: returns the denial reason for denied tools, else undefined. */
|
|
23
|
+
export function deniedToolForReview(toolName) {
|
|
24
|
+
if (!REVIEW_DENIED_TOOLS.includes(toolName))
|
|
25
|
+
return undefined;
|
|
26
|
+
return `Tool "${toolName}" is not available to Maestro review agents: reviews stay read-only on the worktree and side-effect free on the harness.`;
|
|
27
|
+
}
|
|
28
|
+
export function createReviewToolPolicyHandler() {
|
|
29
|
+
return async (exec, next) => {
|
|
30
|
+
const toolName = exec.name ?? '';
|
|
31
|
+
const reason = deniedToolForReview(toolName);
|
|
32
|
+
if (reason !== undefined)
|
|
33
|
+
return { kind: 'deny', reason };
|
|
34
|
+
return next();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Agent-scoped: register inside an agent setup fiber so the policy dies with that agent. */
|
|
38
|
+
export function apply(ctx) {
|
|
39
|
+
const handler = createReviewToolPolicyHandler();
|
|
40
|
+
ctx.effect(() => ctx.on('tools/pre-execute', handler));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=tool-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-policy.js","sourceRoot":"","sources":["../src/tool-policy.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,IAAI,GAAG,4BAA4B,CAAA;AAEhD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,QAAQ;IACR,gBAAgB;IAChB,OAAO;IACP,iBAAiB;IACjB,cAAc;IACd,sBAAsB;IACtB,gBAAgB;IAChB,oBAAoB;CACrB,CAAA;AAED,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAA;IAC7D,OAAO,SAAS,QAAQ,0HAA0H,CAAA;AACpJ,CAAC;AAED,MAAM,UAAU,6BAA6B;IAI3C,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAA;QAChC,MAAM,MAAM,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;QAC5C,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;QACzD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,MAAM,OAAO,GAAG,6BAA6B,EAAE,CAAA;IAC/C,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAA;AACxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-tool.d.ts","sourceRoot":"","sources":["../src/workspace-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAGxC,eAAO,MAAM,IAAI,2BAA2B,CAAA;AAC5C,eAAO,MAAM,MAAM,UAAY,CAAA;AAE/B,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAE3B,CAAA;
|
|
1
|
+
{"version":3,"file":"workspace-tool.d.ts","sourceRoot":"","sources":["../src/workspace-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAGxC,eAAO,MAAM,IAAI,2BAA2B,CAAA;AAC5C,eAAO,MAAM,MAAM,UAAY,CAAA;AAE/B,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAE3B,CAAA;AAoDF,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAwC7D"}
|
package/lib/workspace-tool.js
CHANGED
|
@@ -42,9 +42,15 @@ async function resolveInRoot(rootPath, requestedPath) {
|
|
|
42
42
|
return target;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
function workspaceRootFor(configuredRoot, exec) {
|
|
46
|
+
if (configuredRoot !== undefined)
|
|
47
|
+
return configuredRoot;
|
|
48
|
+
const cwd = exec?.agent?.session?.header?.cwd;
|
|
49
|
+
return typeof cwd === 'string' && cwd !== '' ? cwd : process.cwd();
|
|
50
|
+
}
|
|
45
51
|
export function apply(ctx, config = {}) {
|
|
46
|
-
const
|
|
47
|
-
ctx.tools.register(defineTool({
|
|
52
|
+
const configuredRoot = config.rootPath;
|
|
53
|
+
ctx.effect(() => ctx.tools.register(defineTool({
|
|
48
54
|
name: 'maestro_read_file',
|
|
49
55
|
description: 'Read a text file relative to the current workspace root.',
|
|
50
56
|
parameters: {
|
|
@@ -54,15 +60,15 @@ export function apply(ctx, config = {}) {
|
|
|
54
60
|
schema: { type: 'object', additionalProperties: false, properties: { text: { type: 'string', required: true } } },
|
|
55
61
|
render: (_args, value) => [{ type: 'text', text: value.text }],
|
|
56
62
|
},
|
|
57
|
-
async execute(args) {
|
|
58
|
-
const target = await resolveInRoot(
|
|
63
|
+
async execute(args, exec) {
|
|
64
|
+
const target = await resolveInRoot(workspaceRootFor(configuredRoot, exec), args.path);
|
|
59
65
|
if (target === undefined)
|
|
60
66
|
return { isError: true, text: `Path "${args.path}" escapes the workspace root.` };
|
|
61
67
|
const text = await readFile(target, 'utf-8');
|
|
62
68
|
return { text };
|
|
63
69
|
},
|
|
64
|
-
}));
|
|
65
|
-
ctx.tools.register(defineTool({
|
|
70
|
+
})));
|
|
71
|
+
ctx.effect(() => ctx.tools.register(defineTool({
|
|
66
72
|
name: 'maestro_write_file',
|
|
67
73
|
description: 'Write a text file relative to the current workspace root, creating parent directories as needed.',
|
|
68
74
|
parameters: {
|
|
@@ -73,14 +79,14 @@ export function apply(ctx, config = {}) {
|
|
|
73
79
|
schema: { type: 'object', additionalProperties: false, properties: { written: { type: 'boolean', required: true } } },
|
|
74
80
|
render: (args) => [{ type: 'text', text: `Wrote ${args.path}` }],
|
|
75
81
|
},
|
|
76
|
-
async execute(args) {
|
|
77
|
-
const target = await resolveInRoot(
|
|
82
|
+
async execute(args, exec) {
|
|
83
|
+
const target = await resolveInRoot(workspaceRootFor(configuredRoot, exec), args.path);
|
|
78
84
|
if (target === undefined)
|
|
79
85
|
return { isError: true, text: `Path "${args.path}" escapes the workspace root.` };
|
|
80
86
|
await mkdir(dirname(target), { recursive: true });
|
|
81
87
|
await writeFile(target, args.content, 'utf-8');
|
|
82
88
|
return { written: true };
|
|
83
89
|
},
|
|
84
|
-
}));
|
|
90
|
+
})));
|
|
85
91
|
}
|
|
86
92
|
//# sourceMappingURL=workspace-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-tool.js","sourceRoot":"","sources":["../src/workspace-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEvE,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,MAAM,CAAC,MAAM,IAAI,GAAG,wBAAwB,CAAA;AAC5C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,CAAA;AAM/B,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAA;AAEF,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,aAAqB;IAClE,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;IACnD,IAAI,MAAM,KAAK,YAAY,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,GAAG,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IAEvF,IAAI,QAAgB,CAAA;IACpB,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O,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;YACrH,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;SACjE;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI;YACtB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YACrF,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,IAAI,CAAC,IAAI,+BAA+B,EAAW,CAAA;YACpH,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YACjD,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;QAC1B,CAAC;KACF,CAAC,CAAC,CAAC,CAAA;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddtcorex/dsh-maestro-review",
|
|
3
|
-
"
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.1",
|
|
4
5
|
"description": "Maestro Review — pluggable ReviewProvider (GitLab/GitHub) + orchestrator for automated MR review",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./lib/index.js",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@deepseek-ai/schemastery": "^3.0.0",
|
|
26
|
-
"@ddtcorex/dsh-maestro-config-lib": "^0.1.
|
|
27
|
+
"@ddtcorex/dsh-maestro-config-lib": "^0.1.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@deepseek-ai/cordis": "^4.0.1",
|
package/src/augment.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ declare module '@deepseek-ai/cordis' {
|
|
|
25
25
|
proxyStatus(): any
|
|
26
26
|
reloadConfig(): Promise<void>
|
|
27
27
|
initialReady(): Promise<void>
|
|
28
|
+
getPin(): Promise<string>
|
|
29
|
+
rotatePin(): Promise<string>
|
|
30
|
+
getLanPin(): Promise<string>
|
|
31
|
+
rotateLanPin(): Promise<string>
|
|
28
32
|
}
|
|
29
33
|
logger?: {
|
|
30
34
|
info?: (...args: any[]) => void
|
package/src/config-store.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface MaestroUserConfig {
|
|
|
23
23
|
projectMappings?: Array<{ projectPath: string; localRepoPath: string; reviewProfile?: ReviewSkillProfile; reviewModel?: ReviewModelSelection }>
|
|
24
24
|
/** Override the DSH default model for automated reviews. When absent the global DSH default is used. */
|
|
25
25
|
reviewModel?: ReviewModelSelection
|
|
26
|
+
/** Override the DSH default model for the supervisor debug-agent. When absent the review model (or DSH default) is used. */
|
|
27
|
+
supervisorModel?: ReviewModelSelection
|
|
26
28
|
/** Re-run a quick review whenever new commits land on a previously reviewed MR. */
|
|
27
29
|
autoRereviewOnPush?: boolean
|
|
28
30
|
/** Bound one automated review agent's turn. */
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { join, resolve, sep, basename } from 'node:path'
|
|
2
|
+
import { stat, realpath } from 'node:fs/promises'
|
|
3
|
+
import { execFile } from 'node:child_process'
|
|
4
|
+
import { promisify } from 'node:util'
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
6
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
7
|
+
import z from '@deepseek-ai/schemastery'
|
|
8
|
+
|
|
9
|
+
export const name='maestro-git-worktree-tool'
|
|
10
|
+
export const inject=['tools']
|
|
11
|
+
export const Config:z<{rootPath?:string}> = z.object({rootPath:z.string()})
|
|
12
|
+
interface SC{agent?:{session?:{header?:{cwd?:string}}}}
|
|
13
|
+
function workspaceRootFor(c:string|undefined,e:unknown):string{ if(c!==undefined) return c; const cwd=(e as SC|undefined)?.agent?.session?.header?.cwd; return typeof cwd==='string'&&cwd!==''?cwd:process.cwd()}
|
|
14
|
+
async function isInsideRoot(r:string,t:string):Promise<boolean>{
|
|
15
|
+
const ar=resolve(r); const rs=resolve(ar,t)
|
|
16
|
+
if(rs!==ar && !rs.startsWith(ar+sep)) return false
|
|
17
|
+
// For non-existent targets (create), realpath fails — allow if string prefix passes and parent is inside
|
|
18
|
+
try{ const rr=await realpath(ar); const rt=await realpath(rs); return rt===rr||rt.startsWith(rr+sep)}catch{
|
|
19
|
+
try{ const rr=await realpath(ar); const parent=resolve(rs,'..'); const rp=await realpath(parent); return rp===rr||rp.startsWith(rr+sep) }catch{ return rs===ar || rs.startsWith(ar+sep) }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const SAFE_BRANCH=/^[A-Za-z0-9._\/-]+$/
|
|
23
|
+
const execFileAsync=promisify(execFile)
|
|
24
|
+
async function runGit(cwd:string, args:string[]):Promise<{code:number|null, stdout:string, stderr:string}>{
|
|
25
|
+
try{
|
|
26
|
+
const {stdout, stderr}=await execFileAsync('git', args, {cwd, timeout:10000}) as any
|
|
27
|
+
return {code:0, stdout: String(stdout), stderr: String(stderr)}
|
|
28
|
+
}catch(e:any){
|
|
29
|
+
return {code:e.code ?? 1, stdout: e.stdout ?? '', stderr: e.stderr ?? String(e.message)}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function exists(p:string):Promise<boolean>{ try{await stat(p); return true}catch{return false}}
|
|
33
|
+
|
|
34
|
+
export function apply(ctx:Context, config:{rootPath?:string}={}):void{
|
|
35
|
+
const configuredRoot=config.rootPath
|
|
36
|
+
ctx.effect(()=>ctx.tools.register(defineTool({
|
|
37
|
+
name:'git_worktree',
|
|
38
|
+
description:'Inspect/create/remove git worktrees deterministically (isolated workspace, branch, submodule guard).',
|
|
39
|
+
parameters:{
|
|
40
|
+
op:{type:'string', enum:['inspect','create','remove'], required:true},
|
|
41
|
+
worktreePath:{type:'string', required:true},
|
|
42
|
+
branch:{type:'string'},
|
|
43
|
+
base:{type:'string'},
|
|
44
|
+
},
|
|
45
|
+
output:{
|
|
46
|
+
schema:{
|
|
47
|
+
type:'object', additionalProperties:true,
|
|
48
|
+
properties:{
|
|
49
|
+
op:{type:'string', required:true},
|
|
50
|
+
exists:{type:'boolean'},
|
|
51
|
+
isWorktree:{type:'boolean'},
|
|
52
|
+
created:{type:'boolean'},
|
|
53
|
+
reason:{type:'string'},
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
render:(_a,v)=>[{type:'text', text: JSON.stringify(v,null,2)}],
|
|
57
|
+
},
|
|
58
|
+
async execute(args, exec){
|
|
59
|
+
const op=(args as {op:string}).op
|
|
60
|
+
const rawPath=(args as {worktreePath:string}).worktreePath
|
|
61
|
+
const root=workspaceRootFor(configuredRoot, exec)
|
|
62
|
+
if(!(await isInsideRoot(root, rawPath))) return {text:`Path "${rawPath}" escapes the workspace root.`, truncated:false} as never
|
|
63
|
+
const worktreePath=resolve(root, rawPath)
|
|
64
|
+
|
|
65
|
+
if(op==='inspect'){
|
|
66
|
+
const ex=await exists(worktreePath)
|
|
67
|
+
let isWorktree=false, branch:string|null=null, headSha:string|null=null, isClean=true, gitDir:string|null=null, gitCommonDir:string|null=null
|
|
68
|
+
if(ex){
|
|
69
|
+
// try git rev-parse
|
|
70
|
+
const r1=await runGit(worktreePath, ['rev-parse','--git-dir'])
|
|
71
|
+
const r2=await runGit(worktreePath, ['rev-parse','--git-common-dir'])
|
|
72
|
+
const r3=await runGit(worktreePath, ['branch','--show-current'])
|
|
73
|
+
const r4=await runGit(worktreePath, ['rev-parse','HEAD'])
|
|
74
|
+
const r5=await runGit(worktreePath, ['status','--porcelain'])
|
|
75
|
+
if(r1.code===0) gitDir=r1.stdout.trim()
|
|
76
|
+
if(r2.code===0) gitCommonDir=r2.stdout.trim()
|
|
77
|
+
if(r3.code===0) branch=r3.stdout.trim()||null
|
|
78
|
+
if(r4.code===0) headSha=r4.stdout.trim()||null
|
|
79
|
+
isClean=r5.stdout.trim()===''
|
|
80
|
+
// isWorktree if gitDir is file and gitCommonDir differs
|
|
81
|
+
if(gitDir && gitCommonDir && gitDir!==gitCommonDir) isWorktree=true
|
|
82
|
+
// fallback: if worktreePath contains .worktrees
|
|
83
|
+
if(worktreePath.includes('/.worktrees/')) isWorktree=true
|
|
84
|
+
}
|
|
85
|
+
return {op:'inspect', exists:ex, branch, headSha, isClean, isWorktree, gitDir, gitCommonDir, untrackedFiles:[], truncated:false, ignored:null} as never
|
|
86
|
+
}
|
|
87
|
+
if(op==='create'){
|
|
88
|
+
const branch=(args as {branch?:string}).branch
|
|
89
|
+
const base=(args as {base?:string}).base ?? 'HEAD'
|
|
90
|
+
if(!branch) return {text:'branch required for create', truncated:false} as never
|
|
91
|
+
if(!SAFE_BRANCH.test(branch) || branch.startsWith('-') || branch.includes('..')) return {text:`invalid branch name "${branch}" — must match ${SAFE_BRANCH.source}`, truncated:false} as never
|
|
92
|
+
if(branch.includes('--')) return {text:`invalid branch name "${branch}"`, truncated:false} as never
|
|
93
|
+
// base validate
|
|
94
|
+
if(base && !SAFE_BRANCH.test(base) && !/^[0-9a-f]{7,40}$/.test(base)) return {text:`invalid base "${base}"`, truncated:false} as never
|
|
95
|
+
// .gitignore guard: check if worktreePath is ignored
|
|
96
|
+
const check=await runGit(root, ['check-ignore','-q', worktreePath])
|
|
97
|
+
const isIgnored=check.code===0
|
|
98
|
+
if(!isIgnored){
|
|
99
|
+
return {op:'create', created:false, worktreePath, branch, headSha:'', alreadyExisted:false, reason:'not ignored — add .worktrees to .gitignore'} as never
|
|
100
|
+
}
|
|
101
|
+
if(await exists(worktreePath)){
|
|
102
|
+
return {op:'create', created:false, worktreePath, branch, headSha:'', alreadyExisted:true, reason:'already exists'} as never
|
|
103
|
+
}
|
|
104
|
+
const res=await runGit(root, ['worktree','add','--', worktreePath,'-b', branch, base])
|
|
105
|
+
if(res.code!==0){
|
|
106
|
+
if(res.stderr.includes('permission denied') || res.stderr.includes('EACCES')){
|
|
107
|
+
return {op:'create', created:false, worktreePath, branch, headSha:'', alreadyExisted:false, reason:'blocked by sandbox — working in place'} as never
|
|
108
|
+
}
|
|
109
|
+
return {op:'create', created:false, worktreePath, branch, headSha:'', alreadyExisted:false, reason: res.stderr.slice(0,500)} as never
|
|
110
|
+
}
|
|
111
|
+
const head=await runGit(worktreePath, ['rev-parse','HEAD'])
|
|
112
|
+
return {op:'create', created:true, worktreePath, branch, headSha: head.stdout.trim(), alreadyExisted:false, reason:null} as never
|
|
113
|
+
}
|
|
114
|
+
if(op==='remove'){
|
|
115
|
+
const ex=await exists(worktreePath)
|
|
116
|
+
if(!ex) return {op:'remove', removed:false, pruned:false, reason:'not exists', dirtyFiles:[]} as never
|
|
117
|
+
const status=await runGit(worktreePath, ['status','--porcelain'])
|
|
118
|
+
const dirtyFiles=status.stdout.trim()? status.stdout.trim().split('\n').slice(0,20):[]
|
|
119
|
+
if(dirtyFiles.length>0){
|
|
120
|
+
return {op:'remove', removed:false, pruned:false, reason:'contains modified or untracked files', dirtyFiles} as never
|
|
121
|
+
}
|
|
122
|
+
const res=await runGit(root, ['worktree','remove','--', worktreePath])
|
|
123
|
+
if(res.code!==0) return {op:'remove', removed:false, pruned:false, reason: res.stderr.slice(0,500), dirtyFiles} as never
|
|
124
|
+
const prune=await runGit(root, ['worktree','prune'])
|
|
125
|
+
return {op:'remove', removed:true, pruned: prune.code===0, reason:null, dirtyFiles:[]} as never
|
|
126
|
+
}
|
|
127
|
+
return {text:`unknown op ${op}`, truncated:false} as never
|
|
128
|
+
}
|
|
129
|
+
}), 'git worktree'))
|
|
130
|
+
}
|