@joripspace/cli 0.8.0 → 0.9.1
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/LICENSE +21 -21
- package/README.md +320 -317
- package/THIRD_PARTY_NOTICES.md +136 -136
- package/lib/checkpoint-client.js +456 -450
- package/lib/deployment-error.js +14 -14
- package/lib/help.js +1 -1
- package/lib/remote-commands.js +393 -373
- package/lib/start-command.js +8 -6
- package/lib/start.js +49 -15
- package/package.json +48 -48
- package/vendor/core/cli-onboarding.cjs +19 -3
- package/vendor/core/github-source.cjs +98 -0
- package/vendor/core/github-workflow.cjs +213 -210
- package/vendor/core/onboarding.cjs +18 -11
- package/vendor/core/template-publish-workflow.cjs +169 -169
- package/vendor/templates/index.js +104 -104
- package/vendor/templates/templates/basic-worker/files/worker.js +9 -9
- package/vendor/templates/templates/basic-worker/manifest.json +14 -14
- package/vendor/templates/templates/r2-file-api/files/worker.js +42 -42
- package/vendor/templates/templates/r2-file-api/manifest.json +7 -7
|
@@ -1,210 +1,213 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
await
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
1
|
+
const { githubSourceSnapshotStep, GITHUB_SOURCE_STAGE_COMMAND } = require('./github-source.cjs');
|
|
2
|
+
|
|
3
|
+
function buildGithubWorkflow({
|
|
4
|
+
projectId,
|
|
5
|
+
branch,
|
|
6
|
+
triggerType = 'branch',
|
|
7
|
+
triggerRef = branch,
|
|
8
|
+
connectionId = 'legacy',
|
|
9
|
+
buildCommand,
|
|
10
|
+
artifactPath,
|
|
11
|
+
entrypoint,
|
|
12
|
+
}) {
|
|
13
|
+
const commands = String(buildCommand)
|
|
14
|
+
.split('\n')
|
|
15
|
+
.map((line) => ` ${line}`)
|
|
16
|
+
.join('\n');
|
|
17
|
+
const deployScript = `${inlineDeployMain.toString()}\n\nawait inlineDeployMain();`
|
|
18
|
+
.split('\n')
|
|
19
|
+
.map((line) => ` ${line}`)
|
|
20
|
+
.join('\n');
|
|
21
|
+
const trigger =
|
|
22
|
+
triggerType === 'release'
|
|
23
|
+
? ` release:\n types:\n - published`
|
|
24
|
+
: ` push:\n branches:\n - ${JSON.stringify(String(triggerRef || branch))}\n workflow_dispatch:`;
|
|
25
|
+
return `# joripspace-workflow-version: 9
|
|
26
|
+
name: JoripSpace Deploy ${JSON.stringify(`(${connectionId})`)}
|
|
27
|
+
|
|
28
|
+
on:
|
|
29
|
+
${trigger}
|
|
30
|
+
|
|
31
|
+
permissions:
|
|
32
|
+
contents: read
|
|
33
|
+
id-token: write
|
|
34
|
+
|
|
35
|
+
concurrency:
|
|
36
|
+
group: ${JSON.stringify(`joripspace-${String(projectId)}-${String(connectionId)}`)}
|
|
37
|
+
cancel-in-progress: true
|
|
38
|
+
|
|
39
|
+
jobs:
|
|
40
|
+
deploy:
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
44
|
+
${githubSourceSnapshotStep()} - name: Build
|
|
45
|
+
run: |
|
|
46
|
+
set -Eeuo pipefail
|
|
47
|
+
trap 'code=$?; echo "::error title=JoripSpace build failed::Build failed at line $LINENO (exit $code)"; exit "$code"' ERR
|
|
48
|
+
${commands}
|
|
49
|
+
- name: Deploy to JoripSpace
|
|
50
|
+
shell: bash
|
|
51
|
+
env:
|
|
52
|
+
JORIPSPACE_PROJECT_ID: ${JSON.stringify(String(projectId))}
|
|
53
|
+
JORIPSPACE_CONNECTION_ID: ${JSON.stringify(String(connectionId))}
|
|
54
|
+
JORIPSPACE_ARTIFACT_PATH: ${JSON.stringify(String(artifactPath))}
|
|
55
|
+
JORIPSPACE_ENTRYPOINT: ${JSON.stringify(String(entrypoint))}
|
|
56
|
+
JORIPSPACE_API_URL: "https://api.joripspace.com"
|
|
57
|
+
run: |
|
|
58
|
+
set -euo pipefail
|
|
59
|
+
source_dir="$JORIPSPACE_ARTIFACT_PATH"
|
|
60
|
+
if [[ ! -d "$source_dir" ]]; then
|
|
61
|
+
echo "::error title=JoripSpace artifact preparation failed::JoripSpace artifact directory does not exist: $source_dir" >&2
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
stage_dir="$RUNNER_TEMP/joripspace-artifact-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
|
|
65
|
+
archive_path="$RUNNER_TEMP/joripspace-artifact-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT.zip"
|
|
66
|
+
rm -rf "$stage_dir"
|
|
67
|
+
mkdir -p "$stage_dir"
|
|
68
|
+
cp -R "$source_dir"/. "$stage_dir"/
|
|
69
|
+
${GITHUB_SOURCE_STAGE_COMMAND}
|
|
70
|
+
JORIPSPACE_STAGE_DIR="$stage_dir" node --input-type=module -e '
|
|
71
|
+
import { writeFile } from "node:fs/promises";
|
|
72
|
+
import { join } from "node:path";
|
|
73
|
+
const root = process.env.JORIPSPACE_STAGE_DIR;
|
|
74
|
+
const entrypoint = process.env.JORIPSPACE_ENTRYPOINT;
|
|
75
|
+
await writeFile(join(root, ".joripspace-deploy.json"), JSON.stringify({ entrypoint }) + "\\n");
|
|
76
|
+
'
|
|
77
|
+
(cd "$stage_dir" && find . -type f -exec zip -q "$archive_path" -- {} +)
|
|
78
|
+
JORIPSPACE_ARCHIVE_PATH="$archive_path" node --input-type=module <<'JORIPSPACE_SCRIPT'
|
|
79
|
+
${deployScript}
|
|
80
|
+
JORIPSPACE_SCRIPT
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function projectGithubActionsTemplateFile(projectConfig = {}) {
|
|
85
|
+
return buildGithubWorkflow({
|
|
86
|
+
projectId: String(projectConfig.project_id || '__JORIPSPACE_PROJECT_ID__'),
|
|
87
|
+
branch: '__JORIPSPACE_BRANCH__',
|
|
88
|
+
buildCommand: '__JORIPSPACE_BUILD_COMMAND__',
|
|
89
|
+
artifactPath: '__JORIPSPACE_ARTIFACT_PATH__',
|
|
90
|
+
entrypoint: '__JORIPSPACE_ENTRYPOINT__',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function inlineDeployMain() {
|
|
95
|
+
const { open } = await import('node:fs/promises');
|
|
96
|
+
const audience = 'https://api.joripspace.com/v1/external-builds/github';
|
|
97
|
+
const projectId = requiredEnv('JORIPSPACE_PROJECT_ID');
|
|
98
|
+
const connectionId = String(process.env.JORIPSPACE_CONNECTION_ID || '').trim();
|
|
99
|
+
const archivePath = requiredEnv('JORIPSPACE_ARCHIVE_PATH');
|
|
100
|
+
const apiUrl = requiredEnv('JORIPSPACE_API_URL').replace(/\/+$/, '');
|
|
101
|
+
const oidcToken = await requestOidcToken();
|
|
102
|
+
const create = await api(`/v1/projects/${encodeURIComponent(projectId)}/checkpoint-uploads`, {
|
|
103
|
+
method: 'POST',
|
|
104
|
+
token: oidcToken,
|
|
105
|
+
json: { source_type: 'deployment' },
|
|
106
|
+
});
|
|
107
|
+
const file = await open(archivePath, 'r');
|
|
108
|
+
try {
|
|
109
|
+
const chunkSize = Number(create.chunk_size || 8 * 1024 * 1024);
|
|
110
|
+
const buffer = Buffer.alloc(chunkSize);
|
|
111
|
+
let partNumber = 1;
|
|
112
|
+
let position = 0;
|
|
113
|
+
while (true) {
|
|
114
|
+
const { bytesRead } = await file.read(buffer, 0, buffer.length, position);
|
|
115
|
+
if (bytesRead === 0) break;
|
|
116
|
+
const partPath = String(create.upload_part_url_template).replace('{part_number}', String(partNumber));
|
|
117
|
+
await api(partPath, {
|
|
118
|
+
method: 'PUT',
|
|
119
|
+
token: oidcToken,
|
|
120
|
+
body: buffer.subarray(0, bytesRead),
|
|
121
|
+
contentType: 'application/octet-stream',
|
|
122
|
+
});
|
|
123
|
+
position += bytesRead;
|
|
124
|
+
partNumber += 1;
|
|
125
|
+
}
|
|
126
|
+
if (position === 0) throw new Error('Build artifact ZIP is empty.');
|
|
127
|
+
} finally {
|
|
128
|
+
await file.close();
|
|
129
|
+
}
|
|
130
|
+
await api(create.complete_url, { method: 'POST', token: oidcToken, json: {} });
|
|
131
|
+
const deployPath = `/v1/projects/${encodeURIComponent(projectId)}/checkpoints/${encodeURIComponent(create.checkpoint_id)}/deploy`;
|
|
132
|
+
for (let attempt = 1; attempt <= 150; attempt += 1) {
|
|
133
|
+
const deployToken = await requestOidcToken();
|
|
134
|
+
const result = await api(deployPath, {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
token: deployToken,
|
|
137
|
+
json: {},
|
|
138
|
+
allowedStatuses: [404, 409],
|
|
139
|
+
});
|
|
140
|
+
if (!result.__retry) {
|
|
141
|
+
process.stdout.write(
|
|
142
|
+
`JoripSpace deployment succeeded: ${result.url || result.default_url || result.deployment_id || projectId}\n`
|
|
143
|
+
);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (
|
|
147
|
+
!['checkpoint_not_found', 'checkpoint_not_ready', 'external_build_deploy_busy'].includes(
|
|
148
|
+
result.error?.code
|
|
149
|
+
)
|
|
150
|
+
) {
|
|
151
|
+
throw apiError(result.__status, result);
|
|
152
|
+
}
|
|
153
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
154
|
+
}
|
|
155
|
+
throw new Error('JoripSpace artifact processing did not finish within 5 minutes.');
|
|
156
|
+
|
|
157
|
+
async function requestOidcToken() {
|
|
158
|
+
const requestUrl = requiredEnv('ACTIONS_ID_TOKEN_REQUEST_URL');
|
|
159
|
+
const requestToken = requiredEnv('ACTIONS_ID_TOKEN_REQUEST_TOKEN');
|
|
160
|
+
const separator = requestUrl.includes('?') ? '&' : '?';
|
|
161
|
+
const response = await fetch(`${requestUrl}${separator}audience=${encodeURIComponent(audience)}`, {
|
|
162
|
+
headers: { Authorization: `Bearer ${requestToken}` },
|
|
163
|
+
});
|
|
164
|
+
const payload = await response.json().catch(() => ({}));
|
|
165
|
+
if (!response.ok || typeof payload.value !== 'string') {
|
|
166
|
+
throw new Error(`GitHub OIDC token request failed (${response.status}).`);
|
|
167
|
+
}
|
|
168
|
+
return payload.value;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function api(path, options) {
|
|
172
|
+
const url = path.startsWith('http') ? path : `${apiUrl}${path}`;
|
|
173
|
+
const headers = new Headers({ Authorization: `Bearer ${options.token}`, Accept: 'application/json' });
|
|
174
|
+
if (connectionId) headers.set('X-JoripSpace-Connection-ID', connectionId);
|
|
175
|
+
let body = options.body;
|
|
176
|
+
if (options.json !== undefined) {
|
|
177
|
+
headers.set('Content-Type', 'application/json');
|
|
178
|
+
body = JSON.stringify(options.json);
|
|
179
|
+
} else if (options.contentType) headers.set('Content-Type', options.contentType);
|
|
180
|
+
const response = await fetch(url, { method: options.method, headers, body });
|
|
181
|
+
const text = await response.text();
|
|
182
|
+
const payload = text ? safeJson(text) : {};
|
|
183
|
+
if (response.ok) return payload;
|
|
184
|
+
if ((options.allowedStatuses || []).includes(response.status)) {
|
|
185
|
+
return { ...payload, __retry: true, __status: response.status };
|
|
186
|
+
}
|
|
187
|
+
throw apiError(response.status, payload);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function apiError(status, payload) {
|
|
191
|
+
const error = new Error(payload?.error?.message || `JoripSpace request failed (${status}).`);
|
|
192
|
+
error.code = payload?.error?.code || 'joripspace_request_failed';
|
|
193
|
+
const diagnostic = JSON.stringify({ http_status: status, code: error.code, message: error.message, details: payload?.error?.details || null })
|
|
194
|
+
.replace(/((?:authorization|[\w-]*(?:key|token|secret|password|credential)[\w-]*)["']?\s*[:=]\s*["']?)[^"'\s,}]+/gi, '$1[REDACTED]')
|
|
195
|
+
.replace(/Bearer\s+[^\s"']+/gi, 'Bearer [REDACTED]').slice(0, 16000);
|
|
196
|
+
console.error(`JORIPSPACE_DIAGNOSTIC ${diagnostic}`);
|
|
197
|
+
return error;
|
|
198
|
+
}
|
|
199
|
+
function safeJson(value) {
|
|
200
|
+
try {
|
|
201
|
+
return JSON.parse(value);
|
|
202
|
+
} catch {
|
|
203
|
+
return { error: { code: 'invalid_response', message: value.slice(0, 500) } };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function requiredEnv(name) {
|
|
207
|
+
const value = process.env[name];
|
|
208
|
+
if (!value) throw new Error(`${name} is required.`);
|
|
209
|
+
return value;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
module.exports = { buildGithubWorkflow, projectGithubActionsTemplateFile };
|
|
@@ -15,7 +15,7 @@ const JORIPSPACE_ONBOARDING_GITIGNORE_ENTRIES = [
|
|
|
15
15
|
'.joripspace/local-backups/',
|
|
16
16
|
];
|
|
17
17
|
const JORIPSPACE_ONBOARDING_GITIGNORE_REMOVALS = ['.joripspace/agent-session.json'];
|
|
18
|
-
const JORIPSPACE_AGENT_GUIDE_UPDATED_AT = '2026-11-
|
|
18
|
+
const JORIPSPACE_AGENT_GUIDE_UPDATED_AT = '2026-11-05T11:51:09Z';
|
|
19
19
|
const JORIPSPACE_WORKFLOW_POLICY = Object.freeze({
|
|
20
20
|
target: 'joripspace',
|
|
21
21
|
guide_required: true,
|
|
@@ -149,7 +149,7 @@ const LOCAL_TOOL_READINESS_RULE_LINES = [
|
|
|
149
149
|
const GUIDE_REFRESH_ONLY_RULE_LINES = [
|
|
150
150
|
'Guide refresh is maintenance-only unless deployment is separately explicit:',
|
|
151
151
|
'- Treat requests whose only intent is "지침 업데이트해", "지침 갱신해", "최신 지침 적용해", "refresh the guide", or equivalent wording as local guide maintenance only. They are not authorization to build, test the application, create a checkpoint, stage files, commit, push, run GitHub Actions, or deploy.',
|
|
152
|
-
'- For a guide-refresh-only request, call prepare_project_workspace with guide_only=true (
|
|
152
|
+
'- For a guide-refresh-only request, call prepare_project_workspace with guide_only=true (or CLI start PROJECT --guide-only --json) and update only the JoripSpace managed block in AGENTS.md, the first-line `@AGENTS.md` import in CLAUDE.md, the canonical `.joripspace/project` marker, plus `JORIPSPACE_GUIDE_CHECKED_AT` in `.env.joripspace`. Preserve user-authored content and unrelated environment entries, and do not modify application source, workflow files, or deployment configuration merely to refresh the guide.',
|
|
153
153
|
'- Do not run create_checkpoint, joripspace:save, deploy_code, deploy_checkpoint, rollback_deployment, git add, git commit, git push, or any deployment workflow for a guide-refresh-only request, even when the project uses GitHub Actions or an automatic deployment route.',
|
|
154
154
|
'- Deployment permission must appear explicitly in the current user request with wording such as "배포해", "운영 반영해", or "사이트에 적용해". A deployment approval from an earlier task or chat message does not carry forward to a later guide refresh.',
|
|
155
155
|
'- If a current request explicitly combines guide refresh with deployment, refresh first, then deploy only the application changes the user explicitly placed in scope after the normal verification gate. Do not manufacture an application deployment merely because managed guide files changed.',
|
|
@@ -314,7 +314,7 @@ const PROJECT_PLAN_LIMIT_LINES = [
|
|
|
314
314
|
'- Unlimited metered usage is OFF by default. On Starter, Pro, and Business, if unlimited metered usage is enabled, quota overage is not blocked and usage continues to be recorded in the billing ledger.',
|
|
315
315
|
'- Monthly overage budget is optional. If the budget is empty, it means no budget cap. If a budget is set, overage is allowed only until the projected monthly amount reaches that cap.',
|
|
316
316
|
'- Active unlimited-metered rates are server/API requests +100,000, realtime messages +100,000, DB storage +0.25GB, file storage +1GB, and realtime concurrent users +50.',
|
|
317
|
-
'- Speed boost is available on Starter, Pro, and Business. It has a
|
|
317
|
+
'- Speed boost is available on Starter, Pro, and Business. It has a 0원 monthly base fee, includes 10GB accelerated traffic, and charges extra accelerated traffic at 200원/GB on every paid plan by bytes_in + bytes_out, meaning 들어온 데이터와 나간 데이터 합산.',
|
|
318
318
|
'- If a Free project tries to add a custom domain, the platform returns plan_required. Explain this as "개인 도메인은 Starter 이상에서 사용할 수 있습니다."',
|
|
319
319
|
'- Paid plans may be selectable during development even before billing automation is fully connected. Do not tell users the selection failed unless the API returns an error.',
|
|
320
320
|
'- User-facing wording: 요금제 제공량을 넘으면 추가 과금 없이 기능이 제한되고 차단 안내 페이지가 표시됩니다.',
|
|
@@ -462,15 +462,14 @@ const CHECKPOINT_AGENT_RULE_LINES = [
|
|
|
462
462
|
const AFTER_CONNECTION_RULE_LINES = [
|
|
463
463
|
'After MCP or CLI setup:',
|
|
464
464
|
...JORIPSPACE_TOOL_SELECTION_LINES,
|
|
465
|
-
|
|
466
|
-
'- If search_knowledge returns no direct match, use its prioritized fallback guidance and ask at most three short business questions. If the knowledge service fails, continue with the built-in JoripSpace guide and explain only when the failure blocks the task.',
|
|
465
|
+
'- If focused searches still return no relevant direct match, use only applicable general fallback guidance and ask at most three short business questions. If the knowledge service fails, continue with the built-in JoripSpace guide and explain only when the failure blocks the task.',
|
|
467
466
|
'- Do not stop with only "yes, it is possible" or a capability checklist.',
|
|
468
467
|
'- Reuse existing valid CLI logins and authenticated MCP sessions without a new approval. New CLI connections use login --no-open --json: show approval_url from stderr, keep the process running, and follow the final stdout next_action/next_command. No code entry is required. For MCP initialize the transport, retain Mcp-Session-Id, and call start_login without arguments; show approval_url, then respect interval and call start_login with the returned request_id in the same session until connected. Continue with start_project_session without token arguments. Pending means wait; denial, expiry and errors must not switch flows or create duplicate approvals. Never request or expose a token; do not browse around or inspect browser storage. The server alone retains old code APIs for already released clients; current clients never fall back to a code flow.',
|
|
469
468
|
'- The user does not need to say "onboarding". After connection succeeds, continue into project selection, workspace file writing, and the first service questions automatically.',
|
|
470
469
|
'- When the CLI cannot be installed or executed, prefer a single start_project_session tool call for the MCP fallback. It combines session lookup, project choice handling, workspace file instructions, and first questions.',
|
|
471
|
-
'- If an MCP response includes workspace_setup.files,
|
|
470
|
+
'- If an MCP response includes workspace_setup.files, apply its write_policy and local_file_operations in the current working folder before replying. Treat AGENTS.md as a managed-block merge, never as a whole-file replacement; preserve existing user instructions and unrelated file content.',
|
|
472
471
|
'- If an MCP response includes local_file_operations, execute those local file writes/appends before replying to the user.',
|
|
473
|
-
'- At the start of every new distinct JoripSpace task,
|
|
472
|
+
'- At the start of every new distinct JoripSpace task, check the server guide through CLI start PROJECT --guide-only --json when advertised by the installed help; otherwise call authenticated MCP prepare_project_workspace with guide_only=true before answering, planning, asking questions, or starting work. Repeat when resuming a session or compacted context, at major phase transitions during long-running work, and immediately before deployment. A new chat does not prove that the local guide is current, and a same-day guide update must not be skipped. Preserve all user instructions, apply only the managed block, and reread AGENTS.md after changes. Do not use cron or ask the user to run a refresh command.',
|
|
474
473
|
'- Compare the returned AGENTS.md managed block and agent_guide.updated_at with the local JoripSpace managed block on every task-start check. When it differs, replace only the JoripSpace block and preserve user-authored content. Keep `@AGENTS.md` as the first unique CLAUDE.md line, validate `.joripspace/project`, and upsert `.env.joripspace` without discarding unrelated entries. Delegate legacy credential migration to the installed CLI without reading or printing credential values; remove a legacy session file only after CLI migration is verified.',
|
|
475
474
|
'- Before application work in a Git-history template project, read `.joripspace/template.json` and use the installed JoripSpace CLI `template pull` check to compare its `git_head_sha` with the latest entitled version. This check must not download a bundle or modify Git. When an update exists, report its version plus the local working-tree state and ask for explicit user approval. Only after approval, rerun the CLI command with `--yes`; it replaces `.git/joripspace/upstream.bundle`, fetches `upstream/main`, and merges the official descendant while preserving the user `origin`. If the user declines, continue without updating. Never pull automatically and never download or merge an update automatically; when there are uncommitted changes, rewritten history, divergence, or likely conflicts, stop and explain the safe next action.',
|
|
476
475
|
'- If the current request is only to update or refresh the guide, follow the shared guide-refresh-only rules. Do not turn that maintenance request into source work, a checkpoint, Git activity, GitHub Actions, or deployment.',
|
|
@@ -712,8 +711,6 @@ function projectManagedAgentsBlock() {
|
|
|
712
711
|
'',
|
|
713
712
|
JORIPSPACE_CLI_GUIDE,
|
|
714
713
|
'',
|
|
715
|
-
'Public onboarding reference: https://api.joripspace.com/onboarding.md',
|
|
716
|
-
'',
|
|
717
714
|
'The JoripSpace project is stored in `.joripspace/project`.',
|
|
718
715
|
'',
|
|
719
716
|
'For CLI sessions: Use the installed JoripSpace CLI for JoripSpace infrastructure, domains, and deployment. Do not configure or wait for MCP. For an existing MCP session, use its advertised tools and the web handoffs described above.',
|
|
@@ -730,8 +727,17 @@ function projectClaudeFile() {
|
|
|
730
727
|
return '@AGENTS.md\n';
|
|
731
728
|
}
|
|
732
729
|
|
|
733
|
-
function
|
|
734
|
-
|
|
730
|
+
function projectAgentGuidance() {
|
|
731
|
+
return {
|
|
732
|
+
schema_version: 1,
|
|
733
|
+
updated_at: JORIPSPACE_AGENT_GUIDE_UPDATED_AT,
|
|
734
|
+
instructions: JORIPSPACE_CLI_GUIDE,
|
|
735
|
+
agents_md: projectAgentsFile(),
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function upsertProjectAgentsContent(existingContent = '', projectConfig = {}, managedBlock) {
|
|
740
|
+
const managed = managedBlock === undefined ? projectManagedAgentsBlock() : managedBlock;
|
|
735
741
|
const existing = String(existingContent || '');
|
|
736
742
|
const markerPairs = [
|
|
737
743
|
['<!-- joripspace:start -->', '<!-- joripspace:end -->'],
|
|
@@ -2420,6 +2426,7 @@ module.exports = {
|
|
|
2420
2426
|
beginnerStartPrompt,
|
|
2421
2427
|
beginnerStartPrompts,
|
|
2422
2428
|
projectAgentsFile,
|
|
2429
|
+
projectAgentGuidance,
|
|
2423
2430
|
projectClaudeFile,
|
|
2424
2431
|
projectMarkerFile,
|
|
2425
2432
|
upsertProjectAgentsContent,
|