@aopslabs/aops 0.3.31 → 0.3.33
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 +11 -3
- package/aops-assets-release/aops-assets.json.gz +0 -0
- package/aops-assets-release/disciplines/build-review-chat/SKILL.md +33 -0
- package/aops-assets-release/disciplines/coordinator-loop/SKILL.md +33 -0
- package/aops-assets-release/disciplines/design-first-consensus/SKILL.md +30 -0
- package/aops-assets-release/disciplines/solo-pm-loop/SKILL.md +31 -0
- package/aops-assets-release/docs/user-guides/agentspace-user-guide.md +384 -0
- package/aops-assets-release/docs/user-guides/aops-cli-user-guide.md +2067 -0
- package/aops-assets-release/docs/user-guides/chatv3-user-guide.md +500 -0
- package/aops-assets-release/docs/user-guides/docman-user-guide.md +1009 -0
- package/aops-assets-release/docs/user-guides/projectman-user-guide.md +763 -0
- package/aops-assets-release/docs/user-guides/tasker-user-guide.md +244 -0
- package/aops-assets-release/release.json +6 -0
- package/aops-assets-release/roles/coordinator/ROLE.md +28 -0
- package/aops-assets-release/roles/implementer/ROLE.md +27 -0
- package/aops-assets-release/roles/reviewer/ROLE.md +27 -0
- package/aops-assets-release/skills/aops/SKILL.md +112 -0
- package/aops-assets-release/skills/aops-bootstrapper-authoring/SKILL.md +245 -0
- package/aops-assets-release/skills/aops-cli-agentspace/SKILL.md +186 -0
- package/aops-assets-release/skills/aops-cli-board-lifecycle/SKILL.md +64 -0
- package/aops-assets-release/skills/aops-cli-chat/SKILL.md +204 -0
- package/aops-assets-release/skills/aops-cli-collab/SKILL.md +42 -0
- package/aops-assets-release/skills/aops-cli-core/SKILL.md +219 -0
- package/aops-assets-release/skills/aops-cli-discuss/SKILL.md +172 -0
- package/aops-assets-release/skills/aops-cli-docman/SKILL.md +192 -0
- package/aops-assets-release/skills/aops-cli-fileman/SKILL.md +169 -0
- package/aops-assets-release/skills/aops-cli-mission/SKILL.md +128 -0
- package/aops-assets-release/skills/aops-cli-operator-brief/SKILL.md +67 -0
- package/aops-assets-release/skills/aops-cli-projectman/SKILL.md +235 -0
- package/aops-assets-release/skills/aops-cli-sugar-authoring/SKILL.md +188 -0
- package/aops-assets-release/skills/aops-cli-tasker/SKILL.md +108 -0
- package/aops-assets-release/skills/aops-cli-tooling-agent/SKILL.md +112 -0
- package/aops-assets-release/skills/aops-cli-view/SKILL.md +210 -0
- package/aops-assets-release/skills/aops-collaborative-work/SKILL.md +304 -0
- package/aops-assets-release/skills/aops-interactive/SKILL.md +70 -0
- package/aops-assets-release/skills/aops-loop-interactive/SKILL.md +314 -0
- package/aops-assets-release/skills/aops-working-disciplines/SKILL.md +310 -0
- package/aops-assets-release/skills/feature-retirement-flow/SKILL.md +126 -0
- package/assets/skills/aops-install/SKILL.md +18 -17
- package/dist/commands/assets.js +93 -1264
- package/dist/commands/community-server.js +27 -8
- package/dist/commands/community-setup.js +1 -2
- package/dist/commands/discuss.js +1 -1
- package/dist/commands/doc.js +88 -27
- package/dist/commands/docs.js +68 -0
- package/dist/commands/global-update.js +28 -0
- package/dist/commands/init.js +3 -1
- package/dist/commands/loop.js +6379 -0
- package/dist/commands/memory.js +2 -1
- package/dist/commands/pm/index.js +11 -9
- package/dist/commands/pm/projectman.js +33 -2
- package/dist/commands/project.js +6 -6
- package/dist/commands/prompt.js +1 -1
- package/dist/commands/repo-sync.js +92 -27
- package/dist/commands/runner.js +257 -0
- package/dist/commands/skill.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/commands/tasker.js +361 -0
- package/dist/commands/view.js +53 -9
- package/dist/lib/commercial-setup-readiness-adapter.js +0 -1
- package/dist/lib/community-migration-snapshot.js +7 -9
- package/dist/lib/community-native-database-recovery.js +5 -14
- package/dist/lib/community-native-lifecycle.js +13 -0
- package/dist/lib/setup-agent-assets-bridge.js +28 -148
- package/dist/lib/setup-agent-assets-release.js +16 -44
- package/dist/lib/setup-init-orchestrator.js +11 -15
- package/dist/lib/simple-agent-assets.js +447 -0
- package/dist/lib/user-guide-sections.js +488 -0
- package/dist/main.js +10 -2
- package/dist/seeds/agents-md.js +3 -3
- package/dist/utils/agents-md.js +1 -1
- package/dist/utils/guide-paths.js +7 -7
- package/dist/utils/hosted-workspace.js +2 -1
- package/dist/utils/repo-first-storage.js +26 -1
- package/dist/utils/session-state.js +2 -7
- package/launchers/aops-cockpit.sh +0 -0
- package/launchers/aops-server.sh +0 -0
- package/package.json +67 -35
- package/THIRD_PARTY_NOTICES +0 -16169
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/SKILL.md +0 -47
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/agentspace/SKILL.md +0 -72
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/aops-cli-core/SKILL.md +0 -110
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/chatv3/SKILL.md +0 -59
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/collaborative-work/SKILL.md +0 -81
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/discuss/SKILL.md +0 -66
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/docman/SKILL.md +0 -75
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/projectman/SKILL.md +0 -92
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/sys/SKILL.md +0 -36
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/view/SKILL.md +0 -58
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/working-disciplines/SKILL.md +0 -66
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/agent-assets.md +0 -81
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/agentspace.md +0 -183
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/aops-cli.md +0 -1108
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/aops-system.md +0 -102
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/chatv3.md +0 -113
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/docman.md +0 -223
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/projectman.md +0 -233
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/sys.md +0 -94
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/working-disciplines.md +0 -482
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/manifest.json +0 -117
- package/agent-assets-release/agent-assets/gateway/aops/SKILL.md +0 -14
- package/agent-assets-release/agent-assets/inventory.json +0 -29
- package/agent-assets-release/agent-assets/projection.json +0 -8
- package/agent-assets-release/agent-assets-release.json +0 -171
- package/agent-assets-release/agent-assets-release.sigstore.json +0 -67
- package/assets/agent-assets/core/SKILL.md +0 -47
- package/assets/agent-assets/core/references/agentspace/SKILL.md +0 -72
- package/assets/agent-assets/core/references/aops-cli-core/SKILL.md +0 -110
- package/assets/agent-assets/core/references/chatv3/SKILL.md +0 -59
- package/assets/agent-assets/core/references/collaborative-work/SKILL.md +0 -81
- package/assets/agent-assets/core/references/discuss/SKILL.md +0 -66
- package/assets/agent-assets/core/references/docman/SKILL.md +0 -75
- package/assets/agent-assets/core/references/projectman/SKILL.md +0 -92
- package/assets/agent-assets/core/references/sys/SKILL.md +0 -36
- package/assets/agent-assets/core/references/view/SKILL.md +0 -58
- package/assets/agent-assets/core/references/working-disciplines/SKILL.md +0 -66
- package/assets/agent-assets/core/user-guides/agent-assets.md +0 -81
- package/assets/agent-assets/core/user-guides/agentspace.md +0 -183
- package/assets/agent-assets/core/user-guides/aops-cli.md +0 -1108
- package/assets/agent-assets/core/user-guides/aops-system.md +0 -102
- package/assets/agent-assets/core/user-guides/chatv3.md +0 -113
- package/assets/agent-assets/core/user-guides/docman.md +0 -223
- package/assets/agent-assets/core/user-guides/projectman.md +0 -233
- package/assets/agent-assets/core/user-guides/sys.md +0 -94
- package/assets/agent-assets/core/user-guides/working-disciplines.md +0 -482
- package/assets/agent-assets/gateway/aops/SKILL.md +0 -14
- package/dist/lib/agent-assets/gateway.js +0 -15
- package/dist/lib/agent-assets/guards.js +0 -23
- package/dist/lib/agent-assets/hosted-discovery.js +0 -148
- package/dist/lib/agent-assets/hosted-package-input.js +0 -154
- package/dist/lib/agent-assets/legacy-pointer-migration.js +0 -677
- package/dist/lib/agent-assets/native-fs.js +0 -589
- package/dist/lib/agent-assets/roots.js +0 -45
- package/dist/lib/agent-assets/runtime-binding-reader.js +0 -545
- package/dist/lib/agent-assets/runtime-targets.js +0 -50
- package/dist/lib/agent-assets/store-reader.js +0 -1212
- package/dist/lib/agent-assets/store-writer.js +0 -1484
- package/native/bin/darwin-arm64/aops-agent-assets-fs +0 -0
- package/native/bin/darwin-x64/aops-agent-assets-fs +0 -0
- package/native/bin/linux-arm64/aops-agent-assets-fs +0 -0
- package/native/bin/linux-x64/aops-agent-assets-fs +0 -0
- package/native/bin/win32-x64/aops-agent-assets-fs.exe +0 -0
- package/native/manifest.json +0 -49
- package/native/qualifications/win32-x64.json +0 -23
- package/native/tui/darwin-arm64/aops-tui +0 -0
- package/native/tui/linux-x64/aops-tui +0 -0
- package/native/tui/win32-x64/aops-tui.exe +0 -0
package/dist/commands/view.js
CHANGED
|
@@ -7,7 +7,7 @@ import { readAopsRepoConfig } from '../utils/repo-config.js';
|
|
|
7
7
|
import { resolveProjectBindingContext } from '../utils/project-context.js';
|
|
8
8
|
import { invokeHostedToolWithApiState, requireApiState, unwrapHostedToolResult, } from '../utils/agent-gateway.js';
|
|
9
9
|
import { resolveRepoFirstAgentspacePaths, resolveRepoFirstProjectmanPaths, } from '../utils/repo-first-projectman.js';
|
|
10
|
-
import { resolveRepoFirstWorkspaceRelativeRoot } from '../utils/repo-first-storage.js';
|
|
10
|
+
import { resolveAopsCacheRoot, resolveRepoFirstWorkspaceRelativeRoot } from '../utils/repo-first-storage.js';
|
|
11
11
|
import { resolveHostedWorkspacePaths } from '../utils/hosted-workspace.js';
|
|
12
12
|
import { readLocalMemoryEntryFiles } from '../utils/memory-workspace.js';
|
|
13
13
|
import { readSessionStateNudges } from '../utils/session-state.js';
|
|
@@ -352,7 +352,7 @@ async function loadWorkspace(context) {
|
|
|
352
352
|
const pmPaths = resolveRepoFirstProjectmanPaths(context);
|
|
353
353
|
const agentPaths = resolveRepoFirstAgentspacePaths(context);
|
|
354
354
|
const hostedPaths = resolveHostedWorkspacePaths(context.repoRoot);
|
|
355
|
-
const docRoot = path.join(context.repoRoot, '
|
|
355
|
+
const docRoot = path.join(resolveAopsCacheRoot(context.repoRoot), 'docman');
|
|
356
356
|
const [boardsRaw, tasksRaw, sprintsRaw, issuesRaw, feedbackRaw, reviewRequestsRaw, utasksRaw, memory, discussions, experience, skills, prompts, docsRaw, sessionStateNudges,] = await Promise.all([
|
|
357
357
|
readMarkdownRecords(pmPaths.boards, { repoRoot: context.repoRoot }),
|
|
358
358
|
readMarkdownRecords(pmPaths.tasks, { repoRoot: context.repoRoot }),
|
|
@@ -461,6 +461,50 @@ function microtaskUid(microtask, phase, phaseIndex, microIndex) {
|
|
|
461
461
|
const microPos = typeof microtask.position === 'number' ? microtask.position : microIndex;
|
|
462
462
|
return `P${phasePos}M${microPos}`;
|
|
463
463
|
}
|
|
464
|
+
function phasesForSprint(workspace, sprint) {
|
|
465
|
+
const embedded = recordArray(sprint.frontmatter.phases);
|
|
466
|
+
if (embedded.length > 0)
|
|
467
|
+
return embedded;
|
|
468
|
+
const bodyPhaseOrder = new Map();
|
|
469
|
+
let pendingPhasePosition;
|
|
470
|
+
for (const line of sprint.body.split(/\r?\n/)) {
|
|
471
|
+
const heading = line.match(/^###\s+(\d+)\./);
|
|
472
|
+
if (heading) {
|
|
473
|
+
pendingPhasePosition = Number(heading[1]) - 1;
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const id = pendingPhasePosition !== undefined ? line.match(/^- ID:\s+(.+)$/) : undefined;
|
|
477
|
+
if (id) {
|
|
478
|
+
bodyPhaseOrder.set(id[1].trim(), pendingPhasePosition);
|
|
479
|
+
pendingPhasePosition = undefined;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const aliases = idAliases(sprint);
|
|
483
|
+
const matching = workspace.utasks.filter((utask) => [utask.frontmatter.sprintLocalId, utask.frontmatter.sprintId, utask.frontmatter.sprintRemoteId]
|
|
484
|
+
.some((value) => sameIdOrPrefix(value, aliases)));
|
|
485
|
+
const grouped = new Map();
|
|
486
|
+
for (const utask of matching) {
|
|
487
|
+
const phaseId = stringValue(utask.frontmatter.phaseRemoteId)
|
|
488
|
+
?? stringValue(utask.frontmatter.phaseId)
|
|
489
|
+
?? stringValue(utask.frontmatter.phaseName)
|
|
490
|
+
?? 'unassigned';
|
|
491
|
+
const phase = grouped.get(phaseId) ?? {
|
|
492
|
+
id: phaseId,
|
|
493
|
+
name: stringValue(utask.frontmatter.phaseName) ?? 'Unassigned',
|
|
494
|
+
position: bodyPhaseOrder.get(phaseId)
|
|
495
|
+
?? (typeof utask.frontmatter.phasePosition === 'number' ? utask.frontmatter.phasePosition : grouped.size),
|
|
496
|
+
microtasks: [],
|
|
497
|
+
};
|
|
498
|
+
phase.microtasks.push({ ...utask.frontmatter });
|
|
499
|
+
grouped.set(phaseId, phase);
|
|
500
|
+
}
|
|
501
|
+
return [...grouped.values()].sort((left, right) => (typeof left.position === 'number' ? left.position : Number.MAX_SAFE_INTEGER)
|
|
502
|
+
- (typeof right.position === 'number' ? right.position : Number.MAX_SAFE_INTEGER)).map((phase) => ({
|
|
503
|
+
...phase,
|
|
504
|
+
microtasks: recordArray(phase.microtasks).sort((left, right) => (typeof left.position === 'number' ? left.position : Number.MAX_SAFE_INTEGER)
|
|
505
|
+
- (typeof right.position === 'number' ? right.position : Number.MAX_SAFE_INTEGER)),
|
|
506
|
+
}));
|
|
507
|
+
}
|
|
464
508
|
function boardColumns(board) {
|
|
465
509
|
const columns = recordArray(board.frontmatter.columns);
|
|
466
510
|
if (columns.length > 0)
|
|
@@ -1203,7 +1247,7 @@ async function buildSprintView(context, options, selector) {
|
|
|
1203
1247
|
const reviewRequests = reviewRequestsForSubject(workspace, sprint);
|
|
1204
1248
|
const memory = memoryForSubject(workspace, 'projectman.sprint', sprint);
|
|
1205
1249
|
const discussions = discussionsForSubject(workspace, 'projectman.sprint', sprint);
|
|
1206
|
-
const phases =
|
|
1250
|
+
const phases = phasesForSprint(workspace, sprint);
|
|
1207
1251
|
const microtaskRows = phases.flatMap((phase, phaseIndex) => recordArray(phase.microtasks).map((microtask, microIndex) => [
|
|
1208
1252
|
microtaskUid(microtask, phase, phaseIndex, microIndex),
|
|
1209
1253
|
phase.name ?? '-',
|
|
@@ -1656,13 +1700,13 @@ export async function runViewExperience(options = {}) {
|
|
|
1656
1700
|
export async function runViewSkills(options = {}) {
|
|
1657
1701
|
await emitView('view.skills', options, async (context, viewOptions) => {
|
|
1658
1702
|
const workspace = await loadWorkspace(context);
|
|
1659
|
-
return hostedView('Hosted Skills Mirror', '.aops/hosted/skills', workspace.skills, viewOptions);
|
|
1703
|
+
return hostedView('Hosted Skills Mirror', '.aops-cache/hosted/skills', workspace.skills, viewOptions);
|
|
1660
1704
|
});
|
|
1661
1705
|
}
|
|
1662
1706
|
export async function runViewPrompts(options = {}) {
|
|
1663
1707
|
await emitView('view.prompts', options, async (context, viewOptions) => {
|
|
1664
1708
|
const workspace = await loadWorkspace(context);
|
|
1665
|
-
return hostedView('Hosted Prompts Mirror', '.aops/hosted/prompts', workspace.prompts, viewOptions);
|
|
1709
|
+
return hostedView('Hosted Prompts Mirror', '.aops-cache/hosted/prompts', workspace.prompts, viewOptions);
|
|
1666
1710
|
});
|
|
1667
1711
|
}
|
|
1668
1712
|
export async function runViewDocs(options = {}) {
|
|
@@ -1674,7 +1718,7 @@ export async function runViewDocs(options = {}) {
|
|
|
1674
1718
|
data: workspace.docs.map(materializeRecord),
|
|
1675
1719
|
},
|
|
1676
1720
|
markdown: ['# Docman Mirror Documents', '', docTable(workspace.docs, viewOptions)].join('\n'),
|
|
1677
|
-
footer: commonFooter('.aops/docman', workspace.docs),
|
|
1721
|
+
footer: commonFooter('.aops-cache/docman', workspace.docs),
|
|
1678
1722
|
};
|
|
1679
1723
|
});
|
|
1680
1724
|
}
|
|
@@ -1722,9 +1766,9 @@ Examples:
|
|
|
1722
1766
|
Notes:
|
|
1723
1767
|
Use dashboard for a first scan across boards, tasks, memory, issues, and recent discussions.
|
|
1724
1768
|
Use view digest for handoff/resume context; digest is scoped and usually cheaper than a full dashboard.
|
|
1725
|
-
Dashboard is read-only and reads local .aops/** files only.
|
|
1769
|
+
Dashboard is read-only and reads local .aops-cache/** files only.
|
|
1726
1770
|
`);
|
|
1727
|
-
addNoArg(cmd, 'boards', 'List Projectman boards from .aops/projectman', runViewBoards);
|
|
1771
|
+
addNoArg(cmd, 'boards', 'List Projectman boards from .aops-cache/projectman', runViewBoards);
|
|
1728
1772
|
addOneArg(cmd, 'board', 'Show a Projectman board with tasks and sprints', runViewBoard);
|
|
1729
1773
|
const tasksCmd = addViewOptions(cmd.command('tasks').description('List Projectman kanban tasks'))
|
|
1730
1774
|
.option('--board <selector>', 'Filter by board slug, name, id, or 8+ char prefix')
|
|
@@ -1845,7 +1889,7 @@ Examples:
|
|
|
1845
1889
|
aops-cli view digest --task <selector> --depth deep --max-bytes 32768
|
|
1846
1890
|
|
|
1847
1891
|
Notes:
|
|
1848
|
-
local-cache view commands use local .aops/** files only.
|
|
1892
|
+
local-cache view commands use local .aops-cache/** files only.
|
|
1849
1893
|
hosted view commands call read-only hosted list APIs and do not sync, mutate, or write cache files.
|
|
1850
1894
|
`);
|
|
1851
1895
|
return cmd;
|
|
@@ -126,7 +126,6 @@ export function createExistingAgentAssetsReadinessAuthority(options) {
|
|
|
126
126
|
const result = await options.provider.apply({
|
|
127
127
|
action: 'install',
|
|
128
128
|
fromRelease: options.fromRelease,
|
|
129
|
-
target: 'all',
|
|
130
129
|
});
|
|
131
130
|
if (result.availability !== 'available' || result.state !== 'ready') {
|
|
132
131
|
throw new Error('commercial_setup_agent_assets_not_ready');
|
|
@@ -435,9 +435,7 @@ async function inspectRestoreDatabases(params) {
|
|
|
435
435
|
return { main, candidate, rescue };
|
|
436
436
|
}
|
|
437
437
|
export function assertCommunityNativeRestoredSnapshotStateV1(evidence, restored) {
|
|
438
|
-
if (restored.
|
|
439
|
-
restored.migrationPlan.pendingMigrations.length !== 0 ||
|
|
440
|
-
restored.sourceFingerprintSha256 !== evidence.sourceMigrationStateFingerprintSha256 ||
|
|
438
|
+
if (restored.sourceFingerprintSha256 !== evidence.sourceMigrationStateFingerprintSha256 ||
|
|
441
439
|
restored.lineageId !== evidence.sourceLineageId ||
|
|
442
440
|
restored.schemaFingerprintSha256 !== evidence.sourceSchemaFingerprintSha256 ||
|
|
443
441
|
restored.receiptFingerprintSha256 !== evidence.sourceReceiptFingerprintSha256 ||
|
|
@@ -793,6 +791,12 @@ export async function cleanupCommunityNativeManagedRestoreRescueV1(params) {
|
|
|
793
791
|
receipt.restoredStateFingerprintSha256 !== evidenceRead.evidence.sourceStateFingerprintSha256) {
|
|
794
792
|
throw new Error('community_native_managed_restore_cleanup_receipt_mismatch');
|
|
795
793
|
}
|
|
794
|
+
const observed = await inspectRestoreDatabases({ runtime, state, candidateDatabase, rescueDatabase, signal: params.signal });
|
|
795
|
+
if (!observed.main || observed.candidate) {
|
|
796
|
+
throw new Error('community_native_managed_restore_cleanup_state_invalid');
|
|
797
|
+
}
|
|
798
|
+
if (!observed.rescue)
|
|
799
|
+
return { rescueDatabase, dropped: false };
|
|
796
800
|
const policy = readCommunityNativeMigrationPolicy(params.sourceRoot);
|
|
797
801
|
const restored = await (params.planStrictPgSchema ?? planCommunityStrictPgSchema)({
|
|
798
802
|
repoUrl: buildCommunityNativePostgresUrl(state, 'aops'),
|
|
@@ -800,12 +804,6 @@ export async function cleanupCommunityNativeManagedRestoreRescueV1(params) {
|
|
|
800
804
|
policy,
|
|
801
805
|
});
|
|
802
806
|
assertCommunityNativeRestoredSnapshotStateV1(evidenceRead.evidence, restored);
|
|
803
|
-
const observed = await inspectRestoreDatabases({ runtime, state, candidateDatabase, rescueDatabase, signal: params.signal });
|
|
804
|
-
if (!observed.main || observed.candidate) {
|
|
805
|
-
throw new Error('community_native_managed_restore_cleanup_state_invalid');
|
|
806
|
-
}
|
|
807
|
-
if (!observed.rescue)
|
|
808
|
-
return { rescueDatabase, dropped: false };
|
|
809
807
|
await dropDatabase({ runtime, state, database: rescueDatabase, signal: params.signal });
|
|
810
808
|
return { rescueDatabase, dropped: true };
|
|
811
809
|
}
|
|
@@ -4,7 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { compareCanonicalText } from '@aopslabs/artifact-trust-contracts';
|
|
5
5
|
import { createCommunityNativeApplicationReferenceV1, readCommunityNativeApplicationUpdate, sameCommunityNativeApplicationContent, } from './community-native-application-recovery.js';
|
|
6
6
|
import { assertCommunityNativeRestoredSnapshotStateV1, cleanupCommunityNativeManagedRestoreRescueV1, readCommunityNativeSnapshotEvidenceV1, restoreCommunityNativeManagedSnapshotV1, } from './community-migration-snapshot.js';
|
|
7
|
-
import {
|
|
7
|
+
import { loadExternalPostgresUrl, } from './community-native-lifecycle.js';
|
|
8
8
|
import { planCommunityNativeMigration } from './community-native-migration.js';
|
|
9
9
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
10
10
|
const RAW_SHA256 = /^[a-f0-9]{64}$/;
|
|
@@ -243,15 +243,6 @@ function writePhase(params) {
|
|
|
243
243
|
recordedAt: params.now().toISOString(),
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
function assertPriorSource(params) {
|
|
247
|
-
const source = inspectCommunityNativeSource(params.sourceRoot);
|
|
248
|
-
const expected = params.prepared.prior.content;
|
|
249
|
-
if (source.releaseVersion !== expected.releaseVersion || source.packageSha256 !== expected.packageSha256 ||
|
|
250
|
-
source.lockfileSha256 !== expected.lockfileSha256 || source.sourceFileCount !== expected.sourceFileCount ||
|
|
251
|
-
source.sourceInventorySha256 !== expected.sourceInventorySha256) {
|
|
252
|
-
throw new Error('community_native_database_restore_prior_source_mismatch');
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
246
|
function evidenceFileName(kind, planSha256) {
|
|
256
247
|
return `${kind === 'managed-verified-backup' ? 'managed' : 'external'}-${planSha256}.json`;
|
|
257
248
|
}
|
|
@@ -274,7 +265,6 @@ export async function restoreCommunityNativeDatabaseForUpdate(params, dependenci
|
|
|
274
265
|
!update.outcome.migration.snapshotEvidenceSha256) {
|
|
275
266
|
throw new Error('community_native_database_restore_migrating_update_required');
|
|
276
267
|
}
|
|
277
|
-
assertPriorSource({ sourceRoot: params.sourceRoot, prepared: update.prepared });
|
|
278
268
|
const migration = update.outcome.migration;
|
|
279
269
|
const evidenceKind = migration.snapshotEvidenceKind;
|
|
280
270
|
const evidenceSha256 = migration.snapshotEvidenceSha256;
|
|
@@ -350,6 +340,7 @@ export async function restoreCommunityNativeDatabaseForUpdate(params, dependenci
|
|
|
350
340
|
if (!sameCommunityNativeApplicationContent(active, update.prepared.target)) {
|
|
351
341
|
throw new Error('community_native_database_restore_update_target_not_active');
|
|
352
342
|
}
|
|
343
|
+
const recoverySourceRoot = path.resolve(params.state.source.root);
|
|
353
344
|
if (evidenceRead.evidence.kind === 'external-snapshot-attestation') {
|
|
354
345
|
if (params.state.profile !== 'native-external-postgres') {
|
|
355
346
|
throw new Error('community_native_database_restore_external_profile_mismatch');
|
|
@@ -370,7 +361,7 @@ export async function restoreCommunityNativeDatabaseForUpdate(params, dependenci
|
|
|
370
361
|
}
|
|
371
362
|
const repoUrl = loadExternalPostgresUrl(params.state.postgres.configRef, params.state.postgres.tlsPolicy);
|
|
372
363
|
const planned = await (dependencies.planNativeMigration ?? planCommunityNativeMigration)({
|
|
373
|
-
sourceRoot:
|
|
364
|
+
sourceRoot: recoverySourceRoot,
|
|
374
365
|
repoUrl,
|
|
375
366
|
signal: params.signal,
|
|
376
367
|
});
|
|
@@ -408,7 +399,7 @@ export async function restoreCommunityNativeDatabaseForUpdate(params, dependenci
|
|
|
408
399
|
evidencePath: prepared.evidencePath,
|
|
409
400
|
expectedEvidenceSha256: prepared.evidenceSha256,
|
|
410
401
|
backupRoot: params.paths.backupRoot,
|
|
411
|
-
sourceRoot:
|
|
402
|
+
sourceRoot: recoverySourceRoot,
|
|
412
403
|
state: params.state.postgres,
|
|
413
404
|
instanceName: params.state.instanceName,
|
|
414
405
|
instanceRoot: params.paths.instanceRoot,
|
|
@@ -444,7 +435,7 @@ export async function restoreCommunityNativeDatabaseForUpdate(params, dependenci
|
|
|
444
435
|
evidenceRoot: params.paths.migrationEvidenceRoot,
|
|
445
436
|
evidencePath: prepared.evidencePath,
|
|
446
437
|
expectedEvidenceSha256: prepared.evidenceSha256,
|
|
447
|
-
sourceRoot:
|
|
438
|
+
sourceRoot: recoverySourceRoot,
|
|
448
439
|
state: params.state.postgres,
|
|
449
440
|
instanceName: params.state.instanceName,
|
|
450
441
|
instanceRoot: params.paths.instanceRoot,
|
|
@@ -1905,6 +1905,9 @@ export async function resolveCommunityNativeSnapshotEvidence(params) {
|
|
|
1905
1905
|
'--bundle-dir', input.bundleDirectory,
|
|
1906
1906
|
'--receipt', input.receiptPath,
|
|
1907
1907
|
'--set-id', input.backupSetId,
|
|
1908
|
+
'--policy', input.policyPath,
|
|
1909
|
+
'--inventory', input.inventoryPath,
|
|
1910
|
+
'--migrations-root', input.migrationsRoot,
|
|
1908
1911
|
], {
|
|
1909
1912
|
encoding: 'utf8',
|
|
1910
1913
|
env: { ...process.env, AOPS_PG_URL: input.repoUrl },
|
|
@@ -1944,6 +1947,13 @@ export async function resolveCommunityNativeSnapshotEvidence(params) {
|
|
|
1944
1947
|
const firstPending = params.context.planning.migrationPlan.pendingMigrations?.[0]?.tag;
|
|
1945
1948
|
const repoUrl = loadUrl(postgres);
|
|
1946
1949
|
const snapshotEntry = ownedSetSnapshotEntry(params.context.sourceRoot);
|
|
1950
|
+
const packagedSnapshotAssets = path.join(params.context.sourceRoot, 'scripts', 'community-migration-policy-package-v1.json');
|
|
1951
|
+
const snapshotPolicyPath = existsSync(packagedSnapshotAssets)
|
|
1952
|
+
? packagedSnapshotAssets
|
|
1953
|
+
: path.join(params.context.sourceRoot, 'apps', 'aops-server', 'scripts', 'community-migration-policy-v1.json');
|
|
1954
|
+
const snapshotInventoryPath = existsSync(packagedSnapshotAssets)
|
|
1955
|
+
? path.join(params.context.sourceRoot, 'scripts', 'community-domain-ownership-v1.json')
|
|
1956
|
+
: path.join(params.context.sourceRoot, 'apps', 'aops-server', 'scripts', 'community-domain-ownership-v1.json');
|
|
1947
1957
|
const bundleDirectory = path.join(params.backupRoot, `${params.instanceName}-${firstPending ? `pre-${firstPending}` : 'pre-migration'}-owned-set`);
|
|
1948
1958
|
const receiptPath = `${bundleDirectory}.receipt.json`;
|
|
1949
1959
|
const snapshot = snapshotEntry
|
|
@@ -1953,6 +1963,9 @@ export async function resolveCommunityNativeSnapshotEvidence(params) {
|
|
|
1953
1963
|
bundleDirectory,
|
|
1954
1964
|
receiptPath,
|
|
1955
1965
|
backupSetId: `${params.instanceName}-${Date.now()}`,
|
|
1966
|
+
policyPath: snapshotPolicyPath,
|
|
1967
|
+
inventoryPath: snapshotInventoryPath,
|
|
1968
|
+
migrationsRoot: params.context.sourceRoot,
|
|
1956
1969
|
})
|
|
1957
1970
|
: null;
|
|
1958
1971
|
if (snapshot) {
|
|
@@ -1,176 +1,56 @@
|
|
|
1
|
+
import { installSimpleAgentAssets, readSimpleAgentAssetsState, resolveSimpleAgentAssetsRoots, } from './simple-agent-assets.js';
|
|
2
|
+
import { resolveSetupAgentAssetsReleaseV1 } from './setup-agent-assets-release.js';
|
|
1
3
|
export const SETUP_AGENT_ASSETS_CONTRACT = Object.freeze({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
installCommand: 'aops assets install --target all --apply --json',
|
|
6
|
-
repairCommand: 'aops assets repair --repair-bindings --apply --json',
|
|
7
|
-
transitionRemovalCondition: 'Satisfied by the native TASK-136 provider composed after TASK-137; never route through setup agent-assets.',
|
|
8
|
-
});
|
|
9
|
-
export const SETUP_AGENT_ASSETS_GATEWAYS = Object.freeze({
|
|
10
|
-
codex: '<codex-home>/skills/aops/SKILL.md',
|
|
11
|
-
claude: '<claude-home>/skills/aops/SKILL.md',
|
|
4
|
+
surface: 'aops-assets-simple-v1',
|
|
5
|
+
statusCommand: 'aops assets status --json',
|
|
6
|
+
installCommand: 'aops assets install --target all --json',
|
|
12
7
|
});
|
|
13
|
-
export async function verifySetupAgentAssetsReleaseInput(verifyRelease, releaseRoot) {
|
|
14
|
-
return verifyRelease({ releaseRoot, verificationMode: 'offline' });
|
|
15
|
-
}
|
|
16
8
|
export function createSetupAgentAssetsProvider(dependencies = {}) {
|
|
17
|
-
const
|
|
18
|
-
const readStatus = dependencies.readStatus ?? readAgentAssetsStoreStatus;
|
|
19
|
-
const inspectBindings = dependencies.inspectBindings ?? inspectRuntimeGatewayBindings;
|
|
20
|
-
const verifyRelease = dependencies.verifyRelease ?? verifyAndLoadCommunityCoreReleaseInput;
|
|
21
|
-
const applyCore = dependencies.applyCore ?? applyVerifiedCommunityCore;
|
|
22
|
-
const repairBindings = dependencies.repairBindings ?? repairAgentAssetRuntimeBindings;
|
|
23
|
-
const inspectLegacyPointers = dependencies.inspectLegacyPointers ?? inspectLegacyAopsPointers;
|
|
24
|
-
const migrateLegacyPointers = dependencies.migrateLegacyPointers ?? migrateLegacyAopsPointers;
|
|
9
|
+
const getRoots = dependencies.roots ?? (() => resolveSimpleAgentAssetsRoots());
|
|
25
10
|
const resolveRelease = dependencies.resolveRelease ?? resolveSetupAgentAssetsReleaseV1;
|
|
26
11
|
const inspect = async () => {
|
|
27
|
-
const roots =
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
assetRoot: roots.assetRoot,
|
|
31
|
-
runtimeHomes: {
|
|
32
|
-
codex: roots.runtimeHomes.codex.absolutePath,
|
|
33
|
-
claude: roots.runtimeHomes.claude.absolutePath,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
const states = AGENT_ASSET_RUNTIME_IDS.map((runtime) => bindings[runtime].state);
|
|
37
|
-
const recoveryReasons = store.recoveryReasons ?? [];
|
|
38
|
-
const storeDrift = recoveryReasons.length > 0;
|
|
39
|
-
const ready = store.state === 'ready' && !storeDrift && states.every((state) => state === 'ready');
|
|
40
|
-
const conflict = states.some((state) => state === 'ownership-conflict' || state === 'unsafe-path');
|
|
12
|
+
const roots = getRoots();
|
|
13
|
+
const state = readSimpleAgentAssetsState(roots);
|
|
14
|
+
const ready = state.current !== null;
|
|
41
15
|
return Object.freeze({
|
|
42
16
|
availability: 'available',
|
|
43
|
-
state: ready ? 'ready' :
|
|
44
|
-
summary: ready
|
|
45
|
-
|
|
46
|
-
: conflict
|
|
47
|
-
? 'A global runtime gateway has an ownership or unsafe-path conflict.'
|
|
48
|
-
: store.state === 'ready' && storeDrift
|
|
49
|
-
? 'The verified AOPS core remains usable, but authenticated staging or receipt drift requires inspection.'
|
|
50
|
-
: store.state === 'ready'
|
|
51
|
-
? 'The verified AOPS core is ready, but one or more runtime bindings require repair.'
|
|
52
|
-
: 'The verified global AOPS client core is not installed.',
|
|
53
|
-
nextActions: Object.freeze(ready
|
|
54
|
-
? []
|
|
55
|
-
: conflict
|
|
56
|
-
? ['Inspect `aops assets status --verify full --json`; unknown user files are never overwritten.']
|
|
57
|
-
: store.state === 'ready' && storeDrift
|
|
58
|
-
? ['Inspect `aops assets status --verify full --json` and reconcile only the reported managed recovery state.']
|
|
59
|
-
: store.state === 'ready'
|
|
60
|
-
? ['Run `aops assets repair --repair-bindings --apply --json`.']
|
|
61
|
-
: ['Run `aops assets install --target all --apply --json`.']),
|
|
17
|
+
state: ready ? 'ready' : 'action-required',
|
|
18
|
+
summary: ready ? `AOPS asset release ${state.current} is installed.` : 'AOPS global assets are not installed yet.',
|
|
19
|
+
nextActions: Object.freeze(ready ? [] : ['Run `aops assets install --target all --json`.']),
|
|
62
20
|
data: Object.freeze({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
21
|
+
surface: SETUP_AGENT_ASSETS_CONTRACT.surface,
|
|
22
|
+
currentVersion: state.current,
|
|
23
|
+
previousVersion: state.previous,
|
|
24
|
+
storeRoot: roots.storeRoot,
|
|
25
|
+
recommendedAction: ready ? null : 'install',
|
|
68
26
|
}),
|
|
69
27
|
});
|
|
70
28
|
};
|
|
71
29
|
return Object.freeze({
|
|
72
30
|
status: inspect,
|
|
73
|
-
|
|
74
|
-
return resolveRelease(options);
|
|
75
|
-
},
|
|
31
|
+
resolveRelease,
|
|
76
32
|
async apply(options) {
|
|
77
|
-
const roots =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
claude: roots.runtimeHomes.claude.absolutePath,
|
|
82
|
-
});
|
|
83
|
-
if (options.action === 'install' || options.action === 'update') {
|
|
84
|
-
if (!options.fromRelease)
|
|
85
|
-
throw new Error('setup_init_agent_assets_release_required_for_install');
|
|
86
|
-
const release = await verifySetupAgentAssetsReleaseInput(verifyRelease, options.fromRelease);
|
|
87
|
-
const classifications = inspectLegacyPointers({ assetRoot: roots.assetRoot, runtimeHomes });
|
|
88
|
-
const conflicts = classifications.filter((item) => (item.state !== 'absent'
|
|
89
|
-
&& item.state !== 'managed-ready'
|
|
90
|
-
&& item.state !== 'recognized-legacy') || (item.state === 'recognized-legacy' && !item.eligible));
|
|
91
|
-
if (conflicts.length > 0) {
|
|
92
|
-
throw new Error(`setup_init_agent_assets_runtime_conflict:${conflicts.map((item) => `${item.runtime}:${item.state}`).join(',')}`);
|
|
93
|
-
}
|
|
94
|
-
const legacyRuntimes = new Set(classifications
|
|
95
|
-
.filter((item) => item.state === 'recognized-legacy')
|
|
96
|
-
.map((item) => item.runtime));
|
|
97
|
-
const directRuntimeHomes = Object.freeze(Object.fromEntries(target.runtimes
|
|
98
|
-
.filter((runtime) => !legacyRuntimes.has(runtime))
|
|
99
|
-
.map((runtime) => [runtime, runtimeHomes[runtime]])));
|
|
100
|
-
await applyCore({
|
|
101
|
-
assetRoot: roots.assetRoot,
|
|
102
|
-
release,
|
|
103
|
-
requestedOperation: options.action,
|
|
104
|
-
runtimeHomes: directRuntimeHomes,
|
|
105
|
-
});
|
|
106
|
-
if (legacyRuntimes.size > 0) {
|
|
107
|
-
await migrateLegacyPointers({
|
|
108
|
-
assetRoot: roots.assetRoot,
|
|
109
|
-
runtimeHomes: Object.freeze(Object.fromEntries(target.runtimes
|
|
110
|
-
.filter((runtime) => legacyRuntimes.has(runtime))
|
|
111
|
-
.map((runtime) => [runtime, runtimeHomes[runtime]]))),
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
await repairBindings({
|
|
117
|
-
assetRoot: roots.assetRoot,
|
|
118
|
-
runtimeHomes,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
33
|
+
const roots = getRoots();
|
|
34
|
+
if (!options.fromRelease)
|
|
35
|
+
throw new Error('setup_init_agent_assets_release_required_for_install');
|
|
36
|
+
installSimpleAgentAssets({ releaseRoot: options.fromRelease, roots, target: 'all' });
|
|
121
37
|
return inspect();
|
|
122
38
|
},
|
|
123
39
|
});
|
|
124
40
|
}
|
|
125
|
-
function normalizeProviderStatus(status) {
|
|
126
|
-
if (status.availability !== 'available') {
|
|
127
|
-
throw new Error('setup_agent_assets_provider_contract_invalid');
|
|
128
|
-
}
|
|
129
|
-
return Object.freeze({
|
|
130
|
-
...status,
|
|
131
|
-
nextActions: Object.freeze([...status.nextActions]),
|
|
132
|
-
data: Object.freeze({
|
|
133
|
-
...status.data,
|
|
134
|
-
surface: SETUP_AGENT_ASSETS_CONTRACT.surface,
|
|
135
|
-
gatewayDestinations: SETUP_AGENT_ASSETS_GATEWAYS,
|
|
136
|
-
legacyRepoMirrorInstallerUsed: false,
|
|
137
|
-
}),
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
41
|
export async function inspectSetupAgentAssets(provider) {
|
|
141
42
|
if (!provider) {
|
|
142
43
|
return Object.freeze({
|
|
143
44
|
availability: 'task-136-pending',
|
|
144
45
|
state: 'action-required',
|
|
145
|
-
summary: 'The
|
|
146
|
-
nextActions: Object.freeze([
|
|
147
|
-
'Complete TASK-136 on the TASK-137 merge base, then run `aops assets status --verify quick --json`.',
|
|
148
|
-
]),
|
|
149
|
-
data: Object.freeze({
|
|
150
|
-
task: SETUP_AGENT_ASSETS_CONTRACT.task,
|
|
151
|
-
surface: SETUP_AGENT_ASSETS_CONTRACT.surface,
|
|
152
|
-
gatewayDestinations: SETUP_AGENT_ASSETS_GATEWAYS,
|
|
153
|
-
legacyRepoMirrorInstallerUsed: false,
|
|
154
|
-
transitionRemovalCondition: SETUP_AGENT_ASSETS_CONTRACT.transitionRemovalCondition,
|
|
155
|
-
}),
|
|
46
|
+
summary: 'The AOPS assets provider is unavailable.',
|
|
47
|
+
nextActions: Object.freeze(['Install the official AOPS CLI package.']),
|
|
156
48
|
});
|
|
157
49
|
}
|
|
158
|
-
return
|
|
50
|
+
return provider.status();
|
|
159
51
|
}
|
|
160
52
|
export async function applySetupAgentAssets(provider, options) {
|
|
161
|
-
if (!provider?.apply)
|
|
162
|
-
throw new Error('
|
|
163
|
-
|
|
164
|
-
return normalizeProviderStatus(await provider.apply({
|
|
165
|
-
...options,
|
|
166
|
-
target: 'all',
|
|
167
|
-
}));
|
|
53
|
+
if (!provider?.apply)
|
|
54
|
+
throw new Error('setup_init_agent_assets_provider_unavailable');
|
|
55
|
+
return provider.apply(options);
|
|
168
56
|
}
|
|
169
|
-
import { verifyAndLoadCommunityCoreReleaseInput } from './agent-assets/release-input.js';
|
|
170
|
-
import { resolveAgentAssetsRoots } from './agent-assets/roots.js';
|
|
171
|
-
import { inspectRuntimeGatewayBindings } from './agent-assets/runtime-binding-reader.js';
|
|
172
|
-
import { readAgentAssetsStoreStatus } from './agent-assets/store-reader.js';
|
|
173
|
-
import { applyVerifiedCommunityCore, repairAgentAssetRuntimeBindings, } from './agent-assets/store-writer.js';
|
|
174
|
-
import { inspectLegacyAopsPointers, migrateLegacyAopsPointers, } from './agent-assets/legacy-pointer-migration.js';
|
|
175
|
-
import { resolveSetupAgentAssetsReleaseV1 } from './setup-agent-assets-release.js';
|
|
176
|
-
import { AGENT_ASSET_RUNTIME_IDS, resolveAgentAssetTargetSelection, selectAgentAssetRuntimeHomes, } from './agent-assets/runtime-targets.js';
|
|
@@ -1,58 +1,30 @@
|
|
|
1
|
-
import { lstatSync
|
|
1
|
+
import { lstatSync } from 'node:fs';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import {
|
|
5
|
-
import { AgentAssetsError } from './agent-assets/envelope.js';
|
|
6
|
-
function localAgentAssetsReleaseRoot(candidate) {
|
|
7
|
-
if (!candidate)
|
|
8
|
-
return undefined;
|
|
9
|
-
const releaseRoot = path.resolve(candidate);
|
|
10
|
-
try {
|
|
11
|
-
const root = lstatSync(releaseRoot);
|
|
12
|
-
if (!root.isDirectory() || root.isSymbolicLink())
|
|
13
|
-
return undefined;
|
|
14
|
-
for (const name of ['agent-assets-release.json', 'agent-assets-release.sigstore.json']) {
|
|
15
|
-
const entry = lstatSync(path.join(releaseRoot, name));
|
|
16
|
-
if (!entry.isFile() || entry.isSymbolicLink())
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const assets = lstatSync(path.join(releaseRoot, 'agent-assets'));
|
|
20
|
-
if (!assets.isDirectory() || assets.isSymbolicLink())
|
|
21
|
-
return undefined;
|
|
22
|
-
return realpathSync.native(releaseRoot);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
4
|
+
import { loadSimpleAgentAssetsRelease } from './simple-agent-assets.js';
|
|
28
5
|
function defaultBundledCandidates() {
|
|
29
6
|
const moduleDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
30
7
|
return Object.freeze([
|
|
31
|
-
path.resolve(moduleDirectory, '..', '
|
|
32
|
-
path.resolve(moduleDirectory, '..', '
|
|
8
|
+
path.resolve(moduleDirectory, '..', '..', 'aops-assets-release'),
|
|
9
|
+
path.resolve(moduleDirectory, '..', 'aops-assets-release'),
|
|
33
10
|
]);
|
|
34
11
|
}
|
|
35
12
|
export function resolveBundledAgentAssetsReleaseV1(dependencies = {}) {
|
|
36
13
|
for (const candidate of (dependencies.bundledCandidates ?? defaultBundledCandidates)()) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
14
|
+
try {
|
|
15
|
+
if (!lstatSync(candidate).isDirectory())
|
|
16
|
+
continue;
|
|
17
|
+
loadSimpleAgentAssetsRelease(candidate);
|
|
18
|
+
return Object.freeze({ fromRelease: path.resolve(candidate), source: 'bundled-npm' });
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
}
|
|
40
22
|
}
|
|
41
23
|
return undefined;
|
|
42
24
|
}
|
|
43
|
-
export async function resolveSetupAgentAssetsReleaseV1(
|
|
25
|
+
export async function resolveSetupAgentAssetsReleaseV1(_options = {}, dependencies = {}) {
|
|
44
26
|
const bundled = resolveBundledAgentAssetsReleaseV1(dependencies);
|
|
45
|
-
if (bundled)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return await (dependencies.fallback ?? resolveSetupOfficialCatalogReleaseV1)(options);
|
|
49
|
-
}
|
|
50
|
-
catch (cause) {
|
|
51
|
-
throw new AgentAssetsError('verified_source_unavailable', 'agent_assets_verified_source_unavailable:reinstall_the_official_aops_cli_package_or_use_--from-release_as_an_offline_override', {
|
|
52
|
-
nextActions: [
|
|
53
|
-
'Reinstall the official AOPS CLI package or retry with `--from-release` pointing to an exact signed release bundle.',
|
|
54
|
-
],
|
|
55
|
-
cause,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
27
|
+
if (!bundled)
|
|
28
|
+
throw new Error('aops_assets_bundled_release_missing');
|
|
29
|
+
return bundled;
|
|
58
30
|
}
|
|
@@ -82,7 +82,6 @@ function createSetupInstallerPlan(options, selectedPath, security, readiness, ef
|
|
|
82
82
|
targetAuthProvider: options.targetAuthProvider ?? null,
|
|
83
83
|
targetTlsPolicy: options.targetTlsPolicy ?? null,
|
|
84
84
|
agentAssets: normalizeAgentAssetsAction(options.agentAssets) ?? null,
|
|
85
|
-
agentAssetsRelease: options.agentAssetsRelease ? path.resolve(options.agentAssetsRelease) : null,
|
|
86
85
|
noCatalog: options.noCatalog === true,
|
|
87
86
|
catalogRelease: options.catalogRelease ? path.resolve(options.catalogRelease) : null,
|
|
88
87
|
catalogIdempotencyKey: normalizeNonEmpty(options.catalogIdempotencyKey) ?? null,
|
|
@@ -177,10 +176,10 @@ function normalizeAgentAssetsAction(value) {
|
|
|
177
176
|
const normalized = normalizeNonEmpty(value)?.toLowerCase();
|
|
178
177
|
if (!normalized)
|
|
179
178
|
return undefined;
|
|
180
|
-
if (normalized === 'status' || normalized === 'install' || normalized === '
|
|
179
|
+
if (normalized === 'status' || normalized === 'install' || normalized === 'skip') {
|
|
181
180
|
return normalized;
|
|
182
181
|
}
|
|
183
|
-
throw new Error('setup_init_agent_assets_action_invalid:
|
|
182
|
+
throw new Error('setup_init_agent_assets_action_invalid:choose_status_install_or_skip');
|
|
184
183
|
}
|
|
185
184
|
function resolveAgentAssetsReleasePath(value) {
|
|
186
185
|
const normalized = normalizeNonEmpty(value);
|
|
@@ -361,7 +360,7 @@ export async function runSetupInitOrchestrator(options = {}, dependencies = {})
|
|
|
361
360
|
}
|
|
362
361
|
await dependencies.assertInstallerReleaseCurrent(dependencies.installerRelease);
|
|
363
362
|
}
|
|
364
|
-
if (
|
|
363
|
+
if (requestedAgentAssetsAction === 'install' &&
|
|
365
364
|
!dependencies.agentAssets?.apply) {
|
|
366
365
|
throw new Error('setup_init_agent_assets_contract_unavailable_task_136');
|
|
367
366
|
}
|
|
@@ -375,10 +374,10 @@ export async function runSetupInitOrchestrator(options = {}, dependencies = {})
|
|
|
375
374
|
let officialCatalogRelease;
|
|
376
375
|
let officialCatalogReleaseSource;
|
|
377
376
|
if (localServerPath && !options.noCatalog && dependencies.officialCatalog) {
|
|
378
|
-
const selectedRelease = options.catalogRelease
|
|
377
|
+
const selectedRelease = options.catalogRelease;
|
|
379
378
|
if (normalizeNonEmpty(selectedRelease)) {
|
|
380
379
|
officialCatalogRelease = resolveOfficialCatalogReleasePath(selectedRelease);
|
|
381
|
-
officialCatalogReleaseSource =
|
|
380
|
+
officialCatalogReleaseSource = 'explicit-catalog-release';
|
|
382
381
|
}
|
|
383
382
|
else {
|
|
384
383
|
const resolution = await dependencies.officialCatalog.resolveRelease({
|
|
@@ -734,15 +733,14 @@ export async function runSetupInitOrchestrator(options = {}, dependencies = {})
|
|
|
734
733
|
agentAssetsAction = 'skip';
|
|
735
734
|
}
|
|
736
735
|
else if (!agentAssetsAction && dependencies.agentAssets?.apply) {
|
|
737
|
-
|
|
738
|
-
agentAssetsAction = recommendedAction;
|
|
736
|
+
agentAssetsAction = 'install';
|
|
739
737
|
}
|
|
740
|
-
if (agentAssetsAction === 'install'
|
|
738
|
+
if (agentAssetsAction === 'install') {
|
|
741
739
|
if (!dependencies.agentAssets?.apply) {
|
|
742
740
|
throw new Error('setup_init_agent_assets_contract_unavailable_task_136');
|
|
743
741
|
}
|
|
744
|
-
let fromRelease
|
|
745
|
-
if (agentAssetsAction === 'install' &&
|
|
742
|
+
let fromRelease;
|
|
743
|
+
if (agentAssetsAction === 'install' && dependencies.agentAssets.resolveRelease) {
|
|
746
744
|
const resolution = await dependencies.agentAssets.resolveRelease({
|
|
747
745
|
sourceRoot: options.sourceRoot,
|
|
748
746
|
instance: options.instance,
|
|
@@ -750,11 +748,9 @@ export async function runSetupInitOrchestrator(options = {}, dependencies = {})
|
|
|
750
748
|
});
|
|
751
749
|
fromRelease = resolution.fromRelease;
|
|
752
750
|
}
|
|
753
|
-
const appliedAssets = await progress('Installing global AOPS
|
|
751
|
+
const appliedAssets = await progress('Installing global AOPS skills...', () => applySetupAgentAssets(dependencies.agentAssets, {
|
|
754
752
|
action: agentAssetsAction,
|
|
755
|
-
fromRelease:
|
|
756
|
-
? resolveAgentAssetsReleasePath(fromRelease)
|
|
757
|
-
: undefined,
|
|
753
|
+
fromRelease: resolveAgentAssetsReleasePath(fromRelease),
|
|
758
754
|
}));
|
|
759
755
|
steps.push({ action: `assets.${agentAssetsAction}`, status: appliedAssets.state, target: 'all' });
|
|
760
756
|
result = await inspect();
|