@iseoane/agent-depot 0.6.8 → 0.6.10
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/CHANGELOG.md +45 -0
- package/README.md +24 -2
- package/dist/src/app-flow.js +3 -3
- package/dist/src/app-recipe-removal.js +3 -1
- package/dist/src/atomic-file.js +24 -1
- package/dist/src/cli.js +47 -13
- package/dist/src/git-source.js +42 -28
- package/dist/src/path-safety.js +4 -1
- package/dist/src/process-runner.js +12 -1
- package/dist/src/profile-export.js +1 -1
- package/dist/src/profile-import.js +94 -18
- package/dist/src/project-installation.js +2 -1
- package/dist/src/project-manifest.js +7 -0
- package/dist/src/project-target.js +58 -0
- package/dist/src/skill-discovery.js +86 -6
- package/dist/src/skill-install.js +20 -8
- package/dist/src/source-snapshot.js +59 -0
- package/dist/src/tui/app-actions.js +18 -7
- package/dist/src/tui/app.js +19 -4
- package/dist/src/tui/batch.js +2 -1
- package/dist/src/tui/bulk-actions.js +21 -8
- package/dist/src/tui/catalog-installs.js +3 -2
- package/dist/src/tui/catalog-panel.js +3 -2
- package/dist/src/tui/catalog-state.js +47 -21
- package/dist/src/tui/catalog-tree.js +47 -10
- package/dist/src/tui/catalog-view.js +11 -5
- package/dist/src/tui/installations-view.js +19 -6
- package/dist/src/tui/manage-panel.js +1 -1
- package/dist/src/tui/profile-view.js +68 -31
- package/dist/src/tui/sources-recipes.js +44 -8
- package/dist/src/tui/sources-view.js +12 -5
- package/dist/src/tui/updates.js +1 -0
- package/dist/src/tui/view-retention.js +17 -0
- package/dist/src/update-flow.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.10] - 2026-11-06
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Project-scope `install` and `update` previews start with `Project: <absolute path>`,
|
|
15
|
+
in the CLI and the TUI, and warn without blocking when the directory is inside a Git
|
|
16
|
+
repository but not its top level, or has no manifest and no Host directory. The new
|
|
17
|
+
`--project <path>` option (also on `agent-depot tui`) selects the project directory
|
|
18
|
+
instead of the current one.
|
|
19
|
+
- The Profile import list in the TUI is grouped: additions by Source (App recipes
|
|
20
|
+
in their own group), then Unchanged items (collapsed) and Conflicts. Rows say
|
|
21
|
+
what importing does (`Add Skill ask-matt`, `Select Package ...`) and a conflict
|
|
22
|
+
gives one short reason such as `hosts: would add codex, opencode` instead of raw
|
|
23
|
+
JSON. Selection, preview and confirmation are unchanged. The App recipe label
|
|
24
|
+
now says imported recipes are written but not approved and not installed.
|
|
25
|
+
- `agent-depot import` preview and skipped-result conflict lines show the same
|
|
26
|
+
short reason instead of raw existing/incoming values, and version conflicts say
|
|
27
|
+
`existing` rather than `installed`. Unchanged and conflicting Skills whose name
|
|
28
|
+
appears in several Sources name their Source, and in the TUI Enter previews the
|
|
29
|
+
plan even when nothing is importable.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- A project-scope Skill install no longer reads or locks Package state derived from the
|
|
34
|
+
project directory, which created `.local/state/agent-depot` inside the project on Linux.
|
|
35
|
+
- A recipe for another platform can be removed even when an App with the same
|
|
36
|
+
name is tracked on this machine; recipes that apply here keep their
|
|
37
|
+
protection.
|
|
38
|
+
- In Sources, clashing App recipes show their own file names and the duplicate
|
|
39
|
+
error names the files to repair; a recipe that does not apply here shows its
|
|
40
|
+
platform before its status, and approved recipes read `✓ approved`.
|
|
41
|
+
- On Windows, concurrent writes to the same state file (for example two App
|
|
42
|
+
approvals at once) no longer fail with `EPERM` on rename: the atomic write
|
|
43
|
+
retries briefly before giving up.
|
|
44
|
+
|
|
45
|
+
## [0.6.9] - 2026-11-04
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- Catalog and Installations now read cached Git Source manifests in a bounded
|
|
50
|
+
batch instead of starting a Git process per file. Readers share small immutable
|
|
51
|
+
snapshots for the same repository, directory scope and commit, while resolving
|
|
52
|
+
the current ref again on every read. Host state and operation safety checks
|
|
53
|
+
remain fresh; opening a view does not refresh its Sources.
|
|
54
|
+
|
|
10
55
|
## [0.6.8] - 2026-11-04
|
|
11
56
|
|
|
12
57
|
### Fixed
|
package/README.md
CHANGED
|
@@ -342,6 +342,23 @@ the install method; update execution is not part of this lifecycle.
|
|
|
342
342
|
|
|
343
343
|
## Project installation
|
|
344
344
|
|
|
345
|
+
Project scope acts on one project directory, the current directory unless you pass
|
|
346
|
+
`--project <path>` (`install`, `update` and `tui`). The path must be an existing directory
|
|
347
|
+
without symbolic links in it, and a relative path is resolved against the current
|
|
348
|
+
directory. Every project-scope preview, in the CLI and the TUI, starts with
|
|
349
|
+
`Project: <absolute path>`, so you can see where Skills will be written before
|
|
350
|
+
confirming. Two non-blocking warnings follow it when the directory looks unintended:
|
|
351
|
+
it is inside a Git repository but is not its top level (the warning names the top
|
|
352
|
+
level), or it has no `agent-depot.json` and none of `.agents`, `.claude`, `.codex`,
|
|
353
|
+
`.opencode` or `.pi`. A brand-new project still installs after the warning. Project
|
|
354
|
+
removal does not exist, so this applies to install and update only.
|
|
355
|
+
`agent-depot tui --project <path>` opens the TUI on that directory; a TUI batch
|
|
356
|
+
install shows the project line and warnings once for the whole batch.
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
agent-depot install --scope project --project ../other-repo --source builtin:agent-depot --skill agent-depot-apprecipe --host pi --version latest --portable-v1
|
|
360
|
+
```
|
|
361
|
+
|
|
345
362
|
Project installation requires an explicit `--scope project`, Source ID, Skill
|
|
346
363
|
path, one or more `--host` values (`pi`, `claude`, `codex`, or `opencode`), and
|
|
347
364
|
a version policy (`--version latest` or `--version fixed:<value>`). External
|
|
@@ -554,8 +571,10 @@ the application supplies another start directory.
|
|
|
554
571
|
to the Profile view.
|
|
555
572
|
2. The selected file is parsed and previewed. If it is invalid or cannot be
|
|
556
573
|
read, an inline error appears and the picker stays open so you can choose
|
|
557
|
-
another file. The import list
|
|
558
|
-
|
|
574
|
+
another file. The import list is grouped: additions by Source (App recipes in
|
|
575
|
+
their own group), then **Unchanged** entries (collapsed, skipped) and
|
|
576
|
+
**Conflicts** (skipped, each with a one-line reason). Each row says what
|
|
577
|
+
importing does, and only additions can be selected. Use
|
|
559
578
|
`space` to toggle a row, `a` to select all additions or clear them, and
|
|
560
579
|
`Enter` to preview the selected additions. Press `Esc` to return to the
|
|
561
580
|
Profile view.
|
|
@@ -576,6 +595,9 @@ If the App is installed or tracked, the TUI offers the existing uninstall flow;
|
|
|
576
595
|
uninstall (or when not installed), a separate preview confirms deletion of only
|
|
577
596
|
the recipe file or symlink. App data and Host configuration are not implicitly
|
|
578
597
|
deleted. Invalid recipes must be repaired before their App state can be checked.
|
|
598
|
+
A recipe for another platform stays removable even when an App with the same
|
|
599
|
+
name is tracked here; only a recipe that applies here, or the exact recipe file the
|
|
600
|
+
App was installed from, is protected by tracked state.
|
|
579
601
|
|
|
580
602
|
Safety model:
|
|
581
603
|
|
package/dist/src/app-flow.js
CHANGED
|
@@ -52,11 +52,11 @@ export function createAppOperations(environment = {}) {
|
|
|
52
52
|
const names = new Map();
|
|
53
53
|
for (const entry of entries) {
|
|
54
54
|
if (entry.applicable && entry.recipe) {
|
|
55
|
-
names.set(entry.recipe.name, (names.get(entry.recipe.name) ??
|
|
55
|
+
names.set(entry.recipe.name, [...(names.get(entry.recipe.name) ?? []), path.basename(entry.file)]);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
return entries.map((entry) => (entry.applicable && entry.recipe && names.get(entry.recipe.name) > 1
|
|
59
|
-
? { ...entry, error: `Duplicate applicable App name: ${entry.recipe.name}` }
|
|
58
|
+
return entries.map((entry) => (entry.applicable && entry.recipe && names.get(entry.recipe.name).length > 1
|
|
59
|
+
? { ...entry, error: `Duplicate applicable App name: ${entry.recipe.name} (repair ${names.get(entry.recipe.name).join(", ")})` }
|
|
60
60
|
: entry));
|
|
61
61
|
}
|
|
62
62
|
async function load(files) {
|
|
@@ -27,7 +27,9 @@ export async function planAppRecipeRemoval(apps, entry) {
|
|
|
27
27
|
throw new Error(`Cannot verify App state: ${current.error ?? "invalid recipe"}. Repair the recipe before removing it.`);
|
|
28
28
|
if (current.hash !== entry.hash || current.canonicalFile !== entry.canonicalFile)
|
|
29
29
|
throw new Error("App recipe changed; review it again");
|
|
30
|
-
|
|
30
|
+
// A recipe for another platform owns no installation here, so a same-named record counts only when it points at this very file.
|
|
31
|
+
const tracked = (await apps.trackedApps()).find((record) => record.name === current.recipe.name
|
|
32
|
+
&& (current.applicable || record.recipeFile === current.canonicalFile));
|
|
31
33
|
const inspection = await apps.inspect(current);
|
|
32
34
|
if (inspection.status !== "installed" && inspection.status !== "not installed" && inspection.status !== "not applicable here") {
|
|
33
35
|
throw new Error(`Cannot verify App state (${inspection.status}); approve the recipe before removing it`);
|
package/dist/src/atomic-file.js
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { rename, unlink, writeFile } from "node:fs/promises";
|
|
3
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
4
|
+
export const WINDOWS_RENAME_ATTEMPTS = 20;
|
|
5
|
+
const WINDOWS_RENAME_RETRY_MS = 5;
|
|
6
|
+
/**
|
|
7
|
+
* Windows reports EPERM, EACCES or EBUSY when a rename targets a file another rename or reader is
|
|
8
|
+
* still releasing, so concurrent writers to one destination must retry briefly instead of failing.
|
|
9
|
+
* The dependencies are injectable only so tests can force the Windows branch on any OS.
|
|
10
|
+
*/
|
|
11
|
+
export async function renameWithWindowsRetry(from, to, deps = { rename, platform: process.platform, delay }) {
|
|
12
|
+
for (let attempt = 1;; attempt += 1) {
|
|
13
|
+
try {
|
|
14
|
+
await deps.rename(from, to);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const code = error.code;
|
|
19
|
+
const transient = deps.platform === "win32" && ["EPERM", "EACCES", "EBUSY"].includes(code ?? "");
|
|
20
|
+
if (!transient || attempt >= WINDOWS_RENAME_ATTEMPTS)
|
|
21
|
+
throw error;
|
|
22
|
+
await deps.delay(WINDOWS_RENAME_RETRY_MS * attempt);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
3
26
|
/** Write a unique temporary sibling, then publish it with rename. */
|
|
4
27
|
export async function writeFileAtomically(file, contents, options = {}) {
|
|
5
28
|
const temporaryPath = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
6
29
|
try {
|
|
7
30
|
await writeFile(temporaryPath, contents, { encoding: "utf8", flag: "wx", mode: options.mode });
|
|
8
31
|
try {
|
|
9
|
-
await
|
|
32
|
+
await renameWithWindowsRetry(temporaryPath, file);
|
|
10
33
|
}
|
|
11
34
|
catch (error) {
|
|
12
35
|
const code = error.code;
|
package/dist/src/cli.js
CHANGED
|
@@ -21,6 +21,7 @@ import { describeUnmanagedRemoval, removeInspectedUnmanagedSkills } from "./unma
|
|
|
21
21
|
import { executeHostAddition, executeHostRemoval, planHostAddition, planHostRemoval } from "./skill-hosts.js";
|
|
22
22
|
import { executeSkillRemoval, inspectSkillRemovals, planSkillRemoval, describeSkillRemoval, recheckSkillRemoval, removeSkillFiles, removeSkillsAndRecords, assertManagedInstallationRecordsUnchanged, assertRemovalInspectionUnchanged, selectUserGlobalSkills, SkillSelectionError, userGlobalRemovalOptions, } from "./skill-removal.js";
|
|
23
23
|
import { defaultProjectSkillTreeAccess, executeOrRejectMethod, executeSingleInstall, externalMethodFailure, isValidFixedVersion, findSource, installOne, outputInstallationResult, outputInstallPreview, outputSingleInstallPreview, planSingleInstall, refreshResolvedSource, rejectInstallationCollision, resolveSelection, rollbackTransactions, } from "./skill-install.js";
|
|
24
|
+
import { describeProjectTarget, resolveProjectRootOption } from "./project-target.js";
|
|
24
25
|
import { CliUsageError } from "./usage-error.js";
|
|
25
26
|
import { createSelfUpdateOperations } from "./self-update.js";
|
|
26
27
|
import { selectionWithInstallation } from "./skill-update.js";
|
|
@@ -34,10 +35,11 @@ const USAGE = [
|
|
|
34
35
|
" agent-depot source remove <id> [--skill <id|path>...] [--all] [--yes]",
|
|
35
36
|
" agent-depot source migrate <old-id> <new-id> (--skill <path>... | --all) [--yes]",
|
|
36
37
|
" agent-depot discover <source-id> [source-id...]",
|
|
37
|
-
" agent-depot install --scope <project|user-global> --source <id> --skill <path> --host <host>... --version <latest|version> [--ref <git-ref>] [--method <json>] --portable-v1 [--yes] [--confirm-additional-host]",
|
|
38
|
-
" agent-depot install --scope project --manifest --portable-v1 [--yes] [--confirm-additional-host]",
|
|
39
|
-
" agent-depot update check --scope <project|user-global> [--package <selection>...]",
|
|
40
|
-
" agent-depot update apply --scope <project|user-global> (--all | --skill <id|path>... | --app <name>... | --package <selection>...) [--yes] [--confirm-path <relative-path>...]",
|
|
38
|
+
" agent-depot install --scope <project|user-global> --source <id> --skill <path> --host <host>... --version <latest|version> [--ref <git-ref>] [--method <json>] --portable-v1 [--yes] [--confirm-additional-host] [--project <path>]",
|
|
39
|
+
" agent-depot install --scope project --manifest --portable-v1 [--yes] [--confirm-additional-host] [--project <path>]",
|
|
40
|
+
" agent-depot update check --scope <project|user-global> [--package <selection>...] [--project <path>]",
|
|
41
|
+
" agent-depot update apply --scope <project|user-global> (--all | --skill <id|path>... | --app <name>... | --package <selection>...) [--yes] [--confirm-path <relative-path>...] [--project <path>]",
|
|
42
|
+
" --project <path> picks the project directory for --scope project (default: the current directory).",
|
|
41
43
|
" Apps and Packages run after Skills; --all --scope project skips Apps and Packages.",
|
|
42
44
|
" agent-depot self update [--yes] (npm global installations only; otherwise prints manual guidance)",
|
|
43
45
|
" agent-depot skill remove <id|path>... [--yes]",
|
|
@@ -57,14 +59,14 @@ const USAGE = [
|
|
|
57
59
|
" agent-depot package forget <selection> --host <host> --yes",
|
|
58
60
|
` ${EXPORT_USAGE}`,
|
|
59
61
|
` ${IMPORT_USAGE}`,
|
|
60
|
-
" agent-depot tui",
|
|
62
|
+
" agent-depot tui [--project <path>]",
|
|
61
63
|
" agent-depot --version",
|
|
62
64
|
"",
|
|
63
65
|
"Options for every command, anywhere on the line:",
|
|
64
66
|
" --verbose stream the full child output (npm, pi, git, App commands) to stderr line by line as it runs,",
|
|
65
67
|
" instead of a spinner and the last few lines; stdout is unchanged.",
|
|
66
68
|
].join("\n");
|
|
67
|
-
const INSTALL_USAGE = "Usage: agent-depot install --scope <project|user-global> --source <id> --skill <path> --host <host>... --version <latest|version> [--ref <git-ref>] [--method <json>] --portable-v1 [--overwrite --yes] [--confirm-additional-host]";
|
|
69
|
+
const INSTALL_USAGE = "Usage: agent-depot install --scope <project|user-global> --source <id> --skill <path> --host <host>... --version <latest|version> [--ref <git-ref>] [--method <json>] --portable-v1 [--overwrite --yes] [--confirm-additional-host] [--project <path>]";
|
|
68
70
|
const DISCOVER_USAGE = "Usage: agent-depot discover <source-id> [source-id...]\nSelect at least one Source ID explicitly; run `agent-depot source list` to see registered Sources";
|
|
69
71
|
const REMOVE_SOURCE_USAGE = "Usage: agent-depot source remove <id> [--skill <id|path>...] [--all] [--yes]";
|
|
70
72
|
const MIGRATE_SOURCE_USAGE = "Usage: agent-depot source migrate <old-id> <new-id> (--skill <path>... | --all) [--yes]";
|
|
@@ -144,16 +146,17 @@ const COMMANDS = new Map([
|
|
|
144
146
|
}
|
|
145
147
|
return 0;
|
|
146
148
|
}],
|
|
147
|
-
["tui", async (
|
|
149
|
+
["tui", async (values, { operations, dependencies }) => {
|
|
148
150
|
const isInteractive = dependencies.isInteractive ?? (() => process.stdin.isTTY === true);
|
|
149
151
|
if (!isInteractive()) {
|
|
150
152
|
throw new Error("agent-depot tui requires an interactive terminal");
|
|
151
153
|
}
|
|
154
|
+
const projectRoot = await parseTuiProjectRoot(values, dependencies);
|
|
152
155
|
// Loaded lazily so non-interactive commands never import Ink/React.
|
|
153
156
|
const renderTui = dependencies.renderTui ?? (await import("./tui/render.js")).renderTui;
|
|
154
157
|
await renderTui(operations, {
|
|
155
158
|
homeDirectory: dependencies.homeDirectory,
|
|
156
|
-
projectRoot
|
|
159
|
+
projectRoot,
|
|
157
160
|
sourceAccess: dependencies.sourceAccess,
|
|
158
161
|
installationOptions: dependencies.installationOptions,
|
|
159
162
|
projectManifestStore: dependencies.projectManifestStore,
|
|
@@ -169,6 +172,14 @@ const COMMANDS = new Map([
|
|
|
169
172
|
return 0;
|
|
170
173
|
}],
|
|
171
174
|
]);
|
|
175
|
+
/** `tui [--project <path>]`: the project directory the TUI acts on; also where its file browser opens. */
|
|
176
|
+
async function parseTuiProjectRoot(values, dependencies) {
|
|
177
|
+
if (values.length === 0)
|
|
178
|
+
return dependencies.projectRoot;
|
|
179
|
+
if (values.length !== 2 || values[0] !== "--project")
|
|
180
|
+
throw new CliUsageError(USAGE);
|
|
181
|
+
return resolveProjectRootOption(requireOptionValue(values, 1, "--project"));
|
|
182
|
+
}
|
|
172
183
|
async function runSourceRefresh(values, { operations, output, progress }) {
|
|
173
184
|
if (values.length < 1 || values.length > 2 || (values.length === 2 && values[1] !== "--yes")) {
|
|
174
185
|
throw new CliUsageError("Usage: agent-depot source refresh <id> [--yes]");
|
|
@@ -816,6 +827,7 @@ async function runSelfUpdate(argv, dependencies, output, progress) {
|
|
|
816
827
|
}
|
|
817
828
|
async function runUpdate(argv, operations, dependencies, output, progress) {
|
|
818
829
|
const options = parseUpdateOptions(argv);
|
|
830
|
+
const projectRoot = options.project === undefined ? dependencies.projectRoot : await resolveProjectRootOption(options.project);
|
|
819
831
|
const apps = dependencies.appOperations ?? createAppOperations({ homeDirectory: dependencies.homeDirectory });
|
|
820
832
|
const packages = packageOperationsFor(dependencies, operations);
|
|
821
833
|
const requestedPackages = options.scope === "user-global" && options.requestedPackages.length > 0
|
|
@@ -847,7 +859,7 @@ async function runUpdate(argv, operations, dependencies, output, progress) {
|
|
|
847
859
|
scope: options.scope,
|
|
848
860
|
operations,
|
|
849
861
|
...(dependencies.homeDirectory === undefined ? {} : { homeDirectory: dependencies.homeDirectory }),
|
|
850
|
-
...(
|
|
862
|
+
...(projectRoot === undefined ? {} : { projectRoot }),
|
|
851
863
|
...(dependencies.sourceAccess === undefined ? {} : { sourceAccess: dependencies.sourceAccess }),
|
|
852
864
|
...(dependencies.projectManifestStore === undefined ? {} : { projectManifestStore: dependencies.projectManifestStore }),
|
|
853
865
|
...(dependencies.installationOptions?.fileSystem === undefined ? {} : { installationFileSystem: dependencies.installationOptions.fileSystem }),
|
|
@@ -857,7 +869,9 @@ async function runUpdate(argv, operations, dependencies, output, progress) {
|
|
|
857
869
|
output(`Error (Skills, ${options.scope}): ${error instanceof Error ? error.message : String(error)}`);
|
|
858
870
|
}
|
|
859
871
|
if (loaded) {
|
|
860
|
-
const { assessment, installed, context } = loaded;
|
|
872
|
+
const { assessment, installed, context, projectTarget } = loaded;
|
|
873
|
+
for (const line of projectTarget)
|
|
874
|
+
output(line);
|
|
861
875
|
const userGlobalInventory = options.action === "check" && options.scope === "user-global"
|
|
862
876
|
? await scanUserGlobalSkillInventory({ homeDirectory: context.projectRoot, managedInstallations: installed, reportWarning: output })
|
|
863
877
|
: undefined;
|
|
@@ -874,7 +888,7 @@ async function runUpdate(argv, operations, dependencies, output, progress) {
|
|
|
874
888
|
if (options.action === "check") {
|
|
875
889
|
return appCheckFailed || packageCheckFailed ? 1 : 0;
|
|
876
890
|
}
|
|
877
|
-
const { assessment, context } = loaded;
|
|
891
|
+
const { assessment, context, projectTarget } = loaded;
|
|
878
892
|
const selectedApps = options.all ? appUpdates.filter(item => item.status === "update available")
|
|
879
893
|
: options.requestedApps.map(name => {
|
|
880
894
|
const matches = appUpdates.filter(item => item.entry.recipe?.name === name);
|
|
@@ -927,6 +941,10 @@ async function runUpdate(argv, operations, dependencies, output, progress) {
|
|
|
927
941
|
const { plans, failures: previewFailures, nonCanonicalPaths } = selected.length === 0
|
|
928
942
|
? await previewUpdateCandidates(selected, context)
|
|
929
943
|
: await progress.run("Previewing Skill updates", () => previewUpdateCandidates(selected, context));
|
|
944
|
+
// The assessment output above can be long, so the previews restate the target.
|
|
945
|
+
if (selected.length > 0)
|
|
946
|
+
for (const line of projectTarget)
|
|
947
|
+
output(line);
|
|
930
948
|
// Successes and failures are reported in candidate order, as the preview runs.
|
|
931
949
|
const failedIds = new Set(previewFailures.map(({ item }) => item.id));
|
|
932
950
|
const plansById = new Map(plans.map((plan) => [plan.item.id, plan]));
|
|
@@ -1049,6 +1067,7 @@ function parseUpdateOptions(argv) {
|
|
|
1049
1067
|
throw new CliUsageError(USAGE);
|
|
1050
1068
|
}
|
|
1051
1069
|
let scope;
|
|
1070
|
+
let project;
|
|
1052
1071
|
let all = false;
|
|
1053
1072
|
let confirmed = false;
|
|
1054
1073
|
const requested = [];
|
|
@@ -1060,6 +1079,9 @@ function parseUpdateOptions(argv) {
|
|
|
1060
1079
|
case "--scope":
|
|
1061
1080
|
scope = requireOptionValue(argv, ++index, "--scope");
|
|
1062
1081
|
break;
|
|
1082
|
+
case "--project":
|
|
1083
|
+
project = requireOptionValue(argv, ++index, "--project");
|
|
1084
|
+
break;
|
|
1063
1085
|
case "--confirm-path":
|
|
1064
1086
|
confirmedPaths.push(normalizeConfirmedPath(requireOptionValue(argv, ++index, "--confirm-path")));
|
|
1065
1087
|
break;
|
|
@@ -1085,6 +1107,8 @@ function parseUpdateOptions(argv) {
|
|
|
1085
1107
|
if (scope !== "project" && scope !== "user-global") {
|
|
1086
1108
|
throw new CliUsageError("Update scope must be explicit: use --scope project or --scope user-global");
|
|
1087
1109
|
}
|
|
1110
|
+
if (project !== undefined && scope !== "project")
|
|
1111
|
+
throw new CliUsageError("--project only applies to --scope project");
|
|
1088
1112
|
if (action === "check" && (all || requested.length > 0 || requestedApps.length > 0 || confirmed || confirmedPaths.length > 0)) {
|
|
1089
1113
|
throw new CliUsageError("update check only accepts --scope and optional --package filters; use update apply to select and apply updates");
|
|
1090
1114
|
}
|
|
@@ -1111,6 +1135,7 @@ function parseUpdateOptions(argv) {
|
|
|
1111
1135
|
requestedPackages: Object.freeze(requestedPackages),
|
|
1112
1136
|
confirmed,
|
|
1113
1137
|
confirmedPaths: Object.freeze(confirmedPaths),
|
|
1138
|
+
...(project === undefined ? {} : { project }),
|
|
1114
1139
|
};
|
|
1115
1140
|
}
|
|
1116
1141
|
/** Normalizes a --confirm-path value like the relative path shown in the preview. */
|
|
@@ -1169,7 +1194,9 @@ async function runInstall(argv, operations, dependencies, output, progress) {
|
|
|
1169
1194
|
await runUserGlobalInstall(options, operations, dependencies, sourceAccess, output, progress);
|
|
1170
1195
|
return;
|
|
1171
1196
|
}
|
|
1172
|
-
const projectRoot =
|
|
1197
|
+
const projectRoot = options.project === undefined
|
|
1198
|
+
? path.resolve(dependencies.projectRoot ?? process.cwd())
|
|
1199
|
+
: await resolveProjectRootOption(options.project);
|
|
1173
1200
|
const manifestStore = dependencies.projectManifestStore ?? new ProjectManifestStore(defaultProjectManifestPath(projectRoot));
|
|
1174
1201
|
const context = { options, operations, dependencies, sourceAccess, output, progress, projectRoot, manifestStore };
|
|
1175
1202
|
if (options.fromManifest) {
|
|
@@ -1214,6 +1241,8 @@ async function runManifestInstall(context) {
|
|
|
1214
1241
|
// Two different manifest selections can have different Source/path
|
|
1215
1242
|
// identities while still resolving to the same basename directory.
|
|
1216
1243
|
const inspections = await inspectManifestInstallations(resolved, projectRoot, sourceAccess, dependencies);
|
|
1244
|
+
for (const line of await describeProjectTarget(projectRoot, manifestStore.path))
|
|
1245
|
+
output(line);
|
|
1217
1246
|
for (let index = 0; index < resolved.length; index += 1) {
|
|
1218
1247
|
const item = resolved[index];
|
|
1219
1248
|
outputInstallPreview(item.selection, item.source, projectRoot, output, item.files, item.method, "project", inspections[index], false, options.confirmed);
|
|
@@ -1269,7 +1298,7 @@ async function runSingleProjectInstall(context) {
|
|
|
1269
1298
|
}
|
|
1270
1299
|
const existing = await manifestStore.load();
|
|
1271
1300
|
const request = { ...options, scope: "project", sourceId: options.sourceId, skillPath: options.skillPath, version: options.version };
|
|
1272
|
-
const plan = await progress.run(`Resolving ${options.skillPath}`, () => planSingleInstall(request, { operations, sourceAccess, environment: dependencies, root: projectRoot, existing: existing.skills, recordedIn: manifestStore.path }), { mayPrompt: refreshesSource(options) });
|
|
1301
|
+
const plan = await progress.run(`Resolving ${options.skillPath}`, () => planSingleInstall(request, { operations, sourceAccess, environment: dependencies, root: projectRoot, existing: existing.skills, recordedIn: manifestStore.path, manifestPath: manifestStore.path }), { mayPrompt: refreshesSource(options) });
|
|
1273
1302
|
outputSingleInstallPreview(plan, output);
|
|
1274
1303
|
requireConfirmation(options.confirmed, "Installation not confirmed; rerun with --yes to continue");
|
|
1275
1304
|
await progress.run(`Installing ${options.skillPath}`, () => executeSingleInstall(plan, async (record) => {
|
|
@@ -1309,6 +1338,7 @@ function collectHosts(hosts, value) {
|
|
|
1309
1338
|
}
|
|
1310
1339
|
const INSTALL_VALUE_OPTIONS = new Map([
|
|
1311
1340
|
["--scope", (draft, value) => { draft.scope = value; }],
|
|
1341
|
+
["--project", (draft, value) => { draft.project = value; }],
|
|
1312
1342
|
["--source", (draft, value) => { draft.sourceId = value; }],
|
|
1313
1343
|
["--skill", (draft, value) => { draft.skillPath = value; }],
|
|
1314
1344
|
["--host", (draft, value) => { collectHosts(draft.hosts, value); }],
|
|
@@ -1353,6 +1383,9 @@ function finalizeInstallOptions(draft) {
|
|
|
1353
1383
|
if (scope !== "project" && scope !== "user-global") {
|
|
1354
1384
|
throw new CliUsageError("Installation scope must be explicit: use --scope project or --scope user-global");
|
|
1355
1385
|
}
|
|
1386
|
+
if (draft.project !== undefined && scope !== "project") {
|
|
1387
|
+
throw new CliUsageError("--project only applies to --scope project");
|
|
1388
|
+
}
|
|
1356
1389
|
const selectsSkill = sourceId !== undefined || skillPath !== undefined || ref !== undefined || hosts.length > 0;
|
|
1357
1390
|
if (fromManifest) {
|
|
1358
1391
|
if (scope !== "project") {
|
|
@@ -1378,6 +1411,7 @@ function finalizeInstallOptions(draft) {
|
|
|
1378
1411
|
confirmed: draft.confirmed,
|
|
1379
1412
|
overwrite,
|
|
1380
1413
|
confirmAdditionalHostExposure: draft.confirmAdditionalHostExposure,
|
|
1414
|
+
...(draft.project === undefined ? {} : { project: draft.project }),
|
|
1381
1415
|
};
|
|
1382
1416
|
}
|
|
1383
1417
|
function parseMethodOption(value) {
|
package/dist/src/git-source.js
CHANGED
|
@@ -5,6 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { isLockContention } from "./atomic-file.js";
|
|
6
6
|
import { assertNoSymlinkPath } from "./path-safety.js";
|
|
7
7
|
import { runProcess } from "./process-runner.js";
|
|
8
|
+
import { decodeSnapshotBatch, reuseSourceSnapshot, SOURCE_SNAPSHOT_LIMITS } from "./source-snapshot.js";
|
|
8
9
|
export const SKILL_TREE_LIMITS = Object.freeze({
|
|
9
10
|
maxFiles: 256,
|
|
10
11
|
maxFileBytes: 2 * 1024 * 1024,
|
|
@@ -62,11 +63,14 @@ class NodeGitSnapshotCommandRunner {
|
|
|
62
63
|
async runBinary(command, args, options = {}) {
|
|
63
64
|
const result = await runProcess(command, args, {
|
|
64
65
|
captureStdout: true,
|
|
66
|
+
...(options.stdin === undefined ? {} : { stdin: options.stdin, timeoutMs: 30_000, maxStderrBytes: 64 * 1024 }),
|
|
65
67
|
...(options.maxOutputBytes === undefined ? {} : { maxOutputBytes: options.maxOutputBytes }),
|
|
66
68
|
});
|
|
67
69
|
if (result.outputTooLarge) {
|
|
68
70
|
throw new Error("git command output exceeds the safe size limit");
|
|
69
71
|
}
|
|
72
|
+
if (result.timedOut)
|
|
73
|
+
throw new Error("git command timed out");
|
|
70
74
|
if (result.code !== 0) {
|
|
71
75
|
throw new Error(`git command failed: ${gitFailureDetail(result)}`);
|
|
72
76
|
}
|
|
@@ -168,12 +172,13 @@ function parseSkillTreeRecord(record, relativeSkillPath) {
|
|
|
168
172
|
}
|
|
169
173
|
return { relativePath, objectId, executable: mode === "100755" };
|
|
170
174
|
}
|
|
175
|
+
const defaultSnapshotRunner = new NodeGitSnapshotCommandRunner();
|
|
171
176
|
export class GitSourceSnapshotAccess {
|
|
172
177
|
cachePath;
|
|
173
178
|
runner;
|
|
174
179
|
constructor(options = {}) {
|
|
175
180
|
this.cachePath = options.cachePath ?? defaultGitSourceCachePath();
|
|
176
|
-
this.runner = options.runner ??
|
|
181
|
+
this.runner = options.runner ?? defaultSnapshotRunner;
|
|
177
182
|
}
|
|
178
183
|
async requireMirror(source) {
|
|
179
184
|
const destination = cachePathForSource(this.cachePath, source);
|
|
@@ -278,37 +283,46 @@ export class GitSourceSnapshotAccess {
|
|
|
278
283
|
}
|
|
279
284
|
async readSnapshot(source) {
|
|
280
285
|
const destination = await this.requireMirror(source);
|
|
286
|
+
// Resolve on every read, even on a cache hit: refs can change outside Agent Depot.
|
|
281
287
|
const commit = await this.readResolvedCommit(source);
|
|
282
288
|
const directory = gitSourceLocation(source.url).directory;
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (!
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
const key = JSON.stringify([path.resolve(destination), commit, directory]);
|
|
290
|
+
return reuseSourceSnapshot(this.runner, key, async () => {
|
|
291
|
+
const tree = await this.runner.run("git", [
|
|
292
|
+
"--no-replace-objects", "--git-dir", destination, "ls-tree", "-r", "-z", commit,
|
|
293
|
+
...(directory === undefined ? [] : ["--", directory]),
|
|
294
|
+
], { maxOutputBytes: SKILL_TREE_LIMITS.maxListingBytes });
|
|
295
|
+
if (tree !== "" && !tree.endsWith("\0"))
|
|
296
|
+
throw new Error("Truncated Git snapshot listing");
|
|
297
|
+
const entries = [];
|
|
298
|
+
for (const record of tree.split("\0")) {
|
|
299
|
+
if (!record)
|
|
300
|
+
continue;
|
|
301
|
+
const separator = record.indexOf("\t");
|
|
302
|
+
if (separator < 0)
|
|
303
|
+
throw new Error("Malformed Git snapshot listing");
|
|
304
|
+
const [mode, type, objectId] = record.slice(0, separator).split(" ");
|
|
305
|
+
const relativePath = record.slice(separator + 1);
|
|
306
|
+
if (mode === "120000" || type !== "blob" || !relativePath
|
|
307
|
+
|| (directory !== undefined && !relativePath.startsWith(`${directory}/`))
|
|
308
|
+
|| !isSourceSnapshotFile(relativePath, directory)
|
|
309
|
+
|| relativePath.split("/").slice(0, -1).some(segment => EXCLUDED_LIFECYCLE_SEGMENTS.has(segment)))
|
|
310
|
+
continue;
|
|
311
|
+
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(objectId)
|
|
312
|
+
|| !["100644", "100755"].includes(mode))
|
|
313
|
+
throw new Error("Unsafe Git snapshot entry");
|
|
314
|
+
entries.push({ path: relativePath, objectId });
|
|
315
|
+
if (entries.length > SOURCE_SNAPSHOT_LIMITS.maxFiles)
|
|
316
|
+
throw new Error("Git snapshot exceeds file count limit");
|
|
295
317
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|| (directory !== undefined && !relativePath.startsWith(`${directory}/`))
|
|
302
|
-
|| !isSourceSnapshotFile(relativePath, directory)
|
|
303
|
-
|| relativePath.split("/").slice(0, -1).some((segment) => EXCLUDED_LIFECYCLE_SEGMENTS.has(segment))) {
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
files.push({
|
|
307
|
-
path: relativePath,
|
|
308
|
-
content: await this.runner.run("git", ["--git-dir", destination, "show", `${commit}:${relativePath}`]),
|
|
318
|
+
if (entries.length === 0)
|
|
319
|
+
return Object.freeze([]);
|
|
320
|
+
const output = await this.runner.runBinary("git", ["--no-replace-objects", "--git-dir", destination, "cat-file", "--batch"], {
|
|
321
|
+
stdin: Buffer.from(entries.map(entry => `${entry.objectId}\n`).join("")),
|
|
322
|
+
maxOutputBytes: SOURCE_SNAPSHOT_LIMITS.maxTotalBytes + entries.length * 130,
|
|
309
323
|
});
|
|
310
|
-
|
|
311
|
-
|
|
324
|
+
return decodeSnapshotBatch(output, entries);
|
|
325
|
+
});
|
|
312
326
|
}
|
|
313
327
|
/** File paths at or under `root`, from the same immutable commit as the other reads. */
|
|
314
328
|
async listFiles(source, root) {
|
package/dist/src/path-safety.js
CHANGED
|
@@ -8,6 +8,9 @@ export function pathsOverlap(left, right) {
|
|
|
8
8
|
(!relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)) ||
|
|
9
9
|
(!reverse.startsWith(`..${path.sep}`) && !path.isAbsolute(reverse));
|
|
10
10
|
}
|
|
11
|
+
/** A path component that is a symbolic link or junction; the message names it. */
|
|
12
|
+
export class SymlinkPathError extends Error {
|
|
13
|
+
}
|
|
11
14
|
/** Walks every existing component of a path and rejects the first symbolic link. */
|
|
12
15
|
export async function assertNoSymlinkPath(candidate, label) {
|
|
13
16
|
const absolute = path.resolve(candidate);
|
|
@@ -18,7 +21,7 @@ export async function assertNoSymlinkPath(candidate, label) {
|
|
|
18
21
|
current = path.join(current, segment);
|
|
19
22
|
try {
|
|
20
23
|
if ((await lstat(current)).isSymbolicLink()) {
|
|
21
|
-
throw new
|
|
24
|
+
throw new SymlinkPathError(`${label} contains a symbolic link: ${current}`);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
catch (error) {
|
|
@@ -151,6 +151,10 @@ function signalProcesses(pids, signal) {
|
|
|
151
151
|
*/
|
|
152
152
|
export function runProcess(command, args, options = {}) {
|
|
153
153
|
return new Promise((resolve, reject) => {
|
|
154
|
+
if (options.stdin !== undefined && options.stdin.byteLength > 1024 * 1024) {
|
|
155
|
+
reject(new Error("Process stdin exceeds the safe size limit"));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
154
158
|
const invocation = spawnInvocation(command, args);
|
|
155
159
|
const sink = childOutputSinks.getStore();
|
|
156
160
|
const child = spawn(invocation.command, [...invocation.args], {
|
|
@@ -158,7 +162,7 @@ export function runProcess(command, args, options = {}) {
|
|
|
158
162
|
shell: false,
|
|
159
163
|
windowsVerbatimArguments: invocation.windowsVerbatimArguments,
|
|
160
164
|
// Without a capture, stdout is piped only for a sink, and then discarded after it is shown.
|
|
161
|
-
stdio: ["ignore", options.captureStdout || sink !== undefined ? "pipe" : "ignore", "pipe"],
|
|
165
|
+
stdio: [options.stdin === undefined ? "ignore" : "pipe", options.captureStdout || sink !== undefined ? "pipe" : "ignore", "pipe"],
|
|
162
166
|
});
|
|
163
167
|
const stdout = [];
|
|
164
168
|
let stdoutBytes = 0;
|
|
@@ -189,6 +193,7 @@ export function runProcess(command, args, options = {}) {
|
|
|
189
193
|
};
|
|
190
194
|
// A surviving descendant keeps the pipes open, so `close` may never come: give up on them.
|
|
191
195
|
const giveUp = () => {
|
|
196
|
+
child.stdin?.destroy();
|
|
192
197
|
child.stdout?.destroy();
|
|
193
198
|
child.stderr?.destroy();
|
|
194
199
|
settle(child.exitCode, child.signalCode);
|
|
@@ -263,5 +268,11 @@ export function runProcess(command, args, options = {}) {
|
|
|
263
268
|
});
|
|
264
269
|
child.on("error", reject);
|
|
265
270
|
child.on("close", settle);
|
|
271
|
+
child.stdin?.on("error", (error) => {
|
|
272
|
+
// Windows reports EOF when a child exits with input still pending.
|
|
273
|
+
if (error.code !== "EPIPE" && error.code !== "EOF")
|
|
274
|
+
reject(error);
|
|
275
|
+
});
|
|
276
|
+
child.stdin?.end(options.stdin);
|
|
266
277
|
});
|
|
267
278
|
}
|
|
@@ -45,7 +45,7 @@ export function describeProfileReplica(replica) {
|
|
|
45
45
|
case "package": return `Installed Package ${describeCoordinates(replica.selection)} from ${profileSourceIdentity(replica.selection.source)}`;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function profileSourceIdentity(source) {
|
|
48
|
+
export function profileSourceIdentity(source) {
|
|
49
49
|
if (source.kind === "builtin")
|
|
50
50
|
return "Agent Depot (built-in Source)";
|
|
51
51
|
if ("url" in source)
|