@pi-unipi/subagents 0.1.13 → 0.2.3
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/package.json +1 -1
- package/src/__tests__/badge-generation.test.ts +244 -0
- package/src/agent-manager.ts +12 -1
- package/src/agent-runner.ts +23 -8
- package/src/conversation-viewer.ts +299 -0
- package/src/index.ts +432 -49
- package/src/types.ts +49 -0
- package/src/widget.ts +332 -72
- package/dist/agent-manager.d.ts +0 -72
- package/dist/agent-manager.d.ts.map +0 -1
- package/dist/agent-manager.js +0 -258
- package/dist/agent-manager.js.map +0 -1
- package/dist/agent-runner.d.ts +0 -50
- package/dist/agent-runner.d.ts.map +0 -1
- package/dist/agent-runner.js +0 -238
- package/dist/agent-runner.js.map +0 -1
- package/dist/config.d.ts +0 -24
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -132
- package/dist/config.js.map +0 -1
- package/dist/custom-agents.d.ts +0 -14
- package/dist/custom-agents.d.ts.map +0 -1
- package/dist/custom-agents.js +0 -106
- package/dist/custom-agents.js.map +0 -1
- package/dist/file-lock.d.ts +0 -42
- package/dist/file-lock.d.ts.map +0 -1
- package/dist/file-lock.js +0 -91
- package/dist/file-lock.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -301
- package/dist/index.js.map +0 -1
- package/dist/model-resolver.d.ts +0 -19
- package/dist/model-resolver.d.ts.map +0 -1
- package/dist/model-resolver.js +0 -61
- package/dist/model-resolver.js.map +0 -1
- package/dist/prompts.d.ts +0 -13
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -31
- package/dist/prompts.js.map +0 -1
- package/dist/types.d.ts +0 -79
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
- package/dist/widget.d.ts +0 -26
- package/dist/widget.d.ts.map +0 -1
- package/dist/widget.js +0 -162
- package/dist/widget.js.map +0 -1
package/dist/config.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @pi-unipi/subagents — Config management
|
|
3
|
-
*
|
|
4
|
-
* Loads config from ~/.unipi/config/subagents.json (global)
|
|
5
|
-
* and <workspace>/.unipi/config/subagents.json (override).
|
|
6
|
-
* Auto-generates on first run. Repairs corrupted files.
|
|
7
|
-
*/
|
|
8
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
import { homedir } from "node:os";
|
|
11
|
-
const DEFAULT_CONFIG = {
|
|
12
|
-
maxConcurrent: 4,
|
|
13
|
-
enabled: true,
|
|
14
|
-
types: {
|
|
15
|
-
explore: { enabled: true },
|
|
16
|
-
work: { enabled: true },
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
/** Get global config path: ~/.unipi/config/subagents.json */
|
|
20
|
-
function getGlobalConfigPath() {
|
|
21
|
-
return join(homedir(), ".unipi", "config", "subagents.json");
|
|
22
|
-
}
|
|
23
|
-
/** Get workspace config path: <cwd>/.unipi/config/subagents.json */
|
|
24
|
-
function getWorkspaceConfigPath(cwd) {
|
|
25
|
-
return join(cwd, ".unipi", "config", "subagents.json");
|
|
26
|
-
}
|
|
27
|
-
/** Ensure directory exists. */
|
|
28
|
-
function ensureDir(filePath) {
|
|
29
|
-
const dir = filePath.substring(0, filePath.lastIndexOf("/"));
|
|
30
|
-
if (!existsSync(dir)) {
|
|
31
|
-
mkdirSync(dir, { recursive: true });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/** Ensure a directory exists (not a file path). */
|
|
35
|
-
function ensureDirExists(dirPath) {
|
|
36
|
-
if (!existsSync(dirPath)) {
|
|
37
|
-
mkdirSync(dirPath, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/** Write config atomically (write then rename). */
|
|
41
|
-
function writeConfigAtomic(filePath, config) {
|
|
42
|
-
const tmpPath = filePath + ".tmp";
|
|
43
|
-
writeFileSync(tmpPath, JSON.stringify(config, null, 2), "utf-8");
|
|
44
|
-
renameSync(tmpPath, filePath);
|
|
45
|
-
}
|
|
46
|
-
/** Load and parse config from a path. Returns null on failure. */
|
|
47
|
-
function loadConfigFromPath(filePath) {
|
|
48
|
-
if (!existsSync(filePath))
|
|
49
|
-
return null;
|
|
50
|
-
try {
|
|
51
|
-
const content = readFileSync(filePath, "utf-8");
|
|
52
|
-
const parsed = JSON.parse(content);
|
|
53
|
-
// Basic validation
|
|
54
|
-
if (typeof parsed !== "object" || parsed === null)
|
|
55
|
-
return null;
|
|
56
|
-
return parsed;
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/** Repair corrupted config: rename to .bak and generate fresh. */
|
|
63
|
-
function repairCorrupted(filePath) {
|
|
64
|
-
const backupPath = filePath + ".bak";
|
|
65
|
-
try {
|
|
66
|
-
renameSync(filePath, backupPath);
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
// If rename fails, just overwrite
|
|
70
|
-
}
|
|
71
|
-
writeConfigAtomic(filePath, DEFAULT_CONFIG);
|
|
72
|
-
return DEFAULT_CONFIG;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Initialize config on extension start.
|
|
76
|
-
* - If missing: generate with defaults
|
|
77
|
-
* - If corrupted: rename to .bak, generate fresh
|
|
78
|
-
* - If valid: load
|
|
79
|
-
*/
|
|
80
|
-
export function initConfig(cwd) {
|
|
81
|
-
const globalPath = getGlobalConfigPath();
|
|
82
|
-
const globalDir = join(homedir(), ".unipi", "config");
|
|
83
|
-
const globalAgentsDir = join(homedir(), ".unipi", "config", "agents");
|
|
84
|
-
// Ensure directories exist
|
|
85
|
-
ensureDirExists(globalDir);
|
|
86
|
-
ensureDirExists(globalAgentsDir);
|
|
87
|
-
// Load or create global config
|
|
88
|
-
let globalConfig = loadConfigFromPath(globalPath);
|
|
89
|
-
if (globalConfig === null) {
|
|
90
|
-
globalConfig = repairCorrupted(globalPath);
|
|
91
|
-
}
|
|
92
|
-
// Ensure workspace directories exist if workspace exists
|
|
93
|
-
const workspaceDir = join(cwd, ".unipi", "config");
|
|
94
|
-
const workspaceAgentsDir = join(cwd, ".unipi", "config", "agents");
|
|
95
|
-
if (cwd && !cwd.startsWith(homedir())) {
|
|
96
|
-
// Only create workspace dirs if not in home directory
|
|
97
|
-
ensureDirExists(workspaceDir);
|
|
98
|
-
ensureDirExists(workspaceAgentsDir);
|
|
99
|
-
}
|
|
100
|
-
// Load workspace override if exists
|
|
101
|
-
const workspacePath = getWorkspaceConfigPath(cwd);
|
|
102
|
-
const workspaceConfig = loadConfigFromPath(workspacePath);
|
|
103
|
-
if (workspaceConfig) {
|
|
104
|
-
// Merge: workspace overrides global on any field present
|
|
105
|
-
return {
|
|
106
|
-
...globalConfig,
|
|
107
|
-
...workspaceConfig,
|
|
108
|
-
types: {
|
|
109
|
-
...globalConfig.types,
|
|
110
|
-
...workspaceConfig.types,
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
return globalConfig;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Save global config.
|
|
118
|
-
*/
|
|
119
|
-
export function saveGlobalConfig(config) {
|
|
120
|
-
const globalPath = getGlobalConfigPath();
|
|
121
|
-
ensureDir(globalPath);
|
|
122
|
-
writeConfigAtomic(globalPath, config);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Save workspace config.
|
|
126
|
-
*/
|
|
127
|
-
export function saveWorkspaceConfig(cwd, config) {
|
|
128
|
-
const workspacePath = getWorkspaceConfigPath(cwd);
|
|
129
|
-
ensureDir(workspacePath);
|
|
130
|
-
writeConfigAtomic(workspacePath, config);
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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C;IACzC,SAAS,CAAC,UAAU,CAAC,CAAC;IACtB,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,MAAuB;IACtE,MAAM,aAAa,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAClD,SAAS,CAAC,aAAa,CAAC,CAAC;IACzB,iBAAiB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/custom-agents.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @pi-unipi/subagents — Custom agent loader
|
|
3
|
-
*
|
|
4
|
-
* Discovers agent types from:
|
|
5
|
-
* - <workspace>/.unipi/config/agents/*.md (project, highest priority)
|
|
6
|
-
* - ~/.unipi/config/agents/*.md (global)
|
|
7
|
-
*/
|
|
8
|
-
import type { AgentConfig } from "./types.js";
|
|
9
|
-
/**
|
|
10
|
-
* Load all custom agents from project and global directories.
|
|
11
|
-
* Project agents override global agents with the same name.
|
|
12
|
-
*/
|
|
13
|
-
export declare function loadCustomAgents(cwd: string): Map<string, AgentConfig>;
|
|
14
|
-
//# sourceMappingURL=custom-agents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-agents.d.ts","sourceRoot":"","sources":["../src/custom-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyE9C;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CA4BtE"}
|
package/dist/custom-agents.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @pi-unipi/subagents — Custom agent loader
|
|
3
|
-
*
|
|
4
|
-
* Discovers agent types from:
|
|
5
|
-
* - <workspace>/.unipi/config/agents/*.md (project, highest priority)
|
|
6
|
-
* - ~/.unipi/config/agents/*.md (global)
|
|
7
|
-
*/
|
|
8
|
-
import { existsSync, readdirSync, readFileSync, renameSync } from "node:fs";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
import { homedir } from "node:os";
|
|
11
|
-
import { parseFrontmatter } from "@mariozechner/pi-coding-agent";
|
|
12
|
-
/** Backup a corrupted file by renaming to .bak */
|
|
13
|
-
function backupCorrupted(filePath) {
|
|
14
|
-
const backupPath = filePath + ".bak";
|
|
15
|
-
try {
|
|
16
|
-
renameSync(filePath, backupPath);
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
// If backup fails, just leave it
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Get project agents directory. */
|
|
23
|
-
function getProjectAgentsDir(cwd) {
|
|
24
|
-
return join(cwd, ".unipi", "config", "agents");
|
|
25
|
-
}
|
|
26
|
-
/** Get global agents directory. */
|
|
27
|
-
function getGlobalAgentsDir() {
|
|
28
|
-
return join(homedir(), ".unipi", "config", "agents");
|
|
29
|
-
}
|
|
30
|
-
/** All known built-in tool names. */
|
|
31
|
-
const BUILTIN_TOOL_NAMES = ["read", "bash", "edit", "write", "grep", "find", "ls"];
|
|
32
|
-
/**
|
|
33
|
-
* Load a single agent from a .md file.
|
|
34
|
-
*/
|
|
35
|
-
function loadAgentFromFile(filePath, source) {
|
|
36
|
-
try {
|
|
37
|
-
const content = readFileSync(filePath, "utf-8");
|
|
38
|
-
const { frontmatter, body } = parseFrontmatter(content);
|
|
39
|
-
if (!frontmatter || typeof frontmatter !== "object") {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
const name = filePath.split("/").pop()?.replace(/\.md$/, "") ?? "unknown";
|
|
43
|
-
// Parse tools from comma-separated string
|
|
44
|
-
const toolsStr = frontmatter.tools;
|
|
45
|
-
const builtinToolNames = toolsStr
|
|
46
|
-
? toolsStr.split(",").map((t) => t.trim()).filter((t) => BUILTIN_TOOL_NAMES.includes(t))
|
|
47
|
-
: [...BUILTIN_TOOL_NAMES];
|
|
48
|
-
return {
|
|
49
|
-
name,
|
|
50
|
-
displayName: frontmatter.display_name,
|
|
51
|
-
description: frontmatter.description ?? `${name} agent`,
|
|
52
|
-
builtinToolNames,
|
|
53
|
-
disallowedTools: frontmatter.disallowed_tools
|
|
54
|
-
?.split(",")
|
|
55
|
-
.map((t) => t.trim()),
|
|
56
|
-
extensions: frontmatter.extensions !== false,
|
|
57
|
-
skills: frontmatter.skills !== false,
|
|
58
|
-
model: frontmatter.model,
|
|
59
|
-
thinking: frontmatter.thinking,
|
|
60
|
-
maxTurns: frontmatter.max_turns,
|
|
61
|
-
systemPrompt: body.trim(),
|
|
62
|
-
promptMode: frontmatter.prompt_mode ?? "replace",
|
|
63
|
-
inheritContext: frontmatter.inherit_context,
|
|
64
|
-
runInBackground: frontmatter.run_in_background,
|
|
65
|
-
isolated: frontmatter.isolated,
|
|
66
|
-
enabled: frontmatter.enabled !== false,
|
|
67
|
-
source,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
// Corrupted file — backup and skip
|
|
72
|
-
backupCorrupted(filePath);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Load all custom agents from project and global directories.
|
|
78
|
-
* Project agents override global agents with the same name.
|
|
79
|
-
*/
|
|
80
|
-
export function loadCustomAgents(cwd) {
|
|
81
|
-
const agents = new Map();
|
|
82
|
-
// Load global agents first
|
|
83
|
-
const globalDir = getGlobalAgentsDir();
|
|
84
|
-
if (existsSync(globalDir)) {
|
|
85
|
-
const files = readdirSync(globalDir).filter((f) => f.endsWith(".md"));
|
|
86
|
-
for (const file of files) {
|
|
87
|
-
const agent = loadAgentFromFile(join(globalDir, file), "global");
|
|
88
|
-
if (agent) {
|
|
89
|
-
agents.set(agent.name, agent);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// Load project agents (overrides global)
|
|
94
|
-
const projectDir = getProjectAgentsDir(cwd);
|
|
95
|
-
if (existsSync(projectDir)) {
|
|
96
|
-
const files = readdirSync(projectDir).filter((f) => f.endsWith(".md"));
|
|
97
|
-
for (const file of files) {
|
|
98
|
-
const agent = loadAgentFromFile(join(projectDir, file), "project");
|
|
99
|
-
if (agent) {
|
|
100
|
-
agents.set(agent.name, agent);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return agents;
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=custom-agents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-agents.js","sourceRoot":"","sources":["../src/custom-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,kDAAkD;AAClD,SAAS,eAAe,CAAC,QAAgB;IACvC,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC,IAAI,CAAC;QACH,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;AACH,CAAC;AAED,oCAAoC;AACpC,SAAS,mBAAmB,CAAC,GAAW;IACtC,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,mCAAmC;AACnC,SAAS,kBAAkB;IACzB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAA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,CAAC;gBACV,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAED,yCAAyC;IACzC,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACvE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;YACnE,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/file-lock.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @pi-unipi/subagents — Per-file transparent locking
|
|
3
|
-
*
|
|
4
|
-
* Agents never see lock errors. Write tool queues internally.
|
|
5
|
-
* Per-file granularity: locking src/auth.ts doesn't block src/login.ts.
|
|
6
|
-
*/
|
|
7
|
-
export declare class FileLock {
|
|
8
|
-
/** Active locks by file path. */
|
|
9
|
-
private locks;
|
|
10
|
-
/** Queue of waiting acquires per file path. */
|
|
11
|
-
private queues;
|
|
12
|
-
/**
|
|
13
|
-
* Acquire a lock on a file. Blocks until available.
|
|
14
|
-
* Returns a release function.
|
|
15
|
-
*
|
|
16
|
-
* @param filePath - Absolute path to the file
|
|
17
|
-
* @param agentId - ID of the agent requesting the lock
|
|
18
|
-
* @returns Release function — call when done writing
|
|
19
|
-
*/
|
|
20
|
-
acquire(filePath: string, agentId: string): Promise<() => void>;
|
|
21
|
-
/**
|
|
22
|
-
* Check if a file is currently locked.
|
|
23
|
-
*/
|
|
24
|
-
isLocked(filePath: string): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Get the agent that holds a lock on a file.
|
|
27
|
-
*/
|
|
28
|
-
getHolder(filePath: string): string | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Get count of locked files.
|
|
31
|
-
*/
|
|
32
|
-
get lockCount(): number;
|
|
33
|
-
/**
|
|
34
|
-
* Release all locks held by an agent (on abort).
|
|
35
|
-
*/
|
|
36
|
-
releaseAll(agentId: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* Clear all locks (on shutdown).
|
|
39
|
-
*/
|
|
40
|
-
clear(): void;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=file-lock.d.ts.map
|
package/dist/file-lock.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-lock.d.ts","sourceRoot":"","sources":["../src/file-lock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,qBAAa,QAAQ;IACnB,iCAAiC;IACjC,OAAO,CAAC,KAAK,CAAoC;IACjD,+CAA+C;IAC/C,OAAO,CAAC,MAAM,CAAwC;IAEtD;;;;;;;OAOG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IAoCrE;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAInC;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI/C;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQjC;;OAEG;IACH,KAAK,IAAI,IAAI;CAOd"}
|
package/dist/file-lock.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @pi-unipi/subagents — Per-file transparent locking
|
|
3
|
-
*
|
|
4
|
-
* Agents never see lock errors. Write tool queues internally.
|
|
5
|
-
* Per-file granularity: locking src/auth.ts doesn't block src/login.ts.
|
|
6
|
-
*/
|
|
7
|
-
export class FileLock {
|
|
8
|
-
/** Active locks by file path. */
|
|
9
|
-
locks = new Map();
|
|
10
|
-
/** Queue of waiting acquires per file path. */
|
|
11
|
-
queues = new Map();
|
|
12
|
-
/**
|
|
13
|
-
* Acquire a lock on a file. Blocks until available.
|
|
14
|
-
* Returns a release function.
|
|
15
|
-
*
|
|
16
|
-
* @param filePath - Absolute path to the file
|
|
17
|
-
* @param agentId - ID of the agent requesting the lock
|
|
18
|
-
* @returns Release function — call when done writing
|
|
19
|
-
*/
|
|
20
|
-
async acquire(filePath, agentId) {
|
|
21
|
-
// Wait for existing lock
|
|
22
|
-
while (this.locks.has(filePath)) {
|
|
23
|
-
await new Promise((resolve) => {
|
|
24
|
-
const queue = this.queues.get(filePath) ?? [];
|
|
25
|
-
queue.push(resolve);
|
|
26
|
-
this.queues.set(filePath, queue);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
// Create lock entry
|
|
30
|
-
let releaseFn;
|
|
31
|
-
const promise = new Promise((resolve) => {
|
|
32
|
-
releaseFn = () => {
|
|
33
|
-
this.locks.delete(filePath);
|
|
34
|
-
resolve();
|
|
35
|
-
// Wake next waiter
|
|
36
|
-
const queue = this.queues.get(filePath);
|
|
37
|
-
if (queue && queue.length > 0) {
|
|
38
|
-
const next = queue.shift();
|
|
39
|
-
next();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
const entry = {
|
|
44
|
-
agentId,
|
|
45
|
-
filePath,
|
|
46
|
-
promise,
|
|
47
|
-
release: releaseFn,
|
|
48
|
-
};
|
|
49
|
-
this.locks.set(filePath, entry);
|
|
50
|
-
return releaseFn;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Check if a file is currently locked.
|
|
54
|
-
*/
|
|
55
|
-
isLocked(filePath) {
|
|
56
|
-
return this.locks.has(filePath);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Get the agent that holds a lock on a file.
|
|
60
|
-
*/
|
|
61
|
-
getHolder(filePath) {
|
|
62
|
-
return this.locks.get(filePath)?.agentId;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get count of locked files.
|
|
66
|
-
*/
|
|
67
|
-
get lockCount() {
|
|
68
|
-
return this.locks.size;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Release all locks held by an agent (on abort).
|
|
72
|
-
*/
|
|
73
|
-
releaseAll(agentId) {
|
|
74
|
-
for (const [filePath, entry] of this.locks) {
|
|
75
|
-
if (entry.agentId === agentId) {
|
|
76
|
-
entry.release();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Clear all locks (on shutdown).
|
|
82
|
-
*/
|
|
83
|
-
clear() {
|
|
84
|
-
for (const entry of this.locks.values()) {
|
|
85
|
-
entry.release();
|
|
86
|
-
}
|
|
87
|
-
this.locks.clear();
|
|
88
|
-
this.queues.clear();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=file-lock.js.map
|
package/dist/file-lock.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-lock.js","sourceRoot":"","sources":["../src/file-lock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,OAAO,QAAQ;IACnB,iCAAiC;IACzB,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IACjD,+CAA+C;IACvC,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAC;IAEtD;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,OAAe;QAC7C,y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;IAED;;OAEG;IACH,SAAS,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAe;QACxB,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3C,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC9B,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACxC,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @pi-unipi/subagents — Extension entry
|
|
3
|
-
*
|
|
4
|
-
* Tools: Agent, get_result
|
|
5
|
-
* ESC propagation: all children abort on parent ESC
|
|
6
|
-
*/
|
|
7
|
-
import { type ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
8
|
-
export default function (pi: ExtensionAPI): void;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,KAAK,YAAY,EAAyB,MAAM,+BAA+B,CAAC;AA2BrG,MAAM,CAAC,OAAO,WAAW,EAAE,EAAE,YAAY,QAwUxC"}
|