@duct-sdk/sdk 0.1.13 → 0.2.2
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 +36 -0
- package/README.md +33 -22
- package/dist/adapters/next/shell.d.ts +2 -3
- package/dist/adapters/next/shell.js +11 -4
- package/dist/adapters/react/shell.d.ts +2 -2
- package/dist/adapters/react/shell.js +2 -2
- package/dist/adapters/react/use-page-context.d.ts +1 -1
- package/dist/cli/detectors/topology.d.ts +20 -0
- package/dist/cli/detectors/topology.js +107 -0
- package/dist/cli/generators/config.js +4 -4
- package/dist/cli/generators/shell.js +6 -6
- package/dist/cli/index.js +141 -3
- package/dist/cli/init.js +2 -3
- package/dist/cli/prompts/review.d.ts +25 -0
- package/dist/cli/prompts/review.js +108 -2
- package/dist/cli/selectors/express.d.ts +12 -0
- package/dist/cli/selectors/express.js +117 -0
- package/dist/cli/selectors/fastapi.d.ts +12 -0
- package/dist/cli/selectors/fastapi.js +122 -0
- package/dist/cli/selectors/generic.d.ts +10 -0
- package/dist/cli/selectors/generic.js +74 -0
- package/dist/cli/selectors/index.d.ts +15 -0
- package/dist/cli/selectors/index.js +41 -0
- package/dist/cli/selectors/next.d.ts +12 -0
- package/dist/cli/selectors/next.js +130 -0
- package/dist/core/action.js +0 -2
- package/dist/core/config.d.ts +5 -5
- package/dist/core/config.js +2 -2
- package/dist/core/endpoints.js +2 -2
- package/dist/core/status.d.ts +2 -2
- package/dist/core/status.js +4 -2
- package/dist/core/types.d.ts +15 -11
- package/package.json +6 -3
- package/dist/assets/logo.d.ts +0 -1
- package/dist/assets/logo.js +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog — @duct-sdk/sdk
|
|
2
|
+
|
|
3
|
+
Public release notes for the Duct SDK. Versioning follows [semver](https://semver.org).
|
|
4
|
+
|
|
5
|
+
## [0.2.2] — 2026-06-07
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- `RouteManifest.searchAction` docs updated — runtime now invokes the declared action in-shell for data queries instead of deeplink navigation
|
|
9
|
+
- `dataModel` field docs clarified; entity-resolution runtime wiring tracked separately
|
|
10
|
+
|
|
11
|
+
## [0.2.1] — 2026-06-06
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Smaller published package (removed unused bundled image asset)
|
|
15
|
+
|
|
16
|
+
## [0.2.0] — 2026-06-06
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `duct init --manual` — commented `duct.config.ts` template without LLM
|
|
20
|
+
- `duct init --update` — re-scan only files changed since last push
|
|
21
|
+
- `duct promote --from <id> --to <id>` — copy manifest between environment shells
|
|
22
|
+
- Interactive init review with confidence scores for detected routes and actions
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- `allowedCallers` is canonical; legacy `allowedAgents` removed from config types
|
|
26
|
+
- Generated configs and examples use environment-configurable base URLs
|
|
27
|
+
|
|
28
|
+
## [0.1.13] — 2026-06-05
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- More stable generator output for empty manifests
|
|
32
|
+
|
|
33
|
+
## [0.1.0] — 2026-03-15
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- Initial publish: `login`, `init`, `push`, `pull`, framework adapters (Next, Remix, Vite, SvelteKit, React)
|
package/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# @duct-sdk/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Let agents use your product safely.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The Duct SDK scans your codebase, generates a manifest, and provides embed components so humans and agents can call your existing APIs through one permissioned surface.
|
|
6
6
|
|
|
7
|
-
- **Humans**
|
|
8
|
-
- **Agents**
|
|
7
|
+
- **Humans** — chat or use an embedded shell; Duct runs actions or hands off via signed deeplinks
|
|
8
|
+
- **Agents** — structured, permissioned API access from the same manifest — no scraping, no screen automation
|
|
9
9
|
|
|
10
|
-
Credentials and shell provisioning are managed by
|
|
10
|
+
Credentials and shell provisioning are managed by Duct.
|
|
11
|
+
|
|
12
|
+
Release notes for each version are in [`CHANGELOG.md`](CHANGELOG.md) (included in the published npm package).
|
|
11
13
|
|
|
12
14
|
---
|
|
13
15
|
|
|
14
16
|
## Quickstart
|
|
15
17
|
|
|
16
|
-
**1. Create your account and
|
|
18
|
+
**1. Create your account** in the Duct dashboard and copy your API key.
|
|
17
19
|
|
|
18
20
|
**2. Authenticate:**
|
|
19
21
|
|
|
@@ -21,24 +23,30 @@ Credentials and shell provisioning are managed by **duct**.
|
|
|
21
23
|
npx @duct-sdk/sdk login
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
**3.
|
|
26
|
+
**3. Generate a manifest** (recommended path for first setup):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx @duct-sdk/sdk init --manual
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
For AI-assisted scanning once your API surface is stable:
|
|
25
33
|
|
|
26
34
|
```bash
|
|
27
35
|
npx @duct-sdk/sdk init
|
|
28
36
|
```
|
|
29
37
|
|
|
30
|
-
This
|
|
38
|
+
This produces:
|
|
31
39
|
- `duct.config.ts` — your shell manifest
|
|
32
40
|
- A receiver route (`/duct/receive`) — handles deeplink handoffs
|
|
33
41
|
- A shell widget component — drop into your layout
|
|
34
42
|
|
|
35
|
-
**4. Push your manifest
|
|
43
|
+
**4. Push your manifest:**
|
|
36
44
|
|
|
37
45
|
```bash
|
|
38
46
|
npx @duct-sdk/sdk push
|
|
39
47
|
```
|
|
40
48
|
|
|
41
|
-
**5.
|
|
49
|
+
**5. Embed the shell** (Next.js example):
|
|
42
50
|
|
|
43
51
|
```tsx
|
|
44
52
|
import { DuctShell } from '@duct-sdk/sdk/next';
|
|
@@ -55,23 +63,26 @@ export default function Layout({ children }) {
|
|
|
55
63
|
|
|
56
64
|
---
|
|
57
65
|
|
|
58
|
-
## CLI
|
|
66
|
+
## CLI reference
|
|
59
67
|
|
|
60
68
|
| Command | Description |
|
|
61
69
|
|---|---|
|
|
62
70
|
| `npx @duct-sdk/sdk login` | Authenticate with your Duct API key |
|
|
63
|
-
| `npx @duct-sdk/sdk init` |
|
|
64
|
-
| `npx @duct-sdk/sdk init --
|
|
65
|
-
| `npx @duct-sdk/sdk
|
|
71
|
+
| `npx @duct-sdk/sdk init` | AI-assisted scan — generates config + shell files |
|
|
72
|
+
| `npx @duct-sdk/sdk init --manual` | Instant template without LLM (recommended first run) |
|
|
73
|
+
| `npx @duct-sdk/sdk init --update` | Re-scan only files changed since last push |
|
|
74
|
+
| `npx @duct-sdk/sdk init --no-agents` | Skip AI scan; blank template |
|
|
75
|
+
| `npx @duct-sdk/sdk push` | Push `duct.config.ts` to Duct |
|
|
66
76
|
| `npx @duct-sdk/sdk pull <hash>` | Restore a manifest version from push history |
|
|
67
|
-
| `npx @duct-sdk/sdk
|
|
68
|
-
| `npx @duct-sdk/sdk init --manual` | Generate a config template without LLM (instant) |
|
|
77
|
+
| `npx @duct-sdk/sdk promote --from <id> --to <id>` | Copy manifest to another environment shell |
|
|
69
78
|
| `npx @duct-sdk/sdk scan` | Detect drift between live API and manifest |
|
|
70
79
|
| `npx @duct-sdk/sdk checkup` | Check env config and service connectivity |
|
|
71
80
|
|
|
72
|
-
Once installed globally (`npm i -g @duct-sdk/sdk`),
|
|
81
|
+
Once installed globally (`npm i -g @duct-sdk/sdk`), commands shorten to `duct login`, `duct init`, etc.
|
|
82
|
+
|
|
83
|
+
---
|
|
73
84
|
|
|
74
|
-
## Framework
|
|
85
|
+
## Framework support
|
|
75
86
|
|
|
76
87
|
| Framework | Import |
|
|
77
88
|
|---|---|
|
|
@@ -81,12 +92,12 @@ Once installed globally (`npm i -g @duct-sdk/sdk`), all commands shorten to `duc
|
|
|
81
92
|
| SvelteKit | `@duct-sdk/sdk/sveltekit` |
|
|
82
93
|
| React Embed | `@duct-sdk/sdk/react` |
|
|
83
94
|
|
|
84
|
-
|
|
95
|
+
Your API endpoints stay yours. Duct reads your manifest and calls your existing routes — nothing is proxied or stored.
|
|
85
96
|
|
|
86
97
|
---
|
|
87
98
|
|
|
88
99
|
## Security
|
|
89
100
|
|
|
90
|
-
- Keep secrets server-side
|
|
91
|
-
- Use least privilege when marking actions as
|
|
92
|
-
- Store credentials in environment variables
|
|
101
|
+
- Keep secrets server-side; never expose them in client code
|
|
102
|
+
- Use least privilege when marking actions as `agentAccessible`
|
|
103
|
+
- Store credentials in environment variables; rotate keys in the dashboard when needed
|
|
@@ -55,7 +55,7 @@ export interface DuctShellProps {
|
|
|
55
55
|
/**
|
|
56
56
|
* Duct shell host URL.
|
|
57
57
|
* For local dev: http://localhost:3000
|
|
58
|
-
* For production:
|
|
58
|
+
* For production: your Duct shell host URL (local default: http://localhost:3000)
|
|
59
59
|
*/
|
|
60
60
|
shellHost?: string;
|
|
61
61
|
/**
|
|
@@ -122,8 +122,7 @@ export declare function useShellStatus(shellId: string, shellHost?: string): She
|
|
|
122
122
|
* const res = await fetch("/api/duct/token", { method: "POST" });
|
|
123
123
|
* const { token } = await res.json();
|
|
124
124
|
* return token;
|
|
125
|
-
* }}
|
|
126
|
-
* />
|
|
125
|
+
* }} />
|
|
127
126
|
* ```
|
|
128
127
|
*/
|
|
129
128
|
export declare function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, onPageContext, open, onOpenChange, defaultOpen, shellHost, position, panelWidth, panelHeight, style, className, launcherIconSrc, readyCheck, }: DuctShellProps): React.ReactElement | null;
|
|
@@ -58,8 +58,7 @@ const DUCT_LAUNCHER_ICON_LOCAL_FALLBACK = "/assets/logo.png";
|
|
|
58
58
|
* const res = await fetch("/api/duct/token", { method: "POST" });
|
|
59
59
|
* const { token } = await res.json();
|
|
60
60
|
* return token;
|
|
61
|
-
* }}
|
|
62
|
-
* />
|
|
61
|
+
* }} />
|
|
63
62
|
* ```
|
|
64
63
|
*/
|
|
65
64
|
export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, onPageContext, open, onOpenChange, defaultOpen = false, shellHost = DUCT_SHELL_HOST_DEFAULT, position = "bottom-right", panelWidth = 420, panelHeight = 640, style, className, launcherIconSrc, readyCheck = false, }) {
|
|
@@ -299,12 +298,20 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
299
298
|
e.currentTarget.style.transform = "scale(1)";
|
|
300
299
|
e.currentTarget.style.boxShadow =
|
|
301
300
|
"0 4px 16px rgba(0,0,0,0.40), 0 2px 8px rgba(0,0,0,0.20)";
|
|
302
|
-
}, children: !iconLoadFailed ? (_jsx("img", { src: currentIconSrc, alt: "Duct", width: 28, height: 28, onError: handleIconError, style: { width: "28px", height: "28px", objectFit: "contain" } })) : (_jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M18 12c0-3.3-2.2-5.5-5.5-5.5C9 6.5 7 8.7 7 12s2 5.5 5.5 5.5c2 0 3.6-.8 4.6-2.2l-2.2-1.6c-.6.8-1.4 1.3-2.4 1.3-1.6 0-2.8-1.2-2.8-3s1.2-3 2.8-3c1 0 1.8.5 2.3 1.3L18 12z", fill: "white" }) })) })), _jsx("div", { style: panelStyle, "data-duct-shell": shellId, children:
|
|
301
|
+
}, children: !iconLoadFailed ? (_jsx("img", { src: currentIconSrc, alt: "Duct", width: 28, height: 28, onError: handleIconError, style: { width: "28px", height: "28px", objectFit: "contain" } })) : (_jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M18 12c0-3.3-2.2-5.5-5.5-5.5C9 6.5 7 8.7 7 12s2 5.5 5.5 5.5c2 0 3.6-.8 4.6-2.2l-2.2-1.6c-.6.8-1.4 1.3-2.4 1.3-1.6 0-2.8-1.2-2.8-3s1.2-3 2.8-3c1 0 1.8.5 2.3 1.3L18 12z", fill: "white" }) })) })), _jsx("div", { style: panelStyle, "data-duct-shell": shellId, children: React.createElement("iframe", {
|
|
302
|
+
ref: iframeRef,
|
|
303
|
+
src: shellUrl,
|
|
304
|
+
title: "Duct Shell",
|
|
305
|
+
sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox",
|
|
306
|
+
allow: "clipboard-write",
|
|
307
|
+
referrerPolicy: "no-referrer-when-downgrade",
|
|
308
|
+
style: {
|
|
303
309
|
width: "100%",
|
|
304
310
|
height: "100%",
|
|
305
311
|
border: "none",
|
|
306
312
|
display: "block",
|
|
307
|
-
},
|
|
313
|
+
},
|
|
314
|
+
}) })] }));
|
|
308
315
|
}
|
|
309
316
|
/**
|
|
310
317
|
* Headless launch button — use when you want a custom trigger.
|
|
@@ -55,7 +55,7 @@ export interface DuctShellProps {
|
|
|
55
55
|
/**
|
|
56
56
|
* Duct shell host URL.
|
|
57
57
|
* For local dev: http://localhost:3000
|
|
58
|
-
* For production:
|
|
58
|
+
* For production: your Duct shell host URL (local default: http://localhost:3000)
|
|
59
59
|
*/
|
|
60
60
|
shellHost?: string;
|
|
61
61
|
/**
|
|
@@ -106,7 +106,7 @@ export interface ShellStatusResult {
|
|
|
106
106
|
*
|
|
107
107
|
* @example
|
|
108
108
|
* ```tsx
|
|
109
|
-
* const { status } = useShellStatus('shell_acme_prod', '
|
|
109
|
+
* const { status } = useShellStatus('shell_acme_prod', 'http://localhost:3000');
|
|
110
110
|
* if (status !== 'live') return null;
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
@@ -11,7 +11,7 @@ import React, { useEffect, useRef, useCallback, useState, } from "react";
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
|
-
* const { status } = useShellStatus('shell_acme_prod', '
|
|
14
|
+
* const { status } = useShellStatus('shell_acme_prod', 'http://localhost:3000');
|
|
15
15
|
* if (status !== 'live') return null;
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
@@ -315,7 +315,7 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
315
315
|
height: "100%",
|
|
316
316
|
border: "none",
|
|
317
317
|
display: "block",
|
|
318
|
-
}
|
|
318
|
+
} }) })] }));
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
321
|
* Headless launch button — use when you want a custom trigger.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DuctPageContext } from "../../core/types.js";
|
|
2
2
|
export interface UseDuctPageContextOptions {
|
|
3
3
|
/**
|
|
4
|
-
* The Duct shell host URL (e.g. "
|
|
4
|
+
* The Duct shell host URL (e.g. "http://localhost:3000" in local dev).
|
|
5
5
|
* When provided, the hook validates event.origin against this value — only the
|
|
6
6
|
* Duct iframe can request page context, blocking arbitrary cross-origin access.
|
|
7
7
|
* When omitted, the hook accepts requests from any origin (useful in dev/test).
|
|
@@ -9,6 +9,16 @@ export interface TopoResult {
|
|
|
9
9
|
routeRoot: string;
|
|
10
10
|
/** Relative path to the API directory (e.g. "app/api", "pages/api", "routes") */
|
|
11
11
|
apiRoot: string;
|
|
12
|
+
/** All candidate API root directories (plural — for selectors) */
|
|
13
|
+
apiRoots: string[];
|
|
14
|
+
/** All candidate route root directories (plural — for selectors) */
|
|
15
|
+
routeRoots: string[];
|
|
16
|
+
/** Detected package manager */
|
|
17
|
+
packageManager: "npm" | "yarn" | "pnpm" | "pip" | "unknown";
|
|
18
|
+
/** Absolute path to the project root */
|
|
19
|
+
projectRoot: string;
|
|
20
|
+
/** Detection confidence 0–1 (1 = all signals confirmed) */
|
|
21
|
+
confidence: number;
|
|
12
22
|
/** Auth library detected from deps / config files */
|
|
13
23
|
authLib: AuthStrategy;
|
|
14
24
|
/** Whether this looks like a monorepo (multiple package.json dirs) */
|
|
@@ -24,3 +34,13 @@ export interface TopoResult {
|
|
|
24
34
|
* Must run before any agent or selector.
|
|
25
35
|
*/
|
|
26
36
|
export declare function discoverTopology(projectRoot: string): Promise<TopoResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Detect project topology for the selector pipeline (Phase 0).
|
|
39
|
+
*
|
|
40
|
+
* Returns an enriched TopoResult with plural `apiRoots`, `routeRoots`,
|
|
41
|
+
* `packageManager`, `projectRoot`, and `confidence` in addition to the
|
|
42
|
+
* existing fields from `discoverTopology()`.
|
|
43
|
+
*
|
|
44
|
+
* No LLM — pure filesystem reads only.
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectTopology(projectRoot: string): Promise<TopoResult>;
|
|
@@ -179,6 +179,50 @@ async function inferRoots(projectRoot, framework, topLevel) {
|
|
|
179
179
|
return { routeRoot, apiRoot, refinedFramework: framework };
|
|
180
180
|
}
|
|
181
181
|
// ----------------------------------------------------------------
|
|
182
|
+
// Package manager detection
|
|
183
|
+
// ----------------------------------------------------------------
|
|
184
|
+
async function detectPackageManager(projectRoot, topLevel) {
|
|
185
|
+
const files = topLevel.filter((e) => !e.isDir).map((e) => e.name);
|
|
186
|
+
if (files.includes("pnpm-lock.yaml") || files.includes("pnpm-workspace.yaml"))
|
|
187
|
+
return "pnpm";
|
|
188
|
+
if (files.includes("yarn.lock"))
|
|
189
|
+
return "yarn";
|
|
190
|
+
if (files.includes("package-lock.json"))
|
|
191
|
+
return "npm";
|
|
192
|
+
if (files.includes("package.json")) {
|
|
193
|
+
// Check packageManager field in package.json
|
|
194
|
+
const pkg = await readJsonFile(path.join(projectRoot, "package.json"));
|
|
195
|
+
const pm = pkg?.packageManager;
|
|
196
|
+
if (pm?.startsWith("pnpm"))
|
|
197
|
+
return "pnpm";
|
|
198
|
+
if (pm?.startsWith("yarn"))
|
|
199
|
+
return "yarn";
|
|
200
|
+
if (pm?.startsWith("npm"))
|
|
201
|
+
return "npm";
|
|
202
|
+
return "npm"; // has package.json — default to npm
|
|
203
|
+
}
|
|
204
|
+
if (files.includes("requirements.txt") || files.includes("pyproject.toml") || files.includes("setup.py")) {
|
|
205
|
+
return "pip";
|
|
206
|
+
}
|
|
207
|
+
return "unknown";
|
|
208
|
+
}
|
|
209
|
+
// ----------------------------------------------------------------
|
|
210
|
+
// Confidence scoring
|
|
211
|
+
// ----------------------------------------------------------------
|
|
212
|
+
function computeConfidence(framework, apiRoots, routeRoots, packageManagerKnown) {
|
|
213
|
+
if (framework === "unknown")
|
|
214
|
+
return 0.3;
|
|
215
|
+
let score = 0.5; // base — framework detected
|
|
216
|
+
// Bonus for confirmed directory structure
|
|
217
|
+
if (apiRoots.length > 0)
|
|
218
|
+
score += 0.2;
|
|
219
|
+
if (routeRoots.length > 0)
|
|
220
|
+
score += 0.15;
|
|
221
|
+
if (packageManagerKnown)
|
|
222
|
+
score += 0.15;
|
|
223
|
+
return Math.min(score, 1.0);
|
|
224
|
+
}
|
|
225
|
+
// ----------------------------------------------------------------
|
|
182
226
|
// Language detection
|
|
183
227
|
// ----------------------------------------------------------------
|
|
184
228
|
async function detectLanguage(_projectRoot, topLevel) {
|
|
@@ -298,13 +342,76 @@ export async function discoverTopology(projectRoot) {
|
|
|
298
342
|
framework = refinedFramework;
|
|
299
343
|
// 7. Detect monorepo
|
|
300
344
|
const { isMonorepo, packageDirs } = await detectMonorepo(resolvedRoot, pkg, topLevel);
|
|
345
|
+
// 8. Detect package manager
|
|
346
|
+
const packageManager = await detectPackageManager(resolvedRoot, topLevel);
|
|
347
|
+
// 9. Build plural root arrays for selectors
|
|
348
|
+
const routeRoots = buildRouteRoots(framework, routeRoot);
|
|
349
|
+
const apiRoots = buildApiRoots(framework, apiRoot);
|
|
350
|
+
// 10. Compute confidence
|
|
351
|
+
const confidence = computeConfidence(framework, apiRoots, routeRoots, packageManager !== "unknown");
|
|
301
352
|
return {
|
|
302
353
|
framework,
|
|
303
354
|
language,
|
|
304
355
|
routeRoot,
|
|
305
356
|
apiRoot,
|
|
357
|
+
apiRoots,
|
|
358
|
+
routeRoots,
|
|
359
|
+
packageManager,
|
|
360
|
+
projectRoot: resolvedRoot,
|
|
361
|
+
confidence,
|
|
306
362
|
authLib,
|
|
307
363
|
isMonorepo,
|
|
308
364
|
packageDirs,
|
|
309
365
|
};
|
|
310
366
|
}
|
|
367
|
+
// ----------------------------------------------------------------
|
|
368
|
+
// Plural roots helpers
|
|
369
|
+
// ----------------------------------------------------------------
|
|
370
|
+
function buildRouteRoots(framework, routeRoot) {
|
|
371
|
+
switch (framework) {
|
|
372
|
+
case "next-app":
|
|
373
|
+
return ["app", "src/app"].filter((d) => d === routeRoot || routeRoot.includes(d.replace("src/", "")));
|
|
374
|
+
case "next-pages":
|
|
375
|
+
return ["pages", "src/pages"].filter((d) => d === routeRoot || routeRoot.includes(d.replace("src/", "")));
|
|
376
|
+
case "remix":
|
|
377
|
+
return ["app/routes", "app"];
|
|
378
|
+
case "sveltekit":
|
|
379
|
+
return ["src/routes"];
|
|
380
|
+
case "nuxt":
|
|
381
|
+
return ["pages"];
|
|
382
|
+
default:
|
|
383
|
+
return routeRoot ? [routeRoot] : [];
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
function buildApiRoots(framework, apiRoot) {
|
|
387
|
+
switch (framework) {
|
|
388
|
+
case "next-app":
|
|
389
|
+
return ["app/api", "src/app/api"].filter((d) => d === apiRoot || apiRoot.includes("api"));
|
|
390
|
+
case "next-pages":
|
|
391
|
+
return ["pages/api", "src/pages/api"].filter((d) => d === apiRoot || apiRoot.includes("api"));
|
|
392
|
+
case "remix":
|
|
393
|
+
return ["app/routes"];
|
|
394
|
+
case "sveltekit":
|
|
395
|
+
return ["src/routes/api", "src/routes"];
|
|
396
|
+
default: {
|
|
397
|
+
const candidates = ["routes", "src/routes", "api", "routers", "controllers", "handlers"];
|
|
398
|
+
const found = candidates.filter((c) => apiRoot === c || apiRoot.startsWith(c));
|
|
399
|
+
return found.length > 0 ? found : (apiRoot ? [apiRoot] : []);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// ----------------------------------------------------------------
|
|
404
|
+
// detectTopology — spec-compliant alias
|
|
405
|
+
// ----------------------------------------------------------------
|
|
406
|
+
/**
|
|
407
|
+
* Detect project topology for the selector pipeline (Phase 0).
|
|
408
|
+
*
|
|
409
|
+
* Returns an enriched TopoResult with plural `apiRoots`, `routeRoots`,
|
|
410
|
+
* `packageManager`, `projectRoot`, and `confidence` in addition to the
|
|
411
|
+
* existing fields from `discoverTopology()`.
|
|
412
|
+
*
|
|
413
|
+
* No LLM — pure filesystem reads only.
|
|
414
|
+
*/
|
|
415
|
+
export async function detectTopology(projectRoot) {
|
|
416
|
+
return discoverTopology(projectRoot);
|
|
417
|
+
}
|
|
@@ -156,8 +156,8 @@ function generateAgentPermissions(perms, indentSpaces) {
|
|
|
156
156
|
if (perms.allowedActions && perms.allowedActions.length > 0) {
|
|
157
157
|
lines.push(`${pad} allowedActions: ${formatStringArray(perms.allowedActions, indentSpaces + 2)},`);
|
|
158
158
|
}
|
|
159
|
-
if (perms.
|
|
160
|
-
lines.push(`${pad}
|
|
159
|
+
if (perms.allowedCallers && perms.allowedCallers.length > 0) {
|
|
160
|
+
lines.push(`${pad} allowedCallers: ${formatStringArray(perms.allowedCallers, indentSpaces + 2)},`);
|
|
161
161
|
}
|
|
162
162
|
if (perms.actionOverrides && Object.keys(perms.actionOverrides).length > 0) {
|
|
163
163
|
lines.push(`${pad} actionOverrides: ${jsonValue(perms.actionOverrides, indentSpaces + 2)},`);
|
|
@@ -209,7 +209,7 @@ export function generateManualTemplate(opts) {
|
|
|
209
209
|
*
|
|
210
210
|
* to sync this manifest with Duct cloud.
|
|
211
211
|
*
|
|
212
|
-
* Docs:
|
|
212
|
+
* Docs: see your Duct deployment /docs (local default: http://localhost:3005/docs)
|
|
213
213
|
*/
|
|
214
214
|
|
|
215
215
|
import { defineDuctConfig } from "@duct-sdk/sdk";
|
|
@@ -377,7 +377,7 @@ export function generateConfigFile(config) {
|
|
|
377
377
|
if (config.widget) {
|
|
378
378
|
sections.push("", `${i}// Shell widget display configuration`, `${i}${generateWidget(config.widget, 2)}`);
|
|
379
379
|
}
|
|
380
|
-
let docsBase = '
|
|
380
|
+
let docsBase = 'http://localhost:3005/docs';
|
|
381
381
|
if (config.product?.baseUrl) {
|
|
382
382
|
try {
|
|
383
383
|
const hostname = new URL(config.product.baseUrl).hostname;
|
|
@@ -12,7 +12,7 @@ function generateReactShellComponent(config) {
|
|
|
12
12
|
const height = config.widget?.height ?? 620;
|
|
13
13
|
const docsBase = config.product?.baseUrl
|
|
14
14
|
? `https://docs.${new URL(config.product.baseUrl).hostname.split('.').slice(-2).join('.')}`
|
|
15
|
-
: '
|
|
15
|
+
: 'http://localhost:3005/docs';
|
|
16
16
|
return `/**
|
|
17
17
|
* Duct Shell Widget — auto-generated by \`npx duct init\`
|
|
18
18
|
*
|
|
@@ -156,7 +156,7 @@ function generateRemixShellComponent(config) {
|
|
|
156
156
|
const position = config.widget?.position ?? "bottom-right";
|
|
157
157
|
const docsBase = config.product?.baseUrl
|
|
158
158
|
? `https://docs.${new URL(config.product.baseUrl).hostname.split('.').slice(-2).join('.')}`
|
|
159
|
-
: '
|
|
159
|
+
: 'http://localhost:3005/docs';
|
|
160
160
|
return `/**
|
|
161
161
|
* Duct Shell Widget — auto-generated by \`npx duct init\`
|
|
162
162
|
*
|
|
@@ -214,7 +214,7 @@ function generateViteShellComponent(config) {
|
|
|
214
214
|
const position = config.widget?.position ?? "bottom-right";
|
|
215
215
|
const docsBase = config.product?.baseUrl
|
|
216
216
|
? `https://docs.${new URL(config.product.baseUrl).hostname.split('.').slice(-2).join('.')}`
|
|
217
|
-
: '
|
|
217
|
+
: 'http://localhost:3005/docs';
|
|
218
218
|
return `/**
|
|
219
219
|
* Duct Shell Widget — auto-generated by \`npx duct init\`
|
|
220
220
|
*
|
|
@@ -330,7 +330,7 @@ export function getEnvTemplateName(framework) {
|
|
|
330
330
|
function generateSvelteKitShellComponent(config) {
|
|
331
331
|
const docsBase = config.product?.baseUrl
|
|
332
332
|
? `https://docs.${new URL(config.product.baseUrl).hostname.split('.').slice(-2).join('.')}`
|
|
333
|
-
: '
|
|
333
|
+
: 'http://localhost:3005/docs';
|
|
334
334
|
return `<!--
|
|
335
335
|
Duct Shell Widget — auto-generated by \`npx duct init\`
|
|
336
336
|
|
|
@@ -438,7 +438,7 @@ function generateVue3ShellComponent(config) {
|
|
|
438
438
|
const height = config.widget?.height ?? 620;
|
|
439
439
|
const docsBase = config.product?.baseUrl
|
|
440
440
|
? `https://docs.${new URL(config.product.baseUrl).hostname.split('.').slice(-2).join('.')}`
|
|
441
|
-
: '
|
|
441
|
+
: 'http://localhost:3005/docs';
|
|
442
442
|
const positionStyle = position === "bottom-left"
|
|
443
443
|
? "bottom: 24px; left: 24px;"
|
|
444
444
|
: "bottom: 24px; right: 24px;";
|
|
@@ -557,7 +557,7 @@ function generateNuxtShellComponent(config) {
|
|
|
557
557
|
const height = config.widget?.height ?? 620;
|
|
558
558
|
const docsBase = config.product?.baseUrl
|
|
559
559
|
? `https://docs.${new URL(config.product.baseUrl).hostname.split('.').slice(-2).join('.')}`
|
|
560
|
-
: '
|
|
560
|
+
: 'http://localhost:3005/docs';
|
|
561
561
|
const positionStyle = position === "bottom-left"
|
|
562
562
|
? "bottom: 24px; left: 24px;"
|
|
563
563
|
: "bottom: 24px; right: 24px;";
|