@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,237 @@
1
+ const SAFE_CODE = /^[a-z][a-z0-9_]{2,127}$/;
2
+ const SAFE_SQLSTATE = /^[0-9A-Z]{5}$/;
3
+ const MAX_TEXT_LENGTH = 1_000;
4
+ function redacted(value) {
5
+ return value
6
+ .replace(/postgres(?:ql)?:\/\/[^\s"'`]+/gi, 'postgresql://[REDACTED]')
7
+ .replace(/((?:password|passwd|secret|token|api[_-]?key|authorization)\s*[=:]\s*)[^\s,;]+/gi, '$1[REDACTED]')
8
+ .replace(/(--(?:password|passwd|secret|token|api[_-]?key)\s+)[^\s]+/gi, '$1[REDACTED]')
9
+ .replace(/(\bBearer\s+)[A-Za-z0-9._~+/-]+/gi, '$1[REDACTED]')
10
+ .replace(/("(?:password|passwd|secret|token|apiKey|authorization)"\s*:\s*")[^"]*(")/gi, '$1[REDACTED]$2')
11
+ .slice(0, MAX_TEXT_LENGTH);
12
+ }
13
+ function errorRecord(error) {
14
+ return error && typeof error === 'object' && !Array.isArray(error)
15
+ ? error
16
+ : {};
17
+ }
18
+ function messageCode(error) {
19
+ const message = error instanceof Error ? error.message : String(error ?? '');
20
+ const matched = /\b(?:aops|community|postgres|setup)_[a-z0-9_]+\b/i.exec(message)?.[0]?.toLowerCase();
21
+ return matched && SAFE_CODE.test(matched) ? matched : undefined;
22
+ }
23
+ function safeCauseCode(error, fallback) {
24
+ const record = errorRecord(error);
25
+ const explicit = String(record.code ?? '').toUpperCase();
26
+ if (SAFE_SQLSTATE.test(explicit))
27
+ return explicit;
28
+ return messageCode(error) ?? fallback;
29
+ }
30
+ function categoryFor(code) {
31
+ if (SAFE_SQLSTATE.test(code) || /postgres|pg_|database|sql/.test(code))
32
+ return 'postgresql';
33
+ if (/history_receipt|receipt_identity|intent_not_reconciled|local_state|journal/.test(code))
34
+ return 'local-state';
35
+ if (/migration|schema|lineage|receipt/.test(code))
36
+ return 'migration';
37
+ if (/config|policy|env|tls/.test(code))
38
+ return 'configuration';
39
+ if (/runtime|server|process|health|source_drift|build(?:_identity)?_drift/.test(code))
40
+ return 'runtime';
41
+ return 'unknown';
42
+ }
43
+ function inferredPhase(code, fallback) {
44
+ if (/connection|connect|auth|unreachable|tls/.test(code) || SAFE_SQLSTATE.test(code))
45
+ return 'connect';
46
+ if (/history_receipt|receipt_identity|intent_not_reconciled|state_missing/.test(code))
47
+ return 'persist-local-state';
48
+ if (/lineage|schema|catalog|receipt_(?:count|mismatch|missing)/.test(code))
49
+ return 'inspect-schema';
50
+ if (/plan/.test(code))
51
+ return 'plan';
52
+ if (/snapshot|backup/.test(code))
53
+ return 'snapshot';
54
+ if (/post_commit|final_|verification|verify/.test(code))
55
+ return 'verify';
56
+ if (/source_drift|build(?:_identity)?_drift/.test(code))
57
+ return 'verify';
58
+ if (/migration|apply/.test(code))
59
+ return 'apply';
60
+ if (/start|health|process/.test(code))
61
+ return 'start-server';
62
+ return fallback;
63
+ }
64
+ function guidance(code) {
65
+ if (/community_native_(?:prior_application_)?(?:source|build(?:_identity)?)_drift/.test(code)) {
66
+ return {
67
+ summary: 'The installed npm server package no longer matches the source or build fingerprint AOPS previously verified.',
68
+ nextActions: Object.freeze([
69
+ 'Reinstall the matching public `@aopslabs/aops` and `@aopslabs/aops-server` packages separately.',
70
+ 'Re-run `aops setup init` for the selected path after the verified package bytes have been restored.',
71
+ ]),
72
+ };
73
+ }
74
+ if (/history_receipt|receipt_identity|intent_not_reconciled/.test(code)) {
75
+ return {
76
+ summary: 'Local migration bookkeeping disagrees with the current installation, not necessarily with PostgreSQL.',
77
+ nextActions: Object.freeze([
78
+ 'Re-run `aops setup init` for the selected path so AOPS can inspect the connected database again.',
79
+ 'Do not reset the operator-owned PostgreSQL database for a local receipt or identity mismatch.',
80
+ ]),
81
+ };
82
+ }
83
+ if (/lineage_unknown|schema_mismatch|receipt_(?:count|mismatch|missing)|tables_partial/.test(code)) {
84
+ return {
85
+ summary: 'The connected PostgreSQL schema could not be matched to the expected AOPS-owned structure.',
86
+ nextActions: Object.freeze([
87
+ 'Inspect the reported AOPS-owned table, column, key, index, or constraint differences.',
88
+ 'Correct only the reported structural conflict, then re-run `aops setup init`; do not delete operator-owned data.',
89
+ ]),
90
+ };
91
+ }
92
+ if (/connection|connect|auth|unreachable|tls/.test(code) || SAFE_SQLSTATE.test(code)) {
93
+ return {
94
+ summary: 'AOPS could not complete the PostgreSQL connection step.',
95
+ nextActions: Object.freeze([
96
+ 'Verify the selected private PostgreSQL configuration and TLS policy, then retry setup.',
97
+ ]),
98
+ };
99
+ }
100
+ return {
101
+ summary: 'AOPS could not complete the current setup step.',
102
+ nextActions: Object.freeze([
103
+ 'Review the diagnostic phase and cause code, then retry the same setup path after correcting that condition.',
104
+ ]),
105
+ };
106
+ }
107
+ function safeDetails(details, error) {
108
+ const output = {};
109
+ for (const [key, raw] of Object.entries(details ?? {})) {
110
+ if (!/^[a-z][a-zA-Z0-9]{0,63}$/.test(key))
111
+ continue;
112
+ if (typeof raw === 'string')
113
+ output[key] = redacted(raw);
114
+ else if (typeof raw === 'number' && Number.isFinite(raw))
115
+ output[key] = raw;
116
+ else if (typeof raw === 'boolean' || raw === null)
117
+ output[key] = raw;
118
+ else if (Array.isArray(raw) && raw.every((entry) => typeof entry === 'string')) {
119
+ output[key] = Object.freeze(raw.slice(0, 100).map((entry) => redacted(entry)));
120
+ }
121
+ }
122
+ const sqlState = String(errorRecord(error).code ?? '').toUpperCase();
123
+ if (SAFE_SQLSTATE.test(sqlState))
124
+ output.sqlState = sqlState;
125
+ const message = error instanceof Error ? error.message : String(error ?? '');
126
+ const semanticPrefix = 'community_strict_semantic_schema_mismatch:';
127
+ if (message.startsWith(semanticPrefix)) {
128
+ try {
129
+ const parsed = JSON.parse(message.slice(semanticPrefix.length));
130
+ if (Number.isSafeInteger(parsed.differenceCount) && Number(parsed.differenceCount) >= 0) {
131
+ output.differenceCount = Number(parsed.differenceCount);
132
+ }
133
+ if (typeof parsed.truncated === 'boolean')
134
+ output.differencesTruncated = parsed.truncated;
135
+ if (Array.isArray(parsed.differences)) {
136
+ const schemaDifferences = parsed.differences.slice(0, 64).flatMap((candidate) => {
137
+ if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate))
138
+ return [];
139
+ const row = candidate;
140
+ const section = String(row.section ?? '');
141
+ const kind = String(row.kind ?? '');
142
+ const key = String(row.key ?? '');
143
+ const fields = Array.isArray(row.changedFields) &&
144
+ row.changedFields.every((field) => typeof field === 'string')
145
+ ? row.changedFields.join(',')
146
+ : '';
147
+ if (!['relations', 'columns', 'constraints', 'indexes'].includes(section) ||
148
+ !['missing', 'unexpected', 'changed'].includes(kind) || key.length < 1)
149
+ return [];
150
+ return [redacted(`${section} ${kind} ${key}${fields ? ` fields=${fields}` : ''}`)];
151
+ });
152
+ if (schemaDifferences.length > 0)
153
+ output.schemaDifferences = Object.freeze(schemaDifferences);
154
+ }
155
+ }
156
+ catch {
157
+ }
158
+ }
159
+ return Object.freeze(output);
160
+ }
161
+ export function createCommunityDiagnostic(error, defaults = {}) {
162
+ if (error instanceof CommunityDiagnosticError)
163
+ return error.diagnostic;
164
+ const fallbackCode = defaults.code && SAFE_CODE.test(defaults.code)
165
+ ? defaults.code
166
+ : 'community_operation_failed';
167
+ const causeCode = safeCauseCode(error, fallbackCode);
168
+ const inferred = guidance(causeCode);
169
+ return Object.freeze({
170
+ schemaVersion: 1,
171
+ code: fallbackCode === 'community_operation_failed' ? causeCode : fallbackCode,
172
+ phase: inferredPhase(causeCode, defaults.phase ?? 'unknown'),
173
+ summary: redacted(defaults.summary ?? inferred.summary),
174
+ cause: Object.freeze({ code: causeCode, category: categoryFor(causeCode) }),
175
+ nextActions: Object.freeze((defaults.nextActions ?? inferred.nextActions).map((action) => redacted(action))),
176
+ details: safeDetails(defaults.details, error),
177
+ });
178
+ }
179
+ export function formatCommunityDiagnostic(diagnostic) {
180
+ const lines = [
181
+ diagnostic.code,
182
+ `Stage: ${diagnostic.phase}`,
183
+ `Cause: ${diagnostic.cause.code}`,
184
+ `Reason: ${diagnostic.summary}`,
185
+ ];
186
+ for (const [key, value] of Object.entries(diagnostic.details)) {
187
+ if (Array.isArray(value)) {
188
+ for (const item of value)
189
+ lines.push(`Detail: ${key}: ${item}`);
190
+ }
191
+ else {
192
+ lines.push(`Detail: ${key}: ${String(value)}`);
193
+ }
194
+ }
195
+ for (const action of diagnostic.nextActions)
196
+ lines.push(`Next: ${action}`);
197
+ return lines.join('\n');
198
+ }
199
+ export class CommunityDiagnosticError extends Error {
200
+ diagnostic;
201
+ constructor(diagnostic, options) {
202
+ super(formatCommunityDiagnostic(diagnostic), options);
203
+ this.name = 'CommunityDiagnosticError';
204
+ this.diagnostic = diagnostic;
205
+ }
206
+ }
207
+ export function isCommunityDiagnosticV1(value) {
208
+ if (!value || typeof value !== 'object' || Array.isArray(value))
209
+ return false;
210
+ const candidate = value;
211
+ const causeCategories = ['configuration', 'postgresql', 'migration', 'local-state', 'runtime', 'unknown'];
212
+ const safeText = (text) => typeof text === 'string' && text.length > 0 &&
213
+ text.length <= MAX_TEXT_LENGTH && redacted(text) === text;
214
+ const details = candidate.details && typeof candidate.details === 'object' && !Array.isArray(candidate.details)
215
+ ? Object.entries(candidate.details)
216
+ : null;
217
+ return candidate.schemaVersion === 1 && typeof candidate.code === 'string' && SAFE_CODE.test(candidate.code) &&
218
+ typeof candidate.phase === 'string' &&
219
+ ['configuration', 'connect', 'inspect-schema', 'plan', 'snapshot', 'apply', 'verify',
220
+ 'persist-local-state', 'start-server', 'readiness', 'operation', 'unknown'].includes(candidate.phase) &&
221
+ safeText(candidate.summary) && Boolean(candidate.cause) && typeof candidate.cause?.code === 'string' &&
222
+ (SAFE_CODE.test(candidate.cause.code) || SAFE_SQLSTATE.test(candidate.cause.code)) &&
223
+ typeof candidate.cause?.category === 'string' && causeCategories.includes(candidate.cause.category) &&
224
+ Array.isArray(candidate.nextActions) && candidate.nextActions.length > 0 && candidate.nextActions.length <= 8 &&
225
+ candidate.nextActions.every(safeText) && details !== null && details.length <= 64 &&
226
+ details.every(([key, detail]) => /^[a-z][a-zA-Z0-9]{0,63}$/.test(key) && (detail === null || typeof detail === 'boolean' ||
227
+ (typeof detail === 'number' && Number.isFinite(detail)) || safeText(detail) ||
228
+ (Array.isArray(detail) && detail.length <= 100 && detail.every(safeText))));
229
+ }
230
+ export function asCommunityDiagnosticError(error, defaults = {}) {
231
+ if (error instanceof CommunityDiagnosticError)
232
+ return error;
233
+ return new CommunityDiagnosticError(createCommunityDiagnostic(error, defaults), { cause: error });
234
+ }
235
+ export function redactCommunityDiagnosticText(value) {
236
+ return redacted(String(value ?? ''));
237
+ }