@timurproko/a1 0.2.7-dev.1287 → 0.2.7-dev.1290

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 (50) hide show
  1. package/README.md +4 -0
  2. package/bin/cli.js +4 -0
  3. package/dist/cli/capabilities.d.ts +1 -0
  4. package/dist/cli/capabilities.js +1 -1
  5. package/dist/cli/dispatch.d.ts +4 -0
  6. package/dist/cli/dispatch.js +34 -1
  7. package/dist/cli/session-color.d.ts +6 -0
  8. package/dist/cli/session-color.js +44 -0
  9. package/dist/cli/session-context.js +5 -0
  10. package/dist/composition/owned-settings.d.ts +2 -2
  11. package/dist/composition/owned-settings.js +2 -2
  12. package/dist/composition/owned-ui.js +31 -11
  13. package/dist/composition/session-colors.d.ts +5 -0
  14. package/dist/composition/session-colors.js +33 -0
  15. package/dist/composition/session-runtime-registry.d.ts +3 -1
  16. package/dist/composition/session-runtime-registry.js +32 -3
  17. package/dist/contracts/owned-ui/index.d.ts +2 -2
  18. package/dist/contracts/owned-ui/index.js +1 -0
  19. package/dist/contracts/presentation/progress-palette.generated.d.ts +31 -5
  20. package/dist/contracts/presentation/progress-palette.generated.js +1 -1
  21. package/dist/features/launch/session-context.d.ts +9 -0
  22. package/dist/features/launch/session-context.js +7 -1
  23. package/dist/features/owned-ui/settings-app.js +1 -1
  24. package/dist/foundation/lifecycle/index.d.ts +6 -2
  25. package/dist/foundation/lifecycle/index.js +3 -1
  26. package/dist/foundation/lifecycle/session-control.d.ts +26 -0
  27. package/dist/foundation/lifecycle/session-control.js +222 -0
  28. package/dist/foundation/lifecycle/session-repository-context.d.ts +27 -0
  29. package/dist/foundation/lifecycle/session-repository-context.js +106 -7
  30. package/dist/foundation/lifecycle/session-worktree-completion.d.ts +35 -0
  31. package/dist/foundation/lifecycle/session-worktree-completion.js +190 -0
  32. package/dist/foundation/release/early-accent.d.ts +2 -1
  33. package/dist/integrations/pi/components/upstream/theme/theme.js +8 -6
  34. package/dist/integrations/pi/engine/runtime-integration.js +1 -1
  35. package/dist/integrations/pi/engine/worktree-tools.d.ts +5 -2
  36. package/dist/integrations/pi/engine/worktree-tools.js +18 -3
  37. package/dist/ui/settings/declarations.d.ts +18 -2
  38. package/dist/ui/settings/declarations.js +14 -4
  39. package/dist/ui/settings/early-accent.d.ts +16 -0
  40. package/dist/ui/settings/early-accent.js +1 -3
  41. package/dist/ui/settings/manager.d.ts +4 -2
  42. package/dist/ui/settings/manager.js +36 -4
  43. package/dist/ui/settings/resolution.js +3 -2
  44. package/docs/architecture/project-structure.md +1 -1
  45. package/docs/features/session-colors.md +66 -0
  46. package/docs/features/worktrees.md +30 -2
  47. package/docs/local-worktree-cleanup.md +3 -1
  48. package/docs/openspec-archive-automation.md +3 -3
  49. package/docs/worktree-link-recovery.md +2 -0
  50. package/package.json +3 -3
@@ -11,9 +11,10 @@ Run these commands through an active A1 session's shell tool:
11
11
  | `a1 worktree enter <type/short-description> [--base <branch>]` | Create or resume the matching task checkout and attach it. |
12
12
  | `a1 worktree attach <absolute-path>` | Attach an existing registered task checkout in this session's repository. |
13
13
  | `a1 worktree detach` | Release this session's attachment without deleting files or branches. |
14
+ | `a1 worktree complete [--change <id>] [--pr <number>]` | After a verified merge: return this session to the startup checkout, then run the repository's configured cleanup. |
14
15
  | `a1 worktree list` | Informational same-repository inventory; never required after success. |
15
16
 
