@ohos-ports/assistant-ui 0.0.0-stage → 0.0.136-beta.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/README.md +148 -2
- package/bin/assistant-ui.js +2 -0
- package/dist/codemods/utils/createTransformer.d.ts +15 -0
- package/dist/codemods/utils/createTransformer.d.ts.map +1 -0
- package/dist/codemods/utils/createTransformer.js +19 -0
- package/dist/codemods/utils/createTransformer.js.map +1 -0
- package/dist/codemods/utils/resolveBinding.d.ts +3 -0
- package/dist/codemods/utils/resolveBinding.d.ts.map +1 -0
- package/dist/codemods/utils/resolveBinding.js +77 -0
- package/dist/codemods/utils/resolveBinding.js.map +1 -0
- package/dist/codemods/v0-11/content-part-to-message-part.d.ts +3 -0
- package/dist/codemods/v0-11/content-part-to-message-part.d.ts.map +1 -0
- package/dist/codemods/v0-11/content-part-to-message-part.js +189 -0
- package/dist/codemods/v0-11/content-part-to-message-part.js.map +1 -0
- package/dist/codemods/v0-12/assistant-api-to-aui.d.ts +3 -0
- package/dist/codemods/v0-12/assistant-api-to-aui.d.ts.map +1 -0
- package/dist/codemods/v0-12/assistant-api-to-aui.js +117 -0
- package/dist/codemods/v0-12/assistant-api-to-aui.js.map +1 -0
- package/dist/codemods/v0-12/event-names-to-camelcase.d.ts +3 -0
- package/dist/codemods/v0-12/event-names-to-camelcase.d.ts.map +1 -0
- package/dist/codemods/v0-12/event-names-to-camelcase.js +38 -0
- package/dist/codemods/v0-12/event-names-to-camelcase.js.map +1 -0
- package/dist/codemods/v0-12/primitive-if-to-aui-if.d.ts +3 -0
- package/dist/codemods/v0-12/primitive-if-to-aui-if.d.ts.map +1 -0
- package/dist/codemods/v0-12/primitive-if-to-aui-if.js +226 -0
- package/dist/codemods/v0-12/primitive-if-to-aui-if.js.map +1 -0
- package/dist/codemods/v0-15/aui-accessor-calls-to-properties.d.ts +3 -0
- package/dist/codemods/v0-15/aui-accessor-calls-to-properties.d.ts.map +1 -0
- package/dist/codemods/v0-15/aui-accessor-calls-to-properties.js +85 -0
- package/dist/codemods/v0-15/aui-accessor-calls-to-properties.js.map +1 -0
- package/dist/codemods/v0-8/ui-package-split.d.ts +3 -0
- package/dist/codemods/v0-8/ui-package-split.d.ts.map +1 -0
- package/dist/codemods/v0-8/ui-package-split.js +102 -0
- package/dist/codemods/v0-8/ui-package-split.js.map +1 -0
- package/dist/codemods/v0-9/edge-package-split.d.ts +3 -0
- package/dist/codemods/v0-9/edge-package-split.d.ts.map +1 -0
- package/dist/codemods/v0-9/edge-package-split.js +47 -0
- package/dist/codemods/v0-9/edge-package-split.js.map +1 -0
- package/dist/commands/add.d.ts +17 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +63 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/agent.d.ts +3 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +27 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/cloud.d.ts +25 -0
- package/dist/commands/cloud.d.ts.map +1 -0
- package/dist/commands/cloud.js +239 -0
- package/dist/commands/cloud.js.map +1 -0
- package/dist/commands/create.d.ts +58 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +626 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/doctor.d.ts +22 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +255 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/info.d.ts +6 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +288 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +13 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +100 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +279 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/setup.d.ts +24 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +136 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +58 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/upgrade.d.ts +10 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +38 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/agent-gate.d.ts +66 -0
- package/dist/lib/agent-gate.d.ts.map +1 -0
- package/dist/lib/agent-gate.js +180 -0
- package/dist/lib/agent-gate.js.map +1 -0
- package/dist/lib/agent-setup-hint.d.ts +20 -0
- package/dist/lib/agent-setup-hint.d.ts.map +1 -0
- package/dist/lib/agent-setup-hint.js +33 -0
- package/dist/lib/agent-setup-hint.js.map +1 -0
- package/dist/lib/agent-skill.d.ts +14 -0
- package/dist/lib/agent-skill.d.ts.map +1 -0
- package/dist/lib/agent-skill.js +83 -0
- package/dist/lib/agent-skill.js.map +1 -0
- package/dist/lib/cloud-abort.d.ts +2 -0
- package/dist/lib/cloud-abort.d.ts.map +1 -0
- package/dist/lib/cloud-abort.js +12 -0
- package/dist/lib/cloud-abort.js.map +1 -0
- package/dist/lib/cloud-auth.d.ts +30 -0
- package/dist/lib/cloud-auth.d.ts.map +1 -0
- package/dist/lib/cloud-auth.js +179 -0
- package/dist/lib/cloud-auth.js.map +1 -0
- package/dist/lib/cloud-config.d.ts +31 -0
- package/dist/lib/cloud-config.d.ts.map +1 -0
- package/dist/lib/cloud-config.js +128 -0
- package/dist/lib/cloud-config.js.map +1 -0
- package/dist/lib/cloud-organizations.d.ts +17 -0
- package/dist/lib/cloud-organizations.d.ts.map +1 -0
- package/dist/lib/cloud-organizations.js +36 -0
- package/dist/lib/cloud-organizations.js.map +1 -0
- package/dist/lib/cloud-provision.d.ts +20 -0
- package/dist/lib/cloud-provision.d.ts.map +1 -0
- package/dist/lib/cloud-provision.js +59 -0
- package/dist/lib/cloud-provision.js.map +1 -0
- package/dist/lib/cloud-remote.d.ts +37 -0
- package/dist/lib/cloud-remote.d.ts.map +1 -0
- package/dist/lib/cloud-remote.js +118 -0
- package/dist/lib/cloud-remote.js.map +1 -0
- package/dist/lib/cloud-setup-login.d.ts +9 -0
- package/dist/lib/cloud-setup-login.d.ts.map +1 -0
- package/dist/lib/cloud-setup-login.js +136 -0
- package/dist/lib/cloud-setup-login.js.map +1 -0
- package/dist/lib/cloud-url.d.ts +3 -0
- package/dist/lib/cloud-url.d.ts.map +1 -0
- package/dist/lib/cloud-url.js +10 -0
- package/dist/lib/cloud-url.js.map +1 -0
- package/dist/lib/create-project.d.ts +51 -0
- package/dist/lib/create-project.d.ts.map +1 -0
- package/dist/lib/create-project.js +458 -0
- package/dist/lib/create-project.js.map +1 -0
- package/dist/lib/handle-cli-error.d.ts +2 -0
- package/dist/lib/handle-cli-error.d.ts.map +1 -0
- package/dist/lib/handle-cli-error.js +16 -0
- package/dist/lib/handle-cli-error.js.map +1 -0
- package/dist/lib/init-finish.d.ts +46 -0
- package/dist/lib/init-finish.d.ts.map +1 -0
- package/dist/lib/init-finish.js +187 -0
- package/dist/lib/init-finish.js.map +1 -0
- package/dist/lib/install-ai-sdk-lib.d.ts +2 -0
- package/dist/lib/install-ai-sdk-lib.d.ts.map +1 -0
- package/dist/lib/install-ai-sdk-lib.js +21 -0
- package/dist/lib/install-ai-sdk-lib.js.map +1 -0
- package/dist/lib/install-edge-lib.d.ts +2 -0
- package/dist/lib/install-edge-lib.d.ts.map +1 -0
- package/dist/lib/install-edge-lib.js +14 -0
- package/dist/lib/install-edge-lib.js.map +1 -0
- package/dist/lib/run-spawn.d.ts +21 -0
- package/dist/lib/run-spawn.d.ts.map +1 -0
- package/dist/lib/run-spawn.js +118 -0
- package/dist/lib/run-spawn.js.map +1 -0
- package/dist/lib/safe-project-file.d.ts +2 -0
- package/dist/lib/safe-project-file.d.ts.map +1 -0
- package/dist/lib/safe-project-file.js +25 -0
- package/dist/lib/safe-project-file.js.map +1 -0
- package/dist/lib/setup-session.d.ts +44 -0
- package/dist/lib/setup-session.d.ts.map +1 -0
- package/dist/lib/setup-session.js +122 -0
- package/dist/lib/setup-session.js.map +1 -0
- package/dist/lib/transform-options.d.ts +7 -0
- package/dist/lib/transform-options.d.ts.map +1 -0
- package/dist/lib/transform-options.js +0 -0
- package/dist/lib/transform.d.ts +17 -0
- package/dist/lib/transform.d.ts.map +1 -0
- package/dist/lib/transform.js +75 -0
- package/dist/lib/transform.js.map +1 -0
- package/dist/lib/upgrade.d.ts +9 -0
- package/dist/lib/upgrade.d.ts.map +1 -0
- package/dist/lib/upgrade.js +68 -0
- package/dist/lib/upgrade.js.map +1 -0
- package/dist/lib/utils/config.d.ts +20 -0
- package/dist/lib/utils/config.d.ts.map +1 -0
- package/dist/lib/utils/config.js +28 -0
- package/dist/lib/utils/config.js.map +1 -0
- package/dist/lib/utils/download.d.ts +5 -0
- package/dist/lib/utils/download.d.ts.map +1 -0
- package/dist/lib/utils/download.js +40 -0
- package/dist/lib/utils/download.js.map +1 -0
- package/dist/lib/utils/file-scanner.d.ts +15 -0
- package/dist/lib/utils/file-scanner.d.ts.map +1 -0
- package/dist/lib/utils/file-scanner.js +37 -0
- package/dist/lib/utils/file-scanner.js.map +1 -0
- package/dist/lib/utils/logger.d.ts +9 -0
- package/dist/lib/utils/logger.d.ts.map +1 -0
- package/dist/lib/utils/logger.js +25 -0
- package/dist/lib/utils/logger.js.map +1 -0
- package/dist/lib/utils/package-installer.d.ts +9 -0
- package/dist/lib/utils/package-installer.d.ts.map +1 -0
- package/dist/lib/utils/package-installer.js +21 -0
- package/dist/lib/utils/package-installer.js.map +1 -0
- package/dist/lib/utils/package-json.d.ts +2 -0
- package/dist/lib/utils/package-json.d.ts.map +1 -0
- package/dist/lib/utils/package-json.js +10 -0
- package/dist/lib/utils/package-json.js.map +1 -0
- package/dist/lib/utils/package-manager.d.ts +24 -0
- package/dist/lib/utils/package-manager.d.ts.map +1 -0
- package/dist/lib/utils/package-manager.js +117 -0
- package/dist/lib/utils/package-manager.js.map +1 -0
- package/dist/lib/utils/registry.d.ts +6 -0
- package/dist/lib/utils/registry.d.ts.map +1 -0
- package/dist/lib/utils/registry.js +35 -0
- package/dist/lib/utils/registry.js.map +1 -0
- package/dist/lib/utils/workspace.d.ts +3 -0
- package/dist/lib/utils/workspace.d.ts.map +1 -0
- package/dist/lib/utils/workspace.js +27 -0
- package/dist/lib/utils/workspace.js.map +1 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +22 -0
- package/dist/program.js.map +1 -0
- package/dist/run.d.ts +2 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +8 -0
- package/dist/run.js.map +1 -0
- package/package.json +76 -4
- package/src/codemods/utils/createTransformer.ts +41 -0
- package/src/codemods/utils/resolveBinding.test.ts +107 -0
- package/src/codemods/utils/resolveBinding.ts +130 -0
- package/src/codemods/v0-11/README.md +246 -0
- package/src/codemods/v0-11/__tests__/content-part-to-message-part.test.ts +496 -0
- package/src/codemods/v0-11/content-part-to-message-part.ts +302 -0
- package/src/codemods/v0-12/__tests__/assistant-api-to-aui.test.ts +1220 -0
- package/src/codemods/v0-12/__tests__/event-names-to-camelcase.test.ts +150 -0
- package/src/codemods/v0-12/__tests__/primitive-if-to-aui-if.test.ts +1166 -0
- package/src/codemods/v0-12/assistant-api-to-aui.ts +270 -0
- package/src/codemods/v0-12/event-names-to-camelcase.ts +47 -0
- package/src/codemods/v0-12/primitive-if-to-aui-if.ts +372 -0
- package/src/codemods/v0-15/__tests__/aui-accessor-calls-to-properties.test.ts +210 -0
- package/src/codemods/v0-15/aui-accessor-calls-to-properties.ts +138 -0
- package/src/codemods/v0-8/__tests__/ui-package-split.test.ts +83 -0
- package/src/codemods/v0-8/ui-package-split.ts +159 -0
- package/src/codemods/v0-9/edge-package-split.test.ts +100 -0
- package/src/codemods/v0-9/edge-package-split.ts +70 -0
- package/src/commands/add.ts +111 -0
- package/src/commands/agent.ts +31 -0
- package/src/commands/cloud.test.ts +477 -0
- package/src/commands/cloud.ts +523 -0
- package/src/commands/create.ts +914 -0
- package/src/commands/doctor.ts +425 -0
- package/src/commands/info.ts +481 -0
- package/src/commands/init.ts +156 -0
- package/src/commands/mcp.test.ts +123 -0
- package/src/commands/mcp.ts +475 -0
- package/src/commands/setup.test.ts +285 -0
- package/src/commands/setup.ts +240 -0
- package/src/commands/update.ts +86 -0
- package/src/commands/upgrade.ts +66 -0
- package/src/index.ts +6 -0
- package/src/lib/agent-gate.test.ts +435 -0
- package/src/lib/agent-gate.ts +271 -0
- package/src/lib/agent-setup-hint.test.ts +134 -0
- package/src/lib/agent-setup-hint.ts +56 -0
- package/src/lib/agent-skill.ts +107 -0
- package/src/lib/cloud-abort.ts +12 -0
- package/src/lib/cloud-auth.test.ts +536 -0
- package/src/lib/cloud-auth.ts +299 -0
- package/src/lib/cloud-config.test.ts +220 -0
- package/src/lib/cloud-config.ts +217 -0
- package/src/lib/cloud-organizations.test.ts +76 -0
- package/src/lib/cloud-organizations.ts +55 -0
- package/src/lib/cloud-provision.test.ts +157 -0
- package/src/lib/cloud-provision.ts +96 -0
- package/src/lib/cloud-remote.test.ts +252 -0
- package/src/lib/cloud-remote.ts +236 -0
- package/src/lib/cloud-setup-login.test.ts +361 -0
- package/src/lib/cloud-setup-login.ts +240 -0
- package/src/lib/cloud-url.ts +21 -0
- package/src/lib/create-project-format.test.ts +122 -0
- package/src/lib/create-project.test.ts +158 -0
- package/src/lib/create-project.ts +717 -0
- package/src/lib/handle-cli-error.test.ts +67 -0
- package/src/lib/handle-cli-error.ts +17 -0
- package/src/lib/init-finish.ts +293 -0
- package/src/lib/install-ai-sdk-lib.ts +25 -0
- package/src/lib/install-edge-lib.ts +16 -0
- package/src/lib/run-spawn.test.ts +194 -0
- package/src/lib/run-spawn.ts +154 -0
- package/src/lib/safe-project-file.ts +31 -0
- package/src/lib/setup-session.test.ts +184 -0
- package/src/lib/setup-session.ts +179 -0
- package/src/lib/transform-files.test.ts +69 -0
- package/src/lib/transform-options.ts +6 -0
- package/src/lib/transform.test.ts +155 -0
- package/src/lib/transform.ts +131 -0
- package/src/lib/upgrade.ts +89 -0
- package/src/lib/utils/config.ts +60 -0
- package/src/lib/utils/download.ts +57 -0
- package/src/lib/utils/file-scanner.ts +51 -0
- package/src/lib/utils/logger.ts +22 -0
- package/src/lib/utils/package-installer.test.ts +39 -0
- package/src/lib/utils/package-installer.ts +40 -0
- package/src/lib/utils/package-json.ts +12 -0
- package/src/lib/utils/package-manager.ts +160 -0
- package/src/lib/utils/registry.test.ts +164 -0
- package/src/lib/utils/registry.ts +78 -0
- package/src/lib/utils/workspace.ts +34 -0
- package/src/program.ts +37 -0
- package/src/run.test.ts +23 -0
- package/src/run.ts +5 -0
- package/templates/cloud-harness/.assistant-ui/template.json +3 -0
- package/templates/cloud-harness/.env.example +1 -0
- package/templates/cloud-harness/.oxfmtrc.json +32 -0
- package/templates/cloud-harness/README.md +28 -0
- package/templates/cloud-harness/app/api/chat/route.ts +22 -0
- package/templates/cloud-harness/app/api/credential/route.ts +14 -0
- package/templates/cloud-harness/app/api/request-context.ts +16 -0
- package/templates/cloud-harness/app/assistant.tsx +83 -0
- package/templates/cloud-harness/app/favicon.ico +0 -0
- package/templates/cloud-harness/app/globals.css +139 -0
- package/templates/cloud-harness/app/layout.tsx +37 -0
- package/templates/cloud-harness/app/page.tsx +5 -0
- package/templates/cloud-harness/components/assistant-ui/elements/attachment-state.ts +59 -0
- package/templates/cloud-harness/components/assistant-ui/elements/attachment.aui.tsx +246 -0
- package/templates/cloud-harness/components/assistant-ui/elements/collapsible-root.tsx +19 -0
- package/templates/cloud-harness/components/assistant-ui/elements/markdown-text.tsx +238 -0
- package/templates/cloud-harness/components/assistant-ui/elements/thread.aui.tsx +521 -0
- package/templates/cloud-harness/components/assistant-ui/elements/tool-fallback.aui.tsx +1336 -0
- package/templates/cloud-harness/components/assistant-ui/elements/tooltip-icon-button.tsx +49 -0
- package/templates/cloud-harness/components/ui/avatar.tsx +109 -0
- package/templates/cloud-harness/components/ui/button.tsx +58 -0
- package/templates/cloud-harness/components/ui/collapsible.tsx +21 -0
- package/templates/cloud-harness/components/ui/dialog.tsx +159 -0
- package/templates/cloud-harness/components/ui/textarea.tsx +18 -0
- package/templates/cloud-harness/components/ui/tooltip.tsx +69 -0
- package/templates/cloud-harness/components.json +24 -0
- package/templates/cloud-harness/hooks/use-attachment-src.ts +46 -0
- package/templates/cloud-harness/hooks/use-copy-to-clipboard.ts +54 -0
- package/templates/cloud-harness/lib/utils.ts +1 -0
- package/templates/cloud-harness/next.config.ts +6 -0
- package/templates/cloud-harness/package.json +51 -0
- package/templates/cloud-harness/postcss.config.mjs +5 -0
- package/templates/cloud-harness/tsconfig.json +33 -0
- package/templates/cloud-harness/vendor/LICENSE +21 -0
- package/templates/cloud-harness/vendor/README.md +13 -0
- package/templates/cloud-harness/vendor/assistant-ui-react-harness-sdk-0.0.2.tgz +0 -0
- package/templates/cloud-harness/vendor/harness-sdk-0.3.1.tgz +0 -0
- package/templates/cloud-harness/vendor/provenance.json +38 -0
- package/templates/cloud-harness/vendor/statewire-0.19.3.tgz +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SpawnSignalError } from "../lib/run-spawn.js";
|
|
2
|
+
import { transform } from "../lib/transform.js";
|
|
3
|
+
import { upgrade } from "../lib/upgrade.js";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import debug from "debug";
|
|
6
|
+
// src/commands/upgrade.ts
|
|
7
|
+
const error = debug("codemod:error");
|
|
8
|
+
debug.enable("codemod:*");
|
|
9
|
+
const addTransformOptions = (command) => {
|
|
10
|
+
return command.option("-d, --dry", "Dry run (no changes are made to files)").option("-p, --print", "Print transformed files to stdout").option("--verbose", "Show more information about the transform process").option("-j, --jscodeshift <options>", "Pass options directly to jscodeshift");
|
|
11
|
+
};
|
|
12
|
+
const codemodCommand = addTransformOptions(new Command().name("codemod").description("CLI tool for running codemods").argument("<codemod>", "Codemod to run (e.g., rewrite-framework-imports)").argument("<source>", "Path to source files or directory to transform")).action(async (codemod, source, options) => {
|
|
13
|
+
try {
|
|
14
|
+
await transform(codemod, source, options);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
if (err instanceof SpawnSignalError) throw err;
|
|
17
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
18
|
+
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
19
|
+
error(`Error transforming: ${errorMessage}`);
|
|
20
|
+
if (errorStack) error(errorStack);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const upgradeCommand = addTransformOptions(new Command().command("upgrade").description("Upgrade ai package dependencies and apply codemods")).action(async (options) => {
|
|
25
|
+
try {
|
|
26
|
+
await upgrade(options);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
if (err instanceof SpawnSignalError) throw err;
|
|
29
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
30
|
+
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
31
|
+
error(`Error upgrading: ${errorMessage}`);
|
|
32
|
+
if (errorStack) error(errorStack);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export { codemodCommand, upgradeCommand };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","names":[],"sources":["../../src/commands/upgrade.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { transform } from \"../lib/transform\";\nimport { upgrade } from \"../lib/upgrade\";\nimport { SpawnSignalError } from \"../lib/run-spawn\";\nimport debug from \"debug\";\n\nexport interface TransformOptions {\n dry?: boolean;\n print?: boolean;\n verbose?: boolean;\n jscodeshift?: string;\n}\n\nconst error = debug(\"codemod:error\");\ndebug.enable(\"codemod:*\");\n\nconst addTransformOptions = (command: Command): Command => {\n return command\n .option(\"-d, --dry\", \"Dry run (no changes are made to files)\")\n .option(\"-p, --print\", \"Print transformed files to stdout\")\n .option(\"--verbose\", \"Show more information about the transform process\")\n .option(\n \"-j, --jscodeshift <options>\",\n \"Pass options directly to jscodeshift\",\n );\n};\n\nexport const codemodCommand = addTransformOptions(\n new Command()\n .name(\"codemod\")\n .description(\"CLI tool for running codemods\")\n .argument(\"<codemod>\", \"Codemod to run (e.g., rewrite-framework-imports)\")\n .argument(\"<source>\", \"Path to source files or directory to transform\"),\n).action(async (codemod, source, options: TransformOptions) => {\n try {\n await transform(codemod, source, options);\n } catch (err) {\n if (err instanceof SpawnSignalError) throw err;\n const errorMessage = err instanceof Error ? err.message : String(err);\n const errorStack = err instanceof Error ? err.stack : undefined;\n error(`Error transforming: ${errorMessage}`);\n if (errorStack) {\n error(errorStack);\n }\n process.exit(1);\n }\n});\n\nexport const upgradeCommand = addTransformOptions(\n new Command()\n .command(\"upgrade\")\n .description(\"Upgrade ai package dependencies and apply codemods\"),\n).action(async (options: TransformOptions) => {\n try {\n await upgrade(options);\n } catch (err) {\n if (err instanceof SpawnSignalError) throw err;\n const errorMessage = err instanceof Error ? err.message : String(err);\n const errorStack = err instanceof Error ? err.stack : undefined;\n error(`Error upgrading: ${errorMessage}`);\n if (errorStack) {\n error(errorStack);\n }\n process.exit(1);\n }\n});\n"],"mappings":";;;;;;AAaA,MAAM,QAAQ,MAAM,eAAe;AACnC,MAAM,OAAO,WAAW;AAExB,MAAM,uBAAuB,YAA8B;CACzD,OAAO,QACJ,OAAO,aAAa,wCAAwC,CAAC,CAC7D,OAAO,eAAe,mCAAmC,CAAC,CAC1D,OAAO,aAAa,mDAAmD,CAAC,CACxE,OACC,+BACA,sCACF;AACJ;AAEA,MAAa,iBAAiB,oBAC5B,IAAI,QAAQ,CAAC,CACV,KAAK,SAAS,CAAC,CACf,YAAY,+BAA+B,CAAC,CAC5C,SAAS,aAAa,kDAAkD,CAAC,CACzE,SAAS,YAAY,gDAAgD,CAC1E,CAAC,CAAC,OAAO,OAAO,SAAS,QAAQ,YAA8B;CAC7D,IAAI;EACF,MAAM,UAAU,SAAS,QAAQ,OAAO;CAC1C,SAAS,KAAK;EACZ,IAAI,eAAe,kBAAkB,MAAM;EAC3C,MAAM,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EACpE,MAAM,aAAa,eAAe,QAAQ,IAAI,QAAQ,KAAA;EACtD,MAAM,uBAAuB,cAAc;EAC3C,IAAI,YACF,MAAM,UAAU;EAElB,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC;AAED,MAAa,iBAAiB,oBAC5B,IAAI,QAAQ,CAAC,CACV,QAAQ,SAAS,CAAC,CAClB,YAAY,oDAAoD,CACrE,CAAC,CAAC,OAAO,OAAO,YAA8B;CAC5C,IAAI;EACF,MAAM,QAAQ,OAAO;CACvB,SAAS,KAAK;EACZ,IAAI,eAAe,kBAAkB,MAAM;EAC3C,MAAM,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EACpE,MAAM,aAAa,eAAe,QAAQ,IAAI,QAAQ,KAAA;EACtD,MAAM,oBAAoB,cAAc;EACxC,IAAI,YACF,MAAM,UAAU;EAElB,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { handleCliError } from \"./lib/handle-cli-error\";\nimport { runCli } from \"./run\";\n\nvoid runCli().catch(handleCliError);\n"],"mappings":";;;;AAKK,OAAO,CAAC,CAAC,MAAM,cAAc"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Command } from "commander";
|
|
2
|
+
export declare const AGENT_GATE_MESSAGE = "assistant-ui: you're running as a coding agent. Run `npx assistant-ui@latest setup` instead; it opens a guided setup in the user's browser and gives you the steps. A setup session covers the folder setup runs in and the folders inside it. `init`/`create`/`add` are the manual paths; pass --force only if the user explicitly asked for them. If you are a person and your terminal inherited a coding agent's environment, pass --force or set ASSISTANT_UI_ALLOW_AGENT=1.";
|
|
3
|
+
/** Exit code for a command stopped by the gate, apart from failures (1). */
|
|
4
|
+
export declare const AGENT_GATE_EXIT_CODE = 2;
|
|
5
|
+
/** How long a setup session lets the agent run the manual commands, counted from when setup started it. */
|
|
6
|
+
export declare const SETUP_SESSION_TTL_MS: number;
|
|
7
|
+
/** True when `dir` is the folder `root` or a folder inside it. */
|
|
8
|
+
export declare const isInsideFolder: (dir: string, root: string) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Where `setup` notes that the setup session `setupId` is active for the
|
|
11
|
+
* project folder `project`. One file per OS user, project and setup, so no
|
|
12
|
+
* setup replaces or removes another's marker. It lives in the temp directory,
|
|
13
|
+
* which the agent's shell shares across the commands it runs and which
|
|
14
|
+
* sandboxed agents can write to, and never in the user's project.
|
|
15
|
+
*/
|
|
16
|
+
export declare const setupSessionMarkerPath: (project: string, setupId: string, dir?: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Records that a setup session started in `cwd`, so the commands its steps
|
|
19
|
+
* run there pass the gate. Returns the marker's path, or undefined when it
|
|
20
|
+
* could not be written.
|
|
21
|
+
*/
|
|
22
|
+
export declare const markSetupSession: (session: {
|
|
23
|
+
setupId: string;
|
|
24
|
+
cwd?: string;
|
|
25
|
+
now?: number;
|
|
26
|
+
}, dir?: string) => string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Removes a setup session's marker; setup calls it when it exits. Other
|
|
29
|
+
* setups in the same project keep their own markers.
|
|
30
|
+
*/
|
|
31
|
+
export declare const clearSetupSession: (file: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* True while a setup session is active for the folder `target` (the folder
|
|
34
|
+
* the gated command acts on) or a parent of it: setup wrote its marker there
|
|
35
|
+
* less than the TTL ago and has not exited. The lifetime is fixed when setup
|
|
36
|
+
* starts; using the session does not extend it.
|
|
37
|
+
*/
|
|
38
|
+
export declare const isSetupSessionActive: ({ target, now, dir, }?: {
|
|
39
|
+
target?: string;
|
|
40
|
+
now?: number;
|
|
41
|
+
dir?: string;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
export type AgentGateInput = {
|
|
44
|
+
env?: NodeJS.ProcessEnv;
|
|
45
|
+
force?: boolean;
|
|
46
|
+
setupSessionActive?: () => boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Whether to stop a manual command: only under a coding agent, outside a
|
|
50
|
+
* setup session, and without `--force` or `ASSISTANT_UI_ALLOW_AGENT`.
|
|
51
|
+
* People and CI without agent markers always pass.
|
|
52
|
+
*/
|
|
53
|
+
export declare const shouldGateAgent: ({ env, force, setupSessionActive, }?: AgentGateInput) => boolean;
|
|
54
|
+
/** The command name typed on the command line, not one another command runs internally. */
|
|
55
|
+
export declare const typedCommand: (argv?: readonly string[]) => string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Stops `command` when a coding agent types it outside a setup session for
|
|
58
|
+
* the folder it acts on, and points the agent at `setup`. Commands that run
|
|
59
|
+
* it internally (init runs create, cloud setup runs create) are not stopped.
|
|
60
|
+
* Pass `projectArgument` when the command's first argument is the project
|
|
61
|
+
* directory it acts on.
|
|
62
|
+
*/
|
|
63
|
+
export declare const addAgentGate: (command: Command, options?: {
|
|
64
|
+
projectArgument?: boolean;
|
|
65
|
+
}) => Command;
|
|
66
|
+
//# sourceMappingURL=agent-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-gate.d.ts","sourceRoot":"","sources":["../../src/lib/agent-gate.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AAE,YA2BvC,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Option } from "commander";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { detectAgentKind } from "setup-agent/cli";
|
|
7
|
+
// src/lib/agent-gate.ts
|
|
8
|
+
const AGENT_GATE_MESSAGE = "assistant-ui: you're running as a coding agent. Run `npx assistant-ui@latest setup` instead; it opens a guided setup in the user's browser and gives you the steps. A setup session covers the folder setup runs in and the folders inside it. `init`/`create`/`add` are the manual paths; pass --force only if the user explicitly asked for them. If you are a person and your terminal inherited a coding agent's environment, pass --force or set ASSISTANT_UI_ALLOW_AGENT=1.";
|
|
9
|
+
/** Exit code for a command stopped by the gate, apart from failures (1). */
|
|
10
|
+
const AGENT_GATE_EXIT_CODE = 2;
|
|
11
|
+
/** How long a setup session lets the agent run the manual commands, counted from when setup started it. */
|
|
12
|
+
const SETUP_SESSION_TTL_MS = 72e5;
|
|
13
|
+
/**
|
|
14
|
+
* The real path of `dir`, also for a folder that does not exist yet (such as
|
|
15
|
+
* the one `create` is about to make): the nearest existing parent is resolved
|
|
16
|
+
* and the rest appended.
|
|
17
|
+
*/
|
|
18
|
+
const realPath = (dir) => {
|
|
19
|
+
const resolved = path.resolve(dir);
|
|
20
|
+
try {
|
|
21
|
+
return fs.realpathSync(resolved);
|
|
22
|
+
} catch {
|
|
23
|
+
const parent = path.dirname(resolved);
|
|
24
|
+
if (parent === resolved) return resolved;
|
|
25
|
+
return path.join(realPath(parent), path.basename(resolved));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** True when `dir` is the folder `root` or a folder inside it. */
|
|
29
|
+
const isInsideFolder = (dir, root) => {
|
|
30
|
+
const relative = path.relative(realPath(root), realPath(dir));
|
|
31
|
+
if (relative === "") return true;
|
|
32
|
+
if (path.isAbsolute(relative)) return false;
|
|
33
|
+
return relative.split(path.sep)[0] !== "..";
|
|
34
|
+
};
|
|
35
|
+
const hash = (value, length) => createHash("sha256").update(value).digest("hex").slice(0, length);
|
|
36
|
+
/** The start of every marker name this OS user's setups write. */
|
|
37
|
+
const userMarkerPrefix = () => `assistant-ui-setup-${process.getuid?.() ?? "user"}-`;
|
|
38
|
+
/** The start of every marker name for setups in the project folder `project`. */
|
|
39
|
+
const markerPrefix = (project) => `${userMarkerPrefix()}${hash(realPath(project), 16)}-`;
|
|
40
|
+
/**
|
|
41
|
+
* Where `setup` notes that the setup session `setupId` is active for the
|
|
42
|
+
* project folder `project`. One file per OS user, project and setup, so no
|
|
43
|
+
* setup replaces or removes another's marker. It lives in the temp directory,
|
|
44
|
+
* which the agent's shell shares across the commands it runs and which
|
|
45
|
+
* sandboxed agents can write to, and never in the user's project.
|
|
46
|
+
*/
|
|
47
|
+
const setupSessionMarkerPath = (project, setupId, dir = os.tmpdir()) => path.join(dir, `${markerPrefix(project)}${hash(setupId, 12)}.json`);
|
|
48
|
+
/**
|
|
49
|
+
* Records that a setup session started in `cwd`, so the commands its steps
|
|
50
|
+
* run there pass the gate. Returns the marker's path, or undefined when it
|
|
51
|
+
* could not be written.
|
|
52
|
+
*/
|
|
53
|
+
const markSetupSession = (session, dir = os.tmpdir()) => {
|
|
54
|
+
const cwd = realPath(session.cwd ?? process.cwd());
|
|
55
|
+
const file = setupSessionMarkerPath(cwd, session.setupId, dir);
|
|
56
|
+
const marker = {
|
|
57
|
+
setupId: session.setupId,
|
|
58
|
+
cwd,
|
|
59
|
+
startedAt: session.now ?? Date.now()
|
|
60
|
+
};
|
|
61
|
+
try {
|
|
62
|
+
fs.writeFileSync(file, JSON.stringify(marker), { mode: 384 });
|
|
63
|
+
} catch {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
removeExpiredMarkers(dir, marker.startedAt);
|
|
67
|
+
return file;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Deletes this user's markers that are past the TTL, left behind by setups
|
|
71
|
+
* that were killed before they could remove their own.
|
|
72
|
+
*/
|
|
73
|
+
const removeExpiredMarkers = (dir, now) => {
|
|
74
|
+
let names;
|
|
75
|
+
try {
|
|
76
|
+
names = fs.readdirSync(dir);
|
|
77
|
+
} catch {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const prefix = userMarkerPrefix();
|
|
81
|
+
for (const name of names) {
|
|
82
|
+
if (!name.startsWith(prefix) || !name.endsWith(".json")) continue;
|
|
83
|
+
const file = path.join(dir, name);
|
|
84
|
+
const marker = readMarker(file);
|
|
85
|
+
if (marker !== void 0 && now - marker.startedAt > 72e5) clearSetupSession(file);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const readMarker = (file) => {
|
|
89
|
+
try {
|
|
90
|
+
if (!fs.lstatSync(file).isFile()) return void 0;
|
|
91
|
+
const marker = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
92
|
+
if (typeof marker.setupId !== "string" || typeof marker.cwd !== "string" || typeof marker.startedAt !== "number") return void 0;
|
|
93
|
+
return marker;
|
|
94
|
+
} catch {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Removes a setup session's marker; setup calls it when it exits. Other
|
|
100
|
+
* setups in the same project keep their own markers.
|
|
101
|
+
*/
|
|
102
|
+
const clearSetupSession = (file) => {
|
|
103
|
+
try {
|
|
104
|
+
fs.rmSync(file, { force: true });
|
|
105
|
+
} catch {}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* True while a setup session is active for the folder `target` (the folder
|
|
109
|
+
* the gated command acts on) or a parent of it: setup wrote its marker there
|
|
110
|
+
* less than the TTL ago and has not exited. The lifetime is fixed when setup
|
|
111
|
+
* starts; using the session does not extend it.
|
|
112
|
+
*/
|
|
113
|
+
const isSetupSessionActive = ({ target = process.cwd(), now = Date.now(), dir = os.tmpdir() } = {}) => {
|
|
114
|
+
let names;
|
|
115
|
+
try {
|
|
116
|
+
names = fs.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
117
|
+
} catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
const isLive = (marker, folder) => marker !== void 0 && marker.cwd === folder && now - marker.startedAt >= 0 && now - marker.startedAt <= 72e5 && isInsideFolder(target, marker.cwd);
|
|
121
|
+
let folder = realPath(target);
|
|
122
|
+
for (;;) {
|
|
123
|
+
const prefix = markerPrefix(folder);
|
|
124
|
+
for (const name of names) if (name.startsWith(prefix) && isLive(readMarker(path.join(dir, name)), folder)) return true;
|
|
125
|
+
const parent = path.dirname(folder);
|
|
126
|
+
if (parent === folder) return false;
|
|
127
|
+
folder = parent;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const isSet = (value) => value !== void 0 && ![
|
|
131
|
+
"",
|
|
132
|
+
"0",
|
|
133
|
+
"false"
|
|
134
|
+
].includes(value.toLowerCase());
|
|
135
|
+
/**
|
|
136
|
+
* Whether to stop a manual command: only under a coding agent, outside a
|
|
137
|
+
* setup session, and without `--force` or `ASSISTANT_UI_ALLOW_AGENT`.
|
|
138
|
+
* People and CI without agent markers always pass.
|
|
139
|
+
*/
|
|
140
|
+
const shouldGateAgent = ({ env = process.env, force = false, setupSessionActive = isSetupSessionActive } = {}) => detectAgentKind(env) !== void 0 && !force && !isSet(env.ASSISTANT_UI_ALLOW_AGENT) && !setupSessionActive();
|
|
141
|
+
/** The command name typed on the command line, not one another command runs internally. */
|
|
142
|
+
const typedCommand = (argv = process.argv) => argv.slice(2).find((arg) => !arg.startsWith("-"));
|
|
143
|
+
/**
|
|
144
|
+
* The folder a gated command acts on: its `--cwd` (or the current folder),
|
|
145
|
+
* joined with its project directory argument when it takes one.
|
|
146
|
+
*/
|
|
147
|
+
const gateTarget = (command, { projectArgument = false } = {}) => {
|
|
148
|
+
const { cwd } = command.opts();
|
|
149
|
+
const base = typeof cwd === "string" ? path.resolve(process.cwd(), cwd) : path.resolve(process.cwd());
|
|
150
|
+
const project = projectArgument ? command.args[0] : void 0;
|
|
151
|
+
return typeof project === "string" && project !== "" ? path.resolve(base, project) : base;
|
|
152
|
+
};
|
|
153
|
+
const gated = /* @__PURE__ */ new WeakSet();
|
|
154
|
+
/**
|
|
155
|
+
* Stops `command` when a coding agent types it outside a setup session for
|
|
156
|
+
* the folder it acts on, and points the agent at `setup`. Commands that run
|
|
157
|
+
* it internally (init runs create, cloud setup runs create) are not stopped.
|
|
158
|
+
* Pass `projectArgument` when the command's first argument is the project
|
|
159
|
+
* directory it acts on.
|
|
160
|
+
*/
|
|
161
|
+
const addAgentGate = (command, options = {}) => {
|
|
162
|
+
if (gated.has(command)) return command;
|
|
163
|
+
gated.add(command);
|
|
164
|
+
command.addOption(new Option("--force", "run even when a coding agent is detected outside a setup session").hideHelp());
|
|
165
|
+
command.hook("preAction", async (thisCommand) => {
|
|
166
|
+
if (typedCommand() !== command.name()) return;
|
|
167
|
+
const force = thisCommand.opts().force === true;
|
|
168
|
+
const target = gateTarget(thisCommand, options);
|
|
169
|
+
if (!shouldGateAgent({
|
|
170
|
+
force,
|
|
171
|
+
setupSessionActive: () => isSetupSessionActive({ target })
|
|
172
|
+
})) return;
|
|
173
|
+
await new Promise((resolve) => process.stderr.write(`${AGENT_GATE_MESSAGE}\n`, () => resolve()));
|
|
174
|
+
process.exit(2);
|
|
175
|
+
});
|
|
176
|
+
return command;
|
|
177
|
+
};
|
|
178
|
+
export { AGENT_GATE_EXIT_CODE, AGENT_GATE_MESSAGE, SETUP_SESSION_TTL_MS, addAgentGate, clearSetupSession, isInsideFolder, isSetupSessionActive, markSetupSession, setupSessionMarkerPath, shouldGateAgent, typedCommand };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=agent-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-gate.js","names":[],"sources":["../../src/lib/agent-gate.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { type Command, Option } from \"commander\";\nimport { detectAgentKind } from \"setup-agent/cli\";\n\nexport const AGENT_GATE_MESSAGE =\n \"assistant-ui: you're running as a coding agent. Run `npx assistant-ui@latest setup` instead; it opens a guided setup in the user's browser and gives you the steps. A setup session covers the folder setup runs in and the folders inside it. `init`/`create`/`add` are the manual paths; pass --force only if the user explicitly asked for them. If you are a person and your terminal inherited a coding agent's environment, pass --force or set ASSISTANT_UI_ALLOW_AGENT=1.\";\n\n/** Exit code for a command stopped by the gate, apart from failures (1). */\nexport const AGENT_GATE_EXIT_CODE = 2;\n\n/** How long a setup session lets the agent run the manual commands, counted from when setup started it. */\nexport const SETUP_SESSION_TTL_MS = 2 * 60 * 60 * 1000;\n\n/**\n * The real path of `dir`, also for a folder that does not exist yet (such as\n * the one `create` is about to make): the nearest existing parent is resolved\n * and the rest appended.\n */\nconst realPath = (dir: string): string => {\n const resolved = path.resolve(dir);\n try {\n return fs.realpathSync(resolved);\n } catch {\n const parent = path.dirname(resolved);\n if (parent === resolved) return resolved;\n return path.join(realPath(parent), path.basename(resolved));\n }\n};\n\n/** True when `dir` is the folder `root` or a folder inside it. */\nexport const isInsideFolder = (dir: string, root: string) => {\n const relative = path.relative(realPath(root), realPath(dir));\n if (relative === \"\") return true;\n if (path.isAbsolute(relative)) return false;\n return relative.split(path.sep)[0] !== \"..\";\n};\n\nconst hash = (value: string, length: number) =>\n createHash(\"sha256\").update(value).digest(\"hex\").slice(0, length);\n\n/** The start of every marker name this OS user's setups write. */\nconst userMarkerPrefix = () =>\n `assistant-ui-setup-${process.getuid?.() ?? \"user\"}-`;\n\n/** The start of every marker name for setups in the project folder `project`. */\nconst markerPrefix = (project: string) =>\n `${userMarkerPrefix()}${hash(realPath(project), 16)}-`;\n\n/**\n * Where `setup` notes that the setup session `setupId` is active for the\n * project folder `project`. One file per OS user, project and setup, so no\n * setup replaces or removes another's marker. It lives in the temp directory,\n * which the agent's shell shares across the commands it runs and which\n * sandboxed agents can write to, and never in the user's project.\n */\nexport const setupSessionMarkerPath = (\n project: string,\n setupId: string,\n dir: string = os.tmpdir(),\n) => path.join(dir, `${markerPrefix(project)}${hash(setupId, 12)}.json`);\n\ntype SetupSessionMarker = {\n setupId: string;\n cwd: string;\n startedAt: number;\n};\n\n/**\n * Records that a setup session started in `cwd`, so the commands its steps\n * run there pass the gate. Returns the marker's path, or undefined when it\n * could not be written.\n */\nexport const markSetupSession = (\n session: { setupId: string; cwd?: string; now?: number },\n dir: string = os.tmpdir(),\n) => {\n const cwd = realPath(session.cwd ?? process.cwd());\n const file = setupSessionMarkerPath(cwd, session.setupId, dir);\n const marker: SetupSessionMarker = {\n setupId: session.setupId,\n cwd,\n startedAt: session.now ?? Date.now(),\n };\n try {\n fs.writeFileSync(file, JSON.stringify(marker), { mode: 0o600 });\n } catch {\n return undefined;\n }\n removeExpiredMarkers(dir, marker.startedAt);\n return file;\n};\n\n/**\n * Deletes this user's markers that are past the TTL, left behind by setups\n * that were killed before they could remove their own.\n */\nconst removeExpiredMarkers = (dir: string, now: number) => {\n let names: string[];\n try {\n names = fs.readdirSync(dir);\n } catch {\n return;\n }\n const prefix = userMarkerPrefix();\n for (const name of names) {\n if (!name.startsWith(prefix) || !name.endsWith(\".json\")) continue;\n const file = path.join(dir, name);\n const marker = readMarker(file);\n if (marker !== undefined && now - marker.startedAt > SETUP_SESSION_TTL_MS)\n clearSetupSession(file);\n }\n};\n\nconst readMarker = (file: string): SetupSessionMarker | undefined => {\n try {\n // Only a regular file setup wrote; a symlink or FIFO could block or point anywhere.\n if (!fs.lstatSync(file).isFile()) return undefined;\n const marker = JSON.parse(fs.readFileSync(file, \"utf8\")) as Partial<\n Record<keyof SetupSessionMarker, unknown>\n >;\n if (\n typeof marker.setupId !== \"string\" ||\n typeof marker.cwd !== \"string\" ||\n typeof marker.startedAt !== \"number\"\n )\n return undefined;\n return marker as SetupSessionMarker;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Removes a setup session's marker; setup calls it when it exits. Other\n * setups in the same project keep their own markers.\n */\nexport const clearSetupSession = (file: string) => {\n try {\n fs.rmSync(file, { force: true });\n } catch {\n // Already gone or not ours to remove; the TTL ends it either way.\n }\n};\n\n/**\n * True while a setup session is active for the folder `target` (the folder\n * the gated command acts on) or a parent of it: setup wrote its marker there\n * less than the TTL ago and has not exited. The lifetime is fixed when setup\n * starts; using the session does not extend it.\n */\nexport const isSetupSessionActive = ({\n target = process.cwd(),\n now = Date.now(),\n dir = os.tmpdir(),\n}: { target?: string; now?: number; dir?: string } = {}) => {\n let names: string[];\n try {\n names = fs.readdirSync(dir).filter((name) => name.endsWith(\".json\"));\n } catch {\n return false;\n }\n const isLive = (marker: SetupSessionMarker | undefined, folder: string) =>\n marker !== undefined &&\n marker.cwd === folder &&\n now - marker.startedAt >= 0 &&\n now - marker.startedAt <= SETUP_SESSION_TTL_MS &&\n isInsideFolder(target, marker.cwd);\n let folder = realPath(target);\n for (;;) {\n const prefix = markerPrefix(folder);\n for (const name of names)\n if (\n name.startsWith(prefix) &&\n isLive(readMarker(path.join(dir, name)), folder)\n )\n return true;\n const parent = path.dirname(folder);\n if (parent === folder) return false;\n folder = parent;\n }\n};\n\nconst isSet = (value: string | undefined) =>\n value !== undefined && ![\"\", \"0\", \"false\"].includes(value.toLowerCase());\n\nexport type AgentGateInput = {\n env?: NodeJS.ProcessEnv;\n force?: boolean;\n setupSessionActive?: () => boolean;\n};\n\n/**\n * Whether to stop a manual command: only under a coding agent, outside a\n * setup session, and without `--force` or `ASSISTANT_UI_ALLOW_AGENT`.\n * People and CI without agent markers always pass.\n */\nexport const shouldGateAgent = ({\n env = process.env,\n force = false,\n setupSessionActive = isSetupSessionActive,\n}: AgentGateInput = {}) =>\n detectAgentKind(env) !== undefined &&\n !force &&\n !isSet(env.ASSISTANT_UI_ALLOW_AGENT) &&\n !setupSessionActive();\n\n/** The command name typed on the command line, not one another command runs internally. */\nexport const typedCommand = (argv: readonly string[] = process.argv) =>\n argv.slice(2).find((arg) => !arg.startsWith(\"-\"));\n\n/**\n * The folder a gated command acts on: its `--cwd` (or the current folder),\n * joined with its project directory argument when it takes one.\n */\nconst gateTarget = (\n command: Command,\n { projectArgument = false }: { projectArgument?: boolean } = {},\n) => {\n const { cwd } = command.opts() as { cwd?: unknown };\n const base =\n typeof cwd === \"string\"\n ? path.resolve(process.cwd(), cwd)\n : path.resolve(process.cwd());\n const project: unknown = projectArgument ? command.args[0] : undefined;\n return typeof project === \"string\" && project !== \"\"\n ? path.resolve(base, project)\n : base;\n};\n\nconst gated = new WeakSet<Command>();\n\n/**\n * Stops `command` when a coding agent types it outside a setup session for\n * the folder it acts on, and points the agent at `setup`. Commands that run\n * it internally (init runs create, cloud setup runs create) are not stopped.\n * Pass `projectArgument` when the command's first argument is the project\n * directory it acts on.\n */\nexport const addAgentGate = (\n command: Command,\n options: { projectArgument?: boolean } = {},\n) => {\n if (gated.has(command)) return command;\n gated.add(command);\n command.addOption(\n new Option(\n \"--force\",\n \"run even when a coding agent is detected outside a setup session\",\n ).hideHelp(),\n );\n command.hook(\"preAction\", async (thisCommand) => {\n if (typedCommand() !== command.name()) return;\n const force = thisCommand.opts().force === true;\n const target = gateTarget(thisCommand, options);\n if (\n !shouldGateAgent({\n force,\n setupSessionActive: () => isSetupSessionActive({ target }),\n })\n )\n return;\n await new Promise<void>((resolve) =>\n process.stderr.write(`${AGENT_GATE_MESSAGE}\\n`, () => resolve()),\n );\n process.exit(AGENT_GATE_EXIT_CODE);\n });\n return command;\n};\n"],"mappings":";;;;;;;AAOA,MAAa,qBACX;;AAGF,MAAa,uBAAuB;;AAGpC,MAAa,uBAAuB;;;;;;AAOpC,MAAM,YAAY,QAAwB;CACxC,MAAM,WAAW,KAAK,QAAQ,GAAG;CACjC,IAAI;EACF,OAAO,GAAG,aAAa,QAAQ;CACjC,QAAQ;EACN,MAAM,SAAS,KAAK,QAAQ,QAAQ;EACpC,IAAI,WAAW,UAAU,OAAO;EAChC,OAAO,KAAK,KAA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;EAC3C,MAAM,SAAS,WAAW,aAAa,OAAO;EAC9C,IACE,CAAC,gBAAgB;GACf;GACA,0BAA0B,qBAAqB,EAAE,OAAO,CAAC;EAC3D,CAAC,GAED;EACF,MAAM,IAAI,SAAe,YACvB,QAAQ,OAAO,MAAM,GAAG,mBAAmB,WAAW,QAAQ,CAAC,CACjE;EACA,QAAQ,KAAA,CAAyB;CACnC,CAAC;CACD,OAAO;AACT"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
export declare const AGENT_SETUP_HINT = "Recommended for coding agents: run `npx assistant-ui@latest setup` in the background (Claude Code: run_in_background) and read its output. It keeps running as the guided setup's stream, walks you through the install, and opens the user's browser when it needs their input. If `setup` isn't a known command (a cached or pnpm release-age-gated version), run `npx -y --prefer-online assistant-ui@latest setup` instead.";
|
|
3
|
+
/** True when a coding agent, or anything else without a terminal, runs the CLI. */
|
|
4
|
+
export declare const isRunByAgent: (env?: NodeJS.ProcessEnv, stdin?: {
|
|
5
|
+
isTTY?: boolean | undefined;
|
|
6
|
+
}, stdout?: {
|
|
7
|
+
isTTY?: boolean | undefined;
|
|
8
|
+
}) => boolean;
|
|
9
|
+
/** Ends `command`'s help with the agent setup hint when an agent reads it, so `--help | tail` keeps it. */
|
|
10
|
+
export declare const addAgentSetupHelp: (command: Command) => Command;
|
|
11
|
+
/**
|
|
12
|
+
* Ends `command`'s help with the agent setup hint when an agent reads it,
|
|
13
|
+
* and prints the hint once after the command finishes for one, where an
|
|
14
|
+
* agent reading the tail of the output sees it. People at a terminal see the
|
|
15
|
+
* usual help and output.
|
|
16
|
+
*/
|
|
17
|
+
export declare const addAgentSetupHint: (command: Command, { afterAction }?: {
|
|
18
|
+
afterAction?: boolean;
|
|
19
|
+
}) => Command;
|
|
20
|
+
//# sourceMappingURL=agent-setup-hint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-setup-hint.d.ts","sourceRoot":"","sources":["../../src/lib/agent-setup-hint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,eAAO,MAAM,gBAAgB,oaACsY,CAAC;AAEpa,mFAAmF;AACnF,eAAO,MAAM,YAAY,SAClB,MAAM,CAAC,UAAU,UACf;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,WAC9B;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,YACG,CAAC;AAK7C,2GAA2G;AAC3G,eAAO,MAAM,iBAAiB,YAAa,OAAO,YAKjD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,YACnB,OAAO,oBACQ;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,YAsBlD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { typedCommand } from "./agent-gate.js";
|
|
2
|
+
import { detectAgentKind, isDirectInvocation } from "setup-agent/cli";
|
|
3
|
+
// src/lib/agent-setup-hint.ts
|
|
4
|
+
const AGENT_SETUP_HINT = "Recommended for coding agents: run `npx assistant-ui@latest setup` in the background (Claude Code: run_in_background) and read its output. It keeps running as the guided setup's stream, walks you through the install, and opens the user's browser when it needs their input. If `setup` isn't a known command (a cached or pnpm release-age-gated version), run `npx -y --prefer-online assistant-ui@latest setup` instead.";
|
|
5
|
+
/** True when a coding agent, or anything else without a terminal, runs the CLI. */
|
|
6
|
+
const isRunByAgent = (env = process.env, stdin = process.stdin, stdout = process.stdout) => !isDirectInvocation(env, stdin, stdout);
|
|
7
|
+
const hinted = /* @__PURE__ */ new WeakSet();
|
|
8
|
+
let printed = false;
|
|
9
|
+
/** Ends `command`'s help with the agent setup hint when an agent reads it, so `--help | tail` keeps it. */
|
|
10
|
+
const addAgentSetupHelp = (command) => {
|
|
11
|
+
command.addHelpText("after", () => isRunByAgent() ? `\n${AGENT_SETUP_HINT}` : "");
|
|
12
|
+
return command;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Ends `command`'s help with the agent setup hint when an agent reads it,
|
|
16
|
+
* and prints the hint once after the command finishes for one, where an
|
|
17
|
+
* agent reading the tail of the output sees it. People at a terminal see the
|
|
18
|
+
* usual help and output.
|
|
19
|
+
*/
|
|
20
|
+
const addAgentSetupHint = (command, { afterAction = true } = {}) => {
|
|
21
|
+
if (hinted.has(command)) return command;
|
|
22
|
+
hinted.add(command);
|
|
23
|
+
addAgentSetupHelp(command);
|
|
24
|
+
if (afterAction) command.hook("postAction", () => {
|
|
25
|
+
if (printed || typedCommand() !== command.name() || !isRunByAgent() || detectAgentKind() !== void 0) return;
|
|
26
|
+
printed = true;
|
|
27
|
+
process.stdout.write(`\n${AGENT_SETUP_HINT}\n`);
|
|
28
|
+
});
|
|
29
|
+
return command;
|
|
30
|
+
};
|
|
31
|
+
export { AGENT_SETUP_HINT, addAgentSetupHelp, addAgentSetupHint, isRunByAgent };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=agent-setup-hint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-setup-hint.js","names":[],"sources":["../../src/lib/agent-setup-hint.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { detectAgentKind, isDirectInvocation } from \"setup-agent/cli\";\nimport { typedCommand } from \"./agent-gate\";\n\nexport const AGENT_SETUP_HINT =\n \"Recommended for coding agents: run `npx assistant-ui@latest setup` in the background (Claude Code: run_in_background) and read its output. It keeps running as the guided setup's stream, walks you through the install, and opens the user's browser when it needs their input. If `setup` isn't a known command (a cached or pnpm release-age-gated version), run `npx -y --prefer-online assistant-ui@latest setup` instead.\";\n\n/** True when a coding agent, or anything else without a terminal, runs the CLI. */\nexport const isRunByAgent = (\n env: NodeJS.ProcessEnv = process.env,\n stdin: { isTTY?: boolean | undefined } = process.stdin,\n stdout: { isTTY?: boolean | undefined } = process.stdout,\n) => !isDirectInvocation(env, stdin, stdout);\n\nconst hinted = new WeakSet<Command>();\nlet printed = false;\n\n/** Ends `command`'s help with the agent setup hint when an agent reads it, so `--help | tail` keeps it. */\nexport const addAgentSetupHelp = (command: Command) => {\n command.addHelpText(\"after\", () =>\n isRunByAgent() ? `\\n${AGENT_SETUP_HINT}` : \"\",\n );\n return command;\n};\n\n/**\n * Ends `command`'s help with the agent setup hint when an agent reads it,\n * and prints the hint once after the command finishes for one, where an\n * agent reading the tail of the output sees it. People at a terminal see the\n * usual help and output.\n */\nexport const addAgentSetupHint = (\n command: Command,\n { afterAction = true }: { afterAction?: boolean } = {},\n) => {\n if (hinted.has(command)) return command;\n hinted.add(command);\n addAgentSetupHelp(command);\n if (afterAction) {\n command.hook(\"postAction\", () => {\n // Other commands run create internally; only the one typed gets the hint.\n // A detected agent got here past the agent gate, from a setup session or\n // with --force, so pointing it at setup again would only send it in circles.\n if (\n printed ||\n typedCommand() !== command.name() ||\n !isRunByAgent() ||\n detectAgentKind() !== undefined\n )\n return;\n printed = true;\n process.stdout.write(`\\n${AGENT_SETUP_HINT}\\n`);\n });\n }\n return command;\n};\n"],"mappings":";;;AAIA,MAAa,mBACX;;AAGF,MAAa,gBACX,MAAyB,QAAQ,KACjC,QAAyC,QAAQ,OACjD,SAA0C,QAAQ,WAC/C,CAAC,mBAAmB,KAAK,OAAO,MAAM;AAE3C,MAAM,yBAAS,IAAI,QAAiB;AACpC,IAAI,UAAU;;AAGd,MAAa,qBAAqB,YAAqB;CACrD,QAAQ,YAAY,eAClB,aAAa,IAAI,KAAK,qBAAqB,EAC7C;CACA,OAAO;AACT;;;;;;;AAQA,MAAa,qBACX,SACA,EAAE,cAAc,SAAoC,CAAC,MAClD;CACH,IAAI,OAAO,IAAI,OAAO,GAAG,OAAO;CAChC,OAAO,IAAI,OAAO;CAClB,kBAAkB,OAAO;CACzB,IAAI,aACF,QAAQ,KAAK,oBAAoB;EAI/B,IACE,WACA,aAAa,MAAM,QAAQ,KAAK,KAChC,CAAC,aAAa,KACd,gBAAgB,MAAM,KAAA,GAEtB;EACF,UAAU;EACV,QAAQ,OAAO,MAAM,KAAK,iBAAiB,GAAG;CAChD,CAAC;CAEH,OAAO;AACT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PackageManagerName } from "./utils/package-manager.js";
|
|
2
|
+
export declare const SKILLS_PACKAGE = "assistant-ui/skills";
|
|
3
|
+
export declare const SKILLS_COMMIT = "b0609e66baff7e19f21053d5492464dcc22ec9c3";
|
|
4
|
+
export declare const SKILLS_PLUGIN_SOURCE = "gh:assistant-ui/skills/assistant-ui#b0609e66baff7e19f21053d5492464dcc22ec9c3";
|
|
5
|
+
export declare function resolveSkillsInstall(params: {
|
|
6
|
+
skills?: boolean;
|
|
7
|
+
stdinIsTTY?: boolean;
|
|
8
|
+
}): boolean | undefined;
|
|
9
|
+
export declare function buildSkillsAddCommand(pm: PackageManagerName, params?: {
|
|
10
|
+
stdinIsTTY?: boolean;
|
|
11
|
+
}): [string, string[]];
|
|
12
|
+
export declare function skillsPluginDir(): string;
|
|
13
|
+
export declare function ensureSkillsPlugin(): Promise<string>;
|
|
14
|
+
//# sourceMappingURL=agent-skill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-skill.d.ts","sourceRoot":"","sources":["../../src/lib/agent-skill.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,kBAAkB,EAAE,MAAM,4BAAyB,CAAC;AAE9E,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAGpD,eAAO,MAAM,aAAa,6CAA6C,CAAC;AACxE,eAAO,MAAM,oBAAoB,iFAAuD,CAAC;AAEzF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,GAAG,SAAS,CAKtB;AAED,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,kBAAkB,EACtB,MAAM,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACpC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAUpB;AAED,wBAAgB,eAAe,IAAI,MAAM,CAIxC;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CA2C1D"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { dlxCommand } from "./utils/package-manager.js";
|
|
2
|
+
import { withStagedDownload } from "./utils/download.js";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
// src/lib/agent-skill.ts
|
|
7
|
+
const SKILLS_PACKAGE = "assistant-ui/skills";
|
|
8
|
+
/** The `skills` CLI version that installs {@link SKILLS_PACKAGE}. */
|
|
9
|
+
const SKILLS_CLI_PACKAGE = "skills@1.7.4";
|
|
10
|
+
const SKILLS_COMMIT = "b0609e66baff7e19f21053d5492464dcc22ec9c3";
|
|
11
|
+
const SKILLS_PLUGIN_SOURCE = `gh:${SKILLS_PACKAGE}/assistant-ui#${SKILLS_COMMIT}`;
|
|
12
|
+
function resolveSkillsInstall(params) {
|
|
13
|
+
const { skills, stdinIsTTY = process.stdin.isTTY } = params;
|
|
14
|
+
if (skills !== void 0) return skills;
|
|
15
|
+
if (!stdinIsTTY) return true;
|
|
16
|
+
}
|
|
17
|
+
function buildSkillsAddCommand(pm, params = {}) {
|
|
18
|
+
const { stdinIsTTY = process.stdin.isTTY } = params;
|
|
19
|
+
const [command, dlxArgs] = dlxCommand(pm);
|
|
20
|
+
const args = [
|
|
21
|
+
...dlxArgs,
|
|
22
|
+
SKILLS_CLI_PACKAGE,
|
|
23
|
+
"add",
|
|
24
|
+
SKILLS_PACKAGE
|
|
25
|
+
];
|
|
26
|
+
if (!stdinIsTTY) args.push("--yes");
|
|
27
|
+
return [command, args];
|
|
28
|
+
}
|
|
29
|
+
function skillsPluginDir() {
|
|
30
|
+
const cacheHome = process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
|
|
31
|
+
return path.join(cacheHome, "assistant-ui", "skills", SKILLS_COMMIT);
|
|
32
|
+
}
|
|
33
|
+
async function ensureSkillsPlugin() {
|
|
34
|
+
const dir = skillsPluginDir();
|
|
35
|
+
const marker = path.join(dir, ".claude-plugin", "plugin.json");
|
|
36
|
+
if (fs.existsSync(marker)) return dir;
|
|
37
|
+
const parent = path.dirname(dir);
|
|
38
|
+
await fs.promises.mkdir(parent, { recursive: true });
|
|
39
|
+
const staging = await fs.promises.mkdtemp(path.join(parent, ".staging-"));
|
|
40
|
+
const removeStaging = () => {
|
|
41
|
+
process.removeListener("exit", removeStaging);
|
|
42
|
+
process.removeListener("SIGINT", removeStagingOnSignal);
|
|
43
|
+
process.removeListener("SIGTERM", removeStagingOnSignal);
|
|
44
|
+
fs.rmSync(staging, {
|
|
45
|
+
recursive: true,
|
|
46
|
+
force: true
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const removeStagingOnSignal = (signal) => {
|
|
50
|
+
removeStaging();
|
|
51
|
+
process.kill(process.pid, signal);
|
|
52
|
+
};
|
|
53
|
+
process.once("exit", removeStaging);
|
|
54
|
+
process.once("SIGINT", removeStagingOnSignal);
|
|
55
|
+
process.once("SIGTERM", removeStagingOnSignal);
|
|
56
|
+
await withStagedDownload(SKILLS_PLUGIN_SOURCE, {
|
|
57
|
+
dir: staging,
|
|
58
|
+
preferOffline: true,
|
|
59
|
+
silent: true
|
|
60
|
+
}, "Download timed out.", removeStaging, async (download) => {
|
|
61
|
+
await download.catch((error) => {
|
|
62
|
+
throw new Error("Could not fetch the assistant-ui skills from GitHub. Check your network, or set GITHUB_TOKEN if you are rate limited.", { cause: error });
|
|
63
|
+
});
|
|
64
|
+
await publish(staging, dir, marker);
|
|
65
|
+
});
|
|
66
|
+
return dir;
|
|
67
|
+
}
|
|
68
|
+
async function publish(staging, dir, marker, retry = true) {
|
|
69
|
+
try {
|
|
70
|
+
await fs.promises.rename(staging, dir);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (fs.existsSync(marker)) return;
|
|
73
|
+
if (!retry) throw error;
|
|
74
|
+
await fs.promises.rm(dir, {
|
|
75
|
+
recursive: true,
|
|
76
|
+
force: true
|
|
77
|
+
});
|
|
78
|
+
await publish(staging, dir, marker, false);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export { SKILLS_COMMIT, SKILLS_PACKAGE, SKILLS_PLUGIN_SOURCE, buildSkillsAddCommand, ensureSkillsPlugin, resolveSkillsInstall, skillsPluginDir };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=agent-skill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-skill.js","names":[],"sources":["../../src/lib/agent-skill.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { withStagedDownload } from \"./utils/download\";\nimport { dlxCommand, type PackageManagerName } from \"./utils/package-manager\";\n\nexport const SKILLS_PACKAGE = \"assistant-ui/skills\";\n/** The `skills` CLI version that installs {@link SKILLS_PACKAGE}. */\nconst SKILLS_CLI_PACKAGE = \"skills@1.7.4\";\nexport const SKILLS_COMMIT = \"b0609e66baff7e19f21053d5492464dcc22ec9c3\";\nexport const SKILLS_PLUGIN_SOURCE = `gh:${SKILLS_PACKAGE}/assistant-ui#${SKILLS_COMMIT}`;\n\nexport function resolveSkillsInstall(params: {\n skills?: boolean;\n stdinIsTTY?: boolean;\n}): boolean | undefined {\n const { skills, stdinIsTTY = process.stdin.isTTY } = params;\n if (skills !== undefined) return skills;\n if (!stdinIsTTY) return true;\n return undefined;\n}\n\nexport function buildSkillsAddCommand(\n pm: PackageManagerName,\n params: { stdinIsTTY?: boolean } = {},\n): [string, string[]] {\n const { stdinIsTTY = process.stdin.isTTY } = params;\n const [command, dlxArgs] = dlxCommand(pm);\n const args = [...dlxArgs, SKILLS_CLI_PACKAGE, \"add\", SKILLS_PACKAGE];\n\n // Without a TTY the skills CLI cannot prompt for agent platforms, so skip its\n // confirmation; with a TTY it owns the platform selection interactively.\n if (!stdinIsTTY) args.push(\"--yes\");\n\n return [command, args];\n}\n\nexport function skillsPluginDir(): string {\n const cacheHome =\n process.env.XDG_CACHE_HOME || path.join(os.homedir(), \".cache\");\n return path.join(cacheHome, \"assistant-ui\", \"skills\", SKILLS_COMMIT);\n}\n\nexport async function ensureSkillsPlugin(): Promise<string> {\n const dir = skillsPluginDir();\n const marker = path.join(dir, \".claude-plugin\", \"plugin.json\");\n if (fs.existsSync(marker)) return dir;\n\n const parent = path.dirname(dir);\n await fs.promises.mkdir(parent, { recursive: true });\n const staging = await fs.promises.mkdtemp(path.join(parent, \".staging-\"));\n // Node emits no \"exit\" when a signal kills the process, so the staging\n // directory is removed on the signal and the signal re-raised. The\n // listeners stay armed until the removal runs, which a download that\n // outlives the timeout defers past the caller's own exit.\n const removeStaging = () => {\n process.removeListener(\"exit\", removeStaging);\n process.removeListener(\"SIGINT\", removeStagingOnSignal);\n process.removeListener(\"SIGTERM\", removeStagingOnSignal);\n fs.rmSync(staging, { recursive: true, force: true });\n };\n const removeStagingOnSignal = (signal: NodeJS.Signals) => {\n removeStaging();\n process.kill(process.pid, signal);\n };\n process.once(\"exit\", removeStaging);\n process.once(\"SIGINT\", removeStagingOnSignal);\n process.once(\"SIGTERM\", removeStagingOnSignal);\n\n await withStagedDownload(\n SKILLS_PLUGIN_SOURCE,\n { dir: staging, preferOffline: true, silent: true },\n \"Download timed out.\",\n removeStaging,\n async (download) => {\n await download.catch((error: unknown) => {\n throw new Error(\n \"Could not fetch the assistant-ui skills from GitHub. Check your network, or set GITHUB_TOKEN if you are rate limited.\",\n { cause: error },\n );\n });\n await publish(staging, dir, marker);\n },\n );\n\n return dir;\n}\n\n// A rename fails when the target directory exists and is not empty. A\n// concurrent invocation that published the same commit meanwhile wins and\n// the staged copy is dropped; a directory without the marker is a stale\n// partial cache and is replaced.\nasync function publish(\n staging: string,\n dir: string,\n marker: string,\n retry = true,\n): Promise<void> {\n try {\n await fs.promises.rename(staging, dir);\n } catch (error) {\n if (fs.existsSync(marker)) return;\n if (!retry) throw error;\n await fs.promises.rm(dir, { recursive: true, force: true });\n await publish(staging, dir, marker, false);\n }\n}\n"],"mappings":";;;;;;AAMA,MAAa,iBAAiB;;AAE9B,MAAM,qBAAqB;AAC3B,MAAa,gBAAgB;AAC7B,MAAa,uBAAuB,MAAM,eAAe,gBAAgB;AAEzE,SAAgB,qBAAqB,QAGb;CACtB,MAAM,EAAE,QAAQ,aAAa,QAAQ,MAAM,UAAU;CACrD,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,CAAC,YAAY,OAAO;AAE1B;AAEA,SAAgB,sBACd,IACA,SAAmC,CAAC,GAChB;CACpB,MAAM,EAAE,aAAa,QAAQ,MAAM,UAAU;CAC7C,MAAM,CAAC,SAAS,WAAW,WAAW,EAAE;CACxC,MAAM,OAAO;EAAC,GAAG;EAAS;EAAoB;EAAO;CAAc;CAInE,IAAI,CAAC,YAAY,KAAK,KAAK,OAAO;CAElC,OAAO,CAAC,SAAS,IAAI;AACvB;AAEA,SAAgB,kBAA0B;CACxC,MAAM,YACJ,QAAQ,IAAI,kBAAkB,KAAK,KAAK,GAAG,QAAQ,GAAG,QAAQ;CAChE,OAAO,KAAK,KAAK,WAAW,gBAAgB,UAAU,aAAa;AACrE;AAEA,eAAsB,qBAAsC;CAC1D,MAAM,MAAM,gBAAgB;CAC5B,MAAM,SAAS,KAAK,KAAK,KAAK,kBAAkB,aAAa;CAC7D,IAAI,GAAG,WAAW,MAAM,GAAG,OAAO;CAElC,MAAM,SAAS,KAAK,QAAQ,GAAG;CAC/B,MAAM,GAAG,SAAS,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;CACnD,MAAM,UAAU,MAAM,GAAG,SAAS,QAAQ,KAAK,KAAK,QAAQ,WAAW,CAAC;CAKxE,MAAM,sBAAsB;EAC1B,QAAQ,eAAe,QAAQ,aAAa;EAC5C,QAAQ,eAAe,UAAU,qBAAqB;EACtD,QAAQ,eAAe,WAAW,qBAAqB;EACvD,GAAG,OAAO,SAAS;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;CACrD;CACA,MAAM,yBAAyB,WAA2B;EACxD,cAAc;EACd,QAAQ,KAAK,QAAQ,KAAK,MAAM;CAClC;CACA,QAAQ,KAAK,QAAQ,aAAa;CAClC,QAAQ,KAAK,UAAU,qBAAqB;CAC5C,QAAQ,KAAK,WAAW,qBAAqB;CAE7C,MAAM,mBACJ,sBACA;EAAE,KAAK;EAAS,eAAe;EAAM,QAAQ;CAAK,GAClD,uBACA,eACA,OAAO,aAAa;EAClB,MAAM,SAAS,OAAO,UAAmB;GACvC,MAAM,IAAI,MACR,yHACA,EAAE,OAAO,MAAM,CACjB;EACF,CAAC;EACD,MAAM,QAAQ,SAAS,KAAK,MAAM;CACpC,CACF;CAEA,OAAO;AACT;AAMA,eAAe,QACb,SACA,KACA,QACA,QAAQ,MACO;CACf,IAAI;EACF,MAAM,GAAG,SAAS,OAAO,SAAS,GAAG;CACvC,SAAS,OAAO;EACd,IAAI,GAAG,WAAW,MAAM,GAAG;EAC3B,IAAI,CAAC,OAAO,MAAM;EAClB,MAAM,GAAG,SAAS,GAAG,KAAK;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EAC1D,MAAM,QAAQ,SAAS,KAAK,QAAQ,KAAK;CAC3C;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-abort.d.ts","sourceRoot":"","sources":["../../src/lib/cloud-abort.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,CAAC,WAChB,OAAO,CAAC,CAAC,CAAC,UACX,WAAW,KAClB,OAAO,CAAC,CAAC,CAQR,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/lib/cloud-abort.ts
|
|
2
|
+
const abortable = (promise, signal) => new Promise((resolve, reject) => {
|
|
3
|
+
const abort = () => reject(signal.reason);
|
|
4
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
5
|
+
if (signal.aborted) abort();
|
|
6
|
+
promise.then(resolve, reject).finally(() => {
|
|
7
|
+
signal.removeEventListener("abort", abort);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
export { abortable };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=cloud-abort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-abort.js","names":[],"sources":["../../src/lib/cloud-abort.ts"],"sourcesContent":["export const abortable = <T>(\n promise: Promise<T>,\n signal: AbortSignal,\n): Promise<T> =>\n new Promise((resolve, reject) => {\n const abort = () => reject(signal.reason);\n signal.addEventListener(\"abort\", abort, { once: true });\n if (signal.aborted) abort();\n promise.then(resolve, reject).finally(() => {\n signal.removeEventListener(\"abort\", abort);\n });\n });\n"],"mappings":";AAAA,MAAa,aACX,SACA,WAEA,IAAI,SAAS,SAAS,WAAW;CAC/B,MAAM,cAAc,OAAO,OAAO,MAAM;CACxC,OAAO,iBAAiB,SAAS,OAAO,EAAE,MAAM,KAAK,CAAC;CACtD,IAAI,OAAO,SAAS,MAAM;CAC1B,QAAQ,KAAK,SAAS,MAAM,CAAC,CAAC,cAAc;EAC1C,OAAO,oBAAoB,SAAS,KAAK;CAC3C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type DeviceCredentials } from "aui-auth/device";
|
|
2
|
+
export { validateCloudUrl } from "./cloud-url.js";
|
|
3
|
+
export type CloudAuthConfig = {
|
|
4
|
+
issuer: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
credentialsFile: string;
|
|
7
|
+
};
|
|
8
|
+
type SavedCredentials = DeviceCredentials & {
|
|
9
|
+
issuer: string;
|
|
10
|
+
clientId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const cloudAuthConfig: () => CloudAuthConfig;
|
|
13
|
+
export declare const readCloudCredentials: (config: CloudAuthConfig, options?: {
|
|
14
|
+
matchConfig?: boolean;
|
|
15
|
+
}) => Promise<SavedCredentials | null>;
|
|
16
|
+
export declare const saveCloudCredentials: (config: CloudAuthConfig, credentials: DeviceCredentials, signal?: AbortSignal) => Promise<void>;
|
|
17
|
+
export declare const openBrowser: (url: string) => void;
|
|
18
|
+
export declare const loginToCloud: (config: CloudAuthConfig, options?: {
|
|
19
|
+
noOpen?: boolean;
|
|
20
|
+
setupUrl?: string;
|
|
21
|
+
print?: (text: string) => void;
|
|
22
|
+
}) => Promise<DeviceCredentials>;
|
|
23
|
+
export declare const savedCloudAccessToken: (config: CloudAuthConfig) => Promise<string | null>;
|
|
24
|
+
export declare const cloudAccessToken: (config: CloudAuthConfig, options?: {
|
|
25
|
+
noOpen?: boolean;
|
|
26
|
+
setupUrl?: string;
|
|
27
|
+
print?: (text: string) => void;
|
|
28
|
+
}) => Promise<string>;
|
|
29
|
+
export declare const logoutFromCloud: (config: CloudAuthConfig) => Promise<void>;
|
|
30
|
+
//# sourceMappingURL=cloud-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-auth.d.ts","sourceRoot":"","sources":["../../src/lib/cloud-auth.ts"],"names":[],"mappings":"AAcA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAa,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG,iBAAiB,GAAG;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,eAWjC,CAAC;AAEH,eAAO,MAAM,oBAAoB,WACvB,eAAe,YACd;IAAE,WAAW,CAAC,EA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