@joripspace/cli 0.5.7 → 0.6.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 +38 -9
- package/bin/joripspace.js +46 -49
- package/lib/auth-redaction.js +1 -0
- package/lib/checkpoint-client.js +15 -2
- package/lib/connection-persistence.js +36 -0
- package/lib/credential-store.js +2 -2
- package/lib/deploy-files.js +5 -11
- package/lib/help.js +9 -4
- package/lib/remote-commands.js +3 -42
- package/lib/secret-commands.js +96 -0
- package/lib/start.js +2 -0
- package/lib/template-commands.js +15 -9
- package/package.json +1 -1
- package/vendor/core/auth-redaction.cjs +21 -0
- package/vendor/core/cli-onboarding.cjs +10 -2
- package/vendor/core/onboarding.cjs +2434 -2433
package/lib/template-commands.js
CHANGED
|
@@ -4,6 +4,8 @@ const os = require('node:os');
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const { spawnSync } = require('node:child_process');
|
|
6
6
|
const zlib = require('node:zlib');
|
|
7
|
+
const { redactAuthError } = require('./auth-redaction');
|
|
8
|
+
const responseAuthSecrets = new WeakMap();
|
|
7
9
|
const {
|
|
8
10
|
assertNonOverlappingFilePlan,
|
|
9
11
|
resolveProjectFileTarget,
|
|
@@ -122,12 +124,7 @@ function createTemplateCommands(deps) {
|
|
|
122
124
|
{ method: 'GET', headers }
|
|
123
125
|
);
|
|
124
126
|
if (!response.ok) {
|
|
125
|
-
|
|
126
|
-
let parsed = {};
|
|
127
|
-
try {
|
|
128
|
-
parsed = text ? JSON.parse(text) : {};
|
|
129
|
-
} catch {}
|
|
130
|
-
throw new Error(parsed?.error?.message || parsed?.message || text || `HTTP ${response.status}`);
|
|
127
|
+
throw await fetchError(response);
|
|
131
128
|
}
|
|
132
129
|
const template = parseArchive(Buffer.from(await response.arrayBuffer()));
|
|
133
130
|
writeFiles(targetDir, template.files, deps.booleanFlag(flags, 'force'));
|
|
@@ -240,14 +237,21 @@ async function downloadBundleGrant(apiUrl, headers, templateSlug, project) {
|
|
|
240
237
|
}
|
|
241
238
|
|
|
242
239
|
async function timedFetch(url, options, timeoutMs = 25_000) {
|
|
240
|
+
const authorization = new Headers(options.headers).get('authorization');
|
|
241
|
+
const secrets = authorization ? [authorization, authorization.replace(/^Bearer\s+/i, '')] : [];
|
|
243
242
|
const controller = new AbortController();
|
|
244
243
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
245
244
|
try {
|
|
246
|
-
|
|
245
|
+
const response = await fetch(url, {
|
|
246
|
+
...options, signal: controller.signal,
|
|
247
|
+
...(authorization ? { redirect: 'error' } : {}),
|
|
248
|
+
});
|
|
249
|
+
responseAuthSecrets.set(response, secrets);
|
|
250
|
+
return response;
|
|
247
251
|
} catch (error) {
|
|
248
252
|
if (error?.name === 'AbortError')
|
|
249
253
|
throw new Error(`template request timed out after ${Math.round(timeoutMs / 1000)} seconds`);
|
|
250
|
-
throw error;
|
|
254
|
+
throw new Error(redactAuthError(error instanceof Error ? error.message : String(error), secrets));
|
|
251
255
|
} finally {
|
|
252
256
|
clearTimeout(timer);
|
|
253
257
|
}
|
|
@@ -699,7 +703,9 @@ async function fetchError(response) {
|
|
|
699
703
|
try {
|
|
700
704
|
parsed = text ? JSON.parse(text) : {};
|
|
701
705
|
} catch {}
|
|
702
|
-
|
|
706
|
+
const secrets = responseAuthSecrets.get(response) || [];
|
|
707
|
+
const safe = redactAuthError(parsed, secrets);
|
|
708
|
+
return new Error(safe?.error?.message || safe?.message || redactAuthError(text, secrets) || `HTTP ${response.status}`);
|
|
703
709
|
}
|
|
704
710
|
|
|
705
711
|
function parseArchive(archive) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function redactAuthError(value, secrets = []) {
|
|
4
|
+
const values = [...new Set(secrets.filter((secret) => typeof secret === 'string' && secret))].sort(
|
|
5
|
+
(left, right) => right.length - left.length,
|
|
6
|
+
);
|
|
7
|
+
function redact(item) {
|
|
8
|
+
if (typeof item === 'string') {
|
|
9
|
+
for (const secret of values) item = item.split(secret).join('[REDACTED]');
|
|
10
|
+
return item;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(item)) return item.map(redact);
|
|
13
|
+
if (item && typeof item === 'object') {
|
|
14
|
+
return Object.fromEntries(Object.entries(item).map(([key, entry]) => [redact(key), redact(entry)]));
|
|
15
|
+
}
|
|
16
|
+
return item;
|
|
17
|
+
}
|
|
18
|
+
return redact(value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { redactAuthError };
|
|
@@ -12,9 +12,10 @@ const JORIPSPACE_CLI_GUIDE = [
|
|
|
12
12
|
'Use the project name supplied by the user. The connection flow does not create a missing project. Use the current Git root when one exists, otherwise the current working directory; use --cwd to specify the intended workspace. Never use the npm cache or package installation folder as the project workspace.',
|
|
13
13
|
"Only when the user explicitly requests a new Free project, run create --name NAME --json. Present every returned agreement faithfully in the user's language, link to the terms, and obtain explicit consent before passing --agree-noncommercial --agree-billing --agree-retention. Never infer agreement from the creation request. start never creates a project, and create does not link the workspace. If creation state is unknown, list projects and check the name before retrying.",
|
|
14
14
|
'The JoripSpace project is stored in `.joripspace/project`. Resolve different or invalid markers, symlinks, and conflicting local work without overwriting user files.',
|
|
15
|
-
'Use the installed JoripSpace CLI for JoripSpace infrastructure, domains, and deployment. Do not configure or wait for MCP. Existing MCP integrations remain available for users who choose that workflow; this start session continues through the CLI.',
|
|
15
|
+
'For CLI sessions: Use the installed JoripSpace CLI for JoripSpace infrastructure, domains, and deployment. Do not configure or wait for MCP. Existing MCP integrations remain available for users who choose that workflow; this start session continues through the CLI.',
|
|
16
|
+
'For an existing MCP session, use the tools advertised by that connection. create_project creates only Free projects after explicit confirmation and all returned agreements; start_project_session connects an existing project. MCP supports DB, storage, deployment, checkpoints, domains, crons, mail, realtime, and value-blind Secret generation/listing. For direct Secret registration/replacement, show the selected project Secret web page and ask the user to enter the value there. MCP and CLI credentials are separate; do not assume an OS CLI login authenticates MCP or copy tokens between client configurations.',
|
|
16
17
|
'When start returns connection_required, show connect_url as a clickable link, ask the user to approve the connection and provide the five-minute one-time code, then execute login_command and resume_command. A successful connection also logs in; do not add a separate login step. Never request or print the exchanged token. Reuse the existing connection on later runs. Use logout to remove the current local login without revoking server tokens.',
|
|
17
|
-
'New CLI logins
|
|
18
|
+
'New CLI logins prefer the OS credential store and reuse it across project folders for the same OS user. When that store is available, `.env.joripspace` keeps only the API URL and account reference. If the OS store is unavailable before writing, login saves the token in the project-local `.env.joripspace` instead; that fallback is reused only in this project. Failed OS writes or readback verification do not trigger fallback. Older CLI versions and existing token-bearing `.env.joripspace` files remain supported; keep that file Git-ignored and excluded from deployments and checkpoints. logout removes saved project tokens and the matching OS-stored account credential. OS logins are shared across project folders, including folders where logout was previously run. Do not copy credentials into documents, skills, logs, or source code.',
|
|
18
19
|
'',
|
|
19
20
|
'## Execute commands reliably',
|
|
20
21
|
'',
|
|
@@ -48,8 +49,15 @@ const JORIPSPACE_CLI_GUIDE = [
|
|
|
48
49
|
"After connecting, continue the user's existing request. If the user only asked to start, report the connection and relevant next step; do not invent an app or deploy unchanged files just to complete onboarding. Clarify missing requirements with short questions and concrete choices.",
|
|
49
50
|
'Use normal local tools to inspect source, install project dependencies, build, test, and verify requested behavior. Preserve user edits and project structure. Read actual project scripts and CLI help for the matching deployment path. Do not invent setup or init commands or change infrastructure providers.',
|
|
50
51
|
'Before deployment, inspect runtime imports. When source imports package dependencies, run the project build and deploy its generated bundled Worker entrypoint such as dist/worker.js. Never deploy an unbundled source entrypoint that depends on excluded node_modules.',
|
|
52
|
+
'Directory deployment applies root .gitignore, .ignore, .joripspaceignore and nested .gitignore rules to both small inline uploads and chunked archives. Ignored credentials and protected connection files are excluded in both paths. If the build output is ignored in the project root, select the build output directory with --dir instead of removing credential ignore rules.',
|
|
51
53
|
'Respect the deployment mode returned by the project. With an active GitHub deployment connection, follow its configured branch and trigger. Otherwise use the existing CLI deployment/checkpoint commands. Do not create GitHub Actions workflows merely to deploy an unconnected project. Store external provider secrets in project Secret bindings through the existing authorized flow, never in application source.',
|
|
54
|
+
'When GitHub connection is requested, show https://joripspace.com/projects/PROJECT/?tab=deployment as a clickable link with the selected project slug. The user connects the GitHub App and selects the repository and trigger on that page. Keep the existing GitHub Actions workflow. An authorized agent push to the configured branch triggers automatic deployment for a branch-push connection; follow the configured release trigger for release deployments. Check project status and deployment history afterward.',
|
|
52
55
|
'When development and deployment are requested, verify the build, deploy through JoripSpace, and check the production URL before reporting completion. Report the URL, actual verification, and any unresolved failure. If a response is lost, inspect deployment state before retrying a mutation. For transient reads, follow retryable and retry-after information with bounded backoff. Do not blindly retry authentication, permission, conflict, or invalid-input failures.',
|
|
56
|
+
'',
|
|
57
|
+
'## Project secrets',
|
|
58
|
+
'',
|
|
59
|
+
'Use secret generate --name NAME --json to create an internal random secret without seeing its value. It preserves an existing active secret. Use secret set --name NAME --value-stdin --json (alias: secret update) to create or replace a binding with an authorized value from an external server, provider, or system. Pass the exact UTF-8 bytes through process standard input, never command arguments, chat, logs, source, or temporary project files. No secret value is returned. set/update both create or replace; deleting a secret remains a web operation.',
|
|
60
|
+
'The start onboarding object and secret list/generate/set/update results include secret_management_url for the selected project. Include this as a clickable link when reporting creation or replacement, and whenever the user needs to enter or change a value. Explain the exact key name and purpose in the user\'s language. If the user must enter a provider-issued value, ask them to enter it on that page and click Register or replace, then verify the name, status, and updated_at with secret list --json. Do not ask for secret values in chat. Perform the relevant connection check before reporting that an integration works.',
|
|
53
61
|
].join('\n');
|
|
54
62
|
|
|
55
63
|
const JORIPSPACE_NPM_ONBOARDING_DOCUMENT = [
|