16
- Successful enter/attach returns the canonical root and branch after acquiring the editing claim. It is the complete attachment result: agents do not run a second inventory approval gate or implement their own retry loop. Temporary registration/coordination contention is retried within an operation budget. Actual ownership conflicts and uncertain records produce actionable failures rather than unsafe takeovers. A failed switch preserves the prior attachment. No command removes worktrees, branches, user files, or private workspace data.
17
+ Successful enter/attach returns the canonical root and branch after acquiring the editing claim. It is the complete attachment result: agents do not run a second inventory approval gate or implement their own retry loop. Temporary registration/coordination contention is retried within an operation budget. Actual ownership conflicts and uncertain records produce actionable failures rather than unsafe takeovers. A failed switch preserves the prior attachment. No command removes worktrees, branches, user files, or private workspace data itself; `complete` only runs the cleanup command the repository declares.
17
18
 
18
19
  Enter creates `.worktrees/<short-description>` under the primary checkout. It fetches the selected origin base before creating a new topic branch. Base selection is explicit `--base`, local Git configuration `a1.worktreeBase`, then the origin default branch; local-only repositories fall back to the primary branch. Existing matching worktrees keep their local edits and history. Path/branch collisions, primary checkouts, foreign repositories, and Git-locked worktrees are retained, not forced or adopted. Setup commands, dependency installation, private-clone provisioning, and repository hooks are not executed by A1.
19
20
 
@@ -27,12 +28,39 @@ Background footer polling activates persisted claims once per session binding, t
27
28
 
28
29
  Implementation completion and review handoff do not end the task attachment. Keep it active for review and follow-up fixes so built-in tools and footer PR discovery continue using the task checkout. Detach only when explicitly requested or switching tasks; runtime shutdown releases editing claims automatically. Repository cleanup handoff is independent and does not require runtime detach.
29
30
 
31
+ ## Completing a merged task
32
+
33
+ Never run repository cleanup against the checkout a session is attached to. The shell A1 starts for an attached session has that checkout as its working directory, and on Windows that pins the directory until the shell exits even after `cd`, so cleanup issued from it removes part of the checkout and then fails on the directory itself.
34
+
35
+ `a1 worktree complete` sequences the two steps. In the issuing shell it only checks and detaches: the attachment must be valid and owned by this session, the checkout must not be locked in Git, and `git status` must show no tracked, staged, or untracked content. A blocker leaves the session attached and changes nothing. Otherwise the session returns to its startup checkout. Once that shell has exited, the A1 process runs the configured cleanup from the startup checkout and appends the outcome to the same command's result:
36
+
37
+ | Outcome | Meaning |
38
+ | --- | --- |
39
+ | `cleanup-finished` | The cleanup command ran. Its report follows and is authoritative; A1 does not claim a removal itself. |
40
+ | `cleanup-failed` | The command exited with an error. The checkout may remain; retry with the repository's cleanup from primary. |
41
+ | `cleanup-unavailable` | The repository declares no command, or it needs `--change`/`--pr` that was not given. The checkout is retained. |
42
+ | `cleanup-skipped` | Another live session attached the checkout, its claim is unverifiable, or the request was not settled within five minutes. |
43
+
44
+ In every case the session is already on the startup checkout and its tools keep working. Do not attach a partially removed checkout again.
45
+
46
+ The cleanup command is declared once in the repository, in a committed `.a1/worktree.json`, so no machine needs any setup:
47
+
48
+ ```json
49
+ { "cleanup": ["node", "scripts/governance/local-worktree-cleanup.mjs", "complete", "--repo", "{primary}", "--path", "{worktree}", "--change", "{change}", "--pr", "{pr}"] }
50
+ ```
51
+
52
+ A1 reads the file from the primary checkout the session started in, never from the task checkout being left, so a task branch cannot change what runs until it is merged. The list is run without a shell from the primary checkout, with `{primary}`, `{worktree}`, `{branch}`, `{change}`, and `{pr}` substituted in each element; the first element must be a real executable such as `node`, not a `.cmd` shim. A repository without the file needs nothing: completion detaches, keeps the checkout, and reports `cleanup-unavailable`, and the repository's ordinary cleanup still applies. The command keeps every eligibility and deletion safeguard; A1 adds no deletion of its own. Delivery evidence is the command's to judge, so completing an unmerged task ends detached with the files intact and the command's blocker.
53
+
54
+ ## Invalid attachments
55
+
56
+ If the attached checkout disappears, loses its Git pointer, or is replaced by a different worktree while the startup checkout still verifies, A1 releases this session's own association and editing claim. The built-in tool call that discovers it fails once with `worktree-attachment-invalid`, naming the released path and the startup checkout now in use, so work addressed to the lost checkout is never silently applied elsewhere. The next call runs from the startup checkout, and a resumed session recovers the same way. Uncertain results such as a timeout or an unverifiable startup checkout release nothing. `a1 worktree detach` works without validating the attached checkout. No file, branch, or other session's claim is removed.
57
+
30
58
  Claims coordinate participating A1 sessions. They are not a sandbox against arbitrary external editors, an editing lock in Git, repository cleanup ownership, or permission to merge/delete anything. Delivery and protected cleanup remain independent.
