@swifty.js/swifty 0.0.31 → 0.0.33

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.
Files changed (86) hide show
  1. package/README.md +110 -3
  2. package/dist/acp-5WRTN2LL.js +14 -0
  3. package/dist/agent-3CAPJCPD.js +4 -0
  4. package/dist/anthropic-FXRRA63E.js +4 -0
  5. package/dist/{bwrap-TPE6G4BM.js → bwrap-ZTS67W2K.js} +1 -1
  6. package/dist/checker-3O7QF7XV.js +4 -0
  7. package/dist/chunk-2U4IWZ6E.js +4 -0
  8. package/dist/chunk-35X3GW25.js +4 -0
  9. package/dist/chunk-4C3KJLJV.js +4 -0
  10. package/dist/chunk-4HSQBZBI.js +4 -0
  11. package/dist/{chunk-AGJYBJ5M.js → chunk-4PQYUHSN.js} +1 -1
  12. package/dist/chunk-6I3HEMIE.js +4 -0
  13. package/dist/{chunk-C3WGLVVZ.js → chunk-7JQHFZRD.js} +2 -2
  14. package/dist/chunk-C5WLP3DH.js +5 -0
  15. package/dist/chunk-FUKVR3XO.js +608 -0
  16. package/dist/chunk-FZORZF22.js +16 -0
  17. package/dist/chunk-G2TE2QZM.js +4 -0
  18. package/dist/chunk-I7XJSLRI.js +4 -0
  19. package/dist/{chunk-OQCEP2F5.js → chunk-IKQTIDRL.js} +1 -1
  20. package/dist/chunk-IZ7QOBSB.js +4 -0
  21. package/dist/chunk-LC7ZWLIH.js +4 -0
  22. package/dist/chunk-LHSUYZO5.js +4 -0
  23. package/dist/chunk-M4D66APS.js +67 -0
  24. package/dist/chunk-NAAAN2TD.js +60 -0
  25. package/dist/chunk-NCZR3AGA.js +65 -0
  26. package/dist/{server-BNT2IIKB.js → chunk-PXQD6GWP.js} +15 -22
  27. package/dist/{chunk-FPQ2LBL4.js → chunk-QQVDL4QT.js} +1 -1
  28. package/dist/{chunk-TCQ4EB4G.js → chunk-TNF3EHFY.js} +1 -1
  29. package/dist/chunk-XGUH7SGV.js +4 -0
  30. package/dist/chunk-YIKI3EPG.js +150 -0
  31. package/dist/chunk-YKWIZE5D.js +4 -0
  32. package/dist/{devtools-OJ75EP3T.js → devtools-WJM4UVVT.js} +1 -1
  33. package/dist/esm-46WSO26W.js +4 -0
  34. package/dist/esm-4DBD7ONK.js +229 -0
  35. package/dist/esm-6EDGM6QS.js +4 -0
  36. package/dist/esm-D6BB3FBR.js +4 -0
  37. package/dist/esm-P2KEXEEK.js +4 -0
  38. package/dist/esm-XYKZYVLV.js +4 -0
  39. package/dist/esm-YJVVI2QX.js +4 -0
  40. package/dist/getMachineId-bsd-NBOQ3GRQ.js +4 -0
  41. package/dist/getMachineId-darwin-6VBNSUFR.js +5 -0
  42. package/dist/getMachineId-linux-RQ33NIOO.js +4 -0
  43. package/dist/getMachineId-unsupported-IWOYPUHZ.js +4 -0
  44. package/dist/getMachineId-win-ITT3WXP6.js +4 -0
  45. package/dist/lib/agent-NNYCUIOF.js +10 -0
  46. package/dist/lib/{anthropic-R6DMXE7U.js → anthropic-B33M2AVN.js} +4 -4
  47. package/dist/lib/{checker-M7RKMKJQ.js → checker-UPY4CXUL.js} +3 -3
  48. package/dist/lib/{chunk-OQIQOU5S.js → chunk-3OFLDUAW.js} +121 -1
  49. package/dist/lib/{chunk-EY7HE52Q.js → chunk-3XCGUKGJ.js} +18 -24
  50. package/dist/lib/{chunk-J6AV7SIF.js → chunk-AFYPVA5C.js} +261 -25
  51. package/dist/lib/{chunk-FZ4Y6MBN.js → chunk-BCBD34D2.js} +1 -1
  52. package/dist/lib/{chunk-A4MXZA5Q.js → chunk-CFYAZWDA.js} +10 -4
  53. package/dist/lib/{chunk-4MDCRPVV.js → chunk-FODSMOWP.js} +6 -6
  54. package/dist/lib/chunk-GTHYQZRL.js +31 -0
  55. package/dist/lib/{chunk-EWE5IWZE.js → chunk-LDWFI6MR.js} +15 -4
  56. package/dist/lib/{chunk-OEPCNATU.js → chunk-TJLAJGG4.js} +2 -2
  57. package/dist/lib/index.d.ts +2339 -1581
  58. package/dist/lib/index.js +12210 -10961
  59. package/dist/lib/{openai-5N42ZYIJ.js → openai-C2PZFGJ2.js} +3 -3
  60. package/dist/lib/providers-UJEWP7C7.js +419 -0
  61. package/dist/lib/{tool-filter-XG2GXFVN.js → tool-filter-BFEINZIA.js} +1 -1
  62. package/dist/main.js +190 -183
  63. package/dist/{node-4LTSRXL2.js → node-A6KBFKOV.js} +1 -1
  64. package/dist/{openai-NQYARTT6.js → openai-WPEICAZ4.js} +1 -1
  65. package/dist/providers-WNYZUMZ3.js +6 -0
  66. package/dist/seatbelt-PSPJ5LBR.js +5 -0
  67. package/dist/server-YPBLBRDN.js +4 -0
  68. package/dist/src-3A5BCUSZ.js +4 -0
  69. package/dist/src-CRYFVH7Y.js +12 -0
  70. package/dist/src-Y77IB66J.js +4 -0
  71. package/dist/src-ZCW4GCG2.js +4 -0
  72. package/dist/{tool-filter-5NDJMSTD.js → tool-filter-X6IYME2K.js} +1 -1
  73. package/dist/turndown.es-WNOSVZF6.js +83 -0
  74. package/package.json +38 -15
  75. package/dist/agent-O6C4FCQY.js +0 -4
  76. package/dist/anthropic-CFM2DXMB.js +0 -4
  77. package/dist/checker-A6PGACKZ.js +0 -4
  78. package/dist/chunk-4ABFUBO4.js +0 -601
  79. package/dist/chunk-AQ3A5CF4.js +0 -5
  80. package/dist/chunk-MVVSONAE.js +0 -4
  81. package/dist/chunk-OTVZGPHD.js +0 -121
  82. package/dist/chunk-X3UA5OZL.js +0 -4
  83. package/dist/chunk-Y2UUXOQA.js +0 -4
  84. package/dist/chunk-YAXZ2OUD.js +0 -150
  85. package/dist/lib/agent-YRTROHXU.js +0 -10
  86. package/dist/seatbelt-YXUQ5XR3.js +0 -5
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@swifty.js/swifty",
3
- "version": "0.0.31",
4
- "description": "Swifty — CLI coding agent",
3
+ "version": "0.0.33",
4
+ "description": "Swifty is a terminal-based AI coding agent. It provides an interactive TUI (terminal user interface) for conversing with large language models, executing code, manipulating files, and orchestrating multi-agent workflows, all from the command line.",
5
5
  "keywords": [
6
6
  "agent",
7
7
  "cli",
8
8
  "coding-agent",
9
- "swifty"
9
+ "swifty.js"
10
10
  ],
11
- "homepage": "https://github.com/hangtiancheng/swifty-code",
11
+ "homepage": "https://hangtiancheng.github.io/swifty-code",
12
12
  "bugs": {
13
13
  "url": "https://github.com/hangtiancheng/swifty-code/issues"
14
14
  },
@@ -24,7 +24,6 @@
24
24
  },
25
25
  "files": [
26
26
  "dist",
27
- "docs",
28
27
  "README.md"
29
28
  ],
30
29
  "type": "module",
@@ -42,8 +41,31 @@
42
41
  "access": "public"
43
42
  },
44
43
  "dependencies": {
44
+ "@a2a-js/sdk": "^1.1.0",
45
+ "@agentclientprotocol/sdk": "^1.4.0",
45
46
  "@anthropic-ai/sdk": "^0.104.2",
47
+ "@langfuse/otel": "^5.11.1",
48
+ "@langfuse/tracing": "^5.11.1",
46
49
  "@modelcontextprotocol/sdk": "^1.30.0",
50
+ "@opentelemetry/api": "^1.9.1",
51
+ "@opentelemetry/api-logs": "^0.222.0",
52
+ "@opentelemetry/core": "^2.11.0",
53
+ "@opentelemetry/exporter-logs-otlp-grpc": "^0.222.0",
54
+ "@opentelemetry/exporter-logs-otlp-http": "^0.222.0",
55
+ "@opentelemetry/exporter-logs-otlp-proto": "^0.222.0",
56
+ "@opentelemetry/exporter-metrics-otlp-grpc": "^0.222.0",
57
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.222.0",
58
+ "@opentelemetry/exporter-metrics-otlp-proto": "^0.222.0",
59
+ "@opentelemetry/exporter-prometheus": "^0.222.0",
60
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.222.0",
61
+ "@opentelemetry/exporter-trace-otlp-http": "^0.222.0",
62
+ "@opentelemetry/exporter-trace-otlp-proto": "^0.222.0",
63
+ "@opentelemetry/resources": "^2.11.0",
64
+ "@opentelemetry/sdk-logs": "^0.222.0",
65
+ "@opentelemetry/sdk-metrics": "^2.11.0",
66
+ "@opentelemetry/sdk-trace-base": "^2.11.0",
67
+ "@opentelemetry/semantic-conventions": "^1.43.0",
68
+ "@sentry/node": "^10.75.0",
47
69
  "ansi-escapes": "^7.3.0",
48
70
  "ansi-regex": "^6.3.0",
49
71
  "chalk": "^5.6.2",
@@ -53,12 +75,10 @@
53
75
  "fuse.js": "^7.5.0",
54
76
  "glob": "^13.0.6",
55
77
  "ink": "^7.1.1",
56
- "ink-spinner": "^5.0.0",
57
- "ink-text-input": "^6.0.0",
58
78
  "js-yaml": "^4.3.2",
59
79
  "koa": "^3.2.1",
60
- "marked": "^18.0.12",
61
- "minimatch": "^10.2.2",
80
+ "marked": "^18.0.13",
81
+ "minimatch": "^10.2.6",
62
82
  "node-emoji": "^2.2.0",
63
83
  "openai": "^6.49.0",
64
84
  "pino": "^10.3.1",
@@ -68,9 +88,10 @@
68
88
  "slice-ansi": "^9.0.0",
69
89
  "string-width": "^8.2.2",
70
90
  "supports-hyperlinks": "^4.5.0",
91
+ "turndown": "^7.2.4",
71
92
  "wrap-ansi": "^10.0.1",
72
93
  "ws": "^8.21.3",
73
- "zod": "^4.6.2"
94
+ "zod": "^4.6.5"
74
95
  },
75
96
  "devDependencies": {
76
97
  "@biomejs/biome": "2.4.15",
@@ -78,15 +99,16 @@
78
99
  "@tailwindcss/postcss": "^4.3.3",
79
100
  "@types/js-yaml": "^4.0.9",
80
101
  "@types/koa": "^3.0.3",
81
- "@types/node": "^24.13.4",
102
+ "@types/node": "^24.13.5",
82
103
  "@types/react": "^19.3.0",
83
104
  "@types/react-dom": "^19.3.0",
105
+ "@types/turndown": "^5.0.6",
84
106
  "@types/ws": "^8.18.1",
85
107
  "@vitest/coverage-v8": "^4.1.11",
86
108
  "eslint": "^9.39.5",
87
109
  "eslint-plugin-import": "^2.32.0",
88
110
  "eslint-plugin-react-hooks": "^5.2.0",
89
- "eslint-plugin-react-refresh": "^0.5.6",
111
+ "eslint-plugin-react-refresh": "^0.5.7",
90
112
  "eslint-plugin-unicorn": "^65.0.1",
91
113
  "globals": "^17.12.0",
92
114
  "oxfmt": "^0.53.0",
@@ -107,14 +129,15 @@
107
129
  "build:fe": "cd src/remote/fe && rm -rf ./dist && tsup",
108
130
  "preview:fe": "pnpm dlx serve src/remote/fe/dist",
109
131
  "dev": "tsx ./src/main.tsx",
132
+ "AB:TODO": "pnpm add @growthbook/growthbook",
110
133
  "build": "rm -rf ./dist && tsup",
111
- "lint": "eslint --cache ./src ./tests",
112
- "lint:fix": "eslint --cache --fix ./src ./tests",
134
+ "lint": "eslint --cache --quiet ./src ./tests",
135
+ "lint:fix": "eslint --cache --fix --quiet ./src ./tests",
113
136
  "test": "vitest run --maxWorkers=2",
114
137
  "test:watch": "vitest",
115
138
  "typecheck": "tsc --noEmit -p tsconfig.json",
116
139
  "format": "oxfmt --write .",
117
- "all": "pnpm typecheck && pnpm test && pnpm lint && pnpm build",
140
+ "all": "pnpm typecheck && pnpm lint && pnpm build && pnpm test",
118
141
  "add:user": "pnpm adduser --registry=https://registry.npmjs.org/",
119
142
  "publish:latest": "pnpm publish --access public --registry=https://registry.npmjs.org/",
120
143
  "publish:nightly": "pnpm publish --access public --registry=https://registry.npmjs.org/ --tag nightly"
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __swiftyCreateRequire } from "node:module";
3
- const require = __swiftyCreateRequire(import.meta.url);
4
- import{s as a}from"./chunk-YAXZ2OUD.js";import"./chunk-TCQ4EB4G.js";import"./chunk-AQ3A5CF4.js";import"./chunk-OQCEP2F5.js";import"./chunk-OTVZGPHD.js";import"./chunk-X3UA5OZL.js";export{a as Agent};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __swiftyCreateRequire } from "node:module";
3
- const require = __swiftyCreateRequire(import.meta.url);
4
- import{a as Z}from"./chunk-AGJYBJ5M.js";import{a as Q}from"./chunk-TCQ4EB4G.js";import{g as M}from"./chunk-C3WGLVVZ.js";import{A as V,B as q,D as X,k as B,m as O,n as U,o as j,p as $,q as K,r as F,t as C,u as E,x as D,y as I,z as J}from"./chunk-AQ3A5CF4.js";import"./chunk-OQCEP2F5.js";import{D as w,I as N,J as H,K as z,L as G,M as d,N as W,R as Y,g as R}from"./chunk-OTVZGPHD.js";import"./chunk-X3UA5OZL.js";function oe(o){for(let t=o.length-1;t>=0;t--){let e=o[t];if(e.defer_loading!==!0){e.cache_control={type:"ephemeral"};return}}}function ne(o){return o.some(t=>"defer_loading"in t&&t.defer_loading===!0)}var re="computer-use-2025-11-24";function se(o){if("type"in o&&o.type==="computer_20251124")return{...o};if("input_schema"in o){let t=o,{cache_control:e,...n}=t;return{...n,type:"custom",...t.defer_loading!==!0&&e?{cache_control:e}:{}}}throw new Error("Anthropic received a tool schema serialized for another protocol.")}var T=N({module:"llm"});var ie=3e3,ae=w.object({max_input_tokens:w.coerce.number()});async function Te(o){if(o.protocol!=="anthropic")return 0;let t=E(o),n=`${o.base_url.replace(/\/+$/,"")}/v1/models/${encodeURIComponent(o.model)}`,r=new AbortController,s=setTimeout(()=>{r.abort()},ie);try{let c=await fetch(n,{method:"GET",headers:{"anthropic-version":"2023-06-01",...t?{"x-api-key":t}:{}},signal:r.signal});if(!c.ok)return 0;let v=await c.json(),{success:p,error:u,data:h}=await R(ae,v);if(!p)return T.warn({message:u.message},"model context window schema validation failed"),0;let m=h.max_input_tokens;return Math.max(m,0)}catch(c){return T.error({err:c},"failed to fetch model context window"),0}finally{clearTimeout(s)}}function y(o){return typeof o=="string"?[{type:"text",text:o}]:o.map(t=>{let e=Q(t);if(!e||e.type==="tool_reference")throw new Error(`Unsupported user content block: ${Y(t,"type","unknown")}`);return e})}function le(o){let t=[];for(let e of o)if(e.role==="assistant"){let n=[];if(e.thinkingBlocks)for(let s of e.thinkingBlocks)n.push({type:"thinking",thinking:s.thinking,signature:s.signature});let r=typeof e.content=="string"?e.content:H(e.content);if(r&&n.push({type:"text",text:r}),e.toolUses)for(let s of e.toolUses)n.push({type:"tool_use",id:s.toolUseId,name:s.toolName==="ComputerUse"?"computer":s.toolName,input:s.arguments});n.length===0&&n.push({type:"text",text:""}),t.push({role:"assistant",content:n})}else if(e.toolResults&&e.toolResults.length>0){let n=[];for(let r of e.toolResults)n.push({type:"tool_result",tool_use_id:r.toolUseId,is_error:r.isError,content:r.contentBlocks?.length?r.contentBlocks:r.content});e.content.length>0&&n.push(...y(e.content)),t.push({role:"user",content:n})}else{if(t.length===0){t.push({role:"user",content:y(e.content)});continue}let n=!1,r=t[t.length-1],s=r.content;r.role==="user"&&(typeof s=="string"||Array.isArray(s)&&s.length>0&&(s[0].type==="text"||s[0].type==="image"))&&(n=!0),n?(typeof s=="string"&&(s=r.content=s.trim().length>0?[{type:"text",text:s}]:[]),s.push(...y(e.content))):t.push({role:"user",content:y(e.content)})}return t}var ee=class{protocol="anthropic";client;model;thinkingLevel;systemPrompt;maxOutputTokens;config;constructor(t,e){let n=E(t);if(!n)throw new I("Anthropic API key not found, set ANTHROPIC_API_KEY in ~/.swifty/config.yaml, or via ANTHROPIC_API_KEY env variable.");this.client=new M({apiKey:n,baseURL:t.base_url}),this.model=t.model,this.config={...t},this.thinkingLevel=O(t),this.systemPrompt=e,this.maxOutputTokens=C(t)}setSystemPrompt(t){this.systemPrompt=t}setMaxOutputTokens(t){this.config={...this.config,max_output_tokens:t},this.maxOutputTokens=C(this.config),this.setThinkingLevel(this.thinkingLevel)}setThinkingLevel(t){return this.thinkingLevel=F(this.config,t),this.thinkingLevel}getThinkingLevel(){return this.thinkingLevel}getSupportedThinkingLevels(){return K(this.config)}async*stream(t,e,n){let r=le(X(t.getMessages())),s=ne(e),c=e.map(se),v=c.some(l=>"type"in l&&l.type==="computer_20251124");oe(c),ce(r);let p={model:this.model,max_tokens:this.maxOutputTokens,stream:!0,system:[{type:"text",text:this.systemPrompt,cache_control:{type:"ephemeral"}}],messages:r,...c.length>0?{tools:c}:{}},u=this.getThinkingLevel();if(this.config.reasoning!==!1)if(u==="off")p.thinking={type:"disabled"};else if(this.config.thinking_mode==="adaptive"){let l=$(u,this.config);l!==null&&(p.thinking={type:"adaptive"},p.output_config={effort:l})}else{let l=j(u,this.config);l!==null&&l!=="none"&&(p.thinking={type:"enabled",budget_tokens:Math.min(U(l),this.maxOutputTokens-B)})}let h=0,m=0,x=0,A=0,S="end_turn",b="",L="",P=!1;try{let l=[...s?[Z]:[],...v?[re]:[]],te=this.client.messages.stream(p,{...n?{signal:n}:{},...l.length>0?{headers:{"anthropic-beta":l.join(",")}}:{}}),g="",k="",f="";for await(let a of te)switch(a.type){case"content_block_start":{let i=a.content_block;i.type==="thinking"?(P=!0,b="",L=""):i.type==="tool_use"&&(k=i.id,g=i.name==="computer"?"ComputerUse":i.name,f="",yield{type:"tool_call_start",toolName:g,toolId:k});break}case"content_block_delta":{let i=a.delta;i.type==="thinking_delta"?(b+=i.thinking,yield{type:"thinking_delta",text:i.thinking}):i.type==="signature_delta"?L+=i.signature:i.type==="text_delta"?yield{type:"text_delta",text:i.text}:i.type==="input_json_delta"&&(f+=i.partial_json,yield{type:"tool_call_delta",text:i.partial_json});break}case"content_block_stop":{if(P&&(yield{type:"thinking_complete",thinking:b,signature:L},P=!1),g){let i={};if(f)try{let _=JSON.parse(f);i=z(_)?G(_):{}}catch(_){T.error({err:_},"llm operation failed"),i={}}yield{type:"tool_call_complete",toolId:k,toolName:g,arguments:i},g="",k="",f=""}break}case"message_delta":{a.delta.stop_reason&&(S=a.delta.stop_reason),a.usage.output_tokens&&(m=a.usage.output_tokens,a.usage.input_tokens&&(h=a.usage.input_tokens),a.usage.cache_read_input_tokens&&(x=a.usage.cache_read_input_tokens),a.usage.cache_creation_input_tokens&&(A=a.usage.cache_creation_input_tokens));break}case"message_start":{h=a.message.usage.input_tokens,m=a.message.usage.output_tokens,x=a.message.usage.cache_read_input_tokens??0,A=a.message.usage.cache_creation_input_tokens??0;break}}yield{type:"stream_end",stopReason:S,usage:{inputTokens:h,outputTokens:m,cacheReadInputTokens:x,cacheCreationInputTokens:A}}}catch(l){throw T.error({err:l},"llm operation failed"),pe(l)}}};function ce(o){for(let t=o.length-1;t>=0;t--){if(o[t].role!=="user")continue;let e=o[t].content;if(typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0)return;typeof e=="string"&&(e=o[t].content=[{type:"text",text:e}]);let n=e[e.length-1];for(let r=e.length-1;r>=0;r--)if(e[r].type!=="image"){n=e[r];break}Reflect.set(n,"cache_control",{type:"ephemeral"});return}}function pe(o){if(o instanceof M.APIError){if(o.status===413||/prompts?\s+too\s+long/i.test(o.message))return new q(`Prompt too long: ${o.message}`);if(o.status===401)return new I(`Invalid API key: ${o.message}`);if(o.status===429){let t=o.headers,e=t instanceof Headers?t.get("retry-after"):void 0,n="Rate Limited";if(e){let r=Number.parseInt(d(e));Number.isNaN(r)?n+=", please wait.":n+=`, retry after ${d(r)}s.`}else n+=", please wait.";return new J(n,e?d(e):void 0)}return new D(`Anthropic API error (${d(o.status)}): ${o.message}`)}return new V(`Network error: ${W(o)}`)}export{ee as AnthropicClient,le as buildAnthropicMessages,Te as fetchModelContextWindow,ce as markLastUserTailForCache,oe as markToolsForCache,ne as needsToolSearchBeta};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __swiftyCreateRequire } from "node:module";
3
- const require = __swiftyCreateRequire(import.meta.url);
4
- import{c as a,d as b,e as c,f as d,g as e,h as f}from"./chunk-MVVSONAE.js";import"./chunk-OQCEP2F5.js";import"./chunk-OTVZGPHD.js";import"./chunk-X3UA5OZL.js";export{b as PathSandbox,f as PermissionChecker,d as RuleEngine,c as evaluateRules,a as extractContent,e as isSafeCommand};