@asterxsk/kiln 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/README.md +155 -155
  2. package/agent/AGENTS.md +67 -67
  3. package/agent/README.md +5 -5
  4. package/agent/extensions/ask-user/index.ts +418 -418
  5. package/agent/extensions/ask-user/install.ps1 +27 -27
  6. package/agent/extensions/ask-user/install.sh +24 -24
  7. package/agent/extensions/ask-user/package-lock.json +769 -769
  8. package/agent/extensions/ask-user/package.json +19 -19
  9. package/agent/extensions/ask-user/prompt.ts +45 -45
  10. package/agent/extensions/ask-user/tsconfig.json +7 -7
  11. package/agent/extensions/background-terminals/docs/implementation-guide.md +942 -942
  12. package/agent/extensions/background-terminals/index.ts +627 -627
  13. package/agent/extensions/background-terminals/install.ps1 +27 -27
  14. package/agent/extensions/background-terminals/install.sh +24 -24
  15. package/agent/extensions/background-terminals/manager.test.ts +735 -735
  16. package/agent/extensions/background-terminals/output.test.ts +109 -109
  17. package/agent/extensions/background-terminals/package-lock.json +769 -769
  18. package/agent/extensions/background-terminals/package.json +17 -17
  19. package/agent/extensions/background-terminals/prompt.test.ts +125 -125
  20. package/agent/extensions/background-terminals/ps.test.ts +82 -82
  21. package/agent/extensions/background-terminals/result-delivery.test.ts +44 -44
  22. package/agent/extensions/background-terminals/src/domain.ts +87 -87
  23. package/agent/extensions/background-terminals/src/manager.ts +907 -907
  24. package/agent/extensions/background-terminals/src/output.ts +84 -84
  25. package/agent/extensions/background-terminals/src/prompt.ts +142 -142
  26. package/agent/extensions/background-terminals/src/result-delivery.ts +27 -27
  27. package/agent/extensions/background-terminals/src/runtime.ts +36 -36
  28. package/agent/extensions/background-terminals/src/ui/output-view.ts +79 -79
  29. package/agent/extensions/background-terminals/src/ui/ps.ts +621 -621
  30. package/agent/extensions/background-terminals/tsconfig.json +7 -7
  31. package/agent/extensions/destructive/README.md +31 -31
  32. package/agent/extensions/destructive/index.ts +88 -88
  33. package/agent/extensions/destructive/install.ps1 +27 -27
  34. package/agent/extensions/destructive/install.sh +24 -24
  35. package/agent/extensions/file-search/index.spec.ts +443 -443
  36. package/agent/extensions/file-search/index.ts +459 -459
  37. package/agent/extensions/file-search/install.ps1 +27 -27
  38. package/agent/extensions/file-search/install.sh +24 -24
  39. package/agent/extensions/file-search/package-lock.json +2253 -2253
  40. package/agent/extensions/file-search/package.json +23 -23
  41. package/agent/extensions/file-search/src/args.ts +122 -122
  42. package/agent/extensions/file-search/src/binaries.ts +422 -422
  43. package/agent/extensions/file-search/src/output.ts +126 -126
  44. package/agent/extensions/file-search/src/process.ts +146 -146
  45. package/agent/extensions/file-search/src/prompt.ts +52 -52
  46. package/agent/extensions/file-search/tsconfig.json +7 -7
  47. package/agent/extensions/goal/README.md +50 -50
  48. package/agent/extensions/goal/index.ts +155 -155
  49. package/agent/extensions/goal/install.ps1 +27 -27
  50. package/agent/extensions/goal/install.sh +24 -24
  51. package/agent/extensions/kiln-update/README.md +38 -25
  52. package/agent/extensions/kiln-update/index.ts +177 -99
  53. package/agent/extensions/modelconf/PLAN.md +915 -915
  54. package/agent/extensions/modelconf/README.md +66 -66
  55. package/agent/extensions/modelconf/index.ts +296 -296
  56. package/agent/extensions/modelconf/install.ps1 +27 -27
  57. package/agent/extensions/modelconf/install.sh +24 -24
  58. package/agent/extensions/modelconf/package-lock.json +1809 -1809
  59. package/agent/extensions/modelconf/package.json +13 -13
  60. package/agent/extensions/modelconf/src/fuzzy.ts +26 -26
  61. package/agent/extensions/modelconf/src/glob.ts +13 -13
  62. package/agent/extensions/modelconf/src/persistence.test.ts +46 -46
  63. package/agent/extensions/modelconf/src/persistence.ts +164 -164
  64. package/agent/extensions/modelconf/src/ui/ModelConfView.test.ts +75 -75
  65. package/agent/extensions/modelconf/src/ui/ModelConfView.ts +1101 -1101
  66. package/agent/extensions/modelconf/tsconfig.json +15 -15
  67. package/agent/extensions/pi-web-access/CHANGELOG.md +690 -690
  68. package/agent/extensions/pi-web-access/LICENSE +21 -21
  69. package/agent/extensions/pi-web-access/README.md +470 -470
  70. package/agent/extensions/pi-web-access/SECURITY.md +5 -5
  71. package/agent/extensions/pi-web-access/activity.ts +101 -101
  72. package/agent/extensions/pi-web-access/auth-fetch.ts +148 -148
  73. package/agent/extensions/pi-web-access/brightdata-unlocker.ts +272 -272
  74. package/agent/extensions/pi-web-access/chrome-cookies.ts +669 -669
  75. package/agent/extensions/pi-web-access/content-find.ts +139 -139
  76. package/agent/extensions/pi-web-access/credential-source.ts +191 -191
  77. package/agent/extensions/pi-web-access/data-uri-sanitize.ts +406 -406
  78. package/agent/extensions/pi-web-access/datalab-pdf-extract.ts +568 -568
  79. package/agent/extensions/pi-web-access/declared-web-links.ts +173 -173
  80. package/agent/extensions/pi-web-access/evidence/CONTRACT-EVIDENCE.md +496 -496
  81. package/agent/extensions/pi-web-access/evidence/contract-probe.mjs +140 -140
  82. package/agent/extensions/pi-web-access/exa.ts +526 -526
  83. package/agent/extensions/pi-web-access/extract.ts +1196 -1196
  84. package/agent/extensions/pi-web-access/feature-config.ts +29 -29
  85. package/agent/extensions/pi-web-access/fetch-params.ts +111 -111
  86. package/agent/extensions/pi-web-access/gemini-adc.ts +298 -298
  87. package/agent/extensions/pi-web-access/gemini-api.ts +353 -353
  88. package/agent/extensions/pi-web-access/gemini-pdf-extract.ts +108 -108
  89. package/agent/extensions/pi-web-access/gemini-search.ts +21 -21
  90. package/agent/extensions/pi-web-access/gemini-url-context.ts +128 -128
  91. package/agent/extensions/pi-web-access/gemini-web-config.ts +101 -101
  92. package/agent/extensions/pi-web-access/gemini-web.ts +487 -487
  93. package/agent/extensions/pi-web-access/github-api.ts +197 -197
  94. package/agent/extensions/pi-web-access/github-extract.ts +746 -746
  95. package/agent/extensions/pi-web-access/github-issue-pr.ts +700 -700
  96. package/agent/extensions/pi-web-access/index.ts +1737 -1737
  97. package/agent/extensions/pi-web-access/package-lock.json +5808 -5808
  98. package/agent/extensions/pi-web-access/package.json +64 -64
  99. package/agent/extensions/pi-web-access/page-query.ts +96 -96
  100. package/agent/extensions/pi-web-access/pdf-extract.ts +409 -409
  101. package/agent/extensions/pi-web-access/promise-try.d.ts +7 -7
  102. package/agent/extensions/pi-web-access/query-rewrite.ts +51 -51
  103. package/agent/extensions/pi-web-access/render-search-error.ts +170 -170
  104. package/agent/extensions/pi-web-access/rsc-extract.ts +338 -338
  105. package/agent/extensions/pi-web-access/search-types.ts +20 -20
  106. package/agent/extensions/pi-web-access/source-check.ts +282 -282
  107. package/agent/extensions/pi-web-access/ssrf-protection.ts +526 -526
  108. package/agent/extensions/pi-web-access/storage.ts +521 -521
  109. package/agent/extensions/pi-web-access/summary-model-scope.ts +125 -125
  110. package/agent/extensions/pi-web-access/test/auth-fetch.test.mjs +208 -208
  111. package/agent/extensions/pi-web-access/test/brightdata-unlocker.test.mjs +840 -840
  112. package/agent/extensions/pi-web-access/test/chrome-cookie-extraction.test.mjs +441 -441
  113. package/agent/extensions/pi-web-access/test/config-path.test.mjs +283 -283
  114. package/agent/extensions/pi-web-access/test/content-find.test.mjs +25 -25
  115. package/agent/extensions/pi-web-access/test/credential-source.test.mjs +118 -118
  116. package/agent/extensions/pi-web-access/test/data-uri-sanitize.test.mjs +210 -210
  117. package/agent/extensions/pi-web-access/test/datalab-pdf-extract.test.mjs +552 -552
  118. package/agent/extensions/pi-web-access/test/declared-web-links.test.mjs +212 -212
  119. package/agent/extensions/pi-web-access/test/fetch-answer-storage.test.mjs +40 -40
  120. package/agent/extensions/pi-web-access/test/fetch-cache-storage.test.mjs +334 -334
  121. package/agent/extensions/pi-web-access/test/fetch-content-domain-policy.test.mjs +95 -95
  122. package/agent/extensions/pi-web-access/test/fetch-modes.test.mjs +53 -53
  123. package/agent/extensions/pi-web-access/test/fetch-not-found-guidance.test.mjs +92 -92
  124. package/agent/extensions/pi-web-access/test/fetch-params.test.mjs +86 -86
  125. package/agent/extensions/pi-web-access/test/fetch-render-call.test.mjs +34 -34
  126. package/agent/extensions/pi-web-access/test/fetch-routing.test.mjs +173 -173
  127. package/agent/extensions/pi-web-access/test/gemini-adc-auth.test.mjs +257 -257
  128. package/agent/extensions/pi-web-access/test/gemini-api-transport.test.mjs +170 -170
  129. package/agent/extensions/pi-web-access/test/gemini-pdf-extract.test.mjs +133 -133
  130. package/agent/extensions/pi-web-access/test/gemini-web-cookie-opt-in.test.mjs +178 -178
  131. package/agent/extensions/pi-web-access/test/gemini-web-header-overflow.test.mjs +148 -148
  132. package/agent/extensions/pi-web-access/test/get-search-content.test.mjs +223 -223
  133. package/agent/extensions/pi-web-access/test/github-extract.test.mjs +378 -378
  134. package/agent/extensions/pi-web-access/test/github-issue-pr.test.mjs +565 -565
  135. package/agent/extensions/pi-web-access/test/inline-content-config.test.mjs +99 -99
  136. package/agent/extensions/pi-web-access/test/lazy-extract-load.test.mjs +118 -118
  137. package/agent/extensions/pi-web-access/test/local-video-oversize.test.mjs +52 -52
  138. package/agent/extensions/pi-web-access/test/package-typebox-dependency.test.mjs +50 -50
  139. package/agent/extensions/pi-web-access/test/page-query.test.mjs +51 -51
  140. package/agent/extensions/pi-web-access/test/pdf-config.test.mjs +140 -140
  141. package/agent/extensions/pi-web-access/test/pdf-extract.test.mjs +500 -500
  142. package/agent/extensions/pi-web-access/test/proxy-transport.test.mjs +286 -286
  143. package/agent/extensions/pi-web-access/test/query-rewrite.test.mjs +52 -52
  144. package/agent/extensions/pi-web-access/test/rsc-fallback.test.mjs +102 -102
  145. package/agent/extensions/pi-web-access/test/search-error-render.test.mjs +152 -152
  146. package/agent/extensions/pi-web-access/test/search-providers.test.mjs +274 -274
  147. package/agent/extensions/pi-web-access/test/source-check.test.mjs +179 -179
  148. package/agent/extensions/pi-web-access/test/ssrf-allow-ranges-config.test.mjs +205 -205
  149. package/agent/extensions/pi-web-access/test/ssrf-protection.test.mjs +456 -456
  150. package/agent/extensions/pi-web-access/test/summary-model-scope.test.mjs +106 -106
  151. package/agent/extensions/pi-web-access/test/tool-registration-config.test.mjs +182 -182
  152. package/agent/extensions/pi-web-access/test/web-search-answer-render.test.mjs +66 -66
  153. package/agent/extensions/pi-web-access/test/youtube-extract-errors.test.mjs +64 -64
  154. package/agent/extensions/pi-web-access/tsconfig.json +11 -11
  155. package/agent/extensions/pi-web-access/utils.ts +451 -451
  156. package/agent/extensions/pi-web-access/video-extract.ts +392 -392
  157. package/agent/extensions/pi-web-access/youtube-extract.ts +328 -328
  158. package/agent/extensions/shared/activity-status.ts +31 -31
  159. package/agent/extensions/shared/child-session.test.ts +270 -270
  160. package/agent/extensions/shared/child-session.ts +148 -148
  161. package/agent/extensions/shared/context-utilization.test.ts +48 -48
  162. package/agent/extensions/shared/context-utilization.ts +47 -47
  163. package/agent/extensions/shared/dashboard-state.ts +99 -99
  164. package/agent/extensions/shared/install.ps1 +27 -27
  165. package/agent/extensions/shared/install.sh +24 -24
  166. package/agent/extensions/shared/tool-call-timeout.test.ts +117 -117
  167. package/agent/extensions/shared/tool-call-timeout.ts +104 -104
  168. package/agent/extensions/skillsconf/README.md +74 -74
  169. package/agent/extensions/skillsconf/index.ts +92 -92
  170. package/agent/extensions/skillsconf/install.ps1 +27 -27
  171. package/agent/extensions/skillsconf/install.sh +24 -24
  172. package/agent/extensions/skillsconf/package-lock.json +1809 -1809
  173. package/agent/extensions/skillsconf/package.json +18 -18
  174. package/agent/extensions/skillsconf/src/delete-skill.test.ts +64 -64
  175. package/agent/extensions/skillsconf/src/delete-skill.ts +45 -45
  176. package/agent/extensions/skillsconf/src/filter.test.ts +80 -80
  177. package/agent/extensions/skillsconf/src/filter.ts +74 -74
  178. package/agent/extensions/skillsconf/src/fuzzy.ts +26 -26
  179. package/agent/extensions/skillsconf/src/persistence.test.ts +72 -72
  180. package/agent/extensions/skillsconf/src/persistence.ts +169 -169
  181. package/agent/extensions/skillsconf/src/ui/SkillConfView.test.ts +337 -337
  182. package/agent/extensions/skillsconf/src/ui/SkillConfView.ts +758 -758
  183. package/agent/extensions/skillsconf/src/ui/text-input.ts +91 -91
  184. package/agent/extensions/skillsconf/src/ui/tui-helpers.ts +144 -144
  185. package/agent/extensions/skillsconf/tsconfig.json +15 -15
  186. package/agent/extensions/statusline/index.ts +273 -282
  187. package/agent/extensions/statusline/install.ps1 +27 -27
  188. package/agent/extensions/statusline/install.sh +24 -24
  189. package/agent/extensions/subagents/by-the-way.test.ts +29 -29
  190. package/agent/extensions/subagents/claude.test.ts +119 -119
  191. package/agent/extensions/subagents/codex.test.ts +102 -102
  192. package/agent/extensions/subagents/context-usage.test.ts +107 -107
  193. package/agent/extensions/subagents/docs/design-plan.md +568 -568
  194. package/agent/extensions/subagents/docs/effect-v4-extension-guide.md +354 -354
  195. package/agent/extensions/subagents/docs/effect-v4-notes.md +571 -571
  196. package/agent/extensions/subagents/index.ts +779 -779
  197. package/agent/extensions/subagents/install.ps1 +27 -27
  198. package/agent/extensions/subagents/install.sh +24 -24
  199. package/agent/extensions/subagents/manager.test.ts +276 -276
  200. package/agent/extensions/subagents/package-lock.json +2244 -2244
  201. package/agent/extensions/subagents/package.json +19 -19
  202. package/agent/extensions/subagents/result-delivery.test.ts +27 -27
  203. package/agent/extensions/subagents/src/backend.ts +73 -73
  204. package/agent/extensions/subagents/src/backends/claude.ts +701 -701
  205. package/agent/extensions/subagents/src/backends/codex.ts +1060 -1060
  206. package/agent/extensions/subagents/src/backends/pi.ts +575 -575
  207. package/agent/extensions/subagents/src/backends/stub.ts +300 -300
  208. package/agent/extensions/subagents/src/by-the-way.ts +21 -21
  209. package/agent/extensions/subagents/src/domain.ts +253 -253
  210. package/agent/extensions/subagents/src/format.ts +74 -74
  211. package/agent/extensions/subagents/src/manager.ts +736 -736
  212. package/agent/extensions/subagents/src/prompt.ts +92 -92
  213. package/agent/extensions/subagents/src/result-delivery.ts +20 -20
  214. package/agent/extensions/subagents/src/runtime.ts +53 -53
  215. package/agent/extensions/subagents/src/ui/takeover.ts +583 -583
  216. package/agent/extensions/subagents/src/ui/transcript.ts +201 -201
  217. package/agent/extensions/subagents/takeover.test.ts +29 -29
  218. package/agent/extensions/subagents/tsconfig.json +7 -7
  219. package/agent/extensions/todo/AGENTS.md +38 -38
  220. package/agent/extensions/todo/LICENSE +21 -21
  221. package/agent/extensions/todo/config.ts +55 -55
  222. package/agent/extensions/todo/index.ts +151 -151
  223. package/agent/extensions/todo/install.ps1 +27 -27
  224. package/agent/extensions/todo/install.sh +24 -24
  225. package/agent/extensions/todo/locales/de.json +17 -17
  226. package/agent/extensions/todo/locales/en.json +15 -15
  227. package/agent/extensions/todo/locales/es.json +17 -17
  228. package/agent/extensions/todo/locales/fr.json +17 -17
  229. package/agent/extensions/todo/locales/pt-BR.json +17 -17
  230. package/agent/extensions/todo/locales/pt.json +17 -17
  231. package/agent/extensions/todo/locales/ru.json +17 -17
  232. package/agent/extensions/todo/locales/uk.json +17 -17
  233. package/agent/extensions/todo/locales/zh.json +17 -17
  234. package/agent/extensions/todo/package-lock.json +3358 -3358
  235. package/agent/extensions/todo/package.json +67 -67
  236. package/agent/extensions/todo/state/i18n-bridge.ts +64 -64
  237. package/agent/extensions/todo/state/invariants.ts +20 -20
  238. package/agent/extensions/todo/state/replay.ts +38 -38
  239. package/agent/extensions/todo/state/selectors.ts +107 -107
  240. package/agent/extensions/todo/state/state-reducer.ts +326 -326
  241. package/agent/extensions/todo/state/state.ts +18 -18
  242. package/agent/extensions/todo/state/store.ts +82 -82
  243. package/agent/extensions/todo/state/task-graph.ts +57 -57
  244. package/agent/extensions/todo/todo-overlay.ts +200 -200
  245. package/agent/extensions/todo/todo.ts +155 -155
  246. package/agent/extensions/todo/tool/response-envelope.ts +109 -109
  247. package/agent/extensions/todo/tool/types.ts +206 -206
  248. package/agent/extensions/todo/view/format.ts +177 -177
  249. package/agent/extensions/trim-context/README.md +54 -54
  250. package/agent/extensions/trim-context/index.ts +487 -487
  251. package/agent/extensions/trim-context/install.ps1 +27 -27
  252. package/agent/extensions/trim-context/install.sh +24 -24
  253. package/agent/keybindings.json +7 -7
  254. package/agent/version.txt +1 -1
  255. package/bin/kiln.js +20 -13
  256. package/package.json +1 -1
  257. package/agent/extensions/taste/index.ts +0 -443
  258. package/agent/extensions/taste/install.ps1 +0 -27
  259. package/agent/extensions/taste/install.sh +0 -24
