@stackone/cli 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,13 +29,14 @@ Initialize and configure the StackOne CLI by creating configuration profiles. Th
29
29
  stackone init
30
30
  ```
31
31
 
32
+ **Options:**
33
+
34
+ - `-e, --env <environment>` - Specify the environment for the configuration profile (`production`, `staging` or custom value). Defaults to `production` if not provided. When using a custom environment, you will be prompted to enter the API URL.
35
+
32
36
  The command will interactively prompt you for:
33
37
 
34
38
  1. **Profile label** - A unique name for this configuration profile
35
- 2. **Environment** - Choose from:
36
- - `production`
37
- - `staging`
38
- - `local`
39
+ 2. **API Url** - Only when the environment is specified and is not production or staging
39
40
  3. **API Key** - Your StackOne API key
40
41
 
41
42
  **Features:**
@@ -47,7 +48,7 @@ The command will interactively prompt you for:
47
48
 
48
49
  ### `push`
49
50
 
50
- Push connector(s) file(s) to the StackOne API registry. This command requires a configuration profile created with the `init` command.
51
+ Push connector(s) file(s) to the StackOne API registry. This command can use either a configuration profile created with the `init` command or provide credentials directly via command-line options.
51
52
 
52
53
  ```bash
53
54
  stackone push --profile <profile-label> path/to/connector.s1.yaml
@@ -59,18 +60,36 @@ or
59
60
  stackone push --profile <profile-label> path/to/connectors/
60
61
  ```
61
62
 
63
+ or using direct credentials:
64
+
65
+ ```bash
66
+ stackone push --api-key <your-api-key> path/to/connector.s1.yaml
67
+ ```
68
+
69
+ or with custom API URL:
70
+
71
+ ```bash
72
+ stackone push --api-key <your-api-key> --api-url <api-url> path/to/connector.s1.yaml
73
+ ```
74
+
62
75
  **Arguments:**
63
76
 
64
77
  - `<path>` - Path to the connector file or folder with connectors to upload
65
78
 
66
79
  **Options:**
67
80
 
68
- - `-p, --profile <label>` - Configuration profile to use (required)
81
+ - `-p, --profile <label>` - Configuration profile to use
82
+ - `--api-key <api-key>` - API key to use for authentication (alternative to using a profile)
83
+ - `--api-url <api-url>` - API URL to use (defaults to `https://api.stackone.com` if not specified)
84
+
85
+ **Note:** You must provide either `--profile` or `--api-key`. If using `--api-key`, the `--api-url` option is optional and will default to the production API URL.
69
86
 
70
87
  **Features:**
71
88
 
72
- - **Profile validation**: Ensures the specified profile exists before uploading
89
+ - **Flexible authentication**: Use either a saved profile or provide credentials directly
90
+ - **Profile validation**: Ensures the specified profile exists before uploading (when using `--profile`)
73
91
  - **File validation**: Checks that the file exists and is a valid connector before attempting upload
92
+ - **Batch upload**: Supports uploading multiple connectors from a directory
74
93
 
75
94
  ### `validate`
76
95
 
@@ -106,9 +125,65 @@ Show the current version of the CLI:
106
125
 
107
126
  ```bash
108
127
  stackone --version
109
- stackone -V
128
+ stackone -v
129
+ ```
130
+
131
+ ## Agent Commands
132
+
133
+ The CLI includes agent commands for AI-assisted configuration building.
134
+
135
+ ### `agent setup`
136
+
137
+ Setup the StackOne agent. This command can be used for global authentication or local project configuration.
138
+
139
+ **Global setup** - Initialize and authenticate the StackOne agent globally:
140
+
141
+ ```bash
142
+ stackone agent setup --global
143
+ ```
144
+
145
+ The command will interactively prompt you for:
146
+
147
+ 1. Email - Your StackOne account email
148
+ 2. Password - Your StackOne account password
149
+
150
+ Configuration is saved to `~/.stackone/agent-config.json` with secure permissions. API keys expire after 24 hours.
151
+
152
+ **Local setup** - Setup the StackOne agent for a specific project:
153
+
154
+ ```bash
155
+ stackone agent setup --local
156
+ ```
157
+
158
+ This command requires prior authentication with `agent setup --global`. It creates:
159
+
160
+ - `CLAUDE.md` - Agent workflow instructions and guidelines
161
+ - `.mcp.json` - Local MCP server configuration
162
+
163
+ The MCP configuration uses the `STACKONE_AGENT_MCP_TOKEN` environment variable. Set this in your shell profile:
164
+
165
+ ```bash
166
+ export STACKONE_AGENT_MCP_TOKEN=<your-api-key>
110
167
  ```
111
168
 
169
+ Options:
170
+
171
+ - `-l, --local` - Setup local project configuration (default)
172
+
173
+ ### `agent cleanup`
174
+
175
+ Remove all API keys and credentials from agent configurations. This command:
176
+
177
+ - Removes `~/.stackone/agent-config.json` (global auth config)
178
+ - Removes MCP server from Claude configuration
179
+ - Cleans `.mcp.json` file (replaces Bearer tokens with environment variable references)
180
+
181
+ ```bash
182
+ stackone agent cleanup
183
+ ```
184
+
185
+ **Safety:** This command only modifies files created by `agent setup` commands. It does not scan or modify connector YAML files or other project files.
186
+
112
187
  ### Local Development
113
188
 
