@av-pi-studio/server 0.0.111 → 0.0.112
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/dist/daemon/bootstrap.js +13 -0
- package/dist/extensions/sync-executor.d.ts +4 -0
- package/dist/extensions/sync-executor.js +9 -3
- package/dist/resources/pi-sdk.d.ts +26 -0
- package/dist/resources/pi-sdk.js +21 -0
- package/dist/resources/resource-service.d.ts +197 -0
- package/dist/resources/resource-service.js +717 -0
- package/dist/resources/skill-catalog.d.ts +69 -0
- package/dist/resources/skill-catalog.js +195 -0
- package/dist/resources/skills-cli.d.ts +37 -0
- package/dist/resources/skills-cli.js +113 -0
- package/dist/resources/skills-rpc.d.ts +18 -0
- package/dist/resources/skills-rpc.js +91 -0
- package/dist/resources/spawn-runner.d.ts +41 -0
- package/dist/resources/spawn-runner.js +77 -0
- package/dist/resources/toggle-patterns.d.ts +70 -0
- package/dist/resources/toggle-patterns.js +61 -0
- package/dist/resources/wire.d.ts +17 -0
- package/dist/resources/wire.js +54 -0
- package/package.json +4 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirror of Pi's private skill-toggle pattern derivation (sprint-075/task-002).
|
|
3
|
+
*
|
|
4
|
+
* Pi 1.4.0 (`@earendil-works/pi-coding-agent`) exports no API for turning a skill toggle into
|
|
5
|
+
* a `settings.json` mutation; the logic lives in the TUI-only
|
|
6
|
+
* `modes/interactive/components/config-selector.js` (`ConfigSelectorComponent`/`ResourceList`,
|
|
7
|
+
* lines 655-717), which is never imported here. This module mirrors:
|
|
8
|
+
*
|
|
9
|
+
* - `toggleTopLevelResource` (lines 426-474): pattern = `relative(baseDir ?? agentDir, path)`
|
|
10
|
+
* (`getResourcePattern`, lines 708-714), written into `settings.skills` as `±pattern`, replacing
|
|
11
|
+
* any existing entry whose `!`/`+`/`-`-stripped form equals the same pattern
|
|
12
|
+
* (`getPatternEntryTarget`, lines 696-698).
|
|
13
|
+
* - `togglePackageResource` (lines 475-521): pattern = `relative(baseDir, path)`
|
|
14
|
+
* (`getPackageResourcePattern`, lines 715-717). The matching `packages[]` entry is upgraded
|
|
15
|
+
* from a bare source string to `{source}`, its `skills` filter array is replaced the same way,
|
|
16
|
+
* and the entry collapses back to the bare string once none of `extensions`/`skills`/`prompts`/
|
|
17
|
+
* `themes` remain set (`RESOURCE_TYPES`, line 13; collapse check lines 509-514). Pi's own
|
|
18
|
+
* `enabled` boolean always pushes a replacement entry, so that collapse check is unreachable in
|
|
19
|
+
* practice (confirmed by differential testing below) — `replacePattern`/`applyPackageToggle`
|
|
20
|
+
* here additionally accept `enabled === undefined` to clear an override without replacing it,
|
|
21
|
+
* the same "no push" case as `state === "inherit"` in the project-override tri-state
|
|
22
|
+
* (`setProjectTopLevelOverride`/`setProjectPackageOverride`, lines 563, 600-601), so the
|
|
23
|
+
* collapse this module mirrors is genuinely reachable.
|
|
24
|
+
*
|
|
25
|
+
* Fixture provenance: `ResourceList`/`ConfigSelectorComponent` are not exported, so a throwaway
|
|
26
|
+
* script (deleted after use) imported the internal `config-selector.js` directly by file path —
|
|
27
|
+
* never from `toggle-patterns.ts` itself — constructed a `ConfigSelectorComponent` against a
|
|
28
|
+
* `SettingsManager` pointed at a temporary `HOME`/`PI_CODING_AGENT_DIR`, and called
|
|
29
|
+
* `toggleTopLevelResource`/`togglePackageResource` on its `ResourceList` directly to capture the
|
|
30
|
+
* real `settings.json` mutations frozen as fixtures in `toggle-patterns.test.ts`.
|
|
31
|
+
*/
|
|
32
|
+
/** A Pi `packages[]` entry: a bare source string, or an object with per-resource-type filters. */
|
|
33
|
+
export interface PiPackageEntry {
|
|
34
|
+
source: string;
|
|
35
|
+
autoload?: boolean;
|
|
36
|
+
extensions?: string[];
|
|
37
|
+
skills?: string[];
|
|
38
|
+
prompts?: string[];
|
|
39
|
+
themes?: string[];
|
|
40
|
+
}
|
|
41
|
+
export type PiPackageSource = string | PiPackageEntry;
|
|
42
|
+
/**
|
|
43
|
+
* Derive the top-level (non-package) toggle pattern for a skill: `relative(baseDir ?? agentDir,
|
|
44
|
+
* path)`, mirroring `getResourcePattern` (config-selector.js:708-714).
|
|
45
|
+
*/
|
|
46
|
+
export declare function topLevelPattern(path: string, baseDir: string | undefined, agentDir: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Derive the package-scoped toggle pattern for a skill: `relative(baseDir, path)`, mirroring
|
|
49
|
+
* `getPackageResourcePattern` (config-selector.js:715-717).
|
|
50
|
+
*/
|
|
51
|
+
export declare function packagePattern(path: string, baseDir: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Replace any existing entry targeting `pattern` with `(enabled ? "+" : "-") + pattern`, mirroring
|
|
54
|
+
* the filter common to `toggleTopLevelResource` and `togglePackageResource`
|
|
55
|
+
* (config-selector.js:436-445, 499-508; stripping via `getPatternEntryTarget`, lines 696-698).
|
|
56
|
+
* `enabled === undefined` clears any override for `pattern` without replacing it (see module
|
|
57
|
+
* header) so a caller can drive {@link applyPackageToggle}'s collapse back to a bare string.
|
|
58
|
+
*/
|
|
59
|
+
export declare function replacePattern(entries: string[] | undefined, pattern: string, enabled: boolean | undefined): string[];
|
|
60
|
+
/**
|
|
61
|
+
* Apply a skill toggle to a package's `skills` filter, mirroring `togglePackageResource`
|
|
62
|
+
* (config-selector.js:475-521): the matching entry (by `source`) is upgraded to object form,
|
|
63
|
+
* its `skills` array is replaced via {@link replacePattern}, and the entry collapses back to a
|
|
64
|
+
* bare string once no filter array (`extensions`/`skills`/`prompts`/`themes`) remains. Throws
|
|
65
|
+
* when `source` matches no entry in `packages` (Pi's `togglePackageResource` silently no-ops on
|
|
66
|
+
* a missing `pkgIndex`; this mirror throws instead since task-004 should never call it for an
|
|
67
|
+
* unresolved package).
|
|
68
|
+
*/
|
|
69
|
+
export declare function applyPackageToggle(packages: PiPackageSource[], source: string, pattern: string, enabled: boolean | undefined): PiPackageSource[];
|
|
70
|
+
//# sourceMappingURL=toggle-patterns.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
const FILTER_KEYS = ["extensions", "skills", "prompts", "themes"];
|
|
3
|
+
/**
|
|
4
|
+
* Derive the top-level (non-package) toggle pattern for a skill: `relative(baseDir ?? agentDir,
|
|
5
|
+
* path)`, mirroring `getResourcePattern` (config-selector.js:708-714).
|
|
6
|
+
*/
|
|
7
|
+
export function topLevelPattern(path, baseDir, agentDir) {
|
|
8
|
+
return relative(baseDir ?? agentDir, path)
|
|
9
|
+
.split("\\")
|
|
10
|
+
.join("/");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Derive the package-scoped toggle pattern for a skill: `relative(baseDir, path)`, mirroring
|
|
14
|
+
* `getPackageResourcePattern` (config-selector.js:715-717).
|
|
15
|
+
*/
|
|
16
|
+
export function packagePattern(path, baseDir) {
|
|
17
|
+
return relative(baseDir, path).split("\\").join("/");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Replace any existing entry targeting `pattern` with `(enabled ? "+" : "-") + pattern`, mirroring
|
|
21
|
+
* the filter common to `toggleTopLevelResource` and `togglePackageResource`
|
|
22
|
+
* (config-selector.js:436-445, 499-508; stripping via `getPatternEntryTarget`, lines 696-698).
|
|
23
|
+
* `enabled === undefined` clears any override for `pattern` without replacing it (see module
|
|
24
|
+
* header) so a caller can drive {@link applyPackageToggle}'s collapse back to a bare string.
|
|
25
|
+
*/
|
|
26
|
+
export function replacePattern(entries, pattern, enabled) {
|
|
27
|
+
const updated = (entries ?? []).filter((entry) => {
|
|
28
|
+
const target = entry.startsWith("!") || entry.startsWith("+") || entry.startsWith("-")
|
|
29
|
+
? entry.slice(1)
|
|
30
|
+
: entry;
|
|
31
|
+
return target !== pattern;
|
|
32
|
+
});
|
|
33
|
+
if (enabled !== undefined) {
|
|
34
|
+
updated.push(`${enabled ? "+" : "-"}${pattern}`);
|
|
35
|
+
}
|
|
36
|
+
return updated;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Apply a skill toggle to a package's `skills` filter, mirroring `togglePackageResource`
|
|
40
|
+
* (config-selector.js:475-521): the matching entry (by `source`) is upgraded to object form,
|
|
41
|
+
* its `skills` array is replaced via {@link replacePattern}, and the entry collapses back to a
|
|
42
|
+
* bare string once no filter array (`extensions`/`skills`/`prompts`/`themes`) remains. Throws
|
|
43
|
+
* when `source` matches no entry in `packages` (Pi's `togglePackageResource` silently no-ops on
|
|
44
|
+
* a missing `pkgIndex`; this mirror throws instead since task-004 should never call it for an
|
|
45
|
+
* unresolved package).
|
|
46
|
+
*/
|
|
47
|
+
export function applyPackageToggle(packages, source, pattern, enabled) {
|
|
48
|
+
const result = [...packages];
|
|
49
|
+
const index = result.findIndex((pkg) => (typeof pkg === "string" ? pkg : pkg.source) === source);
|
|
50
|
+
if (index === -1) {
|
|
51
|
+
throw new Error(`applyPackageToggle: no package entry for source ${JSON.stringify(source)}`);
|
|
52
|
+
}
|
|
53
|
+
const existing = result[index];
|
|
54
|
+
const entry = typeof existing === "string" ? { source: existing } : { ...existing };
|
|
55
|
+
const updated = replacePattern(entry.skills, pattern, enabled);
|
|
56
|
+
entry.skills = updated.length > 0 ? updated : undefined;
|
|
57
|
+
const hasFilters = FILTER_KEYS.some((key) => entry[key] !== undefined);
|
|
58
|
+
result[index] = hasFilters ? entry : entry.source;
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=toggle-patterns.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PiPackageInfo, SkillInfo } from "@av-pi-studio/protocol";
|
|
2
|
+
import type { CatalogPackage, CatalogSkill } from "./skill-catalog.js";
|
|
3
|
+
/**
|
|
4
|
+
* Maps `skill-catalog.ts`'s internal `CatalogSkill`/`CatalogPackage` shapes to the wire's
|
|
5
|
+
* `SkillInfo`/`PiPackageInfo` (swe/architecture/pi-resource-management.md § Public contract —
|
|
6
|
+
* `wire.ts`) — the ONE mapping, used by `resource-service.ts`'s `list()`/`setEnabled()` so the
|
|
7
|
+
* wire response can never drift from the internal catalog shape. Drops `CatalogSkill.baseDir`
|
|
8
|
+
* (internal-only — task-004's own pattern-derivation input, never sent on the wire). Every
|
|
9
|
+
* source string leaving the daemon goes through `redactSource` (D29): a git remote's embedded
|
|
10
|
+
* credentials never reach a client. A client echoes that redacted string back for
|
|
11
|
+
* `skills_remove`, which `ResourceService` matches on its redacted form.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toSkillInfo(skill: CatalogSkill): SkillInfo;
|
|
14
|
+
export declare function toSkillInfoList(skills: readonly CatalogSkill[]): SkillInfo[];
|
|
15
|
+
export declare function toPiPackageInfo(pkg: CatalogPackage): PiPackageInfo;
|
|
16
|
+
export declare function toPiPackageInfoList(packages: readonly CatalogPackage[]): PiPackageInfo[];
|
|
17
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { redactSource } from "./spawn-runner.js";
|
|
2
|
+
/**
|
|
3
|
+
* Maps `skill-catalog.ts`'s internal `CatalogSkill`/`CatalogPackage` shapes to the wire's
|
|
4
|
+
* `SkillInfo`/`PiPackageInfo` (swe/architecture/pi-resource-management.md § Public contract —
|
|
5
|
+
* `wire.ts`) — the ONE mapping, used by `resource-service.ts`'s `list()`/`setEnabled()` so the
|
|
6
|
+
* wire response can never drift from the internal catalog shape. Drops `CatalogSkill.baseDir`
|
|
7
|
+
* (internal-only — task-004's own pattern-derivation input, never sent on the wire). Every
|
|
8
|
+
* source string leaving the daemon goes through `redactSource` (D29): a git remote's embedded
|
|
9
|
+
* credentials never reach a client. A client echoes that redacted string back for
|
|
10
|
+
* `skills_remove`, which `ResourceService` matches on its redacted form.
|
|
11
|
+
*/
|
|
12
|
+
export function toSkillInfo(skill) {
|
|
13
|
+
return {
|
|
14
|
+
name: skill.name,
|
|
15
|
+
description: skill.description,
|
|
16
|
+
path: skill.path,
|
|
17
|
+
enabled: skill.enabled,
|
|
18
|
+
origin: skill.origin,
|
|
19
|
+
originLabel: skill.originLabel,
|
|
20
|
+
packageSource: skill.packageSource === undefined ? undefined : redactSource(skill.packageSource),
|
|
21
|
+
shadowedBy: skill.shadowedBy,
|
|
22
|
+
symlinkTarget: skill.symlinkTarget,
|
|
23
|
+
provenance: skill.provenance
|
|
24
|
+
? {
|
|
25
|
+
source: redactSource(skill.provenance.source),
|
|
26
|
+
sourceUrl: skill.provenance.sourceUrl === undefined
|
|
27
|
+
? undefined
|
|
28
|
+
: redactSource(skill.provenance.sourceUrl),
|
|
29
|
+
installedAt: skill.provenance.installedAt,
|
|
30
|
+
}
|
|
31
|
+
: undefined,
|
|
32
|
+
disableModelInvocation: skill.disableModelInvocation,
|
|
33
|
+
warnings: skill.warnings,
|
|
34
|
+
removable: skill.removable,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function toSkillInfoList(skills) {
|
|
38
|
+
return skills.map(toSkillInfo);
|
|
39
|
+
}
|
|
40
|
+
export function toPiPackageInfo(pkg) {
|
|
41
|
+
return {
|
|
42
|
+
source: redactSource(pkg.source),
|
|
43
|
+
kind: pkg.kind,
|
|
44
|
+
identity: redactSource(pkg.identity),
|
|
45
|
+
pinned: pkg.pinned,
|
|
46
|
+
curated: pkg.curated,
|
|
47
|
+
filtered: pkg.filtered,
|
|
48
|
+
skillCount: pkg.skillCount,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function toPiPackageInfoList(packages) {
|
|
52
|
+
return packages.map(toPiPackageInfo);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=wire.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@av-pi-studio/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.112",
|
|
4
4
|
"bin": {
|
|
5
5
|
"pi-studio-daemon": "dist/daemon/main.js"
|
|
6
6
|
},
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@av-pi-studio/protocol": "^0.0.
|
|
28
|
-
"@av-pi-studio/relay": "^0.0.
|
|
27
|
+
"@av-pi-studio/protocol": "^0.0.112",
|
|
28
|
+
"@av-pi-studio/relay": "^0.0.112",
|
|
29
29
|
"@earendil-works/pi-coding-agent": "^1.4.0",
|
|
30
30
|
"@xterm/addon-serialize": "^0.14.0",
|
|
31
31
|
"@xterm/headless": "^6.0.0",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"pino": "^10.2.0",
|
|
37
37
|
"pino-pretty": "^13.1.3",
|
|
38
38
|
"rotating-file-stream": "^3.2.9",
|
|
39
|
+
"skills": "1.7.4",
|
|
39
40
|
"strip-ansi": "^7.1.2",
|
|
40
41
|
"tree-kill": "^1.2.2",
|
|
41
42
|
"tweetnacl": "^1.0.3",
|