@lssm/bundle.contractspec-workspace 0.0.0-canary-20251215220103 → 0.0.0-canary-20251215231151
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/dist/_virtual/rolldown_runtime.js +1 -0
- package/dist/ai/agents/claude-code-agent.js +44 -0
- package/dist/ai/agents/cursor-agent.js +168 -0
- package/dist/ai/agents/index.js +1 -0
- package/dist/ai/agents/openai-codex-agent.js +34 -0
- package/dist/ai/agents/orchestrator.js +1 -0
- package/dist/ai/agents/simple-agent.js +15 -0
- package/dist/ai/client.js +1 -0
- package/dist/ai/index.js +1 -0
- package/dist/ai/prompts/code-generation.js +100 -0
- package/dist/ai/prompts/index.js +1 -0
- package/dist/ai/prompts/spec-creation.js +69 -0
- package/dist/ai/providers.js +1 -0
- package/dist/index.js +1 -1
- package/dist/node_modules/chalk/source/index.js +2 -0
- package/dist/node_modules/chalk/source/utilities.js +4 -0
- package/dist/node_modules/chalk/source/vendor/ansi-styles/index.js +1 -0
- package/dist/node_modules/chalk/source/vendor/supports-color/browser.js +1 -0
- package/dist/node_modules/cli-cursor/index.js +1 -0
- package/dist/node_modules/cli-spinners/index.js +1 -0
- package/dist/node_modules/cli-spinners/spinners.js +1 -0
- package/dist/node_modules/get-east-asian-width/index.js +1 -0
- package/dist/node_modules/get-east-asian-width/lookup.js +1 -0
- package/dist/node_modules/is-interactive/index.js +1 -0
- package/dist/node_modules/is-unicode-supported/index.js +1 -0
- package/dist/node_modules/log-symbols/browser-symbols.js +1 -0
- package/dist/node_modules/mimic-function/index.js +1 -0
- package/dist/node_modules/onetime/index.js +1 -0
- package/dist/node_modules/ora/index.js +6 -0
- package/dist/node_modules/restore-cursor/index.js +1 -0
- package/dist/node_modules/signal-exit/dist/mjs/index.js +1 -0
- package/dist/node_modules/signal-exit/dist/mjs/signals.js +1 -0
- package/dist/node_modules/stdin-discarder/index.js +1 -0
- package/dist/node_modules/string-width/index.js +1 -0
- package/dist/node_modules/strip-ansi/index.js +1 -0
- package/dist/node_modules/strip-ansi/node_modules/ansi-regex/index.js +1 -0
- package/dist/services/index.js +1 -1
- package/dist/services/openapi.js +2 -0
- package/dist/services/registry.js +1 -0
- package/dist/templates/app-config.template.js +33 -0
- package/dist/templates/data-view.template.js +54 -0
- package/dist/templates/event.template.js +24 -0
- package/dist/templates/experiment.template.js +62 -0
- package/dist/templates/handler.template.js +63 -0
- package/dist/templates/index.js +1 -0
- package/dist/templates/integration.template.js +75 -0
- package/dist/templates/knowledge.template.js +33 -0
- package/dist/templates/migration.template.js +37 -0
- package/dist/templates/operation.template.js +88 -0
- package/dist/templates/presentation.template.js +53 -0
- package/dist/templates/telemetry.template.js +69 -0
- package/dist/templates/workflow-runner.template.js +43 -0
- package/dist/templates/workflow.template.js +41 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r};export{t as __export};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import{anthropic as e}from"@ai-sdk/anthropic";import{generateText as t}from"ai";var n=class{name=`claude-code`;apiKey;constructor(){this.apiKey=process.env.ANTHROPIC_API_KEY}canHandle(e){return!!this.apiKey}async generate(n){if(!this.apiKey)return{success:!1,errors:[`ANTHROPIC_API_KEY not set. Claude Code agent requires API access.`]};try{let r=e(`claude-3-7-sonnet-20250219`),i=this.buildSystemPrompt(n),a=await t({model:r,prompt:this.buildUserPrompt(n),system:i,temperature:.2});return{success:!0,code:this.extractCode(a.text),metadata:{model:`claude-3-7-sonnet`,agentMode:`claude-code`,usage:a.usage}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}async validate(n){if(!this.apiKey)return{success:!1,errors:[`ANTHROPIC_API_KEY not set`]};try{let r=await t({model:e(`claude-3-7-sonnet-20250219`),prompt:`
|
|
2
|
+
You are an expert code reviewer. Carefully analyze this implementation against its specification.
|
|
3
|
+
|
|
4
|
+
SPECIFICATION:
|
|
5
|
+
\`\`\`typescript
|
|
6
|
+
${n.specCode}
|
|
7
|
+
\`\`\`
|
|
8
|
+
|
|
9
|
+
IMPLEMENTATION:
|
|
10
|
+
\`\`\`typescript
|
|
11
|
+
${n.existingCode||`// No implementation provided`}
|
|
12
|
+
\`\`\`
|
|
13
|
+
|
|
14
|
+
Provide a structured validation report:
|
|
15
|
+
|
|
16
|
+
## Compliance
|
|
17
|
+
- Does the implementation fulfill all requirements in the spec?
|
|
18
|
+
- Are all inputs/outputs correctly typed?
|
|
19
|
+
|
|
20
|
+
## Code Quality
|
|
21
|
+
- Are there any bugs or potential issues?
|
|
22
|
+
- Is error handling adequate?
|
|
23
|
+
- Are best practices followed?
|
|
24
|
+
|
|
25
|
+
## Suggestions
|
|
26
|
+
- What improvements would you recommend?
|
|
27
|
+
- Are there any missing edge cases?
|
|
28
|
+
|
|
29
|
+
Be thorough and precise. Use a critical but constructive tone.
|
|
30
|
+
`,system:`You are a senior software engineer performing a critical code review.`,temperature:.3}),i=this.detectIssues(r.text);return{success:!i,code:r.text,errors:i?this.extractErrors(r.text):[],warnings:this.extractWarnings(r.text),suggestions:this.extractSuggestions(r.text),metadata:{agentMode:`claude-code`,validationType:`comprehensive`}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}buildSystemPrompt(e){let t=`You are an expert TypeScript developer specializing in contract-driven development.
|
|
31
|
+
|
|
32
|
+
Your code is:
|
|
33
|
+
- Type-safe with comprehensive TypeScript types
|
|
34
|
+
- Well-documented with JSDoc comments
|
|
35
|
+
- Production-ready with proper error handling
|
|
36
|
+
- Following SOLID principles and best practices
|
|
37
|
+
- Modular and testable
|
|
38
|
+
|
|
39
|
+
Generate clean, idiomatic TypeScript code that exactly matches the specification.`;return e.type===`test`?t+`
|
|
40
|
+
|
|
41
|
+
You are also an expert in testing. Write comprehensive tests using Vitest.`:t}buildUserPrompt(e){let t={generate:`Generate a complete, production-ready implementation for this specification:\n\n${e.specCode}\n\nProvide ONLY the TypeScript code, no explanations.`,test:`Generate comprehensive tests for this code:\n\nSpec:\n${e.specCode}\n\nImplementation:\n${e.existingCode}\n\nProvide complete Vitest test suite.`,refactor:`Refactor this code while preserving functionality:\n\n${e.existingCode}\n\nSpec:\n${e.specCode}`,validate:`Validate this implementation:\n\nSpec:\n${e.specCode}\n\nCode:\n${e.existingCode}`};return t[e.type]||t.generate}extractCode(e){let t=e.match(/```(?:typescript|ts|tsx)?\n([\s\S]*?)\n```/);return t&&t[1]?t[1]:e}detectIssues(e){let t=[`missing`,`incorrect`,`bug`,`error`,`violation`,`does not`,`fails to`,`not implemented`,`critical`],n=e.toLowerCase();return t.some(e=>n.includes(e))}extractErrors(e){let t=[],n=e.split(`
|
|
42
|
+
`);for(let e of n){let n=e.toLowerCase();(n.includes(`error`)||n.includes(`bug`)||n.includes(`incorrect`)||n.includes(`missing`))&&t.push(e.trim())}return t.length>0?t:[`Code review identified issues`]}extractWarnings(e){let t=[],n=e.split(`
|
|
43
|
+
`);for(let e of n){let n=e.toLowerCase();(n.includes(`warning`)||n.includes(`should`)||n.includes(`consider`))&&t.push(e.trim())}return t}extractSuggestions(e){let t=[],n=e.split(`
|
|
44
|
+
`);for(let e of n){let n=e.toLowerCase();(n.includes(`suggest`)||n.includes(`recommend`)||n.includes(`could`)||n.includes(`improvement`))&&t.push(e.trim())}return t}};export{n as ClaudeCodeAgent};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import{exec as e,spawn as t}from"child_process";import{mkdir as n,readFile as r,rm as i,writeFile as a}from"fs/promises";import{join as o}from"path";import{homedir as s,tmpdir as c}from"os";import{existsSync as l}from"fs";import{promisify as u}from"util";u(e);var d=class{name=`cursor`;cursorPath=null;isWindsurf=!1;composerPort;constructor(){this.composerPort=process.env.CURSOR_COMPOSER_PORT||`3000`,this.detectEnvironment()}canHandle(e){return this.isCursorAvailable()}async generate(e){try{let t=o(c(),`cursor-agent-${Date.now()}`);await n(t,{recursive:!0});let r=await this.executeWithBestMethod(e,t);return await this.cleanupWorkDir(t),r}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}async validate(e){try{let t=o(c(),`cursor-validate-${Date.now()}`);await n(t,{recursive:!0}),await this.setupValidationWorkspace(e,t);let r=await this.executeWithBestMethod({...e,type:`validate`},t);return await this.cleanupWorkDir(t),r}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}detectEnvironment(){this.isWindsurf=!!(process.env.WINDSURF_SESSION||process.env.CURSOR_USER_DATA||process.env.VSCODE_CWD?.includes(`Cursor`)||process.env.VSCODE_CWD?.includes(`Windsurf`));let e=[`/usr/local/bin/cursor`,`/Applications/Cursor.app/Contents/MacOS/Cursor`,`/Applications/Windsurf.app/Contents/MacOS/Windsurf`,o(s(),`.cursor`,`cursor`),o(s(),`AppData`,`Local`,`Programs`,`cursor`,`Cursor.exe`),o(s(),`AppData`,`Local`,`Programs`,`windsurf`,`Windsurf.exe`),`cursor`,`windsurf`];for(let t of e)if(t.includes(`cursor`)||t.includes(`Cursor`)||t.includes(`windsurf`)||t.includes(`Windsurf`))try{if(l(t)){this.cursorPath=t;break}}catch{continue}}async executeWithBestMethod(e,t){let n=[{name:`cursor-cli`,fn:()=>this.useCursorCLI(e,t)},{name:`file-based`,fn:()=>this.useFileBasedApproach(e,t)}];for(let e of n)try{let t=await e.fn();if(t.success)return t}catch{continue}return{success:!1,warnings:[`Cursor agent could not connect to IDE.`,`Ensure Cursor/Windsurf is running with API enabled.`,`Falling back to simple agent mode is recommended.`],errors:[`All Cursor integration methods failed`],metadata:{agentMode:`cursor`,status:`unavailable`,suggestion:`Use --agent-mode claude-code or --agent-mode simple`}}}async useCursorCLI(e,n){if(!this.cursorPath)throw Error(`Cursor executable not found`);let i=o(n,`spec.ts`),s=o(n,`output.ts`),c=o(n,`INSTRUCTIONS.md`);return await a(i,e.specCode),await a(c,this.buildDetailedPrompt(e)),e.existingCode&&await a(o(n,`existing.ts`),e.existingCode),new Promise((e,i)=>{let a=[`--wait`,`--new-window`,n],o=t(this.cursorPath,a,{cwd:n,stdio:`pipe`,detached:!1}),c=``,u=``;o.stdout?.on(`data`,e=>{c+=e.toString()}),o.stderr?.on(`data`,e=>{u+=e.toString()}),o.on(`error`,e=>{i(e)}),o.on(`close`,async t=>{if(l(s))try{e({success:!0,code:await r(s,`utf-8`),metadata:{agentMode:`cursor`,method:`cli`,exitCode:t}})}catch{i(Error(`Failed to read generated output`))}else i(Error(`Cursor CLI exited with code ${t}. No output generated.`))}),setTimeout(()=>{o.kill(),i(Error(`Cursor CLI timeout`))},6e4)})}async useFileBasedApproach(e,t){let n=o(t,`SPECIFICATION.ts`),r=o(t,`INSTRUCTIONS.md`),i=o(t,`template.ts`);return await a(n,e.specCode),await a(r,this.buildDetailedPrompt(e)),await a(i,this.generateTemplate(e)),await a(o(t,`README.md`),`# Cursor Agent Workspace
|
|
2
|
+
|
|
3
|
+
This workspace was prepared for Cursor AI code generation.
|
|
4
|
+
|
|
5
|
+
## Files:
|
|
6
|
+
- **SPECIFICATION.ts**: The contract specification
|
|
7
|
+
- **INSTRUCTIONS.md**: Detailed instructions for the AI
|
|
8
|
+
- **template.ts**: Starting template
|
|
9
|
+
|
|
10
|
+
## To Complete:
|
|
11
|
+
1. Open this folder in Cursor
|
|
12
|
+
2. Review INSTRUCTIONS.md
|
|
13
|
+
3. Use Cursor AI to generate code based on the spec
|
|
14
|
+
4. Save the result as output.ts
|
|
15
|
+
|
|
16
|
+
Workspace path: ${t}
|
|
17
|
+
`),{success:!1,warnings:[`Cursor agent created workspace but cannot auto-execute.`,`Workspace prepared at: ${t}`,`Open this folder in Cursor IDE to complete code generation.`],code:this.generateTemplate(e),metadata:{agentMode:`cursor`,method:`file-based`,workDir:t}}}async setupValidationWorkspace(e,t){await a(o(t,`specification.ts`),e.specCode),await a(o(t,`implementation.ts`),e.existingCode||`// No implementation`),await a(o(t,`VALIDATION_INSTRUCTIONS.md`),this.buildValidationPrompt(e))}async prepareFilesForAPI(e,t){let n=[{path:`spec.ts`,content:e.specCode}];return e.existingCode&&n.push({path:`existing.ts`,content:e.existingCode}),n}buildDetailedPrompt(e){let t=`# AI Code Generation Task - Cursor Agent\n\n**Task Type:** ${e.type}\n**Generated:** ${new Date().toISOString()}\n\n`,n=`## Specification\n\n\`\`\`typescript\n${e.specCode}\n\`\`\`\n\n`,r={generate:`## Task: Generate Implementation
|
|
18
|
+
|
|
19
|
+
### Requirements:
|
|
20
|
+
1. **Type Safety**: Use strict TypeScript with comprehensive types
|
|
21
|
+
2. **Error Handling**: Implement robust error handling and validation
|
|
22
|
+
3. **Documentation**: Add JSDoc comments for all public APIs
|
|
23
|
+
4. **Best Practices**: Follow SOLID principles and clean code practices
|
|
24
|
+
5. **Testing**: Design code to be easily testable
|
|
25
|
+
6. **Production Ready**: Code should be ready for production use
|
|
26
|
+
|
|
27
|
+
### Implementation Guidelines:
|
|
28
|
+
- Parse and validate all inputs according to the specification
|
|
29
|
+
- Handle all edge cases and error scenarios
|
|
30
|
+
- Use modern TypeScript features appropriately
|
|
31
|
+
- Ensure proper async/await usage if needed
|
|
32
|
+
- Add meaningful variable and function names
|
|
33
|
+
- Keep functions focused and single-purpose
|
|
34
|
+
|
|
35
|
+
### Output Format:
|
|
36
|
+
Provide complete, executable TypeScript code that fully implements the specification.
|
|
37
|
+
Include all necessary imports and type definitions.`,validate:`## Task: Validate Implementation
|
|
38
|
+
|
|
39
|
+
### Current Implementation:
|
|
40
|
+
\`\`\`typescript
|
|
41
|
+
${e.existingCode||`// No implementation provided`}
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
### Validation Criteria:
|
|
45
|
+
1. **Specification Compliance**: Does it match all requirements?
|
|
46
|
+
2. **Type Safety**: Are all types correct and complete?
|
|
47
|
+
3. **Error Handling**: Is error handling adequate?
|
|
48
|
+
4. **Code Quality**: Does it follow best practices?
|
|
49
|
+
5. **Completeness**: Are there missing features?
|
|
50
|
+
|
|
51
|
+
### Review Checklist:
|
|
52
|
+
- [ ] All specified inputs/outputs are handled
|
|
53
|
+
- [ ] Types match the specification exactly
|
|
54
|
+
- [ ] Error cases are properly handled
|
|
55
|
+
- [ ] Code is production-ready
|
|
56
|
+
- [ ] No obvious bugs or issues
|
|
57
|
+
- [ ] Performance is acceptable
|
|
58
|
+
- [ ] Code is maintainable
|
|
59
|
+
|
|
60
|
+
### Output Format:
|
|
61
|
+
Provide a detailed validation report with:
|
|
62
|
+
- **Status**: Pass/Fail
|
|
63
|
+
- **Issues Found**: List all problems
|
|
64
|
+
- **Recommendations**: Specific improvements needed
|
|
65
|
+
- **Code Quality Score**: Rate the implementation`,test:`## Task: Generate Tests
|
|
66
|
+
|
|
67
|
+
### Implementation to Test:
|
|
68
|
+
\`\`\`typescript
|
|
69
|
+
${e.existingCode||``}
|
|
70
|
+
\`\`\`
|
|
71
|
+
|
|
72
|
+
### Test Requirements:
|
|
73
|
+
1. **Coverage**: Test all code paths and edge cases
|
|
74
|
+
2. **Framework**: Use Vitest
|
|
75
|
+
3. **Structure**: Organize tests logically (describe/it blocks)
|
|
76
|
+
4. **Assertions**: Use clear, meaningful assertions
|
|
77
|
+
5. **Mocking**: Mock external dependencies appropriately
|
|
78
|
+
|
|
79
|
+
### Test Categories Needed:
|
|
80
|
+
- Unit tests for individual functions
|
|
81
|
+
- Integration tests for workflows
|
|
82
|
+
- Edge case tests
|
|
83
|
+
- Error handling tests
|
|
84
|
+
- Performance tests (if applicable)
|
|
85
|
+
|
|
86
|
+
### Output Format:
|
|
87
|
+
Complete Vitest test file with comprehensive test coverage.`,refactor:`## Task: Refactor Code
|
|
88
|
+
|
|
89
|
+
### Current Code:
|
|
90
|
+
\`\`\`typescript
|
|
91
|
+
${e.existingCode||``}
|
|
92
|
+
\`\`\`
|
|
93
|
+
|
|
94
|
+
### Refactoring Goals:
|
|
95
|
+
1. **Maintainability**: Improve code organization and readability
|
|
96
|
+
2. **Performance**: Optimize where beneficial
|
|
97
|
+
3. **Type Safety**: Enhance type definitions
|
|
98
|
+
4. **Error Handling**: Improve error handling robustness
|
|
99
|
+
5. **Documentation**: Add missing documentation
|
|
100
|
+
|
|
101
|
+
### Refactoring Guidelines:
|
|
102
|
+
- Preserve all existing functionality
|
|
103
|
+
- Extract reusable components
|
|
104
|
+
- Eliminate code duplication
|
|
105
|
+
- Improve naming and structure
|
|
106
|
+
- Add type guards where beneficial
|
|
107
|
+
- Enhance error messages
|
|
108
|
+
|
|
109
|
+
### Output Format:
|
|
110
|
+
Refactored code that maintains functionality while improving quality.`};return t+n+(r[e.type]||r.generate)}buildValidationPrompt(e){return`# Implementation Validation Report
|
|
111
|
+
|
|
112
|
+
## Specification
|
|
113
|
+
\`\`\`typescript
|
|
114
|
+
${e.specCode}
|
|
115
|
+
\`\`\`
|
|
116
|
+
|
|
117
|
+
## Implementation
|
|
118
|
+
\`\`\`typescript
|
|
119
|
+
${e.existingCode||`// No implementation`}
|
|
120
|
+
\`\`\`
|
|
121
|
+
|
|
122
|
+
## Validation Checklist
|
|
123
|
+
|
|
124
|
+
### 1. Specification Compliance
|
|
125
|
+
- [ ] All required features implemented
|
|
126
|
+
- [ ] Input/output types match specification
|
|
127
|
+
- [ ] Behavior matches documented requirements
|
|
128
|
+
|
|
129
|
+
### 2. Code Quality
|
|
130
|
+
- [ ] Follows TypeScript best practices
|
|
131
|
+
- [ ] Proper error handling
|
|
132
|
+
- [ ] Meaningful variable names
|
|
133
|
+
- [ ] Appropriate code organization
|
|
134
|
+
|
|
135
|
+
### 3. Type Safety
|
|
136
|
+
- [ ] No type assertions (as) unless necessary
|
|
137
|
+
- [ ] Proper generic usage
|
|
138
|
+
- [ ] Complete type coverage
|
|
139
|
+
|
|
140
|
+
### 4. Production Readiness
|
|
141
|
+
- [ ] No console.log statements
|
|
142
|
+
- [ ] Proper error handling
|
|
143
|
+
- [ ] Edge cases covered
|
|
144
|
+
- [ ] Performance considerations
|
|
145
|
+
|
|
146
|
+
### 5. Maintainability
|
|
147
|
+
- [ ] Clear documentation
|
|
148
|
+
- [ ] Testable code structure
|
|
149
|
+
- [ ] No code smells
|
|
150
|
+
- [ ] SOLID principles followed
|
|
151
|
+
|
|
152
|
+
## Instructions
|
|
153
|
+
Review the implementation against the specification and complete the checklist.
|
|
154
|
+
Provide detailed feedback for each failed item.
|
|
155
|
+
Suggest specific improvements with code examples where applicable.`}generateTemplate(e){return`// Auto-generated template for ${e.type} task
|
|
156
|
+
// Specification:
|
|
157
|
+
${e.specCode.split(`
|
|
158
|
+
`).map(e=>`// ${e}`).join(`
|
|
159
|
+
`)}
|
|
160
|
+
|
|
161
|
+
// TODO: Implement according to specification
|
|
162
|
+
// Use Cursor AI to complete this implementation
|
|
163
|
+
|
|
164
|
+
export function implementation() {
|
|
165
|
+
// Implementation goes here
|
|
166
|
+
throw new Error('Not implemented');
|
|
167
|
+
}
|
|
168
|
+
`}async cleanupWorkDir(e){try{await i(e,{recursive:!0,force:!0})}catch{}}isCursorAvailable(){return this.isWindsurf||this.cursorPath!==null||this.hasComposerAPI()}hasComposerAPI(){return!!(process.env.CURSOR_COMPOSER_PORT||process.env.CURSOR_API_ENABLED||this.isWindsurf)}};export{d as CursorAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SimpleAgent as e}from"./simple-agent.js";import{CursorAgent as t}from"./cursor-agent.js";import{ClaudeCodeAgent as n}from"./claude-code-agent.js";import{OpenAICodexAgent as r}from"./openai-codex-agent.js";import{AgentOrchestrator as i}from"./orchestrator.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import{openai as e}from"@ai-sdk/openai";import{generateText as t}from"ai";var n=class{name=`openai-codex`;apiKey;constructor(){this.apiKey=process.env.OPENAI_API_KEY}canHandle(e){return!!this.apiKey}async generate(n){if(!this.apiKey)return{success:!1,errors:[`OPENAI_API_KEY not set. OpenAI Codex agent requires API access.`]};try{let r=this.isComplexTask(n)?`o1`:`gpt-4o`,i=e(r),a=this.buildSystemPrompt(n),o=await t({model:i,prompt:this.buildUserPrompt(n),system:a,temperature:.2});return{success:!0,code:this.extractCode(o.text),metadata:{model:r,agentMode:`openai-codex`,usage:o.usage}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}async validate(n){if(!this.apiKey)return{success:!1,errors:[`OPENAI_API_KEY not set`]};try{let r=await t({model:e(`gpt-4o`),prompt:`
|
|
2
|
+
Review this code implementation against its specification.
|
|
3
|
+
|
|
4
|
+
SPECIFICATION:
|
|
5
|
+
\`\`\`typescript
|
|
6
|
+
${n.specCode}
|
|
7
|
+
\`\`\`
|
|
8
|
+
|
|
9
|
+
IMPLEMENTATION:
|
|
10
|
+
\`\`\`typescript
|
|
11
|
+
${n.existingCode||`// No implementation`}
|
|
12
|
+
\`\`\`
|
|
13
|
+
|
|
14
|
+
Provide a detailed validation report including:
|
|
15
|
+
1. Specification compliance
|
|
16
|
+
2. Code quality assessment
|
|
17
|
+
3. Potential bugs or issues
|
|
18
|
+
4. Recommendations for improvement
|
|
19
|
+
|
|
20
|
+
Format as a structured report.
|
|
21
|
+
`,system:`You are a senior software engineer performing thorough code review.`,temperature:.3}),i=this.detectIssues(r.text);return{success:!i,code:r.text,errors:i?this.extractErrors(r.text):[],warnings:this.extractWarnings(r.text),metadata:{agentMode:`openai-codex`,validationType:`ai-review`}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}isComplexTask(e){let t=[`algorithm`,`optimization`,`complex logic`,`state management`,`concurrent`,`distributed`],n=(e.specCode+(e.existingCode||``)).toLowerCase();return t.some(e=>n.includes(e))}buildSystemPrompt(e){let t=`You are an expert TypeScript/JavaScript developer.
|
|
22
|
+
|
|
23
|
+
Generate production-quality code that is:
|
|
24
|
+
- Type-safe and well-typed
|
|
25
|
+
- Documented with clear comments
|
|
26
|
+
- Following best practices and SOLID principles
|
|
27
|
+
- Properly handling errors and edge cases
|
|
28
|
+
- Testable and maintainable
|
|
29
|
+
|
|
30
|
+
Output only the code without explanations unless specifically asked.`;return e.type===`test`?t+`
|
|
31
|
+
|
|
32
|
+
Generate comprehensive test suites using Vitest.`:t}buildUserPrompt(e){switch(e.type){case`generate`:return`Implement this specification:\n\n${e.specCode}\n\nProvide complete, production-ready TypeScript code.`;case`test`:return`Create comprehensive tests:\n\nSpec:\n${e.specCode}\n\nImplementation:\n${e.existingCode}\n\nGenerate complete Vitest test suite.`;case`refactor`:return`Refactor this code while maintaining functionality:\n\n${e.existingCode}\n\nSpec:\n${e.specCode}`;default:return e.specCode}}extractCode(e){let t=e.match(/```(?:typescript|ts|tsx|javascript|js)?\n([\s\S]*?)\n```/);return t&&t[1]?t[1]:e}detectIssues(e){let t=[`issue`,`problem`,`bug`,`error`,`incorrect`,`missing`,`fails`,`violation`],n=e.toLowerCase();return t.some(e=>n.includes(e))}extractErrors(e){let t=[],n=e.split(`
|
|
33
|
+
`);for(let e of n)(e.toLowerCase().includes(`error`)||e.toLowerCase().includes(`bug`)||e.toLowerCase().includes(`fails`))&&t.push(e.trim());return t}extractWarnings(e){let t=[],n=e.split(`
|
|
34
|
+
`);for(let e of n)(e.toLowerCase().includes(`warning`)||e.toLowerCase().includes(`should`)||e.toLowerCase().includes(`consider`))&&t.push(e.trim());return t}};export{n as OpenAICodexAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SimpleAgent as e}from"./simple-agent.js";import{CursorAgent as t}from"./cursor-agent.js";import{ClaudeCodeAgent as n}from"./claude-code-agent.js";import{OpenAICodexAgent as r}from"./openai-codex-agent.js";import i from"../../node_modules/chalk/source/index.js";import a from"../../node_modules/ora/index.js";var o=class{agents;defaultAgent;constructor(i){this.config=i,this.agents=new Map;let a=new e(i),o=new t,s=new n,c=new r;this.agents.set(`simple`,a),this.agents.set(`cursor`,o),this.agents.set(`claude-code`,s),this.agents.set(`openai-codex`,c),this.defaultAgent=a}async executeTask(e){let t=this.getAgentMode(),n=this.agents.get(t);if(!n)return console.log(i.yellow(`⚠️ Agent '${t}' not found, using simple agent`)),this.defaultAgent.generate(e);if(!n.canHandle(e))return console.log(i.yellow(`⚠️ Agent '${t}' cannot handle this task, falling back to simple agent`)),this.defaultAgent.generate(e);let r=a(`Executing with ${t} agent...`).start();try{let a=e.type===`validate`?await n.validate(e):await n.generate(e);if(a.success)return r.succeed(i.green(`${t} agent completed successfully`)),a;r.warn(i.yellow(`${t} agent failed, trying fallback...`));let o=this.getFallbackMode(t);if(o&&o!==t){let t=this.agents.get(o);if(t&&t.canHandle(e))return e.type===`validate`?await t.validate(e):await t.generate(e)}return r.info(i.gray(`Using simple agent as ultimate fallback`)),e.type===`validate`?await this.defaultAgent.validate(e):await this.defaultAgent.generate(e)}catch{return r.fail(i.red(`Agent execution failed`)),console.log(i.gray(`Falling back to simple agent...`)),e.type===`validate`?await this.defaultAgent.validate(e):await this.defaultAgent.generate(e)}}async generate(e,t){return this.executeTask({type:`generate`,specCode:e,targetPath:t})}async generateTests(e,t){return this.executeTask({type:`test`,specCode:e,existingCode:t})}async validate(e,t){return this.executeTask({type:`validate`,specCode:e,existingCode:t})}async refactor(e,t){return this.executeTask({type:`refactor`,specCode:e,existingCode:t})}async getAvailableAgents(){let e=[];for(let[t,n]of this.agents){let r=n.canHandle({type:`generate`,specCode:`test`});e.push({mode:t,available:r,reason:r?void 0:`Not configured or dependencies missing`})}return e}getAgentMode(){return this.config.agentMode||`simple`}getFallbackMode(e){return{cursor:`claude-code`,"claude-code":`openai-codex`,"openai-codex":`simple`,simple:`simple`}[e]}};export{o as AgentOrchestrator};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{getAIProvider as e}from"../providers.js";import{buildComponentPrompt as t,buildFormPrompt as n,buildHandlerPrompt as r,buildTestPrompt as i,getCodeGenSystemPrompt as a}from"../prompts/code-generation.js";import{generateText as o}from"ai";var s=class{name=`simple`;constructor(e){this.config=e}canHandle(e){return!0}async generate(t){try{let n=await o({model:e(this.config),prompt:this.buildPrompt(t),system:a()});return{success:!0,code:n.text,metadata:{model:this.config.aiModel,provider:this.config.aiProvider,tokens:n.usage}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}async validate(t){try{let n=await o({model:e(this.config),prompt:`
|
|
2
|
+
Review the following implementation against its specification.
|
|
3
|
+
|
|
4
|
+
Specification:
|
|
5
|
+
${t.specCode}
|
|
6
|
+
|
|
7
|
+
Implementation:
|
|
8
|
+
${t.existingCode||`// No implementation provided`}
|
|
9
|
+
|
|
10
|
+
Provide a detailed validation report:
|
|
11
|
+
1. Does the implementation match the spec?
|
|
12
|
+
2. Are there any missing features?
|
|
13
|
+
3. Are there any bugs or issues?
|
|
14
|
+
4. Suggestions for improvement
|
|
15
|
+
`,system:`You are a code review expert. Provide thorough, constructive feedback.`}),r=n.text.toLowerCase().includes(`error`)||n.text.toLowerCase().includes(`missing`)||n.text.toLowerCase().includes(`incorrect`);return{success:!r,code:n.text,warnings:r?[`Implementation may not match specification`]:[],metadata:{validationType:`simple-llm`}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}buildPrompt(e){switch(e.type){case`generate`:return e.specCode.includes(`.contracts.`)||e.specCode.includes(`kind:`)?r(e.specCode):e.specCode.includes(`.presentation.`)?t(e.specCode):e.specCode.includes(`.form.`)?n(e.specCode):`Generate implementation for:\n${e.specCode}`;case`test`:return i(e.specCode,e.existingCode||``,`handler`);case`validate`:return`Validate this implementation:\n${e.existingCode}`;default:return e.specCode}}};export{s as SimpleAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getAIProvider as e}from"./providers.js";import{buildEventSpecPrompt as t,buildOperationSpecPrompt as n,buildPresentationSpecPrompt as r,getSystemPrompt as i}from"./prompts/spec-creation.js";import{buildComponentPrompt as a,buildFormPrompt as o,buildHandlerPrompt as s,buildTestPrompt as c,getCodeGenSystemPrompt as l}from"./prompts/code-generation.js";import{generateObject as u,generateText as d,streamText as f}from"ai";import*as p from"zod";var m=class{constructor(e){this.config=e}async generateOperationSpec(t,r){return(await u({model:e(this.config),schema:p.object({name:p.string().describe(`Dot notation name like "domain.operation"`),version:p.number().int().positive().default(1),description:p.string().describe(`Clear, concise summary`),goal:p.string().describe(`Business purpose`),context:p.string().describe(`Background and constraints`),stability:p.enum([`experimental`,`beta`,`stable`,`deprecated`]).default(`beta`),owners:p.array(p.string()).describe(`Team/person owners with @ prefix`),tags:p.array(p.string()).describe(`Categorization tags`),auth:p.enum([`anonymous`,`user`,`admin`]).describe(`Required auth level`),inputShape:p.string().describe(`Description of input structure`),outputShape:p.string().describe(`Description of output structure`),flags:p.array(p.string()).describe(`Feature flags`).default([]),possibleEvents:p.array(p.string()).describe(`Events this may emit`).default([]),analytics:p.array(p.string()).describe(`Analytics events to track`).default([])}),prompt:n(t,r),system:i()})).object}async generateEventSpec(n){return(await u({model:e(this.config),schema:p.object({name:p.string().describe(`Dot notation name like "domain.event_name"`),version:p.number().int().positive().default(1),description:p.string().describe(`When this event is emitted`),stability:p.enum([`experimental`,`beta`,`stable`,`deprecated`]).default(`beta`),owners:p.array(p.string()).default([]),tags:p.array(p.string()).default([]),payloadShape:p.string().describe(`Description of event payload`),piiFields:p.array(p.string()).describe(`PII field paths`).default([])}),prompt:t(n),system:i()})).object}async generatePresentationSpec(t,n){return(await u({model:e(this.config),schema:p.object({name:p.string(),version:p.number().int().positive().default(1),description:p.string(),stability:p.enum([`experimental`,`beta`,`stable`,`deprecated`]).default(`beta`),owners:p.array(p.string()).default([]),tags:p.array(p.string()).default([]),componentKey:p.string().optional(),propsShape:p.string().optional(),content:p.string().optional(),mimeType:p.string().optional(),dataShape:p.string().optional()}),prompt:r(t,n),system:i()})).object}async generateHandler(t){return(await d({model:e(this.config),prompt:s(t),system:l()})).text}async generateComponent(t){return(await d({model:e(this.config),prompt:a(t),system:l()})).text}async generateForm(t){return(await d({model:e(this.config),prompt:o(t),system:l()})).text}async generateTests(t,n,r){return(await d({model:e(this.config),prompt:c(t,n,r),system:l()})).text}async streamCodeGeneration(t,n){let r=await f({model:e(this.config),prompt:t,system:l()}),i=``;for await(let e of r.textStream)i+=e,n(e);return i}};export{m as AIClient};
|
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__export as e}from"../_virtual/rolldown_runtime.js";import{getAIProvider as t,getRecommendedModels as n,validateProvider as r}from"./providers.js";import{AIClient as i}from"./client.js";import{SimpleAgent as a}from"./agents/simple-agent.js";import{CursorAgent as o}from"./agents/cursor-agent.js";import{ClaudeCodeAgent as s}from"./agents/claude-code-agent.js";import{OpenAICodexAgent as c}from"./agents/openai-codex-agent.js";import{AgentOrchestrator as l}from"./agents/orchestrator.js";import"./agents/index.js";import{prompts_exports as u}from"./prompts/index.js";var d=e({AIClient:()=>i,AgentOrchestrator:()=>l,ClaudeCodeAgent:()=>s,CursorAgent:()=>o,OpenAICodexAgent:()=>c,SimpleAgent:()=>a,getAIProvider:()=>t,getRecommendedModels:()=>n,prompts:()=>u,validateProvider:()=>r});export{d as ai_exports};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import{__export as e}from"../../_virtual/rolldown_runtime.js";var t=e({buildComponentPrompt:()=>r,buildFormPrompt:()=>i,buildHandlerPrompt:()=>n,buildTestPrompt:()=>a,getCodeGenSystemPrompt:()=>o});function n(e){return`You are a senior TypeScript developer implementing a handler for a contract specification.
|
|
2
|
+
|
|
3
|
+
Here is the contract spec:
|
|
4
|
+
|
|
5
|
+
\`\`\`typescript
|
|
6
|
+
${e}
|
|
7
|
+
\`\`\`
|
|
8
|
+
|
|
9
|
+
Generate a complete handler implementation that:
|
|
10
|
+
|
|
11
|
+
1. **Matches the spec signature**: Input/output types from the spec
|
|
12
|
+
2. **Handles errors**: Implement error cases defined in spec.io.errors
|
|
13
|
+
3. **Emits events**: Use the events declared in spec.sideEffects.emits
|
|
14
|
+
4. **Validates input**: Use zod validation from the schema
|
|
15
|
+
5. **Follows best practices**: Clean, type-safe TypeScript
|
|
16
|
+
6. **Includes comments**: Explain business logic
|
|
17
|
+
|
|
18
|
+
The handler should be production-ready with proper error handling, logging points, and clear structure.
|
|
19
|
+
|
|
20
|
+
Return only the TypeScript code for the handler function.`}function r(e){return`You are a senior React developer creating a component for a presentation specification.
|
|
21
|
+
|
|
22
|
+
Here is the presentation spec:
|
|
23
|
+
|
|
24
|
+
\`\`\`typescript
|
|
25
|
+
${e}
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
Generate a complete React component that:
|
|
29
|
+
|
|
30
|
+
1. **Props interface**: Typed props from the spec
|
|
31
|
+
2. **Accessibility**: Proper ARIA labels, roles, keyboard navigation
|
|
32
|
+
3. **Mobile-first**: Optimized for small screens and touch
|
|
33
|
+
4. **Clean UI**: Simple, intuitive interface
|
|
34
|
+
5. **Type-safe**: Full TypeScript with no 'any' types
|
|
35
|
+
6. **Best practices**: React hooks, proper state management
|
|
36
|
+
|
|
37
|
+
The component should follow Atomic Design principles and be reusable.
|
|
38
|
+
|
|
39
|
+
Return only the TypeScript/TSX code for the component.`}function i(e){return`You are a senior React developer creating a form component from a form specification.
|
|
40
|
+
|
|
41
|
+
Here is the form spec:
|
|
42
|
+
|
|
43
|
+
\`\`\`typescript
|
|
44
|
+
${e}
|
|
45
|
+
\`\`\`
|
|
46
|
+
|
|
47
|
+
Generate a complete form component using react-hook-form that:
|
|
48
|
+
|
|
49
|
+
1. **Form validation**: Use zod schema for validation
|
|
50
|
+
2. **Field types**: Proper inputs for each field type
|
|
51
|
+
3. **Conditional logic**: Support visibleWhen, enabledWhen, requiredWhen predicates
|
|
52
|
+
4. **Error handling**: Clear, user-friendly error messages
|
|
53
|
+
5. **Accessibility**: Labels, hints, ARIA attributes
|
|
54
|
+
6. **Mobile-optimized**: Touch-friendly, appropriate input types
|
|
55
|
+
7. **Type-safe**: Full TypeScript
|
|
56
|
+
|
|
57
|
+
The form should provide excellent UX with real-time validation and helpful feedback.
|
|
58
|
+
|
|
59
|
+
Return only the TypeScript/TSX code for the form component.`}function a(e,t,n){return`You are a senior developer writing comprehensive tests.
|
|
60
|
+
|
|
61
|
+
Spec:
|
|
62
|
+
\`\`\`typescript
|
|
63
|
+
${e}
|
|
64
|
+
\`\`\`
|
|
65
|
+
|
|
66
|
+
Implementation:
|
|
67
|
+
\`\`\`typescript
|
|
68
|
+
${t}
|
|
69
|
+
\`\`\`
|
|
70
|
+
|
|
71
|
+
Generate complete test suite using Vitest that:
|
|
72
|
+
${n===`handler`?`
|
|
73
|
+
- Test all acceptance scenarios from the spec
|
|
74
|
+
- Test error cases defined in spec.io.errors
|
|
75
|
+
- Verify events are emitted correctly
|
|
76
|
+
- Test input validation
|
|
77
|
+
- Test happy path and edge cases`:`
|
|
78
|
+
- Test rendering with various props
|
|
79
|
+
- Test user interactions
|
|
80
|
+
- Test accessibility (a11y)
|
|
81
|
+
- Test responsive behavior
|
|
82
|
+
- Test error states`}
|
|
83
|
+
|
|
84
|
+
Use clear test descriptions and follow AAA pattern (Arrange, Act, Assert).
|
|
85
|
+
|
|
86
|
+
Return only the TypeScript test code.`}function o(){return`You are an expert TypeScript developer with deep knowledge of:
|
|
87
|
+
- Type-safe API design
|
|
88
|
+
- React and modern hooks
|
|
89
|
+
- Test-driven development
|
|
90
|
+
- Accessibility best practices
|
|
91
|
+
- Clean code principles
|
|
92
|
+
|
|
93
|
+
Generate production-ready code that is:
|
|
94
|
+
- Fully typed (no 'any' or type assertions unless absolutely necessary)
|
|
95
|
+
- Well-documented with TSDoc comments
|
|
96
|
+
- Following project conventions
|
|
97
|
+
- Defensive and error-safe
|
|
98
|
+
- Easy to maintain and extend
|
|
99
|
+
|
|
100
|
+
Always prioritize code quality, safety, and user experience.`}export{r as buildComponentPrompt,i as buildFormPrompt,n as buildHandlerPrompt,a as buildTestPrompt,t as code_generation_exports,o as getCodeGenSystemPrompt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__export as e}from"../../_virtual/rolldown_runtime.js";import{spec_creation_exports as t}from"./spec-creation.js";import{code_generation_exports as n}from"./code-generation.js";var r=e({codeGeneration:()=>n,specCreation:()=>t});export{r as prompts_exports};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import{__export as e}from"../../_virtual/rolldown_runtime.js";var t=e({addExampleContext:()=>o,buildEventSpecPrompt:()=>r,buildOperationSpecPrompt:()=>n,buildPresentationSpecPrompt:()=>i,getSystemPrompt:()=>a});function n(e,t){return`You are a senior software architect creating a contract specification for an operation.
|
|
2
|
+
|
|
3
|
+
The operation is a ${t} (${t===`command`?`changes state, has side effects`:`read-only, idempotent`}).
|
|
4
|
+
|
|
5
|
+
User description: ${e}
|
|
6
|
+
|
|
7
|
+
Create a complete contract specification following these guidelines:
|
|
8
|
+
|
|
9
|
+
1. **Name**: Use dot notation like "domain.operationName" (e.g., "user.signup", "payment.charge")
|
|
10
|
+
2. **Version**: Start at 1
|
|
11
|
+
3. **Description**: Clear, concise summary (1-2 sentences)
|
|
12
|
+
4. **Goal**: Business purpose - why this operation exists
|
|
13
|
+
5. **Context**: Background, constraints, scope (what it does and doesn't do)
|
|
14
|
+
6. **Input/Output**: Describe the shape (we'll create schemas separately)
|
|
15
|
+
7. **Auth**: Who can call this - anonymous, user, or admin
|
|
16
|
+
8. **Feature Flags**: Any flags that gate this operation
|
|
17
|
+
9. **Side Effects**: What events might be emitted, analytics to track
|
|
18
|
+
|
|
19
|
+
Respond with a structured spec.`}function r(e){return`You are a senior software architect creating an event specification.
|
|
20
|
+
|
|
21
|
+
User description: ${e}
|
|
22
|
+
|
|
23
|
+
Create a complete event specification following these guidelines:
|
|
24
|
+
|
|
25
|
+
1. **Name**: Use dot notation like "domain.event_name" (e.g., "user.signup_completed", "payment.charged")
|
|
26
|
+
2. **Version**: Start at 1
|
|
27
|
+
3. **Description**: Clear description of when this event is emitted
|
|
28
|
+
4. **Payload**: Describe what data the event carries
|
|
29
|
+
5. **PII Fields**: List any personally identifiable information fields (e.g., ["email", "name"])
|
|
30
|
+
|
|
31
|
+
Events represent things that have already happened and should use past tense.
|
|
32
|
+
|
|
33
|
+
Respond with a structured spec.`}function i(e,t){return`You are a senior software architect creating a presentation specification.
|
|
34
|
+
|
|
35
|
+
This is a ${t} presentation - ${{web_component:`a React component with props schema`,markdown:`markdown/MDX documentation or guide`,data:`structured data export (JSON/XML)`}[t]}.
|
|
36
|
+
|
|
37
|
+
User description: ${e}
|
|
38
|
+
|
|
39
|
+
Create a complete presentation specification following these guidelines:
|
|
40
|
+
|
|
41
|
+
1. **Name**: Use dot notation like "domain.presentation_name" (e.g., "user.profile_card", "docs.api_guide")
|
|
42
|
+
2. **Version**: Start at 1
|
|
43
|
+
3. **Description**: What this presentation shows/provides
|
|
44
|
+
4. **Kind-specific details**:
|
|
45
|
+
${t===`web_component`?`- Component key (symbolic, resolved by host app)
|
|
46
|
+
- Props structure
|
|
47
|
+
- Analytics events to track`:t===`markdown`?`- Content or resource URI
|
|
48
|
+
- Target audience`:`- MIME type (e.g., application/json)
|
|
49
|
+
- Data structure description`}
|
|
50
|
+
|
|
51
|
+
Respond with a structured spec.`}function a(){return`You are an expert software architect specializing in API design and contract-driven development.
|
|
52
|
+
|
|
53
|
+
You create clear, well-documented specifications that serve as the single source of truth for operations, events, and presentations.
|
|
54
|
+
|
|
55
|
+
Your specs are:
|
|
56
|
+
- Precise and unambiguous
|
|
57
|
+
- Following TypeScript conventions
|
|
58
|
+
- Business-oriented (capturing the "why" not just "what")
|
|
59
|
+
- Designed for both humans and AI agents to understand
|
|
60
|
+
|
|
61
|
+
Always use proper dot notation for names and ensure all metadata is meaningful and accurate.`}function o(e,t){return t.length===0?e:`${e}
|
|
62
|
+
|
|
63
|
+
Here are some good examples for reference:
|
|
64
|
+
|
|
65
|
+
${t.join(`
|
|
66
|
+
|
|
67
|
+
`)}
|
|
68
|
+
|
|
69
|
+
Follow this structure and quality level.`}export{r as buildEventSpecPrompt,n as buildOperationSpecPrompt,i as buildPresentationSpecPrompt,a as getSystemPrompt,t as spec_creation_exports};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{anthropic as e}from"@ai-sdk/anthropic";import{openai as t}from"@ai-sdk/openai";import{ollama as n}from"ollama-ai-provider";function r(r){let{aiProvider:i,aiModel:a,customEndpoint:o}=r;switch(i){case`claude`:return e(a||`claude-3-5-sonnet-20241022`);case`openai`:return t(a||`gpt-4o`);case`ollama`:return n(a||`codellama`);case`custom`:if(!o)throw Error(`Custom endpoint required. Set customEndpoint in .contractsrc.json or CONTRACTSPEC_LLM_ENDPOINT env var`);return t(a||`default`);default:throw Error(`Unknown AI provider: ${i}`)}}async function i(e){try{let{aiProvider:t}=e;return t===`ollama`?{success:!0}:t===`claude`&&!process.env.ANTHROPIC_API_KEY?{success:!1,error:`ANTHROPIC_API_KEY environment variable not set`}:t===`openai`&&!process.env.OPENAI_API_KEY?{success:!1,error:`OPENAI_API_KEY environment variable not set`}:{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}function a(e){switch(e){case`claude`:return[`claude-3-5-sonnet-20241022`,`claude-3-opus-20240229`,`claude-3-sonnet-20240229`];case`openai`:return[`gpt-4o`,`gpt-4-turbo`,`gpt-3.5-turbo`];case`ollama`:return[`codellama`,`llama3.1`,`mistral`,`deepseek-coder`];case`custom`:return[];default:return[]}}export{r as getAIProvider,a as getRecommendedModels,i as validateProvider};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createNodeFsAdapter as e}from"./adapters/fs.js";import{createNodeGitAdapter as t}from"./adapters/git.js";import{createNodeWatcherAdapter as n}from"./adapters/watcher.js";import{createNodeAiAdapter as r}from"./adapters/ai.js";import{createConsoleLoggerAdapter as i,createNoopLoggerAdapter as a}from"./adapters/logger.js";import{createNodeAdapters as o}from"./adapters/factory.js";import"./adapters/index.js";import{validateSpec as s,validateSpecs as c}from"./services/validate.js";import{validateImplementationFiles as l}from"./services/validate-implementation.js";import{compareSpecs as u}from"./services/diff.js";import{analyzeDeps as d,exportGraphAsDot as f,getContractNode as p,getGraphStats as m}from"./services/deps.js";import{groupSpecsByType as h,listSpecs as g}from"./services/list.js";import{getApiKey as _,loadWorkspaceConfig as v,mergeWorkspaceConfig as y}from"./services/config.js";import{buildSpec as b}from"./services/build.js";import{
|
|
1
|
+
import{createNodeFsAdapter as e}from"./adapters/fs.js";import{createNodeGitAdapter as t}from"./adapters/git.js";import{createNodeWatcherAdapter as n}from"./adapters/watcher.js";import{createNodeAiAdapter as r}from"./adapters/ai.js";import{createConsoleLoggerAdapter as i,createNoopLoggerAdapter as a}from"./adapters/logger.js";import{createNodeAdapters as o}from"./adapters/factory.js";import"./adapters/index.js";import{validateSpec as s,validateSpecs as c}from"./services/validate.js";import{validateImplementationFiles as l}from"./services/validate-implementation.js";import{compareSpecs as u}from"./services/diff.js";import{analyzeDeps as d,exportGraphAsDot as f,getContractNode as p,getGraphStats as m}from"./services/deps.js";import{groupSpecsByType as h,listSpecs as g}from"./services/list.js";import{getApiKey as _,loadWorkspaceConfig as v,mergeWorkspaceConfig as y}from"./services/config.js";import{buildSpec as b}from"./services/build.js";import{exportOpenApi as x}from"./services/openapi.js";import{RegistryClient as S,addToRegistry as C,listFromRegistry as w,resolveRegistryUrl as T,searchRegistry as E}from"./services/registry.js";import{syncSpecs as D}from"./services/sync.js";import{watchSpecs as O}from"./services/watch.js";import{cleanArtifacts as k}from"./services/clean.js";import{runTests as A}from"./services/test.js";import{createRegeneratorService as j}from"./services/regenerator.js";import"./services/index.js";import{templates_exports as M}from"./templates/index.js";import{ai_exports as N}from"./ai/index.js";export*from"@lssm/module.contractspec-workspace";export{S as RegistryClient,C as addToRegistry,N as ai,d as analyzeDeps,b as buildSpec,k as cleanArtifacts,u as compareSpecs,i as createConsoleLoggerAdapter,o as createNodeAdapters,r as createNodeAiAdapter,e as createNodeFsAdapter,t as createNodeGitAdapter,n as createNodeWatcherAdapter,a as createNoopLoggerAdapter,j as createRegeneratorService,f as exportGraphAsDot,x as exportOpenApi,_ as getApiKey,p as getContractNode,m as getGraphStats,h as groupSpecsByType,w as listFromRegistry,g as listSpecs,v as loadWorkspaceConfig,y as mergeWorkspaceConfig,T as resolveRegistryUrl,A as runTests,E as searchRegistry,D as syncSpecs,M as templates,l as validateImplementationFiles,s as validateSpec,c as validateSpecs,O as watchSpecs};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e,{backgroundColorNames as t,foregroundColorNames as n}from"./vendor/ansi-styles/index.js";import r from"./vendor/supports-color/browser.js";import{stringEncaseCRLFWithFirstIndex as i,stringReplaceAll as a}from"./utilities.js";const{stdout:o,stderr:s}=r,c=Symbol(`GENERATOR`),l=Symbol(`STYLER`),u=Symbol(`IS_EMPTY`),d=[`ansi`,`ansi`,`ansi256`,`ansi16m`],f=Object.create(null),p=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=o?o.level:0;e.level=t.level===void 0?n:t.level},m=e=>{let t=(...e)=>e.join(` `);return p(t,e),Object.setPrototypeOf(t,h.prototype),t};function h(e){return m(e)}Object.setPrototypeOf(h.prototype,Function.prototype);for(let[t,n]of Object.entries(e))f[t]={get(){let e=y(this,v(n.open,n.close,this[l]),this[u]);return Object.defineProperty(this,t,{value:e}),e}};f.visible={get(){let e=y(this,this[l],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const g=(t,n,r,...i)=>t===`rgb`?n===`ansi16m`?e[r].ansi16m(...i):n===`ansi256`?e[r].ansi256(e.rgbToAnsi256(...i)):e[r].ansi(e.rgbToAnsi(...i)):t===`hex`?g(`rgb`,n,r,...e.hexToRgb(...i)):e[r][t](...i);for(let t of[`rgb`,`hex`,`ansi256`]){f[t]={get(){let{level:n}=this;return function(...r){let i=v(g(t,d[n],`color`,...r),e.color.close,this[l]);return y(this,i,this[u])}}};let n=`bg`+t[0].toUpperCase()+t.slice(1);f[n]={get(){let{level:n}=this;return function(...r){let i=v(g(t,d[n],`bgColor`,...r),e.bgColor.close,this[l]);return y(this,i,this[u])}}}}const _=Object.defineProperties(()=>{},{...f,level:{enumerable:!0,get(){return this[c].level},set(e){this[c].level=e}}}),v=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},y=(e,t,n)=>{let r=(...e)=>b(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,_),r[c]=e,r[l]=t,r[u]=n,r},b=(e,t)=>{if(e.level<=0||!t)return e[u]?``:t;let n=e[l];if(n===void 0)return t;let{openAll:r,closeAll:o}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=a(t,n.close,n.open),n=n.parent;let s=t.indexOf(`
|
|
2
|
+
`);return s!==-1&&(t=i(t,o,r,s)),r+t+o};Object.defineProperties(h.prototype,f);const x=h();h({level:s?s.level:0});var S=x;export{S as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
function e(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function t(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
2
|
+
`:`
|
|
3
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
4
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}export{t as stringEncaseCRLFWithFirstIndex,e as stringReplaceAll};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e=0)=>t=>`\u001B[${t+e}m`,t=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,n=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,r={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(r.modifier);const i=Object.keys(r.color),a=Object.keys(r.bgColor);[...i,...a];function o(){let i=new Map;for(let[e,t]of Object.entries(r)){for(let[e,n]of Object.entries(t))r[e]={open:`\u001B[${n[0]}m`,close:`\u001B[${n[1]}m`},t[e]=r[e],i.set(n[0],n[1]);Object.defineProperty(r,e,{value:t,enumerable:!1})}return Object.defineProperty(r,`codes`,{value:i,enumerable:!1}),r.color.close=`\x1B[39m`,r.bgColor.close=`\x1B[49m`,r.color.ansi=e(),r.color.ansi256=t(),r.color.ansi16m=n(),r.bgColor.ansi=e(10),r.bgColor.ansi256=t(10),r.bgColor.ansi16m=n(10),Object.defineProperties(r,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>r.rgbToAnsi256(...r.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>r.ansi256ToAnsi(r.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>r.ansi256ToAnsi(r.hexToAnsi256(e)),enumerable:!1}}),r}var s=o();export{a as backgroundColorNames,s as default,i as foregroundColorNames};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(()=>{if(!(`navigator`in globalThis))return 0;if(globalThis.navigator.userAgentData){let e=navigator.userAgentData.brands.find(({brand:e})=>e===`Chromium`);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),t=e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3};var n={stdout:t,stderr:t};export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../restore-cursor/index.js";import t from"node:process";let n=!1;const r={};r.show=(e=t.stderr)=>{e.isTTY&&(n=!1,e.write(`\x1B[?25h`))},r.hide=(r=t.stderr)=>{r.isTTY&&(e(),n=!0,r.write(`\x1B[?25l`))},r.toggle=(e,t)=>{e!==void 0&&(n=e),n?r.show(t):r.hide(t)};var i=r;export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./spinners.js";var t=e;export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={dots:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]},dots2:{interval:80,frames:[`⣾`,`⣽`,`⣻`,`⢿`,`⡿`,`⣟`,`⣯`,`⣷`]},dots3:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠞`,`⠖`,`⠦`,`⠴`,`⠲`,`⠳`,`⠓`]},dots4:{interval:80,frames:[`⠄`,`⠆`,`⠇`,`⠋`,`⠙`,`⠸`,`⠰`,`⠠`,`⠰`,`⠸`,`⠙`,`⠋`,`⠇`,`⠆`]},dots5:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`]},dots6:{interval:80,frames:[`⠁`,`⠉`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠤`,`⠄`,`⠄`,`⠤`,`⠴`,`⠲`,`⠒`,`⠂`,`⠂`,`⠒`,`⠚`,`⠙`,`⠉`,`⠁`]},dots7:{interval:80,frames:[`⠈`,`⠉`,`⠋`,`⠓`,`⠒`,`⠐`,`⠐`,`⠒`,`⠖`,`⠦`,`⠤`,`⠠`,`⠠`,`⠤`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`,`⠉`,`⠈`]},dots8:{interval:80,frames:`⠁.⠁.⠉.⠙.⠚.⠒.⠂.⠂.⠒.⠲.⠴.⠤.⠄.⠄.⠤.⠠.⠠.⠤.⠦.⠖.⠒.⠐.⠐.⠒.⠓.⠋.⠉.⠈.⠈`.split(`.`)},dots9:{interval:80,frames:[`⢹`,`⢺`,`⢼`,`⣸`,`⣇`,`⡧`,`⡗`,`⡏`]},dots10:{interval:80,frames:[`⢄`,`⢂`,`⢁`,`⡁`,`⡈`,`⡐`,`⡠`]},dots11:{interval:100,frames:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`]},dots12:{interval:80,frames:`⢀⠀.⡀⠀.⠄⠀.⢂⠀.⡂⠀.⠅⠀.⢃⠀.⡃⠀.⠍⠀.⢋⠀.⡋⠀.⠍⠁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⢈⠩.⡀⢙.⠄⡙.⢂⠩.⡂⢘.⠅⡘.⢃⠨.⡃⢐.⠍⡐.⢋⠠.⡋⢀.⠍⡁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⠈⠩.⠀⢙.⠀⡙.⠀⠩.⠀⢘.⠀⡘.⠀⠨.⠀⢐.⠀⡐.⠀⠠.⠀⢀.⠀⡀`.split(`.`)},dots13:{interval:80,frames:[`⣼`,`⣹`,`⢻`,`⠿`,`⡟`,`⣏`,`⣧`,`⣶`]},dots14:{interval:80,frames:[`⠉⠉`,`⠈⠙`,`⠀⠹`,`⠀⢸`,`⠀⣰`,`⢀⣠`,`⣀⣀`,`⣄⡀`,`⣆⠀`,`⡇⠀`,`⠏⠀`,`⠋⠁`]},dots8Bit:{interval:80,frames:`⠀.⠁.⠂.⠃.⠄.⠅.⠆.⠇.⡀.⡁.⡂.⡃.⡄.⡅.⡆.⡇.⠈.⠉.⠊.⠋.⠌.⠍.⠎.⠏.⡈.⡉.⡊.⡋.⡌.⡍.⡎.⡏.⠐.⠑.⠒.⠓.⠔.⠕.⠖.⠗.⡐.⡑.⡒.⡓.⡔.⡕.⡖.⡗.⠘.⠙.⠚.⠛.⠜.⠝.⠞.⠟.⡘.⡙.⡚.⡛.⡜.⡝.⡞.⡟.⠠.⠡.⠢.⠣.⠤.⠥.⠦.⠧.⡠.⡡.⡢.⡣.⡤.⡥.⡦.⡧.⠨.⠩.⠪.⠫.⠬.⠭.⠮.⠯.⡨.⡩.⡪.⡫.⡬.⡭.⡮.⡯.⠰.⠱.⠲.⠳.⠴.⠵.⠶.⠷.⡰.⡱.⡲.⡳.⡴.⡵.⡶.⡷.⠸.⠹.⠺.⠻.⠼.⠽.⠾.⠿.⡸.⡹.⡺.⡻.⡼.⡽.⡾.⡿.⢀.⢁.⢂.⢃.⢄.⢅.⢆.⢇.⣀.⣁.⣂.⣃.⣄.⣅.⣆.⣇.⢈.⢉.⢊.⢋.⢌.⢍.⢎.⢏.⣈.⣉.⣊.⣋.⣌.⣍.⣎.⣏.⢐.⢑.⢒.⢓.⢔.⢕.⢖.⢗.⣐.⣑.⣒.⣓.⣔.⣕.⣖.⣗.⢘.⢙.⢚.⢛.⢜.⢝.⢞.⢟.⣘.⣙.⣚.⣛.⣜.⣝.⣞.⣟.⢠.⢡.⢢.⢣.⢤.⢥.⢦.⢧.⣠.⣡.⣢.⣣.⣤.⣥.⣦.⣧.⢨.⢩.⢪.⢫.⢬.⢭.⢮.⢯.⣨.⣩.⣪.⣫.⣬.⣭.⣮.⣯.⢰.⢱.⢲.⢳.⢴.⢵.⢶.⢷.⣰.⣱.⣲.⣳.⣴.⣵.⣶.⣷.⢸.⢹.⢺.⢻.⢼.⢽.⢾.⢿.⣸.⣹.⣺.⣻.⣼.⣽.⣾.⣿`.split(`.`)},dotsCircle:{interval:80,frames:[`⢎ `,`⠎⠁`,`⠊⠑`,`⠈⠱`,` ⡱`,`⢀⡰`,`⢄⡠`,`⢆⡀`]},sand:{interval:80,frames:`⠁.⠂.⠄.⡀.⡈.⡐.⡠.⣀.⣁.⣂.⣄.⣌.⣔.⣤.⣥.⣦.⣮.⣶.⣷.⣿.⡿.⠿.⢟.⠟.⡛.⠛.⠫.⢋.⠋.⠍.⡉.⠉.⠑.⠡.⢁`.split(`.`)},line:{interval:130,frames:[`-`,`\\`,`|`,`/`]},line2:{interval:100,frames:[`⠂`,`-`,`–`,`—`,`–`,`-`]},rollingLine:{interval:80,frames:[`/ `,` - `,` \\ `,` |`,` |`,` \\ `,` - `,`/ `]},pipe:{interval:100,frames:[`┤`,`┘`,`┴`,`└`,`├`,`┌`,`┬`,`┐`]},simpleDots:{interval:400,frames:[`. `,`.. `,`...`,` `]},simpleDotsScrolling:{interval:200,frames:[`. `,`.. `,`...`,` ..`,` .`,` `]},star:{interval:70,frames:[`✶`,`✸`,`✹`,`✺`,`✹`,`✷`]},star2:{interval:80,frames:[`+`,`x`,`*`]},flip:{interval:70,frames:[`_`,`_`,`_`,`-`,"`","`",`'`,`´`,`-`,`_`,`_`,`_`]},hamburger:{interval:100,frames:[`☱`,`☲`,`☴`]},growVertical:{interval:120,frames:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`▆`,`▅`,`▄`,`▃`]},growHorizontal:{interval:120,frames:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`▊`,`▋`,`▌`,`▍`,`▎`]},balloon:{interval:140,frames:[` `,`.`,`o`,`O`,`@`,`*`,` `]},balloon2:{interval:120,frames:[`.`,`o`,`O`,`°`,`O`,`o`,`.`]},noise:{interval:100,frames:[`▓`,`▒`,`░`]},bounce:{interval:120,frames:[`⠁`,`⠂`,`⠄`,`⠂`]},boxBounce:{interval:120,frames:[`▖`,`▘`,`▝`,`▗`]},boxBounce2:{interval:100,frames:[`▌`,`▀`,`▐`,`▄`]},triangle:{interval:50,frames:[`◢`,`◣`,`◤`,`◥`]},binary:{interval:80,frames:[`010010`,`001100`,`100101`,`111010`,`111101`,`010111`,`101011`,`111000`,`110011`,`110101`]},arc:{interval:100,frames:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`]},circle:{interval:120,frames:[`◡`,`⊙`,`◠`]},squareCorners:{interval:180,frames:[`◰`,`◳`,`◲`,`◱`]},circleQuarters:{interval:120,frames:[`◴`,`◷`,`◶`,`◵`]},circleHalves:{interval:50,frames:[`◐`,`◓`,`◑`,`◒`]},squish:{interval:100,frames:[`╫`,`╪`]},toggle:{interval:250,frames:[`⊶`,`⊷`]},toggle2:{interval:80,frames:[`▫`,`▪`]},toggle3:{interval:120,frames:[`□`,`■`]},toggle4:{interval:100,frames:[`■`,`□`,`▪`,`▫`]},toggle5:{interval:100,frames:[`▮`,`▯`]},toggle6:{interval:300,frames:[`ဝ`,`၀`]},toggle7:{interval:80,frames:[`⦾`,`⦿`]},toggle8:{interval:100,frames:[`◍`,`◌`]},toggle9:{interval:100,frames:[`◉`,`◎`]},toggle10:{interval:100,frames:[`㊂`,`㊀`,`㊁`]},toggle11:{interval:50,frames:[`⧇`,`⧆`]},toggle12:{interval:120,frames:[`☗`,`☖`]},toggle13:{interval:80,frames:[`=`,`*`,`-`]},arrow:{interval:100,frames:[`←`,`↖`,`↑`,`↗`,`→`,`↘`,`↓`,`↙`]},arrow2:{interval:80,frames:[`⬆️ `,`↗️ `,`➡️ `,`↘️ `,`⬇️ `,`↙️ `,`⬅️ `,`↖️ `]},arrow3:{interval:120,frames:[`▹▹▹▹▹`,`▸▹▹▹▹`,`▹▸▹▹▹`,`▹▹▸▹▹`,`▹▹▹▸▹`,`▹▹▹▹▸`]},bouncingBar:{interval:80,frames:[`[ ]`,`[= ]`,`[== ]`,`[=== ]`,`[====]`,`[ ===]`,`[ ==]`,`[ =]`,`[ ]`,`[ =]`,`[ ==]`,`[ ===]`,`[====]`,`[=== ]`,`[== ]`,`[= ]`]},bouncingBall:{interval:80,frames:[`( ● )`,`( ● )`,`( ● )`,`( ● )`,`( ●)`,`( ● )`,`( ● )`,`( ● )`,`( ● )`,`(● )`]},smiley:{interval:200,frames:[`😄 `,`😝 `]},monkey:{interval:300,frames:[`🙈 `,`🙈 `,`🙉 `,`🙊 `]},hearts:{interval:100,frames:[`💛 `,`💙 `,`💜 `,`💚 `,`💗 `]},clock:{interval:100,frames:[`🕛 `,`🕐 `,`🕑 `,`🕒 `,`🕓 `,`🕔 `,`🕕 `,`🕖 `,`🕗 `,`🕘 `,`🕙 `,`🕚 `]},earth:{interval:180,frames:[`🌍 `,`🌎 `,`🌏 `]},material:{interval:17,frames:`█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███████▁▁▁▁▁▁▁▁▁▁▁▁▁.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.██████████▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.█████████████▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁██████████████▁▁▁▁.▁▁▁██████████████▁▁▁.▁▁▁▁█████████████▁▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁▁▁████████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.██████▁▁▁▁▁▁▁▁▁▁▁▁▁█.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁▁█████████████▁▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁▁███████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁▁█████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁`.split(`.`)},moon:{interval:80,frames:[`🌑 `,`🌒 `,`🌓 `,`🌔 `,`🌕 `,`🌖 `,`🌗 `,`🌘 `]},runner:{interval:140,frames:[`🚶 `,`🏃 `]},pong:{interval:80,frames:`▐⠂ ▌.▐⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂▌.▐ ⠠▌.▐ ⡀▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐⠠ ▌`.split(`.`)},shark:{interval:120,frames:`▐|\\____________▌.▐_|\\___________▌.▐__|\\__________▌.▐___|\\_________▌.▐____|\\________▌.▐_____|\\_______▌.▐______|\\______▌.▐_______|\\_____▌.▐________|\\____▌.▐_________|\\___▌.▐__________|\\__▌.▐___________|\\_▌.▐____________|\\▌.▐____________/|▌.▐___________/|_▌.▐__________/|__▌.▐_________/|___▌.▐________/|____▌.▐_______/|_____▌.▐______/|______▌.▐_____/|_______▌.▐____/|________▌.▐___/|_________▌.▐__/|__________▌.▐_/|___________▌.▐/|____________▌`.split(`.`)},dqpb:{interval:100,frames:[`d`,`q`,`p`,`b`]},weather:{interval:100,frames:[`☀️ `,`☀️ `,`☀️ `,`🌤 `,`⛅️ `,`🌥 `,`☁️ `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`⛈ `,`🌨 `,`🌧 `,`🌨 `,`☁️ `,`🌥 `,`⛅️ `,`🌤 `,`☀️ `,`☀️ `]},christmas:{interval:400,frames:[`🌲`,`🎄`]},grenade:{interval:80,frames:[`، `,`′ `,` ´ `,` ‾ `,` ⸌`,` ⸊`,` |`,` ⁎`,` ⁕`,` ෴ `,` ⁓`,` `,` `,` `]},point:{interval:125,frames:[`∙∙∙`,`●∙∙`,`∙●∙`,`∙∙●`,`∙∙∙`]},layer:{interval:150,frames:[`-`,`=`,`≡`]},betaWave:{interval:80,frames:[`ρββββββ`,`βρβββββ`,`ββρββββ`,`βββρβββ`,`ββββρββ`,`βββββρβ`,`ββββββρ`]},fingerDance:{interval:160,frames:[`🤘 `,`🤟 `,`🖖 `,`✋ `,`🤚 `,`👆 `]},fistBump:{interval:80,frames:[`🤜 🤛 `,`🤜 🤛 `,`🤜 🤛 `,` 🤜 🤛 `,` 🤜🤛 `,` 🤜✨🤛 `,`🤜 ✨ 🤛 `]},soccerHeader:{interval:80,frames:[` 🧑⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `]},mindblown:{interval:160,frames:[`😐 `,`😐 `,`😮 `,`😮 `,`😦 `,`😦 `,`😧 `,`😧 `,`🤯 `,`💥 `,`✨ `,` `,` `,` `]},speaker:{interval:160,frames:[`🔈 `,`🔉 `,`🔊 `,`🔉 `]},orangePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `]},bluePulse:{interval:100,frames:[`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},orangeBluePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `,`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},timeTravel:{interval:100,frames:[`🕛 `,`🕚 `,`🕙 `,`🕘 `,`🕗 `,`🕖 `,`🕕 `,`🕔 `,`🕓 `,`🕒 `,`🕑 `,`🕐 `]},aesthetic:{interval:80,frames:[`▰▱▱▱▱▱▱`,`▰▰▱▱▱▱▱`,`▰▰▰▱▱▱▱`,`▰▰▰▰▱▱▱`,`▰▰▰▰▰▱▱`,`▰▰▰▰▰▰▱`,`▰▰▰▰▰▰▰`,`▰▱▱▱▱▱▱`]},dwarfFortress:{interval:80,frames:` ██████£££ .☺██████£££ .☺██████£££ .☺▓█████£££ .☺▓█████£££ .☺▒█████£££ .☺▒█████£££ .☺░█████£££ .☺░█████£££ .☺ █████£££ . ☺█████£££ . ☺█████£££ . ☺▓████£££ . ☺▓████£££ . ☺▒████£££ . ☺▒████£££ . ☺░████£££ . ☺░████£££ . ☺ ████£££ . ☺████£££ . ☺████£££ . ☺▓███£££ . ☺▓███£££ . ☺▒███£££ . ☺▒███£££ . ☺░███£££ . ☺░███£££ . ☺ ███£££ . ☺███£££ . ☺███£££ . ☺▓██£££ . ☺▓██£££ . ☺▒██£££ . ☺▒██£££ . ☺░██£££ . ☺░██£££ . ☺ ██£££ . ☺██£££ . ☺██£££ . ☺▓█£££ . ☺▓█£££ . ☺▒█£££ . ☺▒█£££ . ☺░█£££ . ☺░█£££ . ☺ █£££ . ☺█£££ . ☺█£££ . ☺▓£££ . ☺▓£££ . ☺▒£££ . ☺▒£££ . ☺░£££ . ☺░£££ . ☺ £££ . ☺£££ . ☺£££ . ☺▓££ . ☺▓££ . ☺▒££ . ☺▒££ . ☺░££ . ☺░££ . ☺ ££ . ☺££ . ☺££ . ☺▓£ . ☺▓£ . ☺▒£ . ☺▒£ . ☺░£ . ☺░£ . ☺ £ . ☺£ . ☺£ . ☺▓ . ☺▓ . ☺▒ . ☺▒ . ☺░ . ☺░ . ☺ . ☺ &. ☺ ☼&. ☺ ☼ &. ☺☼ &. ☺☼ & . ‼ & . ☺ & . ‼ & . ☺ & . ‼ & . ☺ & .‼ & . & . & . & ░ . & ▒ . & ▓ . & £ . & ░£ . & ▒£ . & ▓£ . & ££ . & ░££ . & ▒££ .& ▓££ .& £££ . ░£££ . ▒£££ . ▓£££ . █£££ . ░█£££ . ▒█£££ . ▓█£££ . ██£££ . ░██£££ . ▒██£££ . ▓██£££ . ███£££ . ░███£££ . ▒███£££ . ▓███£££ . ████£££ . ░████£££ . ▒████£££ . ▓████£££ . █████£££ . ░█████£££ . ▒█████£££ . ▓█████£££ . ██████£££ . ██████£££ `.split(`.`)}};export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isAmbiguous as e,isFullWidth as t,isWide as n}from"./lookup.js";function r(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function i(i,{ambiguousAsWide:a=!1}={}){return r(i),t(i)||n(i)||a&&e(i)?2:1}export{i as eastAsianWidth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function t(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function n(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}export{e as isAmbiguous,t as isFullWidth,n as isWide};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e({stream:e=process.stdout}={}){return!!(e&&e.isTTY&&process.env.TERM!==`dumb`&&!(`CI`in process.env))}export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:process";function t(){let{env:t}=e,{TERM:n,TERM_PROGRAM:r}=t;return e.platform===`win32`?!!t.WT_SESSION||!!t.TERMINUS_SUBLIME||t.ConEmuTask===`{cmd::Cmder}`||r===`Terminus-Sublime`||r===`vscode`||n===`xterm-256color`||n===`alacritty`||n===`rxvt-unicode`||n===`rxvt-unicode-256color`||t.TERMINAL_EMULATOR===`JetBrains-JediTerm`:n!==`linux`}export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`ℹ️`,t=`✅`,n=`⚠️`,r=`❌️`;export{r as error,e as info,t as success,n as warning};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,n,r,i)=>{if(r===`length`||r===`prototype`||r===`arguments`||r===`caller`)return;let a=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(n,r);!t(a,o)&&i||Object.defineProperty(e,r,o)},t=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},n=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},r=(e,t)=>`/* Wrapped ${e}*/\n${t}`,i=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),a=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),o=(e,t,n)=>{let o=n===``?``:`with ${n.trim()}() `,s=r.bind(null,o,t.toString());Object.defineProperty(s,`name`,a);let{writable:c,enumerable:l,configurable:u}=i;Object.defineProperty(e,`toString`,{value:s,writable:c,enumerable:l,configurable:u})};function s(t,r,{ignoreNonConfigurable:i=!1}={}){let{name:a}=t;for(let n of Reflect.ownKeys(r))e(t,r,n,i);return n(t,r),o(t,r,a),t}export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../mimic-function/index.js";const t=new WeakMap,n=(n,r={})=>{if(typeof n!=`function`)throw TypeError(`Expected a function`);let i,a=0,o=n.displayName||n.name||`<anonymous>`,s=function(...e){if(t.set(s,++a),a===1)i=n.apply(this,e),n=void 0;else if(r.throw===!0)throw Error(`Function \`${o}\` can only be called once`);return i};return e(s,n),t.set(s,a),s};n.callCount=e=>{if(!t.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return t.get(e)};var r=n;export{r as default};
|