114
189
  ```bash
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require(`./cliCore-BOwdDcP4.cjs`),t=new e.CLI;t.run();
2
+ const e=require(`./cliCore-BJMMc7zt.cjs`),t=new e.CLI;t.run();
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{CLI as e}from"./cliCore-CYhcPSJT.js";const t=new e;t.run();
2
+ import{CLI as e}from"./cliCore-DObMBAP8.js";const t=new e;t.run();
@@ -0,0 +1,139 @@
1
+ const e=require(`./chunk-CUT6urMc.cjs`),t=e.__toESM(require(`chalk`)),n=e.__toESM(require(`commander`)),r=e.__toESM(require(`node:child_process`)),i=e.__toESM(require(`node:fs/promises`)),a=e.__toESM(require(`node:path`)),o=e.__toESM(require(`node:util`)),s=e.__toESM(require(`ora`)),c=e.__toESM(require(`node:os`)),l=e.__toESM(require(`node:process`)),u=e.__toESM(require(`node:readline`)),d=e.__toESM(require(`inquirer`)),f=e.__toESM(require(`node:url`)),p=e.__toESM(require(`fs`)),m=e.__toESM(require(`os`)),h=e.__toESM(require(`path`)),g=e.__toESM(require(`@stackone/connect-sdk`)),ee=e.__toESM(require(`url`)),_=(0,a.join)((0,c.homedir)(),`.stackone`),v=(0,a.join)(_,`agent-config.json`),te=`stackone-agent-global`,y=`stackone-agent-local`,b=process.env.STACKONE_AGENT_SERVER_URL||`https://mcp-internal-falcon.stackonehq.workers.dev/mcp`;async function x(){await(0,i.mkdir)(_,{recursive:!0,mode:448})}async function S(e){await x(),await(0,i.writeFile)(v,JSON.stringify(e,null,2)),await(0,i.chmod)(v,384)}async function C(){try{let e=await(0,i.readFile)(v,`utf-8`);return JSON.parse(e)}catch{return null}}async function w(){try{await(0,i.rm)(v,{force:!0})}catch{}}function T(){return b}function E(){return te}function D(){return y}function O(e){return new Date(e)<=new Date}function k(e){return!!e?.apiKey&&!O(e.expiresAt)}const A=(0,o.promisify)(r.exec);async function j(e){try{let t=await(0,i.readFile)(e,`utf-8`),n=JSON.parse(t),r=!1;if(n.mcpServers&&typeof n.mcpServers==`object`){for(let[e,t]of Object.entries(n.mcpServers))if(t&&typeof t==`object`&&`transport`in t){let e=t.transport;if(e&&typeof e==`object`&&`headers`in e){let t=e.headers;if(t&&typeof t==`object`&&`Authorization`in t){let e=t.Authorization;typeof e==`string`&&e.startsWith(`Bearer `)&&!e.includes("${")&&(t.Authorization="Bearer ${STACKONE_AGENT_MCP_TOKEN}",r=!0)}}}}return r&&await(0,i.writeFile)(e,JSON.stringify(n,null,2)),r}catch{return!1}}var ne=class{async execute(){console.log(t.default.blue.bold(`🧹 StackOne Agent Cleanup
2
+ `));let e={configsCleaned:0};try{let n=(0,s.default)(`Removing stored configuration...`).start();await w(),n.succeed(`Removed ~/.stackone/agent-config.json`);let r=(0,s.default)(`Removing MCP servers from Claude...`).start(),i=0;try{let e=E();await A(`claude mcp remove ${e} 2>/dev/null`),i++}catch{}try{let e=D();await A(`claude mcp remove ${e} 2>/dev/null`),i++}catch{}i>0?r.succeed(`Removed ${i} MCP server(s) from Claude`):r.warn(`No MCP servers found in Claude (already removed or not configured)`);let o=(0,s.default)(`Checking for .mcp.json file...`).start(),c=process.cwd(),l=(0,a.join)(c,`.mcp.json`);try{let t=await j(l);t?(e.configsCleaned=1,o.succeed(`Cleaned .mcp.json (replaced tokens with environment variables)`)):o.info(`.mcp.json already uses environment variables or not found`)}catch{o.info(`.mcp.json not found (already cleaned or not created)`)}console.log(t.default.green(`
3
+ ✓ Cleanup complete!`)),console.log(t.default.white(`
4
+ What was removed:`)),console.log(t.default.cyan(` • ~/.stackone/agent-config.json`)),console.log(t.default.cyan(` • MCP server from Claude configuration`)),e.configsCleaned>0&&console.log(t.default.cyan(` • Hardcoded credentials from .mcp.json`)),console.log(t.default.dim(`
5
+ To authenticate again:`)),console.log(t.default.cyan(` stackone agent setup --global`),t.default.dim(`(for global setup)`)),console.log(t.default.cyan(` stackone agent setup --local`),t.default.dim(`(for local project setup)`)),console.log(``),process.exit(0)}catch(e){e instanceof Error?console.error(t.default.red(`\n✗ ${e.message}\n`)):console.error(t.default.red(`
6
+ ✗ Unknown error occurred
7
+ `)),process.exit(1)}}},re=class{baseUrl;constructor(e){this.baseUrl=e||process.env.AUTH_SERVER_URL||`https://idp-api.stackone.com`}async login(e,t){try{let n=`${this.baseUrl}/auth/sign-in/mcp`,r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,password:t})});if(!r.ok){let e=await r.text(),t={};try{t=JSON.parse(e)}catch{}return{success:!1,error:t.error||`HTTP ${r.status}: ${r.statusText}`}}let i=await r.text(),a=JSON.parse(i);return a.apiKey?{success:!0,apiKey:a.apiKey}:{success:!1,error:`Invalid response format`}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Network error occurred`}}}async validateKey(e){try{let t=`${this.baseUrl}/api-key/verify`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!n.ok){let e=await n.text(),t={};try{t=JSON.parse(e)}catch{}return{valid:!1,error:t.error||`HTTP ${n.status}: ${n.statusText}`}}let r=await n.text();return JSON.parse(r)}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Network error occurred`}}}};const M=new re,N=(0,o.promisify)(r.exec);function P(e){let t=new Date(e),n=new Date,r=t.getTime()-n.getTime(),i=Math.floor(r/(3600*1e3)),a=t.toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0}),o=t.toDateString()===n.toDateString()?`Today`:t.toDateString()===new Date(n.getTime()+864e5).toDateString()?`Tomorrow`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`});return`${o} at ${a} (${i} hours from now)`}var F=class{async execute(){console.log(t.default.blue.bold(`🤖 StackOne Agent Setup - Global Configuration
8
+ `));try{let e=process.cwd(),n=await(0,i.access)(`${e}/CLAUDE.md`).then(()=>!0).catch(()=>!1),r=await(0,i.access)(`${e}/.mcp.json`).then(()=>!0).catch(()=>!1);if(n||r){console.log(t.default.yellow(`⚠ Existing local setup detected:`)),n&&console.log(t.default.dim(` • CLAUDE.md found in current directory`)),r&&console.log(t.default.dim(` • .mcp.json found in current directory`)),console.log();let{proceed:e}=await d.default.prompt([{type:`confirm`,name:`proceed`,message:`Re-authenticate globally despite existing local setup?`,default:!0}]);e||(console.log(t.default.dim(`
9
+ Setup cancelled.`)),process.exit(0)),console.log()}let a=await C(),o;if(a?.email){console.log(t.default.dim(`Last used email: ${a.email}\n`));let{useExisting:e}=await d.default.prompt([{type:`confirm`,name:`useExisting`,message:`Sign in with this email?`,default:!0}]);if(e)o=a.email;else{let e=(0,u.createInterface)({input:l.stdin,output:l.stdout});o=await new Promise(n=>{e.question(t.default.white(`Email: `),e=>{n(e.trim())})}),e.close(),o||(console.error(t.default.red(`
10
+ ✗ Email is required
11
+ `)),process.exit(1))}}else{let e=(0,u.createInterface)({input:l.stdin,output:l.stdout});o=await new Promise(n=>{e.question(t.default.white(`Email: `),e=>{n(e.trim())})}),e.close(),o||(console.error(t.default.red(`
12
+ ✗ Email is required
13
+ `)),process.exit(1))}let c=await d.default.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);c.password||(console.error(t.default.red(`
14
+ ✗ Password is required
15
+ `)),process.exit(1)),console.log();let f=(0,s.default)(`Authenticating...`).start(),p=await M.login(o,c.password);(!p.success||!p.apiKey)&&(f.fail(`Authentication failed`),console.error(t.default.red(`\n✗ ${p.error||`Invalid credentials`}\n`)),console.log(t.default.dim(`Please check your email and password and try again.
16
+ `)),process.exit(1)),f.succeed(`Login successful!`);let m=new Date(Date.now()+1440*60*1e3).toISOString();await S({apiKey:p.apiKey,userId:o,email:o,expiresAt:m,serverUrl:T()}),console.log(t.default.green.bold(`
17
+ ✓ API key saved to ~/.stackone/agent-config.json`)),console.log(t.default.white(`✓ Key expires at`),t.default.cyan(P(m)));let h=(0,s.default)(`Setting up global MCP configuration...`).start();try{let e=E(),n=T();try{await N(`claude mcp remove ${e} 2>/dev/null`)}catch{}let r=`claude mcp add ${e} ${n} --scope user --transport http --header "Authorization: Bearer ${p.apiKey}"`;await N(r),h.succeed(`Installed to Claude (global)`),console.log(t.default.green(`
18
+ ✓ Global setup complete!`)),console.log(t.default.white(`Config location:`),t.default.cyan(`~/.claude.json`)),console.log(t.default.blue(`
19
+ Verify:`),t.default.cyan(`claude mcp list`)),console.log(t.default.dim(`
20
+ 💡 Tip: Run Claude without permission prompts:`),t.default.cyan(`claude --dangerously-skip-permissions`)),console.log(t.default.dim(`
21
+ To setup for a specific project, run:`),t.default.cyan(`stackone agent setup --local`)),console.log(``)}catch(e){h.fail(`Installation to Claude failed`),e instanceof Error&&(console.error(t.default.red(`\n✗ ${e.message}\n`)),console.error(t.default.dim(`You can manually add the server later with:`)),console.error(t.default.cyan(` claude mcp add ${E()} ${T()} --scope user --transport http --header "Authorization: Bearer ${p.apiKey}"`)))}process.exit(0)}catch(e){e instanceof Error?console.error(t.default.red(`\n✗ ${e.message}\n`)):console.error(t.default.red(`
22
+ ✗ Unknown error occurred
23
+ `)),process.exit(1)}}};const I=(0,o.promisify)(r.exec),L=(0,f.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),R=(0,a.dirname)(L);async function z(){let e=(0,a.join)(R,`..`,`..`,`..`,`CLAUDE_TEMPLATE.md`);try{return await(0,i.readFile)(e,`utf-8`)}catch{return`# 🚀 STACKONE API CONFIG BUILDER
24
+
25
+ This document provides the complete methodology for building StackOne API configurations with Claude. Follow this strict workflow to ensure comprehensive, tested, and customer-valuable integrations.
26
+
27
+ ## 🔴 CRITICAL WORKFLOW (STRICT ORDER)
28
+
29
+ When asked to build StackOne API configurations, you MUST follow this exact sequence:
30
+
31
+ 1. **Research Phase (PARALLEL EXECUTION)** → Launch \`discover_actions\` subagent for action discovery + main agent for auth/docs/external repos
32
+ 2. **Synchronization** → Collect and integrate subagent results
33
+ 3. **Version Validation** → \`analyze_versioning()\` → Detect and resolve API version conflicts for discovered endpoints
34
+ 4. **Config Building** → Create comprehensive configuration with all discovered actions
35
+ 5. **YAML Validation** → \`stackone validate src/configs/<provider>.yaml\` → Ensure valid YAML syntax
36
+ 6. **Coverage Validation** → \`check_all_endpoints()\` → Confirm endpoint coverage ≥80%
37
+ 7. **Testing Phase** → \`run_connector_action()\` → Test EVERY action with real API calls
38
+ 8. **Test Completion** → \`check_test_completion()\` → Verify 100% actions tested
39
+ 9. **Security** → \`scramble_credentials()\` → Secure all sensitive data before storage
40
+ 10. **Meta Feedback** → \`meta_feedback()\` → **MANDATORY** - Send feedback to third-party system for tracking
41
+
42
+ **❌ Skip/Disorder = Incomplete Task / Professional Failure**
43
+
44
+ ## 🎯 CORE PRINCIPLES
45
+
46
+ - **MAXIMUM COVERAGE**: Discover and include ALL useful actions that provide customer value
47
+ - **ACTION-FOCUSED**: Think: "what actions would developers commonly perform with this provider?"
48
+ - **CUSTOMER VALUE**: Prioritize actions that solve real business problems
49
+ - **MORE IS BETTER**: Default to comprehensiveness over minimalism
50
+ - **PRACTICAL UTILITY**: Focus on actions developers actually use in production
51
+
52
+ ## 🔍 AVAILABLE TOOLS
53
+
54
+ ### Core Research
55
+ - \`get_stackone_categories()\`, \`get_stackone_actions(category)\`
56
+ - \`get_providers()\`, \`get_provider_coverage(provider)\`
57
+ - \`vector_search(query, provider, k)\`
58
+
59
+ ### Action Discovery
60
+ - \`discover_actions(provider)\` - Autonomous AI agent (5-15 min)
61
+ - \`get_provider_actions(provider)\` - Check S3 for indexed actions
62
+
63
+ ### API Versioning
64
+ - \`analyze_versioning(provider, endpoints)\` - Version validation (2-5 min)
65
+
66
+ ### External Analysis
67
+ - \`get_external_integrations(provider)\`
68
+ - \`analyze_external_integration(integration, provider)\`
69
+ - \`scan_external_repo(repo_url, search_terms)\`
70
+
71
+ ### Testing
72
+ - \`run_connector_action()\` - Test with real API calls
73
+ - \`check_all_endpoints()\` - Validate ≥80% coverage
74
+ - \`check_test_completion()\` - Verify 100% tested
75
+
76
+ ### Security
77
+ - \`scramble_credentials()\` - **REQUIRED** before storage
78
+ - \`meta_feedback()\` - **MANDATORY** after completion
79
+
80
+ ## 📚 DOCUMENTATION
81
+
82
+ See \`src/configs/README.md\` for complete YAML structure, authentication patterns, actions, and field configs.
83
+
84
+ ## 🔐 AUTHENTICATION
85
+
86
+ Your CLI is authenticated via OAuth with StackOne.
87
+
88
+ **Security:** Your access token is stored as \`STACKONE_FALCON_MCP_TOKEN\` environment variable. The \`.mcp.json\` file uses this variable reference - safe to commit!
89
+
90
+ ## ⚡ QUICK START
91
+
92
+ \`\`\`bash
93
+ # Setup authentication (global)
94
+ stackone agent setup --global
95
+
96
+ # Setup local project
97
+ stackone agent setup --local
98
+
99
+ # Cleanup all credentials
100
+ stackone agent cleanup
101
+ \`\`\`
102
+
103
+ ---
104
+
105
+ *Authenticated with StackOne • Agent MCP Server*
106
+ *For full workflow details, see the complete CLAUDE.md in repository*
107
+ `}}const B=()=>`{
108
+ "mcpServers": {
109
+ "${D()}": {
110
+ "url": "${T()}",
111
+ "transport": {
112
+ "type": "http",
113
+ "headers": {
114
+ "Authorization": "Bearer \${STACKONE_AGENT_MCP_TOKEN}"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }`;var V=class{async execute(){console.log(t.default.blue.bold(`🤖 StackOne Agent Setup - Local Project
120
+ `));try{let e=process.cwd(),n=await(0,i.access)(`${e}/CLAUDE.md`).then(()=>!0).catch(()=>!1),r=await(0,i.access)(`${e}/.mcp.json`).then(()=>!0).catch(()=>!1);if(n||r){console.log(t.default.yellow(`⚠ Existing local setup detected:`)),n&&console.log(t.default.dim(` • CLAUDE.md found`)),r&&console.log(t.default.dim(` • .mcp.json found`)),console.log();let{proceed:e}=await d.default.prompt([{type:`confirm`,name:`proceed`,message:`Overwrite existing local configuration?`,default:!1}]);e||(console.log(t.default.dim(`
121
+ Setup cancelled.`)),process.exit(0)),console.log()}let a=await C();if(!a||!k(a)){console.log(t.default.yellow(`⚠ Not authenticated globally.`)),console.log(t.default.white(`Let's authenticate now...
122
+ `));let e=(0,u.createInterface)({input:l.stdin,output:l.stdout}),n=await new Promise(n=>{e.question(t.default.white(`Email: `),e=>{n(e.trim())})});e.close(),n||(console.error(t.default.red(`
123
+ ✗ Email is required
124
+ `)),process.exit(1));let r=await d.default.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);r.password||(console.error(t.default.red(`
125
+ ✗ Password is required
126
+ `)),process.exit(1)),console.log();let i=(0,s.default)(`Authenticating...`).start(),o=await M.login(n,r.password);(!o.success||!o.apiKey)&&(i.fail(`Authentication failed`),console.error(t.default.red(`\n✗ ${o.error||`Invalid credentials`}\n`)),console.log(t.default.dim(`Please check your email and password and try again.
127
+ `)),process.exit(1)),i.succeed(`Login successful!`);let c=new Date(Date.now()+1440*60*1e3).toISOString();await S({apiKey:o.apiKey,userId:n,email:n,expiresAt:c,serverUrl:T()}),a={apiKey:o.apiKey,userId:n,email:n,expiresAt:c,serverUrl:T()},console.log()}let o=(0,s.default)(`Setting up local project configuration...`).start();o.text=`Creating CLAUDE.md...`;let c=await z();await(0,i.writeFile)(`CLAUDE.md`,c),o.succeed(`Created CLAUDE.md`);let f=(0,s.default)(`Creating .mcp.json...`).start();await(0,i.writeFile)(`.mcp.json`,B()),f.succeed(`Created .mcp.json (using STACKONE_AGENT_MCP_TOKEN env var)`);let p=(0,s.default)(`Installing to Claude (local)...`).start();try{let e=D();try{await I(`claude mcp remove ${e} 2>/dev/null`)}catch{}let n=`claude mcp add ${e} ${T()} --scope local --transport http --header "Authorization: Bearer ${a.apiKey}"`;await I(n),p.succeed(`Installed to Claude (local)`),console.log(t.default.green(`
128
+ ✓ Local setup complete!`)),console.log(t.default.white(`Files created:`)),console.log(t.default.cyan(` - CLAUDE.md`)),console.log(t.default.cyan(` - .mcp.json`)),console.log(t.default.dim(`
129
+ 💡 The stackone-agent-local MCP server is now available in this project`)),console.log(t.default.dim(`
130
+ 💡 Tip: Run Claude without permission prompts:`),t.default.cyan(`claude --dangerously-skip-permissions`)),console.log(t.default.blue(`
131
+ Verify:`),t.default.cyan(`claude mcp list`)),console.log(``)}catch(e){p.fail(`Installation to Claude failed`),e instanceof Error&&(console.error(t.default.red(`\n✗ ${e.message}\n`)),console.error(t.default.dim(`Configuration files created, but Claude setup failed.`)),console.error(t.default.dim(`You can manually add the server later with:`)),console.error(t.default.cyan(` claude mcp add ${D()} ${T()} --scope local --transport http --header "Authorization: Bearer ${a.apiKey}"`))),console.log(``)}process.exit(0)}catch(e){e instanceof Error?console.error(t.default.red(`\n✗ ${e.message}\n`)):console.error(t.default.red(`
132
+ ✗ Unknown error occurred
133
+ `)),process.exit(1)}}};const H=(0,h.join)((0,m.homedir)(),`.stackone`),U={profiles:{}},W=()=>{if(!(0,p.existsSync)(H))return U;try{let e=(0,p.readFileSync)(H,`utf-8`);return JSON.parse(e)}catch{return U}},G=e=>{let t=W();return t.profiles[e]},K=e=>{let t=W();return!!t.profiles[e]},q=(e,t)=>{let n=W();n.profiles[e]=t;let r=(0,h.join)((0,m.homedir)());(0,p.existsSync)(r)||(0,p.mkdirSync)(r,{recursive:!0}),(0,p.writeFileSync)(H,JSON.stringify(n,null,2),`utf-8`)},J=()=>{let e=W();return Object.keys(e.profiles)};var Y=class{static info(e){console.info(t.default.blue(`ℹ`),e)}static warn(e){console.info(t.default.yellow(`⚠`),e)}static error(e){console.info(t.default.red(`✗`),e)}static success(e){console.info(t.default.green(`✓`),e)}};const ie=`https://api.stackone.com`,ae=`https://api.stackone-dev.com`,oe=`http://localhost:4000`;var se=class{async execute({environment:e}={}){let n=e?.toLowerCase()??`production`;try{let{label:e}=await d.default.prompt([{type:`input`,name:`label`,message:`Profile label:`,validate:e=>!e||e.trim().length===0?`The profile label is required`:e.includes(` `)?`The profile label cannot contain spaces`:!0}]);if(K(e)){let{overwrite:t}=await d.default.prompt([{type:`confirm`,name:`overwrite`,message:`Configuration profile with name "${e}" already exists. Do you want to overwrite it?`,default:!1}]);t||(Y.info(`Configuration profile initialization cancelled`),process.exit(0))}let r;if(n===`production`)r=ie;else if(n===`staging`)r=ae;else{let{customUrl:e}=await d.default.prompt([{type:`input`,name:`customUrl`,message:`API URL:`,default:oe,validate:e=>{if(!e||e.trim().length===0)return`API URL is required`;try{return new URL(e),!0}catch{return`Please enter a valid URL`}}}]);r=e}let{apiKey:i}=await d.default.prompt([{type:`password`,name:`apiKey`,message:`API Key:`,validate:e=>!e||e.trim().length===0?`API Key is required`:!0}]),a={label:e,environment:n,apiUrl:r,apiKey:i};q(e,a),console.info(t.default.green(`\n✓ Configuration profile "${e}" saved successfully`)),process.exit(0)}catch(e){e.isTtyError?Y.error(`Prompt couldn't be rendered in the current environment`):Y.error(`Failed to initialize configuration profile: ${e}`),process.exit(1)}}};const X=`https://api.stackone.com`;var ce=class{async execute({profile:e,fileOrDir:t,apiUrl:n,apiKey:r}={}){if(!e&&!r&&(Y.error(`Please provide a profile or API key to use for pushing the connector.`),Y.info(`You can provide these using the --profile and --api-key options.`),Y.info(`Run "stackone init" to create a new configuration profile.`),process.exit(1)),e&&r&&(Y.error(`Please provide either a profile or an API key, not both.`),process.exit(1)),e&&n&&Y.warn(`Specifying --api-url with a profile won't have any effect. Using API url from profile.`),e&&!K(e)){Y.error(`Configuration profile "${e}" not found.`),Y.info(`Run "stackone init" to create a new configuration profile.`);let t=J();Y.info(`Available profiles: ${t.join(`, `)||`none`}`),process.exit(1)}let i=e?G(e):{apiUrl:n??X,apiKey:r};i||(Y.error(`Failed to load configuration profile "${e}".`),process.exit(1)),i.apiKey||(Y.error(`API key is missing. Please provide a valid API key in the profile or via the --api-key option.`),process.exit(1)),t||(Y.error(`File or directory path is required.`),process.exit(1));try{(0,p.statSync)(t)}catch{Y.error(`File or directory not found: ${t}`),process.exit(1)}let a=(0,p.statSync)(t),o=i.apiUrl??X;if(a.isDirectory()){let e=Z(t),n=0;e.length===0?(Y.error(`No .s1.yaml connector files found in the directory: ${t}.`),process.exit(1)):Y.info(`Found ${e.length} connector(s) file(s). Processing...`);for(let t of e){console.info(`
134
+ `);let e=await this.uploadFile(t,o,i.apiKey);e&&n++}console.info(`
135
+ `),Y.info(`Upload completed: ${n} of ${e.length} file(s) uploaded successfully.`),process.exit(n>0?0:1)}else t.endsWith(`.s1.yaml`)||(Y.error(`Only .s1.yaml files are supported for upload.`),process.exit(1));let s=await this.uploadFile(t,o,i.apiKey);process.exit(s?0:1)}async uploadFile(e,n,r){try{console.info(t.default.blue(`📤 Uploading ${(0,h.basename)(e)}...`));let i=le(e);if(!i)return!1;let a=(0,h.basename)(e),o=new FormData,s=new Blob([i],{type:`application/x-yaml`});o.append(`file`,s,a);let c=Buffer.from(r).toString(`base64`),l=await fetch(`${n}/registry/connectors`,{method:`POST`,headers:{Authorization:`Basic ${c}`},body:o});if(!l.ok){let e=await l.text();return Y.error(`Upload failed: ${l.status} - ${l.statusText}`),e&&console.error(t.default.red(e)),!1}let u=await l.json();return console.info(t.default.green(`✓ Successfully uploaded ${a} with connector "${u.provider}@${u.version}"`)),!0}catch(e){return Y.error(`Failed to upload file: ${e}`),!1}}};const le=e=>{let n=(0,g.loadConnector)(e),r=(0,g.validateYamlConnector)(n),i=r?.errors??[];if(r.success){let t=e.split(`/`).pop()||e;return Y.success(`Connector ${t} is valid!`),n}else i.length>0?(Y.error(`Connector ${e} is not valid. Please fix the following errors:\n`),i.forEach(e=>{console.info(t.default.red(`- L${e.line}: ${e.message}`))})):Y.error(`Connector ${e} is not valid. Please check the file for errors.`)},Z=e=>{let t=[],n=(0,p.readdirSync)(e,{withFileTypes:!0});for(let r of n){let n=(0,h.join)(e,r.name);r.isDirectory()?t.push(...Z(n)):r.name.endsWith(`.s1.yaml`)&&t.push(n)}return t};var ue=class{async execute(e){let{watchMode:n,fileOrDir:r}=e,i=(0,s.default)(`Watching for changes...`),a=()=>{console.clear(),console.info(t.default.yellow(`Watch mode enabled. Press "q" to quit.
136
+ `))};if(r){try{(0,p.statSync)(r)}catch{Y.error(`File or directory not found: ${r}`),process.exit(1)}if(n){let{watch:e}=await Promise.resolve().then(()=>require(`./esm-BSZWAx0q.cjs`)),n=await import(`readline`),o=n.createInterface({input:process.stdin,output:process.stdout});process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding(`utf8`);let s=()=>{console.info(t.default.grey(`
137
+
138
+ Exiting watch mode...`)),c.close(),i.stop(),o.close(),process.exit(0)};a(),console.info(t.default.blue(`Running connector(s) validations...`)),await Q(r),i.start();let c=e(r||`.`,{ignored:/(^|[/\\])\../,persistent:!0});c.on(`change`,async e=>{a(),i.stop(),console.info(t.default.blue(`File change detected. Running connector(s) validations...`)),await Q(r),i.start()}),process.stdin.on(`data`,e=>{e.toString()===`q`&&s()}),process.on(`SIGINT`,()=>{s()})}else await Q(r),process.exit(0)}}};const Q=async e=>{let t=(0,p.statSync)(e);if(t.isDirectory()){let t=(0,p.readdirSync)(e),n=t.filter(e=>e.endsWith(`.s1.yaml`));if(n.length===0){Y.error(`No StackOne connectors found in directory: ${e}. Connector files need to have the extension .s1.yaml.\n`);return}let r=0,i=0;for(let t of n){let n=`${e}/${t}`,a=(0,p.statSync)(n);if(a.isFile()){let e=await $(n);e?r++:i++}}Y.info(`Validation completed: ${r} valid, ${i} invalid connectors.\n`)}else t.isFile()&&e.endsWith(`s1.yaml`)?await $(e):Y.error(`No StackOne connector found: ${e}. Connector files need to have the extension .s1.yaml.\n`)},$=async e=>{let n=(0,g.loadConnector)(e),r=(0,g.validateYamlConnector)(n),i=r?.errors??[];if(r.success){let t=e.split(`/`).pop()||e;return Y.success(`Connector ${t} is valid!\n`),!0}else if(i.length>0)return Y.error(`Connector ${e} is not valid. Please fix the following errors:\n`),i.forEach(e=>{console.info(t.default.red(`- L${e.line}: ${e.message}`))}),console.info(`
139
+ `),!1;else return Y.error(`Connector ${e} is not valid. Please check the file for errors.`),!1},de=()=>{try{let e=(0,ee.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),t=(0,h.dirname)(e),n=(0,h.join)(t,`..`,`package.json`),r=JSON.parse((0,p.readFileSync)(n,`utf8`));return r.version}catch{return`unknown`}};var fe=class{constructor(e=new n.Command,t=de()){this.program=e,this.version=t,this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne CLI`).version(this.version,`-v, --version`)}registerCommands(){let e=new se,r=new ce,i=new ue,a=new F,o=new V,s=new ne;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(e,n)=>{n(t.default.red(e))}}),this.program.command(`init`).option(`-e, --env <environment>`,`Specify the environment for the configuration profile`).description(`Initialize & create a StackOne CLI configuration profile`).action(t=>{e.execute({environment:t.env})}),this.program.command(`push`).option(`-p, --profile <label>`,`Configuration profile to use`).option(`--api-url <api url>`,`API URL`).option(`--api-key <api key>`,`API Key`).addArgument(new n.Argument(`<path>`,`Connector file or directory to push`)).description(`Push a connector to the StackOne registry`).action((e,t)=>{r.execute({profile:t.profile,fileOrDir:e,apiUrl:t.apiUrl,apiKey:t.apiKey})}),this.program.command(`validate`).option(`-w, --watch`,`Run in watch mode`).addArgument(new n.Argument(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((e,t)=>{i.execute({watchMode:t.watch,fileOrDir:e})}),this.program.command(`version`).description(`Show version information`).action(()=>{console.info(`${t.default.greenBright(`StackOne`)} ${t.default.grey(`CLI`)} ${t.default.whiteBright(this.version)}`),process.exit(0)});let c=this.program.command(`agent`).description(`StackOne agent commands`);c.command(`setup`).option(`-g, --global`,`Setup global configuration`).option(`-l, --local`,`Setup local project configuration`).description(`Setup StackOne agent (global or local)`).action(e=>{e.global?a.execute():o.execute()}),c.command(`cleanup`).description(`Remove all API keys and credentials from configurations`).action(()=>{s.execute()})}run(){this.program.parse(process.argv)}};Object.defineProperty(exports,`CLI`,{enumerable:!0,get:function(){return fe}});
@@ -0,0 +1,139 @@
1
+ import e from"chalk";import{Argument as t,Command as n}from"commander";import{exec as r}from"node:child_process";import{access as i,chmod as a,mkdir as o,readFile as s,rm as c,writeFile as l}from"node:fs/promises";import{dirname as u,join as d}from"node:path";import{promisify as f}from"node:util";import p from"ora";import{homedir as ee}from"node:os";import{stdin as m,stdout as h}from"node:process";import{createInterface as g}from"node:readline";import _ from"inquirer";import{fileURLToPath as v}from"node:url";import{existsSync as y,mkdirSync as te,readFileSync as b,readdirSync as x,statSync as S,writeFileSync as ne}from"fs";import{homedir as C}from"os";import{basename as w,dirname as re,join as T}from"path";import{loadConnector as E,validateYamlConnector as D}from"@stackone/connect-sdk";import{fileURLToPath as O}from"url";const k=d(ee(),`.stackone`),A=d(k,`agent-config.json`),ie=`stackone-agent-global`,ae=`stackone-agent-local`,oe=process.env.STACKONE_AGENT_SERVER_URL||`https://mcp-internal-falcon.stackonehq.workers.dev/mcp`;async function j(){await o(k,{recursive:!0,mode:448})}async function M(e){await j(),await l(A,JSON.stringify(e,null,2)),await a(A,384)}async function N(){try{let e=await s(A,`utf-8`);return JSON.parse(e)}catch{return null}}async function se(){try{await c(A,{force:!0})}catch{}}function P(){return oe}function F(){return ie}function I(){return ae}function ce(e){return new Date(e)<=new Date}function le(e){return!!e?.apiKey&&!ce(e.expiresAt)}const L=f(r);async function ue(e){try{let t=await s(e,`utf-8`),n=JSON.parse(t),r=!1;if(n.mcpServers&&typeof n.mcpServers==`object`){for(let[e,t]of Object.entries(n.mcpServers))if(t&&typeof t==`object`&&`transport`in t){let e=t.transport;if(e&&typeof e==`object`&&`headers`in e){let t=e.headers;if(t&&typeof t==`object`&&`Authorization`in t){let e=t.Authorization;typeof e==`string`&&e.startsWith(`Bearer `)&&!e.includes("${")&&(t.Authorization="Bearer ${STACKONE_AGENT_MCP_TOKEN}",r=!0)}}}}return r&&await l(e,JSON.stringify(n,null,2)),r}catch{return!1}}var R=class{async execute(){console.log(e.blue.bold(`🧹 StackOne Agent Cleanup
2
+ `));let t={configsCleaned:0};try{let n=p(`Removing stored configuration...`).start();await se(),n.succeed(`Removed ~/.stackone/agent-config.json`);let r=p(`Removing MCP servers from Claude...`).start(),i=0;try{let e=F();await L(`claude mcp remove ${e} 2>/dev/null`),i++}catch{}try{let e=I();await L(`claude mcp remove ${e} 2>/dev/null`),i++}catch{}i>0?r.succeed(`Removed ${i} MCP server(s) from Claude`):r.warn(`No MCP servers found in Claude (already removed or not configured)`);let a=p(`Checking for .mcp.json file...`).start(),o=process.cwd(),s=d(o,`.mcp.json`);try{let e=await ue(s);e?(t.configsCleaned=1,a.succeed(`Cleaned .mcp.json (replaced tokens with environment variables)`)):a.info(`.mcp.json already uses environment variables or not found`)}catch{a.info(`.mcp.json not found (already cleaned or not created)`)}console.log(e.green(`
3
+ ✓ Cleanup complete!`)),console.log(e.white(`
4
+ What was removed:`)),console.log(e.cyan(` • ~/.stackone/agent-config.json`)),console.log(e.cyan(` • MCP server from Claude configuration`)),t.configsCleaned>0&&console.log(e.cyan(` • Hardcoded credentials from .mcp.json`)),console.log(e.dim(`
5
+ To authenticate again:`)),console.log(e.cyan(` stackone agent setup --global`),e.dim(`(for global setup)`)),console.log(e.cyan(` stackone agent setup --local`),e.dim(`(for local project setup)`)),console.log(``),process.exit(0)}catch(t){t instanceof Error?console.error(e.red(`\n✗ ${t.message}\n`)):console.error(e.red(`
6
+ ✗ Unknown error occurred
7
+ `)),process.exit(1)}}},z=class{baseUrl;constructor(e){this.baseUrl=e||process.env.AUTH_SERVER_URL||`https://idp-api.stackone.com`}async login(e,t){try{let n=`${this.baseUrl}/auth/sign-in/mcp`,r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,password:t})});if(!r.ok){let e=await r.text(),t={};try{t=JSON.parse(e)}catch{}return{success:!1,error:t.error||`HTTP ${r.status}: ${r.statusText}`}}let i=await r.text(),a=JSON.parse(i);return a.apiKey?{success:!0,apiKey:a.apiKey}:{success:!1,error:`Invalid response format`}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Network error occurred`}}}async validateKey(e){try{let t=`${this.baseUrl}/api-key/verify`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!n.ok){let e=await n.text(),t={};try{t=JSON.parse(e)}catch{}return{valid:!1,error:t.error||`HTTP ${n.status}: ${n.statusText}`}}let r=await n.text();return JSON.parse(r)}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Network error occurred`}}}};const B=new z,V=f(r);function H(e){let t=new Date(e),n=new Date,r=t.getTime()-n.getTime(),i=Math.floor(r/(3600*1e3)),a=t.toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0}),o=t.toDateString()===n.toDateString()?`Today`:t.toDateString()===new Date(n.getTime()+864e5).toDateString()?`Tomorrow`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`});return`${o} at ${a} (${i} hours from now)`}var U=class{async execute(){console.log(e.blue.bold(`🤖 StackOne Agent Setup - Global Configuration
8
+ `));try{let t=process.cwd(),n=await i(`${t}/CLAUDE.md`).then(()=>!0).catch(()=>!1),r=await i(`${t}/.mcp.json`).then(()=>!0).catch(()=>!1);if(n||r){console.log(e.yellow(`⚠ Existing local setup detected:`)),n&&console.log(e.dim(` • CLAUDE.md found in current directory`)),r&&console.log(e.dim(` • .mcp.json found in current directory`)),console.log();let{proceed:t}=await _.prompt([{type:`confirm`,name:`proceed`,message:`Re-authenticate globally despite existing local setup?`,default:!0}]);t||(console.log(e.dim(`
9
+ Setup cancelled.`)),process.exit(0)),console.log()}let a=await N(),o;if(a?.email){console.log(e.dim(`Last used email: ${a.email}\n`));let{useExisting:t}=await _.prompt([{type:`confirm`,name:`useExisting`,message:`Sign in with this email?`,default:!0}]);if(t)o=a.email;else{let t=g({input:m,output:h});o=await new Promise(n=>{t.question(e.white(`Email: `),e=>{n(e.trim())})}),t.close(),o||(console.error(e.red(`
10
+ ✗ Email is required
11
+ `)),process.exit(1))}}else{let t=g({input:m,output:h});o=await new Promise(n=>{t.question(e.white(`Email: `),e=>{n(e.trim())})}),t.close(),o||(console.error(e.red(`
12
+ ✗ Email is required
13
+ `)),process.exit(1))}let s=await _.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);s.password||(console.error(e.red(`
14
+ ✗ Password is required
15
+ `)),process.exit(1)),console.log();let c=p(`Authenticating...`).start(),l=await B.login(o,s.password);(!l.success||!l.apiKey)&&(c.fail(`Authentication failed`),console.error(e.red(`\n✗ ${l.error||`Invalid credentials`}\n`)),console.log(e.dim(`Please check your email and password and try again.
16
+ `)),process.exit(1)),c.succeed(`Login successful!`);let u=new Date(Date.now()+1440*60*1e3).toISOString();await M({apiKey:l.apiKey,userId:o,email:o,expiresAt:u,serverUrl:P()}),console.log(e.green.bold(`
17
+ ✓ API key saved to ~/.stackone/agent-config.json`)),console.log(e.white(`✓ Key expires at`),e.cyan(H(u)));let d=p(`Setting up global MCP configuration...`).start();try{let t=F(),n=P();try{await V(`claude mcp remove ${t} 2>/dev/null`)}catch{}let r=`claude mcp add ${t} ${n} --scope user --transport http --header "Authorization: Bearer ${l.apiKey}"`;await V(r),d.succeed(`Installed to Claude (global)`),console.log(e.green(`
18
+ ✓ Global setup complete!`)),console.log(e.white(`Config location:`),e.cyan(`~/.claude.json`)),console.log(e.blue(`
19
+ Verify:`),e.cyan(`claude mcp list`)),console.log(e.dim(`
20
+ 💡 Tip: Run Claude without permission prompts:`),e.cyan(`claude --dangerously-skip-permissions`)),console.log(e.dim(`
21
+ To setup for a specific project, run:`),e.cyan(`stackone agent setup --local`)),console.log(``)}catch(t){d.fail(`Installation to Claude failed`),t instanceof Error&&(console.error(e.red(`\n✗ ${t.message}\n`)),console.error(e.dim(`You can manually add the server later with:`)),console.error(e.cyan(` claude mcp add ${F()} ${P()} --scope user --transport http --header "Authorization: Bearer ${l.apiKey}"`)))}process.exit(0)}catch(t){t instanceof Error?console.error(e.red(`\n✗ ${t.message}\n`)):console.error(e.red(`
22
+ ✗ Unknown error occurred
23
+ `)),process.exit(1)}}};const W=f(r),de=v(import.meta.url),fe=u(de);async function pe(){let e=d(fe,`..`,`..`,`..`,`CLAUDE_TEMPLATE.md`);try{return await s(e,`utf-8`)}catch{return`# 🚀 STACKONE API CONFIG BUILDER
24
+
25
+ This document provides the complete methodology for building StackOne API configurations with Claude. Follow this strict workflow to ensure comprehensive, tested, and customer-valuable integrations.
26
+
27
+ ## 🔴 CRITICAL WORKFLOW (STRICT ORDER)
28
+
29
+ When asked to build StackOne API configurations, you MUST follow this exact sequence:
30
+
31
+ 1. **Research Phase (PARALLEL EXECUTION)** → Launch \`discover_actions\` subagent for action discovery + main agent for auth/docs/external repos
32
+ 2. **Synchronization** → Collect and integrate subagent results
33
+ 3. **Version Validation** → \`analyze_versioning()\` → Detect and resolve API version conflicts for discovered endpoints
34
+ 4. **Config Building** → Create comprehensive configuration with all discovered actions
35
+ 5. **YAML Validation** → \`stackone validate src/configs/<provider>.yaml\` → Ensure valid YAML syntax
36
+ 6. **Coverage Validation** → \`check_all_endpoints()\` → Confirm endpoint coverage ≥80%
37
+ 7. **Testing Phase** → \`run_connector_action()\` → Test EVERY action with real API calls
38
+ 8. **Test Completion** → \`check_test_completion()\` → Verify 100% actions tested
39
+ 9. **Security** → \`scramble_credentials()\` → Secure all sensitive data before storage
40
+ 10. **Meta Feedback** → \`meta_feedback()\` → **MANDATORY** - Send feedback to third-party system for tracking
41
+
42
+ **❌ Skip/Disorder = Incomplete Task / Professional Failure**
43
+
44
+ ## 🎯 CORE PRINCIPLES
45
+
46
+ - **MAXIMUM COVERAGE**: Discover and include ALL useful actions that provide customer value
47
+ - **ACTION-FOCUSED**: Think: "what actions would developers commonly perform with this provider?"
48
+ - **CUSTOMER VALUE**: Prioritize actions that solve real business problems
49
+ - **MORE IS BETTER**: Default to comprehensiveness over minimalism
50
+ - **PRACTICAL UTILITY**: Focus on actions developers actually use in production
51
+
52
+ ## 🔍 AVAILABLE TOOLS
53
+
54
+ ### Core Research
55
+ - \`get_stackone_categories()\`, \`get_stackone_actions(category)\`
56
+ - \`get_providers()\`, \`get_provider_coverage(provider)\`
57
+ - \`vector_search(query, provider, k)\`
58
+
59
+ ### Action Discovery
60
+ - \`discover_actions(provider)\` - Autonomous AI agent (5-15 min)
61
+ - \`get_provider_actions(provider)\` - Check S3 for indexed actions
62
+
63
+ ### API Versioning
64
+ - \`analyze_versioning(provider, endpoints)\` - Version validation (2-5 min)
65
+
66
+ ### External Analysis
67
+ - \`get_external_integrations(provider)\`
68
+ - \`analyze_external_integration(integration, provider)\`
69
+ - \`scan_external_repo(repo_url, search_terms)\`
70
+
71
+ ### Testing
72
+ - \`run_connector_action()\` - Test with real API calls
73
+ - \`check_all_endpoints()\` - Validate ≥80% coverage
74
+ - \`check_test_completion()\` - Verify 100% tested
75
+
76
+ ### Security
77
+ - \`scramble_credentials()\` - **REQUIRED** before storage
78
+ - \`meta_feedback()\` - **MANDATORY** after completion
79
+
80
+ ## 📚 DOCUMENTATION
81
+
82
+ See \`src/configs/README.md\` for complete YAML structure, authentication patterns, actions, and field configs.
83
+
84
+ ## 🔐 AUTHENTICATION
85
+
86
+ Your CLI is authenticated via OAuth with StackOne.
87
+
88
+ **Security:** Your access token is stored as \`STACKONE_FALCON_MCP_TOKEN\` environment variable. The \`.mcp.json\` file uses this variable reference - safe to commit!
89
+
90
+ ## ⚡ QUICK START
91
+
92
+ \`\`\`bash
93
+ # Setup authentication (global)
94
+ stackone agent setup --global
95
+
96
+ # Setup local project
97
+ stackone agent setup --local
98
+
99
+ # Cleanup all credentials
100
+ stackone agent cleanup
101
+ \`\`\`
102
+
103
+ ---
104
+
105
+ *Authenticated with StackOne • Agent MCP Server*
106
+ *For full workflow details, see the complete CLAUDE.md in repository*
107
+ `}}const me=()=>`{
108
+ "mcpServers": {
109
+ "${I()}": {
110
+ "url": "${P()}",
111
+ "transport": {
112
+ "type": "http",
113
+ "headers": {
114
+ "Authorization": "Bearer \${STACKONE_AGENT_MCP_TOKEN}"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }`;var he=class{async execute(){console.log(e.blue.bold(`🤖 StackOne Agent Setup - Local Project
120
+ `));try{let t=process.cwd(),n=await i(`${t}/CLAUDE.md`).then(()=>!0).catch(()=>!1),r=await i(`${t}/.mcp.json`).then(()=>!0).catch(()=>!1);if(n||r){console.log(e.yellow(`⚠ Existing local setup detected:`)),n&&console.log(e.dim(` • CLAUDE.md found`)),r&&console.log(e.dim(` • .mcp.json found`)),console.log();let{proceed:t}=await _.prompt([{type:`confirm`,name:`proceed`,message:`Overwrite existing local configuration?`,default:!1}]);t||(console.log(e.dim(`
121
+ Setup cancelled.`)),process.exit(0)),console.log()}let a=await N();if(!a||!le(a)){console.log(e.yellow(`⚠ Not authenticated globally.`)),console.log(e.white(`Let's authenticate now...
122
+ `));let t=g({input:m,output:h}),n=await new Promise(n=>{t.question(e.white(`Email: `),e=>{n(e.trim())})});t.close(),n||(console.error(e.red(`
123
+ ✗ Email is required
124
+ `)),process.exit(1));let r=await _.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);r.password||(console.error(e.red(`
125
+ ✗ Password is required
126
+ `)),process.exit(1)),console.log();let i=p(`Authenticating...`).start(),o=await B.login(n,r.password);(!o.success||!o.apiKey)&&(i.fail(`Authentication failed`),console.error(e.red(`\n✗ ${o.error||`Invalid credentials`}\n`)),console.log(e.dim(`Please check your email and password and try again.
127
+ `)),process.exit(1)),i.succeed(`Login successful!`);let s=new Date(Date.now()+1440*60*1e3).toISOString();await M({apiKey:o.apiKey,userId:n,email:n,expiresAt:s,serverUrl:P()}),a={apiKey:o.apiKey,userId:n,email:n,expiresAt:s,serverUrl:P()},console.log()}let o=p(`Setting up local project configuration...`).start();o.text=`Creating CLAUDE.md...`;let s=await pe();await l(`CLAUDE.md`,s),o.succeed(`Created CLAUDE.md`);let c=p(`Creating .mcp.json...`).start();await l(`.mcp.json`,me()),c.succeed(`Created .mcp.json (using STACKONE_AGENT_MCP_TOKEN env var)`);let u=p(`Installing to Claude (local)...`).start();try{let t=I();try{await W(`claude mcp remove ${t} 2>/dev/null`)}catch{}let n=`claude mcp add ${t} ${P()} --scope local --transport http --header "Authorization: Bearer ${a.apiKey}"`;await W(n),u.succeed(`Installed to Claude (local)`),console.log(e.green(`
128
+ ✓ Local setup complete!`)),console.log(e.white(`Files created:`)),console.log(e.cyan(` - CLAUDE.md`)),console.log(e.cyan(` - .mcp.json`)),console.log(e.dim(`
129
+ 💡 The stackone-agent-local MCP server is now available in this project`)),console.log(e.dim(`
130
+ 💡 Tip: Run Claude without permission prompts:`),e.cyan(`claude --dangerously-skip-permissions`)),console.log(e.blue(`
131
+ Verify:`),e.cyan(`claude mcp list`)),console.log(``)}catch(t){u.fail(`Installation to Claude failed`),t instanceof Error&&(console.error(e.red(`\n✗ ${t.message}\n`)),console.error(e.dim(`Configuration files created, but Claude setup failed.`)),console.error(e.dim(`You can manually add the server later with:`)),console.error(e.cyan(` claude mcp add ${I()} ${P()} --scope local --transport http --header "Authorization: Bearer ${a.apiKey}"`))),console.log(``)}process.exit(0)}catch(t){t instanceof Error?console.error(e.red(`\n✗ ${t.message}\n`)):console.error(e.red(`
132
+ ✗ Unknown error occurred
133
+ `)),process.exit(1)}}};const G=T(C(),`.stackone`),K={profiles:{}},q=()=>{if(!y(G))return K;try{let e=b(G,`utf-8`);return JSON.parse(e)}catch{return K}},ge=e=>{let t=q();return t.profiles[e]},J=e=>{let t=q();return!!t.profiles[e]},_e=(e,t)=>{let n=q();n.profiles[e]=t;let r=T(C());y(r)||te(r,{recursive:!0}),ne(G,JSON.stringify(n,null,2),`utf-8`)},ve=()=>{let e=q();return Object.keys(e.profiles)};var Y=class{static info(t){console.info(e.blue(`ℹ`),t)}static warn(t){console.info(e.yellow(`⚠`),t)}static error(t){console.info(e.red(`✗`),t)}static success(t){console.info(e.green(`✓`),t)}};const ye=`https://api.stackone.com`,be=`https://api.stackone-dev.com`,xe=`http://localhost:4000`;var Se=class{async execute({environment:t}={}){let n=t?.toLowerCase()??`production`;try{let{label:t}=await _.prompt([{type:`input`,name:`label`,message:`Profile label:`,validate:e=>!e||e.trim().length===0?`The profile label is required`:e.includes(` `)?`The profile label cannot contain spaces`:!0}]);if(J(t)){let{overwrite:e}=await _.prompt([{type:`confirm`,name:`overwrite`,message:`Configuration profile with name "${t}" already exists. Do you want to overwrite it?`,default:!1}]);e||(Y.info(`Configuration profile initialization cancelled`),process.exit(0))}let r;if(n===`production`)r=ye;else if(n===`staging`)r=be;else{let{customUrl:e}=await _.prompt([{type:`input`,name:`customUrl`,message:`API URL:`,default:xe,validate:e=>{if(!e||e.trim().length===0)return`API URL is required`;try{return new URL(e),!0}catch{return`Please enter a valid URL`}}}]);r=e}let{apiKey:i}=await _.prompt([{type:`password`,name:`apiKey`,message:`API Key:`,validate:e=>!e||e.trim().length===0?`API Key is required`:!0}]),a={label:t,environment:n,apiUrl:r,apiKey:i};_e(t,a),console.info(e.green(`\n✓ Configuration profile "${t}" saved successfully`)),process.exit(0)}catch(e){e.isTtyError?Y.error(`Prompt couldn't be rendered in the current environment`):Y.error(`Failed to initialize configuration profile: ${e}`),process.exit(1)}}};const X=`https://api.stackone.com`;var Ce=class{async execute({profile:e,fileOrDir:t,apiUrl:n,apiKey:r}={}){if(!e&&!r&&(Y.error(`Please provide a profile or API key to use for pushing the connector.`),Y.info(`You can provide these using the --profile and --api-key options.`),Y.info(`Run "stackone init" to create a new configuration profile.`),process.exit(1)),e&&r&&(Y.error(`Please provide either a profile or an API key, not both.`),process.exit(1)),e&&n&&Y.warn(`Specifying --api-url with a profile won't have any effect. Using API url from profile.`),e&&!J(e)){Y.error(`Configuration profile "${e}" not found.`),Y.info(`Run "stackone init" to create a new configuration profile.`);let t=ve();Y.info(`Available profiles: ${t.join(`, `)||`none`}`),process.exit(1)}let i=e?ge(e):{apiUrl:n??X,apiKey:r};i||(Y.error(`Failed to load configuration profile "${e}".`),process.exit(1)),i.apiKey||(Y.error(`API key is missing. Please provide a valid API key in the profile or via the --api-key option.`),process.exit(1)),t||(Y.error(`File or directory path is required.`),process.exit(1));try{S(t)}catch{Y.error(`File or directory not found: ${t}`),process.exit(1)}let a=S(t),o=i.apiUrl??X;if(a.isDirectory()){let e=Z(t),n=0;e.length===0?(Y.error(`No .s1.yaml connector files found in the directory: ${t}.`),process.exit(1)):Y.info(`Found ${e.length} connector(s) file(s). Processing...`);for(let t of e){console.info(`
134
+ `);let e=await this.uploadFile(t,o,i.apiKey);e&&n++}console.info(`
135
+ `),Y.info(`Upload completed: ${n} of ${e.length} file(s) uploaded successfully.`),process.exit(n>0?0:1)}else t.endsWith(`.s1.yaml`)||(Y.error(`Only .s1.yaml files are supported for upload.`),process.exit(1));let s=await this.uploadFile(t,o,i.apiKey);process.exit(s?0:1)}async uploadFile(t,n,r){try{console.info(e.blue(`📤 Uploading ${w(t)}...`));let i=we(t);if(!i)return!1;let a=w(t),o=new FormData,s=new Blob([i],{type:`application/x-yaml`});o.append(`file`,s,a);let c=Buffer.from(r).toString(`base64`),l=await fetch(`${n}/registry/connectors`,{method:`POST`,headers:{Authorization:`Basic ${c}`},body:o});if(!l.ok){let t=await l.text();return Y.error(`Upload failed: ${l.status} - ${l.statusText}`),t&&console.error(e.red(t)),!1}let u=await l.json();return console.info(e.green(`✓ Successfully uploaded ${a} with connector "${u.provider}@${u.version}"`)),!0}catch(e){return Y.error(`Failed to upload file: ${e}`),!1}}};const we=t=>{let n=E(t),r=D(n),i=r?.errors??[];if(r.success){let e=t.split(`/`).pop()||t;return Y.success(`Connector ${e} is valid!`),n}else i.length>0?(Y.error(`Connector ${t} is not valid. Please fix the following errors:\n`),i.forEach(t=>{console.info(e.red(`- L${t.line}: ${t.message}`))})):Y.error(`Connector ${t} is not valid. Please check the file for errors.`)},Z=e=>{let t=[],n=x(e,{withFileTypes:!0});for(let r of n){let n=T(e,r.name);r.isDirectory()?t.push(...Z(n)):r.name.endsWith(`.s1.yaml`)&&t.push(n)}return t};var Te=class{async execute(t){let{watchMode:n,fileOrDir:r}=t,i=p(`Watching for changes...`),a=()=>{console.clear(),console.info(e.yellow(`Watch mode enabled. Press "q" to quit.
136
+ `))};if(r){try{S(r)}catch{Y.error(`File or directory not found: ${r}`),process.exit(1)}if(n){let{watch:t}=await import(`./esm-Wey0v-fi.js`),n=await import(`readline`),o=n.createInterface({input:process.stdin,output:process.stdout});process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding(`utf8`);let s=()=>{console.info(e.grey(`
137
+
138
+ Exiting watch mode...`)),c.close(),i.stop(),o.close(),process.exit(0)};a(),console.info(e.blue(`Running connector(s) validations...`)),await Q(r),i.start();let c=t(r||`.`,{ignored:/(^|[/\\])\../,persistent:!0});c.on(`change`,async t=>{a(),i.stop(),console.info(e.blue(`File change detected. Running connector(s) validations...`)),await Q(r),i.start()}),process.stdin.on(`data`,e=>{e.toString()===`q`&&s()}),process.on(`SIGINT`,()=>{s()})}else await Q(r),process.exit(0)}}};const Q=async e=>{let t=S(e);if(t.isDirectory()){let t=x(e),n=t.filter(e=>e.endsWith(`.s1.yaml`));if(n.length===0){Y.error(`No StackOne connectors found in directory: ${e}. Connector files need to have the extension .s1.yaml.\n`);return}let r=0,i=0;for(let t of n){let n=`${e}/${t}`,a=S(n);if(a.isFile()){let e=await $(n);e?r++:i++}}Y.info(`Validation completed: ${r} valid, ${i} invalid connectors.\n`)}else t.isFile()&&e.endsWith(`s1.yaml`)?await $(e):Y.error(`No StackOne connector found: ${e}. Connector files need to have the extension .s1.yaml.\n`)},$=async t=>{let n=E(t),r=D(n),i=r?.errors??[];if(r.success){let e=t.split(`/`).pop()||t;return Y.success(`Connector ${e} is valid!\n`),!0}else if(i.length>0)return Y.error(`Connector ${t} is not valid. Please fix the following errors:\n`),i.forEach(t=>{console.info(e.red(`- L${t.line}: ${t.message}`))}),console.info(`
139
+ `),!1;else return Y.error(`Connector ${t} is not valid. Please check the file for errors.`),!1},Ee=()=>{try{let e=O(import.meta.url),t=re(e),n=T(t,`..`,`package.json`),r=JSON.parse(b(n,`utf8`));return r.version}catch{return`unknown`}};var De=class{constructor(e=new n,t=Ee()){this.program=e,this.version=t,this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne CLI`).version(this.version,`-v, --version`)}registerCommands(){let n=new Se,r=new Ce,i=new Te,a=new U,o=new he,s=new R;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(t,n)=>{n(e.red(t))}}),this.program.command(`init`).option(`-e, --env <environment>`,`Specify the environment for the configuration profile`).description(`Initialize & create a StackOne CLI configuration profile`).action(e=>{n.execute({environment:e.env})}),this.program.command(`push`).option(`-p, --profile <label>`,`Configuration profile to use`).option(`--api-url <api url>`,`API URL`).option(`--api-key <api key>`,`API Key`).addArgument(new t(`<path>`,`Connector file or directory to push`)).description(`Push a connector to the StackOne registry`).action((e,t)=>{r.execute({profile:t.profile,fileOrDir:e,apiUrl:t.apiUrl,apiKey:t.apiKey})}),this.program.command(`validate`).option(`-w, --watch`,`Run in watch mode`).addArgument(new t(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((e,t)=>{i.execute({watchMode:t.watch,fileOrDir:e})}),this.program.command(`version`).description(`Show version information`).action(()=>{console.info(`${e.greenBright(`StackOne`)} ${e.grey(`CLI`)} ${e.whiteBright(this.version)}`),process.exit(0)});let c=this.program.command(`agent`).description(`StackOne agent commands`);c.command(`setup`).option(`-g, --global`,`Setup global configuration`).option(`-l, --local`,`Setup local project configuration`).description(`Setup StackOne agent (global or local)`).action(e=>{e.global?a.execute():o.execute()}),c.command(`cleanup`).description(`Remove all API keys and credentials from configurations`).action(()=>{s.execute()})}run(){this.program.parse(process.argv)}};export{De as CLI};
@@ -1 +1 @@
1
- const e=require(`./chunk-CUT6urMc.cjs`),t=e.__toESM(require(`fs`)),n=e.__toESM(require(`os`)),r=e.__toESM(require(`path`)),i=e.__toESM(require(`fs/promises`)),a=e.__toESM(require(`events`)),o=e.__toESM(require(`node:fs/promises`)),s=e.__toESM(require(`node:stream`)),c=e.__toESM(require(`node:path`)),l={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},u={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:l.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(u);const d=`READDIRP_RECURSIVE_ERROR`,f=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,d]),p=[l.DIR_TYPE,l.EVERYTHING_TYPE,l.FILE_DIR_TYPE,l.FILE_TYPE],ee=new Set([l.DIR_TYPE,l.EVERYTHING_TYPE,l.FILE_DIR_TYPE]),m=new Set([l.EVERYTHING_TYPE,l.FILE_DIR_TYPE,l.FILE_TYPE]),te=e=>f.has(e.code),ne=process.platform===`win32`,h=e=>!0,g=e=>{if(e===void 0)return h;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return h};var _=class extends s.Readable{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...u,...e},{root:n,type:r}=t;this._fileFilter=g(t.fileFilter),this._directoryFilter=g(t.directoryFilter);let i=t.lstat?o.lstat:o.stat;ne?this._stat=e=>i(e,{bigint:!0}):this._stat=i,this._maxDepth=t.depth??u.depth,this._wantsDir=r?ee.has(r):!1,this._wantsFile=r?m.has(r):!1,this._wantsEverything=r===l.EVERYTHING_TYPE,this._root=(0,c.resolve)(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await(0,o.readdir)(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let n,r=this._isDirent?e.name:e;try{let i=(0,c.resolve)((0,c.join)(t,r));n={path:(0,c.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(e){this._onError(e);return}return n}_onError(e){te(e)&&!this.destroyed?this.emit(`warn`,e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return``;let t=e[this._statsProp];if(t.isFile())return`file`;if(t.isDirectory())return`directory`;if(t&&t.isSymbolicLink()){let t=e.fullPath;try{let e=await(0,o.realpath)(t),n=await(0,o.lstat)(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===c.sep){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=d,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function v(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=l.FILE_DIR_TYPE),n&&(t.type=n),e){if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!p.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${p.join(`, `)}`)}else throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);return t.root=e,new _(t)}const re=`data`,y=`end`,ie=`close`,b=()=>{},x=process.platform,S=x===`win32`,C=x===`darwin`,w=x===`linux`,T=x===`freebsd`,E=(0,n.type)()===`OS400`,D={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},O=D,ae=`watch`,oe={lstat:i.lstat,stat:i.stat},k=`listeners`,A=`errHandlers`,j=`rawEmitters`,se=[k,A,j],ce=new Set(`3dm.3ds.3g2.3gp.7z.a.aac.adp.afdesign.afphoto.afpub.ai.aif.aiff.alz.ape.apk.appimage.ar.arj.asf.au.avi.bak.baml.bh.bin.bk.bmp.btif.bz2.bzip2.cab.caf.cgm.class.cmx.cpio.cr2.cur.dat.dcm.deb.dex.djvu.dll.dmg.dng.doc.docm.docx.dot.dotm.dra.DS_Store.dsk.dts.dtshd.dvb.dwg.dxf.ecelp4800.ecelp7470.ecelp9600.egg.eol.eot.epub.exe.f4v.fbs.fh.fla.flac.flatpak.fli.flv.fpx.fst.fvt.g3.gh.gif.graffle.gz.gzip.h261.h263.h264.icns.ico.ief.img.ipa.iso.jar.jpeg.jpg.jpgv.jpm.jxr.key.ktx.lha.lib.lvp.lz.lzh.lzma.lzo.m3u.m4a.m4v.mar.mdi.mht.mid.midi.mj2.mka.mkv.mmr.mng.mobi.mov.movie.mp3.mp4.mp4a.mpeg.mpg.mpga.mxu.nef.npx.numbers.nupkg.o.odp.ods.odt.oga.ogg.ogv.otf.ott.pages.pbm.pcx.pdb.pdf.pea.pgm.pic.png.pnm.pot.potm.potx.ppa.ppam.ppm.pps.ppsm.ppsx.ppt.pptm.pptx.psd.pya.pyc.pyo.pyv.qt.rar.ras.raw.resources.rgb.rip.rlc.rmf.rmvb.rpm.rtf.rz.s3m.s7z.scpt.sgi.shar.snap.sil.sketch.slk.smv.snk.so.stl.suo.sub.swf.tar.tbz.tbz2.tga.tgz.thmx.tif.tiff.tlz.ttc.ttf.txz.udf.uvh.uvi.uvm.uvp.uvs.uvu.viv.vob.war.wav.wax.wbmp.wdp.weba.webm.webp.whl.wim.wm.wma.wmv.wmx.woff.woff2.wrm.wvx.xbm.xif.xla.xlam.xls.xlsb.xlsm.xlsx.xlt.xltm.xltx.xm.xmind.xpi.xpm.xwd.xz.z.zip.zipx`.split(`.`)),le=e=>ce.has(r.extname(e).slice(1).toLowerCase()),M=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},N=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},ue=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},P=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},F=e=>e instanceof Set?e.size===0:!e,I=new Map;function L(e,n,i,a,o){let s=(t,n)=>{i(e),o(t,n,{watchedPath:e}),n&&e!==n&&R(r.resolve(e,n),k,r.join(e,n))};try{return(0,t.watch)(e,{persistent:n.persistent},s)}catch(e){a(e);return}}const R=(e,t,n,r,i)=>{let a=I.get(e);a&&M(a[t],e=>{e(n,r,i)})},z=(e,t,n,r)=>{let{listener:a,errHandler:o,rawEmitter:s}=r,c=I.get(t),l;if(!n.persistent)return l=L(e,n,a,o,s),l?l.close.bind(l):void 0;if(c)N(c,k,a),N(c,A,o),N(c,j,s);else{if(l=L(e,n,R.bind(null,t,k),o,R.bind(null,t,j)),!l)return;l.on(O.ERROR,async n=>{let r=R.bind(null,t,A);if(c&&(c.watcherUnusable=!0),S&&n.code===`EPERM`)try{let t=await(0,i.open)(e,`r`);await t.close(),r(n)}catch{}else r(n)}),c={listeners:a,errHandlers:o,rawEmitters:s,watcher:l},I.set(t,c)}return()=>{P(c,k,a),P(c,A,o),P(c,j,s),F(c.listeners)&&(c.watcher.close(),I.delete(t),se.forEach(ue(c)),c.watcher=void 0,Object.freeze(c))}},B=new Map,V=(e,n,r,i)=>{let{listener:a,rawEmitter:o}=i,s=B.get(n),c=s&&s.options;return c&&(c.persistent<r.persistent||c.interval>r.interval)&&((0,t.unwatchFile)(n),s=void 0),s?(N(s,k,a),N(s,j,o)):(s={listeners:a,rawEmitters:o,options:r,watcher:(0,t.watchFile)(n,r,(t,r)=>{M(s.rawEmitters,e=>{e(O.CHANGE,n,{curr:t,prev:r})});let i=t.mtimeMs;(t.size!==r.size||i>r.mtimeMs||i===0)&&M(s.listeners,n=>n(e,t))})},B.set(n,s)),()=>{P(s,k,a),P(s,j,o),F(s.listeners)&&(B.delete(n),(0,t.unwatchFile)(n),s.options=s.watcher=void 0,Object.freeze(s))}};var H=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,i=r.dirname(e),a=r.basename(e),o=this.fsw._getWatchedDir(i);o.add(a);let s=r.resolve(e),c={persistent:n.persistent};t||=b;let l;if(n.usePolling){let r=n.interval!==n.binaryInterval;c.interval=r&&le(a)?n.binaryInterval:n.interval,l=V(e,s,c,{listener:t,rawEmitter:this.fsw._emitRaw})}else l=z(e,s,c,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(e,t,n){if(this.fsw.closed)return;let a=r.dirname(e),o=r.basename(e),s=this.fsw._getWatchedDir(a),c=t;if(s.has(o))return;let l=async(t,n)=>{if(this.fsw._throttle(ae,e,5)){if(!n||n.mtimeMs===0)try{let n=await(0,i.stat)(e);if(this.fsw.closed)return;let r=n.atimeMs,a=n.mtimeMs;if((!r||r<=a||a!==c.mtimeMs)&&this.fsw._emit(O.CHANGE,e,n),(C||w||T)&&c.ino!==n.ino){this.fsw._closeFile(t),c=n;let r=this._watchWithNodeFs(e,l);r&&this.fsw._addPathCloser(t,r)}else c=n}catch{this.fsw._remove(a,o)}else if(s.has(o)){let t=n.atimeMs,r=n.mtimeMs;(!t||t<=r||r!==c.mtimeMs)&&this.fsw._emit(O.CHANGE,e,n),c=n}}},u=this._watchWithNodeFs(e,l);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(O.ADD,e,0))return;this.fsw._emit(O.ADD,e,t)}return u}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let a=e.fullPath,o=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await(0,i.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(o.has(r)?this.fsw._symlinkPaths.get(a)!==t&&(this.fsw._symlinkPaths.set(a,t),this.fsw._emit(O.CHANGE,n,e.stats)):(o.add(r),this.fsw._symlinkPaths.set(a,t),this.fsw._emit(O.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(a))return!0;this.fsw._symlinkPaths.set(a,!0)}_handleRead(e,t,n,i,a,o,s){if(e=r.join(e,``),s=this.fsw._throttle(`readdir`,e,1e3),!s)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,u=this.fsw._readdirp(e,{fileFilter:e=>n.filterPath(e),directoryFilter:e=>n.filterDir(e)});if(u)return u.on(re,async s=>{if(this.fsw.closed){u=void 0;return}let d=s.path,f=r.join(e,d);if(l.add(d),!(s.stats.isSymbolicLink()&&await this._handleSymlink(s,e,f,d))){if(this.fsw.closed){u=void 0;return}(d===i||!i&&!c.has(d))&&(this.fsw._incrReadyCount(),f=r.join(a,r.relative(a,f)),this._addToNodeFs(f,t,n,o+1))}}).on(O.ERROR,this._boundHandleError),new Promise((t,r)=>{if(!u)return r();u.once(y,()=>{if(this.fsw.closed){u=void 0;return}let r=s?s.clear():!1;t(void 0),c.getChildren().filter(t=>t!==e&&!l.has(t)).forEach(t=>{this.fsw._remove(e,t)}),u=void 0,r&&this._handleRead(e,!1,n,i,a,o,s)})})}async _handleDir(e,t,n,i,a,o,s){let c=this.fsw._getWatchedDir(r.dirname(e)),l=c.has(r.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!a&&!l&&this.fsw._emit(O.ADD_DIR,e,t),c.add(r.basename(e)),this.fsw._getWatchedDir(e);let u,d,f=this.fsw.options.depth;if((f==null||i<=f)&&!this.fsw._symlinkPaths.has(s)){if(!a&&(await this._handleRead(e,n,o,a,e,i,u),this.fsw.closed))return;d=this._watchWithNodeFs(e,(t,n)=>{n&&n.mtimeMs===0||this._handleRead(t,!1,o,a,e,i,u)})}return d}async _addToNodeFs(e,t,n,a,o){let s=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return s(),!1;let c=this.fsw._getWatchHelpers(e);n&&(c.filterPath=e=>n.filterPath(e),c.filterDir=e=>n.filterDir(e));try{let n=await oe[c.statMethod](c.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(c.watchPath,n))return s(),!1;let l=this.fsw.options.followSymlinks,u;if(n.isDirectory()){let s=r.resolve(e),d=l?await(0,i.realpath)(e):e;if(this.fsw.closed||(u=await this._handleDir(c.watchPath,n,t,a,o,c,d),this.fsw.closed))return;s!==d&&d!==void 0&&this.fsw._symlinkPaths.set(s,d)}else if(n.isSymbolicLink()){let o=l?await(0,i.realpath)(e):e;if(this.fsw.closed)return;let s=r.dirname(c.watchPath);if(this.fsw._getWatchedDir(s).add(c.watchPath),this.fsw._emit(O.ADD,c.watchPath,n),u=await this._handleDir(s,n,t,a,e,c,o),this.fsw.closed)return;o!==void 0&&this.fsw._symlinkPaths.set(r.resolve(e),o)}else u=this._handleFile(c.watchPath,n,t);return s(),u&&this.fsw._addPathCloser(e,u),!1}catch(t){if(this.fsw._handleError(t))return s(),e}}};const U=`/`,de=`//`,W=`.`,fe=`..`,pe=`string`,me=/\\/g,G=/\/\//,he=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ge=/^\.[/\\]/;function K(e){return Array.isArray(e)?e:[e]}const q=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function _e(e){return typeof e==`function`?e:typeof e==`string`?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e==`object`&&e?t=>{if(e.path===t)return!0;if(e.recursive){let n=r.relative(e.path,t);return n?!n.startsWith(`..`)&&!r.isAbsolute(n):!1}return!1}:()=>!1}function ve(e){if(typeof e!=`string`)throw Error(`string expected`);e=r.normalize(e),e=e.replace(/\\/g,`/`);let t=!1;e.startsWith(`//`)&&(t=!0);let n=/\/\//;for(;e.match(n);)e=e.replace(n,`/`);return t&&(e=`/`+e),e}function J(e,t,n){let r=ve(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function ye(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=K(e),r=n.map(e=>_e(e));return t==null?(e,t)=>J(r,e,t):J(r,t)}const Y=e=>{let t=K(e).flat();if(!t.every(e=>typeof e===pe))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(Z)},X=e=>{let t=e.replace(me,U),n=!1;for(t.startsWith(de)&&(n=!0);t.match(G);)t=t.replace(G,U);return n&&(t=U+t),t},Z=e=>X(r.normalize(X(e))),Q=(e=``)=>t=>typeof t==`string`?Z(r.isAbsolute(t)?t:r.join(e,t)):t,be=(e,t)=>r.isAbsolute(e)?e:r.join(t,e),xe=Object.freeze(new Set);var Se=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==W&&e!==fe&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await(0,i.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(r.dirname(n),r.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path=``,this._removeWatcher=b,this.items=xe,Object.freeze(this)}};const Ce=`stat`,$=`lstat`;var we=class{constructor(e,t,n){this.fsw=n;let i=e;this.path=e=e.replace(ge,``),this.watchPath=i,this.fullWatchPath=r.resolve(i),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=t,this.statMethod=t?Ce:$}entryPath(e){return r.join(this.watchPath,r.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Te=class extends a.EventEmitter{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?K(e.ignored):K([]),awaitWriteFinish:t===!0?n:typeof t==`object`?{...n,...t}:!1};E&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=b,this._readyEmitted=!0,process.nextTick(()=>this.emit(D.READY)))},this._emitRaw=(...e)=>this.emit(D.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new H(this),Object.freeze(r)}_addIgnoredPath(e){if(q(e)){for(let t of this._ignoredPaths)if(q(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e==`string`)for(let t of this._ignoredPaths)q(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:i}=this.options;this.closed=!1,this._closePromise=void 0;let a=Y(e);return i&&(a=a.map(e=>{let t=be(e,i);return t})),a.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=a.length,Promise.all(a.map(async e=>{let r=await this._nodeFsHandler._addToNodeFs(e,!n,void 0,0,t);return r&&this._emitReady(),r})).then(e=>{this.closed||e.forEach(e=>{e&&this.add(r.dirname(e),r.basename(t||e))})}),this}unwatch(e){if(this.closed)return this;let t=Y(e),{cwd:n}=this.options;return t.forEach(e=>{!r.isAbsolute(e)&&!this._closers.has(e)&&(n&&(e=r.join(n,e)),e=r.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let i=this.options.cwd?r.relative(this.options.cwd,n):n,a=i||W;e[a]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==D.ERROR&&this.emit(D.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let a=this.options;S&&(t=r.normalize(t)),a.cwd&&(t=r.relative(a.cwd,t));let o=[t];n!=null&&o.push(n);let s=a.awaitWriteFinish,c;if(s&&(c=this._pendingWrites.get(t)))return c.lastChange=new Date,this;if(a.atomic){if(e===D.UNLINK)return this._pendingUnlinks.set(t,[e,...o]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(D.ALL,...e),this._pendingUnlinks.delete(t)})},typeof a.atomic==`number`?a.atomic:100),this;e===D.ADD&&this._pendingUnlinks.has(t)&&(e=D.CHANGE,this._pendingUnlinks.delete(t))}if(s&&(e===D.ADD||e===D.CHANGE)&&this._readyEmitted){let n=(t,n)=>{t?(e=D.ERROR,o[0]=t,this.emitWithAll(e,o)):n&&(o.length>1?o[1]=n:o.push(n),this.emitWithAll(e,o))};return this._awaitWriteFinish(t,s.stabilityThreshold,e,n),this}if(e===D.CHANGE){let e=!this._throttle(D.CHANGE,t,50);if(e)return this}if(a.alwaysStat&&n===void 0&&(e===D.ADD||e===D.ADD_DIR||e===D.CHANGE)){let e=a.cwd?r.join(a.cwd,t):t,n;try{n=await(0,i.stat)(e)}catch{}if(!n||this.closed)return;o.push(n)}return this.emitWithAll(e,o),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(D.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(o,n);let s={timeoutObject:a,clear:o,count:0};return r.set(t,s),s}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,n,i,a){let o=this.options.awaitWriteFinish;if(typeof o!=`object`)return;let s=o.pollInterval,c,l=e;this.options.cwd&&!r.isAbsolute(e)&&(l=r.join(this.options.cwd,e));let u=new Date,d=this._pendingWrites;function f(r){(0,t.stat)(l,(t,i)=>{if(t||!d.has(e)){t&&t.code!==`ENOENT`&&a(t);return}let o=Number(new Date);r&&i.size!==r.size&&(d.get(e).lastChange=o);let l=d.get(e),u=o-l.lastChange;u>=n?(d.delete(e),a(void 0,i)):c=setTimeout(f,s,i)})}d.has(e)||(d.set(e,{lastChange:u,cancelWait:()=>(d.delete(e),clearTimeout(c),i)}),c=setTimeout(f,s))}_isIgnored(e,t){if(this.options.atomic&&he.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=this.options.ignored,n=(t||[]).map(Q(e)),r=[...this._ignoredPaths],i=[...r.map(Q(e)),...n];this._userIgnored=ye(i,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new we(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=r.resolve(e);return this._watched.has(t)||this._watched.set(t,new Se(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let i=r.join(e,t),a=r.resolve(i);if(n??=this._watched.has(i)||this._watched.has(a),!this._throttle(`remove`,i,100))return;!n&&this._watched.size===1&&this.add(e,t,!0);let o=this._getWatchedDir(i),s=o.getChildren();s.forEach(e=>this._remove(i,e));let c=this._getWatchedDir(e),l=c.has(t);c.remove(t),this._symlinkPaths.has(a)&&this._symlinkPaths.delete(a);let u=i;if(this.options.cwd&&(u=r.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)){let e=this._pendingWrites.get(u).cancelWait();if(e===D.ADD)return}this._watched.delete(i),this._watched.delete(a);let d=n?D.UNLINK_DIR:D.UNLINK;l&&!this._isIgnored(i)&&this._emit(d,i),this._closePath(i)}_closePath(e){this._closeFile(e);let t=r.dirname(e);this._getWatchedDir(t).remove(r.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n={type:D.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=v(e,n);return this._streams.add(r),r.once(ie,()=>{r=void 0}),r.once(y,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function Ee(e,t={}){let n=new Te(t);return n.add(e),n}exports.watch=Ee;
1
+ const e=require(`./chunk-CUT6urMc.cjs`),t=e.__toESM(require(`node:fs/promises`)),n=e.__toESM(require(`node:path`)),r=e.__toESM(require(`fs`)),i=e.__toESM(require(`os`)),a=e.__toESM(require(`path`)),o=e.__toESM(require(`fs/promises`)),s=e.__toESM(require(`events`)),c=e.__toESM(require(`node:stream`)),l={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},u={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:l.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(u);const d=`READDIRP_RECURSIVE_ERROR`,f=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,d]),p=[l.DIR_TYPE,l.EVERYTHING_TYPE,l.FILE_DIR_TYPE,l.FILE_TYPE],ee=new Set([l.DIR_TYPE,l.EVERYTHING_TYPE,l.FILE_DIR_TYPE]),m=new Set([l.EVERYTHING_TYPE,l.FILE_DIR_TYPE,l.FILE_TYPE]),te=e=>f.has(e.code),ne=process.platform===`win32`,h=e=>!0,g=e=>{if(e===void 0)return h;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return h};var _=class extends c.Readable{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...u,...e},{root:i,type:a}=r;this._fileFilter=g(r.fileFilter),this._directoryFilter=g(r.directoryFilter);let o=r.lstat?t.lstat:t.stat;ne?this._stat=e=>o(e,{bigint:!0}):this._stat=o,this._maxDepth=r.depth??u.depth,this._wantsDir=a?ee.has(a):!1,this._wantsFile=a?m.has(a):!1,this._wantsEverything=a===l.EVERYTHING_TYPE,this._root=(0,n.resolve)(i),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,n){let r;try{r=await(0,t.readdir)(e,this._rdOptions)}catch(e){this._onError(e)}return{files:r,depth:n,path:e}}async _formatEntry(e,t){let r,i=this._isDirent?e.name:e;try{let a=(0,n.resolve)((0,n.join)(t,i));r={path:(0,n.relative)(this._root,a),fullPath:a,basename:i},r[this._statsProp]=this._isDirent?e:await this._stat(a)}catch(e){this._onError(e);return}return r}_onError(e){te(e)&&!this.destroyed?this.emit(`warn`,e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return``;let r=e[this._statsProp];if(r.isFile())return`file`;if(r.isDirectory())return`directory`;if(r&&r.isSymbolicLink()){let r=e.fullPath;try{let e=await(0,t.realpath)(r),i=await(0,t.lstat)(e);if(i.isFile())return`file`;if(i.isDirectory()){let t=e.length;if(r.startsWith(e)&&r.substr(t,1)===n.sep){let t=Error(`Circular symlink detected: "${r}" points to "${e}"`);return t.code=d,this._onError(t)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function v(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=l.FILE_DIR_TYPE),n&&(t.type=n),e){if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!p.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${p.join(`, `)}`)}else throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);return t.root=e,new _(t)}const re=`data`,y=`end`,ie=`close`,b=()=>{},x=process.platform,S=x===`win32`,C=x===`darwin`,w=x===`linux`,T=x===`freebsd`,E=(0,i.type)()===`OS400`,D={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},O=D,ae=`watch`,oe={lstat:o.lstat,stat:o.stat},k=`listeners`,A=`errHandlers`,j=`rawEmitters`,se=[k,A,j],ce=new Set(`3dm.3ds.3g2.3gp.7z.a.aac.adp.afdesign.afphoto.afpub.ai.aif.aiff.alz.ape.apk.appimage.ar.arj.asf.au.avi.bak.baml.bh.bin.bk.bmp.btif.bz2.bzip2.cab.caf.cgm.class.cmx.cpio.cr2.cur.dat.dcm.deb.dex.djvu.dll.dmg.dng.doc.docm.docx.dot.dotm.dra.DS_Store.dsk.dts.dtshd.dvb.dwg.dxf.ecelp4800.ecelp7470.ecelp9600.egg.eol.eot.epub.exe.f4v.fbs.fh.fla.flac.flatpak.fli.flv.fpx.fst.fvt.g3.gh.gif.graffle.gz.gzip.h261.h263.h264.icns.ico.ief.img.ipa.iso.jar.jpeg.jpg.jpgv.jpm.jxr.key.ktx.lha.lib.lvp.lz.lzh.lzma.lzo.m3u.m4a.m4v.mar.mdi.mht.mid.midi.mj2.mka.mkv.mmr.mng.mobi.mov.movie.mp3.mp4.mp4a.mpeg.mpg.mpga.mxu.nef.npx.numbers.nupkg.o.odp.ods.odt.oga.ogg.ogv.otf.ott.pages.pbm.pcx.pdb.pdf.pea.pgm.pic.png.pnm.pot.potm.potx.ppa.ppam.ppm.pps.ppsm.ppsx.ppt.pptm.pptx.psd.pya.pyc.pyo.pyv.qt.rar.ras.raw.resources.rgb.rip.rlc.rmf.rmvb.rpm.rtf.rz.s3m.s7z.scpt.sgi.shar.snap.sil.sketch.slk.smv.snk.so.stl.suo.sub.swf.tar.tbz.tbz2.tga.tgz.thmx.tif.tiff.tlz.ttc.ttf.txz.udf.uvh.uvi.uvm.uvp.uvs.uvu.viv.vob.war.wav.wax.wbmp.wdp.weba.webm.webp.whl.wim.wm.wma.wmv.wmx.woff.woff2.wrm.wvx.xbm.xif.xla.xlam.xls.xlsb.xlsm.xlsx.xlt.xltm.xltx.xm.xmind.xpi.xpm.xwd.xz.z.zip.zipx`.split(`.`)),le=e=>ce.has(a.extname(e).slice(1).toLowerCase()),M=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},N=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},ue=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},P=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},F=e=>e instanceof Set?e.size===0:!e,I=new Map;function L(e,t,n,i,o){let s=(t,r)=>{n(e),o(t,r,{watchedPath:e}),r&&e!==r&&R(a.resolve(e,r),k,a.join(e,r))};try{return(0,r.watch)(e,{persistent:t.persistent},s)}catch(e){i(e);return}}const R=(e,t,n,r,i)=>{let a=I.get(e);a&&M(a[t],e=>{e(n,r,i)})},z=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:s}=r,c=I.get(t),l;if(!n.persistent)return l=L(e,n,i,a,s),l?l.close.bind(l):void 0;if(c)N(c,k,i),N(c,A,a),N(c,j,s);else{if(l=L(e,n,R.bind(null,t,k),a,R.bind(null,t,j)),!l)return;l.on(O.ERROR,async n=>{let r=R.bind(null,t,A);if(c&&(c.watcherUnusable=!0),S&&n.code===`EPERM`)try{let t=await(0,o.open)(e,`r`);await t.close(),r(n)}catch{}else r(n)}),c={listeners:i,errHandlers:a,rawEmitters:s,watcher:l},I.set(t,c)}return()=>{P(c,k,i),P(c,A,a),P(c,j,s),F(c.listeners)&&(c.watcher.close(),I.delete(t),se.forEach(ue(c)),c.watcher=void 0,Object.freeze(c))}},B=new Map,V=(e,t,n,i)=>{let{listener:a,rawEmitter:o}=i,s=B.get(t),c=s&&s.options;return c&&(c.persistent<n.persistent||c.interval>n.interval)&&((0,r.unwatchFile)(t),s=void 0),s?(N(s,k,a),N(s,j,o)):(s={listeners:a,rawEmitters:o,options:n,watcher:(0,r.watchFile)(t,n,(n,r)=>{M(s.rawEmitters,e=>{e(O.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&M(s.listeners,t=>t(e,n))})},B.set(t,s)),()=>{P(s,k,a),P(s,j,o),F(s.listeners)&&(B.delete(t),(0,r.unwatchFile)(t),s.options=s.watcher=void 0,Object.freeze(s))}};var H=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,r=a.dirname(e),i=a.basename(e),o=this.fsw._getWatchedDir(r);o.add(i);let s=a.resolve(e),c={persistent:n.persistent};t||=b;let l;if(n.usePolling){let r=n.interval!==n.binaryInterval;c.interval=r&&le(i)?n.binaryInterval:n.interval,l=V(e,s,c,{listener:t,rawEmitter:this.fsw._emitRaw})}else l=z(e,s,c,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(e,t,n){if(this.fsw.closed)return;let r=a.dirname(e),i=a.basename(e),s=this.fsw._getWatchedDir(r),c=t;if(s.has(i))return;let l=async(t,n)=>{if(this.fsw._throttle(ae,e,5)){if(!n||n.mtimeMs===0)try{let n=await(0,o.stat)(e);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==c.mtimeMs)&&this.fsw._emit(O.CHANGE,e,n),(C||w||T)&&c.ino!==n.ino){this.fsw._closeFile(t),c=n;let r=this._watchWithNodeFs(e,l);r&&this.fsw._addPathCloser(t,r)}else c=n}catch{this.fsw._remove(r,i)}else if(s.has(i)){let t=n.atimeMs,r=n.mtimeMs;(!t||t<=r||r!==c.mtimeMs)&&this.fsw._emit(O.CHANGE,e,n),c=n}}},u=this._watchWithNodeFs(e,l);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(O.ADD,e,0))return;this.fsw._emit(O.ADD,e,t)}return u}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await(0,o.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(O.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(O.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,n,r,i,o,s){if(e=a.join(e,``),s=this.fsw._throttle(`readdir`,e,1e3),!s)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,u=this.fsw._readdirp(e,{fileFilter:e=>n.filterPath(e),directoryFilter:e=>n.filterDir(e)});if(u)return u.on(re,async s=>{if(this.fsw.closed){u=void 0;return}let d=s.path,f=a.join(e,d);if(l.add(d),!(s.stats.isSymbolicLink()&&await this._handleSymlink(s,e,f,d))){if(this.fsw.closed){u=void 0;return}(d===r||!r&&!c.has(d))&&(this.fsw._incrReadyCount(),f=a.join(i,a.relative(i,f)),this._addToNodeFs(f,t,n,o+1))}}).on(O.ERROR,this._boundHandleError),new Promise((t,a)=>{if(!u)return a();u.once(y,()=>{if(this.fsw.closed){u=void 0;return}let a=s?s.clear():!1;t(void 0),c.getChildren().filter(t=>t!==e&&!l.has(t)).forEach(t=>{this.fsw._remove(e,t)}),u=void 0,a&&this._handleRead(e,!1,n,r,i,o,s)})})}async _handleDir(e,t,n,r,i,o,s){let c=this.fsw._getWatchedDir(a.dirname(e)),l=c.has(a.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(O.ADD_DIR,e,t),c.add(a.basename(e)),this.fsw._getWatchedDir(e);let u,d,f=this.fsw.options.depth;if((f==null||r<=f)&&!this.fsw._symlinkPaths.has(s)){if(!i&&(await this._handleRead(e,n,o,i,e,r,u),this.fsw.closed))return;d=this._watchWithNodeFs(e,(t,n)=>{n&&n.mtimeMs===0||this._handleRead(t,!1,o,i,e,r,u)})}return d}async _addToNodeFs(e,t,n,r,i){let s=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return s(),!1;let c=this.fsw._getWatchHelpers(e);n&&(c.filterPath=e=>n.filterPath(e),c.filterDir=e=>n.filterDir(e));try{let n=await oe[c.statMethod](c.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(c.watchPath,n))return s(),!1;let l=this.fsw.options.followSymlinks,u;if(n.isDirectory()){let s=a.resolve(e),d=l?await(0,o.realpath)(e):e;if(this.fsw.closed||(u=await this._handleDir(c.watchPath,n,t,r,i,c,d),this.fsw.closed))return;s!==d&&d!==void 0&&this.fsw._symlinkPaths.set(s,d)}else if(n.isSymbolicLink()){let i=l?await(0,o.realpath)(e):e;if(this.fsw.closed)return;let s=a.dirname(c.watchPath);if(this.fsw._getWatchedDir(s).add(c.watchPath),this.fsw._emit(O.ADD,c.watchPath,n),u=await this._handleDir(s,n,t,r,e,c,i),this.fsw.closed)return;i!==void 0&&this.fsw._symlinkPaths.set(a.resolve(e),i)}else u=this._handleFile(c.watchPath,n,t);return s(),u&&this.fsw._addPathCloser(e,u),!1}catch(t){if(this.fsw._handleError(t))return s(),e}}};const U=`/`,de=`//`,W=`.`,fe=`..`,pe=`string`,me=/\\/g,G=/\/\//,he=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ge=/^\.[/\\]/;function K(e){return Array.isArray(e)?e:[e]}const q=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function _e(e){return typeof e==`function`?e:typeof e==`string`?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e==`object`&&e?t=>{if(e.path===t)return!0;if(e.recursive){let n=a.relative(e.path,t);return n?!n.startsWith(`..`)&&!a.isAbsolute(n):!1}return!1}:()=>!1}function ve(e){if(typeof e!=`string`)throw Error(`string expected`);e=a.normalize(e),e=e.replace(/\\/g,`/`);let t=!1;e.startsWith(`//`)&&(t=!0);let n=/\/\//;for(;e.match(n);)e=e.replace(n,`/`);return t&&(e=`/`+e),e}function J(e,t,n){let r=ve(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function ye(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=K(e),r=n.map(e=>_e(e));return t==null?(e,t)=>J(r,e,t):J(r,t)}const Y=e=>{let t=K(e).flat();if(!t.every(e=>typeof e===pe))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(Z)},X=e=>{let t=e.replace(me,U),n=!1;for(t.startsWith(de)&&(n=!0);t.match(G);)t=t.replace(G,U);return n&&(t=U+t),t},Z=e=>X(a.normalize(X(e))),Q=(e=``)=>t=>typeof t==`string`?Z(a.isAbsolute(t)?t:a.join(e,t)):t,be=(e,t)=>a.isAbsolute(e)?e:a.join(t,e),xe=Object.freeze(new Set);var Se=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==W&&e!==fe&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await(0,o.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(a.dirname(n),a.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path=``,this._removeWatcher=b,this.items=xe,Object.freeze(this)}};const Ce=`stat`,$=`lstat`;var we=class{constructor(e,t,n){this.fsw=n;let r=e;this.path=e=e.replace(ge,``),this.watchPath=r,this.fullWatchPath=a.resolve(r),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=t,this.statMethod=t?Ce:$}entryPath(e){return a.join(this.watchPath,a.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Te=class extends s.EventEmitter{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?K(e.ignored):K([]),awaitWriteFinish:t===!0?n:typeof t==`object`?{...n,...t}:!1};E&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=b,this._readyEmitted=!0,process.nextTick(()=>this.emit(D.READY)))},this._emitRaw=(...e)=>this.emit(D.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new H(this),Object.freeze(r)}_addIgnoredPath(e){if(q(e)){for(let t of this._ignoredPaths)if(q(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e==`string`)for(let t of this._ignoredPaths)q(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=Y(e);return r&&(i=i.map(e=>{let t=be(e,r);return t})),i.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=i.length,Promise.all(i.map(async e=>{let r=await this._nodeFsHandler._addToNodeFs(e,!n,void 0,0,t);return r&&this._emitReady(),r})).then(e=>{this.closed||e.forEach(e=>{e&&this.add(a.dirname(e),a.basename(t||e))})}),this}unwatch(e){if(this.closed)return this;let t=Y(e),{cwd:n}=this.options;return t.forEach(e=>{!a.isAbsolute(e)&&!this._closers.has(e)&&(n&&(e=a.join(n,e)),e=a.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let r=this.options.cwd?a.relative(this.options.cwd,n):n,i=r||W;e[i]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==D.ERROR&&this.emit(D.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let r=this.options;S&&(t=a.normalize(t)),r.cwd&&(t=a.relative(r.cwd,t));let i=[t];n!=null&&i.push(n);let s=r.awaitWriteFinish,c;if(s&&(c=this._pendingWrites.get(t)))return c.lastChange=new Date,this;if(r.atomic){if(e===D.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(D.ALL,...e),this._pendingUnlinks.delete(t)})},typeof r.atomic==`number`?r.atomic:100),this;e===D.ADD&&this._pendingUnlinks.has(t)&&(e=D.CHANGE,this._pendingUnlinks.delete(t))}if(s&&(e===D.ADD||e===D.CHANGE)&&this._readyEmitted){let n=(t,n)=>{t?(e=D.ERROR,i[0]=t,this.emitWithAll(e,i)):n&&(i.length>1?i[1]=n:i.push(n),this.emitWithAll(e,i))};return this._awaitWriteFinish(t,s.stabilityThreshold,e,n),this}if(e===D.CHANGE){let e=!this._throttle(D.CHANGE,t,50);if(e)return this}if(r.alwaysStat&&n===void 0&&(e===D.ADD||e===D.ADD_DIR||e===D.CHANGE)){let e=r.cwd?a.join(r.cwd,t):t,n;try{n=await(0,o.stat)(e)}catch{}if(!n||this.closed)return;i.push(n)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(D.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(o,n);let s={timeoutObject:a,clear:o,count:0};return r.set(t,s),s}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,n,i){let o=this.options.awaitWriteFinish;if(typeof o!=`object`)return;let s=o.pollInterval,c,l=e;this.options.cwd&&!a.isAbsolute(e)&&(l=a.join(this.options.cwd,e));let u=new Date,d=this._pendingWrites;function f(n){(0,r.stat)(l,(r,a)=>{if(r||!d.has(e)){r&&r.code!==`ENOENT`&&i(r);return}let o=Number(new Date);n&&a.size!==n.size&&(d.get(e).lastChange=o);let l=d.get(e),u=o-l.lastChange;u>=t?(d.delete(e),i(void 0,a)):c=setTimeout(f,s,a)})}d.has(e)||(d.set(e,{lastChange:u,cancelWait:()=>(d.delete(e),clearTimeout(c),n)}),c=setTimeout(f,s))}_isIgnored(e,t){if(this.options.atomic&&he.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=this.options.ignored,n=(t||[]).map(Q(e)),r=[...this._ignoredPaths],i=[...r.map(Q(e)),...n];this._userIgnored=ye(i,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new we(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=a.resolve(e);return this._watched.has(t)||this._watched.set(t,new Se(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let r=a.join(e,t),i=a.resolve(r);if(n??=this._watched.has(r)||this._watched.has(i),!this._throttle(`remove`,r,100))return;!n&&this._watched.size===1&&this.add(e,t,!0);let o=this._getWatchedDir(r),s=o.getChildren();s.forEach(e=>this._remove(r,e));let c=this._getWatchedDir(e),l=c.has(t);c.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let u=r;if(this.options.cwd&&(u=a.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)){let e=this._pendingWrites.get(u).cancelWait();if(e===D.ADD)return}this._watched.delete(r),this._watched.delete(i);let d=n?D.UNLINK_DIR:D.UNLINK;l&&!this._isIgnored(r)&&this._emit(d,r),this._closePath(r)}_closePath(e){this._closeFile(e);let t=a.dirname(e);this._getWatchedDir(t).remove(a.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n={type:D.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=v(e,n);return this._streams.add(r),r.once(ie,()=>{r=void 0}),r.once(y,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function Ee(e,t={}){let n=new Te(t);return n.add(e),n}exports.watch=Ee;