31
59
 
32
60
  ## Shared repository guidance
33
61
 
34
62
  Use this identical block in repositories, without adding another inventory approval gate:
35
63
 
36
- > In an active A1 session, use `a1 worktree enter <branch>` or `a1 worktree attach <absolute-path>`. Work in the returned directory; successful completion is the attachment confirmation. Keep the task attached after implementation completion and review handoff so follow-up fixes retain its checkout and PR. Use `a1 worktree detach` only when explicitly requested or switching tasks; it preserves files and branches. Runtime shutdown releases claims automatically. A1 owns coordination, retries, and recovery; `a1 worktree list` is informational. Outside A1, use ordinary Git worktrees.
64
+ > In an active A1 session, use `a1 worktree enter <branch>` or `a1 worktree attach <absolute-path>`. Work in the returned directory; success is the attachment confirmation. Keep the task attached after implementation completion and review handoff so follow-up fixes retain its checkout and PR. After a verified merge, run `a1 worktree complete`: it returns the session to primary before repository cleanup runs, so never clean the attached checkout directly. Use `a1 worktree detach` only when explicitly requested or switching tasks; it preserves files and branches. Runtime shutdown releases claims automatically. A1 owns coordination, retries, and recovery; `a1 worktree list` is informational. Outside A1, use ordinary Git worktrees.
37
65
 
38
66
  Install an A1 release exposing this interface before integrating a repository's instruction migration. Older installations only expose the session-context aliases; unknown commands in those older releases may return quietly without performing an operation. A migration PR is not evidence that a compatible installed release is active.
@@ -103,6 +103,8 @@ An exact `complete` invocation may additionally use `--stop-dev-processes`. This
103
103
  cd /d/Git/a1 && node scripts/governance/local-worktree-cleanup.mjs complete --repo D:/Git/a1 --path D:/Git/a1/.worktrees/example-task --change example-change --pr 123 --stop-dev-processes
104
104
  ```
105
105
 
106
+ Inside an A1 session attached to the candidate, do not run this command yourself: run `a1 worktree complete --change example-change --pr 123`, which returns the session to primary and then runs this same command as declared in the repository's `.a1/worktree.json` (see [worktree commands](features/worktrees.md#completing-a-merged-task)). `complete`, sweep, and the queue report `blocked` with `attached-session` while a running A1 session still has the checkout attached, and `attached-session-unverifiable` when that checkout's claim record cannot be read; the check reads A1's claim record only, changes nothing, and needs no A1 installation. Explicit `discard` and `retire-redundant` do not yet apply it.
107
+
106
108
  Agents do not manually remove generated content, call `git worktree remove`, or delete the local branch after delivery. The JSON result is authoritative: report success only for `removed` or verified `already-absent`; otherwise retain the worktree and report the exact blocker. A handed-off entry whose worktree was deleted by hand completes through its journal, and its branch is deleted under the accepted-ancestry rule. Legacy roles can supply separate `--source-pr`, `--candidate-pr`, and `--role` values.
107
109
 
108
110
  ## Explicit closed-unmerged discard
@@ -319,7 +321,7 @@ Disable writes a stop sentinel without waiting for a busy state or resource lock
319
321
  Dependency-free focused fixtures (temporary repositories only, no live PR mutation or watcher activation):
320
322
 
321
323
  ```bash
