@ricsam/r5d-worker 0.0.48 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "type": "module"
5
5
  }
@@ -84,12 +84,16 @@ function workspaceProjectBranchRelativePath(projectId, branchName) {
84
84
  function workspacePlansRelativePath(projectId, branchName) {
85
85
  return path.posix.join("plans", projectId, encodeWorkspaceBranch(branchName));
86
86
  }
87
+ const WORKSPACE_NATIVE_PLANS_RELATIVE_PATH = "workspace-plans";
87
88
  function visibleProjectBranchPath(projectsRoot, manifest, branchName) {
88
89
  return managedBranchPath(projectsRoot, manifest.checkoutPathSegments, branchName);
89
90
  }
90
91
  function localPlansBranchPath(plansRoot, projectId, branchName) {
91
92
  return path.join(plansRoot, projectId, branchName);
92
93
  }
94
+ function localWorkspacePlansPath(plansRoot) {
95
+ return path.join(plansRoot, "workspace");
96
+ }
93
97
  function assertInside(root, candidate, label) {
94
98
  const resolvedRoot = path.resolve(root);
95
99
  const resolvedCandidate = path.resolve(candidate);
@@ -667,12 +671,43 @@ function mirrorShadowPlansToLocal(input, manifest, branchName) {
667
671
  listFilesRecursively(targetRoot, planFilter)
668
672
  );
669
673
  }
674
+ function mirrorLocalWorkspacePlansToShadow(input) {
675
+ if (input.trigger.canonicalCheckoutOnly) return;
676
+ const sourceRoot = localWorkspacePlansPath(input.plansRoot);
677
+ if (!fs.existsSync(sourceRoot)) return;
678
+ const targetRoot = path.join(input.shadowRoot, WORKSPACE_NATIVE_PLANS_RELATIVE_PATH);
679
+ const planFilter = (relativePath) => relativePath.endsWith(".plan.md");
680
+ mirrorFileSet(sourceRoot, targetRoot, listFilesRecursively(sourceRoot, planFilter), listFilesRecursively(targetRoot, planFilter));
681
+ }
682
+ function mirrorShadowWorkspacePlansToLocal(input) {
683
+ if (input.trigger.canonicalCheckoutOnly) return;
684
+ const sourceRoot = path.join(input.shadowRoot, WORKSPACE_NATIVE_PLANS_RELATIVE_PATH);
685
+ const targetRoot = localWorkspacePlansPath(input.plansRoot);
686
+ const planFilter = (relativePath) => relativePath.endsWith(".plan.md");
687
+ mirrorFileSet(
688
+ sourceRoot,
689
+ targetRoot,
690
+ listShadowTrackedFiles(input, WORKSPACE_NATIVE_PLANS_RELATIVE_PATH).filter(planFilter),
691
+ listFilesRecursively(targetRoot, planFilter)
692
+ );
693
+ }
694
+ function reconcileWorkspaceNativePlans(input) {
695
+ if (input.trigger.canonicalCheckoutOnly) return;
696
+ if (fs.existsSync(localWorkspacePlansPath(input.plansRoot))) {
697
+ mirrorLocalWorkspacePlansToShadow(input);
698
+ return;
699
+ }
700
+ if (listShadowTrackedFiles(input, WORKSPACE_NATIVE_PLANS_RELATIVE_PATH).length > 0 || restoreShadowRootFromRemote(input, WORKSPACE_NATIVE_PLANS_RELATIVE_PATH)) {
701
+ mirrorShadowWorkspacePlansToLocal(input);
702
+ }
703
+ }
670
704
  function mergeGitlinkProjection(target, source) {
671
705
  target.entries.push(...source.entries);
672
706
  target.opaqueRoots.push(...source.opaqueRoots);
673
707
  }
674
708
  function mirrorVisibleWorkspaceToShadow(input, excludedCheckouts = /* @__PURE__ */ new Set()) {
675
709
  const projection = { entries: [], opaqueRoots: [] };
710
+ reconcileWorkspaceNativePlans(input);
676
711
  for (const manifest of [...input.projects].sort((left, right) => left.projectId.localeCompare(right.projectId))) {
677
712
  for (const branchName of [...new Set(manifest.branches)].sort()) {
678
713
  if (excludedCheckouts.has(`${manifest.projectId}\0${branchName}`)) continue;
@@ -708,6 +743,7 @@ function reconcileNewVisibleCheckouts(input) {
708
743
  return projection;
709
744
  }
710
745
  function mirrorShadowWorkspaceToVisible(input, opaqueWorkspaceRoots = []) {
746
+ mirrorShadowWorkspacePlansToLocal(input);
711
747
  for (const manifest of [...input.projects].sort((left, right) => left.projectId.localeCompare(right.projectId))) {
712
748
  for (const branchName of [...new Set(manifest.branches)].sort()) {
713
749
  const relativeRoot = workspaceProjectBranchRelativePath(manifest.projectId, branchName);
@@ -1291,6 +1327,7 @@ class WorkspaceSyncSingleFlight {
1291
1327
  export {
1292
1328
  MAX_WORKSPACE_SYNC_DIFF_BYTES,
1293
1329
  WORKSPACE_BRANCH,
1330
+ WORKSPACE_NATIVE_PLANS_RELATIVE_PATH,
1294
1331
  WORKSPACE_PERIODIC_SCAN_INTERVAL_MS,
1295
1332
  WorkspaceSyncSingleFlight,
1296
1333
  assertCanonicalCheckoutIndexMatchesWorktree,
@@ -1,5 +1,14 @@
1
1
  #!/usr/bin/env bun
2
2
  import { type WorkspaceProjectManifestEntry } from "./workspace-sync";
3
+ export type WorkerSessionTarget = {
4
+ type: "project";
5
+ projectId: string;
6
+ branchName: string;
7
+ } | {
8
+ type: "workspace";
9
+ ownerUserId: string;
10
+ rootProfile: "visible_projects" | "canonical_sync";
11
+ };
3
12
  type WorkerReadFileResult = {
4
13
  type: "read";
5
14
  kind: "text";
@@ -60,22 +69,17 @@ export declare function isArtifactEnvPath(filePath: string): boolean;
60
69
  export declare function syncSessionArtifacts(input: {
61
70
  baseUrl: string;
62
71
  token: string;
63
- projectId: string;
64
- branchName: string;
65
72
  sessionId: string;
66
73
  artifactRoot: string;
67
74
  }): Promise<string>;
68
75
  export declare function prepareArtifactEnvForShell(input: {
69
76
  baseUrl: string;
70
77
  token: string;
71
- projectId: string;
72
- branchName: string;
73
78
  sessionId?: string;
74
79
  artifactRoot: string;
75
80
  }): Promise<Record<string, string>>;
76
81
  export declare function preparePlanEnvForShell(input: {
77
- projectId: string;
78
- branchName: string;
82
+ target: WorkerSessionTarget;
79
83
  planRoot: string;
80
84
  activePlanId?: string;
81
85
  }): Record<string, string>;
@@ -136,6 +140,21 @@ export declare function ensureVisibleGitCheckout(input: {
136
140
  allowRequiredRemoteMigration?: boolean;
137
141
  clearPersistentAuth?: boolean;
138
142
  }): string;
143
+ type ResolvedWorkerSessionTarget = {
144
+ target: WorkerSessionTarget;
145
+ rootPath: string;
146
+ manifest?: WorkerProjectManifestEntry;
147
+ };
148
+ export declare function describeWorkerSessionTarget(target: WorkerSessionTarget): string;
149
+ export declare function resolveWorkerSessionTarget(input: {
150
+ target: WorkerSessionTarget;
151
+ baseUrl: string;
152
+ token: string;
153
+ projectsRoot: string;
154
+ syncRoot: string;
155
+ workspaceShadowRoot: string;
156
+ manifestByProjectId: Map<string, WorkerProjectManifestEntry>;
157
+ }): ResolvedWorkerSessionTarget;
139
158
  type VisibleCheckoutTarget = {
140
159
  projectId: string;
141
160
  branchName: string;
@@ -146,6 +165,17 @@ export declare function workspaceSyncCheckoutTargets(input: {
146
165
  includeAllManifestCheckouts: boolean;
147
166
  canonicalCheckoutOnly?: VisibleCheckoutTarget;
148
167
  }): VisibleCheckoutTarget[];
168
+ export declare function prepareBuiltInToolPathsForTarget(input: {
169
+ target: WorkerSessionTarget;
170
+ filePath: string;
171
+ baseUrl: string;
172
+ token: string;
173
+ sessionId?: string;
174
+ activePlanId?: string;
175
+ artifactRoot: string;
176
+ planRoot: string;
177
+ access: "read" | "write";
178
+ }): Promise<WorkerBuiltInToolPaths | undefined>;
149
179
  export declare function readWorkerTextFile(branchPath: string, filePath: string, offset?: number, limit?: number, builtInPaths?: WorkerBuiltInToolPaths): WorkerReadFileResult;
150
180
  export declare function writeWorkerTextFile(branchPath: string, filePath: string, content: string, builtInPaths?: WorkerBuiltInToolPaths): WorkerWriteFileResult;
151
181
  export declare function editWorkerTextFile(branchPath: string, filePath: string, edits: Array<{
@@ -167,6 +197,15 @@ export declare function findWorkerFiles(branchPath: string, input: {
167
197
  }, builtInPaths?: WorkerBuiltInToolPaths): WorkerFindResult;
168
198
  export declare function listWorkerDirectory(branchPath: string, inputPath?: string, inputLimit?: number, builtInPaths?: WorkerBuiltInToolPaths): WorkerLsResult;
169
199
  export declare function readWorkerImageFile(branchPath: string, filePath: string, builtInPaths?: WorkerBuiltInToolPaths): WorkerViewFileBytesResult;
200
+ export declare function prepareShellEnvForTarget(input: {
201
+ target: WorkerSessionTarget;
202
+ baseUrl: string;
203
+ token: string;
204
+ sessionId?: string;
205
+ activePlanId?: string;
206
+ artifactRoot: string;
207
+ planRoot: string;
208
+ }): Promise<Record<string, string>>;
170
209
  export declare function resolveHostShell(command?: string, platform?: NodeJS.Platform): {
171
210
  file: string;
172
211
  args: string[];
@@ -78,6 +78,7 @@ export declare function encodeWorkspaceBranch(branchName: string): string;
78
78
  export declare function workspaceProjectsForSync(projects: readonly WorkspaceProjectManifestEntry[], trigger: WorkspaceSyncTrigger): WorkspaceProjectManifestEntry[];
79
79
  export declare function workspaceProjectBranchRelativePath(projectId: string, branchName: string): string;
80
80
  export declare function workspacePlansRelativePath(projectId: string, branchName: string): string;
81
+ export declare const WORKSPACE_NATIVE_PLANS_RELATIVE_PATH = "workspace-plans";
81
82
  export declare function visibleProjectBranchPath(projectsRoot: string, manifest: WorkspaceProjectManifestEntry, branchName: string): string;
82
83
  type GitlinkEntry = {
83
84
  filePath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/main.cjs",
6
6
  "module": "./dist/mjs/main.mjs",