dal-code 1.0.30 → 1.0.32
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/CHANGELOG.md +14 -0
- package/dal-docs/settings.md +11 -0
- package/dist/core/sandbox/index.d.ts +2 -1
- package/dist/core/sandbox/index.js +1 -1
- package/dist/core/sandbox/package-managers.d.ts +19 -0
- package/dist/core/sandbox/package-managers.js +1 -0
- package/dist/core/sandbox/policy.d.ts +1 -0
- package/dist/core/sandbox/policy.js +1 -1
- package/dist/core/sandbox/shell-sandbox.d.ts +14 -0
- package/dist/core/sandbox/shell-sandbox.js +5 -5
- package/dist/dal/host-extensions.d.ts +2 -0
- package/dist/dal/host-extensions.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/main.js +4 -4
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-mcp/src/config.d.ts +2 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/config.js +1 -1
- package/dist/node_modules/@dalcode/dal-mcp/src/index.js +17 -17
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/commands.js +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +20 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/core.js +3 -4
- package/dist/node_modules/@dalcode/dal-rewind/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-skills/package.json +4 -3
- package/dist/node_modules/@dalcode/dal-skills/src/catalog.js +2 -0
- package/dist/node_modules/@dalcode/dal-skills/src/index.js +12 -11
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
- package/dist/node_modules/@earendil-works/chord/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/sdk/rewind.d.ts +1 -1
- package/dist/sdk/rewind.js +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/bundle/chunks/anthropic-messages-AZKHNVAG.js +0 -5
- package/dist/bundle/chunks/anthropic.js +0 -74
- package/dist/bundle/chunks/azure-openai-responses-LA3FYF3J.js +0 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +0 -82
- package/dist/bundle/chunks/chunk-4HEMJ3PG.js +0 -1140
- package/dist/bundle/chunks/chunk-4L3WN2XY.js +0 -1
- package/dist/bundle/chunks/chunk-4UTLMBZZ.js +0 -13
- package/dist/bundle/chunks/chunk-4XT6IQQ6.js +0 -1
- package/dist/bundle/chunks/chunk-5M7W2EDY.js +0 -3
- package/dist/bundle/chunks/chunk-5ULSWE2O.js +0 -43
- package/dist/bundle/chunks/chunk-6CYCI3EJ.js +0 -11
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +0 -1
- package/dist/bundle/chunks/chunk-ABVPQ2YN.js +0 -14
- package/dist/bundle/chunks/chunk-DRQDKNXA.js +0 -1
- package/dist/bundle/chunks/chunk-F5ZABL6Z.js +0 -19
- package/dist/bundle/chunks/chunk-GYI2XXNW.js +0 -10
- package/dist/bundle/chunks/chunk-H3QXYIF7.js +0 -30
- package/dist/bundle/chunks/chunk-HC56T2OZ.js +0 -134
- package/dist/bundle/chunks/chunk-HMFU7ZIF.js +0 -1
- package/dist/bundle/chunks/chunk-JEMNLK2O.js +0 -10
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +0 -1
- package/dist/bundle/chunks/chunk-LPXNMA2W.js +0 -1
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +0 -1
- package/dist/bundle/chunks/chunk-PJACZCIR.js +0 -1
- package/dist/bundle/chunks/chunk-PMRZO46Y.js +0 -1
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +0 -1
- package/dist/bundle/chunks/chunk-PRXLTI3Y.js +0 -81
- package/dist/bundle/chunks/chunk-Q6IMZXWD.js +0 -129
- package/dist/bundle/chunks/chunk-R4YWRKK4.js +0 -7
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +0 -1
- package/dist/bundle/chunks/chunk-S3GGRYIO.js +0 -5
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +0 -1
- package/dist/bundle/chunks/chunk-TRDNDS6A.js +0 -3
- package/dist/bundle/chunks/chunk-USJZMAIR.js +0 -1
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +0 -1
- package/dist/bundle/chunks/chunk-WXULTH2D.js +0 -1
- package/dist/bundle/chunks/chunk-YKF7PQCJ.js +0 -1
- package/dist/bundle/chunks/chunk-YTERFI73.js +0 -1
- package/dist/bundle/chunks/chunk-ZBURYEWF.js +0 -1
- package/dist/bundle/chunks/chunk-ZKDITC7J.js +0 -35
- package/dist/bundle/chunks/cli-2LJMKSUZ.js +0 -50
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-6WEJUIW2.js +0 -1
- package/dist/bundle/chunks/codemode-worker.js +0 -470
- package/dist/bundle/chunks/dist-37IE4EWG.js +0 -10
- package/dist/bundle/chunks/easter-egg-3d-GHWWTBZN.js +0 -1
- package/dist/bundle/chunks/execute-JU22LJZT.js +0 -489
- package/dist/bundle/chunks/github-copilot.js +0 -1
- package/dist/bundle/chunks/google-generative-ai-RFPHNE43.js +0 -1
- package/dist/bundle/chunks/google-vertex-QDNCMHLE.js +0 -1
- package/dist/bundle/chunks/http-proxy-6TR4MP55.js +0 -1
- package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +0 -12
- package/dist/bundle/chunks/image-resize-worker.js +0 -1
- package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +0 -20
- package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +0 -1
- package/dist/bundle/chunks/kimi-coding.js +0 -1
- package/dist/bundle/chunks/lib-TEDK3E5I.js +0 -8
- package/dist/bundle/chunks/llama-cpp-classify-FYN623RH.js +0 -21
- package/dist/bundle/chunks/meta.js +0 -1
- package/dist/bundle/chunks/mistral-conversations-YHX5TRKG.js +0 -4
- package/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +0 -2
- package/dist/bundle/chunks/node-N5BSDOA5.js +0 -15
- package/dist/bundle/chunks/node-TWVVAGPO.js +0 -1
- package/dist/bundle/chunks/openai-chatgpt.js +0 -74
- package/dist/bundle/chunks/openai-codex-responses-UZEMMAYZ.js +0 -9
- package/dist/bundle/chunks/openai-codex.js +0 -74
- package/dist/bundle/chunks/openai-completions-H6WMELZZ.js +0 -6
- package/dist/bundle/chunks/openai-decisions-URHWCZPN.js +0 -4
- package/dist/bundle/chunks/openai-responses-7X65PCAB.js +0 -2
- package/dist/bundle/chunks/openrouter-images-DUPG5DZO.js +0 -1
- package/dist/bundle/chunks/openrouter.js +0 -74
- package/dist/bundle/chunks/pi-messages-YHKPQIHC.js +0 -7
- package/dist/bundle/chunks/radius.js +0 -74
- package/dist/bundle/chunks/runtime-LLITCT4N.js +0 -1
- package/dist/bundle/chunks/src-UK77SYZE.js +0 -3
- package/dist/bundle/chunks/typesafe-system-one-N7PKHI2N.js +0 -1
- package/dist/bundle/chunks/virtual-modules-H32OTUCD.js +0 -1
- package/dist/bundle/chunks/xai.js +0 -1
- package/dist/bundle/cli-runtime.js +0 -2
- package/dist/bundle/cli.js +0 -2
- package/dist/bundle/index.js +0 -1
- package/dist/bundle/rpc-entry.js +0 -2
- package/dist/core/key-id-schema.js +0 -1
- package/dist/core/keybindings-schema.js +0 -1
- package/dist/core/settings-defaults.js +0 -1
- package/dist/core/settings-schema.js +0 -1
- package/dist/modes/interactive/components/daxnuts.js +0 -1
- package/dist/modes/interactive/theme/theme-schema.js +0 -12
- package/dist/modes/interactive/theme/theme-tokens.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-plugins",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
]
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
25
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
26
26
|
"typebox": "1.3.27"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-review",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Code review: a read-only reviewer sub-agent over uncommitted changes, a base branch, a commit, a PR or a supplied diff, returning structured, deduplicated findings. /review in the TUI, dal -p, RPC and the SDK.",
|
|
6
6
|
"type": "module",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
-
"@dalcode/dal-subagent": "1.0.
|
|
22
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
23
|
+
"@dalcode/dal-subagent": "1.0.32",
|
|
24
24
|
"typebox": "1.3.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-rewind",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Git checkpoints for DAL: a snapshot after every turn that changes files, /rewind, Esc+Esc, safe restore, undo. Adapted from pi-rewind 0.5.0 (MIT, arpagon).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.32"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var x=Object.defineProperty;var F=(u,t)=>x(u,"name",{value:t,configurable:!0});var H=Object.defineProperty,s=F((u,t)=>H(u,"name",{value:t,configurable:!0}),"c");import{t as e}from"@dalcode/dal-pi-kit";import{BranchMismatchError as N,
|
|
1
|
+
var x=Object.defineProperty;var F=(u,t)=>x(u,"name",{value:t,configurable:!0});var H=Object.defineProperty,s=F((u,t)=>H(u,"name",{value:t,configurable:!0}),"c");import{t as e}from"@dalcode/dal-pi-kit";import{BranchMismatchError as N,checkpointId as O,createCheckpoint as L,diffCheckpoints as j,git as P,restoreCheckpoint as U}from"./core.js";import{fill as g}from"./ui.js";function b(u){const t=new Date(u),r=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),D=String(t.getSeconds()).padStart(2,"0");return`${r}:${a}:${D}`}F(b,"B"),s(b,"formatTimestamp");function k(u,t,r){const a=b(u.timestamp),D=u.branch&&r&&u.branch!==r?` \u26A0\uFE0F ${u.branch}`:u.branch?` [${u.branch}]`:"",o=`#${t+1} [${a}]${D}`;return u.trigger==="resume"?`${o} ${e("\u4F1A\u8BDD\u5F00\u59CB\u65F6")}`:u.description?`${o} ${u.description}`:u.trigger==="tool"&&u.toolName?`${o} \u2192 ${u.toolName}`:`${o} ${g(e("\u7B2C {turn} \u8F6E"),{turn:u.turnIndex})}`}F(k,"L"),s(k,"formatCheckpointLabel");function w(u){return[...u.checkpoints.values()].sort((t,r)=>r.timestamp-t.timestamp)}F(w,"R"),s(w,"sortedNewestFirst");function v(){return[{label:e("\u6062\u590D\u6587\u4EF6\u548C\u5BF9\u8BDD"),value:"all"},{label:e("\u53EA\u6062\u590D\u6587\u4EF6\uFF08\u4FDD\u7559\u5BF9\u8BDD\uFF09"),value:"files"},{label:e("\u53EA\u6062\u590D\u5BF9\u8BDD\uFF08\u4FDD\u7559\u6587\u4EF6\uFF09"),value:"conversation"},{label:e("\u53D6\u6D88"),value:"cancel"}]}F(v,"O"),s(v,"restoreOptions");const d=s(()=>e("\u21A9 \u64A4\u9500\u4E0A\u4E00\u6B21\u56DE\u9000"),"undoLabel"),q=s(()=>e("\u65E0\u6CD5\u56DE\u9000\uFF1A\u5F53\u524D\u76EE\u5F55\u4E0D\u5728 git \u4ED3\u5E93\u91CC\uFF0C\u6216\u4F1A\u8BDD\u8FD8\u6CA1\u51C6\u5907\u597D"),"notAvailable");async function $(u,t){if(!u.gitAvailable||!u.repoRoot||!u.sessionId){t.ui.notify(q(),"warning");return}const r=w(u).slice(0,25);if(r.length===0){t.ui.notify(e("\u8FD8\u6CA1\u6709\u53EF\u4EE5\u56DE\u9000\u7684\u68C0\u67E5\u70B9"),"warning");return}const a=[],D=await P("rev-parse --abbrev-ref HEAD",u.repoRoot).catch(()=>"unknown"),o=u.redoStack.length>0?u.redoStack[u.redoStack.length-1]:null;o&&a.push(d());for(let i=0;i<r.length;i++)a.push(k(r[i],i,D));const f=await t.ui.select(e("\u8981\u56DE\u5230\u54EA\u4E2A\u68C0\u67E5\u70B9\uFF1F"),a);if(!f){t.ui.notify(e("\u5DF2\u53D6\u6D88\u56DE\u9000"),"info");return}if(f===d()&&o){await m(u,t,o),u.redoStack.pop(),t.ui.notify(e("\u5DF2\u64A4\u9500\uFF1A\u6587\u4EF6\u56DE\u5230\u4E86\u4E0A\u4E00\u6B21\u56DE\u9000\u4E4B\u524D\u7684\u6837\u5B50"),"info");return}const l=a.indexOf(f)-(o?1:0);if(l<0||l>=r.length)return;const B=r[l];let E="";try{const i=await j(u.repoRoot,B.worktreeTreeSha,"HEAD");i&&i!=="(diff unavailable)"&&(E=i.slice(0,2e3))}catch{}if(E&&!await t.ui.confirm(`${g(e("\u68C0\u67E5\u70B9 #{n} \u4E4B\u540E\u6539\u52A8\u8FC7\u7684\u6587\u4EF6\uFF1A"),{n:l+1})}
|
|
2
2
|
|
|
3
|
-
${E}`,e("\u786E\u5B9A\u8981\u6062\u590D\u5417\uFF1F"))){t.ui.notify(e("\u5DF2\u53D6\u6D88\u56DE\u9000"),"info");return}const p
|
|
3
|
+
${E}`,e("\u786E\u5B9A\u8981\u6062\u590D\u5417\uFF1F"))){t.ui.notify(e("\u5DF2\u53D6\u6D88\u56DE\u9000"),"info");return}const p=v(),c=await t.ui.select(e("\u8981\u6062\u590D\u54EA\u4E9B\u5185\u5BB9\uFF1F"),p.map(i=>i.label)),n=p.find(i=>i.label===c)?.value??"cancel";if(n==="cancel"){t.ui.notify(e("\u5DF2\u53D6\u6D88\u56DE\u9000"),"info");return}if((n==="files"||n==="all")&&!await m(u,t,B))return;if(n==="conversation"||n==="all"){const i=t.sessionManager.getBranch().reduce((A,C)=>{if(!C.timestamp)return A;const y=new Date(C.timestamp).getTime();if(!A)return y<=B.timestamp?C:A;const M=new Date(A.timestamp).getTime();return y<=B.timestamp&&y>M?C:A},null);if(i)try{await t.navigateTree(i.id,{summarize:!0})}catch{t.ui.notify(e("\u5BF9\u8BDD\u6CA1\u80FD\u5B8C\u5168\u56DE\u9000\uFF0C\u8BF7\u770B\u4E00\u4E0B\u73B0\u5728\u505C\u5728\u54EA\u6761\u6D88\u606F"),"warning")}}const h=n==="all"?e("\u5DF2\u628A\u6587\u4EF6\u548C\u5BF9\u8BDD\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #{n}"):n==="files"?e("\u5DF2\u628A\u6587\u4EF6\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #{n}"):e("\u5DF2\u628A\u5BF9\u8BDD\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #{n}");t.ui.notify(g(h,{n:l+1}),"info")}F($,"N"),s($,"runRewindFlow");function R(u){return u instanceof N?g(e("\u8FD9\u4E2A\u68C0\u67E5\u70B9\u662F\u5728\u300C{from}\u300D\u5206\u652F\u4E0A\u521B\u5EFA\u7684\uFF0C\u4F60\u73B0\u5728\u5728\u300C{to}\u300D\u5206\u652F\u4E0A\u3002\u8BF7\u5148\u5207\u6362\u56DE\u300C{from}\u300D\uFF0C\u5426\u5219\u6062\u590D\u53EF\u80FD\u5F04\u4E71\u4F60\u7684\u6587\u4EF6\u3002"),{from:u.checkpointBranch,to:u.currentBranch}):u instanceof Error?u.message:String(u)}F(R,"_"),s(R,"describeRestoreError");async function m(u,t,r){if(!u.repoRoot||!u.sessionId)return!1;try{const a=O("before-restore",u.sessionId),D=await L({root:u.repoRoot,id:a,sessionId:u.sessionId,trigger:"before-restore",turnIndex:0});u.redoStack.push(D)}catch{}try{return await U(u.repoRoot,r),!0}catch(a){return t.ui.notify(g(e("\u6062\u590D\u5931\u8D25\uFF1A{reason}"),{reason:R(a)}),"error"),!1}}F(m,"y"),s(m,"performRestore");async function S(u,t,r){if(!u.gitAvailable||!u.repoRoot||!u.sessionId||!r.hasUI)return;const a=r.sessionManager.getEntry(t.entryId),D=a?.timestamp?new Date(a.timestamp).getTime():Date.now(),o=w(u),f=(o.find(h=>h.timestamp<=D)??o[o.length-1])||u.resumeCheckpoint,l=e("\u53EA\u6062\u590D\u5BF9\u8BDD\uFF08\u4FDD\u7559\u6587\u4EF6\uFF09"),B=e("\u6062\u590D\u6587\u4EF6\u548C\u5BF9\u8BDD"),E=e("\u53EA\u6062\u590D\u6587\u4EF6\uFF08\u4FDD\u7559\u5BF9\u8BDD\uFF09"),p=e("\u53D6\u6D88"),c=[l];f&&(c.push(B),c.push(E)),u.redoStack.length>0&&c.push(d()),c.push(p);const n=await r.ui.select(e("\u8981\u4E0D\u8981\u628A\u4EE3\u7801\u4E5F\u6062\u590D\uFF1F"),c);if(!n||n===p)return{cancel:!0};if(n!==l){if(n===d()&&u.redoStack.length>0){const h=u.redoStack.pop();return await m(u,r,h),r.ui.notify(e("\u5DF2\u64A4\u9500\uFF1A\u6587\u4EF6\u56DE\u5230\u4E86\u4E0A\u4E00\u6B21\u56DE\u9000\u4E4B\u524D\u7684\u6837\u5B50"),"info"),{cancel:!0}}if(!f){r.ui.notify(e("\u8FD8\u6CA1\u6709\u53EF\u4EE5\u56DE\u9000\u7684\u68C0\u67E5\u70B9"),"warning");return}if(await m(u,r,f)&&r.ui.notify(e("\u6587\u4EF6\u5DF2\u6062\u590D\u5230\u68C0\u67E5\u70B9\u65F6\u7684\u6837\u5B50"),"info"),n===E)return{skipConversationRestore:!0}}}F(S,"j"),s(S,"handleForkRestore");async function I(u,t,r){if(!u.gitAvailable||!u.repoRoot||!u.sessionId||!r.hasUI)return;const a=r.sessionManager.getEntry(t.preparation.targetId),D=a?.timestamp?new Date(a.timestamp).getTime():Date.now(),o=w(u).find(c=>c.timestamp<=D)??u.resumeCheckpoint,f=e("\u4FDD\u7559\u73B0\u5728\u7684\u6587\u4EF6"),l=e("\u628A\u6587\u4EF6\u4E5F\u6062\u590D\u5230\u90A3\u4E2A\u65F6\u95F4\u70B9"),B=e("\u53D6\u6D88\u8DF3\u8F6C"),E=[f];o&&E.push(l),u.redoStack.length>0&&E.push(d()),E.push(B);const p=await r.ui.select(e("\u8981\u4E0D\u8981\u628A\u4EE3\u7801\u4E5F\u6062\u590D\uFF1F"),E);if(!p||p===B)return{cancel:!0};if(p!==f){if(p===d()&&u.redoStack.length>0){const c=u.redoStack.pop();return await m(u,r,c),r.ui.notify(e("\u5DF2\u64A4\u9500\uFF1A\u6587\u4EF6\u56DE\u5230\u4E86\u4E0A\u4E00\u6B21\u56DE\u9000\u4E4B\u524D\u7684\u6837\u5B50"),"info"),{cancel:!0}}o&&await m(u,r,o)&&r.ui.notify(e("\u6587\u4EF6\u5DF2\u6062\u590D\u5230\u68C0\u67E5\u70B9\u65F6\u7684\u6837\u5B50"),"info")}}F(I,"q"),s(I,"handleTreeRestore");function T(u,t){u.registerCommand("rewind",{description:e("\u628A\u6587\u4EF6\u6539\u52A8\u548C\u5BF9\u8BDD\u56DE\u9000\u5230\u4E4B\u524D\u7684\u67D0\u4E2A\u68C0\u67E5\u70B9"),handler:s(async(r,a)=>{await $(t,a)},"handler")})}F(T,"G"),s(T,"registerCommands");export{S as handleForkRestore,I as handleTreeRestore,T as registerCommands};
|
|
@@ -2,9 +2,12 @@ export declare const ZEROS: string;
|
|
|
2
2
|
export declare const REF_BASE = "refs/pi-checkpoints";
|
|
3
3
|
export declare const LEGACY_REF_BASE = "refs/dal-checkpoints";
|
|
4
4
|
export declare const MAX_UNTRACKED_FILE_SIZE: number;
|
|
5
|
+
export declare const MAX_UNTRACKED_TOTAL_SIZE: number;
|
|
5
6
|
export declare const MAX_UNTRACKED_DIR_FILES = 200;
|
|
7
|
+
export declare const MAX_BEFORE_RESTORE_CHECKPOINTS = 10;
|
|
6
8
|
export declare const DEFAULT_MAX_CHECKPOINTS = 50;
|
|
7
9
|
export declare const IGNORED_DIR_NAMES: Set<string>;
|
|
10
|
+
export declare function isSecretPath(path: string): boolean;
|
|
8
11
|
export declare const MUTATING_TOOLS: Set<string>;
|
|
9
12
|
export interface CheckpointData {
|
|
10
13
|
id: string;
|
|
@@ -23,8 +26,9 @@ export interface CheckpointData {
|
|
|
23
26
|
skippedLargeFiles?: string[];
|
|
24
27
|
skippedLargeDirs?: string[];
|
|
25
28
|
}
|
|
26
|
-
export declare function
|
|
27
|
-
|
|
29
|
+
export declare function gitEnv(extra?: Readonly<Record<string, string>>): NodeJS.ProcessEnv;
|
|
30
|
+
export declare function git(cmd: string | readonly string[], cwd: string, opts?: {
|
|
31
|
+
env?: Readonly<Record<string, string>>;
|
|
28
32
|
input?: string;
|
|
29
33
|
}): Promise<string>;
|
|
30
34
|
export declare const isGitRepo: (cwd: string) => Promise<boolean>;
|
|
@@ -32,6 +36,13 @@ export declare const getRepoRoot: (cwd: string) => Promise<string>;
|
|
|
32
36
|
export declare function shouldIgnoreForSnapshot(path: string): boolean;
|
|
33
37
|
export declare function isLargeFile(root: string, rel: string): boolean;
|
|
34
38
|
export declare function isLargeDirectory(root: string, rel: string): boolean;
|
|
39
|
+
interface SnapshotSelection {
|
|
40
|
+
paths: string[];
|
|
41
|
+
untracked: string[];
|
|
42
|
+
skippedLargeFiles: string[];
|
|
43
|
+
skippedLargeDirs: string[];
|
|
44
|
+
}
|
|
45
|
+
export declare function selectSnapshotPaths(root: string): Promise<SnapshotSelection>;
|
|
35
46
|
export interface CreateCheckpointOpts {
|
|
36
47
|
root: string;
|
|
37
48
|
id: string;
|
|
@@ -53,9 +64,16 @@ export declare function loadCheckpointFromRef(root: string, ref: string): Promis
|
|
|
53
64
|
export declare function listCheckpointRefs(root: string): Promise<string[]>;
|
|
54
65
|
export declare function loadAllCheckpoints(root: string, sessionId?: string): Promise<CheckpointData[]>;
|
|
55
66
|
export declare function deleteCheckpoint(root: string, cp: Pick<CheckpointData, "ref">): Promise<void>;
|
|
67
|
+
export declare function checkpointId(trigger: CheckpointData["trigger"], sessionId: string, options?: {
|
|
68
|
+
turnIndex?: number;
|
|
69
|
+
timestamp?: number;
|
|
70
|
+
}): string;
|
|
71
|
+
export declare function sessionIdFromCheckpointId(id: string): string | null;
|
|
56
72
|
export declare function pruneCheckpoints(root: string, sessionId: string, max?: number): Promise<number>;
|
|
73
|
+
export declare function deleteSessionCheckpoints(root: string, sessionId: string): Promise<number>;
|
|
57
74
|
export declare function pruneOldSessions(root: string, currentSessionId: string, keepPerOldSession?: number): Promise<number>;
|
|
58
75
|
export declare function diffCheckpoints(root: string, fromTree: string, toTree: string): Promise<string>;
|
|
59
76
|
export declare const isSafeId: (id: string) => boolean;
|
|
60
77
|
export declare function sanitizeForRef(s: string): string;
|
|
61
78
|
export declare function findClosestCheckpoint(checkpoints: CheckpointData[], targetTs: number): CheckpointData | undefined;
|
|
79
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),
|
|
3
|
-
`).filter(Boolean)
|
|
4
|
-
`).filter(Boolean)){const i=k(n);!i||e.has(i)||(e.add(i),r.push(n))}}return r}u(C,"B"),l(C,"listCheckpointRefs");async function B(t,e){const r=await C(t);return(await Promise.all(r.map(s=>N(t,s)))).filter(s=>s!==null&&(!e||s.sessionId===e))}u(B,"pt"),l(B,"loadAllCheckpoints");async function A(t,e){await f(`update-ref -d ${e.ref}`,t).catch(()=>{})}u(A,"U"),l(A,"deleteCheckpoint");async function ie(t,e,r=W){const s=await B(t,e);s.sort((i,a)=>i.timestamp-a.timestamp);const o=s.filter(i=>i.trigger!=="before-restore");if(o.length<=r)return 0;const n=o.slice(0,o.length-r);for(const i of n)await A(t,i);return n.length}u(ie,"Et"),l(ie,"pruneCheckpoints");async function se(t,e,r=0){const s=await C(t);let o=0;const n=new Map;for(const i of s){const a=k(i);if(!a)continue;const d=a.split("-");let c=null;for(let h=0;h<d.length-5;h++){const p=d.slice(h+1,h+6).join("-");if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(p)){c=p;break}}!c||c===e||(n.has(c)||n.set(c,[]),n.get(c).push(i))}for(const[i,a]of n){a.sort((c,h)=>(k(c)??c).localeCompare(k(h)??h));const d=r>0?a.slice(0,Math.max(0,a.length-r)):a;for(const c of d)await A(t,{ref:c}).catch(()=>{}),o++}return o}u(se,"Ct"),l(se,"pruneOldSessions");async function ae(t,e,r){try{return await f(`diff-tree --stat --no-commit-id ${e} ${r}`,t)}catch{return"(diff unavailable)"}}u(ae,"_t"),l(ae,"diffCheckpoints");const ve=l(t=>/^[\w-]+$/.test(t),"isSafeId");function oe(t){return t.replace(/[^a-zA-Z0-9-]/g,"_")}u(oe,"vt"),l(oe,"sanitizeForRef");function ce(t,e){if(t.length!==0)return t.reduce((r,s)=>{const o=Math.abs(r.timestamp-e),n=Math.abs(s.timestamp-e);return s.timestamp<=e&&r.timestamp>e?s:r.timestamp<=e&&s.timestamp>e?r:n<o?s:r})}u(ce,"At"),l(ce,"findClosestCheckpoint");export{te as BranchMismatchError,W as DEFAULT_MAX_CHECKPOINTS,J as IGNORED_DIR_NAMES,j as LEGACY_REF_BASE,v as MAX_UNTRACKED_DIR_FILES,M as MAX_UNTRACKED_FILE_SIZE,Ee as MUTATING_TOOLS,b as REF_BASE,T as ZEROS,k as checkpointIdFromRef,ee as createCheckpoint,A as deleteCheckpoint,ae as diffCheckpoints,ce as findClosestCheckpoint,Te as getRepoRoot,f as git,_e as isGitRepo,K as isLargeDirectory,Z as isLargeFile,ve as isSafeId,C as listCheckpointRefs,B as loadAllCheckpoints,N as loadCheckpointFromRef,ie as pruneCheckpoints,se as pruneOldSessions,re as restoreCheckpoint,oe as sanitizeForRef,S as shouldIgnoreForSnapshot};
|
|
1
|
+
var ke=Object.defineProperty;var l=(t,e)=>ke(t,"name",{value:e,configurable:!0});var Ie=Object.defineProperty,a=l((t,e)=>Ie(t,"name",{value:e,configurable:!0}),"o");import{spawn as _e}from"child_process";import{readdirSync as Se,statSync as O}from"fs";import{mkdtemp as ye,rm as $e}from"fs/promises";import{tmpdir as Ee}from"os";import{join as S}from"path";const T="0".repeat(40),x="refs/pi-checkpoints",q="refs/dal-checkpoints",Y=[x,q],N=5*1024*1024,Q=25*1024*1024,C=200,B=10,V=50,ee=new Set(["node_modules",".venv","venv","env",".env","dist","build",".pytest_cache",".mypy_cache",".cache",".tox","__pycache__"]),Te=new Set([".ssh",".gnupg",".aws",".azure",".kube",".docker"]),Ce=new Set([".netrc","_netrc",".npmrc",".yarnrc",".yarnrc.yml",".pypirc",".pgpass",".htpasswd",".git-credentials",".dockercfg","kubeconfig","credentials","id_rsa","id_dsa","id_ecdsa","id_ed25519"]),ve=[/^\.env(\..*)?$/i,/\.env$/i,/^id_(rsa|dsa|ecdsa|ed25519)(\..*)?$/i,/\.(pem|key|p12|pfx|jks|keystore|p8|ppk|kdbx|gpg|tfstate|tfvars)$/i,/\.tfstate\.backup$/i,/^credentials?\..*$/i,/^secrets?(\..*)?$/i,/^client_secret.*\.json$/i,/^service[-_]?account.*\.json$/i];function v(t){const e=t.split(/[/\\]/).filter(Boolean),s=e.at(-1);return s?e.slice(0,-1).some(r=>Te.has(r))?!0:Ce.has(s.toLowerCase())||ve.some(r=>r.test(s)):!1}l(v,"O"),a(v,"isSecretPath");const Fe=new Set(["write","edit","bash"]);function G(t={}){const e={};for(const[s,r]of Object.entries(process.env))s.toUpperCase().startsWith("GIT_")||(e[s]=r);return{...e,...t,GIT_TERMINAL_PROMPT:"0"}}l(G,"ae"),a(G,"gitEnv");function d(t,e,s={}){return new Promise((r,i)=>{const n=typeof t=="string"?te(t):[...t],o=_e("git",n,{cwd:e,env:G(s.env),stdio:["pipe","pipe","pipe"]});let h="",m="";o.stdout.on("data",u=>{h+=u}),o.stderr.on("data",u=>{m+=u}),o.on("close",u=>{u===0?r(h.trim()):i(new Error(m||`git ${n[0]} failed (code ${u})`))}),o.on("error",i),s.input&&o.stdin?(o.stdin.write(s.input),o.stdin.end()):o.stdin&&o.stdin.end()})}l(d,"f"),a(d,"git");function te(t){const e=[];let s="",r=!1,i=!1;for(let n=0;n<t.length;n++){const o=t[n];o==="'"&&!i?r=!r:o==='"'&&!r?i=!i:o===" "&&!r&&!i?s&&(e.push(s),s=""):s+=o}return s&&e.push(s),e}l(te,"ce"),a(te,"parseArgs");const Re=a(t=>d("rev-parse --is-inside-work-tree",t).then(()=>!0).catch(()=>!1),"isGitRepo"),Ae=a(t=>d("rev-parse --show-toplevel",t),"getRepoRoot");function F(t){return t.split(/[/\\]/).some(e=>ee.has(e))}l(F,"B"),a(F,"shouldIgnoreForSnapshot");function se(t,e){try{const s=O(S(t,e));return s.isFile()&&s.size>N}catch{return!1}}l(se,"Ce"),a(se,"isLargeFile");function re(t,e){try{const s=S(t,e);return O(s).isDirectory()?ne(s,C)>=C:!1}catch{return!1}}l(re,"De"),a(re,"isLargeDirectory");function ne(t,e){let s=0;const r=a(i=>{if(!(s>e))try{for(const n of Se(i,{withFileTypes:!0})){if(s>e)return;n.isDirectory()?r(S(i,n.name)):n.isFile()&&s++}}catch{}},"walk");return r(t),s}l(ne,"le"),a(ne,"countFiles");function I(t){let e=t.replace(/\\/g,"/");return e.startsWith("./")&&(e=e.slice(2)),e.replace(/\/$/,"")}l(I,"S"),a(I,"normalizeGitPath");function P(t,e){if(!e||e==="."||t===e)return!0;const s=e.endsWith("/")?e:`${e}/`;return t.startsWith(s)}l(P,"z"),a(P,"isPathWithin");function z(t,e){for(const s of e)if(P(t,s))return!0;return!1}l(z,"U"),a(z,"isPathWithinAny");async function U(t){const e=await d(["status","--porcelain=2","-z","--untracked-files=all"],t).catch(()=>""),s=[],r=[];let i=!1;for(const c of e.split("\0").filter(Boolean)){if(i){const p=I(c);p&&s.push(p),i=!1;continue}const f=c[0];if(f==="?"){const p=I(c.slice(2));p&&!F(p)&&!v(p)&&r.push(p)}else if(f==="1"){const p=R(c,8);p&&s.push(I(p))}else if(f==="2"){const p=R(c,9);p&&s.push(I(p)),i=!0}else if(f==="u"){const p=R(c,10);p&&s.push(I(p))}}if(r.length===0)return{paths:[...new Set(s)],untracked:[],skippedLargeFiles:[],skippedLargeDirs:[]};const n=(await d(["ls-files","-z","--others","--exclude-standard","--directory","--no-empty-directory"],t).catch(()=>"")).split("\0").filter(c=>c.endsWith("/")).map(I).filter(c=>c.length>0),o=new Map;for(const c of r){let f=n.find(p=>P(c,p));if(!f){const p=c.split("/");f=p.length>1?p.slice(0,-1).join("/"):"."}o.set(f,(o.get(f)??0)+1)}const h=[...o.entries()].filter(([c,f])=>c!=="."&&f>=C).map(([c])=>c).sort(),m=new Set(h),u=[];for(const c of r){if(z(c,m))continue;let f=0;try{const p=O(S(t,c));f=p.isFile()?p.size:0}catch{f=0}u.push({path:c,size:f})}u.sort((c,f)=>c.size-f.size||c.path.localeCompare(f.path));const w=[],g=[];let k=0;for(const{path:c,size:f}of u){if(f>N||k+f>Q){g.push(c);continue}k+=f,w.push(c)}return w.sort(),g.sort(),{paths:[...new Set([...s,...w])],untracked:w,skippedLargeFiles:g,skippedLargeDirs:h}}l(U,"pe"),a(U,"selectSnapshotPaths");function R(t,e){let s=0;for(let r=0;r<t.length;r++)if(t[r]===" "&&++s===e){const i=t.slice(r+1);return i.length>0?i:null}return null}l(R,"T"),a(R,"extractField");async function ie(t){const{root:e,id:s,sessionId:r,trigger:i,turnIndex:n,toolName:o,description:h}=t,m=Date.now(),u=new Date(m).toISOString(),w=await d("rev-parse HEAD",e).catch(()=>T),g=await d("rev-parse --abbrev-ref HEAD",e).catch(()=>"unknown"),k=await d("write-tree",e),c=await ye(S(Ee(),"dal-rewind-")),f=S(c,"index");try{const p={GIT_INDEX_FILE:f},$=await U(e),{skippedLargeFiles:L,skippedLargeDirs:M}=$,J=$.untracked;w!==T&&await d(["read-tree",w],e,{env:p});const K=100;for(let E=0;E<$.paths.length;E+=K)await d(["add","--all","--",...$.paths.slice(E,E+K)],e,{env:p});const b=await d("write-tree",e,{env:p}),ge=[`dal-rewind:${s}`,`sessionId ${r}`,`trigger ${i}`,`turn ${n}`,o?`toolName ${o}`:null,h?`description ${h}`:null,`branch ${g}`,`head ${w}`,`index-tree ${k}`,`worktree-tree ${b}`,`created ${u}`,`untracked ${JSON.stringify(J)}`,`largeFiles ${JSON.stringify(L)}`,`largeDirs ${JSON.stringify(M)}`].filter(Boolean).join(`
|
|
2
|
+
`),me={GIT_AUTHOR_NAME:"dal-rewind",GIT_AUTHOR_EMAIL:"rewind@dal",GIT_AUTHOR_DATE:u,GIT_COMMITTER_NAME:"dal-rewind",GIT_COMMITTER_EMAIL:"rewind@dal",GIT_COMMITTER_DATE:u},we=await d(`commit-tree ${b}`,e,{input:ge,env:me}),Z=`${x}/${s}`;return await d(`update-ref ${Z} ${we}`,e),{id:s,ref:Z,sessionId:r,trigger:i,turnIndex:n,toolName:o,description:h,branch:g,headSha:w,indexTreeSha:k,worktreeTreeSha:b,timestamp:m,preexistingUntrackedFiles:J,skippedLargeFiles:L.length>0?L:void 0,skippedLargeDirs:M.length>0?M:void 0}}finally{await $e(c,{recursive:!0,force:!0}).catch(()=>{})}}l(ie,"$e"),a(ie,"createCheckpoint");class ae extends Error{static{l(this,"ue")}static{a(this,"BranchMismatchError")}checkpointBranch;currentBranch;constructor(e,s){super(`Branch mismatch: checkpoint was created on "${e}" but HEAD is on "${s}"`),this.name="BranchMismatchError",this.checkpointBranch=e,this.currentBranch=s}}async function oe(t,e){if(e.branch){const s=await d("rev-parse --abbrev-ref HEAD",t).catch(()=>"unknown");if(s!==e.branch)throw new ae(e.branch,s)}e.headSha!==T&&await d(`reset --hard ${e.headSha}`,t),await d(`read-tree --reset -u ${e.worktreeTreeSha}`,t),await ce(t,e.preexistingUntrackedFiles||[],e.skippedLargeFiles||[],e.skippedLargeDirs||[]),await d(`read-tree --reset ${e.indexTreeSha}`,t)}l(oe,"Te"),a(oe,"restoreCheckpoint");async function ce(t,e,s,r){const i=await d(["ls-files","--others","--exclude-standard","-z"],t).catch(()=>"");if(!i)return;const n=i.split("\0").filter(Boolean);if(n.length===0)return;const o=new Set(e),h=new Set(s),m=new Set(r),u=n.filter(g=>!(o.has(g)||F(g)||v(g)||h.has(g)||z(g,m)));if(u.length===0)return;const w=100;for(let g=0;g<u.length;g+=w)await d(["clean","-f","-q","--",...u.slice(g,g+w)],t).catch(()=>{})}l(ce,"fe"),a(ce,"safeClean");function _(t){for(const e of Y)if(t.startsWith(`${e}/`))return t.slice(e.length+1);return null}l(_,"x"),a(_,"checkpointIdFromRef");async function A(t,e){const s=_(e);if(!s)return null;try{const r=await d(`rev-parse --verify ${e}`,t),i=await d(`cat-file commit ${r}`,t),n=a(k=>i.match(new RegExp(`^${k} (.+)$`,"m"))?.[1]?.trim(),"get"),o=n("sessionId"),h=n("turn"),m=n("head"),u=n("index-tree"),w=n("worktree-tree");if(!o||!h||!m||!u||!w)return null;const g=a(k=>{const c=n(k);if(c)try{const f=JSON.parse(c);return f.length>0?f:void 0}catch{return}},"parseJson");return{id:s,ref:e,sessionId:o,trigger:n("trigger")||"turn",turnIndex:parseInt(h,10),toolName:n("toolName"),description:n("description"),branch:n("branch")||"unknown",headSha:m,indexTreeSha:u,worktreeTreeSha:w,timestamp:n("created")?new Date(n("created")).getTime():0,preexistingUntrackedFiles:g("untracked"),skippedLargeFiles:g("largeFiles"),skippedLargeDirs:g("largeDirs")}}catch{return null}}l(A,"G"),a(A,"loadCheckpointFromRef");async function D(t){const e=new Set,s=[];for(const r of Y){let i="";try{i=await d(`for-each-ref --format=%(refname) ${r}/`,t)}catch{continue}for(const n of i.split(`
|
|
3
|
+
`).filter(Boolean)){const o=_(n);!o||e.has(o)||(e.add(o),s.push(n))}}return s}l(D,"H"),a(D,"listCheckpointRefs");async function j(t,e){const s=await D(t);return(await Promise.all(s.map(r=>A(t,r)))).filter(r=>r!==null&&(!e||r.sessionId===e))}l(j,"de"),a(j,"loadAllCheckpoints");async function y(t,e){await d(`update-ref -d ${e.ref}`,t).catch(()=>{})}l(y,"R"),a(y,"deleteCheckpoint");function le(t,e,s={}){const r=[t,X(e)];return s.turnIndex!==void 0&&r.push(s.turnIndex),r.push(s.timestamp??Date.now()),r.join("-")}l(le,"Re"),a(le,"checkpointId");const De=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function H(t){const e=t.split("-");for(let s=0;s+6<=e.length;s++){const r=e.slice(s+1,s+6).join("-");if(De.test(r))return r}return null}l(H,"he"),a(H,"sessionIdFromCheckpointId");async function W(t){const e=new Map;for(const s of await D(t)){const r=_(s);if(!r)continue;const i=H(r)??(await A(t,s))?.sessionId??null;if(!i)continue;const n=e.get(i)??[];n.push(s),e.set(i,n)}return e}l(W,"j"),a(W,"checkpointRefsBySession");async function pe(t,e,s=V){const r=await j(t,e);r.sort((h,m)=>h.timestamp-m.timestamp);const i=r.filter(h=>h.trigger!=="before-restore"),n=r.filter(h=>h.trigger==="before-restore"),o=[...i.length>s?i.slice(0,i.length-s):[],...n.length>B?n.slice(0,n.length-B):[]];for(const h of o)await y(t,h);return o.length}l(pe,"ve"),a(pe,"pruneCheckpoints");async function he(t,e){const s=(await W(t)).get(e)??[];for(const r of s)await y(t,{ref:r});return s.length}l(he,"Ae"),a(he,"deleteSessionCheckpoints");async function fe(t,e,s=0){let r=0;for(const[i,n]of await W(t)){if(i===e)continue;n.sort((h,m)=>(_(h)??h).localeCompare(_(m)??m));const o=s>0?n.slice(0,Math.max(0,n.length-s)):n;for(const h of o)await y(t,{ref:h}).catch(()=>{}),r++}return r}l(fe,"Fe"),a(fe,"pruneOldSessions");async function de(t,e,s){try{return await d(`diff-tree --stat --no-commit-id ${e} ${s}`,t)}catch{return"(diff unavailable)"}}l(de,"Le"),a(de,"diffCheckpoints");const Le=a(t=>/^[\w-]+$/.test(t),"isSafeId");function X(t){return t.replace(/[^a-zA-Z0-9-]/g,"_")}l(X,"me"),a(X,"sanitizeForRef");function ue(t,e){if(t.length!==0)return t.reduce((s,r)=>{const i=Math.abs(s.timestamp-e),n=Math.abs(r.timestamp-e);return r.timestamp<=e&&s.timestamp>e?r:s.timestamp<=e&&r.timestamp>e?s:n<i?r:s})}l(ue,"Pe"),a(ue,"findClosestCheckpoint");export{ae as BranchMismatchError,V as DEFAULT_MAX_CHECKPOINTS,ee as IGNORED_DIR_NAMES,q as LEGACY_REF_BASE,B as MAX_BEFORE_RESTORE_CHECKPOINTS,C as MAX_UNTRACKED_DIR_FILES,N as MAX_UNTRACKED_FILE_SIZE,Q as MAX_UNTRACKED_TOTAL_SIZE,Fe as MUTATING_TOOLS,x as REF_BASE,T as ZEROS,le as checkpointId,_ as checkpointIdFromRef,ie as createCheckpoint,y as deleteCheckpoint,he as deleteSessionCheckpoints,de as diffCheckpoints,ue as findClosestCheckpoint,Ae as getRepoRoot,d as git,G as gitEnv,Re as isGitRepo,re as isLargeDirectory,se as isLargeFile,Le as isSafeId,v as isSecretPath,D as listCheckpointRefs,j as loadAllCheckpoints,A as loadCheckpointFromRef,pe as pruneCheckpoints,fe as pruneOldSessions,oe as restoreCheckpoint,X as sanitizeForRef,U as selectSnapshotPaths,H as sessionIdFromCheckpointId,F as shouldIgnoreForSnapshot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=Object.defineProperty;var a=(t,e)=>y(t,"name",{value:e,configurable:!0});var _=Object.defineProperty,d=a((t,e)=>_(t,"name",{value:e,configurable:!0}),"c");import{handleForkRestore as R,handleTreeRestore as S,registerCommands as b}from"./commands.js";import{checkpointId as I,createCheckpoint as g,DEFAULT_MAX_CHECKPOINTS as C,deleteCheckpoint as x,getRepoRoot as A,isGitRepo as M,loadAllCheckpoints as p,MUTATING_TOOLS as m,pruneCheckpoints as v,pruneOldSessions as U}from"./core.js";import{createInitialState as D,resetState as $}from"./state.js";import{clearStatus as N,updateStatus as u}from"./ui.js";function h(t,e){return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}a(h,"I"),d(h,"truncate");function T(t,e){if(!e)return t;switch(t){case"write":return`write \u2192 ${e.path||"?"}`;case"edit":return`edit \u2192 ${e.path||"?"}`;case"bash":return`bash: ${h(String(e.command||""),50)}`;default:return t}}a(T,"P"),d(T,"describeToolCall");function k(t){const e=D();b(t,e);async function f(o){if($(e),e.gitAvailable=await M(o.cwd),!e.gitAvailable){o.hasUI&&N(o);return}e.repoRoot=await A(o.cwd),e.sessionId=o.sessionManager.getSessionId();try{const s=await p(e.repoRoot,e.sessionId);for(const n of s)e.checkpoints.set(n.id,n)}catch{}try{const s=I("resume",e.sessionId),n=await g({root:e.repoRoot,id:s,sessionId:e.sessionId,trigger:"resume",turnIndex:0});e.resumeCheckpoint=n,e.checkpoints.set(n.id,n),e.lastWorktreeTree=n.worktreeTreeSha}catch{}if(o.hasUI&&u(e,o),e.repoRoot&&e.sessionId){const s=e.repoRoot,n=e.sessionId;U(s,n).then(r=>{r>0&&p(s,n).then(l=>{e.checkpoints.clear();for(const c of l)e.checkpoints.set(c.id,c);o.hasUI&&u(e,o)}).catch(()=>{})}).catch(()=>{})}}a(f,"g"),d(f,"initSession"),t.on("session_start",async(o,s)=>{if(o.reason==="fork"){if(!e.gitAvailable)return;e.sessionId=s.sessionManager.getSessionId();return}await f(s)}),t.on("before_agent_start",async(o,s)=>{e.currentPrompt=h(String(o.prompt||""),60),e.turnToolDescriptions=[],e.turnHadMutations=!1}),t.on("turn_start",async(o,s)=>{e.currentTurnIndex=o.turnIndex}),t.on("tool_call",async(o,s)=>{if(m.has(o.toolName)){const n=T(o.toolName,o.input);e.pendingToolInfo.set(o.toolCallId,n)}}),t.on("tool_execution_end",async(o,s)=>{if(!m.has(o.toolName))return;e.turnHadMutations=!0;const n=e.pendingToolInfo.get(o.toolCallId)||o.toolName;e.pendingToolInfo.delete(o.toolCallId),e.turnToolDescriptions.push(n)}),t.on("turn_end",async(o,s)=>{if(!(!e.gitAvailable||e.failed)&&!(!e.repoRoot||!e.sessionId)){if(e.turnHadMutations){const n=e.currentPrompt?`"${e.currentPrompt}"`:"",r=e.turnToolDescriptions.join(", "),l=n&&r?`${n} \u2192 ${r}`:n||r||void 0;e.pending&&await e.pending,e.pending=(async()=>{try{const c=Date.now(),w=I("turn",e.sessionId,{turnIndex:e.currentTurnIndex,timestamp:c}),i=await g({root:e.repoRoot,id:w,sessionId:e.sessionId,trigger:"tool",turnIndex:e.currentTurnIndex,description:l});if(e.lastWorktreeTree&&i.worktreeTreeSha===e.lastWorktreeTree){await x(e.repoRoot,i);return}e.checkpoints.set(i.id,i),e.lastWorktreeTree=i.worktreeTreeSha,s.hasUI&&u(e,s)}catch{}})()}e.pending&&await e.pending;try{if(await v(e.repoRoot,e.sessionId,C)>0){const n=await p(e.repoRoot,e.sessionId);e.checkpoints.clear();for(const r of n)e.checkpoints.set(r.id,r);s.hasUI&&u(e,s)}}catch{}e.turnToolDescriptions=[],e.turnHadMutations=!1}}),t.on("session_before_fork",async(o,s)=>R(e,o,s)),t.on("session_before_tree",async(o,s)=>S(e,o,s)),t.on("session_shutdown",async()=>{e.pending&&await e.pending})}a(k,"U"),d(k,"default");export{k as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-router",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
29
|
-
"@dalcode/deepailab": "1.0.
|
|
30
|
-
"@earendil-works/pi-tui": "^1.0.
|
|
28
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
29
|
+
"@dalcode/deepailab": "1.0.32",
|
|
30
|
+
"@earendil-works/pi-tui": "^1.0.32"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@earendil-works/pi-coding-agent": "^1.0.0"
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-skills",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
9
|
+
"./catalog": "./src/catalog.js",
|
|
9
10
|
"./client": "./src/client.js",
|
|
10
11
|
"./package.json": "./package.json",
|
|
11
12
|
"./packages": "./src/packages.js"
|
|
@@ -19,8 +20,8 @@
|
|
|
19
20
|
]
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
-
"@dalcode/deepailab": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
24
|
+
"@dalcode/deepailab": "1.0.32",
|
|
24
25
|
"typebox": "1.3.7"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var T=Object.defineProperty;var s=(u,e)=>T(u,"name",{value:e,configurable:!0});var b=Object.defineProperty,r=s((u,e)=>b(u,"name",{value:e,configurable:!0}),"l");import{t as n}from"@dalcode/dal-pi-kit";const _=["product","cloud","project","user"];function f(u){return u==="temporary"?"product":u==="project"?"project":"user"}s(f,"S"),r(f,"hostTier");function m(u,e){const t=new Set,o=[];for(const F of u){const i=F.name.toLowerCase();t.has(i)||(t.add(i),o.push({name:F.name,description:F.description,source:"local",tier:f(F.scope),filePath:F.filePath,baseDir:F.baseDir}))}for(const F of e){const i=F.id.toLowerCase(),l=F.name.toLowerCase();t.has(i)||t.has(l)||(t.add(i),t.add(l),o.push({name:F.id,title:F.name!==F.id?F.name:void 0,description:F.description,source:"cloud",tier:"cloud",cloudId:F.id}))}return o}s(m,"_"),r(m,"mergeSkills");function p(u,e){const t=e.trim().toLowerCase();if(t.length!==0)return u.find(o=>o.name.toLowerCase()===t||o.title?.toLowerCase()===t)??u.find(o=>o.name.toLowerCase().includes(t)||o.title?.toLowerCase().includes(t))}s(p,"w"),r(p,"resolveSkill");function d(){return n("\u4EFB\u52A1\u7B26\u5408\u67D0\u4E2A\u6280\u80FD\u7684\u300C\u4F55\u65F6\u4F7F\u7528\u300D\u65F6\uFF0C\u5148\u7528 skill \u5DE5\u5177\u52A0\u8F7D\u5B83\uFF0C\u518D\u56DE\u7B54\u6216\u52A8\u624B\uFF1B\u7528\u6237\u70B9\u540D\u67D0\u4E2A\u6280\u80FD\u65F6\u5FC5\u987B\u4F7F\u7528\u5B83\uFF1B\u4E0D\u8981\u53EA\u63D0\u5230\u6280\u80FD\u800C\u4E0D\u52A0\u8F7D\u3002")}s(d,"k"),r(d,"skillRule");const B=6e3,h=12e3,L=200;function S(u,e){const t=u.description.replace(/\s+/g," ").trim(),o=t.length>e?`${t.slice(0,e-1)}\u2026`:t;return`- ${u.title?`${u.name} (${u.title})`:u.name}: ${o}`}s(S,"E"),r(S,"listingLine");function k(u,e){return`${u==="product"?n("\u5185\u7F6E\u6280\u80FD"):u==="cloud"?n("\u4E91\u7AEF\u6280\u80FD"):u==="project"?n("\u9879\u76EE\u6280\u80FD"):n("\u4E2A\u4EBA\u6280\u80FD")}${n("\u53E6\u6709\u672A\u5217\u51FA\u7684\uFF0C\u6570\u91CF\uFF1A")}${e}${n("\u3002\u7528 query \u641C\u7D22\u3002")}`}s(k,"D"),r(k,"omittedLine");function C(u,e={}){const t=e.budgetChars??B,o=e.guaranteedChars??h,F=e.maxDescriptionChars??L,i=[],l=[];let E=0;for(const a of _){const w=a==="product"||a==="cloud"?o:t;let c=0;for(const A of u){if(A.tier!==a)continue;const D=S(A,F);if(c>0||E+D.length+1>w){c++;continue}i.push(D),E+=D.length+1}c>0&&l.push(k(a,c))}return[...i,...l]}s(C,"L"),r(C,"listSkills");function g(u,e={}){return[d(),n("\u52A0\u8F7D\u6280\u80FD\uFF1A\u4E13\u9879\u4EFB\u52A1\u7684\u64CD\u4F5C\u6307\u5F15\u3002\u8FD9\u662F\u4F7F\u7528\u6280\u80FD\u7684\u552F\u4E00\u5165\u53E3\uFF0C\u4E0D\u8981\u7528 read \u6216 bash \u53BB\u8BFB\u6280\u80FD\u6587\u4EF6\u3002"),n("\u7528 name \u52A0\u8F7D\u67D0\u4E2A\u6280\u80FD\u7684\u5168\u6587\u5E76\u7167\u505A\uFF1B\u7528 query \u6309\u4EFB\u52A1\u63CF\u8FF0\u641C\u7D22\u672A\u5217\u51FA\u7684\u6280\u80FD\u3002"),n('\u7528\u6237\u6D88\u606F\u91CC\u5DF2\u7ECF\u6709 <skill name="\u2026"> \u5757\u65F6\uFF0C\u8BE5\u6280\u80FD\u5DF2\u52A0\u8F7D\uFF0C\u76F4\u63A5\u7167\u505A\uFF0C\u4E0D\u5FC5\u518D\u6B21\u8C03\u7528\u3002'),"",n("\u53EF\u7528\u6280\u80FD\uFF08name: \u4F55\u65F6\u4F7F\u7528\uFF09\uFF1A"),...C(u,e)].join(`
|
|
2
|
+
`)}s(g,"A"),r(g,"describeSkillTool");export{h as DEFAULT_GUARANTEED_CHARS,B as DEFAULT_LISTING_BUDGET_CHARS,L as DEFAULT_MAX_DESCRIPTION_CHARS,g as describeSkillTool,C as listSkills,m as mergeSkills,p as resolveSkill,d as skillRule};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}C(T,"Q"),r(T,"describeTool");function v(n){return n.length===0?e("\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD\u3002\u53EF\u4EE5\u6362\u4E2A\u5173\u952E\u8BCD\uFF0C\u6216\u4E0D\u5E26 query \u8C03\u7528\u67E5\u770B\u53EF\u7528\u6280\u80FD\u3002"):[e("\u6700\u76F8\u5173\u7684\u6280\u80FD\uFF08\u7528 name \u52A0\u8F7D\u5168\u6587\uFF09\uFF1A"),...n.map(o=>`- ${o.name} [${o.source}]: ${o.description}`)].join(`
|
|
3
|
-
`)}C(v,"I"),r(v,"renderMatches");const I=Symbol.for("dalcode.skills.search");function w(n){globalThis[I]=n}C(w,"T"),r(w,"publishSkillSearch");function O(n){const o=z(),S=new Map;let E=[],$=!0;const q=r(a=>{const u=a.trim().toLowerCase();if(u.length!==0)return E.find(t=>t.name.toLowerCase()===u||t.id.toLowerCase()===u)??E.find(t=>t.name.toLowerCase().includes(u))},"resolve");n.on("session_start",async(a,u)=>{w(void 0);let t;try{t=await u.modelRegistry?.getApiKeyForProvider?.("deepailab")}catch{t=void 0}if(!t)return;const F=r(s=>{const i=`${e("\u65E0\u6CD5\u83B7\u53D6\u4E91\u7AEF\u6280\u80FD\u5217\u8868")}\uFF1A${s}`;u.hasUI?u.ui.notify(i,"warning"):process.stderr.write(`${i}
|
|
4
|
-
`)},"reportFailure");if($=n.isToolAllowed("skill"),$){const s=`skills-index-${R(t)}`,i=U(s,P),d=(async()=>{try{const l=await J(o.apiBase,t);if(l==="not-modified"){F(e("\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u610F\u5916\u7684 304"));return}E=l.skills;try{H(s,l.skills)}catch{}}catch(l){const h=l instanceof Error&&l.name==="AbortError"?e("\u8BF7\u6C42\u8D85\u65F6"):String(l);F(h)}})();i?E=i.value:await d}X(o.apiBase,t).then(s=>{const i=Z(x());m=Y(s,i),u.hasUI&&uu(x(),m)&&u.ui.notify(`${e("\u8D26\u53F7\u91CC\u6709")}${m.length}${e(" \u4E2A\u6269\u5C55\u672C\u673A\u8FD8\u6CA1\u88C5\uFF0C/install \u53EF\u76F4\u63A5\u5B89\u88C5\u3002")}`,"info")}).catch(()=>{});const A=r(()=>({includeProject:u.isProjectTrusted()}),"localOptions");if(E.length===0&&b(u.cwd,A()).length===0)return;const c=r(s=>[...E.map(i=>({name:i.name,description:i.description,source:"cloud"})),...b(s,A()).map(i=>({name:i.name,description:i.description,source:i.scope}))],"buildCorpus"),_=r(async(s,i)=>{const d=q(s);if(d){const p=S.get(d.id);if(p!==void 0)return{content:[{type:"text",text:p}],details:{id:d.id,cached:!0}};const D=await G(o.apiBase,t,d.id),f=D.body.length>B?`${D.body.slice(0,B)}
|
|
1
|
+
var H=Object.defineProperty;var f=(u,i)=>H(u,"name",{value:i,configurable:!0});var z=Object.defineProperty,r=f((u,i)=>z(u,"name",{value:i,configurable:!0}),"i");import{readFileSync as I}from"node:fs";import{dirname as J}from"node:path";import{t}from"@dalcode/dal-pi-kit";import{accountTag as N,readCache as Q,writeCache as V}from"@dalcode/deepailab/cache";import{defaultConfig as X}from"@dalcode/deepailab/oidc";import{getAgentDir as P,parseFrontmatter as L}from"@earendil-works/pi-coding-agent";import{Type as g}from"typebox";import{describeSkillTool as T,mergeSkills as Y,resolveSkill as Z,skillRule as uu}from"./catalog.js";import{fetchSkillBody as eu,fetchSkillIndex as tu}from"./client.js";import{listLocalSkills as nu}from"./discover.js";import{runInstallCommand as ru}from"./install.js";import{runSkillCommand as iu}from"./manage.js";import{fetchAccountPackages as ou,missingPackages as su,readInstalledSources as au,shouldAnnouncePending as lu}from"./packages.js";import{rankSkills as cu}from"./search.js";const Fu=g.Object({name:g.Optional(g.String({description:t("\u8981\u52A0\u8F7D\u5168\u6587\u7684\u6280\u80FD\u540D\u79F0\uFF1A\u53D6\u81EA\u5DE5\u5177\u8BF4\u660E\u91CC\u7684\u5217\u8868\uFF0C\u6216 query \u641C\u7D22\u7684\u7ED3\u679C\u3002")})),query:g.Optional(g.String({description:t("\u6309\u4EFB\u52A1\u63CF\u8FF0\u641C\u7D22\u672A\u5217\u51FA\u7684\u6280\u80FD\uFF1A\u8FD4\u56DE\u6700\u76F8\u5173\u7684\u51E0\u6761\uFF08\u540D\u79F0 + \u4F55\u65F6\u4F7F\u7528\uFF09\uFF0C\u518D\u7528 name \u52A0\u8F7D\u5168\u6587\u3002")}))}),O=6;function j(u){return Array.isArray(u)&&u.every(i=>typeof i?.id=="string"&&i.id.length>0&&typeof i.name=="string"&&typeof i.description=="string")}f(j,"oe"),r(j,"isSkillList");const q=6e4;function k(u){return u.length>q?`${u.slice(0,q)}
|
|
5
2
|
|
|
6
|
-
\u2026(truncated)`:
|
|
3
|
+
\u2026(truncated)`:u}f(k,"T"),r(k,"capBody");function $(u){return u.length===0?t("\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD\u3002\u53EF\u4EE5\u6362\u4E2A\u5173\u952E\u8BCD\uFF0C\u6216\u4E0D\u5E26 query \u8C03\u7528\u67E5\u770B\u53EF\u7528\u6280\u80FD\u3002"):[t("\u6700\u76F8\u5173\u7684\u6280\u80FD\uFF08\u7528 name \u52A0\u8F7D\u5168\u6587\uFF09\uFF1A"),...u.map(i=>`- ${i.name} [${i.source}]: ${i.description}`)].join(`
|
|
4
|
+
`)}f($,"B"),r($,"renderMatches");function B(u){return{name:u.name,description:u.title?`${u.title} \u2014 ${u.description}`:u.description,source:u.source}}f(B,"R"),r(B,"searchable");function v(u,i){const h=[];for(const c of u){if(c.source!=="skill"||!c.name.startsWith("skill:"))continue;const E=c.sourceInfo.path;i(E)&&h.push({name:c.name.slice(6),description:c.description??"",filePath:E,baseDir:c.sourceInfo.baseDir??J(E),scope:c.sourceInfo.scope})}return h}f(v,"re"),r(v,"hostSkillsFromCommands");function M(u){try{const{frontmatter:i}=L(I(u,"utf8"));return i["disable-model-invocation"]!==!0}catch{return!1}}f(M,"se"),r(M,"readModelInvocable");function _(u){const i=u.filePath??"",{body:h}=L(I(i,"utf8"));return`<skill name="${u.name}" location="${i}">
|
|
5
|
+
References are relative to ${u.baseDir}.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`),"
|
|
11
|
-
${
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
${k(h.trim())}
|
|
8
|
+
</skill>`}f(_,"le"),r(_,"readHostSkillBody");const R=Symbol.for("dalcode.skills.search");function S(u){globalThis[R]=u}f(S,"L"),r(S,"publishSkillSearch");function W(u){const i=X(),h=new Map;let c=[],E=!0,b=!1,D;const y=new Map,K=r(o=>{let e=y.get(o);return e===void 0&&(e=M(o),y.set(o,e)),e},"isModelInvocable"),C=r(()=>Y(v(u.getCommands(),K),c),"entries");u.on("session_start",async(o,e)=>{S(void 0),y.clear(),D=void 0;try{D=await e.modelRegistry?.getApiKeyForProvider?.("deepailab")}catch{D=void 0}const l=r(a=>{const n=`${t("\u65E0\u6CD5\u83B7\u53D6\u4E91\u7AEF\u6280\u80FD\u5217\u8868")}\uFF1A${a}`;e.hasUI?e.ui.notify(n,"warning"):process.stderr.write(`${n}
|
|
9
|
+
`)},"reportFailure");if(E=u.isToolAllowed("skill"),E&&D){const a=D,n=`skills-index-${N(a)}`,s=Q(n,j),d=(async()=>{try{const m=await tu(i.apiBase,a);if(m==="not-modified"){l(t("\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u610F\u5916\u7684 304"));return}c=m.skills;try{V(n,m.skills)}catch{}}catch(m){const p=m instanceof Error&&m.name==="AbortError"?t("\u8BF7\u6C42\u8D85\u65F6"):String(m);l(p)}})();s?c=s.value:await d}if(D){const a=D;ou(i.apiBase,a).then(n=>{const s=au(P());A=su(n,s),e.hasUI&&lu(P(),A)&&e.ui.notify(`${t("\u8D26\u53F7\u91CC\u6709")}${A.length}${t(" \u4E2A\u6269\u5C55\u672C\u673A\u8FD8\u6CA1\u88C5\uFF0C/install \u53EF\u76F4\u63A5\u5B89\u88C5\u3002")}`,"info")}).catch(()=>{})}if(!E||C().length===0)return;const F=r(async a=>{const n=C(),s=Z(n,a);if(!s)throw new Error(`${t("\u6CA1\u6709\u8FD9\u4E2A\u6280\u80FD\uFF1A")}${a}
|
|
10
|
+
${t("\u53EF\u7528\uFF1A")}${n.map(G=>G.name).join(", ")}`);if(s.source==="local")return{content:[{type:"text",text:_(s)}],details:{name:s.name,source:"local",path:s.filePath}};const d=s.cloudId??s.name,m=h.get(d);if(m!==void 0)return{content:[{type:"text",text:m}],details:{name:s.name,source:"cloud",id:d,cached:!0}};if(!D)throw new Error(t("\u672A\u767B\u5F55\uFF0C\u65E0\u6CD5\u52A0\u8F7D\u4E91\u7AEF\u6280\u80FD"));const p=await eu(i.apiBase,D,d),x=k(p.body);return h.set(d,x),{content:[{type:"text",text:x}],details:{name:s.name,source:"cloud",id:d,version:p.version}}},"loadBody");u.registerTool({name:"skill",label:t("\u6280\u80FD"),description:T(C()),promptSnippet:t("skill - \u52A0\u8F7D\u6280\u80FD\uFF08\u4E13\u9879\u4EFB\u52A1\u6307\u5F15\uFF09\uFF1A\u4EFB\u52A1\u7B26\u5408\u67D0\u4E2A\u6280\u80FD\u65F6\u5148\u52A0\u8F7D\u518D\u52A8\u624B"),promptGuidelines:[uu()],parameters:Fu,prepareLoadout:r(()=>{const a=C();return a.length>0?{descriptions:{skill:T(a)}}:{hiddenDeclarations:["skill"]}},"prepareLoadout"),execute:r(async(a,n)=>{const s=n.name?.trim();if(s)try{return await F(s)}catch(p){throw new Error(`${t("\u52A0\u8F7D\u6280\u80FD\u5931\u8D25\uFF1A")}${s} \u2014 ${p instanceof Error?p.message:String(p)}`)}const d=n.query?.trim();if(d){const p=w(d,O);return{content:[{type:"text",text:$(p)}],details:{query:d,count:p.length}}}const m=C();return{content:[{type:"text",text:$(m.slice(0,O).map(B))}],details:{listed:!0,total:m.length}}},"execute")}),b=!0,S({search:r((a,n,s)=>w(a,s),"search")})});const w=r((o,e)=>cu(C().map(B),o,e),"search");u.on("before_agent_start",o=>{!b||!u.getActiveTools().includes("skill")||C().length!==0&&(o.systemPromptOptions.skills=[])});let A=[];const U=r(o=>o.map(e=>` /install ${e.source} # ${e.name}${e.description?` \u2014 ${e.description}`:""}`).join(`
|
|
11
|
+
`),"describePackages");u.registerCommand("packages",{description:t("\u67E5\u770B\u8D26\u53F7\u63A8\u8350\u7684\u6269\u5C55"),handler:r(async(o,e)=>{if(A.length===0){e.ui.notify(t("\u8D26\u53F7\u91CC\u7684\u6269\u5C55\u90FD\u5DF2\u5B89\u88C5\u3002"),"info");return}e.ui.notify(`${t("\u8D26\u53F7\u63A8\u8350\u3001\u672C\u673A\u5C1A\u672A\u5B89\u88C5\u7684\u6269\u5C55\uFF1A")}
|
|
12
|
+
${U(A)}`,"info")},"handler")}),u.registerCommand("install",{description:t("\u5B89\u88C5\u6269\u5C55\uFF08<npm:\u5305\u540D|git:...> [--local]\uFF1B\u65E0\u53C2\u6570\u4ECE\u8D26\u53F7\u63A8\u8350\u4E2D\u9009\u62E9\uFF09"),getArgumentCompletions:r(o=>{const e=o.trimStart();if(e.includes(" "))return null;const l=[...A.map(F=>({value:F.source,label:(F.description||F.name).slice(0,80)})),{value:"--local",label:t("\u5B89\u88C5\u5230\u5F53\u524D\u9879\u76EE")}];return e.length===0?l:l.filter(F=>F.value.startsWith(e))},"getArgumentCompletions"),handler:r(async(o,e)=>{const l=await ru(o,e,{recommended:A});l.kept&&(A=A.filter(F=>F.source!==l.kept))},"handler")}),u.registerCommand("skills",{description:t("\u67E5\u770B\u53EF\u7528\u7684 DeepAILab \u4E91\u7AEF\u6280\u80FD"),handler:r(async(o,e)=>{if(!E){e.ui.notify(t("\u672C\u4F1A\u8BDD\u7684\u5DE5\u5177\u767D\u540D\u5355\uFF08--tools\uFF09\u4E0D\u542B skill\uFF0C\u672A\u52A0\u8F7D\u4E91\u7AEF\u6280\u80FD\u3002"),"info");return}if(c.length===0){e.ui.notify(t("\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u7684\u4E91\u7AEF\u6280\u80FD\uFF08\u672A\u767B\u5F55\uFF0C\u6216\u670D\u52A1\u7AEF\u76EE\u5F55\u4E3A\u7A7A\uFF09\u3002"),"info");return}e.ui.notify(`${t("\u4E91\u7AEF\u6280\u80FD")} (${c.length})
|
|
13
|
+
`+c.map(l=>` ${l.name}${l.version?` v${l.version}`:""} \u2014 ${l.description}`).join(`
|
|
14
|
+
`),"info")},"handler")}),u.registerCommand("skill",{description:t("\u7BA1\u7406\u672C\u5730\u6280\u80FD\uFF08list | show <name> | add | remove <name>\uFF09\uFF1B/skills \u67E5\u770B\u4E91\u7AEF\u6280\u80FD"),getArgumentCompletions:r(o=>{const e=o.trimStart(),l=e.indexOf(" ");if(l===-1)return["list","add","remove","show"].filter(n=>n.startsWith(e)).map(n=>({value:`${n} `,label:n}));const F=e.slice(0,l),a=e.slice(l+1);return(F==="show"||F==="remove")&&!a.includes(" ")?nu(process.cwd()).filter(n=>n.name.startsWith(a)).map(n=>({value:`${F} ${n.name}`,label:n.description.slice(0,80)})):null},"getArgumentCompletions"),handler:r(async(o,e)=>iu(o,e),"handler")})}f(W,"ce"),r(W,"default");export{R as SKILL_SEARCH_SLOT,W as default,v as hostSkillsFromCommands};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-subagent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
-
"@dalcode/dal-guard": "1.0.
|
|
22
|
-
"@earendil-works/pi-agent-core": "^1.0.
|
|
23
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
20
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
21
|
+
"@dalcode/dal-guard": "1.0.32",
|
|
22
|
+
"@earendil-works/pi-agent-core": "^1.0.32",
|
|
23
|
+
"@earendil-works/pi-ai": "^1.0.32",
|
|
24
24
|
"typebox": "1.3.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-telemetry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.32"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-terminal",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Host terminal context: a terminal_read tool and @terminal mentions, registered only when the embedding host advertises the terminal capability.",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
22
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
23
23
|
"typebox": "1.3.7"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-tool-catalog",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
22
22
|
"typebox": "1.3.7"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
]
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
27
|
-
"@dalcode/deepailab": "1.0.
|
|
26
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
27
|
+
"@dalcode/deepailab": "1.0.32",
|
|
28
28
|
"typebox": "1.3.27"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-workflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
20
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
21
21
|
"typebox": "1.3.27"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/deepailab",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
24
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.32",
|
|
24
|
+
"@earendil-works/pi-ai": "^1.0.32"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|