@thallylabs/cli 0.5.5 → 0.5.7
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/dist/index.js +60 -9
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -278,7 +278,7 @@ async function runDeploy(args) {
|
|
|
278
278
|
import { readFileSync as readFileSync3 } from "fs";
|
|
279
279
|
import Anthropic from "@anthropic-ai/sdk";
|
|
280
280
|
|
|
281
|
-
// ../agent/dist/chunk-
|
|
281
|
+
// ../agent/dist/chunk-MZM56AWR.js
|
|
282
282
|
import fs from "fs";
|
|
283
283
|
import path3 from "path";
|
|
284
284
|
import { AGENT_BRANCH_PREFIX, DOCS_PREVIEW_LABEL, buildTrackInstruction } from "@thallylabs/mcp/track";
|
|
@@ -289,14 +289,14 @@ function nonEmptyModel(value) {
|
|
|
289
289
|
function resolveAgentModel(explicitModel, configuredModel = process.env.THALLY_AGENT_MODEL, legacyModel = process.env.DOX_AGENT_MODEL) {
|
|
290
290
|
return nonEmptyModel(explicitModel) ?? nonEmptyModel(configuredModel) ?? nonEmptyModel(legacyModel) ?? DEFAULT_AGENT_MODEL;
|
|
291
291
|
}
|
|
292
|
-
var DOCS_AGENT_WORKFLOW_CONTRACT = "thally-track/
|
|
292
|
+
var DOCS_AGENT_WORKFLOW_CONTRACT = "thally-track/v4";
|
|
293
293
|
var DOCS_AGENT_WORKFLOW_TEMPLATE = `# Contract: ${DOCS_AGENT_WORKFLOW_CONTRACT}
|
|
294
294
|
name: Thally docs agent
|
|
295
295
|
|
|
296
296
|
on:
|
|
297
297
|
# A product repo dispatches a docs task here (see the sender workflow).
|
|
298
298
|
repository_dispatch:
|
|
299
|
-
types: [thally-document]
|
|
299
|
+
types: [thally-document, thally-readiness]
|
|
300
300
|
# Run it by hand from the Actions tab.
|
|
301
301
|
workflow_dispatch:
|
|
302
302
|
inputs:
|
|
@@ -314,12 +314,15 @@ on:
|
|
|
314
314
|
- cron: '0 6 * * 1'
|
|
315
315
|
|
|
316
316
|
permissions:
|
|
317
|
-
contents:
|
|
318
|
-
pull-requests: write
|
|
317
|
+
contents: read
|
|
319
318
|
|
|
320
319
|
jobs:
|
|
321
320
|
document:
|
|
322
321
|
if: github.event_name != 'schedule'
|
|
322
|
+
permissions:
|
|
323
|
+
contents: write
|
|
324
|
+
pull-requests: write
|
|
325
|
+
id-token: write
|
|
323
326
|
runs-on: ubuntu-latest
|
|
324
327
|
steps:
|
|
325
328
|
- uses: actions/checkout@v4
|
|
@@ -349,7 +352,13 @@ jobs:
|
|
|
349
352
|
FROM_PR: \${{ github.event.client_payload.from_pr || inputs.from_pr }}
|
|
350
353
|
TRACK_CONTEXT: \${{ github.event.client_payload.context || inputs.context }}
|
|
351
354
|
REQUESTER: \${{ github.event.client_payload.requester }}
|
|
355
|
+
THALLY_PR_GRANT: \${{ github.event.client_payload.thally_pr_grant }}
|
|
356
|
+
THALLY_PR_BRANCH: \${{ github.event.client_payload.thally_pr_branch }}
|
|
357
|
+
THALLY_PR_BROKER_URL: \${{ github.event.client_payload.thally_pr_broker_url || 'https://app.thally.io/api/github/readiness-pr' }}
|
|
352
358
|
run: |
|
|
359
|
+
if [ -n "\${THALLY_PR_GRANT:-}" ]; then
|
|
360
|
+
echo "::add-mask::$THALLY_PR_GRANT"
|
|
361
|
+
fi
|
|
353
362
|
run_thally() {
|
|
354
363
|
if [ -x node_modules/.bin/thally ]; then
|
|
355
364
|
# Existing sites may pin an older CLI that cannot consume the
|
|
@@ -366,14 +375,49 @@ jobs:
|
|
|
366
375
|
if [ -n "$REQUESTER" ]; then
|
|
367
376
|
REQUESTER_ARGS=(--requester "$REQUESTER")
|
|
368
377
|
fi
|
|
378
|
+
OUTPUT_ARGS=(--pr)
|
|
379
|
+
if [ -n "\${THALLY_PR_GRANT:-}" ]; then
|
|
380
|
+
# A readiness repair leaves its validated changes staged. The
|
|
381
|
+
# workflow pushes the pre-granted branch, then asks Cloud to open
|
|
382
|
+
# the PR as the Thally App after GitHub OIDC authentication.
|
|
383
|
+
OUTPUT_ARGS=()
|
|
384
|
+
fi
|
|
369
385
|
if [ -n "$TRACK_CONTEXT" ]; then
|
|
370
386
|
CONTEXT_FILE="$RUNNER_TEMP/thally-track-context.md"
|
|
371
387
|
printf '%s' "$TRACK_CONTEXT" > "$CONTEXT_FILE"
|
|
372
|
-
run_thally agent "$INSTRUCTION" --from-pr "$FROM_PR" --context-file "$CONTEXT_FILE" "\${REQUESTER_ARGS[@]}"
|
|
388
|
+
run_thally agent "$INSTRUCTION" --from-pr "$FROM_PR" --context-file "$CONTEXT_FILE" "\${REQUESTER_ARGS[@]}" "\${OUTPUT_ARGS[@]}"
|
|
373
389
|
elif [ -n "$FROM_PR" ]; then
|
|
374
|
-
run_thally agent "$INSTRUCTION" --from-pr "$FROM_PR" "\${REQUESTER_ARGS[@]}"
|
|
390
|
+
run_thally agent "$INSTRUCTION" --from-pr "$FROM_PR" "\${REQUESTER_ARGS[@]}" "\${OUTPUT_ARGS[@]}"
|
|
375
391
|
else
|
|
376
|
-
run_thally agent "$INSTRUCTION" "\${REQUESTER_ARGS[@]}"
|
|
392
|
+
run_thally agent "$INSTRUCTION" "\${REQUESTER_ARGS[@]}" "\${OUTPUT_ARGS[@]}"
|
|
393
|
+
fi
|
|
394
|
+
if [ -n "\${THALLY_PR_GRANT:-}" ]; then
|
|
395
|
+
GENERATED_BRANCH="$(git branch --show-current)"
|
|
396
|
+
if [[ "$GENERATED_BRANCH" != thally/agent-* ]]; then
|
|
397
|
+
echo "No documentation changes were needed."
|
|
398
|
+
exit 0
|
|
399
|
+
fi
|
|
400
|
+
if [[ ! "$THALLY_PR_BRANCH" =~ ^thally/agent-readiness-[a-f0-9]{16}$ ]]; then
|
|
401
|
+
echo "The readiness PR branch grant is invalid." >&2
|
|
402
|
+
exit 1
|
|
403
|
+
fi
|
|
404
|
+
git branch -m "$THALLY_PR_BRANCH"
|
|
405
|
+
git commit -m "docs: improve Thally Agent Readiness"
|
|
406
|
+
git push -u origin "$THALLY_PR_BRANCH"
|
|
407
|
+
|
|
408
|
+
node -e 'const url = new URL(process.env.THALLY_PR_BROKER_URL); const isProduction = url.origin === "https://app.thally.io"; const isPreview = /^deploy-preview-[0-9]+--thally-cloud\\.netlify\\.app$/.test(url.hostname); if (url.pathname !== "/api/github/readiness-pr" || (!isProduction && !isPreview)) process.exit(1)'
|
|
409
|
+
|
|
410
|
+
OIDC_RESPONSE="$(curl --silent --show-error --fail-with-body -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "\${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=thally-readiness-pr")"
|
|
411
|
+
export OIDC_RESPONSE
|
|
412
|
+
OIDC_TOKEN="$(node -e 'const body = JSON.parse(process.env.OIDC_RESPONSE); if (typeof body.value !== "string") process.exit(1); process.stdout.write(body.value)')"
|
|
413
|
+
unset OIDC_RESPONSE
|
|
414
|
+
echo "::add-mask::$OIDC_TOKEN"
|
|
415
|
+
REQUEST_FILE="$RUNNER_TEMP/thally-readiness-pr-request.json"
|
|
416
|
+
RESPONSE_FILE="$RUNNER_TEMP/thally-readiness-pr-response.json"
|
|
417
|
+
node -e 'require("node:fs").writeFileSync(process.argv[1], JSON.stringify({ grant: process.env.THALLY_PR_GRANT }))' "$REQUEST_FILE"
|
|
418
|
+
curl --silent --show-error --fail-with-body --output "$RESPONSE_FILE" -H "Authorization: Bearer $OIDC_TOKEN" -H "Content-Type: application/json" --data-binary "@$REQUEST_FILE" "$THALLY_PR_BROKER_URL"
|
|
419
|
+
unset OIDC_TOKEN
|
|
420
|
+
node -e 'const body = JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8")); if (typeof body.pull_request_url !== "string") process.exit(1); process.stdout.write("Pull request: " + body.pull_request_url + "\\n")' "$RESPONSE_FILE"
|
|
377
421
|
fi
|
|
378
422
|
|
|
379
423
|
drift-sweep:
|
|
@@ -5906,6 +5950,13 @@ function buildRepairPrompt(errors) {
|
|
|
5906
5950
|
function buildPullRequestCreateArgs(title, body, branch, baseBranch) {
|
|
5907
5951
|
return ["pr", "create", "--title", title, "--body", body, "--head", branch, "--base", baseBranch];
|
|
5908
5952
|
}
|
|
5953
|
+
function buildPullRequestTitle(instruction) {
|
|
5954
|
+
const normalizedInstruction = instruction.replace(/\s+/g, " ").trim();
|
|
5955
|
+
if (!normalizedInstruction) return "docs: update documentation";
|
|
5956
|
+
const maxSummaryLength = 65;
|
|
5957
|
+
const summary = normalizedInstruction.length > maxSummaryLength ? `${normalizedInstruction.slice(0, maxSummaryLength).trimEnd()}\u2026` : normalizedInstruction;
|
|
5958
|
+
return `docs: ${summary}`;
|
|
5959
|
+
}
|
|
5909
5960
|
async function runAgent(client, task, options) {
|
|
5910
5961
|
const { projectDir, mode } = options;
|
|
5911
5962
|
const model = resolveAgentModel(options.model);
|
|
@@ -5973,7 +6024,7 @@ async function runAgent(client, task, options) {
|
|
|
5973
6024
|
return { branch, summary, steps, diff, validation, noChanges: false };
|
|
5974
6025
|
}
|
|
5975
6026
|
if (mode === "pr") {
|
|
5976
|
-
const title =
|
|
6027
|
+
const title = buildPullRequestTitle(task.instruction);
|
|
5977
6028
|
const body = `${summary}
|
|
5978
6029
|
|
|
5979
6030
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thallylabs/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "The unified thally CLI — author content + config; the framework stays a hidden runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
27
|
-
"@thallylabs/mcp": "0.7.
|
|
28
|
-
"create-thally-docs": "0.7.
|
|
27
|
+
"@thallylabs/mcp": "0.7.5",
|
|
28
|
+
"create-thally-docs": "0.7.9"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@thallylabs/agent": "*",
|