@dadado/agent-kit-cli 6.25.0 → 6.26.1
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/dashboard/dashboard.html +3 -3
- package/dashboard/lib/guards.mjs +1 -0
- package/dist/{add-OYLOMCM6.js → add-G7KEZLWP.js} +7 -6
- package/dist/{chunk-7HDQEK6T.js → chunk-2G4K4ZI5.js} +7 -3
- package/dist/{chunk-QLTGHJB3.js → chunk-2GXN7HVG.js} +5 -5
- package/dist/{chunk-IFBIO7VT.js → chunk-3KFLQE6Y.js} +1533 -52
- package/dist/{chunk-GQSSXDDK.js → chunk-ARJRICI2.js} +1 -1
- package/dist/{chunk-6WUKLS4D.js → chunk-BIFTTL2O.js} +1 -1
- package/dist/{chunk-QACMV46U.js → chunk-BSK6C4UO.js} +19 -12
- package/dist/{chunk-NJ2SUSWX.js → chunk-BVZDPVUL.js} +1 -1
- package/dist/{chunk-GMG7ZH4E.js → chunk-DOMBVLI4.js} +13 -13
- package/dist/{chunk-2F6NMQOA.js → chunk-FB6G6OD6.js} +3 -3
- package/dist/{chunk-MFKHIWEL.js → chunk-FOVHFMSH.js} +1 -1
- package/dist/{chunk-EO5NGAYV.js → chunk-FUSNEYGU.js} +29 -3
- package/dist/{chunk-SAQ3EE5R.js → chunk-HGB4DHXV.js} +3 -3
- package/dist/{chunk-6M6UKECW.js → chunk-IHVJTGYR.js} +0 -32
- package/dist/chunk-KMK4T4ZM.js +34 -0
- package/dist/{chunk-ZMYV6PRE.js → chunk-LEVNLHH3.js} +2 -1
- package/dist/{chunk-2XLI7XEY.js → chunk-MGVV6YC4.js} +1 -1
- package/dist/{chunk-C7SV7UP5.js → chunk-MWRYQLEG.js} +3 -3
- package/dist/{chunk-WKFE3RUC.js → chunk-NHJ4IAVN.js} +5 -3
- package/dist/{chunk-HSIHZWFF.js → chunk-NW5SWKJV.js} +7 -7
- package/dist/{chunk-C4Q77GGJ.js → chunk-O7VMHCNN.js} +6 -0
- package/dist/{chunk-CIV42JGT.js → chunk-PCIYXGB3.js} +2 -2
- package/dist/{chunk-7Y74KO7U.js → chunk-PLLXFSN2.js} +12 -12
- package/dist/{chunk-XGZOU4DS.js → chunk-QMCBXCP5.js} +4 -4
- package/dist/{chunk-QX55T4UX.js → chunk-RJP47EGS.js} +6 -1
- package/dist/{chunk-KWYF7QNH.js → chunk-RLVY6YD3.js} +17 -2
- package/dist/{chunk-JGG574RK.js → chunk-RRJVC35Y.js} +3 -3
- package/dist/{chunk-PIMGV3E5.js → chunk-SWJJW624.js} +1 -1
- package/dist/{chunk-G5MQRP6M.js → chunk-SYRJ5TTK.js} +13 -9
- package/dist/{chunk-L5V3W3DY.js → chunk-TTUFIE26.js} +60 -14
- package/dist/chunk-WOXTL43E.js +248 -0
- package/dist/{chunk-JFS4GKP7.js → chunk-XXPI4H4D.js} +2 -2
- package/dist/{chunk-M4UL422I.js → chunk-Y5526WCN.js} +6 -6
- package/dist/{chunk-CXE6ASSX.js → chunk-Y575INEC.js} +1 -1
- package/dist/{chunk-H7RAFRRZ.js → chunk-YFRG3CMS.js} +68 -34
- package/dist/{chunk-JG3CNGQM.js → chunk-ZNZHDPS3.js} +6 -4
- package/dist/{commands-UW2C2ZN4.js → commands-SCFSX4U4.js} +8 -6
- package/dist/{conflicts-RING6AHV.js → conflicts-4GLQOMJF.js} +9 -10
- package/dist/{contribute-LSY75JZH.js → contribute-HE4WCBRY.js} +7 -6
- package/dist/{countdown-SZ2P4XHB.js → countdown-VXOFV23S.js} +104 -57
- package/dist/{dashboard-P65XHYCU.js → dashboard-6V6PCNYF.js} +1 -1
- package/dist/{dashboard-broadcast-GYK34QYL.js → dashboard-broadcast-PMVQ7PXU.js} +1 -1
- package/dist/{diff-NZVBVQSK.js → diff-3XUZM7ZT.js} +8 -7
- package/dist/{doctor-TJSXBVGV.js → doctor-KGUWU5SN.js} +16 -15
- package/dist/{engine-info-BBI5QO5Y.js → engine-info-VM4VPGQM.js} +2 -2
- package/dist/{ground-control-ZJXPUIQN.js → ground-control-J4AMA4S4.js} +7 -4
- package/dist/{handoff-2OZSWGTE.js → handoff-LLT4CI6H.js} +2 -3
- package/dist/{hook-3VPKNSOO.js → hook-UPZ3CPYS.js} +22 -22
- package/dist/index.js +52 -32
- package/dist/{init-UW2BJBO2.js → init-ZHLVXEVT.js} +19 -18
- package/dist/{install-RQSI4CHG.js → install-XWOG64W3.js} +19 -18
- package/dist/{installs-7TR4H4QH.js → installs-2ROXPO6M.js} +5 -4
- package/dist/{mission-control-VSU6NT43.js → mission-control-IGOI3WHS.js} +2 -2
- package/dist/models-SNB5Q3YU.js +45 -0
- package/dist/paths-JTPV6SXH.js +107 -0
- package/dist/pi-DCMDOY65.js +248 -0
- package/dist/{plan-index-BNLUU6T5.js → plan-index-5QZJK4AG.js} +2 -3
- package/dist/{queue-JHYILLMX.js → queue-HDR5ER25.js} +11 -13
- package/dist/{run-CQF5RM5X.js → run-RGIY5JTX.js} +24 -30
- package/dist/{run-plan-BEOCOJCF.js → run-plan-DHB3ZXJS.js} +35 -23
- package/dist/{session-start-QV7CEFRX.js → session-start-NC2HE5X5.js} +16 -16
- package/dist/{sessions-AWAAO3DU.js → sessions-WWWLYPW6.js} +4 -4
- package/dist/{setup-global-ST4TT427.js → setup-global-WDMARD4Z.js} +11 -10
- package/dist/{status-HUBPBGUU.js → status-2WNJL7PP.js} +12 -11
- package/dist/update-OXCWYN3Y.js +32 -0
- package/dist/{update-all-YYUTXHGR.js → update-all-E2MV6KME.js} +20 -18
- package/package.json +14 -4
- package/pi/agent-kit.ts +224 -0
- package/dist/chunk-7ABY6DYH.js +0 -89
- package/dist/chunk-AQLBEEPD.js +0 -625
- package/dist/chunk-MUTTNRX4.js +0 -53
- package/dist/chunk-TOSAAQ5A.js +0 -71
- package/dist/update-DD5UZPGG.js +0 -31
|
@@ -2,23 +2,24 @@ import {
|
|
|
2
2
|
classifyInstallError,
|
|
3
3
|
isNonInteractive,
|
|
4
4
|
pathCliStatus
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RRJVC35Y.js";
|
|
6
6
|
import {
|
|
7
7
|
assessEnvironment
|
|
8
8
|
} from "./chunk-2TW7ENWC.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-SAQ3EE5R.js";
|
|
9
|
+
import "./chunk-Y5526WCN.js";
|
|
10
|
+
import "./chunk-MWRYQLEG.js";
|
|
11
|
+
import "./chunk-HGB4DHXV.js";
|
|
13
12
|
import "./chunk-CGXLR77R.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-PFEUZXVT.js";
|
|
14
|
+
import "./chunk-ZNZHDPS3.js";
|
|
15
|
+
import "./chunk-RJP47EGS.js";
|
|
16
|
+
import "./chunk-IHVJTGYR.js";
|
|
17
|
+
import "./chunk-KMK4T4ZM.js";
|
|
17
18
|
import {
|
|
18
19
|
KIT_VERSION,
|
|
19
20
|
pinnedCliSpec
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-2G4K4ZI5.js";
|
|
22
|
+
import "./chunk-O7VMHCNN.js";
|
|
22
23
|
import "./chunk-5B4DVO6C.js";
|
|
23
24
|
|
|
24
25
|
// src/commands/setup-global.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
detectWorkspaceParent,
|
|
3
3
|
workspaceParentAdvisoryLines
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MGVV6YC4.js";
|
|
5
5
|
import {
|
|
6
6
|
createReadinessReport
|
|
7
7
|
} from "./chunk-PNFF6OU3.js";
|
|
@@ -16,27 +16,28 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
npxPinned,
|
|
18
18
|
pathCliStatus
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RRJVC35Y.js";
|
|
20
20
|
import {
|
|
21
21
|
assessEnvironment
|
|
22
22
|
} from "./chunk-2TW7ENWC.js";
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-SAQ3EE5R.js";
|
|
23
|
+
import "./chunk-Y5526WCN.js";
|
|
24
|
+
import "./chunk-MWRYQLEG.js";
|
|
25
|
+
import "./chunk-HGB4DHXV.js";
|
|
27
26
|
import "./chunk-CGXLR77R.js";
|
|
27
|
+
import "./chunk-PFEUZXVT.js";
|
|
28
28
|
import {
|
|
29
29
|
loadAgentKitManifest,
|
|
30
30
|
resolveProtectedGlobs
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-ZNZHDPS3.js";
|
|
32
|
+
import "./chunk-RJP47EGS.js";
|
|
33
|
+
import "./chunk-IHVJTGYR.js";
|
|
33
34
|
import {
|
|
34
35
|
MANIFEST_RELATIVE_PATH
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-KMK4T4ZM.js";
|
|
36
37
|
import {
|
|
37
38
|
KIT_VERSION
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import "./chunk-
|
|
39
|
+
} from "./chunk-2G4K4ZI5.js";
|
|
40
|
+
import "./chunk-O7VMHCNN.js";
|
|
40
41
|
import {
|
|
41
42
|
readJson
|
|
42
43
|
} from "./chunk-5B4DVO6C.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyUpdateAtRoot,
|
|
3
|
+
updateCommand
|
|
4
|
+
} from "./chunk-DOMBVLI4.js";
|
|
5
|
+
import "./chunk-FOVHFMSH.js";
|
|
6
|
+
import "./chunk-2GXN7HVG.js";
|
|
7
|
+
import "./chunk-HS7LVVLO.js";
|
|
8
|
+
import "./chunk-SWJJW624.js";
|
|
9
|
+
import "./chunk-BVZDPVUL.js";
|
|
10
|
+
import "./chunk-FUSNEYGU.js";
|
|
11
|
+
import "./chunk-NHJ4IAVN.js";
|
|
12
|
+
import "./chunk-Q35TWISF.js";
|
|
13
|
+
import "./chunk-QTON2GQX.js";
|
|
14
|
+
import "./chunk-ZB43YMHW.js";
|
|
15
|
+
import "./chunk-RRJVC35Y.js";
|
|
16
|
+
import "./chunk-2TW7ENWC.js";
|
|
17
|
+
import "./chunk-Y5526WCN.js";
|
|
18
|
+
import "./chunk-MWRYQLEG.js";
|
|
19
|
+
import "./chunk-HGB4DHXV.js";
|
|
20
|
+
import "./chunk-CGXLR77R.js";
|
|
21
|
+
import "./chunk-PFEUZXVT.js";
|
|
22
|
+
import "./chunk-ZNZHDPS3.js";
|
|
23
|
+
import "./chunk-RJP47EGS.js";
|
|
24
|
+
import "./chunk-IHVJTGYR.js";
|
|
25
|
+
import "./chunk-KMK4T4ZM.js";
|
|
26
|
+
import "./chunk-2G4K4ZI5.js";
|
|
27
|
+
import "./chunk-O7VMHCNN.js";
|
|
28
|
+
import "./chunk-5B4DVO6C.js";
|
|
29
|
+
export {
|
|
30
|
+
applyUpdateAtRoot,
|
|
31
|
+
updateCommand
|
|
32
|
+
};
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyUpdateAtRoot
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DOMBVLI4.js";
|
|
4
4
|
import {
|
|
5
5
|
QUEUE_LEASE_SESSION_ENV,
|
|
6
6
|
inspectQueueLease
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FOVHFMSH.js";
|
|
8
8
|
import {
|
|
9
9
|
CLAUDE_NESTED_SESSION_KEYS
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3KFLQE6Y.js";
|
|
11
11
|
import "./chunk-P7732A25.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-TTUFIE26.js";
|
|
13
|
+
import "./chunk-2GXN7HVG.js";
|
|
13
14
|
import "./chunk-HS7LVVLO.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-SWJJW624.js";
|
|
16
|
+
import "./chunk-BVZDPVUL.js";
|
|
17
|
+
import "./chunk-FUSNEYGU.js";
|
|
17
18
|
import {
|
|
18
19
|
InstallsRegistryError,
|
|
19
20
|
inspectInstall,
|
|
20
21
|
listInstalls
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-NHJ4IAVN.js";
|
|
22
23
|
import "./chunk-WGLPZXNU.js";
|
|
23
24
|
import "./chunk-Q35TWISF.js";
|
|
24
25
|
import "./chunk-QTON2GQX.js";
|
|
@@ -28,31 +29,32 @@ import {
|
|
|
28
29
|
import {
|
|
29
30
|
logger
|
|
30
31
|
} from "./chunk-ZB43YMHW.js";
|
|
31
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-RRJVC35Y.js";
|
|
32
33
|
import "./chunk-2TW7ENWC.js";
|
|
33
34
|
import {
|
|
34
35
|
checkRunningCliVsNpmLatest,
|
|
35
36
|
compareSemver
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-
|
|
39
|
-
import "./chunk-SAQ3EE5R.js";
|
|
37
|
+
} from "./chunk-Y5526WCN.js";
|
|
38
|
+
import "./chunk-MWRYQLEG.js";
|
|
39
|
+
import "./chunk-HGB4DHXV.js";
|
|
40
40
|
import "./chunk-CGXLR77R.js";
|
|
41
|
+
import "./chunk-PFEUZXVT.js";
|
|
41
42
|
import {
|
|
42
43
|
isProtectedPath,
|
|
43
44
|
loadAgentKitManifest,
|
|
44
45
|
resolveProtectedGlobs
|
|
45
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-ZNZHDPS3.js";
|
|
46
47
|
import {
|
|
47
48
|
MANAGED_HASHES_REL
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-RJP47EGS.js";
|
|
50
|
+
import "./chunk-IHVJTGYR.js";
|
|
49
51
|
import {
|
|
50
52
|
MANIFEST_RELATIVE_PATH
|
|
51
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-KMK4T4ZM.js";
|
|
52
54
|
import {
|
|
53
55
|
KIT_VERSION
|
|
54
|
-
} from "./chunk-
|
|
55
|
-
import "./chunk-
|
|
56
|
+
} from "./chunk-2G4K4ZI5.js";
|
|
57
|
+
import "./chunk-O7VMHCNN.js";
|
|
56
58
|
import "./chunk-5B4DVO6C.js";
|
|
57
59
|
|
|
58
60
|
// src/commands/update-all.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dadado/agent-kit-cli",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.26.1",
|
|
4
4
|
"description": "Agent Kit CLI: HITL framework install and tooling for AI-assisted IDEs (rules, skills, plan/handoff, context).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package"
|
|
7
|
+
],
|
|
5
8
|
"license": "Apache-2.0",
|
|
6
9
|
"homepage": "https://agent.missionkit.io/",
|
|
7
10
|
"repository": {
|
|
@@ -21,9 +24,15 @@
|
|
|
21
24
|
"files": [
|
|
22
25
|
"dist",
|
|
23
26
|
"dashboard",
|
|
27
|
+
"pi/agent-kit.ts",
|
|
24
28
|
"LICENSE",
|
|
25
29
|
"NOTICE"
|
|
26
30
|
],
|
|
31
|
+
"pi": {
|
|
32
|
+
"extensions": [
|
|
33
|
+
"./pi/agent-kit.ts"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
27
36
|
"scripts": {
|
|
28
37
|
"sync-dashboard": "node ../../scripts/sync-cli-dashboard.mjs",
|
|
29
38
|
"prepack": "node ../../scripts/sync-cli-dashboard.mjs",
|
|
@@ -31,11 +40,11 @@
|
|
|
31
40
|
"build": "node ../../scripts/sync-cli-dashboard.mjs && tsup src/index.ts --format esm --dts --clean",
|
|
32
41
|
"dev": "tsx src/index.ts",
|
|
33
42
|
"start": "tsx src/index.ts",
|
|
34
|
-
"lint": "biome check src",
|
|
43
|
+
"lint": "biome check src pi",
|
|
35
44
|
"overlay:hashes": "tsx src/lifecycle/refresh-known-hashes.ts",
|
|
36
45
|
"overlay:hashes:check": "tsx src/lifecycle/refresh-known-hashes.ts --check",
|
|
37
46
|
"test": "vitest run",
|
|
38
|
-
"typecheck": "tsc --noEmit"
|
|
47
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.pi.json"
|
|
39
48
|
},
|
|
40
49
|
"dependencies": {
|
|
41
50
|
"@clack/prompts": "^1.8.1",
|
|
@@ -47,6 +56,7 @@
|
|
|
47
56
|
"tsup": "^9.0.0",
|
|
48
57
|
"tsx": "^4.23.15",
|
|
49
58
|
"vite": "^8.3.5",
|
|
50
|
-
"vitest": "^5.0.5"
|
|
59
|
+
"vitest": "^5.0.5",
|
|
60
|
+
"yaml": "^2.9.0"
|
|
51
61
|
}
|
|
52
62
|
}
|
package/pi/agent-kit.ts
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Kit bridge for pi (ADR 2026-11-28_pi-harness-interactive-surface-extension).
|
|
3
|
+
*
|
|
4
|
+
* - Asks the `agent-kit` CLI on PATH where the kit is (`agent-kit paths --json`); this file knows
|
|
5
|
+
* no kit layout, so a layout change only changes the CLI answer.
|
|
6
|
+
* - Feeds pi the kit's command directory as prompt templates and its skill directories as skills,
|
|
7
|
+
* read in place: nothing is generated or copied into the repository.
|
|
8
|
+
* - Adds the session-start context from `agent-kit hook session-start --format pi` to the system
|
|
9
|
+
* prompt as a named `agent-kit` section.
|
|
10
|
+
* - Runs only the `agent-kit` binary on PATH, never repository code (no node_modules/.bin, no dist).
|
|
11
|
+
* - Fail-open: any CLI problem leaves pi running with one warning and no kit context.
|
|
12
|
+
*
|
|
13
|
+
* Runtime imports are node builtins only, so the file loads from the published package as is.
|
|
14
|
+
*/
|
|
15
|
+
import { execFile } from "node:child_process";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import { resolve, sep } from "node:path";
|
|
18
|
+
|
|
19
|
+
const CLI = "agent-kit";
|
|
20
|
+
const PATHS_SCHEMA_VERSION = 1;
|
|
21
|
+
const PATHS_TIMEOUT_MS = 10_000;
|
|
22
|
+
const CONTEXT_TIMEOUT_MS = 20_000;
|
|
23
|
+
const SECTION = "agent-kit";
|
|
24
|
+
const TOO_OLD =
|
|
25
|
+
"agent-kit: the CLI on PATH is too old for the pi bridge (no `paths`); update agent-kit.";
|
|
26
|
+
/** Survives pi's /reload, which re-creates this module's closure in the same process. */
|
|
27
|
+
const TARGET_KEY = Symbol.for("agent-kit.pi-bridge.target");
|
|
28
|
+
|
|
29
|
+
interface KitPaths {
|
|
30
|
+
schemaVersion: number;
|
|
31
|
+
kitVersion: string;
|
|
32
|
+
root: string;
|
|
33
|
+
commands: string | null;
|
|
34
|
+
skills: string[];
|
|
35
|
+
}
|
|
36
|
+
interface Kit {
|
|
37
|
+
paths: KitPaths;
|
|
38
|
+
context: string;
|
|
39
|
+
}
|
|
40
|
+
type Resolution = { kit?: Kit; warning?: string };
|
|
41
|
+
type NotifyType = "info" | "warning" | "error";
|
|
42
|
+
interface Ctx {
|
|
43
|
+
cwd: string;
|
|
44
|
+
ui: { notify(message: string, type?: NotifyType): void };
|
|
45
|
+
}
|
|
46
|
+
interface BeforeAgentStartEvent {
|
|
47
|
+
messageType?: "user" | "custom";
|
|
48
|
+
systemPrompt: string;
|
|
49
|
+
systemPromptOptions?: { sections?: Record<string, string> };
|
|
50
|
+
}
|
|
51
|
+
interface InputEvent {
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
type Handler<E> = (event: E, ctx: Ctx) => unknown;
|
|
55
|
+
interface PiApi {
|
|
56
|
+
on(event: "session_start", handler: Handler<unknown>): void;
|
|
57
|
+
on(event: "resources_discover", handler: Handler<unknown>): void;
|
|
58
|
+
on(event: "before_agent_start", handler: Handler<BeforeAgentStartEvent>): void;
|
|
59
|
+
on(event: "input", handler: Handler<InputEvent>): void;
|
|
60
|
+
getCommands(): { name: string; source: string; sourceInfo: { path: string } }[];
|
|
61
|
+
registerCommand(
|
|
62
|
+
name: string,
|
|
63
|
+
options: { description: string; handler: (args: string, ctx: Ctx) => Promise<void> },
|
|
64
|
+
): void;
|
|
65
|
+
}
|
|
66
|
+
interface CliRun {
|
|
67
|
+
code: number | null;
|
|
68
|
+
stdout: string;
|
|
69
|
+
stderr: string;
|
|
70
|
+
missing: boolean;
|
|
71
|
+
timedOut: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function runCli(args: string[], timeout: number, cwd?: string): Promise<CliRun> {
|
|
75
|
+
return new Promise((done) => {
|
|
76
|
+
const child = execFile(
|
|
77
|
+
CLI,
|
|
78
|
+
args,
|
|
79
|
+
{ cwd, timeout, encoding: "utf8", maxBuffer: 4 * 1024 * 1024 },
|
|
80
|
+
(error, stdout, stderr) => {
|
|
81
|
+
const err = error as (NodeJS.ErrnoException & { killed?: boolean }) | null;
|
|
82
|
+
done({
|
|
83
|
+
code: err ? (typeof err.code === "number" ? err.code : null) : 0,
|
|
84
|
+
stdout: String(stdout ?? ""),
|
|
85
|
+
stderr: String(stderr ?? ""),
|
|
86
|
+
missing: err?.code === "ENOENT",
|
|
87
|
+
timedOut: err?.killed === true,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
child.stdin?.end(); // the hook reads stdin until EOF
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function why(step: string, run: CliRun, timeout: number): string {
|
|
96
|
+
if (run.missing)
|
|
97
|
+
return `agent-kit: no \`agent-kit\` on PATH; install the Agent Kit CLI to use the pi bridge.`;
|
|
98
|
+
if (run.timedOut) return `agent-kit: \`${step}\` timed out after ${timeout / 1000}s.`;
|
|
99
|
+
if (run.code === 0) return `agent-kit: \`${step}\` printed nothing.`;
|
|
100
|
+
const detail = run.stderr.trim().split("\n")[0] ?? "";
|
|
101
|
+
return `agent-kit: \`${step}\` failed (exit ${run.code ?? "?"})${detail ? `: ${detail}` : ""}.`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function parsePaths(stdout: string): KitPaths | string {
|
|
105
|
+
let value: Partial<KitPaths>;
|
|
106
|
+
try {
|
|
107
|
+
value = JSON.parse(stdout) as Partial<KitPaths>;
|
|
108
|
+
} catch {
|
|
109
|
+
return TOO_OLD;
|
|
110
|
+
}
|
|
111
|
+
if (value.schemaVersion !== PATHS_SCHEMA_VERSION) {
|
|
112
|
+
return `agent-kit: \`agent-kit paths\` answered schemaVersion ${String(value.schemaVersion)}, this bridge reads ${PATHS_SCHEMA_VERSION}; run \`agent-kit pi install\` to update it.`;
|
|
113
|
+
}
|
|
114
|
+
if (typeof value.root !== "string" || !Array.isArray(value.skills)) return TOO_OLD;
|
|
115
|
+
return value as KitPaths;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function resolveKit(dir: string): Promise<Resolution> {
|
|
119
|
+
const run = await runCli(["paths", "--json", "--cwd", dir], PATHS_TIMEOUT_MS);
|
|
120
|
+
// Contract: outside a kit, exit 1 and nothing on stdout. Older CLIs print help for `paths`.
|
|
121
|
+
if (run.code === 1 && run.stdout.trim() === "") return {};
|
|
122
|
+
if (/unknown command/i.test(run.stderr)) return { warning: TOO_OLD };
|
|
123
|
+
if (run.code !== 0) return { warning: why("agent-kit paths", run, PATHS_TIMEOUT_MS) };
|
|
124
|
+
const paths = parsePaths(run.stdout);
|
|
125
|
+
if (typeof paths === "string") return { warning: paths };
|
|
126
|
+
|
|
127
|
+
const args = ["hook", "session-start", "--format", "pi", "--cwd", paths.root];
|
|
128
|
+
const hook = await runCli(args, CONTEXT_TIMEOUT_MS, paths.root);
|
|
129
|
+
const header = `Agent Kit root: ${paths.root} (agent-kit ${paths.kitVersion}, pi bridge). Run kit shell commands from this root.`;
|
|
130
|
+
if (hook.code !== 0 || hook.stdout.trim() === "") {
|
|
131
|
+
const warning = `${why("agent-kit hook session-start", hook, CONTEXT_TIMEOUT_MS)} Commands and skills load; no kit context.`;
|
|
132
|
+
return { kit: { paths, context: "" }, warning };
|
|
133
|
+
}
|
|
134
|
+
return { kit: { paths, context: `${header}\n\n${hook.stdout.trim()}` } };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function expandHome(input: string): string {
|
|
138
|
+
return input === "~" || input.startsWith("~/") ? homedir() + input.slice(1) : input;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
type Target = { cwd: string; dir: string };
|
|
142
|
+
const store = globalThis as typeof globalThis & { [TARGET_KEY]?: Target };
|
|
143
|
+
|
|
144
|
+
export default function agentKitBridge(pi: PiApi): void {
|
|
145
|
+
let kit: Kit | undefined;
|
|
146
|
+
/** Arguments typed after a kit command, held from `input` until `before_agent_start`. */
|
|
147
|
+
let pendingArgs: string | undefined;
|
|
148
|
+
|
|
149
|
+
const load = async (dir: string, ctx: Ctx): Promise<Resolution> => {
|
|
150
|
+
const result = await resolveKit(dir);
|
|
151
|
+
kit = result.kit;
|
|
152
|
+
if (result.warning) ctx.ui.notify(result.warning, "warning");
|
|
153
|
+
return result;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
157
|
+
const target = store[TARGET_KEY];
|
|
158
|
+
await load(target && target.cwd === ctx.cwd ? target.dir : ctx.cwd, ctx);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
pi.on("resources_discover", () => {
|
|
162
|
+
if (!kit) return {};
|
|
163
|
+
return {
|
|
164
|
+
promptPaths: kit.paths.commands ? [kit.paths.commands] : [],
|
|
165
|
+
skillPaths: kit.paths.skills,
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Kit commands use no `$@`, so pi drops what follows `/<command>`. Forward it as an
|
|
170
|
+
// `ARGUMENTS:` message (the Claude Code adapter's convention), for kit commands only.
|
|
171
|
+
pi.on("input", (event) => {
|
|
172
|
+
pendingArgs = undefined;
|
|
173
|
+
const match = /^\/(\S+)\s+(\S[\s\S]*)$/.exec(event.text.trim());
|
|
174
|
+
const commandsDir = kit?.paths.commands;
|
|
175
|
+
if (!match || !commandsDir) return { action: "continue" };
|
|
176
|
+
const fromKit = pi
|
|
177
|
+
.getCommands()
|
|
178
|
+
.some(
|
|
179
|
+
(c) =>
|
|
180
|
+
c.name === match[1] &&
|
|
181
|
+
c.source === "prompt" &&
|
|
182
|
+
c.sourceInfo.path.startsWith(commandsDir + sep),
|
|
183
|
+
);
|
|
184
|
+
if (fromKit) pendingArgs = match[2];
|
|
185
|
+
return { action: "continue" };
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
pi.on("before_agent_start", (event) => {
|
|
189
|
+
const args = event.messageType === "custom" ? undefined : pendingArgs;
|
|
190
|
+
pendingArgs = undefined;
|
|
191
|
+
const message = args
|
|
192
|
+
? { customType: "agent-kit-arguments", content: `ARGUMENTS: ${args}`, display: true }
|
|
193
|
+
: undefined;
|
|
194
|
+
const context = kit?.context ?? "";
|
|
195
|
+
const sections = event.systemPromptOptions?.sections;
|
|
196
|
+
if (sections) {
|
|
197
|
+
if (context) sections[SECTION] = context;
|
|
198
|
+
else delete sections[SECTION];
|
|
199
|
+
return message ? { message } : undefined;
|
|
200
|
+
}
|
|
201
|
+
if (!context) return message ? { message } : undefined;
|
|
202
|
+
return { message, systemPrompt: `${event.systemPrompt}\n\n${context}` };
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
pi.registerCommand("agent-kit", {
|
|
206
|
+
description:
|
|
207
|
+
"Point the Agent Kit bridge at a repo (default: current dir) and reload its context; then /reload for its commands",
|
|
208
|
+
handler: async (args, ctx) => {
|
|
209
|
+
const raw = args.trim();
|
|
210
|
+
const dir = raw ? resolve(ctx.cwd, expandHome(raw)) : ctx.cwd;
|
|
211
|
+
const result = await load(dir, ctx);
|
|
212
|
+
if (!result.kit) {
|
|
213
|
+
if (!result.warning)
|
|
214
|
+
ctx.ui.notify(`agent-kit: no Agent Kit at or above ${dir}.`, "warning");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
store[TARGET_KEY] = { cwd: ctx.cwd, dir };
|
|
218
|
+
ctx.ui.notify(
|
|
219
|
+
`agent-kit: context loaded from ${result.kit.paths.root}. Run /reload to load its slash commands and skills.`,
|
|
220
|
+
"info",
|
|
221
|
+
);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
package/dist/chunk-7ABY6DYH.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
extractHandoffNamedPlans,
|
|
3
|
-
namedPlanCandidatePaths,
|
|
4
|
-
parsePlanFrontmatter
|
|
5
|
-
} from "./chunk-L5V3W3DY.js";
|
|
6
|
-
import {
|
|
7
|
-
HANDOFF_REL
|
|
8
|
-
} from "./chunk-C4Q77GGJ.js";
|
|
9
|
-
import {
|
|
10
|
-
fileExists
|
|
11
|
-
} from "./chunk-5B4DVO6C.js";
|
|
12
|
-
|
|
13
|
-
// src/plan-loop/plan-state.ts
|
|
14
|
-
import { readdir, readFile } from "fs/promises";
|
|
15
|
-
import path from "path";
|
|
16
|
-
function countPendingTodos(raw) {
|
|
17
|
-
return parsePlanFrontmatter(raw).todos.filter(
|
|
18
|
-
(t) => (t.status === "pending" || t.status === "in_progress") && t.id !== "dogfood-poc"
|
|
19
|
-
).length;
|
|
20
|
-
}
|
|
21
|
-
async function findActivePlanFile(plansDir) {
|
|
22
|
-
if (!await fileExists(plansDir)) return null;
|
|
23
|
-
const files = (await readdir(plansDir)).filter((f) => f.endsWith(".plan.md")).sort();
|
|
24
|
-
return files[0] ? path.join(plansDir, files[0]) : null;
|
|
25
|
-
}
|
|
26
|
-
async function readPlan(planPath) {
|
|
27
|
-
return readFile(planPath, "utf8");
|
|
28
|
-
}
|
|
29
|
-
var QUEUE_CURSOR_RE = /^- \*\*Queue cursor:\*\*\s*(.+)$/m;
|
|
30
|
-
var QUEUE_STATUS_RE = /^- \*\*Queue status:\*\*\s*(.+)$/m;
|
|
31
|
-
var QUEUE_DONE_STATUSES = /* @__PURE__ */ new Set(["exhausted", "completed", "done"]);
|
|
32
|
-
function readRunQueueState(handoff) {
|
|
33
|
-
const queue = extractHandoffNamedPlans(handoff).runQueue;
|
|
34
|
-
let cursorIndex = null;
|
|
35
|
-
let cursorPlan = null;
|
|
36
|
-
const cursorRaw = QUEUE_CURSOR_RE.exec(handoff)?.[1]?.trim() ?? "";
|
|
37
|
-
const indexMatch = /^(\d+)\b/.exec(cursorRaw);
|
|
38
|
-
if (indexMatch?.[1]) cursorIndex = Number(indexMatch[1]);
|
|
39
|
-
const currentMatch = /current:\s*`?([^`()]+?)`?\s*\)/i.exec(cursorRaw);
|
|
40
|
-
if (currentMatch?.[1]) {
|
|
41
|
-
const base = currentMatch[1].trim().split("/").pop() ?? "";
|
|
42
|
-
if (/\.plan\.md$/i.test(base)) cursorPlan = base;
|
|
43
|
-
}
|
|
44
|
-
const status = QUEUE_STATUS_RE.exec(handoff)?.[1]?.trim().split(/\s+/)[0]?.replace(/[`*]/g, "");
|
|
45
|
-
const queueStatus = status ? status : null;
|
|
46
|
-
const finished = queueStatus !== null && QUEUE_DONE_STATUSES.has(queueStatus.toLowerCase());
|
|
47
|
-
let cursor = null;
|
|
48
|
-
if (cursorIndex !== null && cursorIndex >= 0 && cursorIndex < queue.length) {
|
|
49
|
-
cursor = cursorIndex;
|
|
50
|
-
} else if (cursorPlan && queue.includes(cursorPlan)) {
|
|
51
|
-
cursor = queue.indexOf(cursorPlan);
|
|
52
|
-
}
|
|
53
|
-
const current = cursor !== null ? queue[cursor] ?? null : cursorPlan;
|
|
54
|
-
return { queue, cursor, current, status: queueStatus, finished };
|
|
55
|
-
}
|
|
56
|
-
function defaultPlanStateIo() {
|
|
57
|
-
return {
|
|
58
|
-
readFile: async (file) => {
|
|
59
|
-
try {
|
|
60
|
-
return await readFile(file, "utf8");
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
findActivePlan: findActivePlanFile
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
async function resolveActivePlanFromHandoff(root, handoff, io = defaultPlanStateIo()) {
|
|
69
|
-
const queue = readRunQueueState(handoff);
|
|
70
|
-
const base = (queue.queue.length > 0 && !queue.finished ? queue.current : null) ?? extractHandoffNamedPlans(handoff).active;
|
|
71
|
-
if (!base) return io.findActivePlan(path.join(root, ".cursor", "plans"));
|
|
72
|
-
for (const candidate of namedPlanCandidatePaths(root, base)) {
|
|
73
|
-
if (await io.readFile(candidate) !== null) return candidate;
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
async function resolveActivePlanPath(root, io = defaultPlanStateIo()) {
|
|
78
|
-
const handoff = await io.readFile(path.join(root, HANDOFF_REL)) ?? "";
|
|
79
|
-
return resolveActivePlanFromHandoff(root, handoff, io);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export {
|
|
83
|
-
countPendingTodos,
|
|
84
|
-
findActivePlanFile,
|
|
85
|
-
readPlan,
|
|
86
|
-
readRunQueueState,
|
|
87
|
-
resolveActivePlanFromHandoff,
|
|
88
|
-
resolveActivePlanPath
|
|
89
|
-
};
|