@duct-sdk/sdk 0.5.13 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +418 -264
- package/TOKEN_SPEC.md +243 -243
- package/dist/cli/action-confusion-format.d.ts +17 -0
- package/dist/cli/action-confusion-format.js +24 -0
- package/dist/cli/add.d.ts +7 -0
- package/dist/cli/add.js +152 -0
- package/dist/cli/agent-prompt.d.ts +3 -0
- package/dist/cli/agent-prompt.js +39 -0
- package/dist/cli/api-sources.d.ts +26 -0
- package/dist/cli/api-sources.js +222 -0
- package/dist/cli/cloud.d.ts +162 -0
- package/dist/cli/cloud.js +306 -0
- package/dist/cli/config-loader.d.ts +14 -0
- package/dist/cli/config-loader.js +56 -7
- package/dist/cli/device-login.d.ts +17 -0
- package/dist/cli/device-login.js +75 -0
- package/dist/cli/drift.js +6 -6
- package/dist/cli/generators/any-stack.d.ts +3 -0
- package/dist/cli/generators/any-stack.js +97 -0
- package/dist/cli/generators/config.js +3 -2
- package/dist/cli/generators/receiver.js +7 -7
- package/dist/cli/generators/shell.js +12 -12
- package/dist/cli/generators/token-route.js +245 -245
- package/dist/cli/generators/wiring-snippets.d.ts +0 -14
- package/dist/cli/generators/wiring-snippets.js +188 -305
- package/dist/cli/index.js +396 -611
- package/dist/cli/mcp-core.d.ts +42 -0
- package/dist/cli/mcp-core.js +161 -0
- package/dist/cli/mcp-setup.d.ts +4 -0
- package/dist/cli/mcp-setup.js +352 -0
- package/dist/cli/mcp.d.ts +2 -0
- package/dist/cli/mcp.js +457 -0
- package/dist/cli/migrate-intershell.js +5 -5
- package/dist/cli/policy-defaults.d.ts +37 -0
- package/dist/cli/policy-defaults.js +127 -0
- package/dist/cli/policy-replay-format.d.ts +9 -0
- package/dist/cli/policy-replay-format.js +46 -0
- package/dist/cli/processors/integration-audit.js +2 -2
- package/dist/cli/processors/openapi-parser.d.ts +5 -0
- package/dist/cli/processors/openapi-parser.js +8 -3
- package/dist/cli/project-loader.d.ts +58 -0
- package/dist/cli/project-loader.js +198 -0
- package/dist/cli/project-writer.d.ts +23 -0
- package/dist/cli/project-writer.js +171 -0
- package/dist/cli/push.d.ts +43 -0
- package/dist/cli/push.js +308 -0
- package/dist/cli/safety-checks.d.ts +9 -0
- package/dist/cli/safety-checks.js +29 -0
- package/dist/cli/setup.d.ts +20 -0
- package/dist/cli/setup.js +349 -0
- package/dist/cli/shell-name.d.ts +8 -0
- package/dist/cli/shell-name.js +29 -0
- package/dist/cli/shells.d.ts +22 -0
- package/dist/cli/shells.js +122 -0
- package/dist/cli/split.d.ts +7 -0
- package/dist/cli/split.js +71 -0
- package/dist/cli/sync.d.ts +25 -0
- package/dist/cli/sync.js +120 -0
- package/dist/cli/test-runner.d.ts +21 -0
- package/dist/cli/test-runner.js +281 -0
- package/dist/core/compile.d.ts +43 -0
- package/dist/core/compile.js +512 -0
- package/dist/core/config.d.ts +538 -19
- package/dist/core/config.js +22 -14
- package/dist/core/login-handoff.d.ts +1 -1
- package/dist/core/login-handoff.js +1 -1
- package/dist/core/project.d.ts +1864 -0
- package/dist/core/project.js +291 -0
- package/dist/core/readiness-checks.js +2 -2
- package/dist/core/types.d.ts +10 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/project.d.ts +4 -0
- package/dist/project.js +8 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +1 -0
- package/package.json +94 -95
- package/dist/adapters/react/page-context-guard.test.d.ts +0 -1
- package/dist/adapters/react/page-context-guard.test.js +0 -15
- package/dist/cli/agents/api-agent.d.ts +0 -22
- package/dist/cli/agents/api-agent.js +0 -761
- package/dist/cli/agents/auth-agent.d.ts +0 -7
- package/dist/cli/agents/auth-agent.js +0 -212
- package/dist/cli/agents/deeplink-agent.d.ts +0 -6
- package/dist/cli/agents/deeplink-agent.js +0 -285
- package/dist/cli/agents/llm.d.ts +0 -33
- package/dist/cli/agents/llm.js +0 -309
- package/dist/cli/agents/pipeline.d.ts +0 -72
- package/dist/cli/agents/pipeline.js +0 -421
- package/dist/cli/agents/reviewer-agent.d.ts +0 -13
- package/dist/cli/agents/reviewer-agent.js +0 -450
- package/dist/cli/agents/route-agent.d.ts +0 -17
- package/dist/cli/agents/route-agent.js +0 -383
- package/dist/cli/config-loader.test.d.ts +0 -1
- package/dist/cli/config-loader.test.js +0 -63
- package/dist/cli/detectors/topology.d.ts +0 -46
- package/dist/cli/detectors/topology.js +0 -417
- package/dist/cli/generators/config.test.d.ts +0 -1
- package/dist/cli/generators/config.test.js +0 -222
- package/dist/cli/generators/shell.test.d.ts +0 -1
- package/dist/cli/generators/shell.test.js +0 -73
- package/dist/cli/generators/token-route.test.d.ts +0 -1
- package/dist/cli/generators/token-route.test.js +0 -53
- package/dist/cli/generators/wiring-snippets.test.d.ts +0 -1
- package/dist/cli/generators/wiring-snippets.test.js +0 -80
- package/dist/cli/init.d.ts +0 -32
- package/dist/cli/init.js +0 -1336
- package/dist/cli/manifest-diff.test.d.ts +0 -1
- package/dist/cli/manifest-diff.test.js +0 -144
- package/dist/cli/processors/curl-parser.test.d.ts +0 -1
- package/dist/cli/processors/curl-parser.test.js +0 -24
- package/dist/cli/processors/integration-audit.test.d.ts +0 -1
- package/dist/cli/processors/integration-audit.test.js +0 -154
- package/dist/cli/processors/postprocess.d.ts +0 -22
- package/dist/cli/processors/postprocess.js +0 -107
- package/dist/cli/processors/prisma-parser.d.ts +0 -35
- package/dist/cli/processors/prisma-parser.js +0 -117
- package/dist/cli/processors/verify-discovery.d.ts +0 -33
- package/dist/cli/processors/verify-discovery.js +0 -193
- package/dist/cli/processors/verify-discovery.test.d.ts +0 -1
- package/dist/cli/processors/verify-discovery.test.js +0 -153
- package/dist/cli/processors/zod-extractor.d.ts +0 -27
- package/dist/cli/processors/zod-extractor.js +0 -153
- package/dist/cli/prompts/review.d.ts +0 -61
- package/dist/cli/prompts/review.js +0 -410
- package/dist/cli/selectors/express.d.ts +0 -12
- package/dist/cli/selectors/express.js +0 -117
- package/dist/cli/selectors/fastapi.d.ts +0 -12
- package/dist/cli/selectors/fastapi.js +0 -122
- package/dist/cli/selectors/generic.d.ts +0 -10
- package/dist/cli/selectors/generic.js +0 -74
- package/dist/cli/selectors/index.d.ts +0 -37
- package/dist/cli/selectors/index.js +0 -315
- package/dist/cli/selectors/next.d.ts +0 -12
- package/dist/cli/selectors/next.js +0 -130
- package/dist/core/config-policy.test.d.ts +0 -1
- package/dist/core/config-policy.test.js +0 -101
- package/dist/core/config-roundtrip.test.d.ts +0 -1
- package/dist/core/config-roundtrip.test.js +0 -180
- package/dist/core/endpoint-guard.test.d.ts +0 -1
- package/dist/core/endpoint-guard.test.js +0 -57
- package/dist/core/env-diagnostics.test.d.ts +0 -1
- package/dist/core/env-diagnostics.test.js +0 -31
- package/dist/core/evidence-bundle.conformance.test.d.ts +0 -1
- package/dist/core/evidence-bundle.conformance.test.js +0 -110
- package/dist/core/evidence-bundle.test.d.ts +0 -1
- package/dist/core/evidence-bundle.test.js +0 -58
- package/dist/core/invariants.test.d.ts +0 -1
- package/dist/core/invariants.test.js +0 -217
- package/dist/core/login-handoff.test.d.ts +0 -1
- package/dist/core/login-handoff.test.js +0 -31
- package/dist/core/profile.test.d.ts +0 -1
- package/dist/core/profile.test.js +0 -95
- package/dist/core/readiness-checks.test.d.ts +0 -1
- package/dist/core/readiness-checks.test.js +0 -106
- package/dist/core/receipt.test.d.ts +0 -1
- package/dist/core/receipt.test.js +0 -75
- package/dist/core/sdk-entrypoint.test.d.ts +0 -1
- package/dist/core/sdk-entrypoint.test.js +0 -8
- package/dist/core/side-effects-review.test.d.ts +0 -1
- package/dist/core/side-effects-review.test.js +0 -28
- package/dist/core/token.conformance.test.d.ts +0 -1
- package/dist/core/token.conformance.test.js +0 -43
- package/dist/core/token.test.d.ts +0 -1
- package/dist/core/token.test.js +0 -66
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
// ============================================================
|
|
2
|
-
// @duct/sdk — Interactive Review CLI
|
|
3
|
-
// Human-in-the-loop decision loop for detected actions/routes.
|
|
4
|
-
// ============================================================
|
|
5
|
-
import * as readline from "readline";
|
|
6
|
-
import * as fs from "fs/promises";
|
|
7
|
-
import * as path from "path";
|
|
8
|
-
import chalk from "chalk";
|
|
9
|
-
// ----------------------------------------------------------------
|
|
10
|
-
// Helpers
|
|
11
|
-
// ----------------------------------------------------------------
|
|
12
|
-
function confidenceColor(c) {
|
|
13
|
-
if (c >= 0.85)
|
|
14
|
-
return chalk.green(`${Math.round(c * 100)}%`);
|
|
15
|
-
if (c >= 0.6)
|
|
16
|
-
return chalk.yellow(`${Math.round(c * 100)}%`);
|
|
17
|
-
return chalk.red(`${Math.round(c * 100)}%`);
|
|
18
|
-
}
|
|
19
|
-
function methodColor(method) {
|
|
20
|
-
const colors = {
|
|
21
|
-
GET: chalk.green,
|
|
22
|
-
HEAD: chalk.green,
|
|
23
|
-
POST: chalk.blue,
|
|
24
|
-
PUT: chalk.yellow,
|
|
25
|
-
PATCH: chalk.yellow,
|
|
26
|
-
DELETE: chalk.red,
|
|
27
|
-
};
|
|
28
|
-
return (colors[method] ?? chalk.white)(method);
|
|
29
|
-
}
|
|
30
|
-
function shouldAutoApprove(action) {
|
|
31
|
-
const isSafeMethod = action.method === "GET";
|
|
32
|
-
const confidence = action.confidence ?? 0;
|
|
33
|
-
return isSafeMethod && confidence >= 0.85;
|
|
34
|
-
}
|
|
35
|
-
function requiresPrompt(action) {
|
|
36
|
-
const isSideEffect = action.method === "POST" ||
|
|
37
|
-
action.method === "PUT" ||
|
|
38
|
-
action.method === "PATCH" ||
|
|
39
|
-
action.method === "DELETE";
|
|
40
|
-
const lowConfidence = (action.confidence ?? 0) < 0.85;
|
|
41
|
-
return isSideEffect || lowConfidence;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* True when at least one agent-accessible action requires auth or has side effects —
|
|
45
|
-
* i.e. this shell needs `webhooks.identityUrl` configured before intershell callers
|
|
46
|
-
* can ever authorize it (see `crossValidateDuctConfig` in core/config.ts for the
|
|
47
|
-
* authoritative, enforced version of this check against the final assembled config).
|
|
48
|
-
*/
|
|
49
|
-
function hasProtectedAgentAccessibleAction(actions) {
|
|
50
|
-
return actions.some((a) => a.agentAccessible && (a.requiresAuth || a.sideEffects));
|
|
51
|
-
}
|
|
52
|
-
// ----------------------------------------------------------------
|
|
53
|
-
// Single-action prompt (readline-based, not inquirer)
|
|
54
|
-
// ----------------------------------------------------------------
|
|
55
|
-
async function promptActionDecision(action, rl) {
|
|
56
|
-
const confidence = action.confidence ?? 0;
|
|
57
|
-
const evidence = Array.isArray(action.evidence)
|
|
58
|
-
? action.evidence.join(", ")
|
|
59
|
-
: (action.evidence ?? "unknown source");
|
|
60
|
-
const method = methodColor(action.method);
|
|
61
|
-
const conf = confidenceColor(confidence);
|
|
62
|
-
const isSideEffect = action.sideEffects ||
|
|
63
|
-
action.method === "POST" ||
|
|
64
|
-
action.method === "PUT" ||
|
|
65
|
-
action.method === "PATCH" ||
|
|
66
|
-
action.method === "DELETE";
|
|
67
|
-
const reason = isSideEffect
|
|
68
|
-
? "side-effect action"
|
|
69
|
-
: `confidence ${Math.round(confidence * 100)}% < 85%`;
|
|
70
|
-
process.stdout.write(`\n ${chalk.bold("[DUCT]")} ${method} ${chalk.cyan(action.path)} — ${reason}\n` +
|
|
71
|
-
` ${chalk.gray(`Confidence: ${conf} | Evidence: ${chalk.dim(evidence)}`)}\n` +
|
|
72
|
-
` ${chalk.gray(`Mark agent-accessible? [y/N/never/explain]: `)}`);
|
|
73
|
-
return new Promise((resolve) => {
|
|
74
|
-
rl.once("line", (answer) => {
|
|
75
|
-
const trimmed = answer.trim().toLowerCase();
|
|
76
|
-
if (trimmed === "y" || trimmed === "yes") {
|
|
77
|
-
resolve("approve");
|
|
78
|
-
}
|
|
79
|
-
else if (trimmed === "never") {
|
|
80
|
-
resolve("never");
|
|
81
|
-
}
|
|
82
|
-
else if (trimmed === "explain") {
|
|
83
|
-
resolve("explain");
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
resolve("reject");
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
async function promptYesNo(question, rl, defaultYes = false) {
|
|
92
|
-
const hint = defaultYes ? "[Y/n]" : "[y/N]";
|
|
93
|
-
process.stdout.write(`\n ${chalk.bold("[DUCT]")} ${question} ${chalk.gray(hint + ": ")}`);
|
|
94
|
-
return new Promise((resolve) => {
|
|
95
|
-
rl.once("line", (answer) => {
|
|
96
|
-
const trimmed = answer.trim().toLowerCase();
|
|
97
|
-
if (trimmed === "")
|
|
98
|
-
resolve(defaultYes);
|
|
99
|
-
else
|
|
100
|
-
resolve(trimmed === "y" || trimmed === "yes");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
async function handleExplain(action) {
|
|
105
|
-
process.stdout.write(chalk.gray(`\n What does "${action.id}" do?\n` +
|
|
106
|
-
` ${action.description}\n\n` +
|
|
107
|
-
` Parameters:\n`));
|
|
108
|
-
for (const p of action.params) {
|
|
109
|
-
process.stdout.write(chalk.gray(` • ${p.name} (${p.type})${p.required ? " *required*" : ""}\n`));
|
|
110
|
-
}
|
|
111
|
-
if (action.inputSchema) {
|
|
112
|
-
process.stdout.write(chalk.gray(`\n Input schema: ${JSON.stringify(action.inputSchema, null, 2).slice(0, 200)}\n`));
|
|
113
|
-
}
|
|
114
|
-
process.stdout.write("\n");
|
|
115
|
-
}
|
|
116
|
-
// ----------------------------------------------------------------
|
|
117
|
-
// runInteractiveReview
|
|
118
|
-
// ----------------------------------------------------------------
|
|
119
|
-
/**
|
|
120
|
-
* Interactive Review CLI.
|
|
121
|
-
*
|
|
122
|
-
* Decision rules:
|
|
123
|
-
* - Auto-approve: GET/HEAD with confidence ≥ 0.85 → no prompt
|
|
124
|
-
* - Always prompt: POST/PUT/PATCH/DELETE, confidence < 0.85, auth ambiguity
|
|
125
|
-
*
|
|
126
|
-
* Flags:
|
|
127
|
-
* - `--yes`: auto-approve everything, skip interactive review
|
|
128
|
-
* - `--no-interactive`: write unresolved decisions to duct-review.json
|
|
129
|
-
*/
|
|
130
|
-
export async function runInteractiveReview(pipelineResult, opts = {}) {
|
|
131
|
-
const { yes = false, noInteractive = false, cwd = process.cwd() } = opts;
|
|
132
|
-
const approvedActions = [];
|
|
133
|
-
const rejectedActions = [];
|
|
134
|
-
const pendingDecisions = [];
|
|
135
|
-
// ---- --yes mode: approve everything ----
|
|
136
|
-
if (yes) {
|
|
137
|
-
for (const action of pipelineResult.actions) {
|
|
138
|
-
approvedActions.push({ ...action, agentAccessible: shouldAutoApprove(action) });
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
routes: pipelineResult.routes,
|
|
142
|
-
actions: approvedActions,
|
|
143
|
-
auth: pipelineResult.auth,
|
|
144
|
-
deeplinks: pipelineResult.deeplinks,
|
|
145
|
-
rejectedActions: [],
|
|
146
|
-
intershell_enabled: false,
|
|
147
|
-
registry_visibility: 'private',
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
// ---- --no-interactive mode: auto-approve where possible, collect rest ----
|
|
151
|
-
if (noInteractive) {
|
|
152
|
-
for (const action of pipelineResult.actions) {
|
|
153
|
-
if (shouldAutoApprove(action)) {
|
|
154
|
-
approvedActions.push({ ...action, agentAccessible: true });
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
// Auto-deny side-effects conservatively; write to review file for human review
|
|
158
|
-
approvedActions.push({ ...action, agentAccessible: false });
|
|
159
|
-
pendingDecisions.push({
|
|
160
|
-
type: "action",
|
|
161
|
-
id: action.id,
|
|
162
|
-
method: action.method,
|
|
163
|
-
path: action.path,
|
|
164
|
-
confidence: action.confidence ?? 0,
|
|
165
|
-
evidence: Array.isArray(action.evidence) ? action.evidence.join(", ") : action.evidence,
|
|
166
|
-
reason: requiresPrompt(action)
|
|
167
|
-
? "Requires human review: side-effect or low confidence"
|
|
168
|
-
: "Pending",
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
// Write duct-review.json
|
|
173
|
-
const reviewFilePath = path.join(cwd, "duct-review.json");
|
|
174
|
-
const reviewContent = {
|
|
175
|
-
generatedAt: new Date().toISOString(),
|
|
176
|
-
pendingDecisions,
|
|
177
|
-
instructions: "Review each entry. Set `approved: true` for actions the AI agent should be able to invoke. Re-run `npx duct init` to apply.",
|
|
178
|
-
};
|
|
179
|
-
await fs.writeFile(reviewFilePath, JSON.stringify(reviewContent, null, 2) + "\n", "utf-8");
|
|
180
|
-
console.log(chalk.yellow(`\n [DUCT] --no-interactive mode: wrote ${pendingDecisions.length} pending decisions to duct-review.json\n`));
|
|
181
|
-
return {
|
|
182
|
-
routes: pipelineResult.routes,
|
|
183
|
-
actions: approvedActions,
|
|
184
|
-
auth: pipelineResult.auth,
|
|
185
|
-
deeplinks: pipelineResult.deeplinks,
|
|
186
|
-
rejectedActions,
|
|
187
|
-
reviewFilePath,
|
|
188
|
-
intershell_enabled: false,
|
|
189
|
-
registry_visibility: 'private',
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
// ---- Interactive mode ----
|
|
193
|
-
const actionsNeedingReview = pipelineResult.actions.filter(requiresPrompt);
|
|
194
|
-
const autoApprovedActions = pipelineResult.actions.filter((a) => !requiresPrompt(a));
|
|
195
|
-
if (actionsNeedingReview.length === 0) {
|
|
196
|
-
// Nothing to review — all actions are safe read-only with high confidence
|
|
197
|
-
console.log(chalk.green(`\n ✓ All ${pipelineResult.actions.length} actions auto-approved (GET/HEAD, confidence ≥ 85%)\n`));
|
|
198
|
-
return {
|
|
199
|
-
routes: pipelineResult.routes,
|
|
200
|
-
actions: pipelineResult.actions.map((a) => ({
|
|
201
|
-
...a,
|
|
202
|
-
agentAccessible: shouldAutoApprove(a),
|
|
203
|
-
})),
|
|
204
|
-
auth: pipelineResult.auth,
|
|
205
|
-
deeplinks: pipelineResult.deeplinks,
|
|
206
|
-
rejectedActions: [],
|
|
207
|
-
intershell_enabled: false,
|
|
208
|
-
registry_visibility: 'private',
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
// Show auto-approved summary
|
|
212
|
-
if (autoApprovedActions.length > 0) {
|
|
213
|
-
console.log(chalk.bold(`\n ${chalk.green("✓")} ${autoApprovedActions.length} action${autoApprovedActions.length === 1 ? "" : "s"} auto-approved (GET/HEAD, confidence ≥ 85%)`));
|
|
214
|
-
for (const a of autoApprovedActions) {
|
|
215
|
-
console.log(chalk.gray(` ${methodColor(a.method)} ${a.path} ${confidenceColor(a.confidence ?? 0)}`));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// Start review loop
|
|
219
|
-
console.log(chalk.bold(`\n ${actionsNeedingReview.length} action${actionsNeedingReview.length === 1 ? "" : "s"} need your review:\n`));
|
|
220
|
-
console.log(chalk.gray(" Side-effect actions (POST/PUT/PATCH/DELETE) and low-confidence detections\n" +
|
|
221
|
-
" require confirmation before being marked as agent-accessible.\n" +
|
|
222
|
-
" y = approve N = deny never = deny + suppress explain = show details\n"));
|
|
223
|
-
const rl = readline.createInterface({
|
|
224
|
-
input: process.stdin,
|
|
225
|
-
output: process.stdout,
|
|
226
|
-
terminal: false,
|
|
227
|
-
});
|
|
228
|
-
// Add approved auto-approved actions
|
|
229
|
-
for (const a of autoApprovedActions) {
|
|
230
|
-
approvedActions.push({ ...a, agentAccessible: true });
|
|
231
|
-
}
|
|
232
|
-
for (const action of actionsNeedingReview) {
|
|
233
|
-
let decision = "reject";
|
|
234
|
-
// Re-prompt on "explain" until the user makes a final decision
|
|
235
|
-
while (true) {
|
|
236
|
-
decision = await promptActionDecision(action, rl);
|
|
237
|
-
if (decision === "explain") {
|
|
238
|
-
await handleExplain(action);
|
|
239
|
-
continue; // re-prompt
|
|
240
|
-
}
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
if (decision === "approve") {
|
|
244
|
-
approvedActions.push({ ...action, agentAccessible: true });
|
|
245
|
-
console.log(chalk.green(` ✓ ${action.id} — marked agent-accessible`));
|
|
246
|
-
}
|
|
247
|
-
else if (decision === "never") {
|
|
248
|
-
// Suppress but include in config with agentAccessible: false
|
|
249
|
-
approvedActions.push({ ...action, agentAccessible: false });
|
|
250
|
-
rejectedActions.push(action);
|
|
251
|
-
console.log(chalk.gray(` — ${action.id} — skipped (never)`));
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
// reject — include in config with agentAccessible: false
|
|
255
|
-
approvedActions.push({ ...action, agentAccessible: false });
|
|
256
|
-
rejectedActions.push(action);
|
|
257
|
-
console.log(chalk.gray(` — ${action.id} — not marked agent-accessible`));
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
// ---- Intershell network exposure prompt ----
|
|
261
|
-
let intershell_enabled = false;
|
|
262
|
-
let registry_visibility = 'private';
|
|
263
|
-
const exposeToNetwork = await promptYesNo("Expose this shell to the Duct network (allow other shells to discover and call it)?", rl);
|
|
264
|
-
if (exposeToNetwork) {
|
|
265
|
-
intershell_enabled = true;
|
|
266
|
-
registry_visibility = 'public';
|
|
267
|
-
// Ask which already-approved actions should be discoverable cross-shell.
|
|
268
|
-
const agentActions = approvedActions.filter((a) => a.agentAccessible);
|
|
269
|
-
if (agentActions.length > 0) {
|
|
270
|
-
console.log(chalk.bold(`\n Which actions should be discoverable cross-shell?\n` +
|
|
271
|
-
chalk.gray(" This makes the action visible in the Duct capability network.\n" +
|
|
272
|
-
" Only agent-accessible actions are shown. y = include N = exclude\n")));
|
|
273
|
-
for (const action of agentActions) {
|
|
274
|
-
process.stdout.write(`\n ${chalk.bold("[DUCT]")} ${methodColor(action.method)} ${chalk.cyan(action.path)} — ${chalk.gray(action.description.slice(0, 80))}\n` +
|
|
275
|
-
` ${chalk.gray(`Include '${action.id}' in cross-shell capability network? [y/N]: `)}`);
|
|
276
|
-
const answer = await new Promise((resolve) => {
|
|
277
|
-
rl.once("line", (line) => resolve(line.trim().toLowerCase()));
|
|
278
|
-
});
|
|
279
|
-
if (answer !== "y" && answer !== "yes") {
|
|
280
|
-
// Mark as not agent-accessible in the final output
|
|
281
|
-
const idx = approvedActions.findIndex((a) => a.id === action.id);
|
|
282
|
-
if (idx !== -1) {
|
|
283
|
-
approvedActions[idx] = { ...approvedActions[idx], agentAccessible: false };
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (hasProtectedAgentAccessibleAction(approvedActions)) {
|
|
289
|
-
console.log(chalk.yellow("\n [DUCT] intershell_enabled shells with protected actions must configure webhooks.identityUrl\n" +
|
|
290
|
-
" Set webhooks.identityUrl (Dashboard → Shell → Settings → Webhooks) or cross-shell\n" +
|
|
291
|
-
" callers will never be able to authorize these actions.\n"));
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
rl.close();
|
|
295
|
-
const agentAccessibleCount = approvedActions.filter((a) => a.agentAccessible).length;
|
|
296
|
-
console.log(chalk.bold(`\n Review complete: ${agentAccessibleCount}/${pipelineResult.actions.length} actions marked agent-accessible\n`));
|
|
297
|
-
return {
|
|
298
|
-
routes: pipelineResult.routes,
|
|
299
|
-
actions: approvedActions,
|
|
300
|
-
auth: pipelineResult.auth,
|
|
301
|
-
deeplinks: pipelineResult.deeplinks,
|
|
302
|
-
rejectedActions,
|
|
303
|
-
intershell_enabled,
|
|
304
|
-
registry_visibility,
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Interactive review for a generated manifest.
|
|
309
|
-
*
|
|
310
|
-
* Decision rules:
|
|
311
|
-
* - `options.yes` → return manifest unchanged, all actions approved
|
|
312
|
-
* - `options.noInteractive` → write to duct-review.json, return manifest unchanged
|
|
313
|
-
* - Otherwise:
|
|
314
|
-
* - GET + confidence ≥ 0.85 → auto-approve (prints "✓ Auto-approved: [id]")
|
|
315
|
-
* - POST / DELETE / PATCH / PUT → always prompt
|
|
316
|
-
* - confidence < 0.85 → prompt regardless of method
|
|
317
|
-
* - Shows evidence: "Detected from: [files]"
|
|
318
|
-
*
|
|
319
|
-
* @param manifest The generated DuctConfig-like manifest (any shape, operates on .actions[])
|
|
320
|
-
* @param options Review mode flags
|
|
321
|
-
* @returns The manifest with only approved actions
|
|
322
|
-
*/
|
|
323
|
-
export async function interactiveReview(
|
|
324
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
325
|
-
manifest, options
|
|
326
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
327
|
-
) {
|
|
328
|
-
const { yes, noInteractive, cwd = process.cwd() } = options;
|
|
329
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
330
|
-
const actions = Array.isArray(manifest?.actions) ? manifest.actions : [];
|
|
331
|
-
// ── --yes mode: return unchanged ─────────────────────────────
|
|
332
|
-
if (yes) {
|
|
333
|
-
return manifest;
|
|
334
|
-
}
|
|
335
|
-
// ── --no-interactive: write to duct-review.json ──────────────
|
|
336
|
-
if (noInteractive) {
|
|
337
|
-
const reviewContent = {
|
|
338
|
-
generatedAt: new Date().toISOString(),
|
|
339
|
-
pendingDecisions: actions
|
|
340
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
|
-
.filter((a) => {
|
|
342
|
-
const isSideEffect = ["POST", "PUT", "PATCH", "DELETE"].includes(a.method ?? "");
|
|
343
|
-
const lowConfidence = (a.confidence ?? 0) < 0.85;
|
|
344
|
-
return isSideEffect || lowConfidence;
|
|
345
|
-
})
|
|
346
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
347
|
-
.map((a) => ({
|
|
348
|
-
id: a.id,
|
|
349
|
-
method: a.method,
|
|
350
|
-
path: a.path,
|
|
351
|
-
confidence: a.confidence ?? 0,
|
|
352
|
-
evidence: Array.isArray(a.evidence) ? a.evidence.join(", ") : (a.evidence ?? ""),
|
|
353
|
-
reason: ["POST", "PUT", "PATCH", "DELETE"].includes(a.method ?? "")
|
|
354
|
-
? "Side-effect action requires review"
|
|
355
|
-
: "Low confidence detection",
|
|
356
|
-
})),
|
|
357
|
-
instructions: "Review each entry. Set `approved: true` for actions to include. Re-run `npx duct init` to apply.",
|
|
358
|
-
};
|
|
359
|
-
const reviewFilePath = path.join(cwd, "duct-review.json");
|
|
360
|
-
await fs.writeFile(reviewFilePath, JSON.stringify(reviewContent, null, 2) + "\n", "utf-8");
|
|
361
|
-
console.log(chalk.yellow(`\n [DUCT] --no-interactive: wrote ${reviewContent.pendingDecisions.length} pending decisions to duct-review.json\n`));
|
|
362
|
-
return manifest;
|
|
363
|
-
}
|
|
364
|
-
// ── Interactive mode ─────────────────────────────────────────
|
|
365
|
-
const approved = [];
|
|
366
|
-
const rl = readline.createInterface({
|
|
367
|
-
input: process.stdin,
|
|
368
|
-
output: process.stdout,
|
|
369
|
-
terminal: false,
|
|
370
|
-
});
|
|
371
|
-
for (const action of actions) {
|
|
372
|
-
const method = action.method ?? "GET";
|
|
373
|
-
const confidence = action.confidence ?? 0;
|
|
374
|
-
const isSafeGet = method === "GET" && confidence >= 0.85;
|
|
375
|
-
const isSideEffect = ["POST", "PUT", "PATCH", "DELETE"].includes(method);
|
|
376
|
-
if (isSafeGet) {
|
|
377
|
-
approved.push(action);
|
|
378
|
-
process.stdout.write(chalk.green(` ✓ Auto-approved: `) +
|
|
379
|
-
chalk.cyan(`[${action.id ?? action.path}]`) +
|
|
380
|
-
chalk.gray(` ${method} ${action.path ?? ""} ${Math.round(confidence * 100)}%\n`));
|
|
381
|
-
continue;
|
|
382
|
-
}
|
|
383
|
-
// Must prompt
|
|
384
|
-
const evidenceStr = Array.isArray(action.evidence)
|
|
385
|
-
? action.evidence.join(", ")
|
|
386
|
-
: (action.evidence ?? "unknown source");
|
|
387
|
-
const reason = isSideEffect
|
|
388
|
-
? "side-effect action"
|
|
389
|
-
: `confidence ${Math.round(confidence * 100)}% < 85%`;
|
|
390
|
-
process.stdout.write(`\n ${chalk.bold("[DUCT]")} ${methodColor(method)} ${chalk.cyan(action.path ?? "")} — ${reason}\n` +
|
|
391
|
-
` ${chalk.gray(`Confidence: ${confidenceColor(confidence)}`)}\n` +
|
|
392
|
-
` ${chalk.gray(`Detected from: ${chalk.dim(evidenceStr)}`)}\n` +
|
|
393
|
-
` ${chalk.gray(`Include action '${action.id ?? action.path}'` +
|
|
394
|
-
(action.description ? ` (${String(action.description).slice(0, 60)})` : "") +
|
|
395
|
-
`? [y/N]: `)}`);
|
|
396
|
-
const answer = await new Promise((resolve) => {
|
|
397
|
-
rl.once("line", (line) => resolve(line.trim().toLowerCase()));
|
|
398
|
-
});
|
|
399
|
-
if (answer === "y" || answer === "yes") {
|
|
400
|
-
approved.push(action);
|
|
401
|
-
console.log(chalk.green(` ✓ Included: ${action.id ?? action.path}`));
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
console.log(chalk.gray(` — Excluded: ${action.id ?? action.path}`));
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
rl.close();
|
|
408
|
-
console.log(chalk.bold(`\n Review complete: ${approved.length}/${actions.length} actions included\n`));
|
|
409
|
-
return { ...manifest, actions: approved };
|
|
410
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Select files for Express / Fastify / Koa projects.
|
|
3
|
-
*
|
|
4
|
-
* Priority:
|
|
5
|
-
* 1. Route files: routes/...ts, src/routes/...ts
|
|
6
|
-
* 2. Middleware: middleware/...ts, src/middleware/...ts
|
|
7
|
-
* 3. Entry points: src/index.ts, index.ts, app.ts, server.ts
|
|
8
|
-
*
|
|
9
|
-
* @param projectRoot Absolute project root path
|
|
10
|
-
* @param maxFiles Maximum total files to return (default 30)
|
|
11
|
-
*/
|
|
12
|
-
export declare function selectExpressFiles(projectRoot: string, maxFiles?: number): Promise<string[]>;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
// ============================================================
|
|
2
|
-
// @duct/sdk — Express / Fastify File Selector
|
|
3
|
-
// Selects route files, middleware, and entry points for Express-like projects.
|
|
4
|
-
// ============================================================
|
|
5
|
-
import * as fs from "fs/promises";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import { glob } from "glob";
|
|
8
|
-
async function fileExists(filePath) {
|
|
9
|
-
try {
|
|
10
|
-
await fs.access(filePath);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async function globFiles(root, pattern) {
|
|
18
|
-
try {
|
|
19
|
-
const matches = await glob(pattern, {
|
|
20
|
-
cwd: root,
|
|
21
|
-
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"],
|
|
22
|
-
nodir: true,
|
|
23
|
-
absolute: false,
|
|
24
|
-
});
|
|
25
|
-
return matches.sort();
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async function getFileSize(filePath) {
|
|
32
|
-
try {
|
|
33
|
-
const s = await fs.stat(filePath);
|
|
34
|
-
return s.size;
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return 0;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function limitFiles(root, files, maxFiles) {
|
|
41
|
-
if (files.length <= maxFiles)
|
|
42
|
-
return files;
|
|
43
|
-
const sized = await Promise.all(files.map(async (f) => ({ f, size: await getFileSize(path.join(root, f)) })));
|
|
44
|
-
sized.sort((a, b) => a.size - b.size);
|
|
45
|
-
return sized.slice(0, maxFiles).map((s) => s.f);
|
|
46
|
-
}
|
|
47
|
-
// ----------------------------------------------------------------
|
|
48
|
-
// Express selector — main export
|
|
49
|
-
// ----------------------------------------------------------------
|
|
50
|
-
/**
|
|
51
|
-
* Select files for Express / Fastify / Koa projects.
|
|
52
|
-
*
|
|
53
|
-
* Priority:
|
|
54
|
-
* 1. Route files: routes/...ts, src/routes/...ts
|
|
55
|
-
* 2. Middleware: middleware/...ts, src/middleware/...ts
|
|
56
|
-
* 3. Entry points: src/index.ts, index.ts, app.ts, server.ts
|
|
57
|
-
*
|
|
58
|
-
* @param projectRoot Absolute project root path
|
|
59
|
-
* @param maxFiles Maximum total files to return (default 30)
|
|
60
|
-
*/
|
|
61
|
-
export async function selectExpressFiles(projectRoot, maxFiles = 30) {
|
|
62
|
-
const priority1 = [];
|
|
63
|
-
const priority2 = [];
|
|
64
|
-
const priority3 = [];
|
|
65
|
-
// ── Priority 1: Route files ──────────────────────────────────
|
|
66
|
-
const routePatterns = [
|
|
67
|
-
"routes/**/*.{ts,js}",
|
|
68
|
-
"src/routes/**/*.{ts,js}",
|
|
69
|
-
"api/**/*.{ts,js}",
|
|
70
|
-
"src/api/**/*.{ts,js}",
|
|
71
|
-
];
|
|
72
|
-
for (const pat of routePatterns) {
|
|
73
|
-
const files = await globFiles(projectRoot, pat);
|
|
74
|
-
priority1.push(...files);
|
|
75
|
-
}
|
|
76
|
-
// ── Priority 2: Middleware ───────────────────────────────────
|
|
77
|
-
const middlewarePatterns = [
|
|
78
|
-
"middleware/**/*.{ts,js}",
|
|
79
|
-
"src/middleware/**/*.{ts,js}",
|
|
80
|
-
"middlewares/**/*.{ts,js}",
|
|
81
|
-
"src/middlewares/**/*.{ts,js}",
|
|
82
|
-
];
|
|
83
|
-
for (const pat of middlewarePatterns) {
|
|
84
|
-
const files = await globFiles(projectRoot, pat);
|
|
85
|
-
priority2.push(...files);
|
|
86
|
-
}
|
|
87
|
-
// ── Priority 3: Entry points ─────────────────────────────────
|
|
88
|
-
const entryCandidates = [
|
|
89
|
-
"src/index.ts",
|
|
90
|
-
"src/index.js",
|
|
91
|
-
"index.ts",
|
|
92
|
-
"index.js",
|
|
93
|
-
"app.ts",
|
|
94
|
-
"app.js",
|
|
95
|
-
"server.ts",
|
|
96
|
-
"server.js",
|
|
97
|
-
"src/app.ts",
|
|
98
|
-
"src/app.js",
|
|
99
|
-
"src/server.ts",
|
|
100
|
-
"src/server.js",
|
|
101
|
-
];
|
|
102
|
-
for (const candidate of entryCandidates) {
|
|
103
|
-
if (await fileExists(path.join(projectRoot, candidate))) {
|
|
104
|
-
priority3.push(candidate);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// ── Combine + deduplicate + limit ───────────────────────────
|
|
108
|
-
const seen = new Set();
|
|
109
|
-
const combined = [];
|
|
110
|
-
for (const f of [...priority1, ...priority2, ...priority3]) {
|
|
111
|
-
if (!seen.has(f)) {
|
|
112
|
-
seen.add(f);
|
|
113
|
-
combined.push(f);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return limitFiles(projectRoot, combined, maxFiles);
|
|
117
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Select files for FastAPI / Django projects.
|
|
3
|
-
*
|
|
4
|
-
* Priority:
|
|
5
|
-
* 1. Router files: routers/...py, api/...py
|
|
6
|
-
* 2. Model/schema files: models.py, schemas.py, models/...py
|
|
7
|
-
* 3. Entry points: main.py, app.py, urls.py (Django)
|
|
8
|
-
*
|
|
9
|
-
* @param projectRoot Absolute project root path
|
|
10
|
-
* @param maxFiles Maximum total files to return (default 30)
|
|
11
|
-
*/
|
|
12
|
-
export declare function selectFastApiFiles(projectRoot: string, maxFiles?: number): Promise<string[]>;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// ============================================================
|
|
2
|
-
// @duct/sdk — FastAPI / Django File Selector
|
|
3
|
-
// Selects router files, models, and entry points for Python API projects.
|
|
4
|
-
// ============================================================
|
|
5
|
-
import * as fs from "fs/promises";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import { glob } from "glob";
|
|
8
|
-
async function fileExists(filePath) {
|
|
9
|
-
try {
|
|
10
|
-
await fs.access(filePath);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async function globFiles(root, pattern) {
|
|
18
|
-
try {
|
|
19
|
-
const matches = await glob(pattern, {
|
|
20
|
-
cwd: root,
|
|
21
|
-
ignore: ["**/__pycache__/**", "**/.venv/**", "**/venv/**", "**/dist/**"],
|
|
22
|
-
nodir: true,
|
|
23
|
-
absolute: false,
|
|
24
|
-
});
|
|
25
|
-
return matches.sort();
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async function getFileSize(filePath) {
|
|
32
|
-
try {
|
|
33
|
-
const s = await fs.stat(filePath);
|
|
34
|
-
return s.size;
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return 0;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function limitFiles(root, files, maxFiles) {
|
|
41
|
-
if (files.length <= maxFiles)
|
|
42
|
-
return files;
|
|
43
|
-
const sized = await Promise.all(files.map(async (f) => ({ f, size: await getFileSize(path.join(root, f)) })));
|
|
44
|
-
sized.sort((a, b) => a.size - b.size);
|
|
45
|
-
return sized.slice(0, maxFiles).map((s) => s.f);
|
|
46
|
-
}
|
|
47
|
-
// ----------------------------------------------------------------
|
|
48
|
-
// FastAPI selector — main export
|
|
49
|
-
// ----------------------------------------------------------------
|
|
50
|
-
/**
|
|
51
|
-
* Select files for FastAPI / Django projects.
|
|
52
|
-
*
|
|
53
|
-
* Priority:
|
|
54
|
-
* 1. Router files: routers/...py, api/...py
|
|
55
|
-
* 2. Model/schema files: models.py, schemas.py, models/...py
|
|
56
|
-
* 3. Entry points: main.py, app.py, urls.py (Django)
|
|
57
|
-
*
|
|
58
|
-
* @param projectRoot Absolute project root path
|
|
59
|
-
* @param maxFiles Maximum total files to return (default 30)
|
|
60
|
-
*/
|
|
61
|
-
export async function selectFastApiFiles(projectRoot, maxFiles = 30) {
|
|
62
|
-
const priority1 = [];
|
|
63
|
-
const priority2 = [];
|
|
64
|
-
const priority3 = [];
|
|
65
|
-
// ── Priority 1: Router / API files ──────────────────────────
|
|
66
|
-
const routerPatterns = [
|
|
67
|
-
"routers/**/*.py",
|
|
68
|
-
"router/**/*.py",
|
|
69
|
-
"api/**/*.py",
|
|
70
|
-
"src/api/**/*.py",
|
|
71
|
-
"app/api/**/*.py",
|
|
72
|
-
"endpoints/**/*.py",
|
|
73
|
-
"views/**/*.py", // Django
|
|
74
|
-
"urls.py", // Django root urls
|
|
75
|
-
"**/urls.py", // Django app-level urls
|
|
76
|
-
];
|
|
77
|
-
for (const pat of routerPatterns) {
|
|
78
|
-
const files = await globFiles(projectRoot, pat);
|
|
79
|
-
priority1.push(...files);
|
|
80
|
-
}
|
|
81
|
-
// ── Priority 2: Model / Schema files ────────────────────────
|
|
82
|
-
const modelCandidates = [
|
|
83
|
-
"models.py",
|
|
84
|
-
"schemas.py",
|
|
85
|
-
"serializers.py", // Django REST
|
|
86
|
-
"src/models.py",
|
|
87
|
-
"src/schemas.py",
|
|
88
|
-
"app/models.py",
|
|
89
|
-
];
|
|
90
|
-
for (const candidate of modelCandidates) {
|
|
91
|
-
if (await fileExists(path.join(projectRoot, candidate))) {
|
|
92
|
-
priority2.push(candidate);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const modelDirFiles = await globFiles(projectRoot, "models/**/*.py");
|
|
96
|
-
const schemasDirFiles = await globFiles(projectRoot, "schemas/**/*.py");
|
|
97
|
-
priority2.push(...modelDirFiles, ...schemasDirFiles);
|
|
98
|
-
// ── Priority 3: Entry points ─────────────────────────────────
|
|
99
|
-
const entryCandidates = [
|
|
100
|
-
"main.py",
|
|
101
|
-
"app.py",
|
|
102
|
-
"application.py",
|
|
103
|
-
"wsgi.py",
|
|
104
|
-
"asgi.py",
|
|
105
|
-
"manage.py", // Django
|
|
106
|
-
];
|
|
107
|
-
for (const candidate of entryCandidates) {
|
|
108
|
-
if (await fileExists(path.join(projectRoot, candidate))) {
|
|
109
|
-
priority3.push(candidate);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// ── Combine + deduplicate + limit ───────────────────────────
|
|
113
|
-
const seen = new Set();
|
|
114
|
-
const combined = [];
|
|
115
|
-
for (const f of [...priority1, ...priority2, ...priority3]) {
|
|
116
|
-
if (!seen.has(f)) {
|
|
117
|
-
seen.add(f);
|
|
118
|
-
combined.push(f);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return limitFiles(projectRoot, combined, maxFiles);
|
|
122
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic fallback file selector.
|
|
3
|
-
*
|
|
4
|
-
* Returns the top `maxFiles` .ts/.js/.py files sorted by file size descending
|
|
5
|
-
* (larger files are more likely to contain route/handler definitions).
|
|
6
|
-
*
|
|
7
|
-
* @param projectRoot Absolute project root path
|
|
8
|
-
* @param maxFiles Maximum total files to return (default 30)
|
|
9
|
-
*/
|
|
10
|
-
export declare function selectGenericFiles(projectRoot: string, maxFiles?: number): Promise<string[]>;
|