@agimon-ai/po-domain 0.0.0-alpha.39 → 0.0.0-alpha.40
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/apply.cjs +1 -1
- package/dist/apply.mjs +1 -1
- package/dist/extensions/server.cjs +1 -1
- package/dist/extensions/server.mjs +1 -1
- package/dist/{resourceCollector-CDnpAYEm.cjs → resourceCollector-BSlkw1wf.cjs} +4 -4
- package/dist/resourceCollector-BSlkw1wf.cjs.map +1 -0
- package/dist/{resourceCollector-DoXqQLuN.mjs → resourceCollector-Bg7rnLiv.mjs} +4 -4
- package/dist/resourceCollector-Bg7rnLiv.mjs.map +1 -0
- package/dist/resources.cjs +1 -1
- package/dist/resources.mjs +1 -1
- package/package.json +9 -9
- package/dist/resourceCollector-CDnpAYEm.cjs.map +0 -1
- package/dist/resourceCollector-DoXqQLuN.mjs.map +0 -1
package/dist/apply.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
3
3
|
const require_mcpFilter = require("./mcpFilter-CghXZ2K-.cjs");
|
|
4
4
|
const require_pluginMaterializer = require("./pluginMaterializer-C8IZ1PSY.cjs");
|
|
5
|
-
const require_resourceCollector = require("./resourceCollector-
|
|
5
|
+
const require_resourceCollector = require("./resourceCollector-BSlkw1wf.cjs");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
8
8
|
let node_path = require("node:path");
|
package/dist/apply.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as resolveMcpAllowlist } from "./mcpFilter-CKUbKmxz.mjs";
|
|
2
2
|
import { t as materializePluginEntries } from "./pluginMaterializer-D9-oDF-b.mjs";
|
|
3
|
-
import { t as collectResources } from "./resourceCollector-
|
|
3
|
+
import { t as collectResources } from "./resourceCollector-Bg7rnLiv.mjs";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { globalPoConfigDirectory } from "@agimon-ai/po-config/config";
|
|
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
|
|
|
4
4
|
});
|
|
5
5
|
const require_mcpFilter = require("../mcpFilter-CghXZ2K-.cjs");
|
|
6
6
|
const require_pluginMaterializer = require("../pluginMaterializer-C8IZ1PSY.cjs");
|
|
7
|
-
const require_resourceCollector = require("../resourceCollector-
|
|
7
|
+
const require_resourceCollector = require("../resourceCollector-BSlkw1wf.cjs");
|
|
8
8
|
const require_domainText = require("../domainText-CbpBLX_M.cjs");
|
|
9
9
|
let _agimon_ai_po_config_domains = require("@agimon-ai/po-config/domains");
|
|
10
10
|
let _agimon_ai_po_config_harnessStore = require("@agimon-ai/po-config/harnessStore");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as resolveMcpAllowlistAsync } from "../mcpFilter-CKUbKmxz.mjs";
|
|
2
2
|
import { t as materializePluginEntries } from "../pluginMaterializer-D9-oDF-b.mjs";
|
|
3
|
-
import { o as stageMcpResources } from "../resourceCollector-
|
|
3
|
+
import { o as stageMcpResources } from "../resourceCollector-Bg7rnLiv.mjs";
|
|
4
4
|
import { d as splitDomains, l as normalizeDomainNames, m as toggledDomains, p as toggleOptionDomain, s as domainToggleOptions, t as DOMAIN_COMMAND, u as pickerTitle } from "../domainText-D0iurn8D.mjs";
|
|
5
5
|
import { listDomainNamesAsync, resolvePluginEntriesAsync } from "@agimon-ai/po-config/domains";
|
|
6
6
|
import { loadHarnessStateAsync } from "@agimon-ai/po-config/harnessStore";
|
|
@@ -100,9 +100,9 @@ function splitFrontmatter(content) {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
const CLAUDE_MODEL_ALIASES = {
|
|
103
|
-
sonnet: "
|
|
104
|
-
opus: "
|
|
105
|
-
haiku: "
|
|
103
|
+
sonnet: "claude-sonnet-5-5",
|
|
104
|
+
opus: "claude-opus-4-6",
|
|
105
|
+
haiku: "claude-haiku-4-5"
|
|
106
106
|
};
|
|
107
107
|
function assertSafeAgentName(name) {
|
|
108
108
|
const trimmed = name.trim();
|
|
@@ -783,4 +783,4 @@ Object.defineProperty(exports, "stageMcpResources", {
|
|
|
783
783
|
}
|
|
784
784
|
});
|
|
785
785
|
|
|
786
|
-
//# sourceMappingURL=resourceCollector-
|
|
786
|
+
//# sourceMappingURL=resourceCollector-BSlkw1wf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceCollector-BSlkw1wf.cjs","names":["os","path","poHomeDirectory","fs","crypto","parse","toPiToolName","stringify","createHash","path","fs","stringify","normalizeAgentPluginMcpSource","globalPoConfigDirectory","pluginMcpSource","applyMcpAllowlist","PO_MCP_PROJECTION_VERSION","os"],"sources":["../src/services/skillCacheLocation/syncLabel.ts","../src/services/skillCacheLocation/index.ts","../src/services/resourceCollector/agentDefinition.ts","../src/services/resourceCollector/index.ts"],"sourcesContent":["const LABEL_MAX_LENGTH = 48;\n\n/** Keeps a repository or worktree name usable as one path segment. */\nexport function sanitizeSyncLabel(value: string, fallback: string): string {\n const normalized = value\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/gu, '')\n .replace(/[^A-Za-z0-9._-]+/gu, '-')\n .replace(/^[._-]+|[._-]+$/gu, '')\n .slice(0, LABEL_MAX_LENGTH)\n .replace(/[._-]+$/gu, '');\n return normalized === '' || normalized === '.' || normalized === '..' ? fallback : normalized;\n}\n","import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport { sanitizeSyncLabel } from './syncLabel';\n\nexport { sanitizeSyncLabel } from './syncLabel';\n\nconst SYNC_DIRECTORY = 'sync';\nconst WORKTREES_DIRECTORY = 'worktrees';\nconst SKILL_CACHE_SEGMENTS = ['cache', 'skills'];\nconst GIT_DIRECTORY = '.git';\nconst COMMON_DIRECTORY_FILE = 'commondir';\nconst IDENTITY_HEX_LENGTH = 32;\nconst DEFAULT_REPOSITORY_LABEL = 'repo';\nconst DEFAULT_WORKTREE_LABEL = 'worktree';\n\n/**\n * The home-scoped skill manifest cache for one worktree.\n *\n * This mirrors the namespace the Po launcher publishes into, so a session\n * that stages resources through the launcher and one that stages them through a\n * `/domains` switch hit the same manifests instead of rescanning every tree.\n * Two worktrees of one repository stay separate, and a checkout reached through\n * a symlink resolves to the same identity as the real path.\n */\nexport function resolveSkillCacheDirectory(repositoryRoot: string, homeDirectory: string = os.homedir()): string {\n const root = canonicalPath(repositoryRoot);\n const commonDirectory = gitCommonDirectory(root);\n const repositoryToken = commonDirectory ? `git:${commonDirectory}` : `root:${root}`;\n const repositoryId = identityHash(repositoryToken);\n const worktreeId = identityHash(`${repositoryToken}\\0worktree:${root}`);\n const repoLabel = repositoryLabel(commonDirectory, root);\n const worktreeLabel = sanitizeSyncLabel(path.basename(root), DEFAULT_WORKTREE_LABEL);\n return path.join(\n poHomeDirectory(path.resolve(homeDirectory)),\n SYNC_DIRECTORY,\n `${repoLabel}--${repositoryId}`,\n WORKTREES_DIRECTORY,\n `${worktreeLabel}--${worktreeId}`,\n ...SKILL_CACHE_SEGMENTS,\n );\n}\n\nfunction canonicalPath(target: string): string {\n const absolute = path.resolve(target);\n try {\n return fs.realpathSync.native(absolute);\n } catch {\n return absolute;\n }\n}\n\nfunction readGitDirectory(repositoryRoot: string): string | undefined {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n const stat = fs.statSync(gitPath);\n if (stat.isDirectory()) return canonicalPath(gitPath);\n if (!stat.isFile()) return undefined;\n const match = /^gitdir:\\s*(.+)$/imu.exec(fs.readFileSync(gitPath, 'utf8').trim());\n return match?.[1] ? canonicalPath(path.resolve(repositoryRoot, match[1].trim())) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction gitCommonDirectory(repositoryRoot: string): string | undefined {\n const gitDirectory = readGitDirectory(repositoryRoot);\n if (!gitDirectory) return undefined;\n try {\n const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), 'utf8').trim();\n return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;\n } catch {\n return gitDirectory;\n }\n}\n\nfunction identityHash(value: string): string {\n return crypto.createHash('sha256').update(value, 'utf8').digest('hex').slice(0, IDENTITY_HEX_LENGTH);\n}\n\nfunction repositoryLabel(commonDirectory: string | undefined, repositoryRoot: string): string {\n if (!commonDirectory) return sanitizeSyncLabel(path.basename(repositoryRoot), DEFAULT_REPOSITORY_LABEL);\n const base = path.basename(commonDirectory);\n const source = base === GIT_DIRECTORY ? path.basename(path.dirname(commonDirectory)) : base;\n return sanitizeSyncLabel(source, DEFAULT_REPOSITORY_LABEL);\n}\n","import { parse, stringify } from 'yaml';\n\nimport type { JsonObject } from '../../types/resources';\nimport { toPiToolName } from '../toolNames';\n\nexport const DISPATCHER_AGENT_NAME = 'agiflow-dispatcher';\n\nexport function splitFrontmatter(content: string): { attributes: JsonObject; body: string } {\n const match = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) throw new Error('Resource is missing YAML frontmatter');\n return { attributes: parse(match[1]!) as JsonObject, body: match[2] ?? '' };\n}\n\nconst CLAUDE_MODEL_ALIASES: Record<string, string> = {\n sonnet: 'claude-sonnet-5-5',\n opus: 'claude-opus-4-6',\n haiku: 'claude-haiku-4-5',\n};\n\nexport function assertSafeAgentName(name: string): string {\n const trimmed = name.trim();\n if (\n !trimmed ||\n trimmed !== name ||\n trimmed === '.' ||\n trimmed === '..' ||\n trimmed.includes('\\0') ||\n /[\\\\/]/.test(trimmed)\n ) {\n throw new Error(`Unsafe agent name: ${JSON.stringify(name)}`);\n }\n return trimmed;\n}\n\nfunction normalizeClaudeModel(value: unknown): unknown {\n if (typeof value === 'string') return CLAUDE_MODEL_ALIASES[value.toLowerCase()] ?? value;\n if (Array.isArray(value)) return value.map((entry) => normalizeClaudeModel(entry));\n return value;\n}\n\n/** Rewrites a Claude-authored agent definition into the form Pi loads. */\nexport function adaptAgentDefinition(content: string): { name: string; content: string } {\n const { attributes, body } = splitFrontmatter(content);\n const rawName = typeof attributes.name === 'string' ? attributes.name : undefined;\n if (!rawName) throw new Error('Agent definition requires a name');\n const name = assertSafeAgentName(rawName);\n const hasTools = Object.hasOwn(attributes, 'tools');\n const rawTools = Array.isArray(attributes.tools)\n ? attributes.tools.map(String)\n : typeof attributes.tools === 'string'\n ? attributes.tools\n .split(',')\n .map((tool) => tool.trim())\n .filter(Boolean)\n : [];\n const mappedTools = [...new Set(rawTools.map(toPiToolName).filter((tool): tool is string => Boolean(tool)))];\n const converted: JsonObject = {\n ...attributes,\n inheritProjectContext: true,\n inheritSkills: true,\n systemPromptMode: attributes.systemPromptMode ?? 'replace',\n };\n if (hasTools) converted.tools = Array.isArray(attributes.tools) ? mappedTools : mappedTools.join(', ');\n else delete converted.tools;\n if (converted.model !== undefined) converted.model = normalizeClaudeModel(converted.model);\n if (converted.fallbackModels !== undefined) converted.fallbackModels = normalizeClaudeModel(converted.fallbackModels);\n if (converted.memory === 'project' || converted.memory === 'user')\n converted.memory = { scope: converted.memory, path: name };\n else if (\n converted.memory !== undefined &&\n (typeof converted.memory !== 'object' || converted.memory === null || Array.isArray(converted.memory))\n )\n throw new Error('Unsupported memory declaration');\n delete converted.permissionMode;\n return { name, content: `---\\n${stringify(converted).trim()}\\n---\\n\\n${body.trimStart()}` };\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { normalizeAgentPluginMcpSource, pluginMcpSource } from '@agimon-ai/po-config/agentPluginMcp';\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport type { PluginEntry, PluginSkillDiscovery } from '@agimon-ai/po-config/domains';\nimport {\n PO_MCP_PROJECTION_VERSION,\n type PoMcpProjection,\n type PoMcpProjectionSource,\n} from '@agimon-ai/po-core/mcpProjection';\nimport { stringify } from 'yaml';\n\nimport type {\n HarnessResourceOptions,\n HarnessResources,\n JsonObject,\n McpResourceOptions,\n NamedResource,\n StagedMcpResources,\n} from '../../types/resources';\nimport { applyMcpAllowlist } from '../mcpFilter';\nimport { resolveSkillCacheDirectory } from '../skillCacheLocation';\nimport { adaptAgentDefinition, assertSafeAgentName, DISPATCHER_AGENT_NAME, splitFrontmatter } from './agentDefinition';\n\nexport { adaptAgentDefinition, DISPATCHER_AGENT_NAME } from './agentDefinition';\n\nconst DISPATCHER_TOOLS = ['read', 'grep', 'find', 'ls', 'bash', 'launch_workflow', 'list_workflows'];\nconst SKILL_MANIFEST_VERSION = 4;\nconst SKILL_MANIFEST_HASH_LENGTH = 16;\nconst PLUGIN_DATA_DIRECTORY = 'plugin-data';\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction canonicalJson(value: unknown): string {\n const normalize = (candidate: unknown): unknown => {\n if (Array.isArray(candidate)) return candidate.map(normalize);\n if (!isJsonObject(candidate)) return candidate;\n return Object.fromEntries(\n Object.entries(candidate)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, child]) => [key, normalize(child)]),\n );\n };\n return JSON.stringify(normalize(value));\n}\n\nfunction projectionFingerprint(input: Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>): string {\n return createHash('sha256').update(canonicalJson(input)).digest('hex');\n}\n\ninterface SkillManifestFile {\n path: string;\n name: string;\n description?: string;\n digest: string;\n size: number;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifestDirectory {\n path: string;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifest {\n version: number;\n root: string;\n discovery: PluginSkillDiscovery;\n files: SkillManifestFile[];\n directories: SkillManifestDirectory[];\n}\n\nfunction skillManifestPath(\n repoRoot: string,\n skillRoot: string,\n discovery: PluginSkillDiscovery,\n cacheDirectory?: string,\n): string {\n const key = createHash('sha256')\n .update(`${path.resolve(skillRoot)}\\0${discovery}`)\n .digest('hex')\n .slice(0, SKILL_MANIFEST_HASH_LENGTH);\n return path.join(cacheDirectory ?? resolveSkillCacheDirectory(repoRoot), `${key}.json`);\n}\n\nfunction fileMatches(previous: SkillManifestFile): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return (\n stat.isFile() &&\n stat.size === previous.size &&\n stat.mtimeMs === previous.mtimeMs &&\n stat.ctimeMs === previous.ctimeMs\n );\n } catch {\n return false;\n }\n}\n\nfunction directoryMatches(previous: SkillManifestDirectory): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return stat.isDirectory() && stat.mtimeMs === previous.mtimeMs && stat.ctimeMs === previous.ctimeMs;\n } catch {\n return false;\n }\n}\n\nfunction readSkillManifest(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): SkillManifest | undefined {\n try {\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories) ||\n !manifest.files.every(fileMatches) ||\n !manifest.directories.every(directoryMatches)\n ) {\n return undefined;\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nfunction writeSkillManifest(manifestPath: string, manifest: SkillManifest): void {\n fs.mkdirSync(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n fs.writeFileSync(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n fs.renameSync(temporary, manifestPath);\n } catch (error) {\n fs.rmSync(temporary, { force: true });\n if (!fs.existsSync(manifestPath)) throw error;\n }\n}\n\nasync function pathExists(target: string): Promise<boolean> {\n try {\n await fs.promises.access(target);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function readSkillManifestAsync(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): Promise<SkillManifest | undefined> {\n try {\n const manifest = JSON.parse(await fs.promises.readFile(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories)\n ) {\n return undefined;\n }\n for (const previous of manifest.files) {\n const stat = await fs.promises.stat(previous.path);\n if (\n !stat.isFile() ||\n stat.size !== previous.size ||\n stat.mtimeMs !== previous.mtimeMs ||\n stat.ctimeMs !== previous.ctimeMs\n ) {\n return undefined;\n }\n }\n for (const previous of manifest.directories) {\n const stat = await fs.promises.stat(previous.path);\n if (!stat.isDirectory() || stat.mtimeMs !== previous.mtimeMs || stat.ctimeMs !== previous.ctimeMs) {\n return undefined;\n }\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nasync function writeSkillManifestAsync(manifestPath: string, manifest: SkillManifest): Promise<void> {\n await fs.promises.mkdir(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n await fs.promises.writeFile(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n await fs.promises.rename(temporary, manifestPath);\n } catch (error) {\n await fs.promises.rm(temporary, { force: true });\n if (!(await pathExists(manifestPath))) throw error;\n }\n}\n\n/**\n * A directory entry resolved through any symlink, or undefined for a broken one.\n *\n * `readdir` reports symlinks with lstat semantics, so a symlinked skill\n * directory answers false to both `isDirectory()` and `isFile()` and would be\n * skipped by a naive branch. Pi stats through the link instead\n * (dist/core/skills.js:171-183) and treats a failing stat as a broken link to\n * skip, which is what keeps a shared skill published as a symlink visible.\n */\nfunction resolveEntryKind(entry: fs.Dirent, candidate: string): { directory: boolean; file: boolean } | undefined {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = fs.statSync(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\nasync function resolveEntryKindAsync(\n entry: fs.Dirent,\n candidate: string,\n): Promise<{ directory: boolean; file: boolean } | undefined> {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = await fs.promises.stat(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The skill's declared name, or the name of the directory holding it.\n *\n * Pi falls back to the containing directory rather than rejecting the file\n * (dist/core/skills.js:245). Rejecting is worse than one missing skill here:\n * this walk feeds the whole resource collection, so a single unnamed SKILL.md\n * from a third-party plugin would fail session launch outright rather than\n * degrade.\n */\nfunction skillName(filePath: string, attributes: JsonObject): string {\n const declared = typeof attributes.name === 'string' ? attributes.name.trim() : '';\n if (declared) return declared;\n const fallback = path.basename(path.dirname(filePath));\n if (!fallback) throw new Error(`Resource requires a name: ${filePath}`);\n return fallback;\n}\n\nfunction scanSkillManifest(root: string, discovery: PluginSkillDiscovery): SkillManifest {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n // Following symlinks makes a cycle reachable, and this walk records every\n // directory it visits, so an unguarded cycle would exhaust the stack and the\n // manifest together. Real paths are what a cycle repeats.\n const visited = new Set<string>();\n const walk = (directory: string, depth: number): void => {\n if (!fs.existsSync(directory)) return;\n const realDirectory = fs.realpathSync(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = fs.statSync(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {\n const candidate = path.join(directory, entry.name);\n const kind = resolveEntryKind(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = fs.readFileSync(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = fs.statSync(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\n/** Cached skill metadata and exact files, ready for Pi without a second tree walk. */\nexport function discoverSkills(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): NamedResource[] {\n if (!fs.existsSync(root)) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = readSkillManifest(manifestPath, root, discovery);\n const manifest = cached ?? scanSkillManifest(root, discovery);\n if (!cached) writeSkillManifest(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function scanSkillManifestAsync(root: string, discovery: PluginSkillDiscovery): Promise<SkillManifest> {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n const visited = new Set<string>();\n const walk = async (directory: string, depth: number): Promise<void> => {\n let entries: fs.Dirent[];\n try {\n const realDirectory = await fs.promises.realpath(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = await fs.promises.stat(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return;\n throw error;\n }\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n const kind = await resolveEntryKindAsync(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) await walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = await fs.promises.readFile(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = await fs.promises.stat(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n await walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\nexport async function discoverSkillsAsync(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): Promise<NamedResource[]> {\n if (!(await pathExists(root))) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = await readSkillManifestAsync(manifestPath, root, discovery);\n const manifest = cached ?? (await scanSkillManifestAsync(root, discovery));\n if (!cached) await writeSkillManifestAsync(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function markdownFilesAsync(directory: string): Promise<string[]> {\n let entries: fs.Dirent[];\n try {\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];\n throw error;\n }\n const results: string[] = [];\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n if (entry.isDirectory()) results.push(...(await markdownFilesAsync(candidate)));\n if (entry.isFile() && entry.name.endsWith('.md')) results.push(candidate);\n }\n return results;\n}\n\nasync function frontmatterNameAsync(filePath: string): Promise<string> {\n const { attributes } = splitFrontmatter(await fs.promises.readFile(filePath, 'utf8'));\n if (typeof attributes.name !== 'string') throw new Error(`Resource requires a name: ${filePath}`);\n return attributes.name;\n}\n\nasync function assertUniqueAsync(resources: NamedResource[], kind: string): Promise<void> {\n const seen = new Map<string, string>();\n const digestByName = new Map<string, string>();\n for (const resource of resources) {\n const previous = seen.get(resource.name);\n const digest =\n resource.digest ??\n createHash('sha256')\n .update(await fs.promises.readFile(resource.path))\n .digest('hex');\n if (previous && digestByName.get(resource.name) !== digest) {\n throw new Error(`Conflicting ${kind} \"${resource.name}\": ${previous} and ${resource.path}`);\n }\n seen.set(resource.name, resource.path);\n digestByName.set(resource.name, digest);\n }\n}\n\nfunction dispatcherAgentSource(): string {\n const attributes: JsonObject = {\n name: DISPATCHER_AGENT_NAME,\n description: 'Selects and launches Agiflow workflows for one loop pass without implementing the work.',\n thinking: 'high',\n systemPromptMode: 'replace',\n inheritProjectContext: true,\n inheritSkills: true,\n tools: DISPATCHER_TOOLS.join(', '),\n // No feature extension is named here. Team inherits the ordered child\n // composition projected from the selected layers for every helper process.\n defaultContext: 'fresh',\n defaultProgress: false,\n };\n const body = [\n 'You are the Agiflow workflow dispatcher.',\n 'Reason about the supplied dispatch context and launch eligible workflows.',\n 'Launch workflows without monitoring them. After dispatching, report and exit.',\n 'Follow the task restrictions exactly. Do not implement jobs or edit repository files.',\n ].join('\\n');\n return `---\\n${stringify(attributes).trim()}\\n---\\n\\n${body}\\n`;\n}\n\nexport function mergeMcpConfigs(configPaths: string[]): JsonObject {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n if (!fs.existsSync(configPath)) continue;\n const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nexport async function mergeMcpConfigsAsync(configPaths: string[]): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n let content: string;\n try {\n content = await fs.promises.readFile(configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n const config = JSON.parse(content) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nasync function mergeProjectedMcpConfigs(\n sources: readonly PoMcpProjectionSource[],\n stagingDirectory: string,\n): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const origins = new Map<string, string>();\n // The person's own entries are defaults: a repository or plugin entry with the same name replaces them.\n const userOwned = new Set<string>();\n\n for (const source of sources) {\n let config: JsonObject;\n if (source.format === 'agent-plugin-v1') {\n config = normalizeAgentPluginMcpSource(source, {\n stagingDirectory,\n // The generated file is consumed by external MCP clients. Keep wrapper\n // names there; Po strips its own in-process wrapper at runtime.\n stripProxyWrappers: false,\n }).claudeConfig;\n } else {\n let content: string;\n try {\n content = await fs.promises.readFile(source.configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n config = JSON.parse(content) as JsonObject;\n }\n\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && !userOwned.has(name) && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${origins.get(name)} and ${source.configPath}`);\n }\n servers[name] = definition;\n origins.set(name, source.configPath);\n if (source.owner === 'user') userOwned.add(name);\n else userOwned.delete(name);\n }\n }\n\n return merged;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Matches a resource name against a subset filter. Undefined keeps everything. */\nfunction keepsName(allowed: string[] | undefined, name: string): boolean {\n if (!allowed) return true;\n return allowed.some((pattern) =>\n pattern.includes('*')\n ? new RegExp(`^${pattern.split('*').map(escapeRegExp).join('.*')}$`).test(name)\n : pattern === name,\n );\n}\n\n/** Stages only the MCP slice shared by Po and compatibility frontends. */\nexport async function stageMcpResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: McpResourceOptions,\n): Promise<StagedMcpResources> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n const pluginMcpConfigPaths: string[] = [];\n const pluginMcpSources: PoMcpProjectionSource[] = [];\n const mcpSources: PoMcpProjectionSource[] = [];\n const pluginDataRoot = options.pluginDataRoot ?? path.join(globalPoConfigDirectory(), PLUGIN_DATA_DIRECTORY);\n const repositoryMcpPath = path.join(repoRoot, '.mcp.json');\n\n await fs.promises.mkdir(options.temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(options.temporaryDirectory, 0o700);\n // First, so every later layer overrides it.\n if (options.enabled && options.userMcpConfigPath && (await pathExists(options.userMcpConfigPath))) {\n const content = await fs.promises.readFile(options.userMcpConfigPath);\n mcpSources.push({\n sourceId: 'user:mcp.json',\n owner: 'user',\n format: 'native',\n configPath: options.userMcpConfigPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n if (options.enabled && (await pathExists(repositoryMcpPath))) {\n const content = await fs.promises.readFile(repositoryMcpPath);\n mcpSources.push({\n sourceId: 'repository:.mcp.json',\n owner: 'repository',\n format: 'native',\n configPath: repositoryMcpPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n\n if (options.enabled) {\n for (const entry of pluginEntries) {\n const source = await pluginMcpSource(entry, pluginDataRoot);\n if (!source) continue;\n mcpSources.push(source);\n pluginMcpSources.push(source);\n pluginMcpConfigPaths.push(source.configPath);\n }\n }\n\n let mcpConfigPath: string | undefined;\n if (options.enabled) {\n mcpConfigPath = path.join(options.temporaryDirectory, 'mcp.json');\n const merged = await applyMcpAllowlist(\n await mergeProjectedMcpConfigs(mcpSources, options.temporaryDirectory),\n options.mcpAllowlist,\n repoRoot,\n options.temporaryDirectory,\n );\n await fs.promises.writeFile(mcpConfigPath, `${JSON.stringify(merged, null, 2)}\\n`, { mode: 0o600 });\n }\n\n const projectionWithoutRuntimePath = {\n version: PO_MCP_PROJECTION_VERSION,\n enabled: options.enabled,\n repoRoot,\n ...(mcpConfigPath ? { generatedConfigPath: mcpConfigPath } : {}),\n sources: options.enabled ? mcpSources : [],\n ...(options.mcpAllowlist ? { allowlist: structuredClone(options.mcpAllowlist) } : {}),\n } satisfies Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>;\n\n return {\n mcpConfigPath,\n mcpProjection: {\n ...projectionWithoutRuntimePath,\n stagingDirectory: options.temporaryDirectory,\n fingerprint: projectionFingerprint(projectionWithoutRuntimePath),\n },\n pluginMcpSources,\n pluginMcpConfigPaths,\n };\n}\n\n/**\n * Stages every resource the selected domains contribute, ready for one Pi session.\n *\n * The caller owns the returned cleanup(): the temporary directory holding agents\n * and the generated MCP config has to outlive this function and be removed once\n * the session that reads it is done.\n */\nexport async function collectResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: HarnessResourceOptions,\n): Promise<HarnessResources & { skillSources: NamedResource[] }> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n // A caller-supplied directory is owned by the caller: it is either a live\n // session's directory or the synced one, and removing it here would delete\n // resources that outlive this collection.\n const ownsDirectory = options.temporaryDirectory === undefined;\n const temporaryDirectory = options.temporaryDirectory ?? (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'po-')));\n await fs.promises.mkdir(temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(temporaryDirectory, 0o700);\n const sharedSkills = path.join(repoRoot, '.claude', 'skills');\n // A domain can opt out of the always-on shared skills to keep its context small.\n const sharedSkillSources =\n options.sharedSkills === false\n ? []\n : await discoverSkillsAsync(repoRoot, sharedSkills, 'recursive', options.skillCacheDirectory);\n const skillDirectories: string[] = [];\n const skillSources: NamedResource[] = [];\n const agentSources: Array<{ name: string; path: string }> = [];\n\n for (const entry of pluginEntries) {\n const pluginDirectory = entry.directory;\n const skills = path.join(pluginDirectory, 'skills');\n if (await pathExists(skills)) {\n const found = (\n await discoverSkillsAsync(repoRoot, skills, entry.skillDiscovery ?? 'recursive', options.skillCacheDirectory)\n ).filter((skill) => keepsName(entry.skills, skill.name));\n // Exact files let Pi skip another recursive traversal and make a plugin\n // subset unambiguous without staging copies of the skill bodies.\n skillDirectories.push(...found.map((skill) => skill.path));\n skillSources.push(...found);\n }\n const agents = path.join(pluginDirectory, 'agents');\n const agentFiles = await markdownFilesAsync(agents);\n const agentNames = await Promise.all(agentFiles.map((filePath) => frontmatterNameAsync(filePath)));\n agentSources.push(\n ...agentFiles\n .map((filePath, index) => ({ name: agentNames[index] ?? '', path: filePath }))\n .filter((agent) => keepsName(entry.agents, agent.name)),\n );\n }\n\n await assertUniqueAsync(skillSources, 'skill');\n await assertUniqueAsync(sharedSkillSources, 'skill');\n // Pi keeps the first skill for a duplicated name. Selected domain plugins are\n // authoritative; shared Claude skills remain fallbacks for names no plugin owns.\n const pluginSkillNames = new Set(skillSources.map((skill) => skill.name));\n const fallbackSharedSkills = sharedSkillSources.filter((skill) => !pluginSkillNames.has(skill.name));\n skillDirectories.push(...fallbackSharedSkills.map((skill) => skill.path));\n skillSources.push(...fallbackSharedSkills);\n\n await assertUniqueAsync(agentSources, 'agent');\n if (agentSources.some((source) => source.name === DISPATCHER_AGENT_NAME)) {\n throw new Error(`Conflicting agent \"${DISPATCHER_AGENT_NAME}\": reserved by the agent harness`);\n }\n\n const agentDirectories: string[] = [];\n const outputDirectory = path.join(temporaryDirectory, 'agents');\n await fs.promises.rm(outputDirectory, { recursive: true, force: true });\n if (options.agents) {\n await fs.promises.mkdir(outputDirectory, { mode: 0o700 });\n for (const source of agentSources) {\n const adapted = adaptAgentDefinition(await fs.promises.readFile(source.path, 'utf8'));\n await fs.promises.writeFile(\n path.join(outputDirectory, `${assertSafeAgentName(adapted.name)}.md`),\n adapted.content,\n { mode: 0o600 },\n );\n }\n await fs.promises.writeFile(path.join(outputDirectory, `${DISPATCHER_AGENT_NAME}.md`), dispatcherAgentSource(), {\n mode: 0o600,\n });\n agentDirectories.push(outputDirectory);\n }\n\n const { mcpConfigPath, mcpProjection, pluginMcpSources, pluginMcpConfigPaths } = await stageMcpResources(\n repoRoot,\n pluginEntries,\n {\n enabled: options.mcp,\n temporaryDirectory,\n ...(options.mcpAllowlist ? { mcpAllowlist: options.mcpAllowlist } : {}),\n ...(options.pluginDataRoot ? { pluginDataRoot: options.pluginDataRoot } : {}),\n ...(options.userMcpConfigPath ? { userMcpConfigPath: options.userMcpConfigPath } : {}),\n },\n );\n\n return {\n temporaryDirectory,\n skillDirectories,\n skillSources,\n skillCount: skillSources.length,\n agentCount: agentSources.length,\n agentDirectories,\n mcpConfigPath,\n mcpProjection,\n pluginMcpSources,\n pluginMcpConfigPaths,\n cleanup: () =>\n ownsDirectory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CAEA,MAAM,EAAE,eAAe,eAAe,kBAAkB,yBAAyB,MAAM,kBACrF,UACA,eACA;EACE,SAAS,QAAQ;EACjB;EACA,GAAI,QAAQ,eAAe,EAAE,cAAc,QAAQ,aAAa,IAAI,CAAC;EACrE,GAAI,QAAQ,iBAAiB,EAAE,gBAAgB,QAAQ,eAAe,IAAI,CAAC;EAC3E,GAAI,QAAQ,oBAAoB,EAAE,mBAAmB,QAAQ,kBAAkB,IAAI,CAAC;CACtF,CACF;CAEA,OAAO;EACL;EACA;EACA;EACA,YAAY,aAAa;EACzB,YAAY,aAAa;EACzB;EACA;EACA;EACA;EACA;EACA,eACE,gBAAgBC,QAAAA,QAAG,SAAS,GAAG,oBAAoB;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC,IAAI,QAAQ,QAAQ;CAC3G;AACF"}
|
|
@@ -95,9 +95,9 @@ function splitFrontmatter(content) {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
const CLAUDE_MODEL_ALIASES = {
|
|
98
|
-
sonnet: "
|
|
99
|
-
opus: "
|
|
100
|
-
haiku: "
|
|
98
|
+
sonnet: "claude-sonnet-5-5",
|
|
99
|
+
opus: "claude-opus-4-6",
|
|
100
|
+
haiku: "claude-haiku-4-5"
|
|
101
101
|
};
|
|
102
102
|
function assertSafeAgentName(name) {
|
|
103
103
|
const trimmed = name.trim();
|
|
@@ -719,4 +719,4 @@ async function collectResources(repoRoot, plugins, options) {
|
|
|
719
719
|
//#endregion
|
|
720
720
|
export { mergeMcpConfigsAsync as a, adaptAgentDefinition as c, mergeMcpConfigs as i, resolveSkillCacheDirectory as l, discoverSkills as n, stageMcpResources as o, discoverSkillsAsync as r, DISPATCHER_AGENT_NAME as s, collectResources as t, sanitizeSyncLabel as u };
|
|
721
721
|
|
|
722
|
-
//# sourceMappingURL=resourceCollector-
|
|
722
|
+
//# sourceMappingURL=resourceCollector-Bg7rnLiv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceCollector-Bg7rnLiv.mjs","names":[],"sources":["../src/services/skillCacheLocation/syncLabel.ts","../src/services/skillCacheLocation/index.ts","../src/services/resourceCollector/agentDefinition.ts","../src/services/resourceCollector/index.ts"],"sourcesContent":["const LABEL_MAX_LENGTH = 48;\n\n/** Keeps a repository or worktree name usable as one path segment. */\nexport function sanitizeSyncLabel(value: string, fallback: string): string {\n const normalized = value\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/gu, '')\n .replace(/[^A-Za-z0-9._-]+/gu, '-')\n .replace(/^[._-]+|[._-]+$/gu, '')\n .slice(0, LABEL_MAX_LENGTH)\n .replace(/[._-]+$/gu, '');\n return normalized === '' || normalized === '.' || normalized === '..' ? fallback : normalized;\n}\n","import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport { sanitizeSyncLabel } from './syncLabel';\n\nexport { sanitizeSyncLabel } from './syncLabel';\n\nconst SYNC_DIRECTORY = 'sync';\nconst WORKTREES_DIRECTORY = 'worktrees';\nconst SKILL_CACHE_SEGMENTS = ['cache', 'skills'];\nconst GIT_DIRECTORY = '.git';\nconst COMMON_DIRECTORY_FILE = 'commondir';\nconst IDENTITY_HEX_LENGTH = 32;\nconst DEFAULT_REPOSITORY_LABEL = 'repo';\nconst DEFAULT_WORKTREE_LABEL = 'worktree';\n\n/**\n * The home-scoped skill manifest cache for one worktree.\n *\n * This mirrors the namespace the Po launcher publishes into, so a session\n * that stages resources through the launcher and one that stages them through a\n * `/domains` switch hit the same manifests instead of rescanning every tree.\n * Two worktrees of one repository stay separate, and a checkout reached through\n * a symlink resolves to the same identity as the real path.\n */\nexport function resolveSkillCacheDirectory(repositoryRoot: string, homeDirectory: string = os.homedir()): string {\n const root = canonicalPath(repositoryRoot);\n const commonDirectory = gitCommonDirectory(root);\n const repositoryToken = commonDirectory ? `git:${commonDirectory}` : `root:${root}`;\n const repositoryId = identityHash(repositoryToken);\n const worktreeId = identityHash(`${repositoryToken}\\0worktree:${root}`);\n const repoLabel = repositoryLabel(commonDirectory, root);\n const worktreeLabel = sanitizeSyncLabel(path.basename(root), DEFAULT_WORKTREE_LABEL);\n return path.join(\n poHomeDirectory(path.resolve(homeDirectory)),\n SYNC_DIRECTORY,\n `${repoLabel}--${repositoryId}`,\n WORKTREES_DIRECTORY,\n `${worktreeLabel}--${worktreeId}`,\n ...SKILL_CACHE_SEGMENTS,\n );\n}\n\nfunction canonicalPath(target: string): string {\n const absolute = path.resolve(target);\n try {\n return fs.realpathSync.native(absolute);\n } catch {\n return absolute;\n }\n}\n\nfunction readGitDirectory(repositoryRoot: string): string | undefined {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n const stat = fs.statSync(gitPath);\n if (stat.isDirectory()) return canonicalPath(gitPath);\n if (!stat.isFile()) return undefined;\n const match = /^gitdir:\\s*(.+)$/imu.exec(fs.readFileSync(gitPath, 'utf8').trim());\n return match?.[1] ? canonicalPath(path.resolve(repositoryRoot, match[1].trim())) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction gitCommonDirectory(repositoryRoot: string): string | undefined {\n const gitDirectory = readGitDirectory(repositoryRoot);\n if (!gitDirectory) return undefined;\n try {\n const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), 'utf8').trim();\n return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;\n } catch {\n return gitDirectory;\n }\n}\n\nfunction identityHash(value: string): string {\n return crypto.createHash('sha256').update(value, 'utf8').digest('hex').slice(0, IDENTITY_HEX_LENGTH);\n}\n\nfunction repositoryLabel(commonDirectory: string | undefined, repositoryRoot: string): string {\n if (!commonDirectory) return sanitizeSyncLabel(path.basename(repositoryRoot), DEFAULT_REPOSITORY_LABEL);\n const base = path.basename(commonDirectory);\n const source = base === GIT_DIRECTORY ? path.basename(path.dirname(commonDirectory)) : base;\n return sanitizeSyncLabel(source, DEFAULT_REPOSITORY_LABEL);\n}\n","import { parse, stringify } from 'yaml';\n\nimport type { JsonObject } from '../../types/resources';\nimport { toPiToolName } from '../toolNames';\n\nexport const DISPATCHER_AGENT_NAME = 'agiflow-dispatcher';\n\nexport function splitFrontmatter(content: string): { attributes: JsonObject; body: string } {\n const match = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) throw new Error('Resource is missing YAML frontmatter');\n return { attributes: parse(match[1]!) as JsonObject, body: match[2] ?? '' };\n}\n\nconst CLAUDE_MODEL_ALIASES: Record<string, string> = {\n sonnet: 'claude-sonnet-5-5',\n opus: 'claude-opus-4-6',\n haiku: 'claude-haiku-4-5',\n};\n\nexport function assertSafeAgentName(name: string): string {\n const trimmed = name.trim();\n if (\n !trimmed ||\n trimmed !== name ||\n trimmed === '.' ||\n trimmed === '..' ||\n trimmed.includes('\\0') ||\n /[\\\\/]/.test(trimmed)\n ) {\n throw new Error(`Unsafe agent name: ${JSON.stringify(name)}`);\n }\n return trimmed;\n}\n\nfunction normalizeClaudeModel(value: unknown): unknown {\n if (typeof value === 'string') return CLAUDE_MODEL_ALIASES[value.toLowerCase()] ?? value;\n if (Array.isArray(value)) return value.map((entry) => normalizeClaudeModel(entry));\n return value;\n}\n\n/** Rewrites a Claude-authored agent definition into the form Pi loads. */\nexport function adaptAgentDefinition(content: string): { name: string; content: string } {\n const { attributes, body } = splitFrontmatter(content);\n const rawName = typeof attributes.name === 'string' ? attributes.name : undefined;\n if (!rawName) throw new Error('Agent definition requires a name');\n const name = assertSafeAgentName(rawName);\n const hasTools = Object.hasOwn(attributes, 'tools');\n const rawTools = Array.isArray(attributes.tools)\n ? attributes.tools.map(String)\n : typeof attributes.tools === 'string'\n ? attributes.tools\n .split(',')\n .map((tool) => tool.trim())\n .filter(Boolean)\n : [];\n const mappedTools = [...new Set(rawTools.map(toPiToolName).filter((tool): tool is string => Boolean(tool)))];\n const converted: JsonObject = {\n ...attributes,\n inheritProjectContext: true,\n inheritSkills: true,\n systemPromptMode: attributes.systemPromptMode ?? 'replace',\n };\n if (hasTools) converted.tools = Array.isArray(attributes.tools) ? mappedTools : mappedTools.join(', ');\n else delete converted.tools;\n if (converted.model !== undefined) converted.model = normalizeClaudeModel(converted.model);\n if (converted.fallbackModels !== undefined) converted.fallbackModels = normalizeClaudeModel(converted.fallbackModels);\n if (converted.memory === 'project' || converted.memory === 'user')\n converted.memory = { scope: converted.memory, path: name };\n else if (\n converted.memory !== undefined &&\n (typeof converted.memory !== 'object' || converted.memory === null || Array.isArray(converted.memory))\n )\n throw new Error('Unsupported memory declaration');\n delete converted.permissionMode;\n return { name, content: `---\\n${stringify(converted).trim()}\\n---\\n\\n${body.trimStart()}` };\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { normalizeAgentPluginMcpSource, pluginMcpSource } from '@agimon-ai/po-config/agentPluginMcp';\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport type { PluginEntry, PluginSkillDiscovery } from '@agimon-ai/po-config/domains';\nimport {\n PO_MCP_PROJECTION_VERSION,\n type PoMcpProjection,\n type PoMcpProjectionSource,\n} from '@agimon-ai/po-core/mcpProjection';\nimport { stringify } from 'yaml';\n\nimport type {\n HarnessResourceOptions,\n HarnessResources,\n JsonObject,\n McpResourceOptions,\n NamedResource,\n StagedMcpResources,\n} from '../../types/resources';\nimport { applyMcpAllowlist } from '../mcpFilter';\nimport { resolveSkillCacheDirectory } from '../skillCacheLocation';\nimport { adaptAgentDefinition, assertSafeAgentName, DISPATCHER_AGENT_NAME, splitFrontmatter } from './agentDefinition';\n\nexport { adaptAgentDefinition, DISPATCHER_AGENT_NAME } from './agentDefinition';\n\nconst DISPATCHER_TOOLS = ['read', 'grep', 'find', 'ls', 'bash', 'launch_workflow', 'list_workflows'];\nconst SKILL_MANIFEST_VERSION = 4;\nconst SKILL_MANIFEST_HASH_LENGTH = 16;\nconst PLUGIN_DATA_DIRECTORY = 'plugin-data';\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction canonicalJson(value: unknown): string {\n const normalize = (candidate: unknown): unknown => {\n if (Array.isArray(candidate)) return candidate.map(normalize);\n if (!isJsonObject(candidate)) return candidate;\n return Object.fromEntries(\n Object.entries(candidate)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, child]) => [key, normalize(child)]),\n );\n };\n return JSON.stringify(normalize(value));\n}\n\nfunction projectionFingerprint(input: Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>): string {\n return createHash('sha256').update(canonicalJson(input)).digest('hex');\n}\n\ninterface SkillManifestFile {\n path: string;\n name: string;\n description?: string;\n digest: string;\n size: number;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifestDirectory {\n path: string;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifest {\n version: number;\n root: string;\n discovery: PluginSkillDiscovery;\n files: SkillManifestFile[];\n directories: SkillManifestDirectory[];\n}\n\nfunction skillManifestPath(\n repoRoot: string,\n skillRoot: string,\n discovery: PluginSkillDiscovery,\n cacheDirectory?: string,\n): string {\n const key = createHash('sha256')\n .update(`${path.resolve(skillRoot)}\\0${discovery}`)\n .digest('hex')\n .slice(0, SKILL_MANIFEST_HASH_LENGTH);\n return path.join(cacheDirectory ?? resolveSkillCacheDirectory(repoRoot), `${key}.json`);\n}\n\nfunction fileMatches(previous: SkillManifestFile): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return (\n stat.isFile() &&\n stat.size === previous.size &&\n stat.mtimeMs === previous.mtimeMs &&\n stat.ctimeMs === previous.ctimeMs\n );\n } catch {\n return false;\n }\n}\n\nfunction directoryMatches(previous: SkillManifestDirectory): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return stat.isDirectory() && stat.mtimeMs === previous.mtimeMs && stat.ctimeMs === previous.ctimeMs;\n } catch {\n return false;\n }\n}\n\nfunction readSkillManifest(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): SkillManifest | undefined {\n try {\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories) ||\n !manifest.files.every(fileMatches) ||\n !manifest.directories.every(directoryMatches)\n ) {\n return undefined;\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nfunction writeSkillManifest(manifestPath: string, manifest: SkillManifest): void {\n fs.mkdirSync(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n fs.writeFileSync(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n fs.renameSync(temporary, manifestPath);\n } catch (error) {\n fs.rmSync(temporary, { force: true });\n if (!fs.existsSync(manifestPath)) throw error;\n }\n}\n\nasync function pathExists(target: string): Promise<boolean> {\n try {\n await fs.promises.access(target);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function readSkillManifestAsync(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): Promise<SkillManifest | undefined> {\n try {\n const manifest = JSON.parse(await fs.promises.readFile(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories)\n ) {\n return undefined;\n }\n for (const previous of manifest.files) {\n const stat = await fs.promises.stat(previous.path);\n if (\n !stat.isFile() ||\n stat.size !== previous.size ||\n stat.mtimeMs !== previous.mtimeMs ||\n stat.ctimeMs !== previous.ctimeMs\n ) {\n return undefined;\n }\n }\n for (const previous of manifest.directories) {\n const stat = await fs.promises.stat(previous.path);\n if (!stat.isDirectory() || stat.mtimeMs !== previous.mtimeMs || stat.ctimeMs !== previous.ctimeMs) {\n return undefined;\n }\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nasync function writeSkillManifestAsync(manifestPath: string, manifest: SkillManifest): Promise<void> {\n await fs.promises.mkdir(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n await fs.promises.writeFile(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n await fs.promises.rename(temporary, manifestPath);\n } catch (error) {\n await fs.promises.rm(temporary, { force: true });\n if (!(await pathExists(manifestPath))) throw error;\n }\n}\n\n/**\n * A directory entry resolved through any symlink, or undefined for a broken one.\n *\n * `readdir` reports symlinks with lstat semantics, so a symlinked skill\n * directory answers false to both `isDirectory()` and `isFile()` and would be\n * skipped by a naive branch. Pi stats through the link instead\n * (dist/core/skills.js:171-183) and treats a failing stat as a broken link to\n * skip, which is what keeps a shared skill published as a symlink visible.\n */\nfunction resolveEntryKind(entry: fs.Dirent, candidate: string): { directory: boolean; file: boolean } | undefined {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = fs.statSync(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\nasync function resolveEntryKindAsync(\n entry: fs.Dirent,\n candidate: string,\n): Promise<{ directory: boolean; file: boolean } | undefined> {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = await fs.promises.stat(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The skill's declared name, or the name of the directory holding it.\n *\n * Pi falls back to the containing directory rather than rejecting the file\n * (dist/core/skills.js:245). Rejecting is worse than one missing skill here:\n * this walk feeds the whole resource collection, so a single unnamed SKILL.md\n * from a third-party plugin would fail session launch outright rather than\n * degrade.\n */\nfunction skillName(filePath: string, attributes: JsonObject): string {\n const declared = typeof attributes.name === 'string' ? attributes.name.trim() : '';\n if (declared) return declared;\n const fallback = path.basename(path.dirname(filePath));\n if (!fallback) throw new Error(`Resource requires a name: ${filePath}`);\n return fallback;\n}\n\nfunction scanSkillManifest(root: string, discovery: PluginSkillDiscovery): SkillManifest {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n // Following symlinks makes a cycle reachable, and this walk records every\n // directory it visits, so an unguarded cycle would exhaust the stack and the\n // manifest together. Real paths are what a cycle repeats.\n const visited = new Set<string>();\n const walk = (directory: string, depth: number): void => {\n if (!fs.existsSync(directory)) return;\n const realDirectory = fs.realpathSync(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = fs.statSync(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {\n const candidate = path.join(directory, entry.name);\n const kind = resolveEntryKind(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = fs.readFileSync(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = fs.statSync(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\n/** Cached skill metadata and exact files, ready for Pi without a second tree walk. */\nexport function discoverSkills(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): NamedResource[] {\n if (!fs.existsSync(root)) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = readSkillManifest(manifestPath, root, discovery);\n const manifest = cached ?? scanSkillManifest(root, discovery);\n if (!cached) writeSkillManifest(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function scanSkillManifestAsync(root: string, discovery: PluginSkillDiscovery): Promise<SkillManifest> {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n const visited = new Set<string>();\n const walk = async (directory: string, depth: number): Promise<void> => {\n let entries: fs.Dirent[];\n try {\n const realDirectory = await fs.promises.realpath(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = await fs.promises.stat(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return;\n throw error;\n }\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n const kind = await resolveEntryKindAsync(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) await walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = await fs.promises.readFile(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = await fs.promises.stat(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n await walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\nexport async function discoverSkillsAsync(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): Promise<NamedResource[]> {\n if (!(await pathExists(root))) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = await readSkillManifestAsync(manifestPath, root, discovery);\n const manifest = cached ?? (await scanSkillManifestAsync(root, discovery));\n if (!cached) await writeSkillManifestAsync(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function markdownFilesAsync(directory: string): Promise<string[]> {\n let entries: fs.Dirent[];\n try {\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];\n throw error;\n }\n const results: string[] = [];\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n if (entry.isDirectory()) results.push(...(await markdownFilesAsync(candidate)));\n if (entry.isFile() && entry.name.endsWith('.md')) results.push(candidate);\n }\n return results;\n}\n\nasync function frontmatterNameAsync(filePath: string): Promise<string> {\n const { attributes } = splitFrontmatter(await fs.promises.readFile(filePath, 'utf8'));\n if (typeof attributes.name !== 'string') throw new Error(`Resource requires a name: ${filePath}`);\n return attributes.name;\n}\n\nasync function assertUniqueAsync(resources: NamedResource[], kind: string): Promise<void> {\n const seen = new Map<string, string>();\n const digestByName = new Map<string, string>();\n for (const resource of resources) {\n const previous = seen.get(resource.name);\n const digest =\n resource.digest ??\n createHash('sha256')\n .update(await fs.promises.readFile(resource.path))\n .digest('hex');\n if (previous && digestByName.get(resource.name) !== digest) {\n throw new Error(`Conflicting ${kind} \"${resource.name}\": ${previous} and ${resource.path}`);\n }\n seen.set(resource.name, resource.path);\n digestByName.set(resource.name, digest);\n }\n}\n\nfunction dispatcherAgentSource(): string {\n const attributes: JsonObject = {\n name: DISPATCHER_AGENT_NAME,\n description: 'Selects and launches Agiflow workflows for one loop pass without implementing the work.',\n thinking: 'high',\n systemPromptMode: 'replace',\n inheritProjectContext: true,\n inheritSkills: true,\n tools: DISPATCHER_TOOLS.join(', '),\n // No feature extension is named here. Team inherits the ordered child\n // composition projected from the selected layers for every helper process.\n defaultContext: 'fresh',\n defaultProgress: false,\n };\n const body = [\n 'You are the Agiflow workflow dispatcher.',\n 'Reason about the supplied dispatch context and launch eligible workflows.',\n 'Launch workflows without monitoring them. After dispatching, report and exit.',\n 'Follow the task restrictions exactly. Do not implement jobs or edit repository files.',\n ].join('\\n');\n return `---\\n${stringify(attributes).trim()}\\n---\\n\\n${body}\\n`;\n}\n\nexport function mergeMcpConfigs(configPaths: string[]): JsonObject {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n if (!fs.existsSync(configPath)) continue;\n const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nexport async function mergeMcpConfigsAsync(configPaths: string[]): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n let content: string;\n try {\n content = await fs.promises.readFile(configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n const config = JSON.parse(content) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nasync function mergeProjectedMcpConfigs(\n sources: readonly PoMcpProjectionSource[],\n stagingDirectory: string,\n): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const origins = new Map<string, string>();\n // The person's own entries are defaults: a repository or plugin entry with the same name replaces them.\n const userOwned = new Set<string>();\n\n for (const source of sources) {\n let config: JsonObject;\n if (source.format === 'agent-plugin-v1') {\n config = normalizeAgentPluginMcpSource(source, {\n stagingDirectory,\n // The generated file is consumed by external MCP clients. Keep wrapper\n // names there; Po strips its own in-process wrapper at runtime.\n stripProxyWrappers: false,\n }).claudeConfig;\n } else {\n let content: string;\n try {\n content = await fs.promises.readFile(source.configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n config = JSON.parse(content) as JsonObject;\n }\n\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && !userOwned.has(name) && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${origins.get(name)} and ${source.configPath}`);\n }\n servers[name] = definition;\n origins.set(name, source.configPath);\n if (source.owner === 'user') userOwned.add(name);\n else userOwned.delete(name);\n }\n }\n\n return merged;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Matches a resource name against a subset filter. Undefined keeps everything. */\nfunction keepsName(allowed: string[] | undefined, name: string): boolean {\n if (!allowed) return true;\n return allowed.some((pattern) =>\n pattern.includes('*')\n ? new RegExp(`^${pattern.split('*').map(escapeRegExp).join('.*')}$`).test(name)\n : pattern === name,\n );\n}\n\n/** Stages only the MCP slice shared by Po and compatibility frontends. */\nexport async function stageMcpResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: McpResourceOptions,\n): Promise<StagedMcpResources> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n const pluginMcpConfigPaths: string[] = [];\n const pluginMcpSources: PoMcpProjectionSource[] = [];\n const mcpSources: PoMcpProjectionSource[] = [];\n const pluginDataRoot = options.pluginDataRoot ?? path.join(globalPoConfigDirectory(), PLUGIN_DATA_DIRECTORY);\n const repositoryMcpPath = path.join(repoRoot, '.mcp.json');\n\n await fs.promises.mkdir(options.temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(options.temporaryDirectory, 0o700);\n // First, so every later layer overrides it.\n if (options.enabled && options.userMcpConfigPath && (await pathExists(options.userMcpConfigPath))) {\n const content = await fs.promises.readFile(options.userMcpConfigPath);\n mcpSources.push({\n sourceId: 'user:mcp.json',\n owner: 'user',\n format: 'native',\n configPath: options.userMcpConfigPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n if (options.enabled && (await pathExists(repositoryMcpPath))) {\n const content = await fs.promises.readFile(repositoryMcpPath);\n mcpSources.push({\n sourceId: 'repository:.mcp.json',\n owner: 'repository',\n format: 'native',\n configPath: repositoryMcpPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n\n if (options.enabled) {\n for (const entry of pluginEntries) {\n const source = await pluginMcpSource(entry, pluginDataRoot);\n if (!source) continue;\n mcpSources.push(source);\n pluginMcpSources.push(source);\n pluginMcpConfigPaths.push(source.configPath);\n }\n }\n\n let mcpConfigPath: string | undefined;\n if (options.enabled) {\n mcpConfigPath = path.join(options.temporaryDirectory, 'mcp.json');\n const merged = await applyMcpAllowlist(\n await mergeProjectedMcpConfigs(mcpSources, options.temporaryDirectory),\n options.mcpAllowlist,\n repoRoot,\n options.temporaryDirectory,\n );\n await fs.promises.writeFile(mcpConfigPath, `${JSON.stringify(merged, null, 2)}\\n`, { mode: 0o600 });\n }\n\n const projectionWithoutRuntimePath = {\n version: PO_MCP_PROJECTION_VERSION,\n enabled: options.enabled,\n repoRoot,\n ...(mcpConfigPath ? { generatedConfigPath: mcpConfigPath } : {}),\n sources: options.enabled ? mcpSources : [],\n ...(options.mcpAllowlist ? { allowlist: structuredClone(options.mcpAllowlist) } : {}),\n } satisfies Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>;\n\n return {\n mcpConfigPath,\n mcpProjection: {\n ...projectionWithoutRuntimePath,\n stagingDirectory: options.temporaryDirectory,\n fingerprint: projectionFingerprint(projectionWithoutRuntimePath),\n },\n pluginMcpSources,\n pluginMcpConfigPaths,\n };\n}\n\n/**\n * Stages every resource the selected domains contribute, ready for one Pi session.\n *\n * The caller owns the returned cleanup(): the temporary directory holding agents\n * and the generated MCP config has to outlive this function and be removed once\n * the session that reads it is done.\n */\nexport async function collectResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: HarnessResourceOptions,\n): Promise<HarnessResources & { skillSources: NamedResource[] }> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n // A caller-supplied directory is owned by the caller: it is either a live\n // session's directory or the synced one, and removing it here would delete\n // resources that outlive this collection.\n const ownsDirectory = options.temporaryDirectory === undefined;\n const temporaryDirectory = options.temporaryDirectory ?? (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'po-')));\n await fs.promises.mkdir(temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(temporaryDirectory, 0o700);\n const sharedSkills = path.join(repoRoot, '.claude', 'skills');\n // A domain can opt out of the always-on shared skills to keep its context small.\n const sharedSkillSources =\n options.sharedSkills === false\n ? []\n : await discoverSkillsAsync(repoRoot, sharedSkills, 'recursive', options.skillCacheDirectory);\n const skillDirectories: string[] = [];\n const skillSources: NamedResource[] = [];\n const agentSources: Array<{ name: string; path: string }> = [];\n\n for (const entry of pluginEntries) {\n const pluginDirectory = entry.directory;\n const skills = path.join(pluginDirectory, 'skills');\n if (await pathExists(skills)) {\n const found = (\n await discoverSkillsAsync(repoRoot, skills, entry.skillDiscovery ?? 'recursive', options.skillCacheDirectory)\n ).filter((skill) => keepsName(entry.skills, skill.name));\n // Exact files let Pi skip another recursive traversal and make a plugin\n // subset unambiguous without staging copies of the skill bodies.\n skillDirectories.push(...found.map((skill) => skill.path));\n skillSources.push(...found);\n }\n const agents = path.join(pluginDirectory, 'agents');\n const agentFiles = await markdownFilesAsync(agents);\n const agentNames = await Promise.all(agentFiles.map((filePath) => frontmatterNameAsync(filePath)));\n agentSources.push(\n ...agentFiles\n .map((filePath, index) => ({ name: agentNames[index] ?? '', path: filePath }))\n .filter((agent) => keepsName(entry.agents, agent.name)),\n );\n }\n\n await assertUniqueAsync(skillSources, 'skill');\n await assertUniqueAsync(sharedSkillSources, 'skill');\n // Pi keeps the first skill for a duplicated name. Selected domain plugins are\n // authoritative; shared Claude skills remain fallbacks for names no plugin owns.\n const pluginSkillNames = new Set(skillSources.map((skill) => skill.name));\n const fallbackSharedSkills = sharedSkillSources.filter((skill) => !pluginSkillNames.has(skill.name));\n skillDirectories.push(...fallbackSharedSkills.map((skill) => skill.path));\n skillSources.push(...fallbackSharedSkills);\n\n await assertUniqueAsync(agentSources, 'agent');\n if (agentSources.some((source) => source.name === DISPATCHER_AGENT_NAME)) {\n throw new Error(`Conflicting agent \"${DISPATCHER_AGENT_NAME}\": reserved by the agent harness`);\n }\n\n const agentDirectories: string[] = [];\n const outputDirectory = path.join(temporaryDirectory, 'agents');\n await fs.promises.rm(outputDirectory, { recursive: true, force: true });\n if (options.agents) {\n await fs.promises.mkdir(outputDirectory, { mode: 0o700 });\n for (const source of agentSources) {\n const adapted = adaptAgentDefinition(await fs.promises.readFile(source.path, 'utf8'));\n await fs.promises.writeFile(\n path.join(outputDirectory, `${assertSafeAgentName(adapted.name)}.md`),\n adapted.content,\n { mode: 0o600 },\n );\n }\n await fs.promises.writeFile(path.join(outputDirectory, `${DISPATCHER_AGENT_NAME}.md`), dispatcherAgentSource(), {\n mode: 0o600,\n });\n agentDirectories.push(outputDirectory);\n }\n\n const { mcpConfigPath, mcpProjection, pluginMcpSources, pluginMcpConfigPaths } = await stageMcpResources(\n repoRoot,\n pluginEntries,\n {\n enabled: options.mcp,\n temporaryDirectory,\n ...(options.mcpAllowlist ? { mcpAllowlist: options.mcpAllowlist } : {}),\n ...(options.pluginDataRoot ? { pluginDataRoot: options.pluginDataRoot } : {}),\n ...(options.userMcpConfigPath ? { userMcpConfigPath: options.userMcpConfigPath } : {}),\n },\n );\n\n return {\n temporaryDirectory,\n skillDirectories,\n skillSources,\n skillCount: skillSources.length,\n agentCount: agentSources.length,\n agentDirectories,\n mcpConfigPath,\n mcpProjection,\n pluginMcpSources,\n pluginMcpConfigPaths,\n cleanup: () =>\n ownsDirectory ? fs.promises.rm(temporaryDirectory, { recursive: true, force: true }) : Promise.resolve(),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,MAAM,mBAAmB;;AAGzB,SAAgB,kBAAkB,OAAe,UAA0B;CACzE,MAAM,aAAa,MAChB,UAAU,MAAM,CAAC,CACjB,QAAQ,qBAAqB,EAAE,CAAC,CAChC,QAAQ,sBAAsB,GAAG,CAAC,CAClC,QAAQ,qBAAqB,EAAE,CAAC,CAChC,MAAM,GAAG,gBAAgB,CAAC,CAC1B,QAAQ,aAAa,EAAE;CAC1B,OAAO,eAAe,MAAM,eAAe,OAAO,eAAe,OAAO,WAAW;AACrF;;;ACDA,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB,CAAC,SAAS,QAAQ;AAC/C,MAAM,gBAAgB;AACtB,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ACA;EACA;EACA;EACA;EACA,eACE,gBAAgB,GAAG,SAAS,GAAG,oBAAoB;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC,IAAI,QAAQ,QAAQ;CAC3G;AACF"}
|
package/dist/resources.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_resourceCollector = require("./resourceCollector-
|
|
2
|
+
const require_resourceCollector = require("./resourceCollector-BSlkw1wf.cjs");
|
|
3
3
|
exports.DISPATCHER_AGENT_NAME = require_resourceCollector.DISPATCHER_AGENT_NAME;
|
|
4
4
|
exports.adaptAgentDefinition = require_resourceCollector.adaptAgentDefinition;
|
|
5
5
|
exports.collectResources = require_resourceCollector.collectResources;
|
package/dist/resources.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { s as DISPATCHER_AGENT_NAME, c as adaptAgentDefinition, t as collectResources, n as discoverSkills, r as discoverSkillsAsync, i as mergeMcpConfigs, a as mergeMcpConfigsAsync, l as resolveSkillCacheDirectory, u as sanitizeSyncLabel, o as stageMcpResources } from "./resourceCollector-
|
|
1
|
+
export { s as DISPATCHER_AGENT_NAME, c as adaptAgentDefinition, t as collectResources, n as discoverSkills, r as discoverSkillsAsync, i as mergeMcpConfigs, a as mergeMcpConfigsAsync, l as resolveSkillCacheDirectory, u as sanitizeSyncLabel, o as stageMcpResources } from "./resourceCollector-Bg7rnLiv.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-domain",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.40",
|
|
4
4
|
"description": "Domain selection, resource staging, and MCP scoping for Po sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -88,18 +88,18 @@
|
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@agimon-ai/po-config": "0.0.0-alpha.
|
|
92
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
93
|
-
"@agimon-ai/po-minor-mode": "0.0.0-alpha.
|
|
91
|
+
"@agimon-ai/po-config": "0.0.0-alpha.40",
|
|
92
|
+
"@agimon-ai/po-core": "0.0.0-alpha.40",
|
|
93
|
+
"@agimon-ai/po-minor-mode": "0.0.0-alpha.40",
|
|
94
94
|
"@deepseek-ai/cordis": "4.0.5",
|
|
95
95
|
"typebox": "1.4.2",
|
|
96
96
|
"yaml": "2.9.1"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
100
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
101
|
-
"@agimon-ai/po-voice": "0.0.0-alpha.
|
|
102
|
-
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.
|
|
99
|
+
"@agimon-ai/po-build": "0.0.0-alpha.40",
|
|
100
|
+
"@agimon-ai/po-core": "0.0.0-alpha.40",
|
|
101
|
+
"@agimon-ai/po-voice": "0.0.0-alpha.40",
|
|
102
|
+
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.40",
|
|
103
103
|
"@deepseek-ai/cordis": "4.0.5",
|
|
104
104
|
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
105
105
|
"@types/node": "26.6.5",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"vitest": "5.0.4"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
112
|
+
"@agimon-ai/po-core": "0.0.0-alpha.40",
|
|
113
113
|
"@earendil-works/pi-coding-agent": "1.3.0"
|
|
114
114
|
},
|
|
115
115
|
"peerDependenciesMeta": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resourceCollector-CDnpAYEm.cjs","names":["os","path","poHomeDirectory","fs","crypto","parse","toPiToolName","stringify","createHash","path","fs","stringify","normalizeAgentPluginMcpSource","globalPoConfigDirectory","pluginMcpSource","applyMcpAllowlist","PO_MCP_PROJECTION_VERSION","os"],"sources":["../src/services/skillCacheLocation/syncLabel.ts","../src/services/skillCacheLocation/index.ts","../src/services/resourceCollector/agentDefinition.ts","../src/services/resourceCollector/index.ts"],"sourcesContent":["const LABEL_MAX_LENGTH = 48;\n\n/** Keeps a repository or worktree name usable as one path segment. */\nexport function sanitizeSyncLabel(value: string, fallback: string): string {\n const normalized = value\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/gu, '')\n .replace(/[^A-Za-z0-9._-]+/gu, '-')\n .replace(/^[._-]+|[._-]+$/gu, '')\n .slice(0, LABEL_MAX_LENGTH)\n .replace(/[._-]+$/gu, '');\n return normalized === '' || normalized === '.' || normalized === '..' ? fallback : normalized;\n}\n","import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport { sanitizeSyncLabel } from './syncLabel';\n\nexport { sanitizeSyncLabel } from './syncLabel';\n\nconst SYNC_DIRECTORY = 'sync';\nconst WORKTREES_DIRECTORY = 'worktrees';\nconst SKILL_CACHE_SEGMENTS = ['cache', 'skills'];\nconst GIT_DIRECTORY = '.git';\nconst COMMON_DIRECTORY_FILE = 'commondir';\nconst IDENTITY_HEX_LENGTH = 32;\nconst DEFAULT_REPOSITORY_LABEL = 'repo';\nconst DEFAULT_WORKTREE_LABEL = 'worktree';\n\n/**\n * The home-scoped skill manifest cache for one worktree.\n *\n * This mirrors the namespace the Po launcher publishes into, so a session\n * that stages resources through the launcher and one that stages them through a\n * `/domains` switch hit the same manifests instead of rescanning every tree.\n * Two worktrees of one repository stay separate, and a checkout reached through\n * a symlink resolves to the same identity as the real path.\n */\nexport function resolveSkillCacheDirectory(repositoryRoot: string, homeDirectory: string = os.homedir()): string {\n const root = canonicalPath(repositoryRoot);\n const commonDirectory = gitCommonDirectory(root);\n const repositoryToken = commonDirectory ? `git:${commonDirectory}` : `root:${root}`;\n const repositoryId = identityHash(repositoryToken);\n const worktreeId = identityHash(`${repositoryToken}\\0worktree:${root}`);\n const repoLabel = repositoryLabel(commonDirectory, root);\n const worktreeLabel = sanitizeSyncLabel(path.basename(root), DEFAULT_WORKTREE_LABEL);\n return path.join(\n poHomeDirectory(path.resolve(homeDirectory)),\n SYNC_DIRECTORY,\n `${repoLabel}--${repositoryId}`,\n WORKTREES_DIRECTORY,\n `${worktreeLabel}--${worktreeId}`,\n ...SKILL_CACHE_SEGMENTS,\n );\n}\n\nfunction canonicalPath(target: string): string {\n const absolute = path.resolve(target);\n try {\n return fs.realpathSync.native(absolute);\n } catch {\n return absolute;\n }\n}\n\nfunction readGitDirectory(repositoryRoot: string): string | undefined {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n const stat = fs.statSync(gitPath);\n if (stat.isDirectory()) return canonicalPath(gitPath);\n if (!stat.isFile()) return undefined;\n const match = /^gitdir:\\s*(.+)$/imu.exec(fs.readFileSync(gitPath, 'utf8').trim());\n return match?.[1] ? canonicalPath(path.resolve(repositoryRoot, match[1].trim())) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction gitCommonDirectory(repositoryRoot: string): string | undefined {\n const gitDirectory = readGitDirectory(repositoryRoot);\n if (!gitDirectory) return undefined;\n try {\n const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), 'utf8').trim();\n return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;\n } catch {\n return gitDirectory;\n }\n}\n\nfunction identityHash(value: string): string {\n return crypto.createHash('sha256').update(value, 'utf8').digest('hex').slice(0, IDENTITY_HEX_LENGTH);\n}\n\nfunction repositoryLabel(commonDirectory: string | undefined, repositoryRoot: string): string {\n if (!commonDirectory) return sanitizeSyncLabel(path.basename(repositoryRoot), DEFAULT_REPOSITORY_LABEL);\n const base = path.basename(commonDirectory);\n const source = base === GIT_DIRECTORY ? path.basename(path.dirname(commonDirectory)) : base;\n return sanitizeSyncLabel(source, DEFAULT_REPOSITORY_LABEL);\n}\n","import { parse, stringify } from 'yaml';\n\nimport type { JsonObject } from '../../types/resources';\nimport { toPiToolName } from '../toolNames';\n\nexport const DISPATCHER_AGENT_NAME = 'agiflow-dispatcher';\n\nexport function splitFrontmatter(content: string): { attributes: JsonObject; body: string } {\n const match = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) throw new Error('Resource is missing YAML frontmatter');\n return { attributes: parse(match[1]!) as JsonObject, body: match[2] ?? '' };\n}\n\nconst CLAUDE_MODEL_ALIASES: Record<string, string> = {\n sonnet: 'anthropic/claude-sonnet-4-6',\n opus: 'anthropic/claude-opus-4-6',\n haiku: 'anthropic/claude-haiku-4-5',\n};\n\nexport function assertSafeAgentName(name: string): string {\n const trimmed = name.trim();\n if (\n !trimmed ||\n trimmed !== name ||\n trimmed === '.' ||\n trimmed === '..' ||\n trimmed.includes('\\0') ||\n /[\\\\/]/.test(trimmed)\n ) {\n throw new Error(`Unsafe agent name: ${JSON.stringify(name)}`);\n }\n return trimmed;\n}\n\nfunction normalizeClaudeModel(value: unknown): unknown {\n if (typeof value === 'string') return CLAUDE_MODEL_ALIASES[value.toLowerCase()] ?? value;\n if (Array.isArray(value)) return value.map((entry) => normalizeClaudeModel(entry));\n return value;\n}\n\n/** Rewrites a Claude-authored agent definition into the form Pi loads. */\nexport function adaptAgentDefinition(content: string): { name: string; content: string } {\n const { attributes, body } = splitFrontmatter(content);\n const rawName = typeof attributes.name === 'string' ? attributes.name : undefined;\n if (!rawName) throw new Error('Agent definition requires a name');\n const name = assertSafeAgentName(rawName);\n const hasTools = Object.hasOwn(attributes, 'tools');\n const rawTools = Array.isArray(attributes.tools)\n ? attributes.tools.map(String)\n : typeof attributes.tools === 'string'\n ? attributes.tools\n .split(',')\n .map((tool) => tool.trim())\n .filter(Boolean)\n : [];\n const mappedTools = [...new Set(rawTools.map(toPiToolName).filter((tool): tool is string => Boolean(tool)))];\n const converted: JsonObject = {\n ...attributes,\n inheritProjectContext: true,\n inheritSkills: true,\n systemPromptMode: attributes.systemPromptMode ?? 'replace',\n };\n if (hasTools) converted.tools = Array.isArray(attributes.tools) ? mappedTools : mappedTools.join(', ');\n else delete converted.tools;\n if (converted.model !== undefined) converted.model = normalizeClaudeModel(converted.model);\n if (converted.fallbackModels !== undefined) converted.fallbackModels = normalizeClaudeModel(converted.fallbackModels);\n if (converted.memory === 'project' || converted.memory === 'user')\n converted.memory = { scope: converted.memory, path: name };\n else if (\n converted.memory !== undefined &&\n (typeof converted.memory !== 'object' || converted.memory === null || Array.isArray(converted.memory))\n )\n throw new Error('Unsupported memory declaration');\n delete converted.permissionMode;\n return { name, content: `---\\n${stringify(converted).trim()}\\n---\\n\\n${body.trimStart()}` };\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { normalizeAgentPluginMcpSource, pluginMcpSource } from '@agimon-ai/po-config/agentPluginMcp';\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport type { PluginEntry, PluginSkillDiscovery } from '@agimon-ai/po-config/domains';\nimport {\n PO_MCP_PROJECTION_VERSION,\n type PoMcpProjection,\n type PoMcpProjectionSource,\n} from '@agimon-ai/po-core/mcpProjection';\nimport { stringify } from 'yaml';\n\nimport type {\n HarnessResourceOptions,\n HarnessResources,\n JsonObject,\n McpResourceOptions,\n NamedResource,\n StagedMcpResources,\n} from '../../types/resources';\nimport { applyMcpAllowlist } from '../mcpFilter';\nimport { resolveSkillCacheDirectory } from '../skillCacheLocation';\nimport { adaptAgentDefinition, assertSafeAgentName, DISPATCHER_AGENT_NAME, splitFrontmatter } from './agentDefinition';\n\nexport { adaptAgentDefinition, DISPATCHER_AGENT_NAME } from './agentDefinition';\n\nconst DISPATCHER_TOOLS = ['read', 'grep', 'find', 'ls', 'bash', 'launch_workflow', 'list_workflows'];\nconst SKILL_MANIFEST_VERSION = 4;\nconst SKILL_MANIFEST_HASH_LENGTH = 16;\nconst PLUGIN_DATA_DIRECTORY = 'plugin-data';\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction canonicalJson(value: unknown): string {\n const normalize = (candidate: unknown): unknown => {\n if (Array.isArray(candidate)) return candidate.map(normalize);\n if (!isJsonObject(candidate)) return candidate;\n return Object.fromEntries(\n Object.entries(candidate)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, child]) => [key, normalize(child)]),\n );\n };\n return JSON.stringify(normalize(value));\n}\n\nfunction projectionFingerprint(input: Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>): string {\n return createHash('sha256').update(canonicalJson(input)).digest('hex');\n}\n\ninterface SkillManifestFile {\n path: string;\n name: string;\n description?: string;\n digest: string;\n size: number;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifestDirectory {\n path: string;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifest {\n version: number;\n root: string;\n discovery: PluginSkillDiscovery;\n files: SkillManifestFile[];\n directories: SkillManifestDirectory[];\n}\n\nfunction skillManifestPath(\n repoRoot: string,\n skillRoot: string,\n discovery: PluginSkillDiscovery,\n cacheDirectory?: string,\n): string {\n const key = createHash('sha256')\n .update(`${path.resolve(skillRoot)}\\0${discovery}`)\n .digest('hex')\n .slice(0, SKILL_MANIFEST_HASH_LENGTH);\n return path.join(cacheDirectory ?? resolveSkillCacheDirectory(repoRoot), `${key}.json`);\n}\n\nfunction fileMatches(previous: SkillManifestFile): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return (\n stat.isFile() &&\n stat.size === previous.size &&\n stat.mtimeMs === previous.mtimeMs &&\n stat.ctimeMs === previous.ctimeMs\n );\n } catch {\n return false;\n }\n}\n\nfunction directoryMatches(previous: SkillManifestDirectory): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return stat.isDirectory() && stat.mtimeMs === previous.mtimeMs && stat.ctimeMs === previous.ctimeMs;\n } catch {\n return false;\n }\n}\n\nfunction readSkillManifest(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): SkillManifest | undefined {\n try {\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories) ||\n !manifest.files.every(fileMatches) ||\n !manifest.directories.every(directoryMatches)\n ) {\n return undefined;\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nfunction writeSkillManifest(manifestPath: string, manifest: SkillManifest): void {\n fs.mkdirSync(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n fs.writeFileSync(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n fs.renameSync(temporary, manifestPath);\n } catch (error) {\n fs.rmSync(temporary, { force: true });\n if (!fs.existsSync(manifestPath)) throw error;\n }\n}\n\nasync function pathExists(target: string): Promise<boolean> {\n try {\n await fs.promises.access(target);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function readSkillManifestAsync(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): Promise<SkillManifest | undefined> {\n try {\n const manifest = JSON.parse(await fs.promises.readFile(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories)\n ) {\n return undefined;\n }\n for (const previous of manifest.files) {\n const stat = await fs.promises.stat(previous.path);\n if (\n !stat.isFile() ||\n stat.size !== previous.size ||\n stat.mtimeMs !== previous.mtimeMs ||\n stat.ctimeMs !== previous.ctimeMs\n ) {\n return undefined;\n }\n }\n for (const previous of manifest.directories) {\n const stat = await fs.promises.stat(previous.path);\n if (!stat.isDirectory() || stat.mtimeMs !== previous.mtimeMs || stat.ctimeMs !== previous.ctimeMs) {\n return undefined;\n }\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nasync function writeSkillManifestAsync(manifestPath: string, manifest: SkillManifest): Promise<void> {\n await fs.promises.mkdir(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n await fs.promises.writeFile(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n await fs.promises.rename(temporary, manifestPath);\n } catch (error) {\n await fs.promises.rm(temporary, { force: true });\n if (!(await pathExists(manifestPath))) throw error;\n }\n}\n\n/**\n * A directory entry resolved through any symlink, or undefined for a broken one.\n *\n * `readdir` reports symlinks with lstat semantics, so a symlinked skill\n * directory answers false to both `isDirectory()` and `isFile()` and would be\n * skipped by a naive branch. Pi stats through the link instead\n * (dist/core/skills.js:171-183) and treats a failing stat as a broken link to\n * skip, which is what keeps a shared skill published as a symlink visible.\n */\nfunction resolveEntryKind(entry: fs.Dirent, candidate: string): { directory: boolean; file: boolean } | undefined {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = fs.statSync(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\nasync function resolveEntryKindAsync(\n entry: fs.Dirent,\n candidate: string,\n): Promise<{ directory: boolean; file: boolean } | undefined> {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = await fs.promises.stat(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The skill's declared name, or the name of the directory holding it.\n *\n * Pi falls back to the containing directory rather than rejecting the file\n * (dist/core/skills.js:245). Rejecting is worse than one missing skill here:\n * this walk feeds the whole resource collection, so a single unnamed SKILL.md\n * from a third-party plugin would fail session launch outright rather than\n * degrade.\n */\nfunction skillName(filePath: string, attributes: JsonObject): string {\n const declared = typeof attributes.name === 'string' ? attributes.name.trim() : '';\n if (declared) return declared;\n const fallback = path.basename(path.dirname(filePath));\n if (!fallback) throw new Error(`Resource requires a name: ${filePath}`);\n return fallback;\n}\n\nfunction scanSkillManifest(root: string, discovery: PluginSkillDiscovery): SkillManifest {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n // Following symlinks makes a cycle reachable, and this walk records every\n // directory it visits, so an unguarded cycle would exhaust the stack and the\n // manifest together. Real paths are what a cycle repeats.\n const visited = new Set<string>();\n const walk = (directory: string, depth: number): void => {\n if (!fs.existsSync(directory)) return;\n const realDirectory = fs.realpathSync(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = fs.statSync(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {\n const candidate = path.join(directory, entry.name);\n const kind = resolveEntryKind(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = fs.readFileSync(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = fs.statSync(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\n/** Cached skill metadata and exact files, ready for Pi without a second tree walk. */\nexport function discoverSkills(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): NamedResource[] {\n if (!fs.existsSync(root)) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = readSkillManifest(manifestPath, root, discovery);\n const manifest = cached ?? scanSkillManifest(root, discovery);\n if (!cached) writeSkillManifest(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function scanSkillManifestAsync(root: string, discovery: PluginSkillDiscovery): Promise<SkillManifest> {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n const visited = new Set<string>();\n const walk = async (directory: string, depth: number): Promise<void> => {\n let entries: fs.Dirent[];\n try {\n const realDirectory = await fs.promises.realpath(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = await fs.promises.stat(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return;\n throw error;\n }\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n const kind = await resolveEntryKindAsync(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) await walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = await fs.promises.readFile(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = await fs.promises.stat(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n await walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\nexport async function discoverSkillsAsync(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): Promise<NamedResource[]> {\n if (!(await pathExists(root))) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = await readSkillManifestAsync(manifestPath, root, discovery);\n const manifest = cached ?? (await scanSkillManifestAsync(root, discovery));\n if (!cached) await writeSkillManifestAsync(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function markdownFilesAsync(directory: string): Promise<string[]> {\n let entries: fs.Dirent[];\n try {\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];\n throw error;\n }\n const results: string[] = [];\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n if (entry.isDirectory()) results.push(...(await markdownFilesAsync(candidate)));\n if (entry.isFile() && entry.name.endsWith('.md')) results.push(candidate);\n }\n return results;\n}\n\nasync function frontmatterNameAsync(filePath: string): Promise<string> {\n const { attributes } = splitFrontmatter(await fs.promises.readFile(filePath, 'utf8'));\n if (typeof attributes.name !== 'string') throw new Error(`Resource requires a name: ${filePath}`);\n return attributes.name;\n}\n\nasync function assertUniqueAsync(resources: NamedResource[], kind: string): Promise<void> {\n const seen = new Map<string, string>();\n const digestByName = new Map<string, string>();\n for (const resource of resources) {\n const previous = seen.get(resource.name);\n const digest =\n resource.digest ??\n createHash('sha256')\n .update(await fs.promises.readFile(resource.path))\n .digest('hex');\n if (previous && digestByName.get(resource.name) !== digest) {\n throw new Error(`Conflicting ${kind} \"${resource.name}\": ${previous} and ${resource.path}`);\n }\n seen.set(resource.name, resource.path);\n digestByName.set(resource.name, digest);\n }\n}\n\nfunction dispatcherAgentSource(): string {\n const attributes: JsonObject = {\n name: DISPATCHER_AGENT_NAME,\n description: 'Selects and launches Agiflow workflows for one loop pass without implementing the work.',\n thinking: 'high',\n systemPromptMode: 'replace',\n inheritProjectContext: true,\n inheritSkills: true,\n tools: DISPATCHER_TOOLS.join(', '),\n // No feature extension is named here. Team inherits the ordered child\n // composition projected from the selected layers for every helper process.\n defaultContext: 'fresh',\n defaultProgress: false,\n };\n const body = [\n 'You are the Agiflow workflow dispatcher.',\n 'Reason about the supplied dispatch context and launch eligible workflows.',\n 'Launch workflows without monitoring them. After dispatching, report and exit.',\n 'Follow the task restrictions exactly. Do not implement jobs or edit repository files.',\n ].join('\\n');\n return `---\\n${stringify(attributes).trim()}\\n---\\n\\n${body}\\n`;\n}\n\nexport function mergeMcpConfigs(configPaths: string[]): JsonObject {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n if (!fs.existsSync(configPath)) continue;\n const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nexport async function mergeMcpConfigsAsync(configPaths: string[]): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n let content: string;\n try {\n content = await fs.promises.readFile(configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n const config = JSON.parse(content) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nasync function mergeProjectedMcpConfigs(\n sources: readonly PoMcpProjectionSource[],\n stagingDirectory: string,\n): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const origins = new Map<string, string>();\n // The person's own entries are defaults: a repository or plugin entry with the same name replaces them.\n const userOwned = new Set<string>();\n\n for (const source of sources) {\n let config: JsonObject;\n if (source.format === 'agent-plugin-v1') {\n config = normalizeAgentPluginMcpSource(source, {\n stagingDirectory,\n // The generated file is consumed by external MCP clients. Keep wrapper\n // names there; Po strips its own in-process wrapper at runtime.\n stripProxyWrappers: false,\n }).claudeConfig;\n } else {\n let content: string;\n try {\n content = await fs.promises.readFile(source.configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n config = JSON.parse(content) as JsonObject;\n }\n\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && !userOwned.has(name) && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${origins.get(name)} and ${source.configPath}`);\n }\n servers[name] = definition;\n origins.set(name, source.configPath);\n if (source.owner === 'user') userOwned.add(name);\n else userOwned.delete(name);\n }\n }\n\n return merged;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Matches a resource name against a subset filter. Undefined keeps everything. */\nfunction keepsName(allowed: string[] | undefined, name: string): boolean {\n if (!allowed) return true;\n return allowed.some((pattern) =>\n pattern.includes('*')\n ? new RegExp(`^${pattern.split('*').map(escapeRegExp).join('.*')}$`).test(name)\n : pattern === name,\n );\n}\n\n/** Stages only the MCP slice shared by Po and compatibility frontends. */\nexport async function stageMcpResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: McpResourceOptions,\n): Promise<StagedMcpResources> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n const pluginMcpConfigPaths: string[] = [];\n const pluginMcpSources: PoMcpProjectionSource[] = [];\n const mcpSources: PoMcpProjectionSource[] = [];\n const pluginDataRoot = options.pluginDataRoot ?? path.join(globalPoConfigDirectory(), PLUGIN_DATA_DIRECTORY);\n const repositoryMcpPath = path.join(repoRoot, '.mcp.json');\n\n await fs.promises.mkdir(options.temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(options.temporaryDirectory, 0o700);\n // First, so every later layer overrides it.\n if (options.enabled && options.userMcpConfigPath && (await pathExists(options.userMcpConfigPath))) {\n const content = await fs.promises.readFile(options.userMcpConfigPath);\n mcpSources.push({\n sourceId: 'user:mcp.json',\n owner: 'user',\n format: 'native',\n configPath: options.userMcpConfigPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n if (options.enabled && (await pathExists(repositoryMcpPath))) {\n const content = await fs.promises.readFile(repositoryMcpPath);\n mcpSources.push({\n sourceId: 'repository:.mcp.json',\n owner: 'repository',\n format: 'native',\n configPath: repositoryMcpPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n\n if (options.enabled) {\n for (const entry of pluginEntries) {\n const source = await pluginMcpSource(entry, pluginDataRoot);\n if (!source) continue;\n mcpSources.push(source);\n pluginMcpSources.push(source);\n pluginMcpConfigPaths.push(source.configPath);\n }\n }\n\n let mcpConfigPath: string | undefined;\n if (options.enabled) {\n mcpConfigPath = path.join(options.temporaryDirectory, 'mcp.json');\n const merged = await applyMcpAllowlist(\n await mergeProjectedMcpConfigs(mcpSources, options.temporaryDirectory),\n options.mcpAllowlist,\n repoRoot,\n options.temporaryDirectory,\n );\n await fs.promises.writeFile(mcpConfigPath, `${JSON.stringify(merged, null, 2)}\\n`, { mode: 0o600 });\n }\n\n const projectionWithoutRuntimePath = {\n version: PO_MCP_PROJECTION_VERSION,\n enabled: options.enabled,\n repoRoot,\n ...(mcpConfigPath ? { generatedConfigPath: mcpConfigPath } : {}),\n sources: options.enabled ? mcpSources : [],\n ...(options.mcpAllowlist ? { allowlist: structuredClone(options.mcpAllowlist) } : {}),\n } satisfies Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>;\n\n return {\n mcpConfigPath,\n mcpProjection: {\n ...projectionWithoutRuntimePath,\n stagingDirectory: options.temporaryDirectory,\n fingerprint: projectionFingerprint(projectionWithoutRuntimePath),\n },\n pluginMcpSources,\n pluginMcpConfigPaths,\n };\n}\n\n/**\n * Stages every resource the selected domains contribute, ready for one Pi session.\n *\n * The caller owns the returned cleanup(): the temporary directory holding agents\n * and the generated MCP config has to outlive this function and be removed once\n * the session that reads it is done.\n */\nexport async function collectResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: HarnessResourceOptions,\n): Promise<HarnessResources & { skillSources: NamedResource[] }> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n // A caller-supplied directory is owned by the caller: it is either a live\n // session's directory or the synced one, and removing it here would delete\n // resources that outlive this collection.\n const ownsDirectory = options.temporaryDirectory === undefined;\n const temporaryDirectory = options.temporaryDirectory ?? (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'po-')));\n await fs.promises.mkdir(temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(temporaryDirectory, 0o700);\n const sharedSkills = path.join(repoRoot, '.claude', 'skills');\n // A domain can opt out of the always-on shared skills to keep its context small.\n const sharedSkillSources =\n options.sharedSkills === false\n ? []\n : await discoverSkillsAsync(repoRoot, sharedSkills, 'recursive', options.skillCacheDirectory);\n const skillDirectories: string[] = [];\n const skillSources: NamedResource[] = [];\n const agentSources: Array<{ name: string; path: string }> = [];\n\n for (const entry of pluginEntries) {\n const pluginDirectory = entry.directory;\n const skills = path.join(pluginDirectory, 'skills');\n if (await pathExists(skills)) {\n const found = (\n await discoverSkillsAsync(repoRoot, skills, entry.skillDiscovery ?? 'recursive', options.skillCacheDirectory)\n ).filter((skill) => keepsName(entry.skills, skill.name));\n // Exact files let Pi skip another recursive traversal and make a plugin\n // subset unambiguous without staging copies of the skill bodies.\n skillDirectories.push(...found.map((skill) => skill.path));\n skillSources.push(...found);\n }\n const agents = path.join(pluginDirectory, 'agents');\n const agentFiles = await markdownFilesAsync(agents);\n const agentNames = await Promise.all(agentFiles.map((filePath) => frontmatterNameAsync(filePath)));\n agentSources.push(\n ...agentFiles\n .map((filePath, index) => ({ name: agentNames[index] ?? '', path: filePath }))\n .filter((agent) => keepsName(entry.agents, agent.name)),\n );\n }\n\n await assertUniqueAsync(skillSources, 'skill');\n await assertUniqueAsync(sharedSkillSources, 'skill');\n // Pi keeps the first skill for a duplicated name. Selected domain plugins are\n // authoritative; shared Claude skills remain fallbacks for names no plugin owns.\n const pluginSkillNames = new Set(skillSources.map((skill) => skill.name));\n const fallbackSharedSkills = sharedSkillSources.filter((skill) => !pluginSkillNames.has(skill.name));\n skillDirectories.push(...fallbackSharedSkills.map((skill) => skill.path));\n skillSources.push(...fallbackSharedSkills);\n\n await assertUniqueAsync(agentSources, 'agent');\n if (agentSources.some((source) => source.name === DISPATCHER_AGENT_NAME)) {\n throw new Error(`Conflicting agent \"${DISPATCHER_AGENT_NAME}\": reserved by the agent harness`);\n }\n\n const agentDirectories: string[] = [];\n const outputDirectory = path.join(temporaryDirectory, 'agents');\n await fs.promises.rm(outputDirectory, { recursive: true, force: true });\n if (options.agents) {\n await fs.promises.mkdir(outputDirectory, { mode: 0o700 });\n for (const source of agentSources) {\n const adapted = adaptAgentDefinition(await fs.promises.readFile(source.path, 'utf8'));\n await fs.promises.writeFile(\n path.join(outputDirectory, `${assertSafeAgentName(adapted.name)}.md`),\n adapted.content,\n { mode: 0o600 },\n );\n }\n await fs.promises.writeFile(path.join(outputDirectory, `${DISPATCHER_AGENT_NAME}.md`), dispatcherAgentSource(), {\n mode: 0o600,\n });\n agentDirectories.push(outputDirectory);\n }\n\n const { mcpConfigPath, mcpProjection, pluginMcpSources, pluginMcpConfigPaths } = await stageMcpResources(\n repoRoot,\n pluginEntries,\n {\n enabled: options.mcp,\n temporaryDirectory,\n ...(options.mcpAllowlist ? { mcpAllowlist: options.mcpAllowlist } : {}),\n ...(options.pluginDataRoot ? { pluginDataRoot: options.pluginDataRoot } : {}),\n ...(options.userMcpConfigPath ? { userMcpConfigPath: options.userMcpConfigPath } : {}),\n },\n );\n\n return {\n temporaryDirectory,\n skillDirectories,\n skillSources,\n skillCount: skillSources.length,\n agentCount: agentSources.length,\n agentDirectories,\n mcpConfigPath,\n mcpProjection,\n pluginMcpSources,\n pluginMcpConfigPaths,\n cleanup: () =>\n ownsDirectory ? fs.promises.rm(temporaryDirectory, { recursive: true, force: true }) : Promise.resolve(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,MAAM,mBAAmB;;AAGzB,SAAgB,kBAAkB,OAAe,UAA0B;CACzE,MAAM,aAAa,MAChB,UAAU,MAAM,CAAC,CACjB,QAAQ,qBAAqB,EAAE,CAAC,CAChC,QAAQ,sBAAsB,GAAG,CAAC,CAClC,QAAQ,qBAAqB,EAAE,CAAC,CAChC,MAAM,GAAG,gBAAgB,CAAC,CAC1B,QAAQ,aAAa,EAAE;CAC1B,OAAO,eAAe,MAAM,eAAe,OAAO,eAAe,OAAO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ACE,gBAAgBC,QAAAA,QAAG,SAAS,GAAG,oBAAoB;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC,IAAI,QAAQ,QAAQ;CAC3G;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resourceCollector-DoXqQLuN.mjs","names":[],"sources":["../src/services/skillCacheLocation/syncLabel.ts","../src/services/skillCacheLocation/index.ts","../src/services/resourceCollector/agentDefinition.ts","../src/services/resourceCollector/index.ts"],"sourcesContent":["const LABEL_MAX_LENGTH = 48;\n\n/** Keeps a repository or worktree name usable as one path segment. */\nexport function sanitizeSyncLabel(value: string, fallback: string): string {\n const normalized = value\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/gu, '')\n .replace(/[^A-Za-z0-9._-]+/gu, '-')\n .replace(/^[._-]+|[._-]+$/gu, '')\n .slice(0, LABEL_MAX_LENGTH)\n .replace(/[._-]+$/gu, '');\n return normalized === '' || normalized === '.' || normalized === '..' ? fallback : normalized;\n}\n","import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport { sanitizeSyncLabel } from './syncLabel';\n\nexport { sanitizeSyncLabel } from './syncLabel';\n\nconst SYNC_DIRECTORY = 'sync';\nconst WORKTREES_DIRECTORY = 'worktrees';\nconst SKILL_CACHE_SEGMENTS = ['cache', 'skills'];\nconst GIT_DIRECTORY = '.git';\nconst COMMON_DIRECTORY_FILE = 'commondir';\nconst IDENTITY_HEX_LENGTH = 32;\nconst DEFAULT_REPOSITORY_LABEL = 'repo';\nconst DEFAULT_WORKTREE_LABEL = 'worktree';\n\n/**\n * The home-scoped skill manifest cache for one worktree.\n *\n * This mirrors the namespace the Po launcher publishes into, so a session\n * that stages resources through the launcher and one that stages them through a\n * `/domains` switch hit the same manifests instead of rescanning every tree.\n * Two worktrees of one repository stay separate, and a checkout reached through\n * a symlink resolves to the same identity as the real path.\n */\nexport function resolveSkillCacheDirectory(repositoryRoot: string, homeDirectory: string = os.homedir()): string {\n const root = canonicalPath(repositoryRoot);\n const commonDirectory = gitCommonDirectory(root);\n const repositoryToken = commonDirectory ? `git:${commonDirectory}` : `root:${root}`;\n const repositoryId = identityHash(repositoryToken);\n const worktreeId = identityHash(`${repositoryToken}\\0worktree:${root}`);\n const repoLabel = repositoryLabel(commonDirectory, root);\n const worktreeLabel = sanitizeSyncLabel(path.basename(root), DEFAULT_WORKTREE_LABEL);\n return path.join(\n poHomeDirectory(path.resolve(homeDirectory)),\n SYNC_DIRECTORY,\n `${repoLabel}--${repositoryId}`,\n WORKTREES_DIRECTORY,\n `${worktreeLabel}--${worktreeId}`,\n ...SKILL_CACHE_SEGMENTS,\n );\n}\n\nfunction canonicalPath(target: string): string {\n const absolute = path.resolve(target);\n try {\n return fs.realpathSync.native(absolute);\n } catch {\n return absolute;\n }\n}\n\nfunction readGitDirectory(repositoryRoot: string): string | undefined {\n const gitPath = path.join(repositoryRoot, GIT_DIRECTORY);\n try {\n const stat = fs.statSync(gitPath);\n if (stat.isDirectory()) return canonicalPath(gitPath);\n if (!stat.isFile()) return undefined;\n const match = /^gitdir:\\s*(.+)$/imu.exec(fs.readFileSync(gitPath, 'utf8').trim());\n return match?.[1] ? canonicalPath(path.resolve(repositoryRoot, match[1].trim())) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction gitCommonDirectory(repositoryRoot: string): string | undefined {\n const gitDirectory = readGitDirectory(repositoryRoot);\n if (!gitDirectory) return undefined;\n try {\n const relative = fs.readFileSync(path.join(gitDirectory, COMMON_DIRECTORY_FILE), 'utf8').trim();\n return relative ? canonicalPath(path.resolve(gitDirectory, relative)) : gitDirectory;\n } catch {\n return gitDirectory;\n }\n}\n\nfunction identityHash(value: string): string {\n return crypto.createHash('sha256').update(value, 'utf8').digest('hex').slice(0, IDENTITY_HEX_LENGTH);\n}\n\nfunction repositoryLabel(commonDirectory: string | undefined, repositoryRoot: string): string {\n if (!commonDirectory) return sanitizeSyncLabel(path.basename(repositoryRoot), DEFAULT_REPOSITORY_LABEL);\n const base = path.basename(commonDirectory);\n const source = base === GIT_DIRECTORY ? path.basename(path.dirname(commonDirectory)) : base;\n return sanitizeSyncLabel(source, DEFAULT_REPOSITORY_LABEL);\n}\n","import { parse, stringify } from 'yaml';\n\nimport type { JsonObject } from '../../types/resources';\nimport { toPiToolName } from '../toolNames';\n\nexport const DISPATCHER_AGENT_NAME = 'agiflow-dispatcher';\n\nexport function splitFrontmatter(content: string): { attributes: JsonObject; body: string } {\n const match = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) throw new Error('Resource is missing YAML frontmatter');\n return { attributes: parse(match[1]!) as JsonObject, body: match[2] ?? '' };\n}\n\nconst CLAUDE_MODEL_ALIASES: Record<string, string> = {\n sonnet: 'anthropic/claude-sonnet-4-6',\n opus: 'anthropic/claude-opus-4-6',\n haiku: 'anthropic/claude-haiku-4-5',\n};\n\nexport function assertSafeAgentName(name: string): string {\n const trimmed = name.trim();\n if (\n !trimmed ||\n trimmed !== name ||\n trimmed === '.' ||\n trimmed === '..' ||\n trimmed.includes('\\0') ||\n /[\\\\/]/.test(trimmed)\n ) {\n throw new Error(`Unsafe agent name: ${JSON.stringify(name)}`);\n }\n return trimmed;\n}\n\nfunction normalizeClaudeModel(value: unknown): unknown {\n if (typeof value === 'string') return CLAUDE_MODEL_ALIASES[value.toLowerCase()] ?? value;\n if (Array.isArray(value)) return value.map((entry) => normalizeClaudeModel(entry));\n return value;\n}\n\n/** Rewrites a Claude-authored agent definition into the form Pi loads. */\nexport function adaptAgentDefinition(content: string): { name: string; content: string } {\n const { attributes, body } = splitFrontmatter(content);\n const rawName = typeof attributes.name === 'string' ? attributes.name : undefined;\n if (!rawName) throw new Error('Agent definition requires a name');\n const name = assertSafeAgentName(rawName);\n const hasTools = Object.hasOwn(attributes, 'tools');\n const rawTools = Array.isArray(attributes.tools)\n ? attributes.tools.map(String)\n : typeof attributes.tools === 'string'\n ? attributes.tools\n .split(',')\n .map((tool) => tool.trim())\n .filter(Boolean)\n : [];\n const mappedTools = [...new Set(rawTools.map(toPiToolName).filter((tool): tool is string => Boolean(tool)))];\n const converted: JsonObject = {\n ...attributes,\n inheritProjectContext: true,\n inheritSkills: true,\n systemPromptMode: attributes.systemPromptMode ?? 'replace',\n };\n if (hasTools) converted.tools = Array.isArray(attributes.tools) ? mappedTools : mappedTools.join(', ');\n else delete converted.tools;\n if (converted.model !== undefined) converted.model = normalizeClaudeModel(converted.model);\n if (converted.fallbackModels !== undefined) converted.fallbackModels = normalizeClaudeModel(converted.fallbackModels);\n if (converted.memory === 'project' || converted.memory === 'user')\n converted.memory = { scope: converted.memory, path: name };\n else if (\n converted.memory !== undefined &&\n (typeof converted.memory !== 'object' || converted.memory === null || Array.isArray(converted.memory))\n )\n throw new Error('Unsupported memory declaration');\n delete converted.permissionMode;\n return { name, content: `---\\n${stringify(converted).trim()}\\n---\\n\\n${body.trimStart()}` };\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { normalizeAgentPluginMcpSource, pluginMcpSource } from '@agimon-ai/po-config/agentPluginMcp';\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport type { PluginEntry, PluginSkillDiscovery } from '@agimon-ai/po-config/domains';\nimport {\n PO_MCP_PROJECTION_VERSION,\n type PoMcpProjection,\n type PoMcpProjectionSource,\n} from '@agimon-ai/po-core/mcpProjection';\nimport { stringify } from 'yaml';\n\nimport type {\n HarnessResourceOptions,\n HarnessResources,\n JsonObject,\n McpResourceOptions,\n NamedResource,\n StagedMcpResources,\n} from '../../types/resources';\nimport { applyMcpAllowlist } from '../mcpFilter';\nimport { resolveSkillCacheDirectory } from '../skillCacheLocation';\nimport { adaptAgentDefinition, assertSafeAgentName, DISPATCHER_AGENT_NAME, splitFrontmatter } from './agentDefinition';\n\nexport { adaptAgentDefinition, DISPATCHER_AGENT_NAME } from './agentDefinition';\n\nconst DISPATCHER_TOOLS = ['read', 'grep', 'find', 'ls', 'bash', 'launch_workflow', 'list_workflows'];\nconst SKILL_MANIFEST_VERSION = 4;\nconst SKILL_MANIFEST_HASH_LENGTH = 16;\nconst PLUGIN_DATA_DIRECTORY = 'plugin-data';\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction canonicalJson(value: unknown): string {\n const normalize = (candidate: unknown): unknown => {\n if (Array.isArray(candidate)) return candidate.map(normalize);\n if (!isJsonObject(candidate)) return candidate;\n return Object.fromEntries(\n Object.entries(candidate)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, child]) => [key, normalize(child)]),\n );\n };\n return JSON.stringify(normalize(value));\n}\n\nfunction projectionFingerprint(input: Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>): string {\n return createHash('sha256').update(canonicalJson(input)).digest('hex');\n}\n\ninterface SkillManifestFile {\n path: string;\n name: string;\n description?: string;\n digest: string;\n size: number;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifestDirectory {\n path: string;\n mtimeMs: number;\n ctimeMs: number;\n}\n\ninterface SkillManifest {\n version: number;\n root: string;\n discovery: PluginSkillDiscovery;\n files: SkillManifestFile[];\n directories: SkillManifestDirectory[];\n}\n\nfunction skillManifestPath(\n repoRoot: string,\n skillRoot: string,\n discovery: PluginSkillDiscovery,\n cacheDirectory?: string,\n): string {\n const key = createHash('sha256')\n .update(`${path.resolve(skillRoot)}\\0${discovery}`)\n .digest('hex')\n .slice(0, SKILL_MANIFEST_HASH_LENGTH);\n return path.join(cacheDirectory ?? resolveSkillCacheDirectory(repoRoot), `${key}.json`);\n}\n\nfunction fileMatches(previous: SkillManifestFile): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return (\n stat.isFile() &&\n stat.size === previous.size &&\n stat.mtimeMs === previous.mtimeMs &&\n stat.ctimeMs === previous.ctimeMs\n );\n } catch {\n return false;\n }\n}\n\nfunction directoryMatches(previous: SkillManifestDirectory): boolean {\n try {\n const stat = fs.statSync(previous.path);\n return stat.isDirectory() && stat.mtimeMs === previous.mtimeMs && stat.ctimeMs === previous.ctimeMs;\n } catch {\n return false;\n }\n}\n\nfunction readSkillManifest(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): SkillManifest | undefined {\n try {\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories) ||\n !manifest.files.every(fileMatches) ||\n !manifest.directories.every(directoryMatches)\n ) {\n return undefined;\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nfunction writeSkillManifest(manifestPath: string, manifest: SkillManifest): void {\n fs.mkdirSync(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n fs.writeFileSync(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n fs.renameSync(temporary, manifestPath);\n } catch (error) {\n fs.rmSync(temporary, { force: true });\n if (!fs.existsSync(manifestPath)) throw error;\n }\n}\n\nasync function pathExists(target: string): Promise<boolean> {\n try {\n await fs.promises.access(target);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function readSkillManifestAsync(\n manifestPath: string,\n root: string,\n discovery: PluginSkillDiscovery,\n): Promise<SkillManifest | undefined> {\n try {\n const manifest = JSON.parse(await fs.promises.readFile(manifestPath, 'utf8')) as SkillManifest;\n if (\n manifest.version !== SKILL_MANIFEST_VERSION ||\n manifest.root !== path.resolve(root) ||\n manifest.discovery !== discovery ||\n !Array.isArray(manifest.files) ||\n !Array.isArray(manifest.directories)\n ) {\n return undefined;\n }\n for (const previous of manifest.files) {\n const stat = await fs.promises.stat(previous.path);\n if (\n !stat.isFile() ||\n stat.size !== previous.size ||\n stat.mtimeMs !== previous.mtimeMs ||\n stat.ctimeMs !== previous.ctimeMs\n ) {\n return undefined;\n }\n }\n for (const previous of manifest.directories) {\n const stat = await fs.promises.stat(previous.path);\n if (!stat.isDirectory() || stat.mtimeMs !== previous.mtimeMs || stat.ctimeMs !== previous.ctimeMs) {\n return undefined;\n }\n }\n return manifest;\n } catch {\n return undefined;\n }\n}\n\nasync function writeSkillManifestAsync(manifestPath: string, manifest: SkillManifest): Promise<void> {\n await fs.promises.mkdir(path.dirname(manifestPath), { recursive: true, mode: 0o700 });\n const temporary = `${manifestPath}.${process.pid}.${Date.now()}.tmp`;\n await fs.promises.writeFile(temporary, `${JSON.stringify(manifest, null, 2)}\\n`, { mode: 0o600 });\n try {\n await fs.promises.rename(temporary, manifestPath);\n } catch (error) {\n await fs.promises.rm(temporary, { force: true });\n if (!(await pathExists(manifestPath))) throw error;\n }\n}\n\n/**\n * A directory entry resolved through any symlink, or undefined for a broken one.\n *\n * `readdir` reports symlinks with lstat semantics, so a symlinked skill\n * directory answers false to both `isDirectory()` and `isFile()` and would be\n * skipped by a naive branch. Pi stats through the link instead\n * (dist/core/skills.js:171-183) and treats a failing stat as a broken link to\n * skip, which is what keeps a shared skill published as a symlink visible.\n */\nfunction resolveEntryKind(entry: fs.Dirent, candidate: string): { directory: boolean; file: boolean } | undefined {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = fs.statSync(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\nasync function resolveEntryKindAsync(\n entry: fs.Dirent,\n candidate: string,\n): Promise<{ directory: boolean; file: boolean } | undefined> {\n if (!entry.isSymbolicLink()) return { directory: entry.isDirectory(), file: entry.isFile() };\n try {\n const stat = await fs.promises.stat(candidate);\n return { directory: stat.isDirectory(), file: stat.isFile() };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The skill's declared name, or the name of the directory holding it.\n *\n * Pi falls back to the containing directory rather than rejecting the file\n * (dist/core/skills.js:245). Rejecting is worse than one missing skill here:\n * this walk feeds the whole resource collection, so a single unnamed SKILL.md\n * from a third-party plugin would fail session launch outright rather than\n * degrade.\n */\nfunction skillName(filePath: string, attributes: JsonObject): string {\n const declared = typeof attributes.name === 'string' ? attributes.name.trim() : '';\n if (declared) return declared;\n const fallback = path.basename(path.dirname(filePath));\n if (!fallback) throw new Error(`Resource requires a name: ${filePath}`);\n return fallback;\n}\n\nfunction scanSkillManifest(root: string, discovery: PluginSkillDiscovery): SkillManifest {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n // Following symlinks makes a cycle reachable, and this walk records every\n // directory it visits, so an unguarded cycle would exhaust the stack and the\n // manifest together. Real paths are what a cycle repeats.\n const visited = new Set<string>();\n const walk = (directory: string, depth: number): void => {\n if (!fs.existsSync(directory)) return;\n const realDirectory = fs.realpathSync(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = fs.statSync(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {\n const candidate = path.join(directory, entry.name);\n const kind = resolveEntryKind(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = fs.readFileSync(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = fs.statSync(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\n/** Cached skill metadata and exact files, ready for Pi without a second tree walk. */\nexport function discoverSkills(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): NamedResource[] {\n if (!fs.existsSync(root)) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = readSkillManifest(manifestPath, root, discovery);\n const manifest = cached ?? scanSkillManifest(root, discovery);\n if (!cached) writeSkillManifest(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function scanSkillManifestAsync(root: string, discovery: PluginSkillDiscovery): Promise<SkillManifest> {\n const directories: SkillManifestDirectory[] = [];\n const files: SkillManifestFile[] = [];\n const visited = new Set<string>();\n const walk = async (directory: string, depth: number): Promise<void> => {\n let entries: fs.Dirent[];\n try {\n const realDirectory = await fs.promises.realpath(directory);\n if (visited.has(realDirectory)) return;\n visited.add(realDirectory);\n const directoryStat = await fs.promises.stat(directory);\n directories.push({ path: directory, mtimeMs: directoryStat.mtimeMs, ctimeMs: directoryStat.ctimeMs });\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return;\n throw error;\n }\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n const kind = await resolveEntryKindAsync(entry, candidate);\n if (!kind) continue;\n if (kind.directory) {\n if (discovery === 'recursive' || depth === 0) await walk(candidate, depth + 1);\n continue;\n }\n if (!kind.file || entry.name !== 'SKILL.md' || (discovery === 'direct-children' && depth !== 1)) {\n continue;\n }\n const content = await fs.promises.readFile(candidate, 'utf8');\n const { attributes } = splitFrontmatter(content);\n const stat = await fs.promises.stat(candidate);\n files.push({\n path: candidate,\n name: skillName(candidate, attributes),\n ...(typeof attributes.description === 'string' ? { description: attributes.description.trim() } : {}),\n digest: createHash('sha256').update(content).digest('hex'),\n size: stat.size,\n mtimeMs: stat.mtimeMs,\n ctimeMs: stat.ctimeMs,\n });\n }\n };\n const resolvedRoot = path.resolve(root);\n await walk(resolvedRoot, 0);\n files.sort((left, right) => left.path.localeCompare(right.path));\n directories.sort((left, right) => left.path.localeCompare(right.path));\n return { version: SKILL_MANIFEST_VERSION, root: resolvedRoot, discovery, files, directories };\n}\n\nexport async function discoverSkillsAsync(\n repoRoot: string,\n root: string,\n discovery: PluginSkillDiscovery = 'recursive',\n cacheDirectory?: string,\n): Promise<NamedResource[]> {\n if (!(await pathExists(root))) return [];\n const manifestPath = skillManifestPath(repoRoot, root, discovery, cacheDirectory);\n const cached = await readSkillManifestAsync(manifestPath, root, discovery);\n const manifest = cached ?? (await scanSkillManifestAsync(root, discovery));\n if (!cached) await writeSkillManifestAsync(manifestPath, manifest);\n return manifest.files.map(({ name, path: filePath, description, digest }) => ({\n name,\n path: filePath,\n digest,\n ...(description === undefined ? {} : { description }),\n }));\n}\n\nasync function markdownFilesAsync(directory: string): Promise<string[]> {\n let entries: fs.Dirent[];\n try {\n entries = await fs.promises.readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];\n throw error;\n }\n const results: string[] = [];\n for (const entry of entries) {\n const candidate = path.join(directory, entry.name);\n if (entry.isDirectory()) results.push(...(await markdownFilesAsync(candidate)));\n if (entry.isFile() && entry.name.endsWith('.md')) results.push(candidate);\n }\n return results;\n}\n\nasync function frontmatterNameAsync(filePath: string): Promise<string> {\n const { attributes } = splitFrontmatter(await fs.promises.readFile(filePath, 'utf8'));\n if (typeof attributes.name !== 'string') throw new Error(`Resource requires a name: ${filePath}`);\n return attributes.name;\n}\n\nasync function assertUniqueAsync(resources: NamedResource[], kind: string): Promise<void> {\n const seen = new Map<string, string>();\n const digestByName = new Map<string, string>();\n for (const resource of resources) {\n const previous = seen.get(resource.name);\n const digest =\n resource.digest ??\n createHash('sha256')\n .update(await fs.promises.readFile(resource.path))\n .digest('hex');\n if (previous && digestByName.get(resource.name) !== digest) {\n throw new Error(`Conflicting ${kind} \"${resource.name}\": ${previous} and ${resource.path}`);\n }\n seen.set(resource.name, resource.path);\n digestByName.set(resource.name, digest);\n }\n}\n\nfunction dispatcherAgentSource(): string {\n const attributes: JsonObject = {\n name: DISPATCHER_AGENT_NAME,\n description: 'Selects and launches Agiflow workflows for one loop pass without implementing the work.',\n thinking: 'high',\n systemPromptMode: 'replace',\n inheritProjectContext: true,\n inheritSkills: true,\n tools: DISPATCHER_TOOLS.join(', '),\n // No feature extension is named here. Team inherits the ordered child\n // composition projected from the selected layers for every helper process.\n defaultContext: 'fresh',\n defaultProgress: false,\n };\n const body = [\n 'You are the Agiflow workflow dispatcher.',\n 'Reason about the supplied dispatch context and launch eligible workflows.',\n 'Launch workflows without monitoring them. After dispatching, report and exit.',\n 'Follow the task restrictions exactly. Do not implement jobs or edit repository files.',\n ].join('\\n');\n return `---\\n${stringify(attributes).trim()}\\n---\\n\\n${body}\\n`;\n}\n\nexport function mergeMcpConfigs(configPaths: string[]): JsonObject {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n if (!fs.existsSync(configPath)) continue;\n const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nexport async function mergeMcpConfigsAsync(configPaths: string[]): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const sources = new Map<string, string>();\n for (const configPath of configPaths) {\n let content: string;\n try {\n content = await fs.promises.readFile(configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n const config = JSON.parse(content) as JsonObject;\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${sources.get(name)} and ${configPath}`);\n }\n servers[name] = definition;\n sources.set(name, configPath);\n }\n }\n return merged;\n}\n\nasync function mergeProjectedMcpConfigs(\n sources: readonly PoMcpProjectionSource[],\n stagingDirectory: string,\n): Promise<JsonObject> {\n const merged: JsonObject = { mcpServers: {} };\n const servers = merged.mcpServers as Record<string, unknown>;\n const origins = new Map<string, string>();\n // The person's own entries are defaults: a repository or plugin entry with the same name replaces them.\n const userOwned = new Set<string>();\n\n for (const source of sources) {\n let config: JsonObject;\n if (source.format === 'agent-plugin-v1') {\n config = normalizeAgentPluginMcpSource(source, {\n stagingDirectory,\n // The generated file is consumed by external MCP clients. Keep wrapper\n // names there; Po strips its own in-process wrapper at runtime.\n stripProxyWrappers: false,\n }).claudeConfig;\n } else {\n let content: string;\n try {\n content = await fs.promises.readFile(source.configPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n config = JSON.parse(content) as JsonObject;\n }\n\n const incoming = (config.mcpServers ?? {}) as Record<string, unknown>;\n for (const [name, definition] of Object.entries(incoming)) {\n const previous = servers[name];\n if (previous && !userOwned.has(name) && JSON.stringify(previous) !== JSON.stringify(definition)) {\n throw new Error(`Conflicting MCP server \"${name}\": ${origins.get(name)} and ${source.configPath}`);\n }\n servers[name] = definition;\n origins.set(name, source.configPath);\n if (source.owner === 'user') userOwned.add(name);\n else userOwned.delete(name);\n }\n }\n\n return merged;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Matches a resource name against a subset filter. Undefined keeps everything. */\nfunction keepsName(allowed: string[] | undefined, name: string): boolean {\n if (!allowed) return true;\n return allowed.some((pattern) =>\n pattern.includes('*')\n ? new RegExp(`^${pattern.split('*').map(escapeRegExp).join('.*')}$`).test(name)\n : pattern === name,\n );\n}\n\n/** Stages only the MCP slice shared by Po and compatibility frontends. */\nexport async function stageMcpResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: McpResourceOptions,\n): Promise<StagedMcpResources> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n const pluginMcpConfigPaths: string[] = [];\n const pluginMcpSources: PoMcpProjectionSource[] = [];\n const mcpSources: PoMcpProjectionSource[] = [];\n const pluginDataRoot = options.pluginDataRoot ?? path.join(globalPoConfigDirectory(), PLUGIN_DATA_DIRECTORY);\n const repositoryMcpPath = path.join(repoRoot, '.mcp.json');\n\n await fs.promises.mkdir(options.temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(options.temporaryDirectory, 0o700);\n // First, so every later layer overrides it.\n if (options.enabled && options.userMcpConfigPath && (await pathExists(options.userMcpConfigPath))) {\n const content = await fs.promises.readFile(options.userMcpConfigPath);\n mcpSources.push({\n sourceId: 'user:mcp.json',\n owner: 'user',\n format: 'native',\n configPath: options.userMcpConfigPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n if (options.enabled && (await pathExists(repositoryMcpPath))) {\n const content = await fs.promises.readFile(repositoryMcpPath);\n mcpSources.push({\n sourceId: 'repository:.mcp.json',\n owner: 'repository',\n format: 'native',\n configPath: repositoryMcpPath,\n contentDigest: createHash('sha256').update(content).digest('hex'),\n });\n }\n\n if (options.enabled) {\n for (const entry of pluginEntries) {\n const source = await pluginMcpSource(entry, pluginDataRoot);\n if (!source) continue;\n mcpSources.push(source);\n pluginMcpSources.push(source);\n pluginMcpConfigPaths.push(source.configPath);\n }\n }\n\n let mcpConfigPath: string | undefined;\n if (options.enabled) {\n mcpConfigPath = path.join(options.temporaryDirectory, 'mcp.json');\n const merged = await applyMcpAllowlist(\n await mergeProjectedMcpConfigs(mcpSources, options.temporaryDirectory),\n options.mcpAllowlist,\n repoRoot,\n options.temporaryDirectory,\n );\n await fs.promises.writeFile(mcpConfigPath, `${JSON.stringify(merged, null, 2)}\\n`, { mode: 0o600 });\n }\n\n const projectionWithoutRuntimePath = {\n version: PO_MCP_PROJECTION_VERSION,\n enabled: options.enabled,\n repoRoot,\n ...(mcpConfigPath ? { generatedConfigPath: mcpConfigPath } : {}),\n sources: options.enabled ? mcpSources : [],\n ...(options.mcpAllowlist ? { allowlist: structuredClone(options.mcpAllowlist) } : {}),\n } satisfies Omit<PoMcpProjection, 'fingerprint' | 'stagingDirectory'>;\n\n return {\n mcpConfigPath,\n mcpProjection: {\n ...projectionWithoutRuntimePath,\n stagingDirectory: options.temporaryDirectory,\n fingerprint: projectionFingerprint(projectionWithoutRuntimePath),\n },\n pluginMcpSources,\n pluginMcpConfigPaths,\n };\n}\n\n/**\n * Stages every resource the selected domains contribute, ready for one Pi session.\n *\n * The caller owns the returned cleanup(): the temporary directory holding agents\n * and the generated MCP config has to outlive this function and be removed once\n * the session that reads it is done.\n */\nexport async function collectResources(\n repoRoot: string,\n plugins: Array<string | PluginEntry>,\n options: HarnessResourceOptions,\n): Promise<HarnessResources & { skillSources: NamedResource[] }> {\n const pluginEntries: PluginEntry[] = plugins.map((plugin) =>\n typeof plugin === 'string' ? { directory: plugin } : plugin,\n );\n // A caller-supplied directory is owned by the caller: it is either a live\n // session's directory or the synced one, and removing it here would delete\n // resources that outlive this collection.\n const ownsDirectory = options.temporaryDirectory === undefined;\n const temporaryDirectory = options.temporaryDirectory ?? (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'po-')));\n await fs.promises.mkdir(temporaryDirectory, { mode: 0o700, recursive: true });\n await fs.promises.chmod(temporaryDirectory, 0o700);\n const sharedSkills = path.join(repoRoot, '.claude', 'skills');\n // A domain can opt out of the always-on shared skills to keep its context small.\n const sharedSkillSources =\n options.sharedSkills === false\n ? []\n : await discoverSkillsAsync(repoRoot, sharedSkills, 'recursive', options.skillCacheDirectory);\n const skillDirectories: string[] = [];\n const skillSources: NamedResource[] = [];\n const agentSources: Array<{ name: string; path: string }> = [];\n\n for (const entry of pluginEntries) {\n const pluginDirectory = entry.directory;\n const skills = path.join(pluginDirectory, 'skills');\n if (await pathExists(skills)) {\n const found = (\n await discoverSkillsAsync(repoRoot, skills, entry.skillDiscovery ?? 'recursive', options.skillCacheDirectory)\n ).filter((skill) => keepsName(entry.skills, skill.name));\n // Exact files let Pi skip another recursive traversal and make a plugin\n // subset unambiguous without staging copies of the skill bodies.\n skillDirectories.push(...found.map((skill) => skill.path));\n skillSources.push(...found);\n }\n const agents = path.join(pluginDirectory, 'agents');\n const agentFiles = await markdownFilesAsync(agents);\n const agentNames = await Promise.all(agentFiles.map((filePath) => frontmatterNameAsync(filePath)));\n agentSources.push(\n ...agentFiles\n .map((filePath, index) => ({ name: agentNames[index] ?? '', path: filePath }))\n .filter((agent) => keepsName(entry.agents, agent.name)),\n );\n }\n\n await assertUniqueAsync(skillSources, 'skill');\n await assertUniqueAsync(sharedSkillSources, 'skill');\n // Pi keeps the first skill for a duplicated name. Selected domain plugins are\n // authoritative; shared Claude skills remain fallbacks for names no plugin owns.\n const pluginSkillNames = new Set(skillSources.map((skill) => skill.name));\n const fallbackSharedSkills = sharedSkillSources.filter((skill) => !pluginSkillNames.has(skill.name));\n skillDirectories.push(...fallbackSharedSkills.map((skill) => skill.path));\n skillSources.push(...fallbackSharedSkills);\n\n await assertUniqueAsync(agentSources, 'agent');\n if (agentSources.some((source) => source.name === DISPATCHER_AGENT_NAME)) {\n throw new Error(`Conflicting agent \"${DISPATCHER_AGENT_NAME}\": reserved by the agent harness`);\n }\n\n const agentDirectories: string[] = [];\n const outputDirectory = path.join(temporaryDirectory, 'agents');\n await fs.promises.rm(outputDirectory, { recursive: true, force: true });\n if (options.agents) {\n await fs.promises.mkdir(outputDirectory, { mode: 0o700 });\n for (const source of agentSources) {\n const adapted = adaptAgentDefinition(await fs.promises.readFile(source.path, 'utf8'));\n await fs.promises.writeFile(\n path.join(outputDirectory, `${assertSafeAgentName(adapted.name)}.md`),\n adapted.content,\n { mode: 0o600 },\n );\n }\n await fs.promises.writeFile(path.join(outputDirectory, `${DISPATCHER_AGENT_NAME}.md`), dispatcherAgentSource(), {\n mode: 0o600,\n });\n agentDirectories.push(outputDirectory);\n }\n\n const { mcpConfigPath, mcpProjection, pluginMcpSources, pluginMcpConfigPaths } = await stageMcpResources(\n repoRoot,\n pluginEntries,\n {\n enabled: options.mcp,\n temporaryDirectory,\n ...(options.mcpAllowlist ? { mcpAllowlist: options.mcpAllowlist } : {}),\n ...(options.pluginDataRoot ? { pluginDataRoot: options.pluginDataRoot } : {}),\n ...(options.userMcpConfigPath ? { userMcpConfigPath: options.userMcpConfigPath } : {}),\n },\n );\n\n return {\n temporaryDirectory,\n skillDirectories,\n skillSources,\n skillCount: skillSources.length,\n agentCount: agentSources.length,\n agentDirectories,\n mcpConfigPath,\n mcpProjection,\n pluginMcpSources,\n pluginMcpConfigPaths,\n cleanup: () =>\n ownsDirectory ? fs.promises.rm(temporaryDirectory, { recursive: true, force: true }) : Promise.resolve(),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,MAAM,mBAAmB;;AAGzB,SAAgB,kBAAkB,OAAe,UAA0B;CACzE,MAAM,aAAa,MAChB,UAAU,MAAM,CAAC,CACjB,QAAQ,qBAAqB,EAAE,CAAC,CAChC,QAAQ,sBAAsB,GAAG,CAAC,CAClC,QAAQ,qBAAqB,EAAE,CAAC,CAChC,MAAM,GAAG,gBAAgB,CAAC,CAC1B,QAAQ,aAAa,EAAE;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