Skip to content

A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.

TypeScript

fix(profiles): preserve Gentle Shell workflow metadata

Maicol Extic Oliveras Jimenezc1fb9ff2c812
diff --git a/docs/gentle-shell-compatibility.md b/docs/gentle-shell-compatibility.md
new file mode 100644
index 0000000..3f150b9
--- /dev/null
+++ b/docs/gentle-shell-compatibility.md
@@ -0,0 +1,25 @@
+# Gentle Shell profile compatibility
+
+Gentle Dot preserves Gentle Shell 4.7 profile workflow metadata when managing model profiles. This is format compatibility, not a new UI control or permission to enable a delegation mode.
+
+## Stored profiles
+
+Gentle Shell keeps its version-1 profile format and may add:
+
+```json
+{
+ "workflow": {
+ "delegated": { "orchestratorMode": "full-delegation" }
+ }
+}
+```
+
+The name must identify a stored profile. Like the engine, Dot omits the default `organic` mode, invalid modes, and orphan workflow entries. Existing organic-only stores retain their previous shape.
+
+Saving routes or applying another profile preserves existing workflow entries. Renaming or duplicating a profile carries its workflow metadata; deleting it removes that profile's entry. An import with identical routes but a different workflow mode is not an identical profile: it receives the normal collision suffix. Repeating that import does not duplicate it again or alter the source store.
+
+## Verification boundaries
+
+Tests exercise synthetic profile files through the public profile store and format functions. They never migrate real user data or invoke a model. Windows POSIX mode-bit assertions must be distinguished from this format change using the unmodified base; they must not be skipped, weakened, or presented as passing.
+
+Dependency resolution, candidate runtime packaging, the pinned Gentle AI helper, and independent verification remain separate checks. A dependency version change alone does not establish runtime compatibility.
diff --git a/odd/tasks/gentle-shell-4-7-main-alignment.md b/odd/tasks/gentle-shell-4-7-main-alignment.md
new file mode 100644
index 0000000..b2e5184
--- /dev/null
+++ b/odd/tasks/gentle-shell-4-7-main-alignment.md
@@ -0,0 +1,23 @@
+# Align main-based Gentle Dot with Gentle Shell 4.7.0
+Target: M:/Dev/Personal/gentle-dot-windows/gentle-dot-shell-4-7, branch feat/align-gentle-shell-4-7 from exact main9732fb3; preserve Windows WIP and global harness. Publishing/merging main is a separate delivery decision.
+Checks: exact registry pin/integrity, Pi/Node compatibility, focused embedded-host/runtime checks, independent verification. Risk: item 1 (preserving existing stored profile workflow metadata); item 5 (dependencies and packaged runtime).
+
+## Specs
+S1. "por cierto antes de ahi que alinar gentle dot en main a la ultima version de gentle-shell por favor hazlo y segumos trabajando"
+
+## Tasks
+T1 | S1 | parent registry/ref checks + read-only integration map | done | Freshmain9732fb3/npm4.7.0confirmed. Explore mw77sgnq-i-7uqu source map: consumed CLI/gates/factory retained; 4.7 v1 profile workflow metadata would be lost by app serializer. Parent read confirmed gap and SDKnormalization. Job35verifiedofficial4.7.0/pnpm11.5archives; exactisolatedpnpm--version11.5.0passed. Source/runtimebehaviornotyetaccepted.
+T2A | S1 | inline profile-format preservation + TDD | pending | Risk:item1. Source/tests/docs implemented:3newcasesRED3→GREEN3,oldorganicshape/CRUD/import/rollbackcovered;Biome/TSCpassed. Fullprofiles27pass/3fail;exactbase24pass/SAME3WindowsPOSIXmodefails,notnewregressions. Final acceptance awaitsT3/T4cross-platform+independentproof,do notmarkdonewhilefullchecksfail. Ownsourcework-unitcommitbeforedependencyunit;no real profiles/newUI/modeauthority.
+T2 | S1 | parent isolated feature branch and minimal alignment | in_progress | New main9732fb3worktree/branchcreated;profiledata-preservationimplementationpresentandfocusedchecksGreen. Nextupdateexactgentle-pi4.7pin/lock/runtimeexpectationwithisolatedpnpm11.5;no4.7releaseageexemption/globalSDK/scripts. Final acceptance T3/T4 still pending.
+T3 | S1 | focused compatibility and package/runtime checks | pending | Observe meaningful RED if behavior changes; for dependency pin-only change explain test-first applicability and use actual target4.7.0, not installed global4.6.0. Fresh isolated config/state, no providers/credentials/hardware; respect resource/toolchain limits and never copy unrelated node_modules as test isolation.
+T4 | S1 | independent risk5 verification + applicable native review | pending | This app4.7.0candidate is distinct from unavailable installed4.6maintenance verifier; never retry or relabel that old result. Exact source/base and correctly scoped isolated proof required; native review only provider-directed and candidate-consented, no invented approval.
+T5 | S1 | reviewable feature commit + explicit main delivery | pending | Work-unit commits only on own feature branch, tests/docs alongside changed behavior; no PR/release/main push or merge inferred from implementation. Record exact check/commit/delivery scope and unresolved proof before returning to original Windows work.
+
+## Log
+L1. Human request verbatim: "por cierto antes de ahi que alinar gentle dot en main a la ultima version de gentle-shell por favor hazlo y segumos trabajando"
+L2. Current app checkout M:/Dev/Personal/gentle-dot-windows/gentle-dot-main is feat/windows-spanish-integration at4d2c84bdf9b2c510605c8991ec7000d610118c95. Preserve modified odd/tasks/windows-current-local-run.md, untracked odd/tasks/windows-subagent-launcher.md and unknown Microsoft/. Sibling gentle-dot-local is feat/windows-native-independent at65bac1710690a46365d1429ccfcc46bf694751d9; no source edits there. App common Git dir is that sibling's .git; enclosing session repository is different M:/Dev/Personal, so subagent independent-repository consent route remains required.
+L3. Fetchjob34exit0 refreshed origin/main, still9732fb3154527db8c4b89e2480cb385887a69d56. Live public npm registry latest gentle-pi4.7.0, repository Gentleman-Programming/gentle-shell, sha512-/wsO16tOPhfN6d2GxZP8kcX18AHNLE2aRI2Q6kvlWxEp7h5AHFGqAl/5TCAw8q31N4Os4cT/ANW/c6DDxozImw==, SHA1e368917fdfe1c5ad88f038396a42b6bdca442ff7. Dependencies unchangedpi-pretty0.6.27; peersPi-coding-agent>=1.2.0/pi-ai*/pi-tui*/typebox*. Main daemon currently pinsgentle-pi4.6.0 and Pi1.5.0; root Node>=24 meets package>=22.19.0. Latest registry metadata is authoritative for pin; Context7 reference confirms minimum/runtime integration concepts but indexed main docs are not a tagged4.7.0artifact proof.
+L4. This request changes APP dependency integration from MAIN, not permission to upgrade installed global gentle-pi4.6.0 or its SDK1.5.0, retry failed upgrade4.7, edit permissions/credentials, resume unavailable verifier or discard prior work. Installed-harness maintenance acceptance remains UNAVAILABLE and original Windows app/installer work remains separate. No paid provider/model/app hardware/desktop execution or canceled localMSVCretry; large local builds remain paused. Main delivery/publication needs its own exact decision after verified candidate exists.
+L5. Created own sibling worktree gentle-dot-shell-4-7/feat/align-gentle-shell-4-7 from exact9732fb3; git status shows only generated plan before implementation. No existing worktree checkout/source changes. Initial plan copy in Windows worktree is owned untracked bookkeeping; active spec/mirror locator is the new worktree. Read only planned edit targets (daemon package/lock blocks/workspace policy); pnpm allowBuilds permitsgentle-pi/esbuildbutthisstageexecutesnone. Parent path pnpm11.0.9 differs repo pin11.5.0, so prepare verified project-local exacttool without global install or private config. Job35active: download official gentle-pi4.7/pnpm11.5, verify SHA512+SHA1/metadata identities/archive paths/types/decompression bounds, extract only fresh owned build/alignment staging; no apps/models/builds/install scripts. Helper syntax checked and build path confirmed ignored. Integration map taskmw77sgnq-i-7uquactive at this checkpoint; no dependency edit or functional acceptance yet.
+L6. Artifactjob35exit0gentle-pi4.7.0archive11.77MiB/pnpm11.5.0archive4.08MiBverified/extractedwithnoscripts/globalchanges;isolatedpnpm--versionexit0/11.5.0/stderr0. Mapagentfinishedreadonly,noCodeGraphavailablefallbackreads. Confirmednewworkflowmetadata:SDK4.7agent-profiles.tsnormalizesknownorganic/full-delegationmodes,omitsdefaultorganicandorphan/invalidrecords;appsrc/profiles.tsparse/serializelosestopworkflowmap,CRUD/importdedupeignoreit. Parentreadexactaffectedcode;mustpreservebeforeupgrade,no newUIcontrolrequested. Otherpinruntime-build.test.ts110requires4.7expectation. CIexact4.6releaseageexceptions remainhistoricalversionspecific;no4.7exception/wildcard/minimum-ageweakeningauthorized. Actual4.7installerpinsGentleAI4.4.0/Windowsv4module/Go>=1.25.10;noexhaustedproviderbuildretryornewlocalGohelperbuildauthorizedhere. Runlightcandidatecheckswithoutlifecycle/modelcredentials;nativehelper/packagedproofseparateandhonest. ProfiledataunitgetsownRisk1commit,dependencyRisk5unitseparate. NewappcandidateverificationdoesnotretryoldinstalledmaintenanceUNAVAILABLE.
+L7. ResourceCIMreadonlyfree565MiB/total7.68GiB;noheavy/nativebuilds. Job36isolatedfrozenbaselineinstall11.5exit0,365packages,ignoreScripts/network2/child1,no privateconfig/global/helpercompile. REDfocused3actualassertionfailuresworkflowroundtrip/mutations/importmode-dedup,thenGREEN3pass(filterexcluded27). Fullprofilesfile27pass/3fail onPOSIXmodeexpectations(0666vs0600twice,vs0644once). Oneexactbase9732fb3code-onlygitarchivesnapshot(no cpnode_modules;sharedreadonlydependencyjunctionswithinownproject)reproducedold24pass/SAME3fail,logsbuild/alignment/main-baseline-PwJQSC;no permissionassertionsweakened/skipped. Sourcechanges60lines/tests92lines+newcompatdoc;existingemptycatchwarningresolvedwithsameProfileErrorthrow,message/codeunchanged. Biomeformat/check2filespassed aftercorrecting pnpm-execstoreoptionto--config.store-dir(beforeexecution,firstattemptnoformatapplied). Typecheckjob37exit0/no stdout/stderr. Fullacceptancepartial,notoverallGREEN. Existingnewdata-sourceunitcanbecommittedforreview,butno main delivery or acceptedtaskclaim.
diff --git a/packages/daemon/src/profiles.ts b/packages/daemon/src/profiles.ts
index 6ea5c89..58afbd1 100644
--- a/packages/daemon/src/profiles.ts
+++ b/packages/daemon/src/profiles.ts
@@ -46,9 +46,14 @@ const LOCK_STALE_MS = 10_000;
const LOCK_RETRY_MS = 20;
const LOCK_ATTEMPTS = 250;
+export interface ProfileWorkflow {
+ orchestratorMode: "organic" | "full-delegation";
+}
+
export interface ProfilesFile {
active?: string;
profiles: Record<string, ProfileRoles>;
+ workflow?: Record<string, ProfileWorkflow>;
}
export type ProfileErrorCode =
@@ -117,6 +122,26 @@ function normalizeRoles(value: unknown): ProfileRoles | undefined {
return roles;
}
+/** Keeps the engine's declared, non-default workflow opt-ins for surviving profiles. */
+function normalizeWorkflow(
+ value: unknown,
+ profiles: Record<string, ProfileRoles>,
+): Record<string, ProfileWorkflow> | undefined {
+ if (!isRecord(value)) return undefined;
+ const workflow: Record<string, ProfileWorkflow> = {};
+ for (const [name, entry] of Object.entries(value)) {
+ if (
+ Object.hasOwn(profiles, name) &&
+ isValidProfileName(name) &&
+ isRecord(entry) &&
+ entry.orchestratorMode === "full-delegation"
+ ) {
+ workflow[name] = { orchestratorMode: "full-delegation" };
+ }
+ }
+ return Object.keys(workflow).length > 0 ? workflow : undefined;
+}
+
/** Parses a profile store; undefined when it is not one. Invalid entries are dropped like the engine does. */
export function parseProfilesFile(text: string): ProfilesFile | undefined {
let value: unknown;
@@ -135,10 +160,12 @@ export function parseProfilesFile(text: string): ProfilesFile | undefined {
}
const file: ProfilesFile = { profiles };
if (typeof value.active === "string" && Object.hasOwn(profiles, value.active)) file.active = value.active;
+ const workflow = normalizeWorkflow(value.workflow, profiles);
+ if (workflow) file.workflow = workflow;
return file;
}
-/** Serializes in the engine's key order: kind, version, profiles, active. */
+/** Serializes in the engine's key order: kind, version, profiles, active, optional workflow. */
export function serializeProfilesFile(file: ProfilesFile): string {
const payload: Record<string, unknown> = {
kind: PROFILES_KIND,
@@ -146,6 +173,8 @@ export function serializeProfilesFile(file: ProfilesFile): string {
profiles: file.profiles,
};
if (file.active !== undefined) payload.active = file.active;
+ const workflow = normalizeWorkflow(file.workflow, file.profiles);
+ if (workflow) payload.workflow = workflow;
return `${JSON.stringify(payload, null, 2)}\n`;
}
@@ -199,7 +228,9 @@ function readObject(path: string, code: ProfileErrorCode): Record<string, unknow
try {
const value: unknown = JSON.parse(text);
if (isRecord(value)) return value;
- } catch {}
+ } catch {
+ throw new ProfileError(code);
+ }
throw new ProfileError(code);
}
@@ -333,6 +364,11 @@ export class ProfileStore {
file.profiles = Object.fromEntries(
Object.entries(file.profiles).map(([name, roles]) => [name === from ? to : name, roles]),
);
+ if (file.workflow?.[from]) {
+ file.workflow = Object.fromEntries(
+ Object.entries(file.workflow).map(([name, entry]) => [name === from ? to : name, entry]),
+ );
+ }
if (file.active === from) file.active = to;
});
}
@@ -342,6 +378,7 @@ export class ProfileStore {
const roles = requireExisting(file, from);
requireFree(file, to);
file.profiles[to] = structuredClone(roles);
+ if (file.workflow?.[from]) file.workflow[to] = structuredClone(file.workflow[from]);
});
}
@@ -350,6 +387,7 @@ export class ProfileStore {
requireExisting(file, name);
if (file.active === name) throw new ProfileError("active_profile");
delete file.profiles[name];
+ if (file.workflow) delete file.workflow[name];
});
}
@@ -448,9 +486,14 @@ export class ProfileStore {
const imported: ImportResult["imported"] = [];
const used = new Set<string>();
for (const [name, roles] of Object.entries(source.profiles)) {
- const target = importName(file, name, roles);
+ const workflow = source.workflow?.[name];
+ const target = importName(file, name, roles, workflow);
if (!target) continue;
file.profiles[target] = roles;
+ if (workflow) {
+ file.workflow ??= {};
+ file.workflow[target] = { ...workflow };
+ }
imported.push({ from: name, to: target });
for (const route of Object.values(roles)) {
const provider = route.model ? splitModel(route.model)?.provider : undefined;
@@ -554,8 +597,15 @@ function cleanRoles(roles: ProfileRoles): ProfileRoles {
}
/** The free name for an imported profile, or undefined when an identical copy is already saved. */
-function importName(file: ProfilesFile, name: string, roles: ProfileRoles): string | undefined {
- const same = (other: string) => JSON.stringify(file.profiles[other]) === JSON.stringify(roles);
+function importName(
+ file: ProfilesFile,
+ name: string,
+ roles: ProfileRoles,
+ workflow?: ProfileWorkflow,
+): string | undefined {
+ const same = (other: string) =>
+ JSON.stringify(file.profiles[other]) === JSON.stringify(roles) &&
+ (file.workflow?.[other]?.orchestratorMode ?? "organic") === (workflow?.orchestratorMode ?? "organic");
for (let n = 0; ; n++) {
const suffix = n === 0 ? "" : n === 1 ? "-imported" : `-imported-${n}`;
const candidate = `${name.slice(0, 64 - suffix.length)}${suffix}`;
diff --git a/packages/daemon/test/profiles.test.ts b/packages/daemon/test/profiles.test.ts
index 977188a..280c46a 100644
--- a/packages/daemon/test/profiles.test.ts
+++ b/packages/daemon/test/profiles.test.ts
@@ -77,6 +77,31 @@ describe("profile file format", () => {
expect(serializeProfilesFile(file ?? { profiles: {} })).toBe(ENGINE_FILE);
});
+ it("preserves 4.7 workflow metadata using the engine's normalization", () => {
+ const payload = {
+ kind: "gentle-pi.agent_model_profiles",
+ version: 1,
+ profiles: { delegated: {}, organic: {}, invalid: {} },
+ active: "delegated",
+ workflow: {
+ delegated: { orchestratorMode: "full-delegation" },
+ organic: { orchestratorMode: "organic" },
+ invalid: { orchestratorMode: "unknown" },
+ missing: { orchestratorMode: "full-delegation" },
+ },
+ };
+ const file = parseProfilesFile(JSON.stringify(payload));
+ expect(file?.workflow).toEqual({ delegated: { orchestratorMode: "full-delegation" } });
+ expect(serializeProfilesFile(file ?? { profiles: {} })).toBe(
+ `${JSON.stringify({ ...payload, workflow: { delegated: { orchestratorMode: "full-delegation" } } }, null, 2)}\n`,
+ );
+ const organic = parseProfilesFile(
+ JSON.stringify({ ...payload, workflow: { organic: { orchestratorMode: "organic" } } }),
+ );
+ expect(organic?.workflow).toBeUndefined();
+ expect(JSON.parse(serializeProfilesFile(organic ?? { profiles: {} }))).not.toHaveProperty("workflow");
+ });
+
it("normalizes like the engine: string routes, effort alias, invalid names and stale active dropped", () => {
const file = parseProfilesFile(
JSON.stringify({
@@ -99,6 +124,73 @@ describe("profile file format", () => {
});
describe("profile store", () => {
+ it("keeps 4.7 workflow metadata through routing mutations", async () => {
+ const { store, write, json, profilesPath } = setup();
+ write(profilesPath, {
+ kind: "gentle-pi.agent_model_profiles",
+ version: 1,
+ profiles: { source: { worker: { thinking: "low" } }, organic: {} },
+ active: "source",
+ workflow: { source: { orchestratorMode: "full-delegation" } },
+ });
+ const beforeRejected = readFileSync(profilesPath, "utf8");
+ const beforeList = store.list();
+ await expect(store.rename("source", "organic")).rejects.toMatchObject({ code: "duplicate_name" });
+ expect(readFileSync(profilesPath, "utf8")).toBe(beforeRejected);
+ expect(store.list()).toEqual(beforeList);
+ await store.save("source", { worker: { thinking: "high" } });
+ expect(json(profilesPath).workflow).toEqual({ source: { orchestratorMode: "full-delegation" } });
+ await store.duplicate("source", "copy");
+ await store.rename("source", "renamed");
+ expect(json(profilesPath).workflow).toEqual({
+ copy: { orchestratorMode: "full-delegation" },
+ renamed: { orchestratorMode: "full-delegation" },
+ });
+ expect(store.list().active).toBe("renamed");
+ await store.apply("organic");
+ expect(store.list().active).toBe("organic");
+ await store.remove("copy");
+ await store.saveCurrent("captured");
+ expect(json(profilesPath).workflow).toEqual({ renamed: { orchestratorMode: "full-delegation" } });
+ expect(store.list().profiles).toEqual([
+ { name: "captured", roles: {} },
+ { name: "organic", roles: {} },
+ { name: "renamed", roles: { worker: { thinking: "high" } } },
+ ]);
+ });
+
+ it("imports 4.7 profiles with identical routes but distinct workflow modes", async () => {
+ const { store, write, json, shellHome, profilesPath } = setup();
+ const roles = { worker: { thinking: "low" as const } };
+ await store.save("same", roles);
+ await store.apply("same");
+ const sourcePath = join(shellHome, "profiles.json");
+ write(sourcePath, {
+ kind: "gentle-pi.agent_model_profiles",
+ version: 1,
+ profiles: { same: roles },
+ active: "same",
+ workflow: { same: { orchestratorMode: "full-delegation" } },
+ });
+ const sourceBytes = readFileSync(sourcePath, "utf8");
+ expect(await store.import()).toEqual({
+ imported: [{ from: "same", to: "same-imported" }],
+ missingProviders: [],
+ });
+ expect(json(profilesPath).workflow).toEqual({ "same-imported": { orchestratorMode: "full-delegation" } });
+ expect(store.list()).toEqual({
+ profiles: [
+ { name: "same", roles },
+ { name: "same-imported", roles },
+ ],
+ active: "same",
+ });
+ const importedBytes = readFileSync(profilesPath, "utf8");
+ expect(await store.import()).toEqual({ imported: [], missingProviders: [] });
+ expect(readFileSync(profilesPath, "utf8")).toBe(importedBytes);
+ expect(readFileSync(sourcePath, "utf8")).toBe(sourceBytes);
+ });
+
it("creates, updates, duplicates, renames, and deletes profiles", async () => {
const { store, json, profilesPath } = setup();
expect(store.list()).toEqual({ profiles: [] });