agentikit 0.0.13 → 0.0.15
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/LICENSE +385 -0
- package/README.md +187 -110
- package/dist/{src/asset-spec.js → asset-spec.js} +11 -2
- package/dist/{src/asset-type-handler.js → asset-type-handler.js} +4 -3
- package/dist/cli.js +709 -0
- package/dist/common.js +192 -0
- package/dist/{src/config-cli.js → config-cli.js} +36 -30
- package/dist/{src/config.js → config.js} +95 -25
- package/dist/{src/db.js → db.js} +123 -51
- package/dist/{src/embedder.js → embedder.js} +57 -2
- package/dist/errors.js +28 -0
- package/dist/file-context.js +188 -0
- package/dist/{src/frontmatter.js → frontmatter.js} +1 -1
- package/dist/{src/github.js → github.js} +1 -3
- package/dist/handlers/agent-handler.js +19 -0
- package/dist/handlers/command-handler.js +20 -0
- package/dist/handlers/handler-bridge.js +51 -0
- package/dist/handlers/index.js +19 -0
- package/dist/handlers/knowledge-handler.js +32 -0
- package/dist/handlers/script-handler.js +42 -0
- package/dist/{src/handlers → handlers}/skill-handler.js +5 -6
- package/dist/{src/handlers → handlers}/tool-handler.js +8 -24
- package/dist/{src/indexer.js → indexer.js} +50 -26
- package/dist/init.js +43 -0
- package/dist/{src/llm.js → llm.js} +6 -11
- package/dist/lockfile.js +60 -0
- package/dist/matchers.js +163 -0
- package/dist/{src/metadata.js → metadata.js} +36 -16
- package/dist/{src/origin-resolve.js → origin-resolve.js} +10 -9
- package/dist/paths.js +83 -0
- package/dist/{src/registry-install.js → registry-install.js} +151 -19
- package/dist/{src/registry-resolve.js → registry-resolve.js} +190 -26
- package/dist/{src/registry-search.js → registry-search.js} +13 -21
- package/dist/renderers.js +286 -0
- package/dist/{src/ripgrep-install.js → ripgrep-install.js} +8 -27
- package/dist/{src/ripgrep-resolve.js → ripgrep-resolve.js} +21 -11
- package/dist/ripgrep.js +2 -0
- package/dist/self-update.js +226 -0
- package/dist/{src/stash-add.js → stash-add.js} +14 -4
- package/dist/stash-clone.js +115 -0
- package/dist/{src/stash-ref.js → stash-ref.js} +10 -9
- package/dist/{src/stash-registry.js → stash-registry.js} +21 -46
- package/dist/{src/stash-resolve.js → stash-resolve.js} +10 -9
- package/dist/{src/stash-search.js → stash-search.js} +89 -74
- package/dist/stash-show.js +74 -0
- package/dist/stash-source.js +127 -0
- package/dist/submit.js +557 -0
- package/dist/{src/tool-runner.js → tool-runner.js} +1 -5
- package/dist/{src/walker.js → walker.js} +38 -0
- package/dist/warn.js +20 -0
- package/package.json +13 -18
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -15
- package/dist/src/asset-spec.d.ts +0 -16
- package/dist/src/asset-type-handler.d.ts +0 -27
- package/dist/src/cli.d.ts +0 -2
- package/dist/src/cli.js +0 -399
- package/dist/src/common.d.ts +0 -13
- package/dist/src/common.js +0 -60
- package/dist/src/config-cli.d.ts +0 -9
- package/dist/src/config.d.ts +0 -50
- package/dist/src/db.d.ts +0 -46
- package/dist/src/embedder.d.ts +0 -10
- package/dist/src/frontmatter.d.ts +0 -30
- package/dist/src/github.d.ts +0 -4
- package/dist/src/handlers/agent-handler.d.ts +0 -2
- package/dist/src/handlers/agent-handler.js +0 -26
- package/dist/src/handlers/command-handler.d.ts +0 -2
- package/dist/src/handlers/command-handler.js +0 -23
- package/dist/src/handlers/index.d.ts +0 -6
- package/dist/src/handlers/index.js +0 -23
- package/dist/src/handlers/knowledge-handler.d.ts +0 -2
- package/dist/src/handlers/knowledge-handler.js +0 -56
- package/dist/src/handlers/markdown-helpers.d.ts +0 -7
- package/dist/src/handlers/script-handler.d.ts +0 -2
- package/dist/src/handlers/script-handler.js +0 -78
- package/dist/src/handlers/skill-handler.d.ts +0 -2
- package/dist/src/handlers/tool-handler.d.ts +0 -2
- package/dist/src/indexer.d.ts +0 -22
- package/dist/src/init.d.ts +0 -19
- package/dist/src/init.js +0 -99
- package/dist/src/llm.d.ts +0 -15
- package/dist/src/markdown.d.ts +0 -18
- package/dist/src/metadata.d.ts +0 -41
- package/dist/src/origin-resolve.d.ts +0 -19
- package/dist/src/registry-install.d.ts +0 -11
- package/dist/src/registry-resolve.d.ts +0 -3
- package/dist/src/registry-search.d.ts +0 -27
- package/dist/src/registry-types.d.ts +0 -62
- package/dist/src/ripgrep-install.d.ts +0 -12
- package/dist/src/ripgrep-resolve.d.ts +0 -13
- package/dist/src/ripgrep.d.ts +0 -3
- package/dist/src/ripgrep.js +0 -2
- package/dist/src/stash-add.d.ts +0 -4
- package/dist/src/stash-clone.d.ts +0 -22
- package/dist/src/stash-clone.js +0 -83
- package/dist/src/stash-ref.d.ts +0 -31
- package/dist/src/stash-registry.d.ts +0 -18
- package/dist/src/stash-resolve.d.ts +0 -2
- package/dist/src/stash-search.d.ts +0 -8
- package/dist/src/stash-show.d.ts +0 -5
- package/dist/src/stash-show.js +0 -46
- package/dist/src/stash-source.d.ts +0 -24
- package/dist/src/stash-source.js +0 -81
- package/dist/src/stash-types.d.ts +0 -227
- package/dist/src/stash.d.ts +0 -16
- package/dist/src/stash.js +0 -9
- package/dist/src/tool-runner.d.ts +0 -35
- package/dist/src/walker.d.ts +0 -19
- package/src/asset-spec.ts +0 -85
- package/src/asset-type-handler.ts +0 -77
- package/src/cli.ts +0 -427
- package/src/common.ts +0 -76
- package/src/config-cli.ts +0 -499
- package/src/config.ts +0 -305
- package/src/db.ts +0 -411
- package/src/embedder.ts +0 -128
- package/src/frontmatter.ts +0 -95
- package/src/github.ts +0 -21
- package/src/handlers/agent-handler.ts +0 -32
- package/src/handlers/command-handler.ts +0 -29
- package/src/handlers/index.ts +0 -25
- package/src/handlers/knowledge-handler.ts +0 -62
- package/src/handlers/markdown-helpers.ts +0 -19
- package/src/handlers/script-handler.ts +0 -92
- package/src/handlers/skill-handler.ts +0 -37
- package/src/handlers/tool-handler.ts +0 -71
- package/src/indexer.ts +0 -392
- package/src/init.ts +0 -114
- package/src/llm.ts +0 -125
- package/src/markdown.ts +0 -106
- package/src/metadata.ts +0 -333
- package/src/origin-resolve.ts +0 -67
- package/src/registry-install.ts +0 -361
- package/src/registry-resolve.ts +0 -341
- package/src/registry-search.ts +0 -335
- package/src/registry-types.ts +0 -72
- package/src/ripgrep-install.ts +0 -200
- package/src/ripgrep-resolve.ts +0 -72
- package/src/ripgrep.ts +0 -3
- package/src/stash-add.ts +0 -63
- package/src/stash-clone.ts +0 -127
- package/src/stash-ref.ts +0 -99
- package/src/stash-registry.ts +0 -259
- package/src/stash-resolve.ts +0 -50
- package/src/stash-search.ts +0 -613
- package/src/stash-show.ts +0 -55
- package/src/stash-source.ts +0 -103
- package/src/stash-types.ts +0 -231
- package/src/stash.ts +0 -39
- package/src/tool-runner.ts +0 -142
- package/src/walker.ts +0 -53
- /package/dist/{src/handlers → handlers}/markdown-helpers.js +0 -0
- /package/dist/{src/markdown.js → markdown.js} +0 -0
- /package/dist/{src/registry-types.js → registry-types.js} +0 -0
- /package/dist/{src/stash-types.js → stash-types.js} +0 -0
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { RegistrySearchResponse } from "./registry-types";
|
|
2
|
-
export interface RegistryIndex {
|
|
3
|
-
version: number;
|
|
4
|
-
updatedAt: string;
|
|
5
|
-
kits: RegistryKitEntry[];
|
|
6
|
-
}
|
|
7
|
-
export interface RegistryKitEntry {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
ref: string;
|
|
12
|
-
source: "npm" | "github" | "git";
|
|
13
|
-
homepage?: string;
|
|
14
|
-
tags?: string[];
|
|
15
|
-
assetTypes?: string[];
|
|
16
|
-
author?: string;
|
|
17
|
-
license?: string;
|
|
18
|
-
latestVersion?: string;
|
|
19
|
-
/** Whether this entry was manually reviewed and approved */
|
|
20
|
-
curated?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface RegistrySearchOptions {
|
|
23
|
-
limit?: number;
|
|
24
|
-
/** Override registry URL(s). Accepts a single URL or an array. */
|
|
25
|
-
registryUrls?: string | string[];
|
|
26
|
-
}
|
|
27
|
-
export declare function searchRegistry(query: string, options?: RegistrySearchOptions): Promise<RegistrySearchResponse>;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export type RegistrySource = "npm" | "github" | "git";
|
|
2
|
-
export interface RegistryRefBase {
|
|
3
|
-
source: RegistrySource;
|
|
4
|
-
ref: string;
|
|
5
|
-
id: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ParsedNpmRef extends RegistryRefBase {
|
|
8
|
-
source: "npm";
|
|
9
|
-
packageName: string;
|
|
10
|
-
requestedVersionOrTag?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ParsedGithubRef extends RegistryRefBase {
|
|
13
|
-
source: "github";
|
|
14
|
-
owner: string;
|
|
15
|
-
repo: string;
|
|
16
|
-
requestedRef?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface ParsedGitRef extends RegistryRefBase {
|
|
19
|
-
source: "git";
|
|
20
|
-
repoRoot: string;
|
|
21
|
-
sourcePath: string;
|
|
22
|
-
}
|
|
23
|
-
export type ParsedRegistryRef = ParsedNpmRef | ParsedGithubRef | ParsedGitRef;
|
|
24
|
-
export interface ResolvedRegistryArtifact {
|
|
25
|
-
id: string;
|
|
26
|
-
source: RegistrySource;
|
|
27
|
-
ref: string;
|
|
28
|
-
artifactUrl: string;
|
|
29
|
-
resolvedVersion?: string;
|
|
30
|
-
resolvedRevision?: string;
|
|
31
|
-
}
|
|
32
|
-
export interface RegistryInstalledEntry {
|
|
33
|
-
id: string;
|
|
34
|
-
source: RegistrySource;
|
|
35
|
-
ref: string;
|
|
36
|
-
resolvedVersion?: string;
|
|
37
|
-
resolvedRevision?: string;
|
|
38
|
-
artifactUrl: string;
|
|
39
|
-
stashRoot: string;
|
|
40
|
-
cacheDir: string;
|
|
41
|
-
installedAt: string;
|
|
42
|
-
}
|
|
43
|
-
export interface RegistryInstallResult extends RegistryInstalledEntry {
|
|
44
|
-
extractedDir: string;
|
|
45
|
-
}
|
|
46
|
-
export interface RegistrySearchHit {
|
|
47
|
-
source: RegistrySource;
|
|
48
|
-
id: string;
|
|
49
|
-
title: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
ref: string;
|
|
52
|
-
homepage?: string;
|
|
53
|
-
score?: number;
|
|
54
|
-
metadata?: Record<string, string>;
|
|
55
|
-
/** Whether this entry was manually reviewed and approved */
|
|
56
|
-
curated?: boolean;
|
|
57
|
-
}
|
|
58
|
-
export interface RegistrySearchResponse {
|
|
59
|
-
query: string;
|
|
60
|
-
hits: RegistrySearchHit[];
|
|
61
|
-
warnings: string[];
|
|
62
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface EnsureRgResult {
|
|
2
|
-
rgPath: string;
|
|
3
|
-
installed: boolean;
|
|
4
|
-
version: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Ensure ripgrep is available. If not found on PATH or in stash/bin,
|
|
8
|
-
* download and install it to stash/bin.
|
|
9
|
-
*
|
|
10
|
-
* Returns the path to the ripgrep binary and whether it was newly installed.
|
|
11
|
-
*/
|
|
12
|
-
export declare function ensureRg(stashDir: string): EnsureRgResult;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const RG_BINARY: string;
|
|
2
|
-
/**
|
|
3
|
-
* Resolve the path to a usable ripgrep binary.
|
|
4
|
-
* Checks in order:
|
|
5
|
-
* 1. stashDir/bin/rg
|
|
6
|
-
* 2. system PATH (rg)
|
|
7
|
-
* Returns null if ripgrep is not available.
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolveRg(stashDir?: string): string | null;
|
|
10
|
-
/**
|
|
11
|
-
* Check if ripgrep is available (either in stash/bin or system PATH).
|
|
12
|
-
*/
|
|
13
|
-
export declare function isRgAvailable(stashDir?: string): boolean;
|
package/dist/src/ripgrep.d.ts
DELETED
package/dist/src/ripgrep.js
DELETED
package/dist/src/stash-add.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type StashSourceKind } from "./stash-source";
|
|
2
|
-
export interface CloneOptions {
|
|
3
|
-
/** Source ref (e.g., npm:@scope/pkg//tool:deploy.sh) */
|
|
4
|
-
sourceRef: string;
|
|
5
|
-
/** Optional new name for the cloned asset */
|
|
6
|
-
newName?: string;
|
|
7
|
-
/** If true, overwrite existing asset in working stash */
|
|
8
|
-
force?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface CloneResponse {
|
|
11
|
-
source: {
|
|
12
|
-
path: string;
|
|
13
|
-
sourceKind: StashSourceKind;
|
|
14
|
-
registryId?: string;
|
|
15
|
-
};
|
|
16
|
-
destination: {
|
|
17
|
-
path: string;
|
|
18
|
-
ref: string;
|
|
19
|
-
};
|
|
20
|
-
overwritten: boolean;
|
|
21
|
-
}
|
|
22
|
-
export declare function agentikitClone(options: CloneOptions): Promise<CloneResponse>;
|
package/dist/src/stash-clone.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { TYPE_DIRS } from "./asset-spec";
|
|
4
|
-
import { parseAssetRef, makeAssetRef } from "./stash-ref";
|
|
5
|
-
import { resolveSourcesForOrigin } from "./origin-resolve";
|
|
6
|
-
import { resolveAssetPath } from "./stash-resolve";
|
|
7
|
-
import { resolveStashSources, findSourceForPath } from "./stash-source";
|
|
8
|
-
export async function agentikitClone(options) {
|
|
9
|
-
const parsed = parseAssetRef(options.sourceRef);
|
|
10
|
-
const allSources = resolveStashSources();
|
|
11
|
-
const workingSource = allSources.find((s) => s.kind === "working");
|
|
12
|
-
if (!workingSource) {
|
|
13
|
-
throw new Error("No working stash configured. Run `akm init` first.");
|
|
14
|
-
}
|
|
15
|
-
const searchSources = resolveSourcesForOrigin(parsed.origin, allSources);
|
|
16
|
-
let sourcePath;
|
|
17
|
-
let lastError;
|
|
18
|
-
for (const source of searchSources) {
|
|
19
|
-
try {
|
|
20
|
-
sourcePath = resolveAssetPath(source.path, parsed.type, parsed.name);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
lastError = err instanceof Error ? err : new Error(String(err));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (!sourcePath) {
|
|
28
|
-
throw lastError ?? new Error(`Source asset not found for ref: ${options.sourceRef}`);
|
|
29
|
-
}
|
|
30
|
-
const sourceSource = findSourceForPath(sourcePath, allSources);
|
|
31
|
-
const sourceKind = sourceSource?.kind ?? "working";
|
|
32
|
-
const destName = options.newName ?? parsed.name;
|
|
33
|
-
const typeDir = TYPE_DIRS[parsed.type];
|
|
34
|
-
const workingDir = workingSource.path;
|
|
35
|
-
// Guard against self-clone
|
|
36
|
-
if (parsed.type === "skill") {
|
|
37
|
-
const sourceSkillDir = path.resolve(path.dirname(sourcePath));
|
|
38
|
-
const destSkillDir = path.resolve(path.join(workingDir, typeDir, destName));
|
|
39
|
-
if (sourceSkillDir === destSkillDir) {
|
|
40
|
-
throw new Error(`Source and destination are the same path. Use --name to provide a new name for the clone.`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const resolvedSource = path.resolve(sourcePath);
|
|
45
|
-
const resolvedDest = path.resolve(path.join(workingDir, typeDir, destName));
|
|
46
|
-
if (resolvedSource === resolvedDest) {
|
|
47
|
-
throw new Error(`Source and destination are the same path. Use --name to provide a new name for the clone.`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
let destPath;
|
|
51
|
-
if (parsed.type === "skill") {
|
|
52
|
-
const sourceSkillDir = path.dirname(sourcePath);
|
|
53
|
-
const destSkillDir = path.join(workingDir, typeDir, destName);
|
|
54
|
-
const overwritten = fs.existsSync(destSkillDir);
|
|
55
|
-
if (overwritten && !options.force) {
|
|
56
|
-
throw new Error(`Asset already exists in working stash: ${destSkillDir}. Use --force to overwrite.`);
|
|
57
|
-
}
|
|
58
|
-
if (overwritten) {
|
|
59
|
-
fs.rmSync(destSkillDir, { recursive: true, force: true });
|
|
60
|
-
}
|
|
61
|
-
fs.cpSync(sourceSkillDir, destSkillDir, { recursive: true });
|
|
62
|
-
destPath = path.join(destSkillDir, "SKILL.md");
|
|
63
|
-
const ref = makeAssetRef(parsed.type, destName, "local");
|
|
64
|
-
return {
|
|
65
|
-
source: { path: sourcePath, sourceKind, registryId: sourceSource?.registryId },
|
|
66
|
-
destination: { path: destPath, ref },
|
|
67
|
-
overwritten,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
destPath = path.join(workingDir, typeDir, destName);
|
|
71
|
-
const overwritten = fs.existsSync(destPath);
|
|
72
|
-
if (overwritten && !options.force) {
|
|
73
|
-
throw new Error(`Asset already exists in working stash: ${destPath}. Use --force to overwrite.`);
|
|
74
|
-
}
|
|
75
|
-
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
76
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
77
|
-
const ref = makeAssetRef(parsed.type, destName, "local");
|
|
78
|
-
return {
|
|
79
|
-
source: { path: sourcePath, sourceKind, registryId: sourceSource?.registryId },
|
|
80
|
-
destination: { path: destPath, ref },
|
|
81
|
-
overwritten,
|
|
82
|
-
};
|
|
83
|
-
}
|
package/dist/src/stash-ref.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type AgentikitAssetType } from "./common";
|
|
2
|
-
export interface AssetRef {
|
|
3
|
-
type: AgentikitAssetType;
|
|
4
|
-
name: string;
|
|
5
|
-
/**
|
|
6
|
-
* Where to find this asset.
|
|
7
|
-
* - undefined: search all sources (working → mounted → installed)
|
|
8
|
-
* - "local": working stash only
|
|
9
|
-
* - registry ref: e.g. "npm:@scope/pkg", "owner/repo", "github:owner/repo#v1"
|
|
10
|
-
* - filesystem path: e.g. "/mnt/shared-stash"
|
|
11
|
-
*/
|
|
12
|
-
origin?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Build a ref string from components.
|
|
16
|
-
*
|
|
17
|
-
* Examples:
|
|
18
|
-
* makeAssetRef("tool", "deploy.sh")
|
|
19
|
-
* → "tool:deploy.sh"
|
|
20
|
-
* makeAssetRef("tool", "deploy.sh", "npm:@scope/pkg")
|
|
21
|
-
* → "npm:@scope/pkg//tool:deploy.sh"
|
|
22
|
-
* makeAssetRef("skill", "code-review", "local")
|
|
23
|
-
* → "local//skill:code-review"
|
|
24
|
-
* makeAssetRef("tool", "db/migrate/run.sh", "owner/repo")
|
|
25
|
-
* → "owner/repo//tool:db/migrate/run.sh"
|
|
26
|
-
*/
|
|
27
|
-
export declare function makeAssetRef(type: AgentikitAssetType, name: string, origin?: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Parse a ref string in the format `[origin//]type:name`.
|
|
30
|
-
*/
|
|
31
|
-
export declare function parseAssetRef(ref: string): AssetRef;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ListResponse, RemoveResponse, ReinstallResponse, UpdateResponse } from "./stash-types";
|
|
2
|
-
export declare function agentikitList(input?: {
|
|
3
|
-
stashDir?: string;
|
|
4
|
-
}): Promise<ListResponse>;
|
|
5
|
-
export declare function agentikitRemove(input: {
|
|
6
|
-
target: string;
|
|
7
|
-
stashDir?: string;
|
|
8
|
-
}): Promise<RemoveResponse>;
|
|
9
|
-
export declare function agentikitReinstall(input?: {
|
|
10
|
-
target?: string;
|
|
11
|
-
all?: boolean;
|
|
12
|
-
stashDir?: string;
|
|
13
|
-
}): Promise<ReinstallResponse>;
|
|
14
|
-
export declare function agentikitUpdate(input?: {
|
|
15
|
-
target?: string;
|
|
16
|
-
all?: boolean;
|
|
17
|
-
stashDir?: string;
|
|
18
|
-
}): Promise<UpdateResponse>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AgentikitSearchType, SearchResponse, SearchSource, SearchUsageMode } from "./stash-types";
|
|
2
|
-
export declare function agentikitSearch(input: {
|
|
3
|
-
query: string;
|
|
4
|
-
type?: AgentikitSearchType;
|
|
5
|
-
limit?: number;
|
|
6
|
-
usage?: SearchUsageMode;
|
|
7
|
-
source?: SearchSource;
|
|
8
|
-
}): Promise<SearchResponse>;
|
package/dist/src/stash-show.d.ts
DELETED
package/dist/src/stash-show.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { parseAssetRef } from "./stash-ref";
|
|
3
|
-
import { resolveSourcesForOrigin } from "./origin-resolve";
|
|
4
|
-
import { resolveAssetPath } from "./stash-resolve";
|
|
5
|
-
import { getHandler } from "./asset-type-handler";
|
|
6
|
-
import { resolveStashSources, findSourceForPath } from "./stash-source";
|
|
7
|
-
export async function agentikitShow(input) {
|
|
8
|
-
const parsed = parseAssetRef(input.ref);
|
|
9
|
-
const allSources = resolveStashSources();
|
|
10
|
-
const searchSources = resolveSourcesForOrigin(parsed.origin, allSources);
|
|
11
|
-
const allStashDirs = searchSources.map((s) => s.path);
|
|
12
|
-
let assetPath;
|
|
13
|
-
let lastError;
|
|
14
|
-
for (const dir of allStashDirs) {
|
|
15
|
-
try {
|
|
16
|
-
assetPath = resolveAssetPath(dir, parsed.type, parsed.name);
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
lastError = err instanceof Error ? err : new Error(String(err));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (!assetPath && parsed.origin && searchSources.length === 0) {
|
|
24
|
-
const installCmd = `akm add ${parsed.origin}`;
|
|
25
|
-
throw new Error(`Stash asset not found for ref: ${parsed.type}:${parsed.name}. ` +
|
|
26
|
-
`Kit "${parsed.origin}" is not installed. Run: ${installCmd}`);
|
|
27
|
-
}
|
|
28
|
-
if (!assetPath) {
|
|
29
|
-
throw lastError ?? new Error(`Stash asset not found for ref: ${parsed.type}:${parsed.name}`);
|
|
30
|
-
}
|
|
31
|
-
const content = fs.readFileSync(assetPath, "utf8");
|
|
32
|
-
const source = findSourceForPath(assetPath, allSources);
|
|
33
|
-
const handler = getHandler(parsed.type);
|
|
34
|
-
const response = handler.buildShowResponse({
|
|
35
|
-
name: parsed.name,
|
|
36
|
-
path: assetPath,
|
|
37
|
-
content,
|
|
38
|
-
view: input.view,
|
|
39
|
-
stashDirs: allStashDirs,
|
|
40
|
-
});
|
|
41
|
-
return {
|
|
42
|
-
...response,
|
|
43
|
-
registryId: source?.registryId,
|
|
44
|
-
editable: source?.writable ?? false,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type StashSourceKind = "working" | "mounted" | "installed";
|
|
2
|
-
export interface StashSource {
|
|
3
|
-
kind: StashSourceKind;
|
|
4
|
-
path: string;
|
|
5
|
-
/** For installed sources, the registry entry id */
|
|
6
|
-
registryId?: string;
|
|
7
|
-
/** Whether this source is writable (only working stash) */
|
|
8
|
-
writable: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Build the ordered list of stash sources:
|
|
12
|
-
* 1. Working stash (writable)
|
|
13
|
-
* 2. Mounted stash dirs (read-only, user-configured)
|
|
14
|
-
* 3. Installed stash dirs (read-only, derived from registry.installed)
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolveStashSources(overrideStashDir?: string): StashSource[];
|
|
17
|
-
/**
|
|
18
|
-
* Convenience: returns just the directory paths, preserving priority order.
|
|
19
|
-
*/
|
|
20
|
-
export declare function resolveAllStashDirs(overrideStashDir?: string): string[];
|
|
21
|
-
/**
|
|
22
|
-
* Find which source a file path belongs to.
|
|
23
|
-
*/
|
|
24
|
-
export declare function findSourceForPath(filePath: string, sources: StashSource[]): StashSource | undefined;
|
package/dist/src/stash-source.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { resolveStashDir } from "./common";
|
|
4
|
-
import { loadConfig } from "./config";
|
|
5
|
-
// ── Resolution ──────────────────────────────────────────────────────────────
|
|
6
|
-
/**
|
|
7
|
-
* Build the ordered list of stash sources:
|
|
8
|
-
* 1. Working stash (writable)
|
|
9
|
-
* 2. Mounted stash dirs (read-only, user-configured)
|
|
10
|
-
* 3. Installed stash dirs (read-only, derived from registry.installed)
|
|
11
|
-
*/
|
|
12
|
-
export function resolveStashSources(overrideStashDir) {
|
|
13
|
-
const stashDir = overrideStashDir ?? resolveStashDir();
|
|
14
|
-
const config = loadConfig();
|
|
15
|
-
const sources = [
|
|
16
|
-
{ kind: "working", path: stashDir, writable: true },
|
|
17
|
-
];
|
|
18
|
-
for (const dir of config.mountedStashDirs) {
|
|
19
|
-
if (isSuspiciousStashRoot(dir)) {
|
|
20
|
-
console.warn(`Warning: stash root "${dir}" appears to be a system directory. This may be unintentional.`);
|
|
21
|
-
}
|
|
22
|
-
if (isValidDirectory(dir)) {
|
|
23
|
-
sources.push({ kind: "mounted", path: dir, writable: false });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
for (const entry of config.registry?.installed ?? []) {
|
|
27
|
-
if (isSuspiciousStashRoot(entry.stashRoot)) {
|
|
28
|
-
console.warn(`Warning: stash root "${entry.stashRoot}" appears to be a system directory. This may be unintentional.`);
|
|
29
|
-
}
|
|
30
|
-
if (isValidDirectory(entry.stashRoot)) {
|
|
31
|
-
sources.push({
|
|
32
|
-
kind: "installed",
|
|
33
|
-
path: entry.stashRoot,
|
|
34
|
-
registryId: entry.id,
|
|
35
|
-
writable: false,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return sources;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Convenience: returns just the directory paths, preserving priority order.
|
|
43
|
-
*/
|
|
44
|
-
export function resolveAllStashDirs(overrideStashDir) {
|
|
45
|
-
return resolveStashSources(overrideStashDir).map((s) => s.path);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Find which source a file path belongs to.
|
|
49
|
-
*/
|
|
50
|
-
export function findSourceForPath(filePath, sources) {
|
|
51
|
-
const resolved = path.resolve(filePath);
|
|
52
|
-
for (const source of sources) {
|
|
53
|
-
if (resolved.startsWith(path.resolve(source.path) + path.sep))
|
|
54
|
-
return source;
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
// ── Validation ──────────────────────────────────────────────────────────────
|
|
59
|
-
const SUSPICIOUS_ROOTS = new Set(['/', '/etc', '/bin', '/sbin', '/usr', '/var', '/tmp', '/dev', '/proc', '/sys']);
|
|
60
|
-
function isSuspiciousStashRoot(dir) {
|
|
61
|
-
const resolved = path.resolve(dir);
|
|
62
|
-
const normalized = process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
63
|
-
if (SUSPICIOUS_ROOTS.has(normalized))
|
|
64
|
-
return true;
|
|
65
|
-
if (process.platform === 'win32') {
|
|
66
|
-
// Check for Windows system directories
|
|
67
|
-
const winDir = (process.env.SystemRoot || 'C:\\Windows').toLowerCase();
|
|
68
|
-
if (normalized === winDir || normalized.startsWith(winDir + path.sep))
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
74
|
-
function isValidDirectory(dir) {
|
|
75
|
-
try {
|
|
76
|
-
return fs.statSync(dir).isDirectory();
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|