@aopslabs/aops 0.2.0

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 (171) hide show
  1. package/LICENSE +19 -0
  2. package/NOTICE +7 -0
  3. package/README.md +203 -0
  4. package/assets/agent-assets/core/SKILL.md +49 -0
  5. package/assets/agent-assets/core/references/agentspace/SKILL.md +78 -0
  6. package/assets/agent-assets/core/references/aops-cli-core/SKILL.md +108 -0
  7. package/assets/agent-assets/core/references/chatv3/SKILL.md +48 -0
  8. package/assets/agent-assets/core/references/collaborative-work/SKILL.md +85 -0
  9. package/assets/agent-assets/core/references/discuss/SKILL.md +66 -0
  10. package/assets/agent-assets/core/references/docman/SKILL.md +69 -0
  11. package/assets/agent-assets/core/references/hosted-chat/SKILL.md +64 -0
  12. package/assets/agent-assets/core/references/mission/SKILL.md +54 -0
  13. package/assets/agent-assets/core/references/projectman/SKILL.md +86 -0
  14. package/assets/agent-assets/core/references/sys/SKILL.md +36 -0
  15. package/assets/agent-assets/core/references/view/SKILL.md +58 -0
  16. package/assets/agent-assets/core/references/working-disciplines/SKILL.md +69 -0
  17. package/assets/agent-assets/core/user-guides/agent-assets.md +81 -0
  18. package/assets/agent-assets/core/user-guides/agentspace.md +1098 -0
  19. package/assets/agent-assets/core/user-guides/aops-cli.md +1107 -0
  20. package/assets/agent-assets/core/user-guides/aops-system.md +63 -0
  21. package/assets/agent-assets/core/user-guides/chatv3.md +113 -0
  22. package/assets/agent-assets/core/user-guides/docman.md +162 -0
  23. package/assets/agent-assets/core/user-guides/projectman.md +212 -0
  24. package/assets/agent-assets/core/user-guides/sys.md +94 -0
  25. package/assets/agent-assets/core/user-guides/working-disciplines.md +588 -0
  26. package/assets/agent-assets/gateway/aops/SKILL.md +14 -0
  27. package/assets/r6-remote-session-baseline.json +19 -0
  28. package/assets/skills/aops-install/SKILL.md +231 -0
  29. package/assets/skills/aops-install/agents/openai.yaml +4 -0
  30. package/dist/commands/activity.js +352 -0
  31. package/dist/commands/agent-profile.js +653 -0
  32. package/dist/commands/agent.js +710 -0
  33. package/dist/commands/agents-md.js +125 -0
  34. package/dist/commands/api.js +84 -0
  35. package/dist/commands/archive.js +873 -0
  36. package/dist/commands/artifact.js +535 -0
  37. package/dist/commands/assets.js +1414 -0
  38. package/dist/commands/auth/device-login.js +1 -0
  39. package/dist/commands/auth/legacy-export.js +177 -0
  40. package/dist/commands/auth/login.js +426 -0
  41. package/dist/commands/chat.js +1363 -0
  42. package/dist/commands/chatv3.js +1684 -0
  43. package/dist/commands/checkpoint.js +549 -0
  44. package/dist/commands/commercial-artifact.js +475 -0
  45. package/dist/commands/commercial-license.js +594 -0
  46. package/dist/commands/community-auth.js +62 -0
  47. package/dist/commands/community-cockpit.js +185 -0
  48. package/dist/commands/community-console.js +109 -0
  49. package/dist/commands/community-doctor.js +335 -0
  50. package/dist/commands/community-server.js +2062 -0
  51. package/dist/commands/community-setup.js +284 -0
  52. package/dist/commands/discuss.js +1448 -0
  53. package/dist/commands/doc.js +5219 -0
  54. package/dist/commands/experience.js +922 -0
  55. package/dist/commands/host.js +1127 -0
  56. package/dist/commands/init.js +118 -0
  57. package/dist/commands/memory.js +3129 -0
  58. package/dist/commands/mission.js +562 -0
  59. package/dist/commands/official-catalog.js +134 -0
  60. package/dist/commands/plan.js +84 -0
  61. package/dist/commands/playbook.js +415 -0
  62. package/dist/commands/pm/context.js +6 -0
  63. package/dist/commands/pm/index.js +701 -0
  64. package/dist/commands/pm/projectman.js +6266 -0
  65. package/dist/commands/project.js +1080 -0
  66. package/dist/commands/prompt.js +1024 -0
  67. package/dist/commands/repo-sync.js +1907 -0
  68. package/dist/commands/resource.js +527 -0
  69. package/dist/commands/skill.js +1211 -0
  70. package/dist/commands/start-disciplines.js +510 -0
  71. package/dist/commands/start.js +1343 -0
  72. package/dist/commands/target.js +309 -0
  73. package/dist/commands/version.js +42 -0
  74. package/dist/commands/view.js +1852 -0
  75. package/dist/launchers/cockpit.js +28 -0
  76. package/dist/launchers/options.js +74 -0
  77. package/dist/launchers/server.js +41 -0
  78. package/dist/lib/agent-assets/envelope.js +83 -0
  79. package/dist/lib/agent-assets/gateway.js +15 -0
  80. package/dist/lib/agent-assets/guards.js +23 -0
  81. package/dist/lib/agent-assets/hosted-discovery.js +148 -0
  82. package/dist/lib/agent-assets/hosted-package-input.js +154 -0
  83. package/dist/lib/agent-assets/legacy-pointer-migration.js +677 -0
  84. package/dist/lib/agent-assets/native-fs.js +589 -0
  85. package/dist/lib/agent-assets/package-manifest.js +324 -0
  86. package/dist/lib/agent-assets/portable-path.js +67 -0
  87. package/dist/lib/agent-assets/release-input.js +177 -0
  88. package/dist/lib/agent-assets/roots.js +45 -0
  89. package/dist/lib/agent-assets/runtime-binding-reader.js +545 -0
  90. package/dist/lib/agent-assets/runtime-targets.js +50 -0
  91. package/dist/lib/agent-assets/store-reader.js +1212 -0
  92. package/dist/lib/agent-assets/store-types.js +1 -0
  93. package/dist/lib/agent-assets/store-writer.js +1484 -0
  94. package/dist/lib/agent-assets/types.js +1 -0
  95. package/dist/lib/agent-assets/unicode-case-folding-v15-1.generated.js +1548 -0
  96. package/dist/lib/commercial-final-readiness.js +504 -0
  97. package/dist/lib/commercial-lifecycle-smoke-isolation.js +236 -0
  98. package/dist/lib/commercial-managed-postgres-docker-adapter.js +274 -0
  99. package/dist/lib/commercial-setup-readiness-adapter.js +179 -0
  100. package/dist/lib/community-client-contract.js +164 -0
  101. package/dist/lib/community-cockpit-lifecycle.js +601 -0
  102. package/dist/lib/community-command-abort.js +59 -0
  103. package/dist/lib/community-diagnostic.js +237 -0
  104. package/dist/lib/community-docker-adapter.js +498 -0
  105. package/dist/lib/community-home.js +31 -0
  106. package/dist/lib/community-instance-contract.js +148 -0
  107. package/dist/lib/community-instance-layout.js +97 -0
  108. package/dist/lib/community-lifecycle.js +1631 -0
  109. package/dist/lib/community-migration-snapshot.js +770 -0
  110. package/dist/lib/community-native-application-recovery.js +425 -0
  111. package/dist/lib/community-native-child.js +240 -0
  112. package/dist/lib/community-native-database-recovery.js +456 -0
  113. package/dist/lib/community-native-lifecycle.js +2458 -0
  114. package/dist/lib/community-native-migration.js +339 -0
  115. package/dist/lib/community-native-postgres.js +596 -0
  116. package/dist/lib/community-operation-journal.js +773 -0
  117. package/dist/lib/community-operation-lock.js +596 -0
  118. package/dist/lib/community-release-resolver.js +291 -0
  119. package/dist/lib/community-release-verifier.js +475 -0
  120. package/dist/lib/community-repo-discovery.js +252 -0
  121. package/dist/lib/community-setup-server-env.js +203 -0
  122. package/dist/lib/external-url.js +110 -0
  123. package/dist/lib/official-catalog-gateway.js +108 -0
  124. package/dist/lib/official-catalog.js +364 -0
  125. package/dist/lib/server-bootstrap.js +240 -0
  126. package/dist/lib/setup-agent-assets-bridge.js +176 -0
  127. package/dist/lib/setup-agent-assets-release.js +52 -0
  128. package/dist/lib/setup-external-postgres.js +108 -0
  129. package/dist/lib/setup-init-orchestrator.js +990 -0
  130. package/dist/lib/setup-install-guide.js +52 -0
  131. package/dist/lib/setup-installer-release.js +47 -0
  132. package/dist/lib/setup-local-postgres.js +329 -0
  133. package/dist/lib/setup-official-catalog-bridge.js +148 -0
  134. package/dist/lib/setup-readiness.js +888 -0
  135. package/dist/lib/tui-launcher.js +59 -0
  136. package/dist/main.js +150 -0
  137. package/dist/seeds/agents-md.js +54 -0
  138. package/dist/utils/agent-gateway.js +275 -0
  139. package/dist/utils/agents-md.js +281 -0
  140. package/dist/utils/api.js +255 -0
  141. package/dist/utils/chatv3-session-store.js +185 -0
  142. package/dist/utils/command.js +67 -0
  143. package/dist/utils/community-host-runtime.js +376 -0
  144. package/dist/utils/config.js +1015 -0
  145. package/dist/utils/discussion-workspace.js +552 -0
  146. package/dist/utils/experience-workspace.js +326 -0
  147. package/dist/utils/guide-paths.js +67 -0
  148. package/dist/utils/hosted-sugar.js +56 -0
  149. package/dist/utils/hosted-workspace.js +229 -0
  150. package/dist/utils/memory-workspace.js +537 -0
  151. package/dist/utils/operator-runtime.js +199 -0
  152. package/dist/utils/password-crypto.js +39 -0
  153. package/dist/utils/playbook-workspace.js +479 -0
  154. package/dist/utils/project-context.js +255 -0
  155. package/dist/utils/prompts.js +70 -0
  156. package/dist/utils/refresh-race.js +28 -0
  157. package/dist/utils/repo-config.js +109 -0
  158. package/dist/utils/repo-first-projectman.js +194 -0
  159. package/dist/utils/repo-first-storage.js +13 -0
  160. package/dist/utils/repo-first-view.js +305 -0
  161. package/dist/utils/session-guidance.js +278 -0
  162. package/dist/utils/session-state.js +137 -0
  163. package/dist/utils/table.js +39 -0
  164. package/dist/utils/transient-fs.js +49 -0
  165. package/dist/utils/workspace-root.js +1 -0
  166. package/launchers/aops-cockpit.ps1 +15 -0
  167. package/launchers/aops-cockpit.sh +16 -0
  168. package/launchers/aops-server.ps1 +15 -0
  169. package/launchers/aops-server.sh +16 -0
  170. package/native/tui/win32-x64/aops-tui.exe +0 -0
  171. package/package.json +81 -0
