portable-agent-layer 0.117.0 → 0.117.1-canary.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.
- package/assets/statusline.ps1 +13 -14
- package/assets/statusline.sh +10 -10
- package/package.json +1 -1
- package/src/bronze/events.ts +2 -1
- package/src/cli/doctor/health.ts +1 -1
- package/src/progress/main-checkout.ts +24 -0
- package/src/progress/merged-worktrees.ts +6 -0
- package/src/progress/progress-tree-prs.ts +3 -2
- package/src/progress/progress-tree.ts +5 -1
- package/src/targets/pal-hook-command.ts +2 -2
- package/src/usage/hook-run.ts +8 -1
package/assets/statusline.ps1
CHANGED
|
@@ -54,24 +54,23 @@ $palSettings = Join-Path $env:USERPROFILE ".pal\settings.json"
|
|
|
54
54
|
if (-not (Test-Path $palSettings)) { $palSettings = Join-Path $env:USERPROFILE ".pal\memory\pal-settings.json" }
|
|
55
55
|
|
|
56
56
|
$OPEN_ISCS = 0
|
|
57
|
-
$PROJECT_NAME = ""
|
|
58
57
|
$projectsDir = Join-Path $env:USERPROFILE ".pal\work\projects"
|
|
59
58
|
if (-not (Test-Path $projectsDir)) { $projectsDir = Join-Path $env:USERPROFILE ".pal\memory\projects" }
|
|
60
|
-
|
|
59
|
+
$bindingsFile = Join-Path $env:USERPROFILE ".pal\bindings.json"
|
|
60
|
+
if ((Test-Path $projectsDir) -and (Test-Path $bindingsFile)) {
|
|
61
61
|
try {
|
|
62
62
|
$CWD_NORM = $CWD.Replace('/', '\').TrimEnd('\')
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
$
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
63
|
+
$bindings = Get-Content $bindingsFile -Raw | ConvertFrom-Json
|
|
64
|
+
$project = $bindings.PSObject.Properties |
|
|
65
|
+
ForEach-Object { [pscustomobject]@{ Slug = $_.Name; Path = ([string]$_.Value).Replace('/', '\').TrimEnd('\') } } |
|
|
66
|
+
Where-Object { $CWD_NORM -eq $_.Path -or $CWD_NORM.StartsWith($_.Path + '\', [StringComparison]::OrdinalIgnoreCase) } |
|
|
67
|
+
Sort-Object { $_.Path.Length } -Descending |
|
|
68
|
+
Select-Object -First 1
|
|
69
|
+
if ($project) {
|
|
70
|
+
$isa = Join-Path $projectsDir "$($project.Slug)\ISA.md"
|
|
71
|
+
if (Test-Path $isa) {
|
|
72
|
+
$content = Get-Content $isa -Raw -ErrorAction SilentlyContinue
|
|
73
|
+
$OPEN_ISCS = ([regex]::Matches($content, '- \[ \] ISC-')).Count
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
} catch { $OPEN_ISCS = 0 }
|
package/assets/statusline.sh
CHANGED
|
@@ -85,17 +85,17 @@ PAL_SETTINGS="$HOME/.pal/settings.json"
|
|
|
85
85
|
OPEN_ISCS=0
|
|
86
86
|
PROJECTS_DIR="$HOME/.pal/work/projects"
|
|
87
87
|
[ -d "$PROJECTS_DIR" ] || PROJECTS_DIR="$HOME/.pal/memory/projects"
|
|
88
|
-
|
|
88
|
+
BINDINGS="$HOME/.pal/bindings.json"
|
|
89
|
+
if [ -d "$PROJECTS_DIR" ] && [ -f "$BINDINGS" ]; then
|
|
89
90
|
CWD_NORM="${CWD%/}"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
done
|
|
91
|
+
PROJECT=$(jq -r --arg cwd "$CWD_NORM" '
|
|
92
|
+
to_entries
|
|
93
|
+
| map(select(.value as $p | ($p | rtrimstr("/")) as $p | $cwd == $p or ($cwd | startswith($p + "/"))))
|
|
94
|
+
| max_by(.value | length) | .key // empty' "$BINDINGS" 2>/dev/null)
|
|
95
|
+
ISA="$PROJECTS_DIR/$PROJECT/ISA.md"
|
|
96
|
+
if [ -n "$PROJECT" ] && [ -f "$ISA" ]; then
|
|
97
|
+
OPEN_ISCS=$(grep -c -- '- \[ \] ISC-' "$ISA" 2>/dev/null) || OPEN_ISCS=0
|
|
98
|
+
fi
|
|
99
99
|
fi
|
|
100
100
|
|
|
101
101
|
# Create context progress bar (20 chars wide)
|
package/package.json
CHANGED
package/src/bronze/events.ts
CHANGED
|
@@ -246,8 +246,9 @@ export const EVENT_FIELDS = {
|
|
|
246
246
|
"early",
|
|
247
247
|
],
|
|
248
248
|
worktree_pruned: ["branch"],
|
|
249
|
+
worktree_prune_failed: ["branch"],
|
|
249
250
|
git_state_injected: ["trigger", "source", "changed", "committedFiles", "chars"],
|
|
250
|
-
hook_run: ["hook", "event", "durationMs", "exitCode"],
|
|
251
|
+
hook_run: ["hook", "event", "part", "durationMs", "exitCode"],
|
|
251
252
|
repo_state: ["head", "branch", "changed", "ahead", "behind"],
|
|
252
253
|
} as const satisfies Record<string, readonly string[]>;
|
|
253
254
|
|
package/src/cli/doctor/health.ts
CHANGED
|
@@ -110,7 +110,7 @@ export function loginExpiryFindings(
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
const MOVES_EXPLAINED =
|
|
113
|
-
"they move your data, so they run only when you start them: PAL must be idle, a verified backup is taken first, every file is hash-checked, and pal cli migrate --undo <id> puts it back. PAL reads the old folders until then. PAL 1.0
|
|
113
|
+
"they move your data, so they run only when you start them: PAL must be idle, a verified backup is taken first, every file is hash-checked, and pal cli migrate --undo <id> puts it back. PAL reads the old folders until then. PAL 1.0 needs every one of them";
|
|
114
114
|
|
|
115
115
|
function ownerMovesFinding(pending: PendingMigration[]): Finding[] {
|
|
116
116
|
const count = pending.filter((migration) => migration.ownerRun).length;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, relative, resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
const LINKED_WORKTREE = /^gitdir:\s*(.+)[\\/]\.git[\\/]worktrees[\\/][^\\/]+\s*$/;
|
|
5
|
+
|
|
6
|
+
/** The main checkout a linked worktree belongs to, read from its `.git` file; the path itself otherwise. */
|
|
7
|
+
export function mainCheckoutOf(cwd: string): string {
|
|
8
|
+
let dir = resolve(cwd);
|
|
9
|
+
|
|
10
|
+
for (;;) {
|
|
11
|
+
const dotGit = resolve(dir, ".git");
|
|
12
|
+
|
|
13
|
+
if (existsSync(dotGit)) {
|
|
14
|
+
if (statSync(dotGit).isDirectory()) return resolve(cwd);
|
|
15
|
+
const main = LINKED_WORKTREE.exec(readFileSync(dotGit, "utf-8").trim())?.[1];
|
|
16
|
+
|
|
17
|
+
return main ? resolve(main, relative(dir, resolve(cwd))) : resolve(cwd);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const parent = dirname(dir);
|
|
21
|
+
if (parent === dir) return resolve(cwd);
|
|
22
|
+
dir = parent;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -104,6 +104,12 @@ export function removeWorktree(
|
|
|
104
104
|
const refusal = gitRefusal(spawnSync("git", ["-C", cwd, "worktree", "remove", path]));
|
|
105
105
|
if (refusal === null)
|
|
106
106
|
appendEvent("worktree_pruned", { branch }, { cwd, content: { path, branch } });
|
|
107
|
+
else
|
|
108
|
+
appendEvent(
|
|
109
|
+
"worktree_prune_failed",
|
|
110
|
+
{ branch },
|
|
111
|
+
{ cwd, content: { path, branch, reason: refusal } }
|
|
112
|
+
);
|
|
107
113
|
|
|
108
114
|
return refusal;
|
|
109
115
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { spawnSync } from "node:child_process";
|
|
9
|
+
import { logError } from "../core/log";
|
|
9
10
|
import {
|
|
10
11
|
appendEvent,
|
|
11
12
|
buildTree,
|
|
@@ -239,7 +240,7 @@ export function settleAttachedPrs(
|
|
|
239
240
|
): void {
|
|
240
241
|
try {
|
|
241
242
|
checkCandidates(scope, cwd, options);
|
|
242
|
-
} catch {
|
|
243
|
-
|
|
243
|
+
} catch (err) {
|
|
244
|
+
logError("progress:settle-prs", err);
|
|
244
245
|
}
|
|
245
246
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { appendFileSync, existsSync, readFileSync } from "node:fs";
|
|
9
9
|
import { resolve } from "node:path";
|
|
10
10
|
import { storeDir } from "../bronze/bronze";
|
|
11
|
+
import { mainCheckoutOf } from "./main-checkout";
|
|
11
12
|
import { sameArtifact } from "./progress-artifact-match";
|
|
12
13
|
import { progressSession } from "./progress-session";
|
|
13
14
|
import { readAllProjects, resolveProjectFromCwd } from "./projects";
|
|
@@ -147,8 +148,11 @@ function progressTreeFile(): string {
|
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
/** A registered project is its own scope wherever in it the agent stands; anything else is its folder. */
|
|
151
|
+
/** One session's nodes stay in one scope, whichever worktree of the project it worked in. */
|
|
150
152
|
export function scopeOf(cwd: string): string {
|
|
151
|
-
|
|
153
|
+
const checkout = mainCheckoutOf(cwd);
|
|
154
|
+
|
|
155
|
+
return resolveProjectFromCwd(checkout, readAllProjects())?.name ?? checkout;
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
export function newNodeId(
|
|
@@ -9,14 +9,14 @@ import { isAbsolute } from "node:path";
|
|
|
9
9
|
*/
|
|
10
10
|
export function canonicalPalCmd(cmd: string): string {
|
|
11
11
|
const withoutEnv = cmd.replace(/^(?:\w+=\S+\s+)+/, "");
|
|
12
|
-
const hookMatch = /bun\s+run\s
|
|
12
|
+
const hookMatch = /bun\s+run\s+.+[\\/]src[\\/]hooks[\\/](\S+)/.exec(withoutEnv);
|
|
13
13
|
if (hookMatch) return `bun run src/hooks/${hookMatch[1]}`;
|
|
14
14
|
|
|
15
15
|
return withoutEnv;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function runsRemovedPalHook(cmd: string): boolean {
|
|
19
|
-
const script = /bun\s+run\s+(\S
|
|
19
|
+
const script = /bun\s+run\s+(\S+[\\/]src[\\/]hooks[\\/]\S+\.ts)/.exec(cmd)?.[1];
|
|
20
20
|
|
|
21
21
|
return script !== undefined && isAbsolute(script) && !existsSync(script);
|
|
22
22
|
}
|
package/src/usage/hook-run.ts
CHANGED
|
@@ -36,10 +36,16 @@ function hookName(entry: string): string {
|
|
|
36
36
|
return basename(entry).replace(/\.[cm]?[jt]s$/, "");
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** The `--only=<part>` a hook was registered with, so two parts of one hook tell apart. */
|
|
40
|
+
function hookPart(argv: string[]): string | null {
|
|
41
|
+
return argv.find((arg) => arg.startsWith("--only="))?.slice("--only=".length) ?? null;
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
export function logHookRun(
|
|
40
45
|
entry: string,
|
|
41
46
|
exitCode: number,
|
|
42
|
-
durationMs: number = performance.now()
|
|
47
|
+
durationMs: number = performance.now(),
|
|
48
|
+
argv: string[] = process.argv
|
|
43
49
|
): void {
|
|
44
50
|
logQuietly("hook_run", () =>
|
|
45
51
|
appendEvent(
|
|
@@ -47,6 +53,7 @@ export function logHookRun(
|
|
|
47
53
|
{
|
|
48
54
|
hook: hookName(entry),
|
|
49
55
|
event: run.event,
|
|
56
|
+
part: hookPart(argv),
|
|
50
57
|
durationMs: Math.round(durationMs),
|
|
51
58
|
exitCode,
|
|
52
59
|
},
|