@@ -1,27 +1,27 @@
1
- #!/usr/bin/env pwsh
2
- # Per-extension installer — Windows / PowerShell
3
- # Installs npm dependencies for this extension. No-op if no package.json.
4
- $ErrorActionPreference = "Stop"
5
- # Drop npm_config_allow_scripts inherited from a parent npm/npx process:
6
- # npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
7
- Remove-Item Env:\npm_config_allow_scripts -ErrorAction SilentlyContinue
8
- Remove-Item Env:\NPM_CONFIG_ALLOW_SCRIPTS -ErrorAction SilentlyContinue
9
- $extDir = $PSScriptRoot
10
- if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
11
- if (-not (Test-Path "$extDir/package.json")) {
12
- Write-Host " - no package.json — skipping" -ForegroundColor DarkGray
13
- exit 0
14
- }
15
- if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
16
- Write-Host " x npm not found — install Node.js 22+" -ForegroundColor Red
17
- exit 1
18
- }
19
- if (Test-Path "$extDir/package-lock.json") {
20
- Write-Host " - npm ci" -ForegroundColor DarkGray
21
- npm --prefix $extDir ci --no-audit --no-fund
22
- } else {
23
- Write-Host " - npm install" -ForegroundColor DarkGray
24
- npm --prefix $extDir install --no-audit --no-fund
25
- }
26
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
27
- Write-Host " + done" -ForegroundColor Green
1
+ #!/usr/bin/env pwsh
2
+ # Per-extension installer — Windows / PowerShell
3
+ # Installs npm dependencies for this extension. No-op if no package.json.
4
+ $ErrorActionPreference = "Stop"
5
+ # Drop npm_config_allow_scripts inherited from a parent npm/npx process:
6
+ # npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
7
+ Remove-Item Env:\npm_config_allow_scripts -ErrorAction SilentlyContinue
8
+ Remove-Item Env:\NPM_CONFIG_ALLOW_SCRIPTS -ErrorAction SilentlyContinue
9
+ $extDir = $PSScriptRoot
10
+ if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
11
+ if (-not (Test-Path "$extDir/package.json")) {
12
+ Write-Host " - no package.json — skipping" -ForegroundColor DarkGray
13
+ exit 0
14
+ }
15
+ if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
16
+ Write-Host " x npm not found — install Node.js 22+" -ForegroundColor Red
17
+ exit 1
18
+ }
19
+ if (Test-Path "$extDir/package-lock.json") {
20
+ Write-Host " - npm ci" -ForegroundColor DarkGray
21
+ npm --prefix $extDir ci --no-audit --no-fund
22
+ } else {
23
+ Write-Host " - npm install" -ForegroundColor DarkGray
24
+ npm --prefix $extDir install --no-audit --no-fund
25
+ }
26
+ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
27
+ Write-Host " + done" -ForegroundColor Green
@@ -1,24 +1,24 @@
1
- #!/bin/sh
2
- # Per-extension installer — macOS / Linux
3
- # Installs npm dependencies for this extension. No-op if no package.json.
4
- set -eu
5
- # Drop npm_config_allow_scripts inherited from a parent npm/npx process:
6
- # npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
7
- unset npm_config_allow_scripts NPM_CONFIG_ALLOW_SCRIPTS 2>/dev/null || true
8
- EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
9
- if [ ! -f "$EXT_DIR/package.json" ]; then
10
- echo " · no package.json — skipping"
11
- exit 0
12
- fi
13
- if ! command -v npm >/dev/null 2>&1; then
14
- echo " ✖ npm not found — install Node.js 22+" >&2
15
- exit 1
16
- fi
17
- if [ -f "$EXT_DIR/package-lock.json" ]; then
18
- echo " · npm ci"
19
- npm --prefix "$EXT_DIR" ci --no-audit --no-fund
20
- else
21
- echo " · npm install"
22
- npm --prefix "$EXT_DIR" install --no-audit --no-fund
23
- fi
24
- echo " ✓ done"
1
+ #!/bin/sh
2
+ # Per-extension installer — macOS / Linux
3
+ # Installs npm dependencies for this extension. No-op if no package.json.
4
+ set -eu
5
+ # Drop npm_config_allow_scripts inherited from a parent npm/npx process:
6
+ # npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
7
+ unset npm_config_allow_scripts NPM_CONFIG_ALLOW_SCRIPTS 2>/dev/null || true
8
+ EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
9
+ if [ ! -f "$EXT_DIR/package.json" ]; then
10
+ echo " · no package.json — skipping"
11
+ exit 0
12
+ fi
13
+ if ! command -v npm >/dev/null 2>&1; then
14
+ echo " ✖ npm not found — install Node.js 22+" >&2
15
+ exit 1
16
+ fi
17
+ if [ -f "$EXT_DIR/package-lock.json" ]; then
18
+ echo " · npm ci"
19
+ npm --prefix "$EXT_DIR" ci --no-audit --no-fund
20
+ else
21
+ echo " · npm install"
22
+ npm --prefix "$EXT_DIR" install --no-audit --no-fund
23
+ fi
24
+ echo " ✓ done"
@@ -1,7 +1,7 @@
1
- {
2
- "tui.input.submit": "enter",
3
- "tui.input.newLine": "shift+enter",
4
- "app.message.followUp": "alt+f",
5
- "app.session.toggleSort": [],
6
- "app.models.save": "alt+s"
7
- }
1
+ {
2
+ "tui.input.submit": "enter",
3
+ "tui.input.newLine": "shift+enter",
4
+ "app.message.followUp": "alt+f",
5
+ "app.session.toggleSort": [],
6
+ "app.models.save": "alt+s"
7
+ }
package/agent/version.txt CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.2
package/bin/kiln.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- // kiln installer (npm) — installs pi, the forge + context packages, and the curated agent config.
3
- // 1) Install/update pi (@earendil-works/pi-coding-agent)
4
- // 2) Install pi packages (pi-context-usage, @baretread/pi-forge)
2
+ // kiln installer (npm) — installs pi, the compact-tools + context packages, and the curated agent config.
3
+ // 1) Install/update pi via the official script (curl on Unix, irm on Windows — never npm)
4
+ // 2) Install pi packages (pi-context-usage, pi-compact-tools)
5
5
  // 3) Install custom config (AGENTS.md, keybindings, extensions …)
