orizu 0.5.29 → 0.5.30
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 +8 -2
- package/dist/account-directory.d.ts +132 -0
- package/dist/account-directory.d.ts.map +1 -0
- package/dist/account-directory.js +434 -0
- package/dist/app-commands.d.ts +29 -0
- package/dist/app-commands.d.ts.map +1 -0
- package/dist/app-commands.js +375 -0
- package/dist/auth-commands.d.ts +11 -0
- package/dist/auth-commands.d.ts.map +1 -0
- package/dist/auth-commands.js +321 -0
- package/dist/cli-console-output.d.ts +12 -0
- package/dist/cli-console-output.d.ts.map +1 -0
- package/dist/cli-console-output.js +57 -0
- package/dist/cli-project-slug.d.ts +3 -0
- package/dist/cli-project-slug.d.ts.map +1 -1
- package/dist/cli-project-slug.js +12 -0
- package/dist/command-line-arguments.d.ts +15 -0
- package/dist/command-line-arguments.d.ts.map +1 -0
- package/dist/command-line-arguments.js +77 -0
- package/dist/credentials.d.ts +2 -0
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +43 -0
- package/dist/dataset-commands.d.ts +16 -0
- package/dist/dataset-commands.d.ts.map +1 -0
- package/dist/dataset-commands.js +634 -0
- package/dist/dataset-download.d.ts.map +1 -1
- package/dist/dataset-download.js +4 -3
- package/dist/egress-policy.d.ts +8 -5
- package/dist/egress-policy.d.ts.map +1 -1
- package/dist/egress-policy.js +18 -7
- package/dist/feedback-cli.d.ts.map +1 -1
- package/dist/feedback-cli.js +22 -8
- package/dist/feedback-contract.d.ts +2 -0
- package/dist/feedback-contract.d.ts.map +1 -1
- package/dist/feedback-contract.js +17 -3
- package/dist/feedback-scrub.d.ts.map +1 -1
- package/dist/feedback-scrub.js +308 -22
- package/dist/gepa-engine-dispatch.d.ts.map +1 -1
- package/dist/gepa-engine-dispatch.js +12 -2
- package/dist/global-flags.d.ts +1 -0
- package/dist/global-flags.d.ts.map +1 -1
- package/dist/global-flags.js +7 -0
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +68 -1
- package/dist/hosted-environment.d.ts +10 -0
- package/dist/hosted-environment.d.ts.map +1 -1
- package/dist/hosted-environment.js +81 -0
- package/dist/hosted-gepa-cli.d.ts.map +1 -1
- package/dist/hosted-gepa-cli.js +37 -5
- package/dist/hosted-harness-claude.d.ts +1 -2
- package/dist/hosted-harness-claude.d.ts.map +1 -1
- package/dist/hosted-harness-claude.js +8 -4
- package/dist/hosted-harness-opencode.d.ts +15 -10
- package/dist/hosted-harness-opencode.d.ts.map +1 -1
- package/dist/hosted-harness-opencode.js +27 -14
- package/dist/hosted-optimization-refusals.d.ts +6 -1
- package/dist/hosted-optimization-refusals.d.ts.map +1 -1
- package/dist/hosted-optimization-refusals.js +8 -2
- package/dist/hosted-optimization.d.ts.map +1 -1
- package/dist/hosted-optimization.js +40 -10
- package/dist/hosted-provider-credentials.d.ts +16 -0
- package/dist/hosted-provider-credentials.d.ts.map +1 -0
- package/dist/hosted-provider-credentials.js +36 -0
- package/dist/hosted-provider-settings.d.ts +7 -4
- package/dist/hosted-provider-settings.d.ts.map +1 -1
- package/dist/hosted-provider-settings.js +16 -13
- package/dist/http.d.ts +11 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +23 -10
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +335 -3675
- package/dist/last-error-caps.d.ts +1 -0
- package/dist/last-error-caps.d.ts.map +1 -1
- package/dist/last-error-caps.js +1 -0
- package/dist/last-error-record.d.ts +3 -0
- package/dist/last-error-record.d.ts.map +1 -1
- package/dist/last-error-record.js +33 -6
- package/dist/model-config-fields.d.ts +2 -4
- package/dist/model-config-fields.d.ts.map +1 -1
- package/dist/model-config-fields.js +26 -9
- package/dist/model-config-price.d.ts +17 -0
- package/dist/model-config-price.d.ts.map +1 -0
- package/dist/model-config-price.js +42 -0
- package/dist/model-configs-cli.d.ts +2 -0
- package/dist/model-configs-cli.d.ts.map +1 -1
- package/dist/model-configs-cli.js +47 -4
- package/dist/optimization-export-cli.d.ts.map +1 -1
- package/dist/optimization-export-cli.js +19 -0
- package/dist/preview-runtime.d.ts.map +1 -1
- package/dist/preview-runtime.js +11 -4
- package/dist/prompt-length-wire.d.ts +1 -1
- package/dist/prompt-length-wire.d.ts.map +1 -1
- package/dist/prompt-length-wire.js +1 -0
- package/dist/provider-lookup.d.ts +24 -0
- package/dist/provider-lookup.d.ts.map +1 -0
- package/dist/provider-lookup.js +43 -0
- package/dist/provider-probe.d.ts +24 -0
- package/dist/provider-probe.d.ts.map +1 -0
- package/dist/provider-probe.js +88 -0
- package/dist/provider-refusals.d.ts +83 -0
- package/dist/provider-refusals.d.ts.map +1 -0
- package/dist/provider-refusals.js +48 -0
- package/dist/provider-registry.d.ts +146 -0
- package/dist/provider-registry.d.ts.map +1 -0
- package/dist/provider-registry.js +155 -0
- package/dist/providers-cli.d.ts +3 -0
- package/dist/providers-cli.d.ts.map +1 -0
- package/dist/providers-cli.js +178 -0
- package/dist/runner-env-allowlist.d.ts +4 -0
- package/dist/runner-env-allowlist.d.ts.map +1 -0
- package/dist/runner-env-allowlist.js +36 -0
- package/dist/runner-env.d.ts +6 -2
- package/dist/runner-env.d.ts.map +1 -1
- package/dist/runner-env.js +44 -21
- package/dist/setup-and-skills-commands.d.ts +11 -0
- package/dist/setup-and-skills-commands.d.ts.map +1 -0
- package/dist/setup-and-skills-commands.js +1055 -0
- package/dist/task-commands.d.ts +13 -0
- package/dist/task-commands.d.ts.map +1 -0
- package/dist/task-commands.js +512 -0
- package/dist/workspace.d.ts +1 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +11 -0
- package/package.json +1 -1
- package/src/account-directory.ts +751 -0
- package/src/app-commands.ts +520 -0
- package/src/auth-commands.ts +388 -0
- package/src/cli-console-output.ts +83 -0
- package/src/cli-project-slug.ts +15 -0
- package/src/command-line-arguments.ts +111 -0
- package/src/credentials.ts +41 -0
- package/src/dataset-commands.ts +863 -0
- package/src/dataset-download.ts +4 -3
- package/src/egress-policy.ts +19 -8
- package/src/feedback-cli.ts +22 -7
- package/src/feedback-contract.ts +21 -2
- package/src/feedback-scrub.ts +376 -43
- package/src/gepa-engine-dispatch.ts +16 -2
- package/src/global-flags.ts +8 -0
- package/src/help.ts +68 -1
- package/src/hosted-environment.ts +70 -0
- package/src/hosted-gepa-cli.ts +35 -5
- package/src/hosted-harness-claude.ts +9 -4
- package/src/hosted-harness-opencode.ts +28 -14
- package/src/hosted-optimization-refusals.ts +11 -3
- package/src/hosted-optimization.ts +42 -12
- package/src/hosted-provider-credentials.js +2 -0
- package/src/hosted-provider-credentials.ts +42 -0
- package/src/hosted-provider-settings.ts +21 -13
- package/src/http.ts +35 -9
- package/src/index.ts +1080 -5332
- package/src/last-error-caps.ts +1 -0
- package/src/last-error-record.ts +40 -7
- package/src/model-config-fields.ts +29 -10
- package/src/model-config-price.js +2 -0
- package/src/model-config-price.ts +55 -0
- package/src/model-configs-cli.ts +41 -4
- package/src/optimization-export-cli.ts +23 -0
- package/src/preview-runtime.ts +11 -4
- package/src/prompt-length-wire.ts +1 -0
- package/src/provider-lookup.js +2 -0
- package/src/provider-lookup.ts +73 -0
- package/src/provider-probe.ts +101 -0
- package/src/provider-refusals.ts +53 -0
- package/src/provider-registry.js +4 -0
- package/src/provider-registry.ts +186 -0
- package/src/providers-cli.ts +153 -0
- package/src/runner-env-allowlist.js +4 -0
- package/src/runner-env-allowlist.ts +38 -0
- package/src/runner-env.js +4 -0
- package/src/runner-env.ts +49 -22
- package/src/setup-and-skills-commands.ts +1242 -0
- package/src/task-commands.ts +703 -0
- package/src/workspace.ts +11 -0
- package/vendor/orizu-gepa/pyproject.toml +7 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/callbacks.py +77 -39
- package/vendor/orizu-gepa/src/orizu_gepa_connector/providers.generated.json +32 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/reflection.py +5 -3
- package/vendor/orizu-gepa/src/orizu_gepa_connector/runtime.py +16 -2
- package/vendor/orizu-gepa/src/orizu_gepa_connector/skilled_proposer_bridge.py +14 -1
- package/vendor/orizu-gepa/src/orizu_gepa_connector/translator.py +91 -24
- package/vendor/orizu-gepa-python/pyproject.toml +7 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/local_log.py +3 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/providers.generated.json +32 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/providers.py +321 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/reflection.py +269 -89
- package/vendor/orizu-gepa-python/src/orizu_gepa/runner.py +40 -6
- package/vendor/skills/orizu/SKILL.md +22 -22
- package/vendor/skills/orizu/flows/promote.md +3 -3
- package/vendor/skills/orizu/flows/triage.md +5 -5
- package/vendor/skills/orizu/references/assess-and-plan.md +16 -16
- package/vendor/skills/orizu/references/building-apps.md +92 -92
- package/vendor/skills/orizu/references/building-judges.md +6 -6
- package/vendor/skills/orizu/references/cli-reference.md +18 -14
- package/vendor/skills/orizu/references/dataset-design.md +3 -3
- package/vendor/skills/orizu/references/eval-strategy.md +8 -8
- package/vendor/skills/orizu/references/feedback.md +21 -9
- package/vendor/skills/orizu/references/instructions-after-prompts.md +5 -5
- package/vendor/skills/orizu/references/migrate-existing-gepa-setup.md +15 -15
- package/vendor/skills/orizu/references/migrate-hand-rolled-instruction-layout.md +4 -4
- package/vendor/skills/orizu/references/optimization-reports.md +5 -5
- package/vendor/skills/orizu/references/optimization-with-gepa.md +41 -35
- package/vendor/skills/orizu/references/orizu-in-your-codebase.md +8 -8
- package/vendor/skills/orizu/references/primer.md +42 -42
- package/vendor/skills/orizu/references/prompt-control-plane.md +29 -29
- package/vendor/skills/orizu/references/vocabulary.md +18 -18
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
// ORI-2044: moved from index.ts to keep app commands together.
|
|
2
|
+
import { readFileSync, mkdirSync, writeFileSync, realpathSync, } from 'fs';
|
|
3
|
+
import { normalize, isAbsolute, join, dirname, } from 'path';
|
|
4
|
+
import { createHash } from 'crypto';
|
|
5
|
+
import { getArg, getArchiveListStatus, hasJsonFlag, expandHomePath, hasArg, } from './command-line-arguments.js';
|
|
6
|
+
import { resolveProjectSlug, fetchApps, selectAppIdInteractively } from './account-directory.js';
|
|
7
|
+
import { printJson, printLine, getErrorMessage } from './cli-console-output.js';
|
|
8
|
+
import { printAppSummaries } from './archive-artifacts-cli.js';
|
|
9
|
+
import { isNodeError, formatTerminalLink } from './auth-commands.js';
|
|
10
|
+
import { authedFetch } from './http.js';
|
|
11
|
+
import { parseJsonResponse, sanitizeTerminalText } from './json-response.js';
|
|
12
|
+
import { runLocalAppPreview } from './preview-runtime.js';
|
|
13
|
+
async function listApps() {
|
|
14
|
+
const project = getArg('--project') || await resolveProjectSlug(null);
|
|
15
|
+
const apps = await fetchApps(project, getArchiveListStatus('apps'));
|
|
16
|
+
if (hasJsonFlag()) {
|
|
17
|
+
printJson({ apps });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
printAppSummaries(apps, printLine);
|
|
21
|
+
}
|
|
22
|
+
function readSourceFile(pathArg) {
|
|
23
|
+
const expandedPath = expandHomePath(pathArg);
|
|
24
|
+
try {
|
|
25
|
+
return readFileSync(expandedPath, 'utf-8');
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (isNodeError(error) && error.code === 'ENOENT') {
|
|
29
|
+
throw new Error(`File not found: ${expandedPath}`);
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`Failed to read file '${expandedPath}': ${getErrorMessage(error)}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function readSourceBytes(pathArg) {
|
|
35
|
+
const expandedPath = expandHomePath(pathArg);
|
|
36
|
+
try {
|
|
37
|
+
return readFileSync(expandedPath);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (isNodeError(error) && error.code === 'ENOENT') {
|
|
41
|
+
throw new Error(`File not found: ${expandedPath}`);
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`Failed to read file '${expandedPath}': ${getErrorMessage(error)}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function readJsonFile(pathArg) {
|
|
47
|
+
const raw = readSourceFile(pathArg);
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(raw);
|
|
50
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
51
|
+
throw new Error('JSON root must be an object');
|
|
52
|
+
}
|
|
53
|
+
return parsed;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(`Invalid JSON file '${pathArg}': ${getErrorMessage(error)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function isRecord(value) {
|
|
60
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
61
|
+
}
|
|
62
|
+
function stringFromRecord(record, key) {
|
|
63
|
+
const value = record[key];
|
|
64
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
65
|
+
}
|
|
66
|
+
function safeRelativePath(value, fallback) {
|
|
67
|
+
const raw = value && value.trim() ? value.trim() : fallback;
|
|
68
|
+
if (raw.includes('\0')) {
|
|
69
|
+
throw new Error(`Unsafe relative path: ${raw}`);
|
|
70
|
+
}
|
|
71
|
+
const normalized = normalize(raw);
|
|
72
|
+
if (isAbsolute(raw) || normalized === '..' || normalized.startsWith('../') || normalized.startsWith('..\\')) {
|
|
73
|
+
throw new Error(`Unsafe relative path: ${raw}`);
|
|
74
|
+
}
|
|
75
|
+
return normalized === '.' ? fallback : normalized;
|
|
76
|
+
}
|
|
77
|
+
function sha256Hex(value) {
|
|
78
|
+
return createHash('sha256').update(value).digest('hex');
|
|
79
|
+
}
|
|
80
|
+
function readPromptPrimaryText(manifest, promptDir) {
|
|
81
|
+
const primaryText = isRecord(manifest.primary_text) ? manifest.primary_text : null;
|
|
82
|
+
const pathValue = primaryText
|
|
83
|
+
? stringFromRecord(primaryText, 'path')
|
|
84
|
+
: stringFromRecord(manifest, 'body_file');
|
|
85
|
+
const bodyPath = safeRelativePath(pathValue || 'prompt.md', 'prompt.md');
|
|
86
|
+
const bodyKind = primaryText
|
|
87
|
+
? stringFromRecord(primaryText, 'kind') || stringFromRecord(manifest, 'body_kind') || 'text'
|
|
88
|
+
: stringFromRecord(manifest, 'body_kind') || 'text';
|
|
89
|
+
return {
|
|
90
|
+
body: readSourceFile(join(promptDir, bodyPath)),
|
|
91
|
+
bodyKind,
|
|
92
|
+
path: bodyPath,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function readPromptSidecars(manifest, promptDir) {
|
|
96
|
+
const sidecars = Array.isArray(manifest.sidecars) ? manifest.sidecars : [];
|
|
97
|
+
return sidecars
|
|
98
|
+
.filter(isRecord)
|
|
99
|
+
.map(sidecar => {
|
|
100
|
+
const pathValue = stringFromRecord(sidecar, 'path');
|
|
101
|
+
if (!pathValue) {
|
|
102
|
+
throw new Error('Prompt sidecar entries require path');
|
|
103
|
+
}
|
|
104
|
+
const relativePath = safeRelativePath(pathValue, pathValue);
|
|
105
|
+
const content = readSourceFile(join(promptDir, relativePath));
|
|
106
|
+
const { content: _ignoredContent, content_sha256: _ignoredSnake, contentSha256: _ignoredCamel, ...metadata } = sidecar;
|
|
107
|
+
return {
|
|
108
|
+
...metadata,
|
|
109
|
+
type: stringFromRecord(sidecar, 'type') || 'file',
|
|
110
|
+
path: relativePath,
|
|
111
|
+
content,
|
|
112
|
+
contentSha256: sha256Hex(content),
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function writeTextFileEnsuringDir(pathArg, content) {
|
|
117
|
+
mkdirSync(dirname(pathArg), { recursive: true });
|
|
118
|
+
writeFileSync(pathArg, content);
|
|
119
|
+
}
|
|
120
|
+
function readManifestFile(dirArg) {
|
|
121
|
+
return readJsonFile(join(expandHomePath(dirArg), 'manifest.json'));
|
|
122
|
+
}
|
|
123
|
+
async function createAppFromFile() {
|
|
124
|
+
const project = getArg('--project');
|
|
125
|
+
const name = getArg('--name');
|
|
126
|
+
const datasetId = getArg('--dataset');
|
|
127
|
+
const filePath = getArg('--file');
|
|
128
|
+
const inputSchemaPath = getArg('--input-schema');
|
|
129
|
+
const outputSchemaPath = getArg('--output-schema');
|
|
130
|
+
const component = getArg('--component') || undefined;
|
|
131
|
+
if (!project || !name || !datasetId || !filePath || !inputSchemaPath || !outputSchemaPath) {
|
|
132
|
+
throw new Error('Usage: orizu apps create --project <team/project> --name <name> --dataset <datasetId> --file <path> --input-schema <json-path> --output-schema <json-path> [--component <name>]');
|
|
133
|
+
}
|
|
134
|
+
const sourceCode = readSourceFile(filePath);
|
|
135
|
+
const inputJsonSchema = readJsonFile(inputSchemaPath);
|
|
136
|
+
const outputJsonSchema = readJsonFile(outputSchemaPath);
|
|
137
|
+
const response = await authedFetch('/api/cli/apps/create-from-file', {
|
|
138
|
+
method: 'POST',
|
|
139
|
+
headers: { 'Content-Type': 'application/json' },
|
|
140
|
+
body: JSON.stringify({
|
|
141
|
+
projectSlug: project,
|
|
142
|
+
name,
|
|
143
|
+
datasetId,
|
|
144
|
+
sourceCode,
|
|
145
|
+
componentName: component,
|
|
146
|
+
inputJsonSchema,
|
|
147
|
+
outputJsonSchema,
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
if (!response.ok) {
|
|
151
|
+
throw new Error(`Failed to create app: ${await response.text()}`);
|
|
152
|
+
}
|
|
153
|
+
const data = await parseJsonResponse(response, 'App create');
|
|
154
|
+
if (hasJsonFlag()) {
|
|
155
|
+
printJson({ app: data.app, warnings: data.warnings || [] });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
printLine(`Created app ${sanitizeTerminalText(data.app.name)} (${sanitizeTerminalText(data.app.id)}) v${data.app.versionNum}`);
|
|
159
|
+
if (data.app.url) {
|
|
160
|
+
printLine(`View app: ${formatTerminalLink(data.app.url)}`);
|
|
161
|
+
}
|
|
162
|
+
if (data.warnings?.length) {
|
|
163
|
+
printLine(`Warnings: ${sanitizeTerminalText(data.warnings.join('; '))}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function previewAppFromFile() {
|
|
167
|
+
const filePath = getArg('--file');
|
|
168
|
+
const inputSchemaPath = getArg('--input-schema');
|
|
169
|
+
const outputSchemaPath = getArg('--output-schema');
|
|
170
|
+
const sampleRowPath = getArg('--sample-row');
|
|
171
|
+
const screenshotPath = getArg('--screenshot');
|
|
172
|
+
const component = getArg('--component') || undefined;
|
|
173
|
+
const headed = hasArg('--headed');
|
|
174
|
+
const keepOpen = hasArg('--keep-open');
|
|
175
|
+
if (!filePath || !inputSchemaPath || !outputSchemaPath || !sampleRowPath) {
|
|
176
|
+
throw new Error('Usage: orizu apps preview --file <path> --input-schema <json-path> --output-schema <json-path> --sample-row <json-path> [--screenshot <png-path>] [--headed] [--keep-open] [--component <name>]');
|
|
177
|
+
}
|
|
178
|
+
const expandedFilePath = realpathSync(expandHomePath(filePath));
|
|
179
|
+
const inputJsonSchema = readJsonFile(inputSchemaPath);
|
|
180
|
+
const outputJsonSchema = readJsonFile(outputSchemaPath);
|
|
181
|
+
const sampleRow = readJsonFile(sampleRowPath);
|
|
182
|
+
const expandedScreenshotPath = screenshotPath ? expandHomePath(screenshotPath) : undefined;
|
|
183
|
+
const result = await runLocalAppPreview({
|
|
184
|
+
filePath: expandedFilePath,
|
|
185
|
+
inputSchema: inputJsonSchema,
|
|
186
|
+
outputSchema: outputJsonSchema,
|
|
187
|
+
sampleRow,
|
|
188
|
+
screenshotPath: expandedScreenshotPath,
|
|
189
|
+
componentName: component,
|
|
190
|
+
headed,
|
|
191
|
+
keepOpen,
|
|
192
|
+
});
|
|
193
|
+
if (hasJsonFlag()) {
|
|
194
|
+
printJson({
|
|
195
|
+
url: result.url,
|
|
196
|
+
screenshotPath: result.screenshotPath || null,
|
|
197
|
+
warnings: result.warnings,
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
printLine(`Preview rendered: ${formatTerminalLink(result.url)}`);
|
|
202
|
+
if (result.screenshotPath) {
|
|
203
|
+
printLine(`Screenshot: ${sanitizeTerminalText(result.screenshotPath)}`);
|
|
204
|
+
}
|
|
205
|
+
if (headed || keepOpen) {
|
|
206
|
+
printLine('Headed preview is running. Close Chromium or stop the command when you are done.');
|
|
207
|
+
}
|
|
208
|
+
if (result.warnings.length > 0) {
|
|
209
|
+
printLine(`Warnings: ${sanitizeTerminalText(result.warnings.join('; '))}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async function updateAppFromFile() {
|
|
213
|
+
const filePath = getArg('--file');
|
|
214
|
+
const inputSchemaPath = getArg('--input-schema');
|
|
215
|
+
const outputSchemaPath = getArg('--output-schema');
|
|
216
|
+
const component = getArg('--component') || undefined;
|
|
217
|
+
let appId = getArg('--app');
|
|
218
|
+
const project = getArg('--project');
|
|
219
|
+
if (!filePath || !inputSchemaPath || !outputSchemaPath) {
|
|
220
|
+
throw new Error('Usage: orizu apps update [--app <appId>] [--project <team/project>] --file <path> --input-schema <json-path> --output-schema <json-path> [--component <name>]');
|
|
221
|
+
}
|
|
222
|
+
if (!appId) {
|
|
223
|
+
const selected = await selectAppIdInteractively(project);
|
|
224
|
+
appId = selected.appId;
|
|
225
|
+
}
|
|
226
|
+
const sourceCode = readSourceFile(filePath);
|
|
227
|
+
const inputJsonSchema = readJsonFile(inputSchemaPath);
|
|
228
|
+
const outputJsonSchema = readJsonFile(outputSchemaPath);
|
|
229
|
+
const response = await authedFetch(`/api/cli/apps/${encodeURIComponent(appId)}/update-from-file`, {
|
|
230
|
+
method: 'POST',
|
|
231
|
+
headers: { 'Content-Type': 'application/json' },
|
|
232
|
+
body: JSON.stringify({
|
|
233
|
+
sourceCode,
|
|
234
|
+
componentName: component,
|
|
235
|
+
inputJsonSchema,
|
|
236
|
+
outputJsonSchema,
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
if (!response.ok) {
|
|
240
|
+
throw new Error(`Failed to update app: ${await response.text()}`);
|
|
241
|
+
}
|
|
242
|
+
const data = await parseJsonResponse(response, 'App update');
|
|
243
|
+
if (hasJsonFlag()) {
|
|
244
|
+
printJson({ app: data.app, warnings: data.warnings || [] });
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
printLine(`Updated app ${sanitizeTerminalText(data.app.name)} (${sanitizeTerminalText(data.app.id)}) to v${data.app.versionNum}`);
|
|
248
|
+
if (data.warnings?.length) {
|
|
249
|
+
printLine(`Warnings: ${sanitizeTerminalText(data.warnings.join('; '))}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async function linkAppDataset() {
|
|
253
|
+
const datasetId = getArg('--dataset');
|
|
254
|
+
const project = getArg('--project');
|
|
255
|
+
let appId = getArg('--app');
|
|
256
|
+
const versionArg = getArg('--version');
|
|
257
|
+
const parsedVersionNum = versionArg ? Number(versionArg) : Number.NaN;
|
|
258
|
+
const versionNum = Number.isInteger(parsedVersionNum) && parsedVersionNum > 0 ? parsedVersionNum : undefined;
|
|
259
|
+
if (!datasetId) {
|
|
260
|
+
throw new Error('Usage: orizu apps link-dataset --dataset <datasetId> [--app <appId>] [--project <team/project>] [--version <n>]');
|
|
261
|
+
}
|
|
262
|
+
if (versionArg && versionNum === undefined) {
|
|
263
|
+
throw new Error('--version must be a positive integer');
|
|
264
|
+
}
|
|
265
|
+
if (!appId) {
|
|
266
|
+
const selected = await selectAppIdInteractively(project);
|
|
267
|
+
appId = selected.appId;
|
|
268
|
+
}
|
|
269
|
+
const response = await authedFetch(`/api/cli/apps/${encodeURIComponent(appId)}/link-dataset`, {
|
|
270
|
+
method: 'POST',
|
|
271
|
+
headers: { 'Content-Type': 'application/json' },
|
|
272
|
+
body: JSON.stringify({
|
|
273
|
+
datasetId,
|
|
274
|
+
versionNum,
|
|
275
|
+
}),
|
|
276
|
+
});
|
|
277
|
+
if (!response.ok) {
|
|
278
|
+
throw new Error(`Failed to link dataset: ${await response.text()}`);
|
|
279
|
+
}
|
|
280
|
+
const data = await parseJsonResponse(response, 'App link dataset');
|
|
281
|
+
if (hasJsonFlag()) {
|
|
282
|
+
printJson({ app: data.app, linkedDataset: data.linkedDataset, versionNum: data.versionNum });
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
printLine(`Linked dataset ${sanitizeTerminalText(data.linkedDataset.name)} (${sanitizeTerminalText(data.linkedDataset.id)}) to app ${sanitizeTerminalText(data.app.name)} (${sanitizeTerminalText(data.app.id)}) version ${data.versionNum}`);
|
|
286
|
+
}
|
|
287
|
+
function defaultAppExportFilename(appName, versionNum) {
|
|
288
|
+
const safeName = appName
|
|
289
|
+
.trim()
|
|
290
|
+
.replace(/[^A-Za-z0-9._-]+/g, '_')
|
|
291
|
+
.replace(/^_+|_+$/g, '')
|
|
292
|
+
.slice(0, 100);
|
|
293
|
+
return `${safeName || 'app'}.v${versionNum}.tsx`;
|
|
294
|
+
}
|
|
295
|
+
async function appDetail() {
|
|
296
|
+
const appId = getArg('--app');
|
|
297
|
+
const project = getArg('--project');
|
|
298
|
+
if (!appId) {
|
|
299
|
+
throw new Error('Usage: orizu apps detail --app <appId> [--project <team/project>] [--json]');
|
|
300
|
+
}
|
|
301
|
+
const projectSlug = project || await resolveProjectSlug(null);
|
|
302
|
+
// Single fetch — the apps endpoint already returns full detail (ALI-544)
|
|
303
|
+
const detailResponse = await authedFetch(`/api/cli/apps?project=${encodeURIComponent(projectSlug)}`);
|
|
304
|
+
if (!detailResponse.ok) {
|
|
305
|
+
throw new Error(`Failed to fetch app detail: ${await detailResponse.text()}`);
|
|
306
|
+
}
|
|
307
|
+
const detailData = await parseJsonResponse(detailResponse, 'App detail');
|
|
308
|
+
const detail = detailData.apps.find(a => a.id === appId);
|
|
309
|
+
if (!detail) {
|
|
310
|
+
throw new Error(`App '${appId}' not found in project '${projectSlug}'`);
|
|
311
|
+
}
|
|
312
|
+
if (hasJsonFlag()) {
|
|
313
|
+
printLine(JSON.stringify(detail, null, 2));
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
printLine(`App: ${sanitizeTerminalText(detail.name)} (${sanitizeTerminalText(detail.id)})`);
|
|
317
|
+
printLine(` Project: ${sanitizeTerminalText(`${detail.teamSlug}/${detail.projectSlug}`)}`);
|
|
318
|
+
if (detail.currentVersion) {
|
|
319
|
+
printLine(` Current version: v${detail.currentVersion.versionNum} (${sanitizeTerminalText(detail.currentVersion.versionId)})`);
|
|
320
|
+
printLine(` Input schema: ${detail.currentVersion.inputJsonSchema ? 'defined' : 'none'}`);
|
|
321
|
+
printLine(` Output schema: ${detail.currentVersion.outputJsonSchema ? 'defined' : 'none'}`);
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
printLine(` Current version: none`);
|
|
325
|
+
}
|
|
326
|
+
printLine(` Compatible datasets: ${detail.compatibleDatasetsCount}/${detail.totalDatasetsCount}`);
|
|
327
|
+
if (detail.createdByEmail) {
|
|
328
|
+
printLine(` Created by: ${sanitizeTerminalText(detail.createdByName || detail.createdByEmail)}`);
|
|
329
|
+
}
|
|
330
|
+
printLine(` Created: ${sanitizeTerminalText(detail.createdAt)}`);
|
|
331
|
+
printLine(` Updated: ${sanitizeTerminalText(detail.updatedAt)}`);
|
|
332
|
+
}
|
|
333
|
+
async function exportAppSource() {
|
|
334
|
+
const project = getArg('--project');
|
|
335
|
+
const versionArg = getArg('--version');
|
|
336
|
+
const outPathArg = getArg('--out');
|
|
337
|
+
let appId = getArg('--app');
|
|
338
|
+
const versionNum = versionArg && /^[1-9]\d*$/.test(versionArg)
|
|
339
|
+
? Number.parseInt(versionArg, 10)
|
|
340
|
+
: undefined;
|
|
341
|
+
if (versionArg && versionNum === undefined) {
|
|
342
|
+
throw new Error('--version must be a positive integer');
|
|
343
|
+
}
|
|
344
|
+
if (!appId) {
|
|
345
|
+
const selected = await selectAppIdInteractively(project);
|
|
346
|
+
appId = selected.appId;
|
|
347
|
+
}
|
|
348
|
+
const query = new URLSearchParams();
|
|
349
|
+
if (project) {
|
|
350
|
+
query.set('project', project);
|
|
351
|
+
}
|
|
352
|
+
if (versionNum) {
|
|
353
|
+
query.set('version', String(versionNum));
|
|
354
|
+
}
|
|
355
|
+
const suffix = query.toString() ? `?${query.toString()}` : '';
|
|
356
|
+
const response = await authedFetch(`/api/cli/apps/${encodeURIComponent(appId)}/export${suffix}`);
|
|
357
|
+
if (!response.ok) {
|
|
358
|
+
throw new Error(`Failed to export app (${response.status}): ${await response.text()}`);
|
|
359
|
+
}
|
|
360
|
+
const data = await parseJsonResponse(response, 'App export');
|
|
361
|
+
const filename = outPathArg
|
|
362
|
+
? expandHomePath(outPathArg)
|
|
363
|
+
: defaultAppExportFilename(data.app.name, data.version.versionNum);
|
|
364
|
+
writeTextFileEnsuringDir(filename, data.version.code);
|
|
365
|
+
if (hasJsonFlag()) {
|
|
366
|
+
printJson({
|
|
367
|
+
app: { id: data.app.id, name: data.app.name },
|
|
368
|
+
versionNum: data.version.versionNum,
|
|
369
|
+
savedTo: filename,
|
|
370
|
+
});
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
printLine(`Saved app ${sanitizeTerminalText(data.app.name)} v${data.version.versionNum} source to ${sanitizeTerminalText(filename)}`);
|
|
374
|
+
}
|
|
375
|
+
export { readSourceFile, readJsonFile, readManifestFile, readPromptPrimaryText, readPromptSidecars, stringFromRecord, isRecord, safeRelativePath, writeTextFileEnsuringDir, sha256Hex, readSourceBytes, listApps, createAppFromFile, previewAppFromFile, updateAppFromFile, linkAppDataset, appDetail, exportAppSource, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare function isNodeError(error: unknown): error is NodeJS.ErrnoException;
|
|
2
|
+
export declare function createCodeChallenge(verifier: string): string;
|
|
3
|
+
export declare function validateBrowserUrl(url: string, expectedOrigin?: string): URL;
|
|
4
|
+
export declare function formatTerminalLink(url: string): string;
|
|
5
|
+
declare function shellQuote(value: string): string;
|
|
6
|
+
declare function login(baseUrlOverride?: string): Promise<void>;
|
|
7
|
+
declare function whoami(): Promise<void>;
|
|
8
|
+
declare function logout(baseUrlOverride?: string): Promise<void>;
|
|
9
|
+
declare function printEnv(): Promise<void>;
|
|
10
|
+
export { isNodeError, login, shellQuote, logout, whoami, printEnv };
|
|
11
|
+
//# sourceMappingURL=auth-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-commands.d.ts","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"AA+BA,iBAAS,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,cAAc,CAEnE;AAMD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D;AAQD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,GAAG,CAwB5E;AA6BD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgBtD;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzC;AAwBD,iBAAe,KAAK,CAAC,eAAe,CAAC,EAAE,MAAM,iBAmC5C;AAoHD,iBAAe,MAAM,kBAWpB;AAED,iBAAe,MAAM,CAAC,eAAe,CAAC,EAAE,MAAM,iBA+C7C;AAED,iBAAe,QAAQ,kBA0BtB;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA"}
|