anhedral 0.15.0 → 0.16.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.
- package/README.md +29 -38
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/UPSTREAM.json +7 -1
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/assets/ui/native/_controls.tsx +521 -0
- package/assets/ui/native/_core.tsx +118 -0
- package/assets/ui/native/_data.tsx +200 -0
- package/assets/ui/native/_display.tsx +453 -0
- package/assets/ui/native/_feedback.tsx +242 -0
- package/assets/ui/native/_legacy-dialog.tsx +38 -0
- package/assets/ui/native/_motion.tsx +520 -0
- package/assets/ui/native/_overlay.tsx +402 -0
- package/assets/ui/native/_selection.tsx +366 -0
- package/assets/ui/native/accordion.tsx +1 -0
- package/assets/ui/native/alert-dialog.tsx +11 -0
- package/assets/ui/native/alert.tsx +1 -0
- package/assets/ui/native/aspect-ratio.tsx +1 -0
- package/assets/ui/native/attachment.tsx +8 -0
- package/assets/ui/native/avatar.tsx +8 -0
- package/assets/ui/native/badge.tsx +1 -0
- package/assets/ui/native/breadcrumb.tsx +9 -0
- package/assets/ui/native/bubble.tsx +1 -0
- package/assets/ui/native/button-group.tsx +1 -0
- package/assets/ui/native/button.tsx +2 -1
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +16 -5
- package/assets/ui/native/carousel.tsx +1 -0
- package/assets/ui/native/chart.tsx +193 -0
- package/assets/ui/native/checkbox.tsx +1 -0
- package/assets/ui/native/code-block.tsx +137 -0
- package/assets/ui/native/collapsible.tsx +1 -0
- package/assets/ui/native/combobox.tsx +1 -0
- package/assets/ui/native/command.tsx +11 -0
- package/assets/ui/native/context-menu.tsx +16 -0
- package/assets/ui/native/data-table.tsx +1 -0
- package/assets/ui/native/date-picker.tsx +43 -0
- package/assets/ui/native/dialog.tsx +14 -74
- package/assets/ui/native/direction.tsx +1 -0
- package/assets/ui/native/drawer.tsx +10 -0
- package/assets/ui/native/dropdown-menu.tsx +16 -0
- package/assets/ui/native/empty.tsx +8 -0
- package/assets/ui/native/field.tsx +13 -0
- package/assets/ui/native/hover-card.tsx +1 -0
- package/assets/ui/native/input-group.tsx +8 -0
- package/assets/ui/native/input-otp.tsx +1 -0
- package/assets/ui/native/input.tsx +2 -1
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -0
- package/assets/ui/native/marker.tsx +1 -0
- package/assets/ui/native/menubar.tsx +17 -0
- package/assets/ui/native/message-scroller.tsx +6 -0
- package/assets/ui/native/message.tsx +10 -0
- package/assets/ui/native/native-select.tsx +1 -0
- package/assets/ui/native/navigation-menu.tsx +10 -0
- package/assets/ui/native/pagination.tsx +9 -0
- package/assets/ui/native/popover.tsx +1 -0
- package/assets/ui/native/progress.tsx +1 -0
- package/assets/ui/native/questionnaire.tsx +130 -0
- package/assets/ui/native/radio-group.tsx +1 -0
- package/assets/ui/native/registry.json +1103 -0
- package/assets/ui/native/resizable.tsx +1 -0
- package/assets/ui/native/scroll-area.tsx +1 -0
- package/assets/ui/native/select.tsx +11 -0
- package/assets/ui/native/separator.tsx +1 -0
- package/assets/ui/native/sheet.tsx +10 -0
- package/assets/ui/native/sidebar.tsx +22 -0
- package/assets/ui/native/skeleton.tsx +1 -0
- package/assets/ui/native/slider.tsx +1 -0
- package/assets/ui/native/spinner.tsx +1 -0
- package/assets/ui/native/switch.tsx +1 -0
- package/assets/ui/native/table.tsx +10 -0
- package/assets/ui/native/tabs.tsx +1 -0
- package/assets/ui/native/textarea.tsx +1 -0
- package/assets/ui/native/toast.tsx +11 -0
- package/assets/ui/native/toggle-group.tsx +1 -0
- package/assets/ui/native/toggle.tsx +1 -0
- package/assets/ui/native/tooltip.tsx +1 -0
- package/assets/ui/native/trace.tsx +20 -0
- package/assets/ui/native/typography.tsx +15 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -66
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +39 -322
- package/dist/dependencies.d.ts +29 -6
- package/dist/dependencies.js +61 -14
- package/dist/index.d.ts +1 -42
- package/dist/index.js +1 -27
- package/dist/platforms/mobile.js +1 -20
- package/dist/platforms/web.d.ts +1 -1
- package/dist/platforms/web.js +27 -75
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -82
- package/dist/registry/options.js +1 -5
- package/dist/registry/resolve.d.ts +1 -1
- package/dist/registry/resolve.js +2 -10
- package/dist/registry/usage.js +3 -9
- package/dist/scaffold/backend.js +0 -3
- package/dist/scaffold/database.js +2 -1
- package/dist/scaffold/documentation.js +82 -20
- package/dist/scaffold/expo-runtime.js +3 -4
- package/dist/scaffold/native-ui.js +12 -7
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/workspace.js +26 -21
- package/dist/stack-registry.d.ts +2 -8
- package/dist/stack-registry.js +11 -87
- package/dist/standard.js +1 -11
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +4 -20
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -44
- package/docs/stack-standard.md +11 -60
- package/docs/ui.md +33 -0
- package/docs/verification.md +191 -0
- package/package.json +19 -18
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -129
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -112
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -157
- package/dist/delivery.d.ts +0 -82
- package/dist/delivery.js +0 -489
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -12
- package/dist/integration-service-readers.js +0 -92
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -370
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -671
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -47
- package/dist/project-state.js +0 -480
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -180
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -85
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -103
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -136
- package/dist/providers/definitions.d.ts +0 -115
- package/dist/providers/definitions.js +0 -42
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -56
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -52
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -234
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -283
- package/dist/provision.d.ts +0 -47
- package/dist/provision.js +0 -208
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -117
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -210
- package/dist/registry/bootstrap.d.ts +0 -3
- package/dist/registry/bootstrap.js +0 -5
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -83
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -2
- package/dist/scaffold/auth.js +0 -76
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -208
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -203
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -257
- package/dist/scaffold/integrations.d.ts +0 -2
- package/dist/scaffold/integrations.js +0 -11
- package/dist/scaffold/managed-email.d.ts +0 -3
- package/dist/scaffold/managed-email.js +0 -47
- package/dist/scaffold/password-reset.d.ts +0 -1
- package/dist/scaffold/password-reset.js +0 -99
- package/dist/scaffold/private-files.d.ts +0 -2
- package/dist/scaffold/private-files.js +0 -78
- package/dist/scaffold/web-billing.d.ts +0 -2
- package/dist/scaffold/web-billing.js +0 -48
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -71
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -48
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -216
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -96
- package/dist/ship.d.ts +0 -35
- package/dist/ship.js +0 -107
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
package/dist/project-catalog.js
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { existsSync, lstatSync, openSync, closeSync, mkdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, } from 'node:fs';
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { hostname } from 'node:os';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { projectSnapshot, readCatalogSourceIdentity } from './catalog-snapshot.js';
|
|
7
|
-
import { readBoundedFile } from './bounded-file.js';
|
|
8
|
-
const catalogErrors = {
|
|
9
|
-
CATALOG_BUSY: {
|
|
10
|
-
message: 'The catalog is busy. Retry when the other operation has finished.',
|
|
11
|
-
nextAction: 'If an operation was interrupted, inspect the catalog lock and use the local recover-catalog-lock command.',
|
|
12
|
-
},
|
|
13
|
-
CATALOG_INVALID: {
|
|
14
|
-
message: 'Project catalog is invalid. Restore the local catalog before continuing.',
|
|
15
|
-
nextAction: 'Restore a valid catalog backup; no project files were changed.',
|
|
16
|
-
},
|
|
17
|
-
PROJECT_NOT_FOUND: {
|
|
18
|
-
message: 'This project is not in your catalog.',
|
|
19
|
-
nextAction: 'Refresh the project list and select a registered project.',
|
|
20
|
-
},
|
|
21
|
-
PROJECT_UNAVAILABLE: {
|
|
22
|
-
message: 'Registered source is unavailable.',
|
|
23
|
-
nextAction: 'Restore the registered source directory, then refresh.',
|
|
24
|
-
},
|
|
25
|
-
INVALID_INPUT: {
|
|
26
|
-
message: 'The catalog input is invalid.',
|
|
27
|
-
nextAction: 'Check the project ID and requested input, then retry.',
|
|
28
|
-
},
|
|
29
|
-
CATALOG_FAILURE: {
|
|
30
|
-
message: 'The catalog operation could not complete.',
|
|
31
|
-
nextAction: 'Check local catalog access and retry.',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
export class CatalogError extends Error {
|
|
35
|
-
code;
|
|
36
|
-
constructor(code) {
|
|
37
|
-
super(catalogErrors[code].message);
|
|
38
|
-
this.code = code;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export function catalogFailure(error) {
|
|
42
|
-
const code = error instanceof CatalogError ? error.code : 'CATALOG_FAILURE';
|
|
43
|
-
return { code, ...catalogErrors[code] };
|
|
44
|
-
}
|
|
45
|
-
const entrySchema = z
|
|
46
|
-
.object({
|
|
47
|
-
id: z.string().uuid(),
|
|
48
|
-
root: z.string().min(1),
|
|
49
|
-
name: z.string().trim().min(1).max(80),
|
|
50
|
-
updatedAt: z.string().datetime(),
|
|
51
|
-
sourceIdentity: z.string().uuid().optional(),
|
|
52
|
-
})
|
|
53
|
-
.strict();
|
|
54
|
-
const catalogSchema = z
|
|
55
|
-
.object({
|
|
56
|
-
schemaVersion: z.literal(1),
|
|
57
|
-
projects: z.array(entrySchema).max(200),
|
|
58
|
-
view: z.enum(['list', 'grid']),
|
|
59
|
-
})
|
|
60
|
-
.strict();
|
|
61
|
-
const projectId = z.string().uuid();
|
|
62
|
-
const toolSchema = z.enum([
|
|
63
|
-
'list_projects',
|
|
64
|
-
'get_project',
|
|
65
|
-
'rename_project',
|
|
66
|
-
'forget_project',
|
|
67
|
-
'set_view',
|
|
68
|
-
]);
|
|
69
|
-
const inputSchemas = {
|
|
70
|
-
list_projects: z.object({}).strict(),
|
|
71
|
-
get_project: z.object({ id: projectId }).strict(),
|
|
72
|
-
rename_project: z.object({ id: projectId, name: z.string().trim().min(1).max(80) }).strict(),
|
|
73
|
-
forget_project: z.object({ id: projectId }).strict(),
|
|
74
|
-
set_view: z.object({ view: z.enum(['list', 'grid']) }).strict(),
|
|
75
|
-
};
|
|
76
|
-
const CATALOG_LIMIT = 1024 * 1024;
|
|
77
|
-
export class ProjectStore {
|
|
78
|
-
directory;
|
|
79
|
-
file;
|
|
80
|
-
constructor(directory) {
|
|
81
|
-
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
82
|
-
this.directory = realpathSync(directory);
|
|
83
|
-
this.file = path.join(this.directory, 'projects.json');
|
|
84
|
-
}
|
|
85
|
-
read() {
|
|
86
|
-
if (!existsSync(this.file))
|
|
87
|
-
return { schemaVersion: 1, projects: [], view: 'list' };
|
|
88
|
-
try {
|
|
89
|
-
const value = catalogSchema.parse(JSON.parse(readBoundedFile(this.file, CATALOG_LIMIT).toString('utf8')));
|
|
90
|
-
if (new Set(value.projects.map((project) => project.id)).size !== value.projects.length)
|
|
91
|
-
throw new Error();
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
throw new CatalogError('CATALOG_INVALID');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
write(catalog) {
|
|
99
|
-
const temporary = path.join(this.directory, `${randomUUID()}.tmp`);
|
|
100
|
-
const bytes = JSON.stringify(catalogSchema.parse(catalog), null, 2) + '\n';
|
|
101
|
-
if (Buffer.byteLength(bytes) > CATALOG_LIMIT)
|
|
102
|
-
throw new Error('Project catalog exceeds its storage limit.');
|
|
103
|
-
writeFileSync(temporary, bytes, {
|
|
104
|
-
mode: 0o600,
|
|
105
|
-
flag: 'wx',
|
|
106
|
-
});
|
|
107
|
-
try {
|
|
108
|
-
renameSync(temporary, this.file);
|
|
109
|
-
}
|
|
110
|
-
finally {
|
|
111
|
-
rmSync(temporary, { force: true });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
register(root, displayName) {
|
|
115
|
-
const resolved = realpathSync(root);
|
|
116
|
-
if (!statSync(resolved).isDirectory())
|
|
117
|
-
throw new Error('Choose a project directory.');
|
|
118
|
-
// Registration is an operator action; MCP tools cannot add arbitrary filesystem paths.
|
|
119
|
-
let packageName;
|
|
120
|
-
try {
|
|
121
|
-
packageName = z
|
|
122
|
-
.string()
|
|
123
|
-
.min(1)
|
|
124
|
-
.parse(JSON.parse(readBoundedFile(path.join(resolved, 'package.json'), 1024 * 1024).toString('utf8')).name);
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
throw new Error('Choose a project with a valid package.json name.');
|
|
128
|
-
}
|
|
129
|
-
const sourceIdentity = readCatalogSourceIdentity(resolved);
|
|
130
|
-
return this.mutate((catalog) => {
|
|
131
|
-
const previous = catalog.projects.find((project) => project.root === resolved && project.sourceIdentity === sourceIdentity);
|
|
132
|
-
if (previous)
|
|
133
|
-
return previous.id;
|
|
134
|
-
const entry = entrySchema.parse({
|
|
135
|
-
id: randomUUID(),
|
|
136
|
-
root: resolved,
|
|
137
|
-
name: displayName ?? packageName,
|
|
138
|
-
updatedAt: new Date().toISOString(),
|
|
139
|
-
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
140
|
-
});
|
|
141
|
-
catalog.projects.push(entry);
|
|
142
|
-
return entry.id;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
mutate(operation) {
|
|
146
|
-
const lock = path.join(this.directory, 'projects.lock');
|
|
147
|
-
let descriptor;
|
|
148
|
-
try {
|
|
149
|
-
if (existsSync(path.join(this.directory, 'projects.recovery.lock')))
|
|
150
|
-
throw new Error();
|
|
151
|
-
descriptor = openSync(lock, 'wx', 0o600);
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
writeFileSync(descriptor, JSON.stringify({
|
|
158
|
-
schemaVersion: 1,
|
|
159
|
-
pid: process.pid,
|
|
160
|
-
host: hostname(),
|
|
161
|
-
token: randomUUID(),
|
|
162
|
-
createdAt: new Date().toISOString(),
|
|
163
|
-
}));
|
|
164
|
-
if (existsSync(path.join(this.directory, 'projects.recovery.lock')))
|
|
165
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
166
|
-
const catalog = this.read();
|
|
167
|
-
const result = operation(catalog);
|
|
168
|
-
this.write(catalog);
|
|
169
|
-
return result;
|
|
170
|
-
}
|
|
171
|
-
finally {
|
|
172
|
-
closeSync(descriptor);
|
|
173
|
-
rmSync(lock, { force: true });
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/** Explicit local operator recovery only; uncertain ownership never removes a lock. */
|
|
177
|
-
recoverCatalogLock() {
|
|
178
|
-
const guard = path.join(this.directory, 'projects.recovery.lock');
|
|
179
|
-
let descriptor;
|
|
180
|
-
try {
|
|
181
|
-
descriptor = openSync(guard, 'wx', 0o600);
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
const lock = path.join(this.directory, 'projects.lock');
|
|
188
|
-
if (!existsSync(lock))
|
|
189
|
-
return { recovered: false };
|
|
190
|
-
let owner;
|
|
191
|
-
try {
|
|
192
|
-
if (!lstatSync(lock).isFile() || lstatSync(lock).isSymbolicLink())
|
|
193
|
-
throw new Error();
|
|
194
|
-
owner = z
|
|
195
|
-
.object({
|
|
196
|
-
schemaVersion: z.literal(1),
|
|
197
|
-
pid: z.number().int().positive(),
|
|
198
|
-
host: z.string(),
|
|
199
|
-
token: z.string().uuid(),
|
|
200
|
-
createdAt: z.string().datetime(),
|
|
201
|
-
})
|
|
202
|
-
.strict()
|
|
203
|
-
.parse(JSON.parse(readBoundedFile(lock, 4096).toString('utf8')));
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
207
|
-
}
|
|
208
|
-
if (owner.host !== hostname())
|
|
209
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
210
|
-
try {
|
|
211
|
-
process.kill(owner.pid, 0);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
if (error.code === 'ESRCH') {
|
|
215
|
-
rmSync(lock);
|
|
216
|
-
return { recovered: true };
|
|
217
|
-
}
|
|
218
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
219
|
-
}
|
|
220
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
221
|
-
}
|
|
222
|
-
finally {
|
|
223
|
-
closeSync(descriptor);
|
|
224
|
-
rmSync(guard, { force: true });
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
context(id) {
|
|
228
|
-
const project = this.read().projects.find((project) => project.id === id);
|
|
229
|
-
if (!project)
|
|
230
|
-
throw new CatalogError('PROJECT_NOT_FOUND');
|
|
231
|
-
try {
|
|
232
|
-
if (realpathSync(project.root) !== project.root ||
|
|
233
|
-
project.sourceIdentity !== readCatalogSourceIdentity(project.root))
|
|
234
|
-
throw new Error();
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
throw new CatalogError('PROJECT_UNAVAILABLE');
|
|
238
|
-
}
|
|
239
|
-
return { id: project.id, name: project.name, directory: project.root };
|
|
240
|
-
}
|
|
241
|
-
snapshot(selectedId = null) {
|
|
242
|
-
const catalog = this.read();
|
|
243
|
-
return {
|
|
244
|
-
projects: catalog.projects
|
|
245
|
-
.map((entry) => projectSnapshot(entry, entry.id === selectedId))
|
|
246
|
-
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt)),
|
|
247
|
-
selectedId,
|
|
248
|
-
preferences: { view: catalog.view },
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
call(tool, raw) {
|
|
252
|
-
let args;
|
|
253
|
-
try {
|
|
254
|
-
args = inputSchemas[toolSchema.parse(tool)].parse(raw);
|
|
255
|
-
}
|
|
256
|
-
catch {
|
|
257
|
-
throw new CatalogError('INVALID_INPUT');
|
|
258
|
-
}
|
|
259
|
-
if (tool === 'list_projects')
|
|
260
|
-
return this.snapshot();
|
|
261
|
-
if (tool === 'get_project') {
|
|
262
|
-
if (!this.read().projects.some((project) => project.id === args.id))
|
|
263
|
-
throw new CatalogError('PROJECT_NOT_FOUND');
|
|
264
|
-
return this.snapshot(args.id);
|
|
265
|
-
}
|
|
266
|
-
const selectedId = this.mutate((catalog) => {
|
|
267
|
-
if (tool === 'set_view') {
|
|
268
|
-
if (!args.view)
|
|
269
|
-
throw new Error('Choose list or grid view.');
|
|
270
|
-
catalog.view = args.view;
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
const project = catalog.projects.find((project) => project.id === args.id);
|
|
274
|
-
if (!project)
|
|
275
|
-
throw new CatalogError('PROJECT_NOT_FOUND');
|
|
276
|
-
if (tool === 'rename_project') {
|
|
277
|
-
if (!args.name)
|
|
278
|
-
throw new Error('Enter a project name.');
|
|
279
|
-
project.name = args.name;
|
|
280
|
-
project.updatedAt = new Date().toISOString();
|
|
281
|
-
return project.id;
|
|
282
|
-
}
|
|
283
|
-
catalog.projects = catalog.projects.filter((entry) => entry.id !== project.id);
|
|
284
|
-
return null;
|
|
285
|
-
});
|
|
286
|
-
return this.snapshot(selectedId);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ProjectInspection } from './inspector-model.js';
|
|
2
|
-
/** Local read-only inspection. Each section has bounded allowlisted inputs and an
|
|
3
|
-
* independent error state. No secrets, commands, provider calls, or migrations. */
|
|
4
|
-
export declare function inspectApplication(root: string): ProjectInspection;
|