6
6
  // 4) Install per-extension npm deps via each extension's own installer
7
7
  //
@@ -30,8 +30,8 @@ const PI_PACKAGE = "@earendil-works/pi-coding-agent";
30
30
  const NODE_MIN = [22, 19, 0];
31
31
  const DEFAULT_REPO = "https://github.com/asterxsk/kiln";
32
32
  const DEFAULT_BRANCH = "main";
33
- const PACKAGES = ["pi-context-usage@latest", "@baretread/pi-forge@latest"];
34
- const SETTINGS_PACKAGES = ["npm:pi-context-usage", "npm:@baretread/pi-forge"];
33
+ const PACKAGES = ["pi-context-usage@latest", "pi-compact-tools@latest"];
34
+ const SETTINGS_PACKAGES = ["npm:pi-context-usage", "npm:pi-compact-tools"];
35
35
 
36
36
  const startTime = Date.now();
37
37
  let clonedTmp = "";
@@ -49,7 +49,7 @@ for (const k of ["npm_config_allow_scripts", "NPM_CONFIG_ALLOW_SCRIPTS"]) delete
49
49
  // ── summary buckets ─────────────────────────────────────────────────────
50
50
  // Every completed item is recorded here; the final Summary prints them all.
51
51
  const buckets = { skipped: [], updated: [], installed: [], "npm modules": [] };