@@ -0,0 +1,291 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { lstatSync, readFileSync, realpathSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { verifyCommunityReleaseDescriptor, } from './community-release-verifier.js';
5
+ const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
6
+ const RAW_ORIGIN = 'https://raw.githubusercontent.com';
7
+ const PUBLIC_REPOSITORY_PATH = 'eeemzs/aops-community';
8
+ const FETCH_TIMEOUT_MS = 15_000;
9
+ const MAX_BYTES = Object.freeze({
10
+ manifest: 256 * 1024,
11
+ signature: 2 * 1024 * 1024,
12
+ compose: 1024 * 1024,
13
+ });
14
+ function fail(code, detail) {
15
+ throw new Error(detail ? `${code}:${detail}` : code);
16
+ }
17
+ function lstatBigInt(candidate, code) {
18
+ try {
19
+ return lstatSync(candidate, { bigint: true });
20
+ }
21
+ catch {
22
+ fail(code, candidate);
23
+ }
24
+ }
25
+ function canonicalPath(candidate, code) {
26
+ try {
27
+ return realpathSync.native(candidate);
28
+ }
29
+ catch {
30
+ fail(code, candidate);
31
+ }
32
+ }
33
+ function sameEntry(left, right) {
34
+ return left.dev === right.dev
35
+ && left.ino === right.ino
36
+ && left.mode === right.mode
37
+ && left.size === right.size
38
+ && left.mtimeNs === right.mtimeNs;
39
+ }
40
+ function entrySnapshot(lexicalPath, realPath, stat, bytes) {
41
+ return Object.freeze({
42
+ lexicalPath,
43
+ realPath,
44
+ device: stat.dev.toString(),
45
+ inode: stat.ino.toString(),
46
+ mode: stat.mode.toString(),
47
+ size: stat.size.toString(),
48
+ modifiedNanoseconds: stat.mtimeNs.toString(),
49
+ ...(bytes ? { sha256: `sha256:${createHash('sha256').update(bytes).digest('hex')}` } : {}),
50
+ });
51
+ }
52
+ function captureOfflineRoot(rootPath) {
53
+ const lexicalPath = path.resolve(rootPath);
54
+ const before = lstatBigInt(lexicalPath, 'community_offline_release_root_missing');
55
+ if (before.isSymbolicLink() || !before.isDirectory())
56
+ fail('community_offline_release_root_invalid', lexicalPath);
57
+ const realPath = canonicalPath(lexicalPath, 'community_offline_release_root_realpath_failed');
58
+ const after = lstatBigInt(lexicalPath, 'community_offline_release_snapshot_changed');
59
+ const physical = lstatBigInt(realPath, 'community_offline_release_snapshot_changed');
60
+ if (!sameEntry(before, after) || !sameEntry(after, physical)) {
61
+ fail('community_offline_release_snapshot_changed', lexicalPath);
62
+ }
63
+ return entrySnapshot(lexicalPath, realPath, after);
64
+ }
65
+ function isConfined(root, candidate) {
66
+ const relative = path.relative(root, candidate);
67
+ return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
68
+ }
69
+ function captureOfflineFile(options) {
70
+ const lexicalPath = path.resolve(options.filePath);
71
+ const before = lstatBigInt(lexicalPath, `${options.code}_missing`);
72
+ if (before.isSymbolicLink() || !before.isFile())
73
+ fail(`${options.code}_invalid`, lexicalPath);
74
+ if (before.size <= 0n || before.size > BigInt(options.maxBytes))
75
+ fail(`${options.code}_size_invalid`);
76
+ const realPath = canonicalPath(lexicalPath, `${options.code}_realpath_failed`);
77
+ if (!isConfined(options.root.realPath, realPath))
78
+ fail(`${options.code}_escape`, realPath);
79
+ const physical = lstatBigInt(realPath, 'community_offline_release_snapshot_changed');
80
+ if (!sameEntry(before, physical))
81
+ fail('community_offline_release_snapshot_changed', lexicalPath);
82
+ let bytes;
83
+ try {
84
+ bytes = readFileSync(realPath);
85
+ }
86
+ catch {
87
+ fail(`${options.code}_read_failed`, realPath);
88
+ }
89
+ const after = lstatBigInt(lexicalPath, 'community_offline_release_snapshot_changed');
90
+ if (!sameEntry(before, after) || bytes.byteLength !== Number(after.size)) {
91
+ fail('community_offline_release_snapshot_changed', lexicalPath);
92
+ }
93
+ let content;
94
+ try {
95
+ content = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
96
+ }
97
+ catch {
98
+ fail(`${options.code}_utf8_invalid`);
99
+ }
100
+ return { content, snapshot: entrySnapshot(lexicalPath, realPath, after, bytes) };
101
+ }
102
+ function captureOfflineReleaseSnapshot(descriptorPath) {
103
+ const lexicalManifestPath = path.resolve(descriptorPath);
104
+ if (path.basename(lexicalManifestPath) !== 'release.json') {
105
+ fail('community_offline_release_descriptor_name_invalid');
106
+ }
107
+ const root = captureOfflineRoot(path.dirname(lexicalManifestPath));
108
+ const manifest = captureOfflineFile({
109
+ filePath: lexicalManifestPath,
110
+ root,
111
+ maxBytes: MAX_BYTES.manifest,
112
+ code: 'community_offline_release_manifest',
113
+ });
114
+ const signatureBundle = captureOfflineFile({
115
+ filePath: path.join(root.lexicalPath, 'release.sigstore.json'),
116
+ root,
117
+ maxBytes: MAX_BYTES.signature,
118
+ code: 'community_offline_release_signature',
119
+ });
120
+ const compose = captureOfflineFile({
121
+ filePath: path.join(root.lexicalPath, 'compose.yaml'),
122
+ root,
123
+ maxBytes: MAX_BYTES.compose,
124
+ code: 'community_offline_release_compose',
125
+ });
126
+ return {
127
+ snapshot: Object.freeze({
128
+ root,
129
+ manifest: manifest.snapshot,
130
+ signatureBundle: signatureBundle.snapshot,
131
+ compose: compose.snapshot,
132
+ }),
133
+ manifestContent: manifest.content,
134
+ signatureBundleContent: signatureBundle.content,
135
+ composeContent: compose.content,
136
+ };
137
+ }
138
+ function assertOfflineReleaseCurrent(expected) {
139
+ let current;
140
+ try {
141
+ current = captureOfflineReleaseSnapshot(expected.manifest.lexicalPath).snapshot;
142
+ }
143
+ catch (error) {
144
+ fail('community_offline_release_snapshot_changed', error instanceof Error ? error.message : String(error));
145
+ }
146
+ if (JSON.stringify(current) !== JSON.stringify(expected))
147
+ fail('community_offline_release_snapshot_changed');
148
+ }
149
+ function exactReleaseBase(releaseVersion) {
150
+ if (!RELEASE_VERSION.test(releaseVersion))
151
+ fail('community_published_release_version_invalid');
152
+ return `${RAW_ORIGIN}/${PUBLIC_REPOSITORY_PATH}/v${releaseVersion}/release`;
153
+ }
154
+ function boundedSignal(signal) {
155
+ const timeout = AbortSignal.timeout(FETCH_TIMEOUT_MS);
156
+ return signal ? AbortSignal.any([signal, timeout]) : timeout;
157
+ }
158
+ async function readBoundedUtf8(response, maxBytes, code) {
159
+ const declared = response.headers.get('content-length');
160
+ if (declared !== null && (!/^\d+$/.test(declared) || Number(declared) > maxBytes)) {
161
+ fail(`${code}_size_invalid`);
162
+ }
163
+ if (!response.body)
164
+ fail(`${code}_body_missing`);
165
+ const reader = response.body.getReader();
166
+ const chunks = [];
167
+ let byteLength = 0;
168
+ try {
169
+ while (true) {
170
+ const result = await reader.read();
171
+ if (result.done)
172
+ break;
173
+ byteLength += result.value.byteLength;
174
+ if (byteLength > maxBytes)
175
+ fail(`${code}_size_invalid`);
176
+ chunks.push(result.value);
177
+ }
178
+ }
179
+ finally {
180
+ reader.releaseLock();
181
+ }
182
+ if (byteLength === 0)
183
+ fail(`${code}_body_empty`);
184
+ try {
185
+ return new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks.map((chunk) => Buffer.from(chunk))));
186
+ }
187
+ catch {
188
+ fail(`${code}_utf8_invalid`);
189
+ }
190
+ }
191
+ async function fetchExactText(options) {
192
+ let response;
193
+ try {
194
+ response = await options.fetcher(options.url, {
195
+ method: 'GET',
196
+ redirect: 'error',
197
+ cache: 'no-store',
198
+ headers: { accept: 'application/octet-stream, application/json;q=0.9, text/plain;q=0.8' },
199
+ signal: boundedSignal(options.signal),
200
+ });
201
+ }
202
+ catch (error) {
203
+ fail(`${options.code}_fetch_failed`, error instanceof Error ? error.message : String(error));
204
+ }
205
+ if (response.status !== 200)
206
+ fail(`${options.code}_http_status`, String(response.status));
207
+ if (response.redirected || (response.url && response.url !== options.url)) {
208
+ fail(`${options.code}_redirect_refused`);
209
+ }
210
+ return readBoundedUtf8(response, options.maxBytes, options.code);
211
+ }
212
+ export async function resolveCommunityPublishedRelease(options) {
213
+ const base = exactReleaseBase(options.releaseVersion);
214
+ const descriptorSource = Object.freeze({
215
+ kind: 'published-tag',
216
+ repository: 'https://github.com/eeemzs/aops-community',
217
+ tag: `v${options.releaseVersion}`,
218
+ manifestUrl: `${base}/release.json`,
219
+ signatureBundleUrl: `${base}/release.sigstore.json`,
220
+ composeUrl: `${base}/compose.yaml`,
221
+ });
222
+ const fetcher = options.fetcher ?? globalThis.fetch;
223
+ const manifestContent = await fetchExactText({
224
+ url: descriptorSource.manifestUrl,
225
+ maxBytes: MAX_BYTES.manifest,
226
+ code: 'community_published_release_manifest',
227
+ fetcher,
228
+ signal: options.signal,
229
+ });
230
+ const [signatureBundleContent, composeContent] = await Promise.all([
231
+ fetchExactText({
232
+ url: descriptorSource.signatureBundleUrl,
233
+ maxBytes: MAX_BYTES.signature,
234
+ code: 'community_published_release_signature',
235
+ fetcher,
236
+ signal: options.signal,
237
+ }),
238
+ fetchExactText({
239
+ url: descriptorSource.composeUrl,
240
+ maxBytes: MAX_BYTES.compose,
241
+ code: 'community_published_release_compose',
242
+ fetcher,
243
+ signal: options.signal,
244
+ }),
245
+ ]);
246
+ const verified = await verifyCommunityReleaseDescriptor({
247
+ manifestContent,
248
+ signatureBundleContent,
249
+ composeContent,
250
+ expectedReleaseVersion: options.releaseVersion,
251
+ certificateIdentity: options.certificateIdentity,
252
+ certificateOidcIssuer: options.certificateOidcIssuer,
253
+ signatureVerifier: options.signatureVerifier,
254
+ verificationMode: 'online',
255
+ });
256
+ return { ...verified, descriptorSource };
257
+ }
258
+ export async function resolveCommunityOfflineRelease(options) {
259
+ if (typeof options.descriptorPath !== 'string' || options.descriptorPath.trim() === '') {
260
+ fail('community_offline_release_descriptor_path_invalid');
261
+ }
262
+ options.signal?.throwIfAborted();
263
+ const captured = captureOfflineReleaseSnapshot(options.descriptorPath);
264
+ const verified = await verifyCommunityReleaseDescriptor({
265
+ manifestContent: captured.manifestContent,
266
+ signatureBundleContent: captured.signatureBundleContent,
267
+ composeContent: captured.composeContent,
268
+ expectedReleaseVersion: options.releaseVersion,
269
+ certificateIdentity: options.certificateIdentity,
270
+ certificateOidcIssuer: options.certificateOidcIssuer,
271
+ signatureVerifier: options.signatureVerifier,
272
+ verificationMode: 'offline',
273
+ });
274
+ options.signal?.throwIfAborted();
275
+ const assertCurrent = () => assertOfflineReleaseCurrent(captured.snapshot);
276
+ assertCurrent();
277
+ return Object.freeze({
278
+ verified,
279
+ assertCurrent,
280
+ descriptorSource: Object.freeze({
281
+ kind: 'offline-descriptor',
282
+ releaseDirectory: captured.snapshot.root.realPath,
283
+ manifestPath: captured.snapshot.manifest.realPath,
284
+ manifestSha256: captured.snapshot.manifest.sha256,
285
+ signatureBundlePath: captured.snapshot.signatureBundle.realPath,
286
+ signatureBundleSha256: captured.snapshot.signatureBundle.sha256,
287
+ composePath: captured.snapshot.compose.realPath,
288
+ composeSha256: captured.snapshot.compose.sha256,
289
+ }),
290
+ });
291
+ }