@agimon-ai/doompi-profile 0.0.1-alpha.10

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  4. package/dist/adapters/pi/extension.cjs +2 -0
  5. package/dist/adapters/pi/extension.cjs.map +1 -0
  6. package/dist/adapters/pi/extension.d.cts +10 -0
  7. package/dist/adapters/pi/extension.d.cts.map +1 -0
  8. package/dist/adapters/pi/extension.d.mts +10 -0
  9. package/dist/adapters/pi/extension.d.mts.map +1 -0
  10. package/dist/adapters/pi/extension.mjs +2 -0
  11. package/dist/adapters/pi/extension.mjs.map +1 -0
  12. package/dist/adapters/pi/persona.cjs +2 -0
  13. package/dist/adapters/pi/persona.cjs.map +1 -0
  14. package/dist/adapters/pi/persona.d.cts +8 -0
  15. package/dist/adapters/pi/persona.d.cts.map +1 -0
  16. package/dist/adapters/pi/persona.d.mts +8 -0
  17. package/dist/adapters/pi/persona.d.mts.map +1 -0
  18. package/dist/adapters/pi/persona.mjs +2 -0
  19. package/dist/adapters/pi/persona.mjs.map +1 -0
  20. package/dist/adapters/telemetry/logSinkTelemetry.cjs +2 -0
  21. package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +1 -0
  22. package/dist/adapters/telemetry/logSinkTelemetry.d.cts +14 -0
  23. package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +1 -0
  24. package/dist/adapters/telemetry/logSinkTelemetry.d.mts +14 -0
  25. package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +1 -0
  26. package/dist/adapters/telemetry/logSinkTelemetry.mjs +2 -0
  27. package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +1 -0
  28. package/dist/commands/profileCommand.cjs +2 -0
  29. package/dist/commands/profileCommand.cjs.map +1 -0
  30. package/dist/commands/profileCommand.mjs +2 -0
  31. package/dist/commands/profileCommand.mjs.map +1 -0
  32. package/dist/extensions/persona.cjs +1 -0
  33. package/dist/extensions/persona.d.cts +2 -0
  34. package/dist/extensions/persona.d.mts +2 -0
  35. package/dist/extensions/persona.mjs +1 -0
  36. package/dist/extensions/pi.cjs +1 -0
  37. package/dist/extensions/pi.d.cts +2 -0
  38. package/dist/extensions/pi.d.mts +2 -0
  39. package/dist/extensions/pi.mjs +1 -0
  40. package/dist/index.cjs +1 -0
  41. package/dist/index.d.cts +6 -0
  42. package/dist/index.d.mts +6 -0
  43. package/dist/index.mjs +1 -0
  44. package/dist/services/profileText.cjs +3 -0
  45. package/dist/services/profileText.cjs.map +1 -0
  46. package/dist/services/profileText.d.cts +12 -0
  47. package/dist/services/profileText.d.cts.map +1 -0
  48. package/dist/services/profileText.d.mts +12 -0
  49. package/dist/services/profileText.d.mts.map +1 -0
  50. package/dist/services/profileText.mjs +3 -0
  51. package/dist/services/profileText.mjs.map +1 -0
  52. package/dist/types/telemetry.cjs +2 -0
  53. package/dist/types/telemetry.cjs.map +1 -0
  54. package/dist/types/telemetry.d.cts +16 -0
  55. package/dist/types/telemetry.d.cts.map +1 -0
  56. package/dist/types/telemetry.d.mts +16 -0
  57. package/dist/types/telemetry.d.mts.map +1 -0
  58. package/dist/types/telemetry.mjs +2 -0
  59. package/dist/types/telemetry.mjs.map +1 -0
  60. package/llms.txt +12 -0
  61. package/package.json +98 -0
  62. package/src/prompts/doompi-author-profile/SKILL.md +20 -0
  63. package/src/prompts/doompi-author-profile/references/profiles-contract.md +100 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vuong Ngo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # @agimon-ai/doompi-profile
