@asterxsk/kiln 0.2.0 → 0.4.0

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 (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +4 -19
  3. package/agent/extensions/AGENTS.md +68 -68
  4. package/agent/extensions/ask-user/install.ps1 +4 -0
  5. package/agent/extensions/ask-user/install.sh +3 -0
  6. package/agent/extensions/background-terminals/install.ps1 +4 -0
  7. package/agent/extensions/background-terminals/install.sh +3 -0
  8. package/agent/extensions/destructive/install.ps1 +4 -0
  9. package/agent/extensions/destructive/install.sh +3 -0
  10. package/agent/extensions/file-search/install.ps1 +4 -0
  11. package/agent/extensions/file-search/install.sh +3 -0
  12. package/agent/extensions/goal/install.ps1 +4 -0
  13. package/agent/extensions/goal/install.sh +3 -0
  14. package/agent/extensions/herdr-agent-state.ts +257 -0
  15. package/agent/extensions/kiln-update/README.md +25 -0
  16. package/agent/extensions/kiln-update/index.ts +99 -0
  17. package/agent/extensions/kiln-update/install.ps1 +27 -0
  18. package/agent/extensions/kiln-update/install.sh +24 -0
  19. package/agent/extensions/modelconf/install.ps1 +4 -0
  20. package/agent/extensions/modelconf/install.sh +3 -0
  21. package/agent/extensions/shared/install.ps1 +4 -0
  22. package/agent/extensions/shared/install.sh +3 -0
  23. package/agent/extensions/skillsconf/install.ps1 +4 -0
  24. package/agent/extensions/skillsconf/install.sh +3 -0
  25. package/agent/extensions/statusline/install.ps1 +4 -0
  26. package/agent/extensions/statusline/install.sh +3 -0
  27. package/agent/extensions/subagents/install.ps1 +4 -0
  28. package/agent/extensions/subagents/install.sh +3 -0
  29. package/agent/extensions/taste/index.ts +443 -0
  30. package/agent/extensions/taste/install.ps1 +27 -0
  31. package/agent/extensions/taste/install.sh +24 -0
  32. package/agent/extensions/todo/install.ps1 +4 -0
  33. package/agent/extensions/todo/install.sh +3 -0
  34. package/agent/extensions/trim-context/install.ps1 +4 -0
  35. package/agent/extensions/trim-context/install.sh +3 -0
  36. package/agent/version.txt +1 -0
  37. package/bin/kiln.js +590 -471
  38. package/package.json +27 -27
  39. package/agent/install.ps1 +0 -637
  40. package/agent/install.sh +0 -620
@@ -0,0 +1,99 @@
1
+ /**
2
+ * kiln-update — tell the user when their kiln checkout is behind GitHub.
3
+ *
4
+ * Compares the installed `~/.pi/agent/version.txt` against the one on the
5
+ * main branch. On mismatch, shows a nudge on every session start:
6
+ *
7
+ * Kiln update available (0.2.0 → 0.3.0) — to update kiln to the newest
8
+ * version, run: kiln
9
+ *
10
+ * Failures (offline, timeout, missing file) are silent — this must never
11
+ * block or annoy. Bump `agent/version.txt` with every user-visible change;
12
+ * no npm publish is needed since `kiln` installs from GitHub.
13
+ *
14
+ * Env overrides:
15
+ * KILN_VERSION_URL Full URL of the remote version.txt (for forks).
16
+ * KILN_NO_UPDATE_CHECK=1 Disable the check entirely.
17
+ * PI_AGENT_DIR Local agent dir (default ~/.pi/agent).
18
+ */
19
+
20
+ import { readFileSync } from "node:fs";
21
+ import { homedir } from "node:os";
22
+ import { dirname, join } from "node:path";
23
+ import { fileURLToPath } from "node:url";
24
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
25
+
26
+ const REPO = "asterxsk/kiln";
27
+ const BRANCH = "main";
28
+ const TIMEOUT_MS = 5000;
29
+
30
+ function remoteUrl(): string {
31
+ return (
32
+ process.env.KILN_VERSION_URL ||
33
+ `https://raw.githubusercontent.com/${REPO}/${BRANCH}/agent/version.txt`
34
+ );
35
+ }
36
+
37
+ function agentDir(): string {
38
+ return process.env.PI_AGENT_DIR || join(homedir(), ".pi", "agent");
39
+ }
40
+
41
+ /** Installed version, or "" when unknown. */
42
+ export function localVersion(): string {
43
+ try {
44
+ return readFileSync(join(agentDir(), "version.txt"), "utf8").trim();
45
+ } catch {
46
+ // Fall through to the checkout-relative fallback.
47
+ }
48
+ try {
49
+ const here = dirname(fileURLToPath(import.meta.url));
50
+ return readFileSync(join(here, "..", "..", "version.txt"), "utf8").trim();
51
+ } catch {
52
+ return "";
53
+ }
54
+ }
55
+
56
+ /** GitHub version, or "" when unreachable. Never throws. */
57
+ export async function remoteVersion(): Promise<string> {
58
+ const ctrl = new AbortController();
59
+ const timer = setTimeout(() => ctrl.abort(), TIMEOUT_MS);
60
+ try {
61
+ const res = await fetch(remoteUrl(), { signal: ctrl.signal });
62
+ if (!res.ok) return "";
63
+ return (await res.text()).trim();
64
+ } catch {
65
+ return "";
66
+ } finally {
67
+ clearTimeout(timer);
68
+ }
69
+ }
70
+
71
+ /** The update to report, or null when up to date / unknown / disabled. */
72
+ export async function checkForUpdate(): Promise<{ local: string; remote: string } | null> {
73
+ if (process.env.KILN_NO_UPDATE_CHECK === "1") return null;
74
+ const local = localVersion();
75
+ if (!local) return null;
76
+ const remote = await remoteVersion();
77
+ if (!remote || remote === local) return null;
78
+ return { local, remote };
79
+ }
80
+
81
+ function updateMessage(local: string, remote: string): string {
82
+ return `Kiln update available (${local} → ${remote}) — to update kiln to the newest version, run: kiln`;
83
+ }
84
+
85
+ export default function (pi: ExtensionAPI) {
86
+ pi.on("session_start", async (_event, ctx) => {
87
+ const update = await checkForUpdate();
88
+ if (update) ctx.ui.notify(updateMessage(update.local, update.remote), "warning");
89
+ });
90
+
91
+ pi.registerCommand("kiln-update", {
92
+ description: "Check whether kiln is behind the GitHub version",
93
+ handler: async (_args, ctx) => {
94
+ const update = await checkForUpdate();
95
+ if (update) ctx.ui.notify(updateMessage(update.local, update.remote), "warning");
96
+ else ctx.ui.notify("kiln is up to date", "info");
97
+ },
98
+ });
99
+ }
@@ -0,0 +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
@@ -0,0 +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"
@@ -2,6 +2,10 @@
2
2
  # Per-extension installer — Windows / PowerShell
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
9
  $extDir = $PSScriptRoot
6
10
  if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
7
11
  if (-not (Test-Path "$extDir/package.json")) {
@@ -2,6 +2,9 @@
2
2
  # Per-extension installer — macOS / Linux
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
8
  EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
9
  if [ ! -f "$EXT_DIR/package.json" ]; then
7
10
  echo " · no package.json — skipping"
@@ -2,6 +2,10 @@
2
2
  # Per-extension installer — Windows / PowerShell
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
9
  $extDir = $PSScriptRoot
6
10
  if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
7
11
  if (-not (Test-Path "$extDir/package.json")) {
@@ -2,6 +2,9 @@
2
2
  # Per-extension installer — macOS / Linux
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
8
  EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
9
  if [ ! -f "$EXT_DIR/package.json" ]; then
7
10
  echo " · no package.json — skipping"
@@ -2,6 +2,10 @@
2
2
  # Per-extension installer — Windows / PowerShell
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
9
  $extDir = $PSScriptRoot
6
10
  if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
7
11
  if (-not (Test-Path "$extDir/package.json")) {
@@ -2,6 +2,9 @@
2
2
  # Per-extension installer — macOS / Linux
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
8
  EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
9
  if [ ! -f "$EXT_DIR/package.json" ]; then
7
10
  echo " · no package.json — skipping"
@@ -2,6 +2,10 @@
2
2
  # Per-extension installer — Windows / PowerShell
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
9
  $extDir = $PSScriptRoot
6
10
  if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
7
11
  if (-not (Test-Path "$extDir/package.json")) {
@@ -2,6 +2,9 @@
2
2
  # Per-extension installer — macOS / Linux
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
8
  EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
9
  if [ ! -f "$EXT_DIR/package.json" ]; then
7
10
  echo " · no package.json — skipping"
@@ -2,6 +2,10 @@
2
2
  # Per-extension installer — Windows / PowerShell
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
9
  $extDir = $PSScriptRoot
6
10
  if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
7
11
  if (-not (Test-Path "$extDir/package.json")) {
@@ -2,6 +2,9 @@
2
2
  # Per-extension installer — macOS / Linux
3
3
  # Installs npm dependencies for this extension. No-op if no package.json.
4
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
5
8
  EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
9
  if [ ! -f "$EXT_DIR/package.json" ]; then
7
10
  echo " · no package.json — skipping"