52
- const FRIENDLY = { "pi-context-usage": "context extension", "@baretread/pi-forge": "forge extension" };
52
+ const FRIENDLY = { "pi-context-usage": "context extension", "pi-compact-tools": "compact tools extension" };
53
53
  function note(bucket, name) { buckets[bucket].push(name); }
54
54
  function prettyPkg(spec) { return FRIENDLY[spec.replace(/^npm:/, "")] || spec; }
55
55
 
@@ -142,7 +142,7 @@ function liveStop() {
142
142
  function title() {
143
143
  line("");
144
144
  line(` ${C.bold}◆ Pi Setup${C.reset}`);
145
- line(` ${C.dim}custom agent config · pi + forge + extensions${C.reset}`);
145
+ line(` ${C.dim}custom agent config · pi + compact-tools + extensions${C.reset}`);
146
146
  if (!isTTY) for (const r of artLines(0)) line(` ${r}`);
147
147
  line("");
148
148
  }
@@ -192,6 +192,13 @@ function piStep(label, args) {
192
192
  if (process.platform === "win32") return runStep("pkg", label, "pi " + args.map(q).join(" "), [], { shell: true });
193
193
  return runStep("pkg", label, "pi", args);
194
194
  }
195
+ // pi installs via its official script — curl on Unix, irm on Windows. Never npm.
196
+ function piInstallStep(step, label) {
197
+ const cmd = process.platform === "win32"
198
+ ? 'powershell -NoProfile -Command "irm https://pi.dev/install.ps1 | iex"'
199
+ : "curl -fsSL https://pi.dev/install.sh | sh";
200
+ return runStep(step, label, cmd, [], { shell: true });
201
+ }
195
202
  const npmVer = process.platform === "win32" ? cmdOutShell("npm.cmd --version") : cmdOut("npm", ["--version"]);
196
203
 
197
204
  // Installed global version of a package ("" when not installed).
@@ -345,7 +352,7 @@ async function main() {
345
352
  note("skipped", "pi");
346
353
  } else {
347
354
  const label = installed ? `updating pi ${installed} → ${latest || "latest"}` : `installing pi`;
348
- const code = await npmStep("1/4", label, ["install", "-g", `${PI_PACKAGE}@latest`, "--no-audit", "--no-fund", "--min-release-age=0"]);
355
+ const code = await piInstallStep("1/4", label);
349
356
  if (code === 0) {
350
357
  detail(` · ${label} — ${cmdOut("pi", ["--version"]) || "?"}`);
351
358
  note(installed ? "updated" : "installed", "pi");
@@ -357,7 +364,7 @@ async function main() {
357
364
  }
358
365
  } else {
359
366
  const label = `installing pi`;
360
- const code = await npmStep("1/4", label, ["install", "-g", `${PI_PACKAGE}@latest`, "--no-audit", "--no-fund", "--min-release-age=0"]);
367
+ const code = await piInstallStep("1/4", label);
361
368
  if (code === 0) {
362
369
  detail(` · ${label} — ${cmdOut("pi", ["--version"]) || "?"}`);
363
370
  note("installed", "pi");
@@ -405,7 +412,7 @@ async function main() {
405
412
  bak = `${targetDir}.bak.${d.getFullYear()}${p2(d.getMonth() + 1)}${p2(d.getDate())}-${p2(d.getHours())}${p2(d.getMinutes())}${p2(d.getSeconds())}`;
406
413
  detail(` · backup ${targetDir}/extensions → ${bak}`);
407
414
  fs.mkdirSync(bak, { recursive: true });
408
- for (const f of ["AGENTS.md", "keybindings.json", "README.md"]) {
415
+ for (const f of ["AGENTS.md", "keybindings.json", "README.md", "version.txt"]) {
409
416
  const s = path.join(targetDir, f);
410
417
  if (fs.existsSync(s)) try { fs.copyFileSync(s, path.join(bak, f)); } catch {}
411
418
  }
@@ -423,7 +430,7 @@ async function main() {
423
430
  let copied = 0;
424
431
  const selfInstall = path.resolve(sourceRoot) === path.resolve(targetDir);
425
432
  if (selfInstall) detail(` · source == target — skipping file copy (self-install)`);
426
- for (const f of ["AGENTS.md", "keybindings.json", "README.md"]) {
433
+ for (const f of ["AGENTS.md", "keybindings.json", "README.md", "version.txt"]) {
427
434
  if (!fs.existsSync(path.join(sourceRoot, f))) continue;
428
435
  if (!selfInstall) fs.copyFileSync(path.join(sourceRoot, f), path.join(targetDir, f));
429
436
  copied++;
@@ -456,7 +463,7 @@ async function main() {
456
463
  j.packages = j.packages || [];
457
464
  let changed = false;
458
465
  for (const pkg of SETTINGS_PACKAGES) if (!j.packages.includes(pkg)) { j.packages.push(pkg); changed = true; }
459
- if (changed) { fs.writeFileSync(p, JSON.stringify(j, null, 2) + "\n"); detail(" · patched settings.json packages → forge + context"); }
466
+ if (changed) { fs.writeFileSync(p, JSON.stringify(j, null, 2) + "\n"); detail(" · patched settings.json packages → compact-tools + context"); }
460
467
  } catch {}
461
468
  }
462
469
  for (const t of ["taste.md", "taste", "taste.json"]) {
@@ -541,7 +548,7 @@ async function main() {
541
548
  else detail(` ⚠ extension deps ${failed.length} failed: ${failed.join(", ")} — see log`);
542
549
  }
543
550
 
544
- // ── pi package ensure (forge + context actually registered with pi) ──
551
+ // ── pi package ensure (compact-tools + context actually registered with pi) ──
545
552
  // `pi list` is truth: global installs mean nothing to pi (it uses its own dir).
546
553
  const defaultDir = path.join(os.homedir(), ".pi", "agent");
547
554
  if (args.skipPackages) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asterxsk/kiln",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Kiln — versioned pi agent configuration (extensions, defaults, keybindings) with an idempotent cross-platform installer.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,443 +0,0 @@
1
- /**
2
- * pi-taste — local "taste" learning, no npx / no network.
3
- *
4
- * Mirrors Command Code's Taste but entirely on-disk:
5
- * - Learns preferences from each completed request via the active local model.
6
- * - Stores them as markdown at two scopes:
7
- * Global : ~/.pi/agent/extensions/taste/taste.md (applies to ALL projects)
8
- * Project: <cwd>/.pi/taste/taste.md (this codebase only)
9
- * - Feeds high-confidence learnings back into the system prompt each turn.
10
- *
11
- * Confidence system: new learning = newConfidence (0.40); a repeat (same
12
- * category + normalized text) raises confidence by repeatIncrement (0.10),
13
- * capped at 0.95. Only learnings >= applyThreshold (0.60) are injected.
14
- */
15
-
16
- import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
17
- import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
18
- import { uuidv7 } from "@earendil-works/pi-ai";
19
- import * as fs from "node:fs";
20
- import * as path from "node:path";
21
- import * as os from "node:os";
22
-
23
- // ---- Paths -------------------------------------------------------------
24
- // Global taste lives INSIDE this extension's folder (per user request).
25
- const EXT_DIR = path.join(os.homedir(), ".pi", "agent", "extensions", "taste");
26
- const GLOBAL_TASTE = path.join(EXT_DIR, "taste.md");
27
- const GLOBAL_SETTINGS = path.join(EXT_DIR, "settings.json");
28
-
29
- const projectTasteFile = (cwd: string) =>
30
- path.join(cwd, CONFIG_DIR_NAME, "taste", "taste.md");
31
- const projectSettingsFile = (cwd: string) =>
32
- path.join(cwd, CONFIG_DIR_NAME, "taste", "settings.json");
33
-
34
- // ---- Settings ----------------------------------------------------------
35
- interface Settings {
36
- learning: boolean;
37
- applyThreshold: number;
38
- newConfidence: number;
39
- repeatIncrement: number;
40
- minPromptLength: number;
41
- minIntervalMs: number;
42
- }
43
-
44
- const DEFAULTS: Settings = {
45
- learning: true,
46
- applyThreshold: 0.6,
47
- newConfidence: 0.4,
48
- repeatIncrement: 0.1,
49
- minPromptLength: 20,
50
- minIntervalMs: 15000,
51
- };
52
-
53
- function loadSettings(file: string): Settings {
54
- try {
55
- if (fs.existsSync(file)) {
56
- return { ...DEFAULTS, ...JSON.parse(fs.readFileSync(file, "utf8")) };
57
- }
58
- } catch {
59
- /* corrupt settings -> defaults */
60
- }
61
- return { ...DEFAULTS };
62
- }
63
-
64
- // ---- Taste data model --------------------------------------------------
65
- interface Item {
66
- text: string;
67
- confidence: number;
68
- }
69
- type Taste = Map<string, Item[]>;
70
-
71
- const normalize = (s: string) =>
72
- s.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
73
-
74
- function parseTaste(text: string): Taste {
75
- const taste: Taste = new Map();
76
- let category = "Other";
77
- for (const line of text.split(/\r?\n/)) {
78
- const h = line.match(/^#\s+(.+?)\s*$/);
79
- if (h) {
80
- category = h[1].trim() || "Other";
81
- if (!taste.has(category)) taste.set(category, []);
82
- continue;
83
- }
84
- const b = line.match(
85
- /^-\s+(.*?)\s*\.\s*Confidence:\s*([0-9]+(?:\.[0-9]+)?)\s*$/i,
86
- );
87
- if (b) {
88
- const items = taste.get(category) ?? [];
89
- items.push({ text: b[1].trim(), confidence: parseFloat(b[2]) });
90
- taste.set(category, items);
91
- }
92
- }
93
- return taste;
94
- }
95
-
96
- function serializeTaste(taste: Taste): string {
97
- const lines: string[] = [];
98
- for (const [category, items] of taste) {
99
- if (items.length === 0) continue;
100
- lines.push(`# ${category}`);
101
- for (const it of [...items].sort((a, b) => b.confidence - a.confidence)) {
102
- lines.push(`- ${it.text}. Confidence: ${it.confidence.toFixed(2)}`);
103
- }
104
- lines.push("");
105
- }
106
- return lines.join("\n").trimEnd() + "\n";
107
- }
108
-
109
- /** Merge one learning; returns true if the file should be rewritten. */
110
- function mergeLearning(
111
- taste: Taste,
112
- category: string,
113
- preference: string,
114
- s: Settings,
115
- ): boolean {
116
- const cat = category.trim() || "Other";
117
- const norm = normalize(preference);
118
- if (!norm) return false;
119
-
120
- const items = taste.get(cat) ?? [];
121
- const existing = items.find((i) => normalize(i.text) === norm);
122
- if (existing) {
123
- const before = existing.confidence;
124
- existing.confidence = Math.min(
125
- 0.95,
126
- +(existing.confidence + s.repeatIncrement).toFixed(2),
127
- );
128
- return existing.confidence !== before;
129
- }
130
- items.push({ text: preference.trim(), confidence: s.newConfidence });
131
- taste.set(cat, items);
132
- return true;
133
- }
134
-
135
- function readTaste(file: string): Taste {
136
- try {
137
- if (fs.existsSync(file)) return parseTaste(fs.readFileSync(file, "utf8"));
138
- } catch {
139
- /* unreadable -> empty */
140
- }
141
- return new Map();
142
- }
143
-
144
- function writeTaste(file: string, taste: Taste): void {
145
- fs.mkdirSync(path.dirname(file), { recursive: true });
146
- fs.writeFileSync(file, serializeTaste(taste), "utf8");
147
- }
148
-
149
- function safeDelete(file: string): void {
150
- try {
151
- if (fs.existsSync(file)) fs.unlinkSync(file);
152
- } catch {
153
- /* ignore */
154
- }
155
- }
156
-
157
- // ---- Apply: build the system-prompt section ----------------------------
158
- function tasteToLines(taste: Taste, threshold: number): string[] {
159
- const out: string[] = [];
160
- for (const [cat, items] of taste) {
161
- const applied = items.filter((i) => i.confidence >= threshold);
162
- if (applied.length === 0) continue;
163
- out.push(`**${cat}**`);
164
- for (const it of [...applied].sort((a, b) => b.confidence - a.confidence)) {
165
- out.push(`- ${it.text}. (conf ${it.confidence.toFixed(2)})`);
166
- }
167
- }
168
- return out;
169
- }
170
-
171
- function buildTasteSection(
172
- gTaste: Taste,
173
- pTaste: Taste,
174
- gThresh: number,
175
- pThresh: number,
176
- ): string {
177
- const gLines = tasteToLines(gTaste, gThresh);
178
- const pLines = tasteToLines(pTaste, pThresh);
179
- if (gLines.length === 0 && pLines.length === 0) return "";
180
-
181
- const parts = [
182
- "## Your learned taste (pi-taste)",
183
- "",
184
- "Preferences learned from your past requests. Follow them unless the current request clearly overrides.",
185
- "",
186
- ];
187
- if (gLines.length) {
188
- parts.push("### Global preferences (all projects)");
189
- parts.push(...gLines, "");
190
- }
191
- if (pLines.length) {
192
- parts.push("### This project");
193
- parts.push(...pLines, "");
194
- }
195
- return parts.join("\n").trimEnd();
196
- }
197
-
198
- // ---- Learn: extract preferences via the active local model ------------
199
- interface RawLearning {
200
- category?: string;
201
- preference?: string;
202
- scope?: "global" | "project";
203
- }
204
-
205
- const EXTRACT_PROMPT = `You are a coding-preference extractor. Given a user's coding request and the assistant's outcome, extract DURABLE preferences about how this user likes to work.
206
-
207
- Rules:
208
- - Extract only preferences clearly evidenced by the request or the resulting choices: tooling, libraries, language style, architecture, testing, git/commit style, documentation, or communication/format.
209
- - Do NOT extract task-specific facts (file names, bug locations, one-off decisions).
210
- - For each, set scope:
211
- - "global" if it applies to ANY software project regardless of language/stack (e.g. "prefer pnpm", "write concise commit messages").
212
- - "project" if it is specific to THIS codebase (its languages, frameworks, conventions, file layout).
213
- - Choose a short category from: CLI, TypeScript, JavaScript, Python, Rust, Go, Architecture, Testing, Git, Documentation, Style, Tooling, Communication, Other.
214
-
215
- Return ONLY minified JSON: an array of {"category":string,"preference":string,"scope":"global"|"project"}. No markdown fences, no commentary. If nothing durable, return [].`;
216
-
217
- function parseLearnings(text: string): RawLearning[] {
218
- let t = text.trim();
219
- const fence = t.match(/```(?:json)?\s*([\s\S]*?)```/i);
220
- if (fence) t = fence[1].trim();
221
- try {
222
- const parsed = JSON.parse(t);
223
- if (!Array.isArray(parsed)) return [];
224
- return parsed
225
- .filter(
226
- (x) =>
227
- x &&
228
- typeof x.preference === "string" &&
229
- x.preference.trim().length > 0,
230
- )
231
- .map((x) => ({
232
- category: typeof x.category === "string" ? x.category : "Other",
233
- preference: x.preference,
234
- scope: x.scope === "global" ? "global" : "project",
235
- }));
236
- } catch {
237
- return [];
238
- }
239
- }
240
-
241
- function lastAssistantText(ctx: ExtensionContext): string {
242
- const entries = ctx.sessionManager.getEntries();
243
- for (let i = entries.length - 1; i >= 0; i--) {
244
- const e = entries[i];
245
- if (e.type === "message" && e.message?.role === "assistant") {
246
- const c = e.message.content;
247
- if (typeof c === "string") return c;
248
- if (Array.isArray(c)) {
249
- return c
250
- .filter((p: any) => p?.type === "text")
251
- .map((p: any) => p.text)
252
- .join("\n");
253
- }
254
- return "";
255
- }
256
- }
257
- return "";
258
- }
259
-
260
- async function extractLearnings(
261
- ctx: ExtensionContext,
262
- userPrompt: string,
263
- assistantText: string,
264
- ): Promise<RawLearning[]> {
265
- if (!ctx.model) return [];
266
- if (!ctx.modelRegistry.hasConfiguredAuth(ctx.model)) return [];
267
-
268
- const context = {
269
- messages: [
270
- {
271
- role: "user" as const,
272
- content: [
273
- {
274
- type: "text" as const,
275
- text:
276
- EXTRACT_PROMPT +
277
- `\n\nUSER REQUEST:\n${userPrompt}\n\nASSISTANT OUTCOME:\n${assistantText}`,
278
- },
279
- ],
280
- timestamp: Date.now(),
281
- },
282
- ],
283
- } as any;
284
-
285
- const res = await ctx.modelRegistry.complete(ctx.model, context, {
286
- reasoningEffort: "low",
287
- cacheRetention: "none",
288
- sessionId: uuidv7(),
289
- });
290
-
291
- const text = res.content
292
- .filter((c: any) => c.type === "text")
293
- .map((c: any) => c.text)
294
- .join("");
295
- return parseLearnings(text);
296
- }
297
-
298
- // ---- Wiring ------------------------------------------------------------
299
- export default function (pi: ExtensionAPI) {
300
- let lastUserPrompt = "";
301
- let lastLearnAt = 0;
302
- let pendingLearn: Promise<void> | null = null;
303
- // True only between a genuine user `input` and that turn's `agent_settled`.
304
- // Synthetic re-runs (auto-compaction, retries) emit no `input`, so this
305
- // stays false and we never learn preferences from a system-generated prompt.
306
- let freshInput = false;
307
-
308
- // A genuine user submission arms learning. Extension-injected messages
309
- // (source "extension") are excluded so we don't learn the taste of our own
310
- // meta-prompts (e.g. review-subagent instructions).
311
- pi.on("input", (event) => {
312
- if (event.source !== "extension") freshInput = true;
313
- });
314
-
315
- // Apply: inject learned taste before each agent run.
316
- pi.on("before_agent_start", (event, ctx) => {
317
- if (freshInput) lastUserPrompt = event.prompt ?? "";
318
-
319
-
320
- const gSettings = loadSettings(GLOBAL_SETTINGS);
321
- const pSettings = loadSettings(projectSettingsFile(ctx.cwd));
322
- const gTaste = readTaste(GLOBAL_TASTE);
323
- const pTaste = readTaste(projectTasteFile(ctx.cwd));
324
-
325
- const section = buildTasteSection(
326
- gTaste,
327
- pTaste,
328
- gSettings.applyThreshold,
329
- pSettings.applyThreshold,
330
- );
331
- if (!section) return;
332
- return { systemPrompt: event.systemPrompt + "\n\n" + section };
333
- });
334
-
335
- // Learn: after a request fully settles (no retry/compact/follow-up left).
336
- pi.on("agent_settled", async (_event, ctx) => {
337
- const gSettings = loadSettings(GLOBAL_SETTINGS);
338
- const pSettings = loadSettings(projectSettingsFile(ctx.cwd));
339
- if (!gSettings.learning && !pSettings.learning) return;
340
- if (!freshInput) return; // synthetic re-run (e.g. auto-compaction) — skip
341
- freshInput = false; // this genuine turn is now being consumed
342
-
343
- const prompt = lastUserPrompt.trim();
344
- if (!prompt || prompt.length < gSettings.minPromptLength) return;
345
- if (prompt.startsWith("/taste")) return; // don't learn from our own command
346
-
347
- // Rate-limit window follows whichever scope is actually learning.
348
- const interval = gSettings.learning
349
- ? gSettings.minIntervalMs
350
- : pSettings.minIntervalMs;
351
- if (Date.now() - lastLearnAt < interval) return;
352
-
353
- const assistantText = lastAssistantText(ctx);
354
- if (!assistantText) return;
355
-
356
- const learnings = await extractLearnings(ctx, prompt, assistantText);
357
- if (learnings.length === 0) return;
358
-
359
- // Only consume the cooldown once we actually learned something.
360
- lastLearnAt = Date.now();
361
-
362
- const task = (async () => {
363
- let wrote = false;
364
- for (const l of learnings) {
365
- const isGlobal = l.scope === "global";
366
- const settings = isGlobal ? gSettings : pSettings;
367
- if (!settings.learning) continue;
368
- const file = isGlobal ? GLOBAL_TASTE : projectTasteFile(ctx.cwd);
369
- const taste = readTaste(file);
370
- if (mergeLearning(taste, l.category ?? "Other", l.preference ?? "", settings)) {
371
- writeTaste(file, taste);
372
- wrote = true;
373
- }
374
- }
375
- if (wrote && ctx.hasUI) {
376
- ctx.ui.notify(
377
- `TASTE learned ${learnings.length} preference(s)`,
378
- "info",
379
- );
380
- }
381
- })();
382
- pendingLearn = task;
383
- await task;
384
- });
385
-
386
- // Flush any in-flight learning so it isn't lost on exit.
387
- pi.on("session_shutdown", async () => {
388
- if (pendingLearn) {
389
- try {
390
- await pendingLearn;
391
- } catch {
392
- /* ignore */
393
- }
394
- }
395
- });
396
-
397
- // /taste — view or reset learnings.
398
- pi.registerCommand("taste", {
399
- description:
400
- "Show or reset learned taste. Usage: /taste [reset [global|project]]",
401
- handler: async (args, ctx) => {
402
- const parts = args.trim().split(/\s+/).filter(Boolean);
403
- if (parts[0] === "reset") {
404
- const scope = parts[1];
405
- if (scope === "global") {
406
- safeDelete(GLOBAL_TASTE);
407
- ctx.ui.notify("Cleared global taste.", "info");
408
- } else if (scope === "project") {
409
- safeDelete(projectTasteFile(ctx.cwd));
410
- ctx.ui.notify("Cleared project taste.", "info");
411
- } else if (!scope) {
412
- safeDelete(GLOBAL_TASTE);
413
- safeDelete(projectTasteFile(ctx.cwd));
414
- ctx.ui.notify("Cleared global + project taste.", "info");
415
- } else {
416
- ctx.ui.notify(
417
- `Unknown scope '${scope}'. Use 'global' or 'project'.`,
418
- "warning",
419
- );
420
- }
421
- return;
422
- }
423
-
424
- const g = readTaste(GLOBAL_TASTE);
425
- const p = readTaste(projectTasteFile(ctx.cwd));
426
- const gSettings = loadSettings(GLOBAL_SETTINGS);
427
- const pSettings = loadSettings(projectSettingsFile(ctx.cwd));
428
- const count = (t: Taste) =>
429
- [...t.values()].reduce((n, a) => n + a.length, 0);
430
- const applied = (t: Taste, th: number) =>
431
- [...t.values()].flat().filter((i) => i.confidence >= th).length;
432
-
433
- ctx.ui.notify(
434
- [
435
- `TASTE — global : ${count(g)} prefs (${applied(g, gSettings.applyThreshold)} applied) → ${GLOBAL_TASTE}`,
436
- `TASTE — project: ${count(p)} prefs (${applied(p, pSettings.applyThreshold)} applied) → ${projectTasteFile(ctx.cwd)}`,
437
- `Run '/taste reset [global|project]' to clear.`,
438
- ].join("\n"),
439
- "info",
440
- );
441
- },
442
- });
443
- }