2
+
3
+ Persona and environment profile switching for [DoomPi](https://www.npmjs.com/package/@agimon-ai/doompi)
4
+ sessions.
5
+
6
+ A **profile** is one of the four axes of a DoomPi selection, alongside domains, the major mode,
7
+ and the minor modes. It names a persona directory and a set of environment defaults:
8
+
9
+ ```yaml
10
+ # .doom/profiles.yaml
11
+ profiles:
12
+ roots: [agents]
13
+ entries:
14
+ reviewer:
15
+ persona: agents/reviewer
16
+ env:
17
+ REVIEW_STRICTNESS: high
18
+ ```
19
+
20
+ The persona is `profile.md`, `SOUL.md`, and `AGENTS.md` concatenated from the named directory. The
21
+ harness assembles them into one file in the run directory and records its path; the persona entry
22
+ appends that file to the system prompt on every agent start, so the repository's own `AGENTS.md`
23
+ keeps applying underneath it.
24
+
25
+ ## What it registers
26
+
27
+ | Entry | Surface |
28
+ | ---------------------- | -------------------------------------------------------------------------------------------- |
29
+ | `./extensions/pi` | the `/profile` command, which lists profiles, switches persona and environment, then reloads |
30
+ | `./extensions/persona` | a `before_agent_start` hook that appends the active persona to the system prompt |
31
+
32
+ DoomPi uses two entries because a detached child session needs the persona but has no transition
33
+ coordinator to run a switch through. DoomPi activates `./extensions/pi` in the parent and
34
+ `./extensions/persona` in both.
35
+
36
+ ## Switching
37
+
38
+ `/profile` plans the change through the session's transition coordinator before applying anything.
39
+ A profile change is always a `pi-reload`: the extension set does not change, but module-level caches
40
+ have to be dropped so every extension re-reads the environment. Active minor modes are captured
41
+ before the reload and restored after it.
42
+
43
+ ## Configuration
44
+
45
+ Personal profiles load from `~/.pi/.doom/profiles.yaml`, then repository profiles load from
46
+ `.doom/profiles.yaml`. Roots discover either one persona folder or direct-child persona folders.
47
+ Explicit entries provide a persona path and optional string environment defaults. Resolution runs
48
+ from personal discovery to repository discovery, then personal explicit entries to repository
49
+ explicit entries. A later profile replaces an earlier profile with the same name.
50
+
51
+ Persona paths must stay inside the declaring config's `agents/` directory or a profile root from
52
+ that same file. Directory and persona-file symlinks cannot escape those boundaries. See the
53
+ shipped [profiles contract](./src/prompts/doompi-author-profile/references/profiles-contract.md) for
54
+ the full configuration model and verification steps.
55
+
56
+ ## Help
57
+
58
+ The package registers `doompi-author-profile` with the session's `doom/help` Cordis service. Its
59
+ package guidance becomes visible to the AI only while the parent Help minor mode is active. The
60
+ registration follows the Help provider lifecycle and is withdrawn when this package or the provider
61
+ is disposed.
62
+
63
+ ## Installation
64
+
65
+ DoomPi depends on this package and activates it as fixed host core, so a DoomPi install already has
66
+ it. It is not selectable from `.doom/modes.yaml`.
67
+
68
+ ## License
69
+
70
+ MIT
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));exports.__toESM=s;
@@ -0,0 +1,2 @@
1
+ const e=require("../telemetry/logSinkTelemetry.cjs"),t=require("../../commands/profileCommand.cjs");let n=require("@agimon-ai/doompi-extension-contracts/config"),r=require("@agimon-ai/doompi-extension-contracts/cordis-host"),i=require("@agimon-ai/doompi-extension-contracts/help"),a=require("@agimon-ai/doompi-extension-contracts/transition");const o=`@agimon-ai/doompi-profile`;async function s(t,n=e.createProfileTelemetry()){let i=await(0,r.connectDoomCordisHost)(t,o),a=i.root.plugin(c,{pi:t,telemetry:n});try{await a}catch(e){try{await a.dispose()}finally{await i.dispose()}throw e}let s;t.on(`session_shutdown`,()=>s??=(async()=>{try{await a.dispose()}finally{await i.dispose()}})())}function c(e,r){e.inject([i.DOOM_HELP_SERVICE],e=>{let t=(0,i.requireDoomHelpService)(e).register({source:o,moduleUrl:require("url").pathToFileURL(__filename).href,skills:[{name:`doompi-author-profile`,description:`Configure DoomPi profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.`}]});return()=>t.dispose()});let s;e.inject([n.DOOM_CONFIG_SERVICE,a.DOOM_TRANSITION_SERVICE],e=>(s=e,()=>{s===e&&(s=void 0)}));let c=()=>{if(!s)throw Error(`Doom profile runtime is waiting for the session config service.`);return s};e.effect(function*(){t.registerProfileCommand(r.pi,r.telemetry,c),yield()=>void 0},o)}exports.default=s,exports.profileExtension=s;
2
+ //# sourceMappingURL=extension.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.cjs","names":["createProfileTelemetry","connectDoomCordisHost","DOOM_HELP_SERVICE","requireDoomHelpService","DOOM_CONFIG_SERVICE","DOOM_TRANSITION_SERVICE"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_HELP_SERVICE, requireDoomHelpService } from '@agimon-ai/doompi-extension-contracts/help';\nimport { DOOM_TRANSITION_SERVICE } from '@agimon-ai/doompi-extension-contracts/transition';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { registerProfileCommand } from '../../commands/profileCommand.ts';\nimport type { ProfileTelemetry } from '../../types/telemetry.ts';\nimport { createProfileTelemetry } from '../telemetry/logSinkTelemetry.ts';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-profile';\n\n/**\n * The package's single standard Pi factory.\n */\nexport async function profileExtension(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry = createProfileTelemetry(),\n): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(profilePlugin, { pi, telemetry });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\ninterface ProfilePluginConfig {\n readonly pi: ExtensionAPI;\n readonly telemetry: ProfileTelemetry;\n}\n\nfunction profilePlugin(cordis: Context, config: ProfilePluginConfig): void {\n cordis.inject([DOOM_HELP_SERVICE], (helpContext) => {\n const contribution = requireDoomHelpService(helpContext).register({\n source: PACKAGE_SOURCE,\n moduleUrl: import.meta.url,\n skills: [\n {\n name: 'doompi-author-profile',\n description:\n 'Configure DoomPi profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.',\n },\n ],\n });\n return () => contribution.dispose();\n });\n\n let activeContext: Context | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE, DOOM_TRANSITION_SERVICE], (context) => {\n activeContext = context;\n return () => {\n if (activeContext === context) activeContext = undefined;\n };\n });\n const requireRuntimeContext = (): Context => {\n if (!activeContext) throw new Error('Doom profile runtime is waiting for the session config service.');\n return activeContext;\n };\n cordis.effect(function* () {\n registerProfileCommand(config.pi, config.telemetry, requireRuntimeContext);\n yield () => undefined;\n }, PACKAGE_SOURCE);\n}\n\nexport default profileExtension;\n"],"mappings":"uVAUA,MAAM,EAAiB,4BAKvB,eAAsB,EACpB,EACA,EAA8BA,EAAAA,uBAAuB,EACtC,CACf,IAAM,EAAa,MAAA,EAAMC,EAAAA,sBAAAA,CAAsB,EAAI,CAAc,EAC3D,EAAQ,EAAW,KAAK,OAAO,EAAe,CAAE,KAAI,WAAU,CAAC,EACrE,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CACd,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACA,MAAM,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF,CAOA,SAAS,EAAc,EAAiB,EAAmC,CACzE,EAAO,OAAO,CAACC,EAAAA,iBAAiB,EAAI,GAAgB,CAClD,IAAM,GAAA,EAAeC,EAAAA,uBAAAA,CAAuB,CAAW,CAAC,CAAC,SAAS,CAChE,OAAQ,EACR,UAAA,QAAA,KAAA,CAAA,CAAA,cAAA,UAAA,CAAA,CAAA,KACA,OAAQ,CACN,CACE,KAAM,wBACN,YACE,+OACJ,CACF,CACF,CAAC,EACD,UAAa,EAAa,QAAQ,CACpC,CAAC,EAED,IAAI,EACJ,EAAO,OAAO,CAACC,EAAAA,oBAAqBC,EAAAA,uBAAuB,EAAI,IAC7D,EAAgB,MACH,CACP,IAAkB,IAAS,EAAgB,IAAA,GACjD,EACD,EACD,IAAM,MAAuC,CAC3C,GAAI,CAAC,EAAe,MAAU,MAAM,iEAAiE,EACrG,OAAO,CACT,EACA,EAAO,OAAO,WAAa,CACzB,EAAA,uBAAuB,EAAO,GAAI,EAAO,UAAW,CAAqB,EACzE,SAAY,IAAA,EACd,EAAG,CAAc,CACnB"}
@@ -0,0 +1,10 @@
1
+ import { ProfileTelemetry } from "../../types/telemetry.cjs";
2
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ //#region src/adapters/pi/extension.d.ts
4
+ /**
5
+ * The package's single standard Pi factory.
6
+ */
7
+ declare function profileExtension(pi: ExtensionAPI, telemetry?: ProfileTelemetry): Promise<void>;
8
+ //#endregion
9
+ export { profileExtension as default, profileExtension };
10
+ //# sourceMappingURL=extension.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;;;iBAesB,iBACpB,IAAI,cACJ,YAAW,mBACV"}
@@ -0,0 +1,10 @@
1
+ import { ProfileTelemetry } from "../../types/telemetry.mjs";
2
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ //#region src/adapters/pi/extension.d.ts
4
+ /**
5
+ * The package's single standard Pi factory.
6
+ */
7
+ declare function profileExtension(pi: ExtensionAPI, telemetry?: ProfileTelemetry): Promise<void>;
8
+ //#endregion
9
+ export { profileExtension as default, profileExtension };
10
+ //# sourceMappingURL=extension.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;;;iBAesB,iBACpB,IAAI,cACJ,YAAW,mBACV"}
@@ -0,0 +1,2 @@
1
+ import{createProfileTelemetry as e}from"../telemetry/logSinkTelemetry.mjs";import{registerProfileCommand as t}from"../../commands/profileCommand.mjs";import{DOOM_CONFIG_SERVICE as n}from"@agimon-ai/doompi-extension-contracts/config";import{connectDoomCordisHost as r}from"@agimon-ai/doompi-extension-contracts/cordis-host";import{DOOM_HELP_SERVICE as i,requireDoomHelpService as a}from"@agimon-ai/doompi-extension-contracts/help";import{DOOM_TRANSITION_SERVICE as o}from"@agimon-ai/doompi-extension-contracts/transition";const s=`@agimon-ai/doompi-profile`;async function c(t,n=e()){let i=await r(t,s),a=i.root.plugin(l,{pi:t,telemetry:n});try{await a}catch(e){try{await a.dispose()}finally{await i.dispose()}throw e}let o;t.on(`session_shutdown`,()=>o??=(async()=>{try{await a.dispose()}finally{await i.dispose()}})())}function l(e,r){e.inject([i],e=>{let t=a(e).register({source:s,moduleUrl:import.meta.url,skills:[{name:`doompi-author-profile`,description:`Configure DoomPi profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.`}]});return()=>t.dispose()});let c;e.inject([n,o],e=>(c=e,()=>{c===e&&(c=void 0)}));let l=()=>{if(!c)throw Error(`Doom profile runtime is waiting for the session config service.`);return c};e.effect(function*(){t(r.pi,r.telemetry,l),yield()=>void 0},s)}export{c as default,c as profileExtension};
2
+ //# sourceMappingURL=extension.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.mjs","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_HELP_SERVICE, requireDoomHelpService } from '@agimon-ai/doompi-extension-contracts/help';\nimport { DOOM_TRANSITION_SERVICE } from '@agimon-ai/doompi-extension-contracts/transition';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { registerProfileCommand } from '../../commands/profileCommand.ts';\nimport type { ProfileTelemetry } from '../../types/telemetry.ts';\nimport { createProfileTelemetry } from '../telemetry/logSinkTelemetry.ts';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-profile';\n\n/**\n * The package's single standard Pi factory.\n */\nexport async function profileExtension(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry = createProfileTelemetry(),\n): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(profilePlugin, { pi, telemetry });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\ninterface ProfilePluginConfig {\n readonly pi: ExtensionAPI;\n readonly telemetry: ProfileTelemetry;\n}\n\nfunction profilePlugin(cordis: Context, config: ProfilePluginConfig): void {\n cordis.inject([DOOM_HELP_SERVICE], (helpContext) => {\n const contribution = requireDoomHelpService(helpContext).register({\n source: PACKAGE_SOURCE,\n moduleUrl: import.meta.url,\n skills: [\n {\n name: 'doompi-author-profile',\n description:\n 'Configure DoomPi profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.',\n },\n ],\n });\n return () => contribution.dispose();\n });\n\n let activeContext: Context | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE, DOOM_TRANSITION_SERVICE], (context) => {\n activeContext = context;\n return () => {\n if (activeContext === context) activeContext = undefined;\n };\n });\n const requireRuntimeContext = (): Context => {\n if (!activeContext) throw new Error('Doom profile runtime is waiting for the session config service.');\n return activeContext;\n };\n cordis.effect(function* () {\n registerProfileCommand(config.pi, config.telemetry, requireRuntimeContext);\n yield () => undefined;\n }, PACKAGE_SOURCE);\n}\n\nexport default profileExtension;\n"],"mappings":"ygBAUA,MAAM,EAAiB,4BAKvB,eAAsB,EACpB,EACA,EAA8B,EAAuB,EACtC,CACf,IAAM,EAAa,MAAM,EAAsB,EAAI,CAAc,EAC3D,EAAQ,EAAW,KAAK,OAAO,EAAe,CAAE,KAAI,WAAU,CAAC,EACrE,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CACd,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACA,MAAM,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF,CAOA,SAAS,EAAc,EAAiB,EAAmC,CACzE,EAAO,OAAO,CAAC,CAAiB,EAAI,GAAgB,CAClD,IAAM,EAAe,EAAuB,CAAW,CAAC,CAAC,SAAS,CAChE,OAAQ,EACR,UAAW,YAAY,IACvB,OAAQ,CACN,CACE,KAAM,wBACN,YACE,+OACJ,CACF,CACF,CAAC,EACD,UAAa,EAAa,QAAQ,CACpC,CAAC,EAED,IAAI,EACJ,EAAO,OAAO,CAAC,EAAqB,CAAuB,EAAI,IAC7D,EAAgB,MACH,CACP,IAAkB,IAAS,EAAgB,IAAA,GACjD,EACD,EACD,IAAM,MAAuC,CAC3C,GAAI,CAAC,EAAe,MAAU,MAAM,iEAAiE,EACrG,OAAO,CACT,EACA,EAAO,OAAO,WAAa,CACzB,EAAuB,EAAO,GAAI,EAAO,UAAW,CAAqB,EACzE,SAAY,IAAA,EACd,EAAG,CAAc,CACnB"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../telemetry/logSinkTelemetry.cjs"),n=require("../../types/telemetry.cjs");let r=require("node:fs");r=e.__toESM(r,1);let i=require("@agimon-ai/doompi-config"),a=require("@agimon-ai/doompi-extension-contracts/config"),o=require("@agimon-ai/doompi-extension-contracts/cordis-host");function s(e,{pi:t,telemetry:n}){let r;e.inject([a.DOOM_CONFIG_SERVICE],e=>(r=e,()=>{r===e&&(r=void 0)})),c(t,n,()=>{if(!r)throw Error(`Doom persona runtime is waiting for the session config service.`);return r})}function c(e,t,a){e.on(`before_agent_start`,async(e,o)=>{let{personaFile:s}=(0,i.requireDoomConfigContext)(a()).harness;if(s)try{let t=(await r.default.promises.readFile(s,`utf8`)).trim();return t?{systemPrompt:`${e.systemPrompt}\n\n${t}`}:void 0}catch(e){let r=e instanceof Error?e.message:String(e);t.recordError(n.PROFILE_EVENT.personaReadFailed,e),process.stderr.write(`[pi-persona] could not read ${s}: ${r}\n`);return}})}async function l(e,n=t.createProfileTelemetry()){let r=await(0,o.connectDoomCordisHost)(e,`@agimon-ai/doompi-profile/persona`),i=r.root.plugin(s,{pi:e,telemetry:n});try{await i}catch(e){throw await i.dispose(),await r.dispose(),e}let a;e.on(`session_shutdown`,()=>a??=(async()=>{try{await i.dispose()}finally{await r.dispose()}})())}exports.default=l,exports.personaExtension=l,exports.registerPersonaHandlers=c;
2
+ //# sourceMappingURL=persona.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona.cjs","names":["DOOM_CONFIG_SERVICE","requireDoomConfigContext","fs","PROFILE_EVENT","createProfileTelemetry","connectDoomCordisHost"],"sources":["../../../src/adapters/pi/persona.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { requireDoomConfigContext } from '@agimon-ai/doompi-config';\nimport { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { PROFILE_EVENT, type ProfileTelemetry } from '../../types/telemetry.ts';\nimport { createProfileTelemetry } from '../telemetry/logSinkTelemetry.ts';\n\n/**\n * Appends the selected profile's persona to the system prompt.\n *\n * The harness writes the assembled persona to a file in the run directory and\n * records the path in the harness state, so agents/ stays the single source of\n * persona material and is never copied into config.\n *\n * This is a separate Pi entry from the /profile command because detached\n * children need the persona without the command: they have no transition\n * coordinator to run a switch through.\n */\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-profile/persona';\n\ninterface PersonaPluginConfig {\n readonly pi: ExtensionAPI;\n readonly telemetry: ProfileTelemetry;\n}\n\nfunction personaPlugin(cordis: Context, { pi, telemetry }: PersonaPluginConfig): void {\n let activeContext: Context | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE], (context) => {\n activeContext = context;\n return () => {\n if (activeContext === context) activeContext = undefined;\n };\n });\n registerPersonaHandlers(pi, telemetry, () => {\n if (!activeContext) throw new Error('Doom persona runtime is waiting for the session config service.');\n return activeContext;\n });\n}\n\nexport function registerPersonaHandlers(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry,\n cordisContext: () => Context,\n): void {\n pi.on('before_agent_start', async (event, _ctx) => {\n const { personaFile } = requireDoomConfigContext(cordisContext()).harness;\n if (!personaFile) return undefined;\n\n try {\n const content = (await fs.promises.readFile(personaFile, 'utf8')).trim();\n return content ? { systemPrompt: `${event.systemPrompt}\\n\\n${content}` } : undefined;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n void telemetry.recordError(PROFILE_EVENT.personaReadFailed, error);\n process.stderr.write(`[pi-persona] could not read ${personaFile}: ${reason}\\n`);\n return undefined;\n }\n });\n}\n\nexport async function personaExtension(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry = createProfileTelemetry(),\n): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(personaPlugin, { pi, telemetry });\n try {\n await fiber;\n } catch (error) {\n await fiber.dispose();\n await connection.dispose();\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default personaExtension;\n"],"mappings":"2VA2BA,SAAS,EAAc,EAAiB,CAAE,KAAI,aAAwC,CACpF,IAAI,EACJ,EAAO,OAAO,CAACA,EAAAA,mBAAmB,EAAI,IACpC,EAAgB,MACH,CACP,IAAkB,IAAS,EAAgB,IAAA,GACjD,EACD,EACD,EAAwB,EAAI,MAAiB,CAC3C,GAAI,CAAC,EAAe,MAAU,MAAM,iEAAiE,EACrG,OAAO,CACT,CAAC,CACH,CAEA,SAAgB,EACd,EACA,EACA,EACM,CACN,EAAG,GAAG,qBAAsB,MAAO,EAAO,IAAS,CACjD,GAAM,CAAE,gBAAA,EAAgBC,EAAAA,yBAAAA,CAAyB,EAAc,CAAC,CAAC,CAAC,QAC7D,KAEL,GAAI,CACF,IAAM,GAAW,MAAMC,EAAAA,QAAG,SAAS,SAAS,EAAa,MAAM,EAAA,CAAG,KAAK,EACvE,OAAO,EAAU,CAAE,aAAc,GAAG,EAAM,aAAa,MAAM,GAAU,EAAI,IAAA,EAC7E,OAAS,EAAO,CACd,IAAM,EAAS,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,EACpE,EAAe,YAAYC,EAAAA,cAAc,kBAAmB,CAAK,EACjE,QAAQ,OAAO,MAAM,+BAA+B,EAAY,IAAI,EAAO,GAAG,EAC9E,MACF,CACF,CAAC,CACH,CAEA,eAAsB,EACpB,EACA,EAA8BC,EAAAA,uBAAuB,EACtC,CACf,IAAM,EAAa,MAAA,EAAMC,EAAAA,sBAAAA,CAAsB,EAAI,mCAAc,EAC3D,EAAQ,EAAW,KAAK,OAAO,EAAe,CAAE,KAAI,WAAU,CAAC,EACrE,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CAGd,MAFA,MAAM,EAAM,QAAQ,EACpB,MAAM,EAAW,QAAQ,EACnB,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF"}
@@ -0,0 +1,8 @@
1
+ import { ProfileTelemetry } from "../../types/telemetry.cjs";
2
+ import "@deepseek-ai/cordis";
3
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
+ //#region src/adapters/pi/persona.d.ts
5
+ declare function personaExtension(pi: ExtensionAPI, telemetry?: ProfileTelemetry): Promise<void>;
6
+ //#endregion
7
+ export { personaExtension as default, personaExtension };
8
+ //# sourceMappingURL=persona.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona.d.cts","names":[],"sources":["../../../src/adapters/pi/persona.ts"],"mappings":";;;;iBA8DsB,iBACpB,IAAI,cACJ,YAAW,mBACV"}
@@ -0,0 +1,8 @@
1
+ import { ProfileTelemetry } from "../../types/telemetry.mjs";
2
+ import "@deepseek-ai/cordis";
3
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
+ //#region src/adapters/pi/persona.d.ts
5
+ declare function personaExtension(pi: ExtensionAPI, telemetry?: ProfileTelemetry): Promise<void>;
6
+ //#endregion
7
+ export { personaExtension as default, personaExtension };
8
+ //# sourceMappingURL=persona.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona.d.mts","names":[],"sources":["../../../src/adapters/pi/persona.ts"],"mappings":";;;;iBA8DsB,iBACpB,IAAI,cACJ,YAAW,mBACV"}
@@ -0,0 +1,2 @@
1
+ import{createProfileTelemetry as e}from"../telemetry/logSinkTelemetry.mjs";import{PROFILE_EVENT as t}from"../../types/telemetry.mjs";import n from"node:fs";import{requireDoomConfigContext as r}from"@agimon-ai/doompi-config";import{DOOM_CONFIG_SERVICE as i}from"@agimon-ai/doompi-extension-contracts/config";import{connectDoomCordisHost as a}from"@agimon-ai/doompi-extension-contracts/cordis-host";function o(e,{pi:t,telemetry:n}){let r;e.inject([i],e=>(r=e,()=>{r===e&&(r=void 0)})),s(t,n,()=>{if(!r)throw Error(`Doom persona runtime is waiting for the session config service.`);return r})}function s(e,i,a){e.on(`before_agent_start`,async(e,o)=>{let{personaFile:s}=r(a()).harness;if(s)try{let t=(await n.promises.readFile(s,`utf8`)).trim();return t?{systemPrompt:`${e.systemPrompt}\n\n${t}`}:void 0}catch(e){let n=e instanceof Error?e.message:String(e);i.recordError(t.personaReadFailed,e),process.stderr.write(`[pi-persona] could not read ${s}: ${n}\n`);return}})}async function c(t,n=e()){let r=await a(t,`@agimon-ai/doompi-profile/persona`),i=r.root.plugin(o,{pi:t,telemetry:n});try{await i}catch(e){throw await i.dispose(),await r.dispose(),e}let s;t.on(`session_shutdown`,()=>s??=(async()=>{try{await i.dispose()}finally{await r.dispose()}})())}export{c as default,c as personaExtension,s as registerPersonaHandlers};
2
+ //# sourceMappingURL=persona.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona.mjs","names":[],"sources":["../../../src/adapters/pi/persona.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { requireDoomConfigContext } from '@agimon-ai/doompi-config';\nimport { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { PROFILE_EVENT, type ProfileTelemetry } from '../../types/telemetry.ts';\nimport { createProfileTelemetry } from '../telemetry/logSinkTelemetry.ts';\n\n/**\n * Appends the selected profile's persona to the system prompt.\n *\n * The harness writes the assembled persona to a file in the run directory and\n * records the path in the harness state, so agents/ stays the single source of\n * persona material and is never copied into config.\n *\n * This is a separate Pi entry from the /profile command because detached\n * children need the persona without the command: they have no transition\n * coordinator to run a switch through.\n */\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-profile/persona';\n\ninterface PersonaPluginConfig {\n readonly pi: ExtensionAPI;\n readonly telemetry: ProfileTelemetry;\n}\n\nfunction personaPlugin(cordis: Context, { pi, telemetry }: PersonaPluginConfig): void {\n let activeContext: Context | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE], (context) => {\n activeContext = context;\n return () => {\n if (activeContext === context) activeContext = undefined;\n };\n });\n registerPersonaHandlers(pi, telemetry, () => {\n if (!activeContext) throw new Error('Doom persona runtime is waiting for the session config service.');\n return activeContext;\n });\n}\n\nexport function registerPersonaHandlers(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry,\n cordisContext: () => Context,\n): void {\n pi.on('before_agent_start', async (event, _ctx) => {\n const { personaFile } = requireDoomConfigContext(cordisContext()).harness;\n if (!personaFile) return undefined;\n\n try {\n const content = (await fs.promises.readFile(personaFile, 'utf8')).trim();\n return content ? { systemPrompt: `${event.systemPrompt}\\n\\n${content}` } : undefined;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n void telemetry.recordError(PROFILE_EVENT.personaReadFailed, error);\n process.stderr.write(`[pi-persona] could not read ${personaFile}: ${reason}\\n`);\n return undefined;\n }\n });\n}\n\nexport async function personaExtension(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry = createProfileTelemetry(),\n): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(personaPlugin, { pi, telemetry });\n try {\n await fiber;\n } catch (error) {\n await fiber.dispose();\n await connection.dispose();\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default personaExtension;\n"],"mappings":"6YA2BA,SAAS,EAAc,EAAiB,CAAE,KAAI,aAAwC,CACpF,IAAI,EACJ,EAAO,OAAO,CAAC,CAAmB,EAAI,IACpC,EAAgB,MACH,CACP,IAAkB,IAAS,EAAgB,IAAA,GACjD,EACD,EACD,EAAwB,EAAI,MAAiB,CAC3C,GAAI,CAAC,EAAe,MAAU,MAAM,iEAAiE,EACrG,OAAO,CACT,CAAC,CACH,CAEA,SAAgB,EACd,EACA,EACA,EACM,CACN,EAAG,GAAG,qBAAsB,MAAO,EAAO,IAAS,CACjD,GAAM,CAAE,eAAgB,EAAyB,EAAc,CAAC,CAAC,CAAC,QAC7D,KAEL,GAAI,CACF,IAAM,GAAW,MAAM,EAAG,SAAS,SAAS,EAAa,MAAM,EAAA,CAAG,KAAK,EACvE,OAAO,EAAU,CAAE,aAAc,GAAG,EAAM,aAAa,MAAM,GAAU,EAAI,IAAA,EAC7E,OAAS,EAAO,CACd,IAAM,EAAS,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,EACpE,EAAe,YAAY,EAAc,kBAAmB,CAAK,EACjE,QAAQ,OAAO,MAAM,+BAA+B,EAAY,IAAI,EAAO,GAAG,EAC9E,MACF,CACF,CAAC,CACH,CAEA,eAAsB,EACpB,EACA,EAA8B,EAAuB,EACtC,CACf,IAAM,EAAa,MAAM,EAAsB,EAAI,mCAAc,EAC3D,EAAQ,EAAW,KAAK,OAAO,EAAe,CAAE,KAAI,WAAU,CAAC,EACrE,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CAGd,MAFA,MAAM,EAAM,QAAQ,EACpB,MAAM,EAAW,QAAQ,EACnB,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF"}
@@ -0,0 +1,2 @@
1
+ let e=require("@agimon-ai/doompi-telemetry");function t(t={}){let n=(0,e.createDoomTelemetry)({serviceName:`doom-pi-profile`,packageName:`@agimon-ai/doompi-profile`,cwd:t.cwd,workspaceRoot:t.workspaceRoot,env:t.env,telemetryFactory:t.telemetryFactory,warn:t.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,r)=>n.recordError(e,t,r),recordEvent:(e,t)=>n.recordEvent(e,t)}}exports.createProfileTelemetry=t;
2
+ //# sourceMappingURL=logSinkTelemetry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.cjs","names":["createDoomTelemetry"],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\nimport type { ProfileTelemetry } from '../../types/telemetry.ts';\n\nconst SERVICE_NAME = 'doom-pi-profile';\nconst PACKAGE_NAME = '@agimon-ai/doompi-profile';\n\nexport interface ProfileTelemetryOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport function createProfileTelemetry(options: ProfileTelemetryOptions = {}): ProfileTelemetry {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n };\n}\n"],"mappings":"6CAcA,SAAgB,EAAuB,EAAmC,CAAC,EAAqB,CAC9F,IAAM,GAAA,EAA2BA,EAAAA,oBAAAA,CAAoB,CACnD,YAAa,kBACb,YAAa,4BACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,CAC7E,CACF"}
@@ -0,0 +1,14 @@
1
+ import { ProfileTelemetry } from "../../types/telemetry.cjs";
2
+ import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
3
+ //#region src/adapters/telemetry/logSinkTelemetry.d.ts
4
+ interface ProfileTelemetryOptions {
5
+ cwd?: string;
6
+ workspaceRoot?: string;
7
+ env?: NodeJS.ProcessEnv;
8
+ telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
9
+ warn?: (message: string) => void;
10
+ }
11
+ declare function createProfileTelemetry(options?: ProfileTelemetryOptions): ProfileTelemetry;
12
+ //#endregion
13
+ export { ProfileTelemetryOptions, createProfileTelemetry };
14
+ //# sourceMappingURL=logSinkTelemetry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.d.cts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;;UAMiB;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;iBAGM,uBAAuB,UAAS,0BAA+B"}
@@ -0,0 +1,14 @@
1
+ import { ProfileTelemetry } from "../../types/telemetry.mjs";
2
+ import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
3
+ //#region src/adapters/telemetry/logSinkTelemetry.d.ts
4
+ interface ProfileTelemetryOptions {
5
+ cwd?: string;
6
+ workspaceRoot?: string;
7
+ env?: NodeJS.ProcessEnv;
8
+ telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
9
+ warn?: (message: string) => void;
10
+ }
11
+ declare function createProfileTelemetry(options?: ProfileTelemetryOptions): ProfileTelemetry;
12
+ //#endregion
13
+ export { ProfileTelemetryOptions, createProfileTelemetry };
14
+ //# sourceMappingURL=logSinkTelemetry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.d.mts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;;UAMiB;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;iBAGM,uBAAuB,UAAS,0BAA+B"}
@@ -0,0 +1,2 @@
1
+ import{createDoomTelemetry as e}from"@agimon-ai/doompi-telemetry";function t(t={}){let n=e({serviceName:`doom-pi-profile`,packageName:`@agimon-ai/doompi-profile`,cwd:t.cwd,workspaceRoot:t.workspaceRoot,env:t.env,telemetryFactory:t.telemetryFactory,warn:t.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,r)=>n.recordError(e,t,r),recordEvent:(e,t)=>n.recordEvent(e,t)}}export{t as createProfileTelemetry};
2
+ //# sourceMappingURL=logSinkTelemetry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.mjs","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\nimport type { ProfileTelemetry } from '../../types/telemetry.ts';\n\nconst SERVICE_NAME = 'doom-pi-profile';\nconst PACKAGE_NAME = '@agimon-ai/doompi-profile';\n\nexport interface ProfileTelemetryOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport function createProfileTelemetry(options: ProfileTelemetryOptions = {}): ProfileTelemetry {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n };\n}\n"],"mappings":"kEAcA,SAAgB,EAAuB,EAAmC,CAAC,EAAqB,CAC9F,IAAM,EAA2B,EAAoB,CACnD,YAAa,kBACb,YAAa,4BACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,CAC7E,CACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../types/telemetry.cjs"),t=require("../services/profileText.cjs");let n=require("@agimon-ai/doompi-extension-contracts/transition"),r=require("@agimon-ai/doompi-config/piContext");const i=`warning`,a=`info`,o=`.doom/profiles.yaml`;function s(){let e,t,n,r,i;return{harnessStore:()=>e??=import(`@agimon-ai/doompi-config/harnessStore`),journal:()=>t??=import(`@agimon-ai/doompi-config/piContext`),picker:()=>n??=import(`@agimon-ai/doompi-ui/components/matrixPicker`),profiles:()=>r??=import(`@agimon-ai/doompi-config/profiles`),selection:()=>i??=import(`@agimon-ai/doompi-config/selectionSwitch`)}}async function c(e,n,r,i){let a=t.profileTitle(r);if(e.mode!==`tui`)return e.ui.select(a,n.map(e=>e.name));let{MatrixPickerComponent:o}=await i();return(await e.ui.custom((e,i,s,c)=>new o({title:a,items:t.profileItems(n),selected:r?[r]:[],multi:!1},i,s,c)))?.[0]}function l(l,u,d){let f=s();l.registerCommand(`profile`,{description:`Show profiles and load a different persona and environment`,handler:async(s,p)=>{let m=d(),h=(0,r.requireDoomConfigContext)(m).harness,[{requireHarnessRoot:g},{loadProfiles:_}]=await Promise.all([f.harnessStore(),f.profiles()]),v=g(h),y=h.profile,b;try{b=_(v)}catch(t){let n=t instanceof Error?t.message:String(t);u.recordError(e.PROFILE_EVENT.profileLoadFailed,t),p.ui.notify(`Could not load ${o}: ${n}`,i);return}if(b.length===0){p.ui.notify(`No profiles found in ${o}.`,i);return}let x=await c(p,b,y,f.picker),S=b.find(e=>e.name===x);if(!S)return;if(S.name===y){p.ui.notify(t.profileSummary(S),a);return}let C=(0,n.requireDoomTransitionCoordinator)(m),w,T=await C.execute({sessionId:p.sessionManager.getSessionId(),hostGeneration:C.hostGeneration,operationId:crypto.randomUUID(),source:p.mode===`tui`?`ui`:`command`,target:{axis:`profile`,profile:S.name}},async(t,r)=>{w=(0,n.prepareMinorModeReloadHandoff)(m,p.sessionManager.getSessionId(),C.hostGeneration,r.operationId,r.previous.minorModes);try{let{applyProfile:t}=await f.selection();p.ui.notify(await t(S,h),a);let{persistHarnessSelection:n}=await f.journal();return n(l,{...h,profile:S.name}),u.recordEvent(e.PROFILE_EVENT.profileApplied,{"harness.profile":S.name,...y?{"harness.profile.previous":y}:{},"harness.transition.disposition":r.disposition,"harness.transition.operation_id":r.operationId}),`applied`}catch(e){throw w?.discard(),w=void 0,e}});if(T.outcome===`rejected`||T.outcome===`stale`){w?.discard(),p.ui.notify(`Profile transition was ${T.outcome}: ${T.diagnostics.join(`, `)}`,i);return}if(T.outcome!==`applied`){w?.discard();return}try{await p.waitForIdle(),await p.reload()}catch(e){throw w?.discard(),e}}})}exports.registerProfileCommand=l;
2
+ //# sourceMappingURL=profileCommand.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileCommand.cjs","names":["profileTitle","profileItems","requireDoomConfigContext","PROFILE_EVENT","profileSummary","requireDoomTransitionCoordinator","prepareMinorModeReloadHandoff"],"sources":["../../src/commands/profileCommand.ts"],"sourcesContent":["import { requireDoomConfigContext } from '@agimon-ai/doompi-config/piContext';\nimport type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport {\n type MinorModeReloadHandoffHandle,\n prepareMinorModeReloadHandoff,\n requireDoomTransitionCoordinator,\n} from '@agimon-ai/doompi-extension-contracts/transition';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport type { Context } from '@deepseek-ai/cordis';\nimport { profileItems, profileSummary, profileTitle } from '../services/profileText.ts';\nimport { PROFILE_EVENT, type ProfileTelemetry } from '../types/telemetry.ts';\n\nconst WARNING = 'warning';\nconst INFO = 'info';\nconst PROFILE_CONFIG_PATH = '.doom/profiles.yaml';\n\n/**\n * The picker and everything behind it load on first use.\n *\n * Every session registers this command, but almost none of them run it, so the\n * profile catalogue, the TUI component and the switch stay off the startup path.\n */\nfunction lazyModules() {\n let harnessStore: Promise<typeof import('@agimon-ai/doompi-config/harnessStore')> | undefined;\n let journal: Promise<typeof import('@agimon-ai/doompi-config/piContext')> | undefined;\n let picker: Promise<typeof import('@agimon-ai/doompi-ui/components/matrixPicker')> | undefined;\n let profiles: Promise<typeof import('@agimon-ai/doompi-config/profiles')> | undefined;\n let selection: Promise<typeof import('@agimon-ai/doompi-config/selectionSwitch')> | undefined;\n return {\n harnessStore: () => (harnessStore ??= import('@agimon-ai/doompi-config/harnessStore')),\n journal: () => (journal ??= import('@agimon-ai/doompi-config/piContext')),\n picker: () => (picker ??= import('@agimon-ai/doompi-ui/components/matrixPicker')),\n profiles: () => (profiles ??= import('@agimon-ai/doompi-config/profiles')),\n selection: () => (selection ??= import('@agimon-ai/doompi-config/selectionSwitch')),\n };\n}\n\nasync function pickProfile(\n ctx: ExtensionContext,\n profiles: AgentProfile[],\n current: string | undefined,\n loadPicker: () => Promise<typeof import('@agimon-ai/doompi-ui/components/matrixPicker')>,\n): Promise<string | undefined> {\n const title = profileTitle(current);\n if (ctx.mode !== 'tui') {\n return ctx.ui.select(\n title,\n profiles.map((profile) => profile.name),\n );\n }\n const { MatrixPickerComponent } = await loadPicker();\n const chosen = await ctx.ui.custom<string[] | undefined>(\n (_tui, theme, keybindings, done) =>\n new MatrixPickerComponent(\n { title, items: profileItems(profiles), selected: current ? [current] : [], multi: false },\n theme,\n keybindings,\n done,\n ),\n );\n return chosen?.[0];\n}\n\nexport function registerProfileCommand(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry,\n cordisContext: () => Context,\n): void {\n const load = lazyModules();\n\n pi.registerCommand('profile', {\n description: 'Show profiles and load a different persona and environment',\n handler: async (_args, ctx) => {\n const cordis = cordisContext();\n const state = requireDoomConfigContext(cordis).harness;\n const [{ requireHarnessRoot }, { loadProfiles }] = await Promise.all([load.harnessStore(), load.profiles()]);\n const root = requireHarnessRoot(state);\n const current = state.profile;\n let profiles: AgentProfile[];\n try {\n profiles = loadProfiles(root);\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n void telemetry.recordError(PROFILE_EVENT.profileLoadFailed, error);\n ctx.ui.notify(`Could not load ${PROFILE_CONFIG_PATH}: ${reason}`, WARNING);\n return;\n }\n\n if (profiles.length === 0) {\n ctx.ui.notify(`No profiles found in ${PROFILE_CONFIG_PATH}.`, WARNING);\n return;\n }\n\n const picked = await pickProfile(ctx, profiles, current, load.picker);\n const profile = profiles.find((candidate) => candidate.name === picked);\n if (!profile) return;\n if (profile.name === current) {\n ctx.ui.notify(profileSummary(profile), INFO);\n return;\n }\n\n const coordinator = requireDoomTransitionCoordinator(cordis);\n let minorModeReloadHandoff: MinorModeReloadHandoffHandle | undefined;\n const result = await coordinator.execute(\n {\n sessionId: ctx.sessionManager.getSessionId(),\n hostGeneration: coordinator.hostGeneration,\n operationId: crypto.randomUUID(),\n source: ctx.mode === 'tui' ? 'ui' : 'command',\n target: { axis: 'profile', profile: profile.name },\n },\n async (_request, plan) => {\n minorModeReloadHandoff = prepareMinorModeReloadHandoff(\n cordis,\n ctx.sessionManager.getSessionId(),\n coordinator.hostGeneration,\n plan.operationId,\n plan.previous.minorModes,\n );\n try {\n const { applyProfile } = await load.selection();\n ctx.ui.notify(await applyProfile(profile, state), INFO);\n const { persistHarnessSelection } = await load.journal();\n persistHarnessSelection(pi, { ...state, profile: profile.name });\n void telemetry.recordEvent(PROFILE_EVENT.profileApplied, {\n 'harness.profile': profile.name,\n ...(current ? { 'harness.profile.previous': current } : {}),\n 'harness.transition.disposition': plan.disposition,\n 'harness.transition.operation_id': plan.operationId,\n });\n return 'applied';\n } catch (error) {\n minorModeReloadHandoff?.discard();\n minorModeReloadHandoff = undefined;\n throw error;\n }\n },\n );\n if (result.outcome === 'rejected' || result.outcome === 'stale') {\n minorModeReloadHandoff?.discard();\n ctx.ui.notify(`Profile transition was ${result.outcome}: ${result.diagnostics.join(', ')}`, WARNING);\n return;\n }\n if (result.outcome !== 'applied') {\n minorModeReloadHandoff?.discard();\n return;\n }\n\n try {\n await ctx.waitForIdle();\n // Reload replaces the session and invalidates this command context.\n // Keep it as the handler's final action.\n await ctx.reload();\n } catch (error) {\n minorModeReloadHandoff?.discard();\n throw error;\n }\n },\n });\n}\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import{PROFILE_EVENT as e}from"../types/telemetry.mjs";import{profileItems as t,profileSummary as n,profileTitle as r}from"../services/profileText.mjs";import{prepareMinorModeReloadHandoff as i,requireDoomTransitionCoordinator as a}from"@agimon-ai/doompi-extension-contracts/transition";import{requireDoomConfigContext as o}from"@agimon-ai/doompi-config/piContext";const s=`warning`,c=`info`,l=`.doom/profiles.yaml`;function u(){let e,t,n,r,i;return{harnessStore:()=>e??=import(`@agimon-ai/doompi-config/harnessStore`),journal:()=>t??=import(`@agimon-ai/doompi-config/piContext`),picker:()=>n??=import(`@agimon-ai/doompi-ui/components/matrixPicker`),profiles:()=>r??=import(`@agimon-ai/doompi-config/profiles`),selection:()=>i??=import(`@agimon-ai/doompi-config/selectionSwitch`)}}async function d(e,n,i,a){let o=r(i);if(e.mode!==`tui`)return e.ui.select(o,n.map(e=>e.name));let{MatrixPickerComponent:s}=await a();return(await e.ui.custom((e,r,a,c)=>new s({title:o,items:t(n),selected:i?[i]:[],multi:!1},r,a,c)))?.[0]}function f(t,r,f){let p=u();t.registerCommand(`profile`,{description:`Show profiles and load a different persona and environment`,handler:async(u,m)=>{let h=f(),g=o(h).harness,[{requireHarnessRoot:_},{loadProfiles:v}]=await Promise.all([p.harnessStore(),p.profiles()]),y=_(g),b=g.profile,x;try{x=v(y)}catch(t){let n=t instanceof Error?t.message:String(t);r.recordError(e.profileLoadFailed,t),m.ui.notify(`Could not load ${l}: ${n}`,s);return}if(x.length===0){m.ui.notify(`No profiles found in ${l}.`,s);return}let S=await d(m,x,b,p.picker),C=x.find(e=>e.name===S);if(!C)return;if(C.name===b){m.ui.notify(n(C),c);return}let w=a(h),T,E=await w.execute({sessionId:m.sessionManager.getSessionId(),hostGeneration:w.hostGeneration,operationId:crypto.randomUUID(),source:m.mode===`tui`?`ui`:`command`,target:{axis:`profile`,profile:C.name}},async(n,a)=>{T=i(h,m.sessionManager.getSessionId(),w.hostGeneration,a.operationId,a.previous.minorModes);try{let{applyProfile:n}=await p.selection();m.ui.notify(await n(C,g),c);let{persistHarnessSelection:i}=await p.journal();return i(t,{...g,profile:C.name}),r.recordEvent(e.profileApplied,{"harness.profile":C.name,...b?{"harness.profile.previous":b}:{},"harness.transition.disposition":a.disposition,"harness.transition.operation_id":a.operationId}),`applied`}catch(e){throw T?.discard(),T=void 0,e}});if(E.outcome===`rejected`||E.outcome===`stale`){T?.discard(),m.ui.notify(`Profile transition was ${E.outcome}: ${E.diagnostics.join(`, `)}`,s);return}if(E.outcome!==`applied`){T?.discard();return}try{await m.waitForIdle(),await m.reload()}catch(e){throw T?.discard(),e}}})}export{f as registerProfileCommand};
2
+ //# sourceMappingURL=profileCommand.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileCommand.mjs","names":[],"sources":["../../src/commands/profileCommand.ts"],"sourcesContent":["import { requireDoomConfigContext } from '@agimon-ai/doompi-config/piContext';\nimport type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport {\n type MinorModeReloadHandoffHandle,\n prepareMinorModeReloadHandoff,\n requireDoomTransitionCoordinator,\n} from '@agimon-ai/doompi-extension-contracts/transition';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport type { Context } from '@deepseek-ai/cordis';\nimport { profileItems, profileSummary, profileTitle } from '../services/profileText.ts';\nimport { PROFILE_EVENT, type ProfileTelemetry } from '../types/telemetry.ts';\n\nconst WARNING = 'warning';\nconst INFO = 'info';\nconst PROFILE_CONFIG_PATH = '.doom/profiles.yaml';\n\n/**\n * The picker and everything behind it load on first use.\n *\n * Every session registers this command, but almost none of them run it, so the\n * profile catalogue, the TUI component and the switch stay off the startup path.\n */\nfunction lazyModules() {\n let harnessStore: Promise<typeof import('@agimon-ai/doompi-config/harnessStore')> | undefined;\n let journal: Promise<typeof import('@agimon-ai/doompi-config/piContext')> | undefined;\n let picker: Promise<typeof import('@agimon-ai/doompi-ui/components/matrixPicker')> | undefined;\n let profiles: Promise<typeof import('@agimon-ai/doompi-config/profiles')> | undefined;\n let selection: Promise<typeof import('@agimon-ai/doompi-config/selectionSwitch')> | undefined;\n return {\n harnessStore: () => (harnessStore ??= import('@agimon-ai/doompi-config/harnessStore')),\n journal: () => (journal ??= import('@agimon-ai/doompi-config/piContext')),\n picker: () => (picker ??= import('@agimon-ai/doompi-ui/components/matrixPicker')),\n profiles: () => (profiles ??= import('@agimon-ai/doompi-config/profiles')),\n selection: () => (selection ??= import('@agimon-ai/doompi-config/selectionSwitch')),\n };\n}\n\nasync function pickProfile(\n ctx: ExtensionContext,\n profiles: AgentProfile[],\n current: string | undefined,\n loadPicker: () => Promise<typeof import('@agimon-ai/doompi-ui/components/matrixPicker')>,\n): Promise<string | undefined> {\n const title = profileTitle(current);\n if (ctx.mode !== 'tui') {\n return ctx.ui.select(\n title,\n profiles.map((profile) => profile.name),\n );\n }\n const { MatrixPickerComponent } = await loadPicker();\n const chosen = await ctx.ui.custom<string[] | undefined>(\n (_tui, theme, keybindings, done) =>\n new MatrixPickerComponent(\n { title, items: profileItems(profiles), selected: current ? [current] : [], multi: false },\n theme,\n keybindings,\n done,\n ),\n );\n return chosen?.[0];\n}\n\nexport function registerProfileCommand(\n pi: ExtensionAPI,\n telemetry: ProfileTelemetry,\n cordisContext: () => Context,\n): void {\n const load = lazyModules();\n\n pi.registerCommand('profile', {\n description: 'Show profiles and load a different persona and environment',\n handler: async (_args, ctx) => {\n const cordis = cordisContext();\n const state = requireDoomConfigContext(cordis).harness;\n const [{ requireHarnessRoot }, { loadProfiles }] = await Promise.all([load.harnessStore(), load.profiles()]);\n const root = requireHarnessRoot(state);\n const current = state.profile;\n let profiles: AgentProfile[];\n try {\n profiles = loadProfiles(root);\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n void telemetry.recordError(PROFILE_EVENT.profileLoadFailed, error);\n ctx.ui.notify(`Could not load ${PROFILE_CONFIG_PATH}: ${reason}`, WARNING);\n return;\n }\n\n if (profiles.length === 0) {\n ctx.ui.notify(`No profiles found in ${PROFILE_CONFIG_PATH}.`, WARNING);\n return;\n }\n\n const picked = await pickProfile(ctx, profiles, current, load.picker);\n const profile = profiles.find((candidate) => candidate.name === picked);\n if (!profile) return;\n if (profile.name === current) {\n ctx.ui.notify(profileSummary(profile), INFO);\n return;\n }\n\n const coordinator = requireDoomTransitionCoordinator(cordis);\n let minorModeReloadHandoff: MinorModeReloadHandoffHandle | undefined;\n const result = await coordinator.execute(\n {\n sessionId: ctx.sessionManager.getSessionId(),\n hostGeneration: coordinator.hostGeneration,\n operationId: crypto.randomUUID(),\n source: ctx.mode === 'tui' ? 'ui' : 'command',\n target: { axis: 'profile', profile: profile.name },\n },\n async (_request, plan) => {\n minorModeReloadHandoff = prepareMinorModeReloadHandoff(\n cordis,\n ctx.sessionManager.getSessionId(),\n coordinator.hostGeneration,\n plan.operationId,\n plan.previous.minorModes,\n );\n try {\n const { applyProfile } = await load.selection();\n ctx.ui.notify(await applyProfile(profile, state), INFO);\n const { persistHarnessSelection } = await load.journal();\n persistHarnessSelection(pi, { ...state, profile: profile.name });\n void telemetry.recordEvent(PROFILE_EVENT.profileApplied, {\n 'harness.profile': profile.name,\n ...(current ? { 'harness.profile.previous': current } : {}),\n 'harness.transition.disposition': plan.disposition,\n 'harness.transition.operation_id': plan.operationId,\n });\n return 'applied';\n } catch (error) {\n minorModeReloadHandoff?.discard();\n minorModeReloadHandoff = undefined;\n throw error;\n }\n },\n );\n if (result.outcome === 'rejected' || result.outcome === 'stale') {\n minorModeReloadHandoff?.discard();\n ctx.ui.notify(`Profile transition was ${result.outcome}: ${result.diagnostics.join(', ')}`, WARNING);\n return;\n }\n if (result.outcome !== 'applied') {\n minorModeReloadHandoff?.discard();\n return;\n }\n\n try {\n await ctx.waitForIdle();\n // Reload replaces the session and invalidates this command context.\n // Keep it as the handler's final action.\n await ctx.reload();\n } catch (error) {\n minorModeReloadHandoff?.discard();\n throw error;\n }\n },\n });\n}\n"],"mappings":"6WAYA,MAAM,EAAU,UACV,EAAO,OACP,EAAsB,sBAQ5B,SAAS,GAAc,CACrB,IAAI,EACA,EACA,EACA,EACA,EACJ,MAAO,CACL,iBAAqB,IAAiB,OAAO,yCAC7C,YAAgB,IAAY,OAAO,sCACnC,WAAe,IAAW,OAAO,gDACjC,aAAiB,IAAa,OAAO,qCACrC,cAAkB,IAAc,OAAO,2CACzC,CACF,CAEA,eAAe,EACb,EACA,EACA,EACA,EAC6B,CAC7B,IAAM,EAAQ,EAAa,CAAO,EAClC,GAAI,EAAI,OAAS,MACf,OAAO,EAAI,GAAG,OACZ,EACA,EAAS,IAAK,GAAY,EAAQ,IAAI,CACxC,EAEF,GAAM,CAAE,yBAA0B,MAAM,EAAW,EAUnD,OAAO,MATc,EAAI,GAAG,QACzB,EAAM,EAAO,EAAa,IACzB,IAAI,EACF,CAAE,QAAO,MAAO,EAAa,CAAQ,EAAG,SAAU,EAAU,CAAC,CAAO,EAAI,CAAC,EAAG,MAAO,EAAM,EACzF,EACA,EACA,CACF,CACJ,EAAA,GACgB,EAClB,CAEA,SAAgB,EACd,EACA,EACA,EACM,CACN,IAAM,EAAO,EAAY,EAEzB,EAAG,gBAAgB,UAAW,CAC5B,YAAa,6DACb,QAAS,MAAO,EAAO,IAAQ,CAC7B,IAAM,EAAS,EAAc,EACvB,EAAQ,EAAyB,CAAM,CAAC,CAAC,QACzC,CAAC,CAAE,sBAAsB,CAAE,iBAAkB,MAAM,QAAQ,IAAI,CAAC,EAAK,aAAa,EAAG,EAAK,SAAS,CAAC,CAAC,EACrG,EAAO,EAAmB,CAAK,EAC/B,EAAU,EAAM,QAClB,EACJ,GAAI,CACF,EAAW,EAAa,CAAI,CAC9B,OAAS,EAAO,CACd,IAAM,EAAS,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,EACpE,EAAe,YAAY,EAAc,kBAAmB,CAAK,EACjE,EAAI,GAAG,OAAO,kBAAkB,EAAoB,IAAI,IAAU,CAAO,EACzE,MACF,CAEA,GAAI,EAAS,SAAW,EAAG,CACzB,EAAI,GAAG,OAAO,wBAAwB,EAAoB,GAAI,CAAO,EACrE,MACF,CAEA,IAAM,EAAS,MAAM,EAAY,EAAK,EAAU,EAAS,EAAK,MAAM,EAC9D,EAAU,EAAS,KAAM,GAAc,EAAU,OAAS,CAAM,EACtE,GAAI,CAAC,EAAS,OACd,GAAI,EAAQ,OAAS,EAAS,CAC5B,EAAI,GAAG,OAAO,EAAe,CAAO,EAAG,CAAI,EAC3C,MACF,CAEA,IAAM,EAAc,EAAiC,CAAM,EACvD,EACE,EAAS,MAAM,EAAY,QAC/B,CACE,UAAW,EAAI,eAAe,aAAa,EAC3C,eAAgB,EAAY,eAC5B,YAAa,OAAO,WAAW,EAC/B,OAAQ,EAAI,OAAS,MAAQ,KAAO,UACpC,OAAQ,CAAE,KAAM,UAAW,QAAS,EAAQ,IAAK,CACnD,EACA,MAAO,EAAU,IAAS,CACxB,EAAyB,EACvB,EACA,EAAI,eAAe,aAAa,EAChC,EAAY,eACZ,EAAK,YACL,EAAK,SAAS,UAChB,EACA,GAAI,CACF,GAAM,CAAE,gBAAiB,MAAM,EAAK,UAAU,EAC9C,EAAI,GAAG,OAAO,MAAM,EAAa,EAAS,CAAK,EAAG,CAAI,EACtD,GAAM,CAAE,2BAA4B,MAAM,EAAK,QAAQ,EAQvD,OAPA,EAAwB,EAAI,CAAE,GAAG,EAAO,QAAS,EAAQ,IAAK,CAAC,EAC/D,EAAe,YAAY,EAAc,eAAgB,CACvD,kBAAmB,EAAQ,KAC3B,GAAI,EAAU,CAAE,2BAA4B,CAAQ,EAAI,CAAC,EACzD,iCAAkC,EAAK,YACvC,kCAAmC,EAAK,WAC1C,CAAC,EACM,SACT,OAAS,EAAO,CAGd,MAFA,GAAwB,QAAQ,EAChC,EAAyB,IAAA,GACnB,CACR,CACF,CACF,EACA,GAAI,EAAO,UAAY,YAAc,EAAO,UAAY,QAAS,CAC/D,GAAwB,QAAQ,EAChC,EAAI,GAAG,OAAO,0BAA0B,EAAO,QAAQ,IAAI,EAAO,YAAY,KAAK,IAAI,IAAK,CAAO,EACnG,MACF,CACA,GAAI,EAAO,UAAY,UAAW,CAChC,GAAwB,QAAQ,EAChC,MACF,CAEA,GAAI,CACF,MAAM,EAAI,YAAY,EAGtB,MAAM,EAAI,OAAO,CACnB,OAAS,EAAO,CAEd,MADA,GAAwB,QAAQ,EAC1B,CACR,CACF,CACF,CAAC,CACH"}
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../adapters/pi/persona.cjs");exports.default=e.default,exports.personaExtension=e.default;
@@ -0,0 +1,2 @@
1
+ import personaExtension from "../adapters/pi/persona.cjs";
2
+ export { personaExtension as default, personaExtension };
@@ -0,0 +1,2 @@
1
+ import personaExtension from "../adapters/pi/persona.mjs";
2
+ export { personaExtension as default, personaExtension };
@@ -0,0 +1 @@
1
+ import e from"../adapters/pi/persona.mjs";export{e as default,e as personaExtension};
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../adapters/pi/extension.cjs");exports.default=e.default,exports.profileExtension=e.default;
@@ -0,0 +1,2 @@
1
+ import profileExtension from "../adapters/pi/extension.cjs";
2
+ export { profileExtension as default, profileExtension };
@@ -0,0 +1,2 @@
1
+ import profileExtension from "../adapters/pi/extension.mjs";
2
+ export { profileExtension as default, profileExtension };
@@ -0,0 +1 @@
1
+ import e from"../adapters/pi/extension.mjs";export{e as default,e as profileExtension};
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapters/telemetry/logSinkTelemetry.cjs"),t=require("./types/telemetry.cjs"),n=require("./adapters/pi/persona.cjs"),r=require("./services/profileText.cjs"),i=require("./adapters/pi/extension.cjs");exports.PROFILE_EVENT=t.PROFILE_EVENT,exports.createProfileTelemetry=e.createProfileTelemetry,exports.personaExtension=n.default,exports.profileDescription=r.profileDescription,exports.profileExtension=i.default,exports.profileItems=r.profileItems,exports.profileSummary=r.profileSummary,exports.profileTitle=r.profileTitle;
@@ -0,0 +1,6 @@
1
+ import { PROFILE_EVENT, ProfileEventAttributes, ProfileEventName, ProfileTelemetry } from "./types/telemetry.cjs";
2
+ import personaExtension from "./adapters/pi/persona.cjs";
3
+ import profileExtension from "./adapters/pi/extension.cjs";
4
+ import { ProfileTelemetryOptions, createProfileTelemetry } from "./adapters/telemetry/logSinkTelemetry.cjs";
5
+ import { profileDescription, profileItems, profileSummary, profileTitle } from "./services/profileText.cjs";
6
+ export { PROFILE_EVENT, type ProfileEventAttributes, type ProfileEventName, type ProfileTelemetry, type ProfileTelemetryOptions, createProfileTelemetry, personaExtension, profileDescription, profileExtension, profileItems, profileSummary, profileTitle };
@@ -0,0 +1,6 @@
1
+ import { PROFILE_EVENT, ProfileEventAttributes, ProfileEventName, ProfileTelemetry } from "./types/telemetry.mjs";
2
+ import personaExtension from "./adapters/pi/persona.mjs";
3
+ import profileExtension from "./adapters/pi/extension.mjs";
4
+ import { ProfileTelemetryOptions, createProfileTelemetry } from "./adapters/telemetry/logSinkTelemetry.mjs";
5
+ import { profileDescription, profileItems, profileSummary, profileTitle } from "./services/profileText.mjs";
6
+ export { PROFILE_EVENT, type ProfileEventAttributes, type ProfileEventName, type ProfileTelemetry, type ProfileTelemetryOptions, createProfileTelemetry, personaExtension, profileDescription, profileExtension, profileItems, profileSummary, profileTitle };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{createProfileTelemetry as e}from"./adapters/telemetry/logSinkTelemetry.mjs";import{PROFILE_EVENT as t}from"./types/telemetry.mjs";import n from"./adapters/pi/persona.mjs";import{profileDescription as r,profileItems as i,profileSummary as a,profileTitle as o}from"./services/profileText.mjs";import s from"./adapters/pi/extension.mjs";export{t as PROFILE_EVENT,e as createProfileTelemetry,n as personaExtension,r as profileDescription,s as profileExtension,i as profileItems,a as profileSummary,o as profileTitle};
@@ -0,0 +1,3 @@
1
+ const e=`(none)`;function t(e){return e.map(e=>({value:e.name,label:e.name,description:n(e)}))}function n(e){let t=Object.keys(e.env).sort();return t.length>0?`${e.persona} (env: ${t.join(`, `)})`:e.persona}function r(t){let n=Object.keys(t.env).sort();return[`Profile ${t.name}`,`Persona: ${t.persona}`,`Env: ${n.join(`, `)||e}`,`Already loaded.`].join(`
2
+ `)}function i(t){return`Profile (current: ${t??e})`}exports.profileDescription=n,exports.profileItems=t,exports.profileSummary=r,exports.profileTitle=i;
3
+ //# sourceMappingURL=profileText.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileText.cjs","names":[],"sources":["../../src/services/profileText.ts"],"sourcesContent":["import type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport type { SelectItem } from '@earendil-works/pi-tui';\n\nconst NONE = '(none)';\n\n/** Rows for the single-select profile picker. */\nexport function profileItems(profiles: AgentProfile[]): SelectItem[] {\n return profiles.map((profile) => ({\n value: profile.name,\n label: profile.name,\n description: profileDescription(profile),\n }));\n}\n\nexport function profileDescription(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return environmentKeys.length > 0 ? `${profile.persona} (env: ${environmentKeys.join(', ')})` : profile.persona;\n}\n\n/** Shown when the picked profile is already active. */\nexport function profileSummary(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return [\n `Profile ${profile.name}`,\n `Persona: ${profile.persona}`,\n `Env: ${environmentKeys.join(', ') || NONE}`,\n 'Already loaded.',\n ].join('\\n');\n}\n\nexport function profileTitle(current?: string): string {\n return `Profile (current: ${current ?? NONE})`;\n}\n"],"mappings":"AAGA,MAAM,EAAO,SAGb,SAAgB,EAAa,EAAwC,CACnE,OAAO,EAAS,IAAK,IAAa,CAChC,MAAO,EAAQ,KACf,MAAO,EAAQ,KACf,YAAa,EAAmB,CAAO,CACzC,EAAE,CACJ,CAEA,SAAgB,EAAmB,EAA+B,CAChE,IAAM,EAAkB,OAAO,KAAK,EAAQ,GAAG,CAAC,CAAC,KAAK,EACtD,OAAO,EAAgB,OAAS,EAAI,GAAG,EAAQ,QAAQ,SAAS,EAAgB,KAAK,IAAI,EAAE,GAAK,EAAQ,OAC1G,CAGA,SAAgB,EAAe,EAA+B,CAC5D,IAAM,EAAkB,OAAO,KAAK,EAAQ,GAAG,CAAC,CAAC,KAAK,EACtD,MAAO,CACL,WAAW,EAAQ,OACnB,YAAY,EAAQ,UACpB,QAAQ,EAAgB,KAAK,IAAI,GAAK,IACtC,iBACF,CAAC,CAAC,KAAK;CAAI,CACb,CAEA,SAAgB,EAAa,EAA0B,CACrD,MAAO,qBAAqB,GAAW,EAAK,EAC9C"}
@@ -0,0 +1,12 @@
1
+ import { AgentProfile } from "@agimon-ai/doompi-config/profiles";
2
+ import { SelectItem } from "@earendil-works/pi-tui";
3
+ //#region src/services/profileText.d.ts
4
+ /** Rows for the single-select profile picker. */
5
+ declare function profileItems(profiles: AgentProfile[]): SelectItem[];
6
+ declare function profileDescription(profile: AgentProfile): string;
7
+ /** Shown when the picked profile is already active. */
8
+ declare function profileSummary(profile: AgentProfile): string;
9
+ declare function profileTitle(current?: string): string;
10
+ //#endregion
11
+ export { profileDescription, profileItems, profileSummary, profileTitle };
12
+ //# sourceMappingURL=profileText.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileText.d.cts","names":[],"sources":["../../src/services/profileText.ts"],"mappings":";;;;iBAMgB,aAAa,UAAU,iBAAiB;iBAQxC,mBAAmB,SAAS;;iBAM5B,eAAe,SAAS;iBAUxB,aAAa"}
@@ -0,0 +1,12 @@
1
+ import { AgentProfile } from "@agimon-ai/doompi-config/profiles";
2
+ import { SelectItem } from "@earendil-works/pi-tui";
3
+ //#region src/services/profileText.d.ts
4
+ /** Rows for the single-select profile picker. */
5
+ declare function profileItems(profiles: AgentProfile[]): SelectItem[];
6
+ declare function profileDescription(profile: AgentProfile): string;
7
+ /** Shown when the picked profile is already active. */
8
+ declare function profileSummary(profile: AgentProfile): string;
9
+ declare function profileTitle(current?: string): string;
10
+ //#endregion
11
+ export { profileDescription, profileItems, profileSummary, profileTitle };
12
+ //# sourceMappingURL=profileText.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileText.d.mts","names":[],"sources":["../../src/services/profileText.ts"],"mappings":";;;;iBAMgB,aAAa,UAAU,iBAAiB;iBAQxC,mBAAmB,SAAS;;iBAM5B,eAAe,SAAS;iBAUxB,aAAa"}
@@ -0,0 +1,3 @@
1
+ const e=`(none)`;function t(e){return e.map(e=>({value:e.name,label:e.name,description:n(e)}))}function n(e){let t=Object.keys(e.env).sort();return t.length>0?`${e.persona} (env: ${t.join(`, `)})`:e.persona}function r(t){let n=Object.keys(t.env).sort();return[`Profile ${t.name}`,`Persona: ${t.persona}`,`Env: ${n.join(`, `)||e}`,`Already loaded.`].join(`
2
+ `)}function i(t){return`Profile (current: ${t??e})`}export{n as profileDescription,t as profileItems,r as profileSummary,i as profileTitle};
3
+ //# sourceMappingURL=profileText.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileText.mjs","names":[],"sources":["../../src/services/profileText.ts"],"sourcesContent":["import type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport type { SelectItem } from '@earendil-works/pi-tui';\n\nconst NONE = '(none)';\n\n/** Rows for the single-select profile picker. */\nexport function profileItems(profiles: AgentProfile[]): SelectItem[] {\n return profiles.map((profile) => ({\n value: profile.name,\n label: profile.name,\n description: profileDescription(profile),\n }));\n}\n\nexport function profileDescription(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return environmentKeys.length > 0 ? `${profile.persona} (env: ${environmentKeys.join(', ')})` : profile.persona;\n}\n\n/** Shown when the picked profile is already active. */\nexport function profileSummary(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return [\n `Profile ${profile.name}`,\n `Persona: ${profile.persona}`,\n `Env: ${environmentKeys.join(', ') || NONE}`,\n 'Already loaded.',\n ].join('\\n');\n}\n\nexport function profileTitle(current?: string): string {\n return `Profile (current: ${current ?? NONE})`;\n}\n"],"mappings":"AAGA,MAAM,EAAO,SAGb,SAAgB,EAAa,EAAwC,CACnE,OAAO,EAAS,IAAK,IAAa,CAChC,MAAO,EAAQ,KACf,MAAO,EAAQ,KACf,YAAa,EAAmB,CAAO,CACzC,EAAE,CACJ,CAEA,SAAgB,EAAmB,EAA+B,CAChE,IAAM,EAAkB,OAAO,KAAK,EAAQ,GAAG,CAAC,CAAC,KAAK,EACtD,OAAO,EAAgB,OAAS,EAAI,GAAG,EAAQ,QAAQ,SAAS,EAAgB,KAAK,IAAI,EAAE,GAAK,EAAQ,OAC1G,CAGA,SAAgB,EAAe,EAA+B,CAC5D,IAAM,EAAkB,OAAO,KAAK,EAAQ,GAAG,CAAC,CAAC,KAAK,EACtD,MAAO,CACL,WAAW,EAAQ,OACnB,YAAY,EAAQ,UACpB,QAAQ,EAAgB,KAAK,IAAI,GAAK,IACtC,iBACF,CAAC,CAAC,KAAK;CAAI,CACb,CAEA,SAAgB,EAAa,EAA0B,CACrD,MAAO,qBAAqB,GAAW,EAAK,EAC9C"}
@@ -0,0 +1,2 @@
1
+ const e={profileApplied:`doom_pi_profile.applied`,profileLoadFailed:`doom_pi_profile.load_failed`,personaReadFailed:`doom_pi_profile.persona_read_failed`};exports.PROFILE_EVENT=e;
2
+ //# sourceMappingURL=telemetry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.cjs","names":[],"sources":["../../src/types/telemetry.ts"],"sourcesContent":["/** Telemetry events this package reports, and the port that records them. */\nexport const PROFILE_EVENT = {\n profileApplied: 'doom_pi_profile.applied',\n profileLoadFailed: 'doom_pi_profile.load_failed',\n personaReadFailed: 'doom_pi_profile.persona_read_failed',\n} as const;\n\nexport type ProfileEventName = (typeof PROFILE_EVENT)[keyof typeof PROFILE_EVENT];\nexport type ProfileEventAttributes = Record<string, string | number | boolean>;\n\nexport interface ProfileTelemetry {\n recordError(event: ProfileEventName, error: unknown, attributes?: ProfileEventAttributes): Promise<void>;\n recordEvent(event: ProfileEventName, attributes?: ProfileEventAttributes): Promise<void>;\n}\n"],"mappings":"AACA,MAAa,EAAgB,CAC3B,eAAgB,0BAChB,kBAAmB,8BACnB,kBAAmB,qCACrB"}
@@ -0,0 +1,16 @@
1
+ //#region src/types/telemetry.d.ts
2
+ /** Telemetry events this package reports, and the port that records them. */
3
+ declare const PROFILE_EVENT: {
4
+ readonly profileApplied: 'doom_pi_profile.applied';
5
+ readonly profileLoadFailed: 'doom_pi_profile.load_failed';
6
+ readonly personaReadFailed: 'doom_pi_profile.persona_read_failed';
7
+ };
8
+ type ProfileEventName = (typeof PROFILE_EVENT)[keyof typeof PROFILE_EVENT];
9
+ type ProfileEventAttributes = Record<string, string | number | boolean>;
10
+ interface ProfileTelemetry {
11
+ recordError(event: ProfileEventName, error: unknown, attributes?: ProfileEventAttributes): Promise<void>;
12
+ recordEvent(event: ProfileEventName, attributes?: ProfileEventAttributes): Promise<void>;
13
+ }
14
+ //#endregion
15
+ export { PROFILE_EVENT, ProfileEventAttributes, ProfileEventName, ProfileTelemetry };
16
+ //# sourceMappingURL=telemetry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.cts","names":[],"sources":["../../src/types/telemetry.ts"],"mappings":";;cACa;WACX;WACA;WACA;;KAGU,2BAA2B,4BAA4B;KACvD,yBAAyB;UAEpB;EACf,YAAY,OAAO,kBAAkB,gBAAgB,aAAa,yBAAyB;EAC3F,YAAY,OAAO,kBAAkB,aAAa,yBAAyB"}
@@ -0,0 +1,16 @@
1
+ //#region src/types/telemetry.d.ts
2
+ /** Telemetry events this package reports, and the port that records them. */
3
+ declare const PROFILE_EVENT: {
4
+ readonly profileApplied: 'doom_pi_profile.applied';
5
+ readonly profileLoadFailed: 'doom_pi_profile.load_failed';
6
+ readonly personaReadFailed: 'doom_pi_profile.persona_read_failed';
7
+ };
8
+ type ProfileEventName = (typeof PROFILE_EVENT)[keyof typeof PROFILE_EVENT];
9
+ type ProfileEventAttributes = Record<string, string | number | boolean>;
10
+ interface ProfileTelemetry {
11
+ recordError(event: ProfileEventName, error: unknown, attributes?: ProfileEventAttributes): Promise<void>;
12
+ recordEvent(event: ProfileEventName, attributes?: ProfileEventAttributes): Promise<void>;
13
+ }
14
+ //#endregion
15
+ export { PROFILE_EVENT, ProfileEventAttributes, ProfileEventName, ProfileTelemetry };
16
+ //# sourceMappingURL=telemetry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.mts","names":[],"sources":["../../src/types/telemetry.ts"],"mappings":";;cACa;WACX;WACA;WACA;;KAGU,2BAA2B,4BAA4B;KACvD,yBAAyB;UAEpB;EACf,YAAY,OAAO,kBAAkB,gBAAgB,aAAa,yBAAyB;EAC3F,YAAY,OAAO,kBAAkB,aAAa,yBAAyB"}
@@ -0,0 +1,2 @@
1
+ const e={profileApplied:`doom_pi_profile.applied`,profileLoadFailed:`doom_pi_profile.load_failed`,personaReadFailed:`doom_pi_profile.persona_read_failed`};export{e as PROFILE_EVENT};
2
+ //# sourceMappingURL=telemetry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.mjs","names":[],"sources":["../../src/types/telemetry.ts"],"sourcesContent":["/** Telemetry events this package reports, and the port that records them. */\nexport const PROFILE_EVENT = {\n profileApplied: 'doom_pi_profile.applied',\n profileLoadFailed: 'doom_pi_profile.load_failed',\n personaReadFailed: 'doom_pi_profile.persona_read_failed',\n} as const;\n\nexport type ProfileEventName = (typeof PROFILE_EVENT)[keyof typeof PROFILE_EVENT];\nexport type ProfileEventAttributes = Record<string, string | number | boolean>;\n\nexport interface ProfileTelemetry {\n recordError(event: ProfileEventName, error: unknown, attributes?: ProfileEventAttributes): Promise<void>;\n recordEvent(event: ProfileEventName, attributes?: ProfileEventAttributes): Promise<void>;\n}\n"],"mappings":"AACA,MAAa,EAAgB,CAC3B,eAAgB,0BAChB,kBAAmB,8BACnB,kBAAmB,qCACrB"}
package/llms.txt ADDED
@@ -0,0 +1,12 @@
1
+ # Doom Pi Profile
2
+
3
+ Package-owned guidance for DoomPi profile discovery, personas, environment defaults, and precedence.
4
+
5
+ ## How to author
6
+
7
+ - [Author DoomPi profiles](./src/prompts/doompi-author-profile/SKILL.md): Configure personal and repository profiles.
8
+ - [Profiles authoring contract](./src/prompts/doompi-author-profile/references/profiles-contract.md): File locations, discovery, precedence, path safety, environment defaults, and verification.
9
+
10
+ ## Package reference
11
+
12
+ - [Package README](./README.md): Profile behavior, activation, and public package entries.
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@agimon-ai/doompi-profile",
3
+ "version": "0.0.1-alpha.10",
4
+ "description": "Persona and environment profile switching for DoomPi sessions.",
5
+ "keywords": [
6
+ "agent-persona",
7
+ "ai",
8
+ "coding-agent",
9
+ "developer-tools",
10
+ "doompi",
11
+ "pi-coding-agent",
12
+ "pi-extension",
13
+ "pi-package",
14
+ "profile-switching",
15
+ "system-prompt"
16
+ ],
17
+ "homepage": "https://agimon.ai",
18
+ "license": "MIT",
19
+ "author": "Vuong Ngo",
20
+ "files": [
21
+ "dist",
22
+ "llms.txt",
23
+ "README.md",
24
+ "src/prompts",
25
+ "LICENSE",
26
+ "package.json"
27
+ ],
28
+ "type": "module",
29
+ "main": "./dist/index.cjs",
30
+ "types": "./dist/index.d.mts",
31
+ "jsnext:main": "./dist/index.mjs",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.mts",
35
+ "import": "./dist/index.mjs",
36
+ "require": "./dist/index.cjs"
37
+ },
38
+ "./extensions/persona": {
39
+ "types": "./dist/extensions/persona.d.mts",
40
+ "import": "./dist/extensions/persona.mjs",
41
+ "require": "./dist/extensions/persona.cjs"
42
+ },
43
+ "./extensions/pi": {
44
+ "types": "./dist/extensions/pi.d.mts",
45
+ "import": "./dist/extensions/pi.mjs",
46
+ "require": "./dist/extensions/pi.cjs"
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "dependencies": {
54
+ "@deepseek-ai/cordis": "4.0.1",
55
+ "@agimon-ai/doompi-config": "0.0.1-alpha.32",
56
+ "@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.32",
57
+ "@agimon-ai/doompi-telemetry": "0.0.1-alpha.32",
58
+ "@agimon-ai/doompi-ui": "0.0.1-alpha.32"
59
+ },
60
+ "devDependencies": {
61
+ "@deepseek-ai/cordis": "4.0.1",
62
+ "@earendil-works/pi-coding-agent": "0.84.2",
63
+ "@earendil-works/pi-tui": "0.84.2",
64
+ "@types/node": "26.2.0",
65
+ "@vitest/coverage-v8": "4.1.11",
66
+ "tsdown": "0.22.14",
67
+ "typescript": "7.0.2",
68
+ "vitest": "4.1.11",
69
+ "@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.30"
70
+ },
71
+ "peerDependencies": {
72
+ "@earendil-works/pi-coding-agent": "0.84.2",
73
+ "@earendil-works/pi-tui": "0.84.2"
74
+ },
75
+ "peerDependenciesMeta": {
76
+ "@earendil-works/pi-coding-agent": {
77
+ "optional": true
78
+ },
79
+ "@earendil-works/pi-tui": {
80
+ "optional": true
81
+ }
82
+ },
83
+ "engines": {
84
+ "node": ">=22.19.0"
85
+ },
86
+ "pi": {
87
+ "extensions": [
88
+ "./dist/extensions/pi.mjs"
89
+ ]
90
+ },
91
+ "scripts": {
92
+ "build": "tsdown",
93
+ "test": "vitest --run",
94
+ "typecheck": "tsc --noEmit",
95
+ "lint": "oxlint . && oxfmt . --check",
96
+ "fixcode": "oxlint . --fix && oxfmt ."
97
+ }
98
+ }
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: doompi-author-profile
3
+ description: Configure DoomPi profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.
4
+ ---
5
+
6
+ # Author DoomPi profiles
7
+
8
+ Configure a profile as one persona plus optional environment defaults.
9
+
10
+ ## Workflow
11
+
12
+ 1. Read both `~/.pi/.doom/profiles.yaml` and the repository's `.doom/profiles.yaml` when they exist.
13
+ 2. Use `profiles.roots` for one-level persona discovery. Use `profiles.entries` when a profile needs an explicit persona path or environment defaults.
14
+ 3. Resolve relative roots and persona paths against the file that declares them. Keep an explicit persona inside that file's `agents/` directory or one of its configured roots.
15
+ 4. Put instructions in `profile.md`, `SOUL.md`, or `AGENTS.md`. DoomPi concatenates non-empty files in that order.
16
+ 5. Keep every `env` value a string. Treat it as a default because an already exported value wins.
17
+ 6. Preserve the precedence rules. Explicit entries override discoveries, and repository entries override personal entries at the same precedence level.
18
+ 7. Verify the selection with `doompi --profile <name> --explain`, then smoke-test `/profile` when changing live switching behavior.
19
+
20
+ Read [references/profiles-contract.md](references/profiles-contract.md) before changing discovery, precedence, path handling, or profile application.
@@ -0,0 +1,100 @@
1
+ # DoomPi profiles authoring contract
2
+
3
+ ## Sources and shape
4
+
5
+ DoomPi reads profile declarations in this order:
6
+
7
+ 1. `~/.pi/.doom/profiles.yaml`
8
+ 2. `<repoRoot>/.doom/profiles.yaml`
9
+
10
+ The current catalog shape is:
11
+
12
+ ```yaml
13
+ profiles:
14
+ roots: [agents/acme]
15
+ entries:
16
+ writer:
17
+ persona: agents/special/writer
18
+ env:
19
+ BRAND: acme
20
+ TONE: concise
21
+ ```
22
+
23
+ The document may contain only the `profiles` mapping. In catalog form, `profiles` may contain only
24
+ `roots` and `entries`. DoomPi still accepts the earlier flat form, where profile names appear
25
+ directly below `profiles`, but new configuration should use catalog form.
26
+
27
+ Every relative root or persona path resolves against the file that declares it. Repository paths
28
+ resolve from the repository root. Personal paths resolve from `~/.pi/.doom`.
29
+
30
+ ## Root discovery
31
+
32
+ Each `profiles.roots` value must resolve to an existing directory.
33
+
34
+ - If the root directly contains `profile.md`, `SOUL.md`, or `AGENTS.md`, the root is one profile.
35
+ Its directory name is the profile name, and its children are not scanned.
36
+ - Otherwise, DoomPi inspects only the root's direct-child directories. A child becomes a profile
37
+ when it directly contains at least one persona file.
38
+ - Discovery does not recurse. Add another root or an explicit entry for a deeper persona.
39
+ - A discovered profile has an empty environment mapping.
40
+ - Unreadable candidates and candidates whose real path or persona files escape the configured root
41
+ are ignored. An invalid configured root itself is an error.
42
+
43
+ ## Explicit entries and path confinement
44
+
45
+ An explicit entry may contain only `persona` and `env`. `persona` is required, must be a non-empty
46
+ relative path, and must resolve to a directory containing readable persona content.
47
+
48
+ The persona must remain inside either:
49
+
50
+ - the `agents/` directory beside the declaring repository root or personal `.doom` directory, or
51
+ - one of the `profiles.roots` directories declared in that same file.
52
+
53
+ DoomPi checks both the lexical path and the real filesystem path. A persona-directory symlink cannot
54
+ escape an allowed root. Each resolved persona file must also remain inside the real persona
55
+ directory, so a file symlink cannot import instructions from outside it. Invalid explicit entries
56
+ fail loading instead of being skipped.
57
+
58
+ Persona content is assembled from non-empty files in this order:
59
+
60
+ 1. `profile.md`
61
+ 2. `SOUL.md`
62
+ 3. `AGENTS.md`
63
+
64
+ ## Precedence
65
+
66
+ DoomPi resolves names in four passes, from lowest to highest precedence:
67
+
68
+ 1. Personal root discoveries
69
+ 2. Repository root discoveries
70
+ 3. Personal explicit entries
71
+ 4. Repository explicit entries
72
+
73
+ A later profile replaces an earlier profile with the same name. This means any explicit entry
74
+ overrides discovery, including a personal explicit entry replacing a repository discovery. A
75
+ repository explicit entry wins over a personal explicit entry. Unrelated names from all sources
76
+ remain available, and the final list is sorted by profile name.
77
+
78
+ ## Environment defaults and activation
79
+
80
+ Every `env` key maps to a string. Applying a profile writes only variables that are not already
81
+ exported by the caller. When switching profiles, DoomPi removes a value contributed by the previous
82
+ profile only if that value has not since changed, then applies the next profile's defaults.
83
+
84
+ The `/profile` command resolves the named profile and executes the change through the session
85
+ transition coordinator. A profile change uses Pi reload so extensions re-read the environment.
86
+ DoomPi assembles the persona into a private run-directory file, and the persona Pi entry appends
87
+ that content to the system prompt after reload.
88
+
89
+ ## Verification
90
+
91
+ ```sh
92
+ pnpm nx test @agimon-ai/doompi-config
93
+ pnpm nx typecheck @agimon-ai/doompi-config
94
+ pnpm nx test @agimon-ai/doompi-profile
95
+ pnpm nx typecheck @agimon-ai/doompi-profile
96
+ pnpm --filter @agimon-ai/doompi exec doompi --profile writer --explain
97
+ ```
98
+
99
+ Use an actual parent session to smoke-test `/profile` when changing transition, environment, or
100
+ persona application behavior.