@agimon-ai/doompi-config 0.0.1-alpha.48 → 0.0.1-alpha.49
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/adapters/piConfig.cjs +1 -1
- package/dist/adapters/piConfig.cjs.map +1 -1
- package/dist/adapters/piConfig.d.cts +14 -1
- package/dist/adapters/piConfig.d.cts.map +1 -1
- package/dist/adapters/piConfig.d.mts +14 -1
- package/dist/adapters/piConfig.d.mts.map +1 -1
- package/dist/adapters/piConfig.mjs +1 -1
- package/dist/adapters/piConfig.mjs.map +1 -1
- package/dist/config/piConfig.cjs +1 -1
- package/dist/config/piConfig.d.cts +3 -2
- package/dist/config/piConfig.d.mts +3 -2
- package/dist/config/piConfig.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +1 -1
- package/dist/services/imageSettings.cjs +2 -0
- package/dist/services/imageSettings.cjs.map +1 -0
- package/dist/services/imageSettings.d.cts +23 -0
- package/dist/services/imageSettings.d.cts.map +1 -0
- package/dist/services/imageSettings.d.mts +23 -0
- package/dist/services/imageSettings.d.mts.map +1 -0
- package/dist/services/imageSettings.mjs +2 -0
- package/dist/services/imageSettings.mjs.map +1 -0
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs");let
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./atomicJson.cjs"),n=require("../services/imageSettings.cjs");let r=require("node:fs");r=e.__toESM(r,1);let i=require("node:path");i=e.__toESM(i,1);let a=require("node:os");a=e.__toESM(a,1);const o=`settings.json`;function s(e){let t=i.default.join(e,`.pi`,`agent`);if(e!==a.default.homedir())return t;let n=process.env.PI_CODING_AGENT_DIR?.trim();return n?n===`~`?e:n.startsWith(`~/`)?i.default.join(e,n.slice(2)):i.default.resolve(n):t}function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=c(t)&&c(r)?l(t,r):r}return n}function u(e){if(!r.default.existsSync(e))return{};let t;try{t=JSON.parse(r.default.readFileSync(e,`utf8`))}catch(t){throw Error(`Could not parse Pi settings at ${e}`,{cause:t})}if(!c(t))throw Error(`Pi settings at ${e} must be a JSON object`);return t}async function d(e){let t;try{t=JSON.parse(await r.default.promises.readFile(e,`utf8`))}catch(t){if(t.code===`ENOENT`)return{};throw Error(`Could not parse Pi settings at ${e}`,{cause:t})}if(!c(t))throw Error(`Pi settings at ${e} must be a JSON object`);return t}function f(e){return e.reduce((e,t)=>l(e,u(t)),{})}async function p(e){return(await Promise.all(e.map(d))).reduce(l,{})}function m(e){return typeof e==`function`?e():e}function h(e,t=a.default.homedir(),n=s(t)){return{canonicalUser:i.default.join(n,o),canonicalProject:i.default.join(e,`.pi`,o),legacyUser:[i.default.join(t,`.pi`,o)],legacyProject:[i.default.join(e,`pi`,o)]}}function g(e){let t=h(e.repoRoot,e.homeDirectory),n=[...t.legacyUser,...e.userConfigPaths??[],t.canonicalUser],r=[...t.legacyProject,...e.projectConfigPaths??[],t.canonicalProject],i=e.defaults??{},a=f(n),o=m(e.isProjectTrusted)?f(r):{};return[i,a,e.overlay??{},o,e.environment??{},e.cli??{},e.programmatic??{}].reduce(l,{})}async function _(e){let t=h(e.repoRoot,e.homeDirectory),n=[...t.legacyUser,...e.userConfigPaths??[],t.canonicalUser],r=[...t.legacyProject,...e.projectConfigPaths??[],t.canonicalProject],[i,a]=await Promise.all([p(n),m(e.isProjectTrusted)?p(r):Promise.resolve({})]);return[e.defaults??{},i,e.overlay??{},a,e.environment??{},e.cli??{},e.programmatic??{}].reduce(l,{})}function v(e){return{legacy:i.default.join(e,`.pi`,o),canonical:i.default.join(s(e),o)}}function y(e=a.default.homedir()){return v(e).canonical}function b(e=a.default.homedir()){let t=v(e);return n.parsePiImageSettings(f([t.legacy,t.canonical]))}function x(e,r=a.default.homedir()){let i=v(r);return t.writePrivateAtomicJson(i.canonical,n.applyPiImageSettings(u(i.canonical),e)),b(r)}exports.loadPiConfig=g,exports.loadPiConfigAsync=_,exports.loadPiImageSettings=b,exports.piConfigPaths=h,exports.piImageSettingsPath=y,exports.savePiImageSettings=x;
|
|
2
2
|
//# sourceMappingURL=piConfig.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piConfig.cjs","names":["path","os","fs"],"sources":["../../src/adapters/piConfig.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport type { PiConfig, PiConfigLoadOptions, PiConfigPaths } from '../schemas/config/schema.ts';\n\nconst SETTINGS_FILE_NAME = 'settings.json';\nconst CONFIG_DIR_NAME = '.pi';\nconst AGENT_DIR_NAME = 'agent';\nconst PI_CODING_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst LEGACY_CONFIG_DIR_NAME = 'pi';\n\nfunction defaultAgentDirectory(homeDirectory: string): string {\n const fallback = path.join(homeDirectory, CONFIG_DIR_NAME, AGENT_DIR_NAME);\n if (homeDirectory !== os.homedir()) return fallback;\n const configured = process.env[PI_CODING_AGENT_DIR_ENV]?.trim();\n if (!configured) return fallback;\n if (configured === '~') return homeDirectory;\n if (configured.startsWith('~/')) return path.join(homeDirectory, configured.slice(2));\n return path.resolve(configured);\n}\nfunction isObject(value: unknown): value is PiConfig {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction mergeConfig(base: PiConfig, override: PiConfig): PiConfig {\n const result: PiConfig = { ...base };\n for (const [key, value] of Object.entries(override)) {\n const current = result[key];\n result[key] = isObject(current) && isObject(value) ? mergeConfig(current, value) : value;\n }\n return result;\n}\n\nfunction readConfig(filePath: string): PiConfig {\n if (!fs.existsSync(filePath)) return {};\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n } catch (error) {\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nasync function readConfigAsync(filePath: string): Promise<PiConfig> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(await fs.promises.readFile(filePath, 'utf8'));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return {};\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nfunction readConfigPaths(paths: readonly string[]): PiConfig {\n return paths.reduce<PiConfig>((config, filePath) => mergeConfig(config, readConfig(filePath)), {});\n}\n\nasync function readConfigPathsAsync(paths: readonly string[]): Promise<PiConfig> {\n const layers = await Promise.all(paths.map(readConfigAsync));\n return layers.reduce<PiConfig>(mergeConfig, {});\n}\n\nfunction projectIsTrusted(value: PiConfigLoadOptions['isProjectTrusted']): boolean {\n return typeof value === 'function' ? value() : value;\n}\n\nexport function piConfigPaths(\n repoRoot: string,\n homeDirectory = os.homedir(),\n agentDirectory = defaultAgentDirectory(homeDirectory),\n): PiConfigPaths {\n return {\n canonicalUser: path.join(agentDirectory, SETTINGS_FILE_NAME),\n canonicalProject: path.join(repoRoot, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),\n legacyUser: [path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n legacyProject: [path.join(repoRoot, LEGACY_CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n };\n}\n\nexport function loadPiConfig(options: PiConfigLoadOptions): PiConfig {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const defaults = options.defaults ?? {};\n const user = readConfigPaths(userPaths);\n const trustedProject = projectIsTrusted(options.isProjectTrusted) ? readConfigPaths(projectPaths) : {};\n return [\n defaults,\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n\nexport async function loadPiConfigAsync(options: PiConfigLoadOptions): Promise<PiConfig> {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const [user, trustedProject] = await Promise.all([\n readConfigPathsAsync(userPaths),\n projectIsTrusted(options.isProjectTrusted) ? readConfigPathsAsync(projectPaths) : Promise.resolve({}),\n ]);\n return [\n options.defaults ?? {},\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n"],"mappings":"qLAKA,MAAM,EAAqB,gBAM3B,SAAS,EAAsB,EAA+B,CAC5D,IAAM,EAAWA,EAAAA,QAAK,KAAK,EAAe,MAAiB,OAAc,EACzE,GAAI,IAAkBC,EAAAA,QAAG,QAAQ,EAAG,OAAO,EAC3C,IAAM,EAAa,QAAQ,IAAI,qBAA0B,KAAK,EAI9D,OAHK,EACD,IAAe,IAAY,EAC3B,EAAW,WAAW,IAAI,EAAUD,EAAAA,QAAK,KAAK,EAAe,EAAW,MAAM,CAAC,CAAC,EAC7EA,EAAAA,QAAK,QAAQ,CAAU,EAHN,CAI1B,CACA,SAAS,EAAS,EAAmC,CACnD,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAEA,SAAS,EAAY,EAAgB,EAA8B,CACjE,IAAM,EAAmB,CAAE,GAAG,CAAK,EACnC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAQ,EAAG,CACnD,IAAM,EAAU,EAAO,GACvB,EAAO,GAAO,EAAS,CAAO,GAAK,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O,CAAC,EAChB,EAAQ,cAAgB,CAAC,CAC3B,CAAC,CAAC,OAAO,EAAa,CAAC,CAAC,CAC1B"}
|
|
1
|
+
{"version":3,"file":"piConfig.cjs","names":["path","os","fs","parsePiImageSettings","applyPiImageSettings"],"sources":["../../src/adapters/piConfig.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport type { PiConfig, PiConfigLoadOptions, PiConfigPaths } from '../schemas/config/schema.ts';\nimport {\n applyPiImageSettings,\n parsePiImageSettings,\n type PiImageSettings,\n type PiImageSettingsUpdate,\n} from '../services/imageSettings.ts';\nimport { writePrivateAtomicJson } from './atomicJson.ts';\n\nconst SETTINGS_FILE_NAME = 'settings.json';\nconst CONFIG_DIR_NAME = '.pi';\nconst AGENT_DIR_NAME = 'agent';\nconst PI_CODING_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst LEGACY_CONFIG_DIR_NAME = 'pi';\n\nfunction defaultAgentDirectory(homeDirectory: string): string {\n const fallback = path.join(homeDirectory, CONFIG_DIR_NAME, AGENT_DIR_NAME);\n if (homeDirectory !== os.homedir()) return fallback;\n const configured = process.env[PI_CODING_AGENT_DIR_ENV]?.trim();\n if (!configured) return fallback;\n if (configured === '~') return homeDirectory;\n if (configured.startsWith('~/')) return path.join(homeDirectory, configured.slice(2));\n return path.resolve(configured);\n}\nfunction isObject(value: unknown): value is PiConfig {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction mergeConfig(base: PiConfig, override: PiConfig): PiConfig {\n const result: PiConfig = { ...base };\n for (const [key, value] of Object.entries(override)) {\n const current = result[key];\n result[key] = isObject(current) && isObject(value) ? mergeConfig(current, value) : value;\n }\n return result;\n}\n\nfunction readConfig(filePath: string): PiConfig {\n if (!fs.existsSync(filePath)) return {};\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n } catch (error) {\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nasync function readConfigAsync(filePath: string): Promise<PiConfig> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(await fs.promises.readFile(filePath, 'utf8'));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return {};\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nfunction readConfigPaths(paths: readonly string[]): PiConfig {\n return paths.reduce<PiConfig>((config, filePath) => mergeConfig(config, readConfig(filePath)), {});\n}\n\nasync function readConfigPathsAsync(paths: readonly string[]): Promise<PiConfig> {\n const layers = await Promise.all(paths.map(readConfigAsync));\n return layers.reduce<PiConfig>(mergeConfig, {});\n}\n\nfunction projectIsTrusted(value: PiConfigLoadOptions['isProjectTrusted']): boolean {\n return typeof value === 'function' ? value() : value;\n}\n\nexport function piConfigPaths(\n repoRoot: string,\n homeDirectory = os.homedir(),\n agentDirectory = defaultAgentDirectory(homeDirectory),\n): PiConfigPaths {\n return {\n canonicalUser: path.join(agentDirectory, SETTINGS_FILE_NAME),\n canonicalProject: path.join(repoRoot, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),\n legacyUser: [path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n legacyProject: [path.join(repoRoot, LEGACY_CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n };\n}\n\nexport function loadPiConfig(options: PiConfigLoadOptions): PiConfig {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const defaults = options.defaults ?? {};\n const user = readConfigPaths(userPaths);\n const trustedProject = projectIsTrusted(options.isProjectTrusted) ? readConfigPaths(projectPaths) : {};\n return [\n defaults,\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n\nexport async function loadPiConfigAsync(options: PiConfigLoadOptions): Promise<PiConfig> {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const [user, trustedProject] = await Promise.all([\n readConfigPathsAsync(userPaths),\n projectIsTrusted(options.isProjectTrusted) ? readConfigPathsAsync(projectPaths) : Promise.resolve({}),\n ]);\n return [\n options.defaults ?? {},\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n\n/**\n * Where the image limits are read from and written to.\n *\n * The user layer only. Pi merges a trusted project settings.json over it, but\n * these limits describe one machine's tolerance for image payloads rather than\n * one repository's, and the cockpit page that writes them has no repository\n * scope to offer. The legacy user path is still read, because a machine that\n * has not been migrated still answers from it.\n */\nfunction userSettingsPaths(homeDirectory: string): { legacy: string; canonical: string } {\n return {\n legacy: path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),\n canonical: path.join(defaultAgentDirectory(homeDirectory), SETTINGS_FILE_NAME),\n };\n}\n\n/** The file a change lands in; Pi's own settings toggle writes the same one. */\nexport function piImageSettingsPath(homeDirectory = os.homedir()): string {\n return userSettingsPaths(homeDirectory).canonical;\n}\n\nexport function loadPiImageSettings(homeDirectory = os.homedir()): PiImageSettings {\n const paths = userSettingsPaths(homeDirectory);\n return parsePiImageSettings(readConfigPaths([paths.legacy, paths.canonical]));\n}\n\n/**\n * Writes the changed keys back and reports the limits that now apply.\n *\n * Read-modify-write on Pi's own file, so a save races a concurrent Pi settings\n * save rather than merging with it. Pi writes only the fields its UI touched,\n * as this does, which keeps the window to the one setting being changed on\n * both sides at once.\n */\nexport function savePiImageSettings(update: PiImageSettingsUpdate, homeDirectory = os.homedir()): PiImageSettings {\n const paths = userSettingsPaths(homeDirectory);\n writePrivateAtomicJson(paths.canonical, applyPiImageSettings(readConfig(paths.canonical), update));\n return loadPiImageSettings(homeDirectory);\n}\n"],"mappings":"8PAYA,MAAM,EAAqB,gBAM3B,SAAS,EAAsB,EAA+B,CAC5D,IAAM,EAAWA,EAAAA,QAAK,KAAK,EAAe,MAAiB,OAAc,EACzE,GAAI,IAAkBC,EAAAA,QAAG,QAAQ,EAAG,OAAO,EAC3C,IAAM,EAAa,QAAQ,IAAI,qBAA0B,KAAK,EAI9D,OAHK,EACD,IAAe,IAAY,EAC3B,EAAW,WAAW,IAAI,EAAUD,EAAAA,QAAK,KAAK,EAAe,EAAW,MAAM,CAAC,CAAC,EAC7EA,EAAAA,QAAK,QAAQ,CAAU,EAHN,CAI1B,CACA,SAAS,EAAS,EAAmC,CACnD,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAEA,SAAS,EAAY,EAAgB,EAA8B,CACjE,IAAM,EAAmB,CAAE,GAAG,CAAK,EACnC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAQ,EAAG,CACnD,IAAM,EAAU,EAAO,GACvB,EAAO,GAAO,EAAS,CAAO,GAAK,EAAS,CAAK,EAAI,EAAY,EAAS,CAAK,EAAI,CACrF,CACA,OAAO,CACT,CAEA,SAAS,EAAW,EAA4B,CAC9C,GAAI,CAACE,EAAAA,QAAG,WAAW,CAAQ,EAAG,MAAO,CAAC,EACtC,IAAI,EACJ,GAAI,CACF,EAAS,KAAK,MAAMA,EAAAA,QAAG,aAAa,EAAU,MAAM,CAAC,CACvD,OAAS,EAAO,CACd,MAAU,MAAM,kCAAkC,IAAY,CAAE,MAAO,CAAM,CAAC,CAChF,CACA,GAAI,CAAC,EAAS,CAAM,EAAG,MAAU,MAAM,kBAAkB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BA,EAAAA,QAAG,QAAQ,EAAoB,CACjF,IAAM,EAAQ,EAAkB,CAAa,EAC7C,OAAOE,EAAAA,qBAAqB,EAAgB,CAAC,EAAM,OAAQ,EAAM,SAAS,CAAC,CAAC,CAC9E,CAUA,SAAgB,EAAoB,EAA+B,EAAgBF,EAAAA,QAAG,QAAQ,EAAoB,CAChH,IAAM,EAAQ,EAAkB,CAAa,EAE7C,OADA,EAAA,uBAAuB,EAAM,UAAWG,EAAAA,qBAAqB,EAAW,EAAM,SAAS,EAAG,CAAM,CAAC,EAC1F,EAAoB,CAAa,CAC1C"}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { PiConfig, PiConfigLoadOptions, PiConfigPaths } from "../schemas/config/schema.cjs";
|
|
2
|
+
import { PiImageSettings, PiImageSettingsUpdate } from "../services/imageSettings.cjs";
|
|
2
3
|
//#region src/adapters/piConfig.d.ts
|
|
3
4
|
declare function piConfigPaths(repoRoot: string, homeDirectory?: string, agentDirectory?: string): PiConfigPaths;
|
|
4
5
|
declare function loadPiConfig(options: PiConfigLoadOptions): PiConfig;
|
|
5
6
|
declare function loadPiConfigAsync(options: PiConfigLoadOptions): Promise<PiConfig>;
|
|
7
|
+
/** The file a change lands in; Pi's own settings toggle writes the same one. */
|
|
8
|
+
declare function piImageSettingsPath(homeDirectory?: string): string;
|
|
9
|
+
declare function loadPiImageSettings(homeDirectory?: string): PiImageSettings;
|
|
10
|
+
/**
|
|
11
|
+
* Writes the changed keys back and reports the limits that now apply.
|
|
12
|
+
*
|
|
13
|
+
* Read-modify-write on Pi's own file, so a save races a concurrent Pi settings
|
|
14
|
+
* save rather than merging with it. Pi writes only the fields its UI touched,
|
|
15
|
+
* as this does, which keeps the window to the one setting being changed on
|
|
16
|
+
* both sides at once.
|
|
17
|
+
*/
|
|
18
|
+
declare function savePiImageSettings(update: PiImageSettingsUpdate, homeDirectory?: string): PiImageSettings;
|
|
6
19
|
//#endregion
|
|
7
|
-
export { loadPiConfig, loadPiConfigAsync, piConfigPaths };
|
|
20
|
+
export { loadPiConfig, loadPiConfigAsync, loadPiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings };
|
|
8
21
|
//# sourceMappingURL=piConfig.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piConfig.d.cts","names":[],"sources":["../../src/adapters/piConfig.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"piConfig.d.cts","names":[],"sources":["../../src/adapters/piConfig.ts"],"mappings":";;;iBA6EgB,cACd,kBACA,wBACA,0BACC;iBASa,aAAa,SAAS,sBAAsB;iBAkBtC,kBAAkB,SAAS,sBAAsB,QAAQ;;iBAoC/D,oBAAoB;iBAIpB,oBAAoB,yBAA+B;;;;;;;;;iBAanD,oBAAoB,QAAQ,uBAAuB,yBAA+B"}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { PiConfig, PiConfigLoadOptions, PiConfigPaths } from "../schemas/config/schema.mjs";
|
|
2
|
+
import { PiImageSettings, PiImageSettingsUpdate } from "../services/imageSettings.mjs";
|
|
2
3
|
//#region src/adapters/piConfig.d.ts
|
|
3
4
|
declare function piConfigPaths(repoRoot: string, homeDirectory?: string, agentDirectory?: string): PiConfigPaths;
|
|
4
5
|
declare function loadPiConfig(options: PiConfigLoadOptions): PiConfig;
|
|
5
6
|
declare function loadPiConfigAsync(options: PiConfigLoadOptions): Promise<PiConfig>;
|
|
7
|
+
/** The file a change lands in; Pi's own settings toggle writes the same one. */
|
|
8
|
+
declare function piImageSettingsPath(homeDirectory?: string): string;
|
|
9
|
+
declare function loadPiImageSettings(homeDirectory?: string): PiImageSettings;
|
|
10
|
+
/**
|
|
11
|
+
* Writes the changed keys back and reports the limits that now apply.
|
|
12
|
+
*
|
|
13
|
+
* Read-modify-write on Pi's own file, so a save races a concurrent Pi settings
|
|
14
|
+
* save rather than merging with it. Pi writes only the fields its UI touched,
|
|
15
|
+
* as this does, which keeps the window to the one setting being changed on
|
|
16
|
+
* both sides at once.
|
|
17
|
+
*/
|
|
18
|
+
declare function savePiImageSettings(update: PiImageSettingsUpdate, homeDirectory?: string): PiImageSettings;
|
|
6
19
|
//#endregion
|
|
7
|
-
export { loadPiConfig, loadPiConfigAsync, piConfigPaths };
|
|
20
|
+
export { loadPiConfig, loadPiConfigAsync, loadPiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings };
|
|
8
21
|
//# sourceMappingURL=piConfig.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piConfig.d.mts","names":[],"sources":["../../src/adapters/piConfig.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"piConfig.d.mts","names":[],"sources":["../../src/adapters/piConfig.ts"],"mappings":";;;iBA6EgB,cACd,kBACA,wBACA,0BACC;iBASa,aAAa,SAAS,sBAAsB;iBAkBtC,kBAAkB,SAAS,sBAAsB,QAAQ;;iBAoC/D,oBAAoB;iBAIpB,oBAAoB,yBAA+B;;;;;;;;;iBAanD,oBAAoB,QAAQ,uBAAuB,yBAA+B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:fs";import
|
|
1
|
+
import{writePrivateAtomicJson as e}from"./atomicJson.mjs";import{applyPiImageSettings as t,parsePiImageSettings as n}from"../services/imageSettings.mjs";import r from"node:fs";import i from"node:path";import a from"node:os";const o=`settings.json`;function s(e){let t=i.join(e,`.pi`,`agent`);if(e!==a.homedir())return t;let n=process.env.PI_CODING_AGENT_DIR?.trim();return n?n===`~`?e:n.startsWith(`~/`)?i.join(e,n.slice(2)):i.resolve(n):t}function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=c(t)&&c(r)?l(t,r):r}return n}function u(e){if(!r.existsSync(e))return{};let t;try{t=JSON.parse(r.readFileSync(e,`utf8`))}catch(t){throw Error(`Could not parse Pi settings at ${e}`,{cause:t})}if(!c(t))throw Error(`Pi settings at ${e} must be a JSON object`);return t}async function d(e){let t;try{t=JSON.parse(await r.promises.readFile(e,`utf8`))}catch(t){if(t.code===`ENOENT`)return{};throw Error(`Could not parse Pi settings at ${e}`,{cause:t})}if(!c(t))throw Error(`Pi settings at ${e} must be a JSON object`);return t}function f(e){return e.reduce((e,t)=>l(e,u(t)),{})}async function p(e){return(await Promise.all(e.map(d))).reduce(l,{})}function m(e){return typeof e==`function`?e():e}function h(e,t=a.homedir(),n=s(t)){return{canonicalUser:i.join(n,o),canonicalProject:i.join(e,`.pi`,o),legacyUser:[i.join(t,`.pi`,o)],legacyProject:[i.join(e,`pi`,o)]}}function g(e){let t=h(e.repoRoot,e.homeDirectory),n=[...t.legacyUser,...e.userConfigPaths??[],t.canonicalUser],r=[...t.legacyProject,...e.projectConfigPaths??[],t.canonicalProject],i=e.defaults??{},a=f(n),o=m(e.isProjectTrusted)?f(r):{};return[i,a,e.overlay??{},o,e.environment??{},e.cli??{},e.programmatic??{}].reduce(l,{})}async function _(e){let t=h(e.repoRoot,e.homeDirectory),n=[...t.legacyUser,...e.userConfigPaths??[],t.canonicalUser],r=[...t.legacyProject,...e.projectConfigPaths??[],t.canonicalProject],[i,a]=await Promise.all([p(n),m(e.isProjectTrusted)?p(r):Promise.resolve({})]);return[e.defaults??{},i,e.overlay??{},a,e.environment??{},e.cli??{},e.programmatic??{}].reduce(l,{})}function v(e){return{legacy:i.join(e,`.pi`,o),canonical:i.join(s(e),o)}}function y(e=a.homedir()){return v(e).canonical}function b(e=a.homedir()){let t=v(e);return n(f([t.legacy,t.canonical]))}function x(n,r=a.homedir()){let i=v(r);return e(i.canonical,t(u(i.canonical),n)),b(r)}export{g as loadPiConfig,_ as loadPiConfigAsync,b as loadPiImageSettings,h as piConfigPaths,y as piImageSettingsPath,x as savePiImageSettings};
|
|
2
2
|
//# sourceMappingURL=piConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piConfig.mjs","names":[],"sources":["../../src/adapters/piConfig.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport type { PiConfig, PiConfigLoadOptions, PiConfigPaths } from '../schemas/config/schema.ts';\n\nconst SETTINGS_FILE_NAME = 'settings.json';\nconst CONFIG_DIR_NAME = '.pi';\nconst AGENT_DIR_NAME = 'agent';\nconst PI_CODING_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst LEGACY_CONFIG_DIR_NAME = 'pi';\n\nfunction defaultAgentDirectory(homeDirectory: string): string {\n const fallback = path.join(homeDirectory, CONFIG_DIR_NAME, AGENT_DIR_NAME);\n if (homeDirectory !== os.homedir()) return fallback;\n const configured = process.env[PI_CODING_AGENT_DIR_ENV]?.trim();\n if (!configured) return fallback;\n if (configured === '~') return homeDirectory;\n if (configured.startsWith('~/')) return path.join(homeDirectory, configured.slice(2));\n return path.resolve(configured);\n}\nfunction isObject(value: unknown): value is PiConfig {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction mergeConfig(base: PiConfig, override: PiConfig): PiConfig {\n const result: PiConfig = { ...base };\n for (const [key, value] of Object.entries(override)) {\n const current = result[key];\n result[key] = isObject(current) && isObject(value) ? mergeConfig(current, value) : value;\n }\n return result;\n}\n\nfunction readConfig(filePath: string): PiConfig {\n if (!fs.existsSync(filePath)) return {};\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n } catch (error) {\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nasync function readConfigAsync(filePath: string): Promise<PiConfig> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(await fs.promises.readFile(filePath, 'utf8'));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return {};\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nfunction readConfigPaths(paths: readonly string[]): PiConfig {\n return paths.reduce<PiConfig>((config, filePath) => mergeConfig(config, readConfig(filePath)), {});\n}\n\nasync function readConfigPathsAsync(paths: readonly string[]): Promise<PiConfig> {\n const layers = await Promise.all(paths.map(readConfigAsync));\n return layers.reduce<PiConfig>(mergeConfig, {});\n}\n\nfunction projectIsTrusted(value: PiConfigLoadOptions['isProjectTrusted']): boolean {\n return typeof value === 'function' ? value() : value;\n}\n\nexport function piConfigPaths(\n repoRoot: string,\n homeDirectory = os.homedir(),\n agentDirectory = defaultAgentDirectory(homeDirectory),\n): PiConfigPaths {\n return {\n canonicalUser: path.join(agentDirectory, SETTINGS_FILE_NAME),\n canonicalProject: path.join(repoRoot, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),\n legacyUser: [path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n legacyProject: [path.join(repoRoot, LEGACY_CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n };\n}\n\nexport function loadPiConfig(options: PiConfigLoadOptions): PiConfig {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const defaults = options.defaults ?? {};\n const user = readConfigPaths(userPaths);\n const trustedProject = projectIsTrusted(options.isProjectTrusted) ? readConfigPaths(projectPaths) : {};\n return [\n defaults,\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n\nexport async function loadPiConfigAsync(options: PiConfigLoadOptions): Promise<PiConfig> {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const [user, trustedProject] = await Promise.all([\n readConfigPathsAsync(userPaths),\n projectIsTrusted(options.isProjectTrusted) ? readConfigPathsAsync(projectPaths) : Promise.resolve({}),\n ]);\n return [\n options.defaults ?? {},\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n"],"mappings":"uEAKA,MAAM,EAAqB,gBAM3B,SAAS,EAAsB,EAA+B,CAC5D,IAAM,EAAW,EAAK,KAAK,EAAe,MAAiB,OAAc,EACzE,GAAI,IAAkB,EAAG,QAAQ,EAAG,OAAO,EAC3C,IAAM,EAAa,QAAQ,IAAI,qBAA0B,KAAK,EAI9D,OAHK,EACD,IAAe,IAAY,EAC3B,EAAW,WAAW,IAAI,EAAU,EAAK,KAAK,EAAe,EAAW,MAAM,CAAC,CAAC,EAC7E,EAAK,QAAQ,CAAU,EAHN,CAI1B,CACA,SAAS,EAAS,EAAmC,CACnD,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAEA,SAAS,EAAY,EAAgB,EAA8B,CACjE,IAAM,EAAmB,CAAE,GAAG,CAAK,EACnC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAQ,EAAG,CACnD,IAAM,EAAU,EAAO,GACvB,EAAO,GAAO,EAAS,CAAO,GAAK,EAAS,CAAK,EAAI,EAAY,EAAS,CAAK,EAAI,CACrF,CACA,OAAO,CACT,CAEA,SAAS,EAAW,EAA4B,CAC9C,GAAI,CAAC,EAAG,WAAW,CAAQ,EAAG,MAAO,CAAC,EACtC,IAAI,EACJ,GAAI,CACF,EAAS,KAAK,MAAM,EAAG,aAAa,EAAU,MAAM,CAAC,CACvD,OAAS,EAAO,CACd,MAAU,MAAM,kCAAkC,IAAY,CAAE,MAAO,CAAM,CAAC,CAChF,CACA,GAAI,CAAC,EAAS,CAAM,EAAG,MAAU,MAAM,kBAAkB,EAAS,u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Q,UAAY,CAAC,EAChC,EAAO,EAAgB,CAAS,EAChC,EAAiB,EAAiB,EAAQ,gBAAgB,EAAI,EAAgB,CAAY,EAAI,CAAC,EACrG,MAAO,CACL,EACA,EACA,EAAQ,SAAW,CAAC,EACpB,EACA,EAAQ,aAAe,CAAC,EACxB,EAAQ,KAAO,CAAC,EAChB,EAAQ,cAAgB,CAAC,CAC3B,CAAC,CAAC,OAAO,EAAa,CAAC,CAAC,CAC1B,CAEA,eAAsB,EAAkB,EAAiD,CACvF,IAAM,EAAQ,EAAc,EAAQ,SAAU,EAAQ,aAAa,EAC7D,EAAY,CAAC,GAAG,EAAM,WAAY,GAAI,EAAQ,iBAAmB,CAAC,EAAI,EAAM,aAAa,EACzF,EAAe,CAAC,GAAG,EAAM,cAAe,GAAI,EAAQ,oBAAsB,CAAC,EAAI,EAAM,gBAAgB,EACrG,CAAC,EAAM,GAAkB,MAAM,QAAQ,IAAI,CAC/C,EAAqB,CAAS,EAC9B,EAAiB,EAAQ,gBAAgB,EAAI,EAAqB,CAAY,EAAI,QAAQ,QAAQ,CAAC,CAAC,CACtG,CAAC,EACD,MAAO,CACL,EAAQ,UAAY,CAAC,EACrB,EACA,EAAQ,SAAW,CAAC,EACpB,EACA,EAAQ,aAAe,CAAC,EACxB,EAAQ,KAAO,CAAC,EAChB,EAAQ,cAAgB,CAAC,CAC3B,CAAC,CAAC,OAAO,EAAa,CAAC,CAAC,CAC1B"}
|
|
1
|
+
{"version":3,"file":"piConfig.mjs","names":[],"sources":["../../src/adapters/piConfig.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport type { PiConfig, PiConfigLoadOptions, PiConfigPaths } from '../schemas/config/schema.ts';\nimport {\n applyPiImageSettings,\n parsePiImageSettings,\n type PiImageSettings,\n type PiImageSettingsUpdate,\n} from '../services/imageSettings.ts';\nimport { writePrivateAtomicJson } from './atomicJson.ts';\n\nconst SETTINGS_FILE_NAME = 'settings.json';\nconst CONFIG_DIR_NAME = '.pi';\nconst AGENT_DIR_NAME = 'agent';\nconst PI_CODING_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst LEGACY_CONFIG_DIR_NAME = 'pi';\n\nfunction defaultAgentDirectory(homeDirectory: string): string {\n const fallback = path.join(homeDirectory, CONFIG_DIR_NAME, AGENT_DIR_NAME);\n if (homeDirectory !== os.homedir()) return fallback;\n const configured = process.env[PI_CODING_AGENT_DIR_ENV]?.trim();\n if (!configured) return fallback;\n if (configured === '~') return homeDirectory;\n if (configured.startsWith('~/')) return path.join(homeDirectory, configured.slice(2));\n return path.resolve(configured);\n}\nfunction isObject(value: unknown): value is PiConfig {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction mergeConfig(base: PiConfig, override: PiConfig): PiConfig {\n const result: PiConfig = { ...base };\n for (const [key, value] of Object.entries(override)) {\n const current = result[key];\n result[key] = isObject(current) && isObject(value) ? mergeConfig(current, value) : value;\n }\n return result;\n}\n\nfunction readConfig(filePath: string): PiConfig {\n if (!fs.existsSync(filePath)) return {};\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n } catch (error) {\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nasync function readConfigAsync(filePath: string): Promise<PiConfig> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(await fs.promises.readFile(filePath, 'utf8'));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return {};\n throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });\n }\n if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);\n return parsed;\n}\n\nfunction readConfigPaths(paths: readonly string[]): PiConfig {\n return paths.reduce<PiConfig>((config, filePath) => mergeConfig(config, readConfig(filePath)), {});\n}\n\nasync function readConfigPathsAsync(paths: readonly string[]): Promise<PiConfig> {\n const layers = await Promise.all(paths.map(readConfigAsync));\n return layers.reduce<PiConfig>(mergeConfig, {});\n}\n\nfunction projectIsTrusted(value: PiConfigLoadOptions['isProjectTrusted']): boolean {\n return typeof value === 'function' ? value() : value;\n}\n\nexport function piConfigPaths(\n repoRoot: string,\n homeDirectory = os.homedir(),\n agentDirectory = defaultAgentDirectory(homeDirectory),\n): PiConfigPaths {\n return {\n canonicalUser: path.join(agentDirectory, SETTINGS_FILE_NAME),\n canonicalProject: path.join(repoRoot, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),\n legacyUser: [path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n legacyProject: [path.join(repoRoot, LEGACY_CONFIG_DIR_NAME, SETTINGS_FILE_NAME)],\n };\n}\n\nexport function loadPiConfig(options: PiConfigLoadOptions): PiConfig {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const defaults = options.defaults ?? {};\n const user = readConfigPaths(userPaths);\n const trustedProject = projectIsTrusted(options.isProjectTrusted) ? readConfigPaths(projectPaths) : {};\n return [\n defaults,\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n\nexport async function loadPiConfigAsync(options: PiConfigLoadOptions): Promise<PiConfig> {\n const paths = piConfigPaths(options.repoRoot, options.homeDirectory);\n const userPaths = [...paths.legacyUser, ...(options.userConfigPaths ?? []), paths.canonicalUser];\n const projectPaths = [...paths.legacyProject, ...(options.projectConfigPaths ?? []), paths.canonicalProject];\n const [user, trustedProject] = await Promise.all([\n readConfigPathsAsync(userPaths),\n projectIsTrusted(options.isProjectTrusted) ? readConfigPathsAsync(projectPaths) : Promise.resolve({}),\n ]);\n return [\n options.defaults ?? {},\n user,\n options.overlay ?? {},\n trustedProject,\n options.environment ?? {},\n options.cli ?? {},\n options.programmatic ?? {},\n ].reduce(mergeConfig, {});\n}\n\n/**\n * Where the image limits are read from and written to.\n *\n * The user layer only. Pi merges a trusted project settings.json over it, but\n * these limits describe one machine's tolerance for image payloads rather than\n * one repository's, and the cockpit page that writes them has no repository\n * scope to offer. The legacy user path is still read, because a machine that\n * has not been migrated still answers from it.\n */\nfunction userSettingsPaths(homeDirectory: string): { legacy: string; canonical: string } {\n return {\n legacy: path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),\n canonical: path.join(defaultAgentDirectory(homeDirectory), SETTINGS_FILE_NAME),\n };\n}\n\n/** The file a change lands in; Pi's own settings toggle writes the same one. */\nexport function piImageSettingsPath(homeDirectory = os.homedir()): string {\n return userSettingsPaths(homeDirectory).canonical;\n}\n\nexport function loadPiImageSettings(homeDirectory = os.homedir()): PiImageSettings {\n const paths = userSettingsPaths(homeDirectory);\n return parsePiImageSettings(readConfigPaths([paths.legacy, paths.canonical]));\n}\n\n/**\n * Writes the changed keys back and reports the limits that now apply.\n *\n * Read-modify-write on Pi's own file, so a save races a concurrent Pi settings\n * save rather than merging with it. Pi writes only the fields its UI touched,\n * as this does, which keeps the window to the one setting being changed on\n * both sides at once.\n */\nexport function savePiImageSettings(update: PiImageSettingsUpdate, homeDirectory = os.homedir()): PiImageSettings {\n const paths = userSettingsPaths(homeDirectory);\n writePrivateAtomicJson(paths.canonical, applyPiImageSettings(readConfig(paths.canonical), update));\n return loadPiImageSettings(homeDirectory);\n}\n"],"mappings":"gOAYA,MAAM,EAAqB,gBAM3B,SAAS,EAAsB,EAA+B,CAC5D,IAAM,EAAW,EAAK,KAAK,EAAe,MAAiB,OAAc,EACzE,GAAI,IAAkB,EAAG,QAAQ,EAAG,OAAO,EAC3C,IAAM,EAAa,QAAQ,IAAI,qBAA0B,KAAK,EAI9D,OAHK,EACD,IAAe,IAAY,EAC3B,EAAW,WAAW,IAAI,EAAU,EA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AsB,CAAC,EAAI,EAAM,gBAAgB,EACrG,CAAC,EAAM,GAAkB,MAAM,QAAQ,IAAI,CAC/C,EAAqB,CAAS,EAC9B,EAAiB,EAAQ,gBAAgB,EAAI,EAAqB,CAAY,EAAI,QAAQ,QAAQ,CAAC,CAAC,CACtG,CAAC,EACD,MAAO,CACL,EAAQ,UAAY,CAAC,EACrB,EACA,EAAQ,SAAW,CAAC,EACpB,EACA,EAAQ,aAAe,CAAC,EACxB,EAAQ,KAAO,CAAC,EAChB,EAAQ,cAAgB,CAAC,CAC3B,CAAC,CAAC,OAAO,EAAa,CAAC,CAAC,CAC1B,CAWA,SAAS,EAAkB,EAA8D,CACvF,MAAO,CACL,OAAQ,EAAK,KAAK,EAAe,MAAiB,CAAkB,EACpE,UAAW,EAAK,KAAK,EAAsB,CAAa,EAAG,CAAkB,CAC/E,CACF,CAGA,SAAgB,EAAoB,EAAgB,EAAG,QAAQ,EAAW,CACxE,OAAO,EAAkB,CAAa,CAAC,CAAC,SAC1C,CAEA,SAAgB,EAAoB,EAAgB,EAAG,QAAQ,EAAoB,CACjF,IAAM,EAAQ,EAAkB,CAAa,EAC7C,OAAO,EAAqB,EAAgB,CAAC,EAAM,OAAQ,EAAM,SAAS,CAAC,CAAC,CAC9E,CAUA,SAAgB,EAAoB,EAA+B,EAAgB,EAAG,QAAQ,EAAoB,CAChH,IAAM,EAAQ,EAAkB,CAAa,EAE7C,OADA,EAAuB,EAAM,UAAW,EAAqB,EAAW,EAAM,SAAS,EAAG,CAAM,CAAC,EAC1F,EAAoB,CAAa,CAC1C"}
|
package/dist/config/piConfig.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../adapters/piConfig.cjs");exports.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/imageSettings.cjs"),t=require("../adapters/piConfig.cjs");exports.DEFAULT_IMAGE_MAX_DIMENSION=e.DEFAULT_IMAGE_MAX_DIMENSION,exports.MIN_IMAGE_MAX_DIMENSION=e.MIN_IMAGE_MAX_DIMENSION,exports.clampImageMaxDimension=e.clampImageMaxDimension,exports.loadPiConfig=t.loadPiConfig,exports.loadPiConfigAsync=t.loadPiConfigAsync,exports.loadPiImageSettings=t.loadPiImageSettings,exports.parsePiImageSettings=e.parsePiImageSettings,exports.piConfigPaths=t.piConfigPaths,exports.piImageSettingsPath=t.piImageSettingsPath,exports.savePiImageSettings=t.savePiImageSettings;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, PiImageSettings, PiImageSettingsUpdate, clampImageMaxDimension, parsePiImageSettings } from "../services/imageSettings.cjs";
|
|
2
|
+
import { loadPiConfig, loadPiConfigAsync, loadPiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings } from "../adapters/piConfig.cjs";
|
|
3
|
+
export { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, type PiImageSettings, type PiImageSettingsUpdate, clampImageMaxDimension, loadPiConfig, loadPiConfigAsync, loadPiImageSettings, parsePiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, PiImageSettings, PiImageSettingsUpdate, clampImageMaxDimension, parsePiImageSettings } from "../services/imageSettings.mjs";
|
|
2
|
+
import { loadPiConfig, loadPiConfigAsync, loadPiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings } from "../adapters/piConfig.mjs";
|
|
3
|
+
export { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, type PiImageSettings, type PiImageSettingsUpdate, clampImageMaxDimension, loadPiConfig, loadPiConfigAsync, loadPiImageSettings, parsePiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings };
|
package/dist/config/piConfig.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{DEFAULT_IMAGE_MAX_DIMENSION as e,MIN_IMAGE_MAX_DIMENSION as t,clampImageMaxDimension as n,parsePiImageSettings as r}from"../services/imageSettings.mjs";import{loadPiConfig as i,loadPiConfigAsync as a,loadPiImageSettings as o,piConfigPaths as s,piImageSettingsPath as c,savePiImageSettings as l}from"../adapters/piConfig.mjs";export{e as DEFAULT_IMAGE_MAX_DIMENSION,t as MIN_IMAGE_MAX_DIMENSION,n as clampImageMaxDimension,i as loadPiConfig,a as loadPiConfigAsync,o as loadPiImageSettings,r as parsePiImageSettings,s as piConfigPaths,c as piImageSettingsPath,l as savePiImageSettings};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapters/atomicJson.cjs"),t=require("./services/configPolicy.cjs"),n=require("./adapters/config.cjs"),r=require("./adapters/configWriter.cjs"),i=require("./services/domains.cjs"),a=require("./adapters/layeredConfig.cjs"),o=require("./adapters/pluginCatalog.cjs"),s=require("./adapters/domains.cjs"),c=require("./adapters/harnessState.cjs"),l=require("./adapters/harnessStore.cjs"),u=require("./adapters/init.cjs"),d=require("./adapters/majorModes.cjs");require("./types/config.cjs");const f=require("./adapters/pi/piContext.cjs"),p=require("./adapters/piConfig.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapters/atomicJson.cjs"),t=require("./services/configPolicy.cjs"),n=require("./adapters/config.cjs"),r=require("./adapters/configWriter.cjs"),i=require("./services/domains.cjs"),a=require("./adapters/layeredConfig.cjs"),o=require("./adapters/pluginCatalog.cjs"),s=require("./adapters/domains.cjs"),c=require("./adapters/harnessState.cjs"),l=require("./adapters/harnessStore.cjs"),u=require("./adapters/init.cjs"),d=require("./adapters/majorModes.cjs");require("./types/config.cjs");const f=require("./adapters/pi/piContext.cjs"),p=require("./services/imageSettings.cjs"),m=require("./adapters/piConfig.cjs"),h=require("./adapters/profiles.cjs");let g=require("@agimon-ai/doompi-extension-contracts/config");exports.DEFAULT_IMAGE_MAX_DIMENSION=p.DEFAULT_IMAGE_MAX_DIMENSION,exports.DOOM_CONFIG_ENTRY_TYPE=f.DOOM_CONFIG_ENTRY_TYPE,Object.defineProperty(exports,"DOOM_CONFIG_SERVICE",{enumerable:!0,get:function(){return g.DOOM_CONFIG_SERVICE}}),exports.DOOM_CONFIG_TEMPLATES=u.DOOM_CONFIG_TEMPLATES,exports.DOOM_CONFIG_TRANSITION_ENTRY_TYPE=f.DOOM_CONFIG_TRANSITION_ENTRY_TYPE,exports.DOOM_DIR=a.DOOM_DIR,exports.DOOM_PLANNING_THINKING_LEVELS=t.DOOM_PLANNING_THINKING_LEVELS,exports.DOOM_VOICE_ENGINES=t.DOOM_VOICE_ENGINES,exports.DOOM_VOICE_TTS_ENGINES=t.DOOM_VOICE_TTS_ENGINES,exports.FILE_ONLY_STATE_FIELDS=c.FILE_ONLY_STATE_FIELDS,exports.GLOBAL_DOOM_SEED_FILES=u.GLOBAL_DOOM_SEED_FILES,exports.HARNESS_STATE_KEYS=c.HARNESS_STATE_KEYS,exports.HARNESS_STATE_POINTER=l.HARNESS_STATE_POINTER,exports.MARKETPLACE_MANIFEST_RELATIVE_PATHS=o.MARKETPLACE_MANIFEST_RELATIVE_PATHS,exports.MIN_IMAGE_MAX_DIMENSION=p.MIN_IMAGE_MAX_DIMENSION,exports.PERSONA_FILES=h.PERSONA_FILES,exports.REPOSITORY_DOOM_CONFIG_TEMPLATES=u.REPOSITORY_DOOM_CONFIG_TEMPLATES,exports.acknowledgeDoomConfigTransition=f.acknowledgeDoomConfigTransition,exports.appendDoomConfigSelection=f.appendDoomConfigSelection,exports.appendDoomConfigTransition=f.appendDoomConfigTransition,exports.applyProfileEnvironment=h.applyProfileEnvironment,exports.buildPersonaPrompt=h.buildPersonaPrompt,exports.clampImageMaxDimension=p.clampImageMaxDimension,exports.configLeafKeys=t.configLeafKeys,exports.configRootKeys=t.configRootKeys,exports.configScopeOf=t.configScopeOf,exports.createDoomConfigContext=f.createDoomConfigContext,exports.createDoomConfigContextAsync=f.createDoomConfigContextAsync,exports.createHarnessSession=l.createHarnessSession,exports.disposeHarnessState=l.disposeHarnessState,exports.domainCompletionItems=i.domainCompletionItems,exports.domainCompletionPrefix=i.domainCompletionPrefix,exports.expandDomainNames=i.expandDomainNames,exports.findPluginManifestPath=o.findPluginManifestPath,exports.freezeDoomConfigContext=f.freezeDoomConfigContext,exports.getHarnessState=l.getHarnessState,exports.globalDoomConfigDirectory=n.globalDoomConfigDirectory,exports.globalDoomConfigPath=n.globalDoomConfigPath,exports.harnessRoot=l.harnessRoot,exports.initializeGlobalDoomConfig=u.initializeGlobalDoomConfig,exports.initializeRepositoryDoomConfig=u.initializeRepositoryDoomConfig,exports.isLocalPackageSpecifier=d.isLocalPackageSpecifier,exports.isRemotePluginSource=o.isRemotePluginSource,exports.layerEntries=d.layerEntries,exports.layerHookGroups=d.layerHookGroups,exports.listDomainNames=s.listDomainNames,exports.listProfileNames=h.listProfileNames,exports.loadDomains=s.loadDomains,exports.loadDoomConfig=n.loadDoomConfig,exports.loadDoomConfigAsync=n.loadDoomConfigAsync,exports.loadDoomConfigLayers=n.loadDoomConfigLayers,exports.loadHarnessState=l.loadHarnessState,exports.loadMajorModesConfig=d.loadMajorModesConfig,exports.loadPiConfig=m.loadPiConfig,exports.loadPiConfigAsync=m.loadPiConfigAsync,exports.loadPiImageSettings=m.loadPiImageSettings,exports.loadProfiles=h.loadProfiles,exports.mergeDoomConfigs=t.mergeDoomConfigs,exports.parseAutocompactModeConfig=t.parseAutocompactModeConfig,exports.parseDoomConfig=t.parseDoomConfig,exports.parsePiImageSettings=p.parsePiImageSettings,exports.parsePlanningModeConfig=t.parsePlanningModeConfig,exports.piConfigPaths=m.piConfigPaths,exports.piImageSettingsPath=m.piImageSettingsPath,exports.pluginDirectoryForSource=o.pluginDirectoryForSource,exports.projectHarnessEnvironment=c.projectHarnessEnvironment,exports.provideDoomConfigContext=f.provideDoomConfigContext,exports.readDoomConfigContextGeneration=f.readDoomConfigContextGeneration,exports.readDoomConfigPendingSelection=f.readDoomConfigPendingSelection,exports.readDoomConfigSelection=f.readDoomConfigSelection,exports.readHarnessState=c.readHarnessState,exports.replaceDoomConfigContext=f.replaceDoomConfigContext,exports.replaceProfileEnvironment=h.replaceProfileEnvironment,exports.repositoryDoomConfigPath=n.repositoryDoomConfigPath,exports.requireDoomConfigContext=f.requireDoomConfigContext,exports.requireHarnessPaths=l.requireHarnessPaths,exports.requireHarnessRoot=l.requireHarnessRoot,exports.resetHarnessStore=l.resetHarnessStore,exports.resolveLayers=d.resolveLayers,exports.resolvePackageConfigurations=d.resolvePackageConfigurations,exports.resolvePlanningPlansDirectory=n.resolvePlanningPlansDirectory,exports.resolvePluginDirectories=s.resolvePluginDirectories,exports.resolvePluginEntries=s.resolvePluginEntries,exports.resolveProfile=h.resolveProfile,exports.resolveSharedSkills=s.resolveSharedSkills,exports.resolveVoiceConfig=t.resolveVoiceConfig,exports.restoreHarnessStateSnapshot=l.restoreHarnessStateSnapshot,exports.savePiImageSettings=m.savePiImageSettings,exports.setDoomConfigValue=r.setDoomConfigValue,exports.snapshotHarnessState=l.snapshotHarnessState,exports.supersedeDoomConfigTransition=f.supersedeDoomConfigTransition,exports.unsetDoomConfigValue=r.unsetDoomConfigValue,exports.updateHarnessState=l.updateHarnessState,exports.valueAtKeyPath=t.valueAtKeyPath,exports.writeDoomConfigValues=r.writeDoomConfigValues,exports.writePrivateAtomicJson=e.writePrivateAtomicJson;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,8 @@ import { AutocompactModeConfig, AutocompactThresholdConfig, ConfigValueOrigin, D
|
|
|
3
3
|
import { globalDoomConfigDirectory, globalDoomConfigPath, loadDoomConfig, loadDoomConfigAsync, loadDoomConfigLayers, repositoryDoomConfigPath, resolvePlanningPlansDirectory } from "./adapters/config.cjs";
|
|
4
4
|
import { ConfigKeyScope, DOOM_PLANNING_THINKING_LEVELS, DOOM_VOICE_ENGINES, DOOM_VOICE_TTS_ENGINES, configLeafKeys, configRootKeys, configScopeOf, mergeDoomConfigs, parseAutocompactModeConfig, parseDoomConfig, parsePlanningModeConfig, resolveVoiceConfig, valueAtKeyPath } from "./services/configPolicy.cjs";
|
|
5
5
|
import { ConfigAdapterRegistrationOptions, PiConfig, PiConfigLoadOptions, PiConfigPaths } from "./schemas/config/schema.cjs";
|
|
6
|
-
import {
|
|
6
|
+
import { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, PiImageSettings, PiImageSettingsUpdate, clampImageMaxDimension, parsePiImageSettings } from "./services/imageSettings.cjs";
|
|
7
|
+
import { loadPiConfig, loadPiConfigAsync, loadPiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings } from "./adapters/piConfig.cjs";
|
|
7
8
|
import { DoomConfigEdit, DoomConfigScope, WriteDoomConfigOptions, setDoomConfigValue, unsetDoomConfigValue, writeDoomConfigValues } from "./adapters/configWriter.cjs";
|
|
8
9
|
import { DomainDefinition, DomainManifest, DomainMcpAllowlist, DomainPlugin, GitPluginSource, LocalPluginSource, NpmPluginSource, PluginCatalog, PluginCatalogEntry, PluginEntry, PluginManifestMetadata, PluginSkillDiscovery, PluginSource, ResolvedDomain } from "./types/domains.cjs";
|
|
9
10
|
import { DOOM_DIR } from "./adapters/layeredConfig.cjs";
|
|
@@ -16,4 +17,4 @@ import { DOOM_CONFIG_TEMPLATES, GLOBAL_DOOM_SEED_FILES, GlobalDoomInitResult, RE
|
|
|
16
17
|
import { LayerDefinition, LayerPackage, LayerPackageConfig, LayerResolvers, MajorModeDefinition, MajorModesConfig, ResolvedLayerDefinition, ResolvedPackageConfiguration, isLocalPackageSpecifier, layerEntries, layerHookGroups, loadMajorModesConfig, resolveLayers, resolvePackageConfigurations } from "./adapters/majorModes.cjs";
|
|
17
18
|
import { DOOM_CONFIG_ENTRY_TYPE, DOOM_CONFIG_TRANSITION_ENTRY_TYPE, DoomConfigSelection, acknowledgeDoomConfigTransition, appendDoomConfigSelection, appendDoomConfigTransition, createDoomConfigContext, createDoomConfigContextAsync, freezeDoomConfigContext, provideDoomConfigContext, readDoomConfigContextGeneration, readDoomConfigPendingSelection, readDoomConfigSelection, replaceDoomConfigContext, requireDoomConfigContext, supersedeDoomConfigTransition } from "./adapters/pi/piContext.cjs";
|
|
18
19
|
import { AgentProfile, PERSONA_FILES, applyProfileEnvironment, buildPersonaPrompt, listProfileNames, loadProfiles, replaceProfileEnvironment, resolveProfile } from "./adapters/profiles.cjs";
|
|
19
|
-
export { type AgentProfile, type AutocompactModeConfig, type AutocompactThresholdConfig, type ConfigAdapterRegistrationOptions, type ConfigKeyScope, type ConfigValueOrigin, DOOM_CONFIG_ENTRY_TYPE, DOOM_CONFIG_SERVICE, DOOM_CONFIG_TEMPLATES, DOOM_CONFIG_TRANSITION_ENTRY_TYPE, DOOM_DIR, DOOM_PLANNING_THINKING_LEVELS, DOOM_VOICE_ENGINES, DOOM_VOICE_TTS_ENGINES, type DeepReadonly, type DomainDefinition, type DomainManifest, type DomainMcpAllowlist, type DomainPlugin, type DoomConfig, type DoomConfigContext, type DoomConfigEdit, type DoomConfigLayer, type DoomConfigLayers, type DoomConfigPendingSelection, type DoomConfigScope, type DoomConfigSelection, type DoomConfigTransitionPhase, type DoomConfigTransitionRecord, type DoomConfigTransitionStrategy, type DoomHarnessContext, type DoomSelectionConfig, type EditorConfig, FILE_ONLY_STATE_FIELDS, GLOBAL_DOOM_SEED_FILES, type GitPluginSource, type GlobalDoomInitResult, HARNESS_STATE_KEYS, HARNESS_STATE_POINTER, type HarnessState, type HarnessStateFile, type HarnessStateParseReporter, type HarnessStateTransactionSnapshot, type IDoomConfigLoader, type IDoomConfigService, type LayerDefinition, type LayerPackage, type LayerPackageConfig, type LayerResolvers, type LoadedHarnessState, type LocalPluginSource, MARKETPLACE_MANIFEST_RELATIVE_PATHS, type MajorModeDefinition, type MajorModesConfig, type NpmPluginSource, PERSONA_FILES, type PackageAttribution, type PiConfig, type PiConfigLoadOptions, type PiConfigPaths, type PlanningAgentConfig, type PlanningModeConfig, type PlanningThinkingLevel, type PluginCatalog, type PluginCatalogEntry, type PluginEntry, type PluginHookSource, type PluginManifestMetadata, type PluginSkillDiscovery, type PluginSource, type ProjectTrust, REPOSITORY_DOOM_CONFIG_TEMPLATES, type RepositoryDoomInitOptions, type RepositoryDoomInitResult, type ResolvedDomain, type ResolvedLayerDefinition, type ResolvedPackageConfiguration, type ResolvedVoiceAutoCaptureConfig, type ResolvedVoiceConfig, type VoiceAdapterConfig, type VoiceAutoCaptureConfig, type VoiceConfig, type VoiceEngine, type VoiceModelConfig, type VoiceTtsConfig, type VoiceTtsEngine, type WriteDoomConfigOptions, acknowledgeDoomConfigTransition, appendDoomConfigSelection, appendDoomConfigTransition, applyProfileEnvironment, buildPersonaPrompt, configLeafKeys, configRootKeys, configScopeOf, createDoomConfigContext, createDoomConfigContextAsync, createHarnessSession, disposeHarnessState, domainCompletionItems, domainCompletionPrefix, expandDomainNames, findPluginManifestPath, freezeDoomConfigContext, getHarnessState, globalDoomConfigDirectory, globalDoomConfigPath, harnessRoot, initializeGlobalDoomConfig, initializeRepositoryDoomConfig, isLocalPackageSpecifier, isRemotePluginSource, layerEntries, layerHookGroups, listDomainNames, listProfileNames, loadDomains, loadDoomConfig, loadDoomConfigAsync, loadDoomConfigLayers, loadHarnessState, loadMajorModesConfig, loadPiConfig, loadPiConfigAsync, loadProfiles, mergeDoomConfigs, parseAutocompactModeConfig, parseDoomConfig, parsePlanningModeConfig, piConfigPaths, pluginDirectoryForSource, projectHarnessEnvironment, provideDoomConfigContext, readDoomConfigContextGeneration, readDoomConfigPendingSelection, readDoomConfigSelection, readHarnessState, replaceDoomConfigContext, replaceProfileEnvironment, repositoryDoomConfigPath, requireDoomConfigContext, requireHarnessPaths, requireHarnessRoot, resetHarnessStore, resolveLayers, resolvePackageConfigurations, resolvePlanningPlansDirectory, resolvePluginDirectories, resolvePluginEntries, resolveProfile, resolveSharedSkills, resolveVoiceConfig, restoreHarnessStateSnapshot, setDoomConfigValue, snapshotHarnessState, supersedeDoomConfigTransition, unsetDoomConfigValue, updateHarnessState, valueAtKeyPath, writeDoomConfigValues, writePrivateAtomicJson };
|
|
20
|
+
export { type AgentProfile, type AutocompactModeConfig, type AutocompactThresholdConfig, type ConfigAdapterRegistrationOptions, type ConfigKeyScope, type ConfigValueOrigin, DEFAULT_IMAGE_MAX_DIMENSION, DOOM_CONFIG_ENTRY_TYPE, DOOM_CONFIG_SERVICE, DOOM_CONFIG_TEMPLATES, DOOM_CONFIG_TRANSITION_ENTRY_TYPE, DOOM_DIR, DOOM_PLANNING_THINKING_LEVELS, DOOM_VOICE_ENGINES, DOOM_VOICE_TTS_ENGINES, type DeepReadonly, type DomainDefinition, type DomainManifest, type DomainMcpAllowlist, type DomainPlugin, type DoomConfig, type DoomConfigContext, type DoomConfigEdit, type DoomConfigLayer, type DoomConfigLayers, type DoomConfigPendingSelection, type DoomConfigScope, type DoomConfigSelection, type DoomConfigTransitionPhase, type DoomConfigTransitionRecord, type DoomConfigTransitionStrategy, type DoomHarnessContext, type DoomSelectionConfig, type EditorConfig, FILE_ONLY_STATE_FIELDS, GLOBAL_DOOM_SEED_FILES, type GitPluginSource, type GlobalDoomInitResult, HARNESS_STATE_KEYS, HARNESS_STATE_POINTER, type HarnessState, type HarnessStateFile, type HarnessStateParseReporter, type HarnessStateTransactionSnapshot, type IDoomConfigLoader, type IDoomConfigService, type LayerDefinition, type LayerPackage, type LayerPackageConfig, type LayerResolvers, type LoadedHarnessState, type LocalPluginSource, MARKETPLACE_MANIFEST_RELATIVE_PATHS, MIN_IMAGE_MAX_DIMENSION, type MajorModeDefinition, type MajorModesConfig, type NpmPluginSource, PERSONA_FILES, type PackageAttribution, type PiConfig, type PiConfigLoadOptions, type PiConfigPaths, type PiImageSettings, type PiImageSettingsUpdate, type PlanningAgentConfig, type PlanningModeConfig, type PlanningThinkingLevel, type PluginCatalog, type PluginCatalogEntry, type PluginEntry, type PluginHookSource, type PluginManifestMetadata, type PluginSkillDiscovery, type PluginSource, type ProjectTrust, REPOSITORY_DOOM_CONFIG_TEMPLATES, type RepositoryDoomInitOptions, type RepositoryDoomInitResult, type ResolvedDomain, type ResolvedLayerDefinition, type ResolvedPackageConfiguration, type ResolvedVoiceAutoCaptureConfig, type ResolvedVoiceConfig, type VoiceAdapterConfig, type VoiceAutoCaptureConfig, type VoiceConfig, type VoiceEngine, type VoiceModelConfig, type VoiceTtsConfig, type VoiceTtsEngine, type WriteDoomConfigOptions, acknowledgeDoomConfigTransition, appendDoomConfigSelection, appendDoomConfigTransition, applyProfileEnvironment, buildPersonaPrompt, clampImageMaxDimension, configLeafKeys, configRootKeys, configScopeOf, createDoomConfigContext, createDoomConfigContextAsync, createHarnessSession, disposeHarnessState, domainCompletionItems, domainCompletionPrefix, expandDomainNames, findPluginManifestPath, freezeDoomConfigContext, getHarnessState, globalDoomConfigDirectory, globalDoomConfigPath, harnessRoot, initializeGlobalDoomConfig, initializeRepositoryDoomConfig, isLocalPackageSpecifier, isRemotePluginSource, layerEntries, layerHookGroups, listDomainNames, listProfileNames, loadDomains, loadDoomConfig, loadDoomConfigAsync, loadDoomConfigLayers, loadHarnessState, loadMajorModesConfig, loadPiConfig, loadPiConfigAsync, loadPiImageSettings, loadProfiles, mergeDoomConfigs, parseAutocompactModeConfig, parseDoomConfig, parsePiImageSettings, parsePlanningModeConfig, piConfigPaths, piImageSettingsPath, pluginDirectoryForSource, projectHarnessEnvironment, provideDoomConfigContext, readDoomConfigContextGeneration, readDoomConfigPendingSelection, readDoomConfigSelection, readHarnessState, replaceDoomConfigContext, replaceProfileEnvironment, repositoryDoomConfigPath, requireDoomConfigContext, requireHarnessPaths, requireHarnessRoot, resetHarnessStore, resolveLayers, resolvePackageConfigurations, resolvePlanningPlansDirectory, resolvePluginDirectories, resolvePluginEntries, resolveProfile, resolveSharedSkills, resolveVoiceConfig, restoreHarnessStateSnapshot, savePiImageSettings, setDoomConfigValue, snapshotHarnessState, supersedeDoomConfigTransition, unsetDoomConfigValue, updateHarnessState, valueAtKeyPath, writeDoomConfigValues, writePrivateAtomicJson };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,8 @@ import { AutocompactModeConfig, AutocompactThresholdConfig, ConfigValueOrigin, D
|
|
|
3
3
|
import { globalDoomConfigDirectory, globalDoomConfigPath, loadDoomConfig, loadDoomConfigAsync, loadDoomConfigLayers, repositoryDoomConfigPath, resolvePlanningPlansDirectory } from "./adapters/config.mjs";
|
|
4
4
|
import { ConfigKeyScope, DOOM_PLANNING_THINKING_LEVELS, DOOM_VOICE_ENGINES, DOOM_VOICE_TTS_ENGINES, configLeafKeys, configRootKeys, configScopeOf, mergeDoomConfigs, parseAutocompactModeConfig, parseDoomConfig, parsePlanningModeConfig, resolveVoiceConfig, valueAtKeyPath } from "./services/configPolicy.mjs";
|
|
5
5
|
import { ConfigAdapterRegistrationOptions, PiConfig, PiConfigLoadOptions, PiConfigPaths } from "./schemas/config/schema.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, PiImageSettings, PiImageSettingsUpdate, clampImageMaxDimension, parsePiImageSettings } from "./services/imageSettings.mjs";
|
|
7
|
+
import { loadPiConfig, loadPiConfigAsync, loadPiImageSettings, piConfigPaths, piImageSettingsPath, savePiImageSettings } from "./adapters/piConfig.mjs";
|
|
7
8
|
import { DoomConfigEdit, DoomConfigScope, WriteDoomConfigOptions, setDoomConfigValue, unsetDoomConfigValue, writeDoomConfigValues } from "./adapters/configWriter.mjs";
|
|
8
9
|
import { DomainDefinition, DomainManifest, DomainMcpAllowlist, DomainPlugin, GitPluginSource, LocalPluginSource, NpmPluginSource, PluginCatalog, PluginCatalogEntry, PluginEntry, PluginManifestMetadata, PluginSkillDiscovery, PluginSource, ResolvedDomain } from "./types/domains.mjs";
|
|
9
10
|
import { DOOM_DIR } from "./adapters/layeredConfig.mjs";
|
|
@@ -16,4 +17,4 @@ import { DOOM_CONFIG_TEMPLATES, GLOBAL_DOOM_SEED_FILES, GlobalDoomInitResult, RE
|
|
|
16
17
|
import { LayerDefinition, LayerPackage, LayerPackageConfig, LayerResolvers, MajorModeDefinition, MajorModesConfig, ResolvedLayerDefinition, ResolvedPackageConfiguration, isLocalPackageSpecifier, layerEntries, layerHookGroups, loadMajorModesConfig, resolveLayers, resolvePackageConfigurations } from "./adapters/majorModes.mjs";
|
|
17
18
|
import { DOOM_CONFIG_ENTRY_TYPE, DOOM_CONFIG_TRANSITION_ENTRY_TYPE, DoomConfigSelection, acknowledgeDoomConfigTransition, appendDoomConfigSelection, appendDoomConfigTransition, createDoomConfigContext, createDoomConfigContextAsync, freezeDoomConfigContext, provideDoomConfigContext, readDoomConfigContextGeneration, readDoomConfigPendingSelection, readDoomConfigSelection, replaceDoomConfigContext, requireDoomConfigContext, supersedeDoomConfigTransition } from "./adapters/pi/piContext.mjs";
|
|
18
19
|
import { AgentProfile, PERSONA_FILES, applyProfileEnvironment, buildPersonaPrompt, listProfileNames, loadProfiles, replaceProfileEnvironment, resolveProfile } from "./adapters/profiles.mjs";
|
|
19
|
-
export { type AgentProfile, type AutocompactModeConfig, type AutocompactThresholdConfig, type ConfigAdapterRegistrationOptions, type ConfigKeyScope, type ConfigValueOrigin, DOOM_CONFIG_ENTRY_TYPE, DOOM_CONFIG_SERVICE, DOOM_CONFIG_TEMPLATES, DOOM_CONFIG_TRANSITION_ENTRY_TYPE, DOOM_DIR, DOOM_PLANNING_THINKING_LEVELS, DOOM_VOICE_ENGINES, DOOM_VOICE_TTS_ENGINES, type DeepReadonly, type DomainDefinition, type DomainManifest, type DomainMcpAllowlist, type DomainPlugin, type DoomConfig, type DoomConfigContext, type DoomConfigEdit, type DoomConfigLayer, type DoomConfigLayers, type DoomConfigPendingSelection, type DoomConfigScope, type DoomConfigSelection, type DoomConfigTransitionPhase, type DoomConfigTransitionRecord, type DoomConfigTransitionStrategy, type DoomHarnessContext, type DoomSelectionConfig, type EditorConfig, FILE_ONLY_STATE_FIELDS, GLOBAL_DOOM_SEED_FILES, type GitPluginSource, type GlobalDoomInitResult, HARNESS_STATE_KEYS, HARNESS_STATE_POINTER, type HarnessState, type HarnessStateFile, type HarnessStateParseReporter, type HarnessStateTransactionSnapshot, type IDoomConfigLoader, type IDoomConfigService, type LayerDefinition, type LayerPackage, type LayerPackageConfig, type LayerResolvers, type LoadedHarnessState, type LocalPluginSource, MARKETPLACE_MANIFEST_RELATIVE_PATHS, type MajorModeDefinition, type MajorModesConfig, type NpmPluginSource, PERSONA_FILES, type PackageAttribution, type PiConfig, type PiConfigLoadOptions, type PiConfigPaths, type PlanningAgentConfig, type PlanningModeConfig, type PlanningThinkingLevel, type PluginCatalog, type PluginCatalogEntry, type PluginEntry, type PluginHookSource, type PluginManifestMetadata, type PluginSkillDiscovery, type PluginSource, type ProjectTrust, REPOSITORY_DOOM_CONFIG_TEMPLATES, type RepositoryDoomInitOptions, type RepositoryDoomInitResult, type ResolvedDomain, type ResolvedLayerDefinition, type ResolvedPackageConfiguration, type ResolvedVoiceAutoCaptureConfig, type ResolvedVoiceConfig, type VoiceAdapterConfig, type VoiceAutoCaptureConfig, type VoiceConfig, type VoiceEngine, type VoiceModelConfig, type VoiceTtsConfig, type VoiceTtsEngine, type WriteDoomConfigOptions, acknowledgeDoomConfigTransition, appendDoomConfigSelection, appendDoomConfigTransition, applyProfileEnvironment, buildPersonaPrompt, configLeafKeys, configRootKeys, configScopeOf, createDoomConfigContext, createDoomConfigContextAsync, createHarnessSession, disposeHarnessState, domainCompletionItems, domainCompletionPrefix, expandDomainNames, findPluginManifestPath, freezeDoomConfigContext, getHarnessState, globalDoomConfigDirectory, globalDoomConfigPath, harnessRoot, initializeGlobalDoomConfig, initializeRepositoryDoomConfig, isLocalPackageSpecifier, isRemotePluginSource, layerEntries, layerHookGroups, listDomainNames, listProfileNames, loadDomains, loadDoomConfig, loadDoomConfigAsync, loadDoomConfigLayers, loadHarnessState, loadMajorModesConfig, loadPiConfig, loadPiConfigAsync, loadProfiles, mergeDoomConfigs, parseAutocompactModeConfig, parseDoomConfig, parsePlanningModeConfig, piConfigPaths, pluginDirectoryForSource, projectHarnessEnvironment, provideDoomConfigContext, readDoomConfigContextGeneration, readDoomConfigPendingSelection, readDoomConfigSelection, readHarnessState, replaceDoomConfigContext, replaceProfileEnvironment, repositoryDoomConfigPath, requireDoomConfigContext, requireHarnessPaths, requireHarnessRoot, resetHarnessStore, resolveLayers, resolvePackageConfigurations, resolvePlanningPlansDirectory, resolvePluginDirectories, resolvePluginEntries, resolveProfile, resolveSharedSkills, resolveVoiceConfig, restoreHarnessStateSnapshot, setDoomConfigValue, snapshotHarnessState, supersedeDoomConfigTransition, unsetDoomConfigValue, updateHarnessState, valueAtKeyPath, writeDoomConfigValues, writePrivateAtomicJson };
|
|
20
|
+
export { type AgentProfile, type AutocompactModeConfig, type AutocompactThresholdConfig, type ConfigAdapterRegistrationOptions, type ConfigKeyScope, type ConfigValueOrigin, DEFAULT_IMAGE_MAX_DIMENSION, DOOM_CONFIG_ENTRY_TYPE, DOOM_CONFIG_SERVICE, DOOM_CONFIG_TEMPLATES, DOOM_CONFIG_TRANSITION_ENTRY_TYPE, DOOM_DIR, DOOM_PLANNING_THINKING_LEVELS, DOOM_VOICE_ENGINES, DOOM_VOICE_TTS_ENGINES, type DeepReadonly, type DomainDefinition, type DomainManifest, type DomainMcpAllowlist, type DomainPlugin, type DoomConfig, type DoomConfigContext, type DoomConfigEdit, type DoomConfigLayer, type DoomConfigLayers, type DoomConfigPendingSelection, type DoomConfigScope, type DoomConfigSelection, type DoomConfigTransitionPhase, type DoomConfigTransitionRecord, type DoomConfigTransitionStrategy, type DoomHarnessContext, type DoomSelectionConfig, type EditorConfig, FILE_ONLY_STATE_FIELDS, GLOBAL_DOOM_SEED_FILES, type GitPluginSource, type GlobalDoomInitResult, HARNESS_STATE_KEYS, HARNESS_STATE_POINTER, type HarnessState, type HarnessStateFile, type HarnessStateParseReporter, type HarnessStateTransactionSnapshot, type IDoomConfigLoader, type IDoomConfigService, type LayerDefinition, type LayerPackage, type LayerPackageConfig, type LayerResolvers, type LoadedHarnessState, type LocalPluginSource, MARKETPLACE_MANIFEST_RELATIVE_PATHS, MIN_IMAGE_MAX_DIMENSION, type MajorModeDefinition, type MajorModesConfig, type NpmPluginSource, PERSONA_FILES, type PackageAttribution, type PiConfig, type PiConfigLoadOptions, type PiConfigPaths, type PiImageSettings, type PiImageSettingsUpdate, type PlanningAgentConfig, type PlanningModeConfig, type PlanningThinkingLevel, type PluginCatalog, type PluginCatalogEntry, type PluginEntry, type PluginHookSource, type PluginManifestMetadata, type PluginSkillDiscovery, type PluginSource, type ProjectTrust, REPOSITORY_DOOM_CONFIG_TEMPLATES, type RepositoryDoomInitOptions, type RepositoryDoomInitResult, type ResolvedDomain, type ResolvedLayerDefinition, type ResolvedPackageConfiguration, type ResolvedVoiceAutoCaptureConfig, type ResolvedVoiceConfig, type VoiceAdapterConfig, type VoiceAutoCaptureConfig, type VoiceConfig, type VoiceEngine, type VoiceModelConfig, type VoiceTtsConfig, type VoiceTtsEngine, type WriteDoomConfigOptions, acknowledgeDoomConfigTransition, appendDoomConfigSelection, appendDoomConfigTransition, applyProfileEnvironment, buildPersonaPrompt, clampImageMaxDimension, configLeafKeys, configRootKeys, configScopeOf, createDoomConfigContext, createDoomConfigContextAsync, createHarnessSession, disposeHarnessState, domainCompletionItems, domainCompletionPrefix, expandDomainNames, findPluginManifestPath, freezeDoomConfigContext, getHarnessState, globalDoomConfigDirectory, globalDoomConfigPath, harnessRoot, initializeGlobalDoomConfig, initializeRepositoryDoomConfig, isLocalPackageSpecifier, isRemotePluginSource, layerEntries, layerHookGroups, listDomainNames, listProfileNames, loadDomains, loadDoomConfig, loadDoomConfigAsync, loadDoomConfigLayers, loadHarnessState, loadMajorModesConfig, loadPiConfig, loadPiConfigAsync, loadPiImageSettings, loadProfiles, mergeDoomConfigs, parseAutocompactModeConfig, parseDoomConfig, parsePiImageSettings, parsePlanningModeConfig, piConfigPaths, piImageSettingsPath, pluginDirectoryForSource, projectHarnessEnvironment, provideDoomConfigContext, readDoomConfigContextGeneration, readDoomConfigPendingSelection, readDoomConfigSelection, readHarnessState, replaceDoomConfigContext, replaceProfileEnvironment, repositoryDoomConfigPath, requireDoomConfigContext, requireHarnessPaths, requireHarnessRoot, resetHarnessStore, resolveLayers, resolvePackageConfigurations, resolvePlanningPlansDirectory, resolvePluginDirectories, resolvePluginEntries, resolveProfile, resolveSharedSkills, resolveVoiceConfig, restoreHarnessStateSnapshot, savePiImageSettings, setDoomConfigValue, snapshotHarnessState, supersedeDoomConfigTransition, unsetDoomConfigValue, updateHarnessState, valueAtKeyPath, writeDoomConfigValues, writePrivateAtomicJson };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writePrivateAtomicJson as e}from"./adapters/atomicJson.mjs";import{DOOM_PLANNING_THINKING_LEVELS as t,DOOM_VOICE_ENGINES as n,DOOM_VOICE_TTS_ENGINES as r,configLeafKeys as i,configRootKeys as a,configScopeOf as o,mergeDoomConfigs as s,parseAutocompactModeConfig as c,parseDoomConfig as l,parsePlanningModeConfig as u,resolveVoiceConfig as d,valueAtKeyPath as f}from"./services/configPolicy.mjs";import{globalDoomConfigDirectory as p,globalDoomConfigPath as m,loadDoomConfig as h,loadDoomConfigAsync as g,loadDoomConfigLayers as _,repositoryDoomConfigPath as v,resolvePlanningPlansDirectory as y}from"./adapters/config.mjs";import{setDoomConfigValue as b,unsetDoomConfigValue as x,writeDoomConfigValues as S}from"./adapters/configWriter.mjs";import{domainCompletionItems as C,domainCompletionPrefix as w,expandDomainNames as T}from"./services/domains.mjs";import{DOOM_DIR as E}from"./adapters/layeredConfig.mjs";import{MARKETPLACE_MANIFEST_RELATIVE_PATHS as D,findPluginManifestPath as O,isRemotePluginSource as k,pluginDirectoryForSource as A}from"./adapters/pluginCatalog.mjs";import{listDomainNames as j,loadDomains as M,resolvePluginDirectories as N,resolvePluginEntries as P,resolveSharedSkills as F}from"./adapters/domains.mjs";import{FILE_ONLY_STATE_FIELDS as I,HARNESS_STATE_KEYS as L,projectHarnessEnvironment as R,readHarnessState as z}from"./adapters/harnessState.mjs";import{HARNESS_STATE_POINTER as B,createHarnessSession as V,disposeHarnessState as H,getHarnessState as U,harnessRoot as W,loadHarnessState as G,requireHarnessPaths as K,requireHarnessRoot as q,resetHarnessStore as J,restoreHarnessStateSnapshot as Y,snapshotHarnessState as X,updateHarnessState as Z}from"./adapters/harnessStore.mjs";import{DOOM_CONFIG_TEMPLATES as Q,GLOBAL_DOOM_SEED_FILES as $,REPOSITORY_DOOM_CONFIG_TEMPLATES as ee,initializeGlobalDoomConfig as te,initializeRepositoryDoomConfig as ne}from"./adapters/init.mjs";import{isLocalPackageSpecifier as re,layerEntries as ie,layerHookGroups as ae,loadMajorModesConfig as oe,resolveLayers as se,resolvePackageConfigurations as ce}from"./adapters/majorModes.mjs";import{DOOM_CONFIG_SERVICE as le}from"./types/config.mjs";import{DOOM_CONFIG_ENTRY_TYPE as ue,DOOM_CONFIG_TRANSITION_ENTRY_TYPE as de,acknowledgeDoomConfigTransition as fe,appendDoomConfigSelection as pe,appendDoomConfigTransition as me,createDoomConfigContext as he,createDoomConfigContextAsync as ge,freezeDoomConfigContext as _e,provideDoomConfigContext as ve,readDoomConfigContextGeneration as ye,readDoomConfigPendingSelection as be,readDoomConfigSelection as xe,replaceDoomConfigContext as Se,requireDoomConfigContext as Ce,supersedeDoomConfigTransition as we}from"./adapters/pi/piContext.mjs";import{
|
|
1
|
+
import{writePrivateAtomicJson as e}from"./adapters/atomicJson.mjs";import{DOOM_PLANNING_THINKING_LEVELS as t,DOOM_VOICE_ENGINES as n,DOOM_VOICE_TTS_ENGINES as r,configLeafKeys as i,configRootKeys as a,configScopeOf as o,mergeDoomConfigs as s,parseAutocompactModeConfig as c,parseDoomConfig as l,parsePlanningModeConfig as u,resolveVoiceConfig as d,valueAtKeyPath as f}from"./services/configPolicy.mjs";import{globalDoomConfigDirectory as p,globalDoomConfigPath as m,loadDoomConfig as h,loadDoomConfigAsync as g,loadDoomConfigLayers as _,repositoryDoomConfigPath as v,resolvePlanningPlansDirectory as y}from"./adapters/config.mjs";import{setDoomConfigValue as b,unsetDoomConfigValue as x,writeDoomConfigValues as S}from"./adapters/configWriter.mjs";import{domainCompletionItems as C,domainCompletionPrefix as w,expandDomainNames as T}from"./services/domains.mjs";import{DOOM_DIR as E}from"./adapters/layeredConfig.mjs";import{MARKETPLACE_MANIFEST_RELATIVE_PATHS as D,findPluginManifestPath as O,isRemotePluginSource as k,pluginDirectoryForSource as A}from"./adapters/pluginCatalog.mjs";import{listDomainNames as j,loadDomains as M,resolvePluginDirectories as N,resolvePluginEntries as P,resolveSharedSkills as F}from"./adapters/domains.mjs";import{FILE_ONLY_STATE_FIELDS as I,HARNESS_STATE_KEYS as L,projectHarnessEnvironment as R,readHarnessState as z}from"./adapters/harnessState.mjs";import{HARNESS_STATE_POINTER as B,createHarnessSession as V,disposeHarnessState as H,getHarnessState as U,harnessRoot as W,loadHarnessState as G,requireHarnessPaths as K,requireHarnessRoot as q,resetHarnessStore as J,restoreHarnessStateSnapshot as Y,snapshotHarnessState as X,updateHarnessState as Z}from"./adapters/harnessStore.mjs";import{DOOM_CONFIG_TEMPLATES as Q,GLOBAL_DOOM_SEED_FILES as $,REPOSITORY_DOOM_CONFIG_TEMPLATES as ee,initializeGlobalDoomConfig as te,initializeRepositoryDoomConfig as ne}from"./adapters/init.mjs";import{isLocalPackageSpecifier as re,layerEntries as ie,layerHookGroups as ae,loadMajorModesConfig as oe,resolveLayers as se,resolvePackageConfigurations as ce}from"./adapters/majorModes.mjs";import{DOOM_CONFIG_SERVICE as le}from"./types/config.mjs";import{DOOM_CONFIG_ENTRY_TYPE as ue,DOOM_CONFIG_TRANSITION_ENTRY_TYPE as de,acknowledgeDoomConfigTransition as fe,appendDoomConfigSelection as pe,appendDoomConfigTransition as me,createDoomConfigContext as he,createDoomConfigContextAsync as ge,freezeDoomConfigContext as _e,provideDoomConfigContext as ve,readDoomConfigContextGeneration as ye,readDoomConfigPendingSelection as be,readDoomConfigSelection as xe,replaceDoomConfigContext as Se,requireDoomConfigContext as Ce,supersedeDoomConfigTransition as we}from"./adapters/pi/piContext.mjs";import{DEFAULT_IMAGE_MAX_DIMENSION as Te,MIN_IMAGE_MAX_DIMENSION as Ee,clampImageMaxDimension as De,parsePiImageSettings as Oe}from"./services/imageSettings.mjs";import{loadPiConfig as ke,loadPiConfigAsync as Ae,loadPiImageSettings as je,piConfigPaths as Me,piImageSettingsPath as Ne,savePiImageSettings as Pe}from"./adapters/piConfig.mjs";import{PERSONA_FILES as Fe,applyProfileEnvironment as Ie,buildPersonaPrompt as Le,listProfileNames as Re,loadProfiles as ze,replaceProfileEnvironment as Be,resolveProfile as Ve}from"./adapters/profiles.mjs";export{Te as DEFAULT_IMAGE_MAX_DIMENSION,ue as DOOM_CONFIG_ENTRY_TYPE,le as DOOM_CONFIG_SERVICE,Q as DOOM_CONFIG_TEMPLATES,de as DOOM_CONFIG_TRANSITION_ENTRY_TYPE,E as DOOM_DIR,t as DOOM_PLANNING_THINKING_LEVELS,n as DOOM_VOICE_ENGINES,r as DOOM_VOICE_TTS_ENGINES,I as FILE_ONLY_STATE_FIELDS,$ as GLOBAL_DOOM_SEED_FILES,L as HARNESS_STATE_KEYS,B as HARNESS_STATE_POINTER,D as MARKETPLACE_MANIFEST_RELATIVE_PATHS,Ee as MIN_IMAGE_MAX_DIMENSION,Fe as PERSONA_FILES,ee as REPOSITORY_DOOM_CONFIG_TEMPLATES,fe as acknowledgeDoomConfigTransition,pe as appendDoomConfigSelection,me as appendDoomConfigTransition,Ie as applyProfileEnvironment,Le as buildPersonaPrompt,De as clampImageMaxDimension,i as configLeafKeys,a as configRootKeys,o as configScopeOf,he as createDoomConfigContext,ge as createDoomConfigContextAsync,V as createHarnessSession,H as disposeHarnessState,C as domainCompletionItems,w as domainCompletionPrefix,T as expandDomainNames,O as findPluginManifestPath,_e as freezeDoomConfigContext,U as getHarnessState,p as globalDoomConfigDirectory,m as globalDoomConfigPath,W as harnessRoot,te as initializeGlobalDoomConfig,ne as initializeRepositoryDoomConfig,re as isLocalPackageSpecifier,k as isRemotePluginSource,ie as layerEntries,ae as layerHookGroups,j as listDomainNames,Re as listProfileNames,M as loadDomains,h as loadDoomConfig,g as loadDoomConfigAsync,_ as loadDoomConfigLayers,G as loadHarnessState,oe as loadMajorModesConfig,ke as loadPiConfig,Ae as loadPiConfigAsync,je as loadPiImageSettings,ze as loadProfiles,s as mergeDoomConfigs,c as parseAutocompactModeConfig,l as parseDoomConfig,Oe as parsePiImageSettings,u as parsePlanningModeConfig,Me as piConfigPaths,Ne as piImageSettingsPath,A as pluginDirectoryForSource,R as projectHarnessEnvironment,ve as provideDoomConfigContext,ye as readDoomConfigContextGeneration,be as readDoomConfigPendingSelection,xe as readDoomConfigSelection,z as readHarnessState,Se as replaceDoomConfigContext,Be as replaceProfileEnvironment,v as repositoryDoomConfigPath,Ce as requireDoomConfigContext,K as requireHarnessPaths,q as requireHarnessRoot,J as resetHarnessStore,se as resolveLayers,ce as resolvePackageConfigurations,y as resolvePlanningPlansDirectory,N as resolvePluginDirectories,P as resolvePluginEntries,Ve as resolveProfile,F as resolveSharedSkills,d as resolveVoiceConfig,Y as restoreHarnessStateSnapshot,Pe as savePiImageSettings,b as setDoomConfigValue,X as snapshotHarnessState,we as supersedeDoomConfigTransition,x as unsetDoomConfigValue,Z as updateHarnessState,f as valueAtKeyPath,S as writeDoomConfigValues,e as writePrivateAtomicJson};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`images`,t=`autoResize`,n=`maxDimension`,r=2e3;function i(e){let t=Math.round(e);return t<256?256:t>2e3?r:t}function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function o(o){let s=o[e];if(!a(s))return{autoResize:!0,maxDimension:r};let c=s[t],l=s[n];return{autoResize:typeof c!=`boolean`||c,maxDimension:typeof l==`number`&&Number.isFinite(l)?i(l):r}}function s(r,o){let s=r[e],c=a(s)?{...s}:{};return o.autoResize!==void 0&&(c[t]=o.autoResize),o.maxDimension!==void 0&&(c[n]=i(o.maxDimension)),{...r,[e]:c}}exports.DEFAULT_IMAGE_MAX_DIMENSION=r,exports.IMAGE_AUTO_RESIZE_KEY=t,exports.IMAGE_MAX_DIMENSION_KEY=n,exports.IMAGE_SETTINGS_KEY=e,exports.MIN_IMAGE_MAX_DIMENSION=256,exports.applyPiImageSettings=s,exports.clampImageMaxDimension=i,exports.parsePiImageSettings=o;
|
|
2
|
+
//# sourceMappingURL=imageSettings.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSettings.cjs","names":[],"sources":["../../src/services/imageSettings.ts"],"sourcesContent":["/**\n * The image limits every DoomPi surface applies before an image reaches a model.\n *\n * Pi already owns half of this: `images.autoResize` lives in its settings.json\n * and its resize core hardcodes a 2000px cap. What Pi has no place for is a\n * smaller cap, so `images.maxDimension` is Doom's key written into the same\n * file, because a machine should describe how images reach a model in one\n * place rather than two.\n *\n * A cap above Pi's own is not offered. Pi normalizes every tool result image at\n * 2000px as it enters session history, so a larger number would hold on a\n * pasted image and be silently undone on a read. Clamping says so instead of\n * letting the two surfaces disagree.\n *\n * AVOID:\n * - Reading these keys straight off a config record; a hand-written file holds\n * strings, nulls and negative numbers, and only this parser answers for them.\n */\n\nimport type { PiConfig } from '../schemas/config/schema.ts';\n\nexport const IMAGE_SETTINGS_KEY = 'images';\nexport const IMAGE_AUTO_RESIZE_KEY = 'autoResize';\nexport const IMAGE_MAX_DIMENSION_KEY = 'maxDimension';\n\n/** Pi's own cap, from its resize core; also the largest value worth writing. */\nexport const DEFAULT_IMAGE_MAX_DIMENSION = 2000;\n/** Below this a screenshot stops being readable, which is what reads are for. */\nexport const MIN_IMAGE_MAX_DIMENSION = 256;\n\nexport interface PiImageSettings {\n /** Pi's own toggle. Unset is on, matching Pi's default. */\n autoResize: boolean;\n /** The longest edge an image keeps once resizing is on. */\n maxDimension: number;\n}\n\n/** The written form of a change; an absent field leaves that key alone. */\nexport interface PiImageSettingsUpdate {\n autoResize?: boolean;\n maxDimension?: number;\n}\n\nexport function clampImageMaxDimension(value: number): number {\n const rounded = Math.round(value);\n if (rounded < MIN_IMAGE_MAX_DIMENSION) return MIN_IMAGE_MAX_DIMENSION;\n if (rounded > DEFAULT_IMAGE_MAX_DIMENSION) return DEFAULT_IMAGE_MAX_DIMENSION;\n return rounded;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Resolves the effective limits, defaulting anything absent or unusable. */\nexport function parsePiImageSettings(config: PiConfig): PiImageSettings {\n const images = config[IMAGE_SETTINGS_KEY];\n if (!isRecord(images)) return { autoResize: true, maxDimension: DEFAULT_IMAGE_MAX_DIMENSION };\n const autoResize = images[IMAGE_AUTO_RESIZE_KEY];\n const maxDimension = images[IMAGE_MAX_DIMENSION_KEY];\n return {\n autoResize: typeof autoResize === 'boolean' ? autoResize : true,\n maxDimension:\n typeof maxDimension === 'number' && Number.isFinite(maxDimension)\n ? clampImageMaxDimension(maxDimension)\n : DEFAULT_IMAGE_MAX_DIMENSION,\n };\n}\n\n/**\n * Folds a change into the `images` object of a settings document, leaving every\n * other key of that document, and of `images` itself, as it was.\n */\nexport function applyPiImageSettings(config: PiConfig, update: PiImageSettingsUpdate): PiConfig {\n const existing = config[IMAGE_SETTINGS_KEY];\n const images: Record<string, unknown> = isRecord(existing) ? { ...existing } : {};\n if (update.autoResize !== undefined) images[IMAGE_AUTO_RESIZE_KEY] = update.autoResize;\n if (update.maxDimension !== undefined) images[IMAGE_MAX_DIMENSION_KEY] = clampImageMaxDimension(update.maxDimension);\n return { ...config, [IMAGE_SETTINGS_KEY]: images };\n}\n"],"mappings":"AAqBA,MAAa,EAAqB,SACrB,EAAwB,aACxB,EAA0B,eAG1B,EAA8B,IAiB3C,SAAgB,EAAuB,EAAuB,CAC5D,IAAM,EAAU,KAAK,MAAM,CAAK,EAGhC,OAFI,EAAA,IAAmC,IACnC,EAAA,IAA8C,EAC3C,CACT,CAEA,SAAS,EAAS,EAAkD,CAClE,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAGA,SAAgB,EAAqB,EAAmC,CACtE,IAAM,EAAS,EAAO,GACtB,GAAI,CAAC,EAAS,CAAM,EAAG,MAAO,CAAE,WAAY,GAAM,aAAc,CAA4B,EAC5F,IAAM,EAAa,EAAO,GACpB,EAAe,EAAO,GAC5B,MAAO,CACL,WAAY,OAAO,GAAe,WAAY,EAC9C,aACE,OAAO,GAAiB,UAAY,OAAO,SAAS,CAAY,EAC5D,EAAuB,CAAY,EACnC,CACR,CACF,CAMA,SAAgB,EAAqB,EAAkB,EAAyC,CAC9F,IAAM,EAAW,EAAO,GAClB,EAAkC,EAAS,CAAQ,EAAI,CAAE,GAAG,CAAS,EAAI,CAAC,EAGhF,OAFI,EAAO,aAAe,IAAA,KAAW,EAAO,GAAyB,EAAO,YACxE,EAAO,eAAiB,IAAA,KAAW,EAAO,GAA2B,EAAuB,EAAO,YAAY,GAC5G,CAAE,GAAG,GAAS,GAAqB,CAAO,CACnD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PiConfig } from "../schemas/config/schema.cjs";
|
|
2
|
+
//#region src/services/imageSettings.d.ts
|
|
3
|
+
/** Pi's own cap, from its resize core; also the largest value worth writing. */
|
|
4
|
+
declare const DEFAULT_IMAGE_MAX_DIMENSION = 2000;
|
|
5
|
+
/** Below this a screenshot stops being readable, which is what reads are for. */
|
|
6
|
+
declare const MIN_IMAGE_MAX_DIMENSION = 256;
|
|
7
|
+
interface PiImageSettings {
|
|
8
|
+
/** Pi's own toggle. Unset is on, matching Pi's default. */
|
|
9
|
+
autoResize: boolean;
|
|
10
|
+
/** The longest edge an image keeps once resizing is on. */
|
|
11
|
+
maxDimension: number;
|
|
12
|
+
}
|
|
13
|
+
/** The written form of a change; an absent field leaves that key alone. */
|
|
14
|
+
interface PiImageSettingsUpdate {
|
|
15
|
+
autoResize?: boolean;
|
|
16
|
+
maxDimension?: number;
|
|
17
|
+
}
|
|
18
|
+
declare function clampImageMaxDimension(value: number): number;
|
|
19
|
+
/** Resolves the effective limits, defaulting anything absent or unusable. */
|
|
20
|
+
declare function parsePiImageSettings(config: PiConfig): PiImageSettings;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, PiImageSettings, PiImageSettingsUpdate, clampImageMaxDimension, parsePiImageSettings };
|
|
23
|
+
//# sourceMappingURL=imageSettings.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSettings.d.cts","names":[],"sources":["../../src/services/imageSettings.ts"],"mappings":";;;cA0Ba;;cAEA;UAEI;;EAEf;;EAEA;;;UAIe;EACf;EACA;;iBAGc,uBAAuB;;iBAYvB,qBAAqB,QAAQ,WAAW"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PiConfig } from "../schemas/config/schema.mjs";
|
|
2
|
+
//#region src/services/imageSettings.d.ts
|
|
3
|
+
/** Pi's own cap, from its resize core; also the largest value worth writing. */
|
|
4
|
+
declare const DEFAULT_IMAGE_MAX_DIMENSION = 2000;
|
|
5
|
+
/** Below this a screenshot stops being readable, which is what reads are for. */
|
|
6
|
+
declare const MIN_IMAGE_MAX_DIMENSION = 256;
|
|
7
|
+
interface PiImageSettings {
|
|
8
|
+
/** Pi's own toggle. Unset is on, matching Pi's default. */
|
|
9
|
+
autoResize: boolean;
|
|
10
|
+
/** The longest edge an image keeps once resizing is on. */
|
|
11
|
+
maxDimension: number;
|
|
12
|
+
}
|
|
13
|
+
/** The written form of a change; an absent field leaves that key alone. */
|
|
14
|
+
interface PiImageSettingsUpdate {
|
|
15
|
+
autoResize?: boolean;
|
|
16
|
+
maxDimension?: number;
|
|
17
|
+
}
|
|
18
|
+
declare function clampImageMaxDimension(value: number): number;
|
|
19
|
+
/** Resolves the effective limits, defaulting anything absent or unusable. */
|
|
20
|
+
declare function parsePiImageSettings(config: PiConfig): PiImageSettings;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { DEFAULT_IMAGE_MAX_DIMENSION, MIN_IMAGE_MAX_DIMENSION, PiImageSettings, PiImageSettingsUpdate, clampImageMaxDimension, parsePiImageSettings };
|
|
23
|
+
//# sourceMappingURL=imageSettings.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSettings.d.mts","names":[],"sources":["../../src/services/imageSettings.ts"],"mappings":";;;cA0Ba;;cAEA;UAEI;;EAEf;;EAEA;;;UAIe;EACf;EACA;;iBAGc,uBAAuB;;iBAYvB,qBAAqB,QAAQ,WAAW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`images`,t=`autoResize`,n=`maxDimension`,r=2e3,i=256;function a(e){let t=Math.round(e);return t<256?256:t>2e3?r:t}function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(i){let s=i[e];if(!o(s))return{autoResize:!0,maxDimension:r};let c=s[t],l=s[n];return{autoResize:typeof c!=`boolean`||c,maxDimension:typeof l==`number`&&Number.isFinite(l)?a(l):r}}function c(r,i){let s=r[e],c=o(s)?{...s}:{};return i.autoResize!==void 0&&(c[t]=i.autoResize),i.maxDimension!==void 0&&(c[n]=a(i.maxDimension)),{...r,[e]:c}}export{r as DEFAULT_IMAGE_MAX_DIMENSION,t as IMAGE_AUTO_RESIZE_KEY,n as IMAGE_MAX_DIMENSION_KEY,e as IMAGE_SETTINGS_KEY,i as MIN_IMAGE_MAX_DIMENSION,c as applyPiImageSettings,a as clampImageMaxDimension,s as parsePiImageSettings};
|
|
2
|
+
//# sourceMappingURL=imageSettings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSettings.mjs","names":[],"sources":["../../src/services/imageSettings.ts"],"sourcesContent":["/**\n * The image limits every DoomPi surface applies before an image reaches a model.\n *\n * Pi already owns half of this: `images.autoResize` lives in its settings.json\n * and its resize core hardcodes a 2000px cap. What Pi has no place for is a\n * smaller cap, so `images.maxDimension` is Doom's key written into the same\n * file, because a machine should describe how images reach a model in one\n * place rather than two.\n *\n * A cap above Pi's own is not offered. Pi normalizes every tool result image at\n * 2000px as it enters session history, so a larger number would hold on a\n * pasted image and be silently undone on a read. Clamping says so instead of\n * letting the two surfaces disagree.\n *\n * AVOID:\n * - Reading these keys straight off a config record; a hand-written file holds\n * strings, nulls and negative numbers, and only this parser answers for them.\n */\n\nimport type { PiConfig } from '../schemas/config/schema.ts';\n\nexport const IMAGE_SETTINGS_KEY = 'images';\nexport const IMAGE_AUTO_RESIZE_KEY = 'autoResize';\nexport const IMAGE_MAX_DIMENSION_KEY = 'maxDimension';\n\n/** Pi's own cap, from its resize core; also the largest value worth writing. */\nexport const DEFAULT_IMAGE_MAX_DIMENSION = 2000;\n/** Below this a screenshot stops being readable, which is what reads are for. */\nexport const MIN_IMAGE_MAX_DIMENSION = 256;\n\nexport interface PiImageSettings {\n /** Pi's own toggle. Unset is on, matching Pi's default. */\n autoResize: boolean;\n /** The longest edge an image keeps once resizing is on. */\n maxDimension: number;\n}\n\n/** The written form of a change; an absent field leaves that key alone. */\nexport interface PiImageSettingsUpdate {\n autoResize?: boolean;\n maxDimension?: number;\n}\n\nexport function clampImageMaxDimension(value: number): number {\n const rounded = Math.round(value);\n if (rounded < MIN_IMAGE_MAX_DIMENSION) return MIN_IMAGE_MAX_DIMENSION;\n if (rounded > DEFAULT_IMAGE_MAX_DIMENSION) return DEFAULT_IMAGE_MAX_DIMENSION;\n return rounded;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Resolves the effective limits, defaulting anything absent or unusable. */\nexport function parsePiImageSettings(config: PiConfig): PiImageSettings {\n const images = config[IMAGE_SETTINGS_KEY];\n if (!isRecord(images)) return { autoResize: true, maxDimension: DEFAULT_IMAGE_MAX_DIMENSION };\n const autoResize = images[IMAGE_AUTO_RESIZE_KEY];\n const maxDimension = images[IMAGE_MAX_DIMENSION_KEY];\n return {\n autoResize: typeof autoResize === 'boolean' ? autoResize : true,\n maxDimension:\n typeof maxDimension === 'number' && Number.isFinite(maxDimension)\n ? clampImageMaxDimension(maxDimension)\n : DEFAULT_IMAGE_MAX_DIMENSION,\n };\n}\n\n/**\n * Folds a change into the `images` object of a settings document, leaving every\n * other key of that document, and of `images` itself, as it was.\n */\nexport function applyPiImageSettings(config: PiConfig, update: PiImageSettingsUpdate): PiConfig {\n const existing = config[IMAGE_SETTINGS_KEY];\n const images: Record<string, unknown> = isRecord(existing) ? { ...existing } : {};\n if (update.autoResize !== undefined) images[IMAGE_AUTO_RESIZE_KEY] = update.autoResize;\n if (update.maxDimension !== undefined) images[IMAGE_MAX_DIMENSION_KEY] = clampImageMaxDimension(update.maxDimension);\n return { ...config, [IMAGE_SETTINGS_KEY]: images };\n}\n"],"mappings":"AAqBA,MAAa,EAAqB,SACrB,EAAwB,aACxB,EAA0B,eAG1B,EAA8B,IAE9B,EAA0B,IAevC,SAAgB,EAAuB,EAAuB,CAC5D,IAAM,EAAU,KAAK,MAAM,CAAK,EAGhC,OAFI,EAAA,IAAmC,IACnC,EAAA,IAA8C,EAC3C,CACT,CAEA,SAAS,EAAS,EAAkD,CAClE,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAGA,SAAgB,EAAqB,EAAmC,CACtE,IAAM,EAAS,EAAO,GACtB,GAAI,CAAC,EAAS,CAAM,EAAG,MAAO,CAAE,WAAY,GAAM,aAAc,CAA4B,EAC5F,IAAM,EAAa,EAAO,GACpB,EAAe,EAAO,GAC5B,MAAO,CACL,WAAY,OAAO,GAAe,WAAY,EAC9C,aACE,OAAO,GAAiB,UAAY,OAAO,SAAS,CAAY,EAC5D,EAAuB,CAAY,EACnC,CACR,CACF,CAMA,SAAgB,EAAqB,EAAkB,EAAyC,CAC9F,IAAM,EAAW,EAAO,GAClB,EAAkC,EAAS,CAAQ,EAAI,CAAE,GAAG,CAAS,EAAI,CAAC,EAGhF,OAFI,EAAO,aAAe,IAAA,KAAW,EAAO,GAAyB,EAAO,YACxE,EAAO,eAAiB,IAAA,KAAW,EAAO,GAA2B,EAAuB,EAAO,YAAY,GAC5G,CAAE,GAAG,GAAS,GAAqB,CAAO,CACnD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/doompi-config",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.49",
|
|
4
4
|
"description": "Typed configuration loading, validation, and host adapters for composing DoomPi sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-configuration",
|
|
@@ -136,8 +136,8 @@
|
|
|
136
136
|
"dependencies": {
|
|
137
137
|
"@deepseek-ai/cordis": "4.0.1",
|
|
138
138
|
"yaml": "2.9.0",
|
|
139
|
-
"@agimon-ai/doompi-
|
|
140
|
-
"@agimon-ai/doompi-
|
|
139
|
+
"@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.49",
|
|
140
|
+
"@agimon-ai/doompi-telemetry": "0.0.1-alpha.49"
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
143
|
"@earendil-works/pi-coding-agent": "0.84.4",
|