322
- node --test test/repository-governance/local-cleanup.node.mjs test/repository-governance/local-cleanup-evidence.node.mjs test/repository-governance/local-cleanup-watch.node.mjs
324
+ node --test test/repository-governance/local-cleanup.node.mjs test/repository-governance/local-cleanup-evidence.node.mjs test/repository-governance/local-cleanup-watch.node.mjs test/repository-governance/local-cleanup-attachment.node.mjs
323
325
  ```
324
326
 
325
327
  The Vitest bridge includes these fixtures in ordinary fast CI, whose runner is Windows. On Windows the suite exercises an actual exclusive file handle and a junction; a non-Windows run explicitly skips the Windows-only handle case rather than claiming it passed. The handle fixture starts one throwaway `powershell.exe` when the file loads so the hosted runner's interpreter cold start overlaps the earlier tests instead of the fixture's timed hold; its bounds and release protocol are unchanged. Required current-head CI and a separately authorized live archive lifecycle remain necessary before acceptance; fixtures and preview do not replace those gates.
@@ -42,8 +42,8 @@ Follow the [development worktree protocol](architecture/project-structure.md#dev
42
42
 
43
43
  ## Version-3 lifecycle
44
44
 
45
- 1. **Draft plan:** create one normally named branch/PR such as `feature/...`, `fix/...`, or `chore/...`. Start the body with `## Proposal`, use it for one or two sentences of intent, and follow it with one or more unchecked, outcome-sized task items under `## Implementation`, with no fixed maximum. Each item names a delivered code outcome. Omit generic process tasks; run, verify, validate, evidence, or manual-test items; quoted phase lines; and routine validation command lists, and keep machine linkage under final collapsed `Automation`. Keep it draft and include only planning artifacts until the maintainer approves the plan and explicitly requests implementation.
46
- 2. **Same-PR implementation:** continue after explicit approval in the same worktree, branch, history, draft PR, and phase-free body. Check an Implementation item as soon as its associated code and tests are written and its detailed task bookkeeping is complete; an ordinary progress edit changes only `[ ]` to `[x]` and is not deferred until handoff. Adding, removing, reordering, or rewriting an item is a scope refinement requiring explicit approval and coherent planning updates, with affected scope left unchecked. Reconcile approved refinements before corresponding code edits.
45
+ 1. **Draft plan:** create one normally named branch/PR such as `feature/...`, `fix/...`, or `chore/...`. Start the body with `## Proposal`, use it for one or two sentences of intent, and follow it with one or more unchecked, outcome-sized task items under `## Implementation`, with no fixed maximum. Each item names a delivered code outcome, and `tasks.md` holds one task group per item in the same order. Omit generic process tasks; run, verify, validate, evidence, or manual-test items; quoted phase lines; and routine validation command lists, and keep machine linkage under final collapsed `Automation`. Keep it draft and include only planning artifacts until the maintainer approves the plan and explicitly requests implementation.
46
+ 2. **Same-PR implementation:** continue after explicit approval in the same worktree, branch, history, draft PR, and phase-free body. Follow the `Implementation progress` rule in `AGENTS.md`: deliver one item at a time, and once its code and tests are written and its task group is ticked, commit, push, and check that item before starting the next. An ordinary progress edit changes only `[ ]` to `[x]` and is never saved for handoff. Adding, removing, reordering, or rewriting an item is a scope refinement requiring explicit approval and coherent planning updates, with affected scope left unchecked. Reconcile approved refinements before corresponding code edits.
47
47
  3. **Complete implementation:** finish the code and its tests, substantive tasks, and explicit known-gap disposition. CI runs those tests after readiness; its success is objective evidence, not acceptance, and GitHub check counts are not Implementation task progress. Manual validation is the maintainer's optional choice before integrating and never blocks a checkbox, finalization, or merge.
48
48
  4. **Plain acceptance list:** before checking the final item, keep the body phase-free and add final `## Acceptance` with one to ten concise implementation-specific behavior-and-result bullets. Do not use checkboxes, generic review/CI/approval/archive statements, angle-bracket placeholders or HTML, URLs, mentions, or automated-test inventory.
49
49
  5. **Automatic readiness and finalization:** reconcile and push current `origin/develop`, run the [delivery body check](#delivery-body-check) on the intended final body, then check the final item. That checkbox update completes the agent-owned implementation job; agents never mark implementation PRs ready themselves. Trusted automation revalidates the exact fully complete version-3 task-list snapshot and all pre-finalization inputs, marks the PR ready, and then conservatively synchronizes all deltas, moves the active change into its dated archive, stages the conditional acceptance manifest, commits that to the same branch with the archive App identity, and writes the emitted paths into the body's implementation fence. It never checks tasks or infers completion. Running the [finalization command](#finalization-command) locally first is optional and yields the same bytes.
@@ -306,7 +306,7 @@ After version-3 merge, verify:
306
306
  - the declared archive, conditional manifest, and synchronized specs match their digests; and
307
307
  - the unchanged remote topic ref is absent.
308
308
 
309
- Only then shall the owning agent invoke the exact-candidate `complete` operation documented in [local cleanup](local-worktree-cleanup.md) from the primary checkout. The command owns registration/release, repository-generated disposables, one bounded evidence pass, non-force worktree removal, and unchanged local-ref cleanup; agents do not manually delete generated content, worktrees, or branches. Version 3 uses the implementation PR as both source and candidate and does not wait for nonexistent acceptance/archive PRs.
309
+ Only then shall the owning agent invoke the exact-candidate `complete` operation documented in [local cleanup](local-worktree-cleanup.md) from the primary checkout. An A1 session still attached to that checkout uses `a1 worktree complete --change <change> --pr <pr>` instead, which leaves the checkout before the same operation runs. The command owns registration/release, repository-generated disposables, one bounded evidence pass, non-force worktree removal, and unchanged local-ref cleanup; agents do not manually delete generated content, worktrees, or branches. Version 3 uses the implementation PR as both source and candidate and does not wait for nonexistent acceptance/archive PRs.
310
310
 
311
311
  Closing an unmerged PR does not by itself authorize local or remote deletion. After explicit candidate-specific rejection and remote-deletion confirmation, the repository-owned local `discard` command may compare-and-delete only that closed-unmerged PR's exact unchanged same-repository unprotected topic ref, then apply the ordinary non-force local safeguards. Automatic remote cleanup remains merge-only and never touches local worktrees.
312
312
 
@@ -33,5 +33,7 @@ When the old gate is absent, updated A1 initializes its compatibility barrier au
33
33
  | `session-runtime-unverifiable` | The runtime's recorded process cannot be checked. Retry; no ownership takeover is authorized. |
34
34
  | `worktree-active-in-another-session` | Another live agent owns the target. Use a different worktree or have that owner release it. |
35
35
  | `worktree-owner-unverifiable` | The editing claim itself is uncertain. Gate recovery cannot make that claim available. |
36
+ | `worktree-attachment-invalid` | The attached checkout is gone or replaced. A1 released this session's attachment; retry the call from the startup checkout. |
37
+ | `worktree-not-attached` / `worktree-content` | Completion needs an attached checkout without uncommitted or untracked content. Nothing was changed. |
36
38
 
37
39
  Diagnostics do not expose another session's process identity, session file, transcript, or credentials. The mechanism does not repair arbitrary damaged claim records, change tool cwd, or grant Git/cleanup authority.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timurproko/a1",
3
- "version": "0.2.7-dev.1287",
3
+ "version": "0.2.7-dev.1290",
4
4
  "description": "Standalone single-agent terminal UI on pinned Pi",
5
5
  "type": "module",
6
6
  "privateLaunchContract": "neutral-launch-v1",
@@ -113,7 +113,7 @@
113
113
  "@mariozechner/clipboard": "^0.3.9"
114
114
  },
115
115
  "publication": {
116
- "source": "df8f3fea78404f0413ce40de8d39b7102ead643a",
117
- "pullRequest": 914
116
+ "source": "c39a95552f7be42f1f7c83f7b3fdf8d92203d965",
117
+ "pullRequest": 917
118
118
  }
119
119
  }