@swifty.js/swifty 0.0.1-canary → 0.0.2-alpha
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 +302 -0
- package/dist/anthropic-RNEEF6RX.js +4 -0
- package/dist/builtin/teach-me/SKILL.md +1 -1
- package/dist/bwrap-TPE6G4BM.js +4 -0
- package/dist/{chunk-DNCLVUXL.js → chunk-2PFMEUGN.js} +1 -1
- package/dist/chunk-GW6RG76F.js +4 -0
- package/dist/chunk-MQ5XOYLD.js +4 -0
- package/dist/{chunk-XWWKIJ5J.js → chunk-SLGPWJQF.js} +31 -31
- package/dist/chunk-YUOKPBUW.js +526 -0
- package/dist/{cleanup-4R3534Z3.js → cleanup-BQJDUOKA.js} +1 -1
- package/dist/{devtools-X2EGZM6L.js → devtools-CUVBHY35.js} +1 -1
- package/dist/glob_addon.node +0 -0
- package/dist/main.js +295 -1183
- package/dist/openai-BUFKIEZO.js +26 -0
- package/dist/seatbelt-YXUQ5XR3.js +5 -0
- package/dist/server-4FIOX5PK.js +244 -0
- package/dist/tool-filter-6ETY4ZEY.js +4 -0
- package/package.json +20 -28
- package/dist/anthropic-IS6JB2DP.js +0 -4
- package/dist/builtin/commit/SKILL.md +0 -41
- package/dist/builtin/test/SKILL.md +0 -42
- package/dist/chunk-NCPOPA4A.js +0 -4
- package/dist/openai-4CKFFKCY.js +0 -27
- package/docs/ch1.md +0 -25
- package/docs/ch10.md +0 -122
- package/docs/ch11.md +0 -163
- package/docs/ch12.md +0 -288
- package/docs/ch13.md +0 -320
- package/docs/ch14.md +0 -146
- package/docs/ch15.md +0 -62
- package/docs/ch2.md +0 -273
- package/docs/ch3.md +0 -206
- package/docs/ch4.md +0 -125
- package/docs/ch5.md +0 -165
- package/docs/ch6.md +0 -201
- package/docs/ch7.md +0 -448
- package/docs/ch8.md +0 -218
- package/docs/ch9.md +0 -351
- package/docs/index.css +0 -23
- package/docs/index.md +0 -21
- package/docs/swifty.mdx +0 -7
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
|
+
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-GW6RG76F.js";import"./chunk-X3UA5OZL.js";export{a as ALL_AGENT_DISALLOWED_TOOLS,c as ASYNC_AGENT_ALLOWED_TOOLS,b as CUSTOM_AGENT_DISALLOWED_TOOLS,e as FORK_QUERY_SOURCE,f as cloneRegistryForFork,d as filterToolsForAgent};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swifty.js/swifty",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Swifty — CLI coding agent
|
|
3
|
+
"version": "0.0.2-alpha",
|
|
4
|
+
"description": "Swifty — CLI coding agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
7
7
|
"cli",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/hangtiancheng/swifty-cli/issues"
|
|
15
15
|
},
|
|
16
|
-
"license": "
|
|
16
|
+
"license": "MIT",
|
|
17
17
|
"author": "https://github.com/hangtiancheng",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
|
-
"docs"
|
|
28
|
+
"docs",
|
|
29
|
+
"README.md"
|
|
29
30
|
],
|
|
30
31
|
"type": "module",
|
|
31
32
|
"main": "dist/main.js",
|
|
@@ -33,25 +34,20 @@
|
|
|
33
34
|
"access": "public"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
|
-
"fe:dev": "cd src/remote/fe &&
|
|
37
|
-
"fe:build": "cd src/remote/fe &&
|
|
38
|
-
"fe:preview": "
|
|
39
|
-
"
|
|
40
|
-
"fe:check": "cd src/remote/fe && biome check --write",
|
|
41
|
-
"prebuild": "pnpm --filter @swifty.js/glob-wasm asbuild:release && pnpm --filter @swifty.js/glob-addon build",
|
|
37
|
+
"fe:dev": "cd src/remote/fe && tsup --watch",
|
|
38
|
+
"fe:build": "cd src/remote/fe && tsup",
|
|
39
|
+
"fe:preview": "npx -y serve src/remote/fe/dist",
|
|
40
|
+
"prebuild": "pnpm --filter @swifty.js/glob-addon build && pnpm --filter @swifty.js/glob-wasm asbuild:release",
|
|
42
41
|
"dev": "tsx ./src/main.tsx",
|
|
43
42
|
"build": "tsup",
|
|
44
|
-
"dev:docs": "rspress dev",
|
|
45
|
-
"build:docs": "rspress build",
|
|
46
|
-
"preview:docs": "rspress preview",
|
|
47
43
|
"lint": "eslint ./src",
|
|
48
44
|
"lint:fix": "eslint --fix ./src",
|
|
49
45
|
"test": "vitest run",
|
|
50
46
|
"test:watch": "vitest",
|
|
51
47
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
52
|
-
"format": "oxfmt --write .
|
|
48
|
+
"format": "oxfmt --write .",
|
|
53
49
|
"prepublishOnly": "pnpm build",
|
|
54
|
-
"
|
|
50
|
+
"add:user": "npm adduser --registry=https://registry.npmjs.org/",
|
|
55
51
|
"publish:latest": "npm publish --access public --registry=https://registry.npmjs.org/",
|
|
56
52
|
"publish:alpha": "npm publish --access public --registry=https://registry.npmjs.org/ --tag alpha",
|
|
57
53
|
"publish:beta": "npm publish --access public --registry=https://registry.npmjs.org/ --tag beta",
|
|
@@ -64,17 +60,15 @@
|
|
|
64
60
|
"@anthropic-ai/sdk": "^0.104.2",
|
|
65
61
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
66
62
|
"chalk": "^5.6.2",
|
|
67
|
-
"
|
|
68
|
-
"dompurify": "^3.4.11",
|
|
63
|
+
"dompurify": "^3.4.12",
|
|
69
64
|
"fuse.js": "^7.4.2",
|
|
70
65
|
"ink": "^7.1.0",
|
|
71
66
|
"ink-spinner": "^5.0.0",
|
|
72
67
|
"ink-text-input": "^6.0.0",
|
|
73
68
|
"js-yaml": "^4.3.0",
|
|
74
69
|
"koa": "^3.2.1",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"openai": "^6.45.0",
|
|
70
|
+
"marked": "^18.0.6",
|
|
71
|
+
"openai": "^6.46.0",
|
|
78
72
|
"pino": "^10.3.1",
|
|
79
73
|
"react": "19.2.7",
|
|
80
74
|
"react-dom": "19.2.7",
|
|
@@ -83,33 +77,31 @@
|
|
|
83
77
|
},
|
|
84
78
|
"devDependencies": {
|
|
85
79
|
"@biomejs/biome": "2.4.15",
|
|
86
|
-
"@eslint/js": "^9.39.
|
|
87
|
-
"@rsbuild/core": "^2.1.5",
|
|
88
|
-
"@rsbuild/plugin-react": "^2.1.0",
|
|
89
|
-
"@rsbuild/plugin-tailwindcss": "^2.0.3",
|
|
80
|
+
"@eslint/js": "^9.39.5",
|
|
90
81
|
"@swifty.js/glob-addon": "workspace:*",
|
|
91
82
|
"@swifty.js/glob-wasm": "workspace:*",
|
|
92
83
|
"@swifty.js/marked-terminal": "workspace:^",
|
|
84
|
+
"@tailwindcss/postcss": "^4.3.2",
|
|
93
85
|
"@types/js-yaml": "^4.0.9",
|
|
94
86
|
"@types/koa": "^3.0.3",
|
|
95
|
-
"@types/node": "^24.13.
|
|
87
|
+
"@types/node": "^24.13.3",
|
|
96
88
|
"@types/react": "^19.2.17",
|
|
97
89
|
"@types/react-dom": "^19.2.3",
|
|
98
90
|
"@types/ws": "^8.18.1",
|
|
99
91
|
"@vitest/coverage-v8": "^4.1.10",
|
|
100
|
-
"eslint": "^9.39.
|
|
92
|
+
"eslint": "^9.39.5",
|
|
101
93
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
102
94
|
"eslint-plugin-react-refresh": "^0.5.3",
|
|
103
95
|
"eslint-plugin-unicorn": "^65.0.1",
|
|
104
96
|
"globals": "^17.7.0",
|
|
105
97
|
"oxfmt": "^0.53.0",
|
|
106
98
|
"pino-pretty": "^13.1.3",
|
|
107
|
-
"
|
|
99
|
+
"postcss": "^8.5.20",
|
|
108
100
|
"tailwindcss": "^4.3.2",
|
|
109
101
|
"tsup": "^8.5.1",
|
|
110
102
|
"tsx": "^4.23.0",
|
|
111
103
|
"typescript": "^5.9.3",
|
|
112
|
-
"typescript-eslint": "^8.
|
|
104
|
+
"typescript-eslint": "^8.63.0",
|
|
113
105
|
"vitest": "^4.1.10"
|
|
114
106
|
},
|
|
115
107
|
"packageManager": "pnpm@10.33.1"
|
|
@@ -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{g as w}from"./chunk-H7VXSMJR.js";import{$ as K,L as x,N as P,O,P as v,Q as f,R as S,X as j,Y as I,Z as U,_ as $,aa as g,ba as W,da as B,e as L,ea as M,p as N}from"./chunk-XWWKIJ5J.js";import"./chunk-NCPOPA4A.js";import"./chunk-X3UA5OZL.js";var d=L({module:"llm"});var F=3e3,G=x.object({max_input_tokens:x.preprocess(n=>{if(n==null||n===""||n===!1)return g;let t=Number(n);return Number.isFinite(t)&&t>0?t:g},x.number().positive())});async function et(n){if(n.protocol!=="anthropic")return 0;let t=M(n),o=`${n.base_url.replace(/\/+$/,"")}/v1/models/${encodeURIComponent(n.model)}`,r=new AbortController,i=setTimeout(()=>{r.abort()},F);try{let l=await fetch(o,{method:"GET",headers:{"anthropic-version":"2023-06-01",...t?{"x-api-key":t}:{}},signal:r.signal});if(!l.ok)return g;let y=await l.json(),{success:h,data:k}=await N(G,y);return h?k.max_input_tokens:g}catch(l){return d.error({err:l},"llm operation failed"),g}finally{clearTimeout(i)}}function H(){return!0}function Y(n){let t=[];for(let e of n)if(e.role==="assistant"){let o=[];if(e.thinkingBlocks)for(let r of e.thinkingBlocks)o.push({type:"thinking",thinking:r.thinking,signature:r.signature});if(e.content&&o.push({type:"text",text:e.content}),e.toolUses)for(let r of e.toolUses)o.push({type:"tool_use",id:r.toolUseId,name:r.toolName,input:r.arguments});o.length===0&&o.push({type:"text",text:""}),t.push({role:"assistant",content:o})}else if(e.toolResults&&e.toolResults.length>0){let o=[];for(let r of e.toolResults)o.push({type:"tool_result",tool_use_id:r.toolUseId,is_error:r.isError,content:r.content});t.push({role:"user",content:o})}else{if(t.length===0){t.push({role:"user",content:[{type:"text",text:e.content}]});continue}let o=!1,r=t[t.length-1],i=r.content;r.role==="user"&&(typeof i=="string"||Array.isArray(i)&&i.length>0&&i[0].type==="text")&&(o=!0),o?(typeof i=="string"&&(i=r.content=i.trim().length>0?[{type:"text",text:i}]:[]),i.push({type:"text",text:e.content})):t.push({role:"user",content:[{type:"text",text:e.content}]})}return t}var D=class{client;model;thinking;systemPrompt;maxOutputTokens;contextWindow;constructor(t,e){let o=M(t);if(!o)throw new I("Anthropic API key not found, set ANTHROPIC_API_KEY in .swifty/config.y(a)ml, or via ANTHROPIC_API_KEY env variable.");this.client=new w({apiKey:o,baseURL:t.base_url}),this.model=t.model,this.thinking=t.thinking??!0,this.systemPrompt=e,this.maxOutputTokens=B(t),this.contextWindow=W(t)}setMaxOutputTokens(t){this.maxOutputTokens=t}async*stream(t,e,o){let r=Y(t.getMessages()),i=e.map(c=>{let p=c.input_schema;return{name:c.name,description:c.description,input_schema:{type:"object",properties:p.properties,required:p.required??[]}}});i.length>0&&(i[i.length-1].cache_control={type:"ephemeral"}),q(r);let l={model:this.model,max_tokens:this.maxOutputTokens,stream:!0,system:[{type:"text",text:this.systemPrompt,cache_control:{type:"ephemeral"}}],messages:r,...i.length>0?{tools:i}:{}};this.thinking?H()&&(l.thinking={type:"enabled",budget_tokens:this.maxOutputTokens-1}):l.thinking={type:"enabled",budget_tokens:this.maxOutputTokens-1};let y=0,h=0,k=0,R=0,C="end_turn",b="",T="",A=!1,E=0;try{let c=this.client.messages.stream(l,{...o?{signal:o}:{}}),p="",_="",u="";for await(let a of c)switch(a.type){case"content_block_start":{let s=a.content_block;s.type==="thinking"?(A=!0,b="",T=""):s.type==="tool_use"&&(_=s.id,p=s.name,u="",yield{type:"tool_call_start",toolName:p,toolId:_});break}case"content_block_delta":{let s=a.delta;s.type==="thinking_delta"?(b+=s.thinking,yield{type:"thinking_delta",text:s.thinking}):s.type==="signature_delta"?(d.debug({signature:s.signature},"thinking signature received"),T=s.signature):s.type==="text_delta"?yield{type:"text_delta",text:s.text}:s.type==="input_json_delta"&&(u+=s.partial_json,yield{type:"tool_call_delta",text:s.partial_json});break}case"content_block_stop":{if(A&&(yield{type:"thinking_complete",thinking:b,signature:T},A=!1),p){let s={};if(u)try{let m=JSON.parse(u);s=O(m)?v(m):{[P]:u}}catch(m){d.error({err:m},"llm operation failed"),s={[P]:u}}yield{type:"tool_call_complete",toolId:_,toolName:p,arguments:s},p="",_="",u=""}break}case"message_delta":{a.delta.stop_reason&&(C=a.delta.stop_reason),a.usage.output_tokens&&(h=a.usage.output_tokens);break}case"message_start":{E=performance.now(),y=a.message.usage.input_tokens,h=a.message.usage.output_tokens,k=a.message.usage.cache_read_input_tokens??0,R=a.message.usage.cache_creation_input_tokens??0;break}case"message_stop":{let m=performance.now()-E;d.debug({elapsedMs:m},"message stream complete");break}}yield{type:"stream_end",stopReason:C,usage:{inputTokens:y,outputTokens:h,cacheReadInputTokens:k,cacheCreationInputTokens:R}}}catch(c){throw d.error({err:c},"llm operation failed"),J(c)}}};function q(n){for(let t=n.length-1;t>=0;t--){if(n[t].role!=="user")continue;let e=n[t].content;if(typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0)return;typeof e=="string"&&(e=n[t].content=[{type:"text",text:e}]);let o=e[e.length-1];Reflect.set(o,"cache_control",{type:"ephemeral"})}}function J(n){if(n instanceof w.APIError){if(n.status===413||/prompts?\s+too\s+long/i.test(n.message))return new K(`Prompt too long: ${n.message}`);if(n.status===401)return new I(`Invalid API key: ${n.message}`);if(n.status===429){let t=v(n.headers)["retry-after"],e="Rate Limited";if(t){let o=Number.parseInt(f(t));Number.isNaN(o)&&(e+=", please wait."),e+=`, retry after ${f(o)}s.`}else e+=", please wait.";return new U(e,t?f(t):void 0)}return new j(`Anthropic API error (${f(n.status)}): ${n.message}`)}return new $(`Network error: ${S(n)}`)}export{D as AnthropicClient,Y as buildAnthropicMessages,et as fetchModelContextWindow};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: commit
|
|
3
|
-
description: Analyze git diff and produce a conventional commit
|
|
4
|
-
mode: inline
|
|
5
|
-
allowed_tools:
|
|
6
|
-
- Bash
|
|
7
|
-
- ReadFile
|
|
8
|
-
- Grep
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Task
|
|
12
|
-
|
|
13
|
-
You are creating a git commit for the user.
|
|
14
|
-
|
|
15
|
-
## Steps
|
|
16
|
-
|
|
17
|
-
1. Run `git status` to see what has changed.
|
|
18
|
-
2. Run `git diff` and `git diff --staged` to inspect the actual changes. Read both staged and unstaged.
|
|
19
|
-
3. Decide the commit type from the diff content:
|
|
20
|
-
- `feat`: new user-facing capability
|
|
21
|
-
- `fix`: bug fix
|
|
22
|
-
- `docs`: documentation only
|
|
23
|
-
- `refactor`: code restructuring without behavior change
|
|
24
|
-
- `test`: tests only
|
|
25
|
-
- `chore`: build / tooling / non-source changes
|
|
26
|
-
4. Compose a message in conventional-commit format: `type(scope): description`.
|
|
27
|
-
- Description in English, no trailing period, ≤ 72 chars.
|
|
28
|
-
- Scope optional; use the package or module touched (e.g. `feat(skills): ...`).
|
|
29
|
-
5. Stage files one by one with `git add <path>` — never `git add -A` or `git add .`.
|
|
30
|
-
- Skip `.env`, credentials, secrets, large binaries, build artifacts.
|
|
31
|
-
- If more than 10 files changed, ask the user whether to split into multiple commits before staging.
|
|
32
|
-
6. Create the commit with `git commit -m "<message>"`.
|
|
33
|
-
7. Report the commit hash and the message.
|
|
34
|
-
|
|
35
|
-
## Notes
|
|
36
|
-
|
|
37
|
-
- If the user provided extra context in `$ARGUMENTS`, fold it into the message body (after the title line, blank line, then prose).
|
|
38
|
-
- Do not push.
|
|
39
|
-
- If the working tree is clean, report that and stop.
|
|
40
|
-
|
|
41
|
-
$ARGUMENTS
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: test
|
|
3
|
-
description: Detect project type, run tests, distinguish code bugs from test bugs
|
|
4
|
-
mode: inline
|
|
5
|
-
allowed_tools:
|
|
6
|
-
- Bash
|
|
7
|
-
- ReadFile
|
|
8
|
-
- Grep
|
|
9
|
-
- Glob
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Task
|
|
13
|
-
|
|
14
|
-
You are running the project's test suite and analyzing the results.
|
|
15
|
-
|
|
16
|
-
## Steps
|
|
17
|
-
|
|
18
|
-
1. Detect project type by checking for known config files:
|
|
19
|
-
- `go.mod` → Go project → `go test ./...`
|
|
20
|
-
- `package.json` → Node project → check `scripts.test`, run `npm test` (or `pnpm test` / `yarn test` based on lockfile)
|
|
21
|
-
- `pyproject.toml` / `setup.py` / `requirements.txt` → Python → `pytest` (fall back to `python -m unittest`)
|
|
22
|
-
- `Cargo.toml` → Rust → `cargo test`
|
|
23
|
-
- `pom.xml` / `build.gradle` → Java → `mvn test` / `gradle test`
|
|
24
|
-
- None matched: report and stop.
|
|
25
|
-
2. Run the test command, capture stdout + stderr.
|
|
26
|
-
3. If all tests pass:
|
|
27
|
-
- Report pass count and total runtime.
|
|
28
|
-
- If a coverage tool is available, run it once and call out files with < 50% coverage as candidates for new tests.
|
|
29
|
-
- Suggest 1-3 edge-case scenarios likely not exercised (boundary inputs, error paths, concurrent access).
|
|
30
|
-
4. If tests fail, classify each failure:
|
|
31
|
-
- **Code bug**: the assertion expects behavior X, the code does Y, and Y is wrong → the source code needs the fix.
|
|
32
|
-
- **Test bug**: the assertion expects behavior X, the code correctly does Y, but the test was written assuming X by mistake → the test needs the fix.
|
|
33
|
-
- **Environment**: missing dependency, port conflict, fixture path wrong → not strictly code or test, call it out separately.
|
|
34
|
-
5. For each failure, produce a one-paragraph summary: `[category] file:line — assertion / observation / recommendation`.
|
|
35
|
-
|
|
36
|
-
## Notes
|
|
37
|
-
|
|
38
|
-
- Do not modify any files in this skill — only run tests and report.
|
|
39
|
-
- Run the full suite once. Do not re-run individual tests after triage.
|
|
40
|
-
- $ARGUMENTS, when present, may target a specific package / test name; thread that into the test command.
|
|
41
|
-
|
|
42
|
-
$ARGUMENTS
|
package/dist/chunk-NCPOPA4A.js
DELETED
|
@@ -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{readdirSync as f,statSync as m,unlinkSync as u,existsSync as a}from"fs";import{join as o}from"path";var y=30,g=y*24*60*60*1e3;function c(n){if(!a(n))return 0;let t;try{t=f(n).filter(s=>s.endsWith(".jsonl"))}catch{return 0}let e=Date.now(),r=0;for(let s of t){let i=o(n,s);try{let l=m(i);e-l.mtimeMs>g&&(u(i),r++)}catch{}}return r}function d(n){let t=0;t+=c(o(n,".swifty","logs"));let e=o(n,".swifty","teams");if(!a(e))return t;let r;try{r=f(e)}catch{return t}for(let s of r)t+=c(o(e,s,"logs"));return t}export{d as a};
|