mirror of
https://github.com/logseq/logseq.git
synced 2026-05-24 20:54:09 +00:00
dev(skill): remove logseq-task-on-lambda
This commit is contained in:
@@ -1,113 +0,0 @@
|
||||
---
|
||||
name: logseq-task-on-lambda
|
||||
description: Use when Codex needs to execute or continue a task described by a Logseq block in the Lambda RTC graph. The request may provide a block UUID directly or as a double-bracket UUID reference; when no UUID is provided, discover TODO tasks from today's Journal Page, ask the user which one to run, and then continue with the selected UUID. This skill validates sync state, fetches the target block tree with the Logseq CLI, handles in-review tasks with TODO #agent-steer guidance blocks, and then completes the task described by the active block tree.
|
||||
---
|
||||
|
||||
# Logseq Task On Lambda
|
||||
|
||||
Use one block in the `Lambda RTC` graph as the current task brief. The parent agent owns every `Lambda RTC` read, write, sync gate, selection prompt, and orchestration step. Load `.agents/skills/logseq-cli/SKILL.md` in the parent before running any ad hoc `logseq` command against `Lambda RTC`.
|
||||
|
||||
If the task explicitly requests a pull request, load the matching GitHub publishing skill for the current environment before staging, committing, pushing, or opening a PR.
|
||||
|
||||
## Selection and Fetch Scripts
|
||||
|
||||
When the user does not provide a UUID, run `.agents/skills/logseq-task-on-lambda/scripts/list-today-todo-tasks.sh` from the repo root. Pass no arguments.
|
||||
|
||||
The list script targets only `Lambda RTC`, starts sync at most once, waits up to 20 seconds for `ws-state=open`, `pending-local=0`, and `pending-server=0`, queries TODO tasks whose `:block/page` is today's Journal Page, validates the structured query result, prints numbered candidates with UUIDs, then runs `logseq show --graph "Lambda RTC" --uuid "$uuid" --level 100` for every candidate and prints each full block tree to stdout. It prints the journal day plus sync gate summary to stderr. Stop on any non-zero exit status. If no TODO tasks are found, report that and stop unless the user provides a UUID.
|
||||
|
||||
Run `.agents/skills/logseq-task-on-lambda/scripts/fetch-task-block.sh UUID_OR_DOUBLE_BRACKET_UUID` from the repo root. Pass exactly one bare UUID or one double-bracket UUID reference.
|
||||
|
||||
The script validates the input, targets only `Lambda RTC`, starts sync at most once, waits up to 20 seconds for `ws-state=open`, `pending-local=0`, and `pending-server=0`, validates the structured `show` result, prints the human block tree to stdout, and prints the normalized UUID plus sync gate summary to stderr. Stop on any non-zero exit status. Do not fetch block content before this script succeeds.
|
||||
|
||||
## Shared Write Rules
|
||||
|
||||
For every parent-owned `Lambda RTC` write:
|
||||
|
||||
- Re-run the sync gate immediately before writing and follow `logseq-cli` write rules.
|
||||
- Use the normalized UUID reported by the fetch script unless the step names a preserved child UUID.
|
||||
- Stop on command errors, ambiguous targets, invalid JSON, missing blocks, sync timeout, non-idle sync state, or non-actionable task briefs.
|
||||
- Never substitute another graph, block, page, db id, or query result.
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Resolve the task UUID and fetch the task block tree.
|
||||
- If the request includes one UUID, accept only bare form, such as `11111111-1111-1111-1111-111111111111`, or double-bracket form, such as `[[11111111-1111-1111-1111-111111111111]]`.
|
||||
- If the request includes no UUID, run the list script, present the numbered TODO task candidates to the user, and ask which task to solve. Accept only one listed index or one listed UUID from the user's answer.
|
||||
- Reject page names, db ids, block refs with extra text, multiple UUIDs, malformed UUIDs, empty answers, and answers that do not select exactly one listed task.
|
||||
- After resolving one UUID, run the fetch script and treat stdout as the complete root block tree.
|
||||
- Read stderr for `normalized-uuid` and `sync-gate`.
|
||||
|
||||
2. Select the active task brief.
|
||||
- If the fetched root task is not `in-review`, use the fetched root block tree as the brief.
|
||||
- If the root task is `in-review`, continue only from child block-trees whose root block has both `#agent-steer` and `TODO`.
|
||||
- Preserve every selected `#agent-steer` TODO UUID for later status updates.
|
||||
- If the fetched text does not expose the needed steer UUIDs or task statuses, re-run the sync gate and perform the smallest structured `logseq` read needed to identify them.
|
||||
- Stop if an `in-review` task has no actionable `#agent-steer` TODO block-tree or the matches are ambiguous.
|
||||
|
||||
3. Move the root task to `doing`.
|
||||
- Run `logseq upsert task --graph "Lambda RTC" --uuid "$normalized_uuid" --status doing`.
|
||||
- Stop if the root block cannot be updated as a task.
|
||||
|
||||
4. Record `Reproducible?` for bug and regression tasks.
|
||||
- For clear bug or regression tasks, set the root block property to exactly one string choice: `Not sure`, `Yes`, or `No`.
|
||||
- Use `Yes` when reproduced, `No` when reproduction was actively attempted and failed, and `Not sure` when reproduction was not attempted or evidence is insufficient.
|
||||
- If unknown before implementation, write `Not sure` first and update it before the completion summary if later evidence changes the answer.
|
||||
- Use `logseq upsert block --graph "Lambda RTC" --uuid "$normalized_uuid" --update-properties "{\"Reproducible?\" \"$reproducible_value\"}"`.
|
||||
- Skip idea and enhancement tasks. Stop if a clear bug or regression task cannot be updated with one exact choice.
|
||||
|
||||
5. Delegate implementation to a worker subagent.
|
||||
- Spawn a worker subagent; do not complete this step locally.
|
||||
- Keep all `Lambda RTC` graph work in the parent, including fetches, sync gates, status updates, `Reproducible?`, PR metadata writes, completion summaries, completed steer status updates, and final `in-review`.
|
||||
- Give the worker the active brief, full fetched block tree, normalized UUID, repo path, branch/worktree state, and the parent/worker boundary.
|
||||
- Require the worker to load task-required skills in its own context, including skills named by `agent-skills`, repo-local skills required by touched files, and `.agents/skills/logseq-cli/SKILL.md` only when the task itself needs non-`Lambda RTC` Logseq CLI work.
|
||||
- Instruct the worker to avoid all `Lambda RTC` reads, writes, syncs, and communication; report any needed `Lambda RTC` operation back to the parent.
|
||||
- Instruct the worker to follow the active brief, respect repo `AGENTS.md`, preserve others' edits, and avoid assumptions from the UUID or graph name.
|
||||
- Require the final report to list loaded skills, files changed, non-`Lambda RTC` Logseq CLI operations, requested `Lambda RTC` operations, verification, completed `#agent-steer` UUIDs, and blockers.
|
||||
- Stop if the worker cannot be spawned, touches `Lambda RTC`, skips required skills, returns an ambiguous result, or reports that the task is not actionable.
|
||||
|
||||
6. Close handled `#agent-steer` guidance.
|
||||
- Only for roots that started as `in-review`, mark every completed selected steer block as `done` before adding the completion summary.
|
||||
- Use `logseq upsert task --graph "Lambda RTC" --uuid "$agent_steer_uuid" --status done`.
|
||||
- Mark only steer blocks whose instructions were actually completed. Stop if any handled steer block cannot be updated as a task.
|
||||
|
||||
7. Create a PR only when explicitly requested.
|
||||
- Default to no PR.
|
||||
- If requested, generate the PR title and branch name after implementation and before staging. Follow `feat|enhance|fix(<module>): <short description>` and use a lowercase `codex/` branch unless the user asked otherwise.
|
||||
- Use `fix` for bug or regression tasks, `enhance` for improvements to existing behavior, and `feat` for new behavior.
|
||||
- For bug or regression tasks with an existing GitHub issue URL, preserve the issue URL before writing any PR URL and include `fix $github_issue_url` in the commit message.
|
||||
- Follow the loaded GitHub publishing workflow; prefer a draft PR unless the task asks for ready.
|
||||
- After PR creation, update the root block property with `logseq upsert block --graph "Lambda RTC" --uuid "$normalized_uuid" --update-properties "{\"GitHub Url\" \"$pr_url\"}"`.
|
||||
- Stop if explicit PR creation cannot be completed safely or a created PR cannot be recorded in `GitHub Url`.
|
||||
|
||||
8. Add a completion summary.
|
||||
- Before final status change, create a `Summary:` child block with `logseq upsert block --graph "Lambda RTC" --target-uuid "$normalized_uuid" --content "Summary:"`.
|
||||
- Write a proportional Markdown outline block tree with useful sections such as `Outcome`, `Changes`, `Verification`, `PR`, `Evidence`, `How It Works`, `Edge Cases and Open Questions`, or `Practical Takeaways`.
|
||||
- Include concrete file paths, namespaces, commands, runtime surfaces, observed behavior, and verification results when useful.
|
||||
- Use Markdown backticks for code symbols, namespaces, file paths, commands, properties, keywords, and literal values.
|
||||
- Do not write a vague single-block summary and do not include the PR URL in the summary child block.
|
||||
- Stop if the summary block cannot be created.
|
||||
|
||||
9. Move the root task to `in-review`.
|
||||
- Run `logseq upsert task --graph "Lambda RTC" --uuid "$normalized_uuid" --status in-review`.
|
||||
- Stop if the root block cannot be updated as a task.
|
||||
|
||||
10. Report the result.
|
||||
- Include the normalized UUID and sync gate values: `ws-state`, `pending-local`, and `pending-server`.
|
||||
- If the UUID was selected from today's Journal Page, state which listed task was selected.
|
||||
- State that the root moved to `doing`, a completion summary was added, and the root moved to `in-review`.
|
||||
- State that step 5 was completed by a worker subagent, list the worker-reported skills, and confirm the parent handled all `Lambda RTC` graph interactions.
|
||||
- Report selected `#agent-steer` TODO UUIDs moved to `done`, or state that no steer guidance was completed.
|
||||
- Report the `Reproducible?` choice for bug or regression tasks, or state that it was skipped.
|
||||
- If a PR was created, include the PR URL, confirm `GitHub Url` was updated, and for linked bug/regression issues confirm the commit message mentioned `fix $github_issue_url`.
|
||||
- Summarize the outcome and verification performed.
|
||||
|
||||
## Hard Stops
|
||||
|
||||
- Never fetch the selected block tree before the fetch script reports a passed sync gate.
|
||||
- Never run no-UUID discovery from anywhere except today's Journal Page TODO list in `Lambda RTC` after the list script reports a passed sync gate.
|
||||
- Never redo a whole `in-review` root task when actionable `#agent-steer` TODO guidance exists.
|
||||
- Never create a PR unless the active task brief or current user request explicitly asks for one.
|
||||
- Never leave a created PR unrecorded on the root block's `GitHub Url` property.
|
||||
- Never set `Reproducible?` for idea or enhancement tasks, use boolean values, or skip it for a clear bug or regression task.
|
||||
- Never delegate `Lambda RTC` graph reads, writes, sync gates, or orchestration writes to the worker.
|
||||
- Never skip the `doing` status write, completion summary child block, or final `in-review` status write after successful completion.
|
||||
@@ -1,4 +0,0 @@
|
||||
interface:
|
||||
display_name: "Logseq Task On Lambda"
|
||||
short_description: "Run Lambda RTC block-described tasks"
|
||||
default_prompt: "Use $logseq-task-on-lambda to run a Lambda RTC task; if no UUID is provided, list today's TODO tasks and ask me which one to solve."
|
||||
@@ -1,165 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
GRAPH_NAME="Lambda RTC"
|
||||
TIMEOUT_SECONDS=20
|
||||
LOGSEQ_BIN="${LOGSEQ_BIN:-logseq}"
|
||||
|
||||
fail() {
|
||||
printf 'error: %s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat >&2 <<'EOF'
|
||||
Usage: fetch-task-block.sh UUID_OR_DOUBLE_BRACKET_UUID
|
||||
|
||||
Fetch one task block tree from the Lambda RTC graph after verifying that
|
||||
sync is open and idle.
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
usage
|
||||
fail "expected exactly one UUID argument"
|
||||
fi
|
||||
|
||||
input="$(printf '%s' "$1" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')"
|
||||
uuid_pattern='[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'
|
||||
|
||||
if [[ "$input" =~ ^\[\[($uuid_pattern)\]\]$ ]]; then
|
||||
uuid="${BASH_REMATCH[1],,}"
|
||||
elif [[ "$input" =~ ^($uuid_pattern)$ ]]; then
|
||||
uuid="${BASH_REMATCH[1],,}"
|
||||
else
|
||||
fail "expected one bare UUID or one double-bracket UUID reference"
|
||||
fi
|
||||
|
||||
assess_sync_status() {
|
||||
node -e '
|
||||
const fs = require("fs");
|
||||
|
||||
function fail(message) {
|
||||
console.error(message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(fs.readFileSync(0, "utf8"));
|
||||
} catch (error) {
|
||||
fail(`sync status did not return valid JSON: ${error.message}`);
|
||||
}
|
||||
|
||||
if (payload.status !== "ok") {
|
||||
fail(`sync status returned non-ok status: ${JSON.stringify(payload)}`);
|
||||
}
|
||||
|
||||
const data = payload.data;
|
||||
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
||||
fail("sync status missing object data");
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(data, "last-error") && data["last-error"] != null) {
|
||||
fail(`sync status reports last-error: ${JSON.stringify(data["last-error"])}`);
|
||||
}
|
||||
|
||||
const wsState = data["ws-state"];
|
||||
const graphId = data["graph-id"];
|
||||
|
||||
if (wsState !== "open" || typeof graphId !== "string" || graphId.length === 0) {
|
||||
console.log("need-start");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const pendingLocal = data["pending-local"];
|
||||
const pendingServer = data["pending-server"];
|
||||
if (typeof pendingLocal !== "number" || !Number.isFinite(pendingLocal)) {
|
||||
fail("sync status pending-local must be a number");
|
||||
}
|
||||
if (typeof pendingServer !== "number" || !Number.isFinite(pendingServer)) {
|
||||
fail("sync status pending-server must be a number");
|
||||
}
|
||||
|
||||
const state = pendingLocal === 0 && pendingServer === 0 ? "complete" : "pending";
|
||||
console.log([state, wsState, pendingLocal, pendingServer].join("\t"));
|
||||
'
|
||||
}
|
||||
|
||||
validate_show_json() {
|
||||
node -e '
|
||||
const fs = require("fs");
|
||||
|
||||
function fail(message) {
|
||||
console.error(message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(fs.readFileSync(0, "utf8"));
|
||||
} catch (error) {
|
||||
fail(`show did not return valid JSON: ${error.message}`);
|
||||
}
|
||||
|
||||
if (payload.status !== "ok") {
|
||||
fail(`show returned non-ok status: ${JSON.stringify(payload)}`);
|
||||
}
|
||||
|
||||
const root = payload.data && payload.data.root;
|
||||
if (!root || typeof root !== "object" || Array.isArray(root)) {
|
||||
fail("show returned no root block");
|
||||
}
|
||||
|
||||
if (typeof root["block/title"] !== "string" || root["block/title"].length === 0) {
|
||||
fail("show root block has no block/title content");
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
run_status() {
|
||||
"$LOGSEQ_BIN" sync status --graph "$GRAPH_NAME" --output json
|
||||
}
|
||||
|
||||
status_json="$(run_status)" || fail "sync status command failed"
|
||||
assessment="$(printf '%s' "$status_json" | assess_sync_status)" || fail "sync status returned invalid state"
|
||||
|
||||
if [[ "$assessment" == "need-start" ]]; then
|
||||
"$LOGSEQ_BIN" sync start --graph "$GRAPH_NAME" >/dev/null || fail "sync start command failed"
|
||||
fi
|
||||
|
||||
deadline=$((SECONDS + TIMEOUT_SECONDS))
|
||||
while true; do
|
||||
status_json="$(run_status)" || fail "sync status command failed"
|
||||
assessment="$(printf '%s' "$status_json" | assess_sync_status)" || fail "sync status returned invalid state"
|
||||
|
||||
if [[ "$assessment" == complete$'\t'* ]]; then
|
||||
IFS=$'\t' read -r _ ws_state pending_local pending_server <<<"$assessment"
|
||||
printf 'normalized-uuid: %s\n' "$uuid" >&2
|
||||
printf 'sync-gate: ws-state=%s pending-local=%s pending-server=%s\n' \
|
||||
"$ws_state" "$pending_local" "$pending_server" >&2
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ "$assessment" == "need-start" ]]; then
|
||||
fail "sync did not open after sync start"
|
||||
fi
|
||||
|
||||
if (( SECONDS >= deadline )); then
|
||||
fail "sync status polling timed out before queues settled"
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
show_json="$("$LOGSEQ_BIN" show --graph "$GRAPH_NAME" --uuid "$uuid" --level 100 --output json)" \
|
||||
|| fail "show command failed"
|
||||
printf '%s' "$show_json" | validate_show_json || fail "show returned invalid block tree"
|
||||
|
||||
human_output="$("$LOGSEQ_BIN" show --graph "$GRAPH_NAME" --uuid "$uuid" --level 100)" \
|
||||
|| fail "show command failed"
|
||||
if [[ -z "$human_output" ]]; then
|
||||
fail "show returned empty block tree"
|
||||
fi
|
||||
|
||||
printf '%s\n' "$human_output"
|
||||
@@ -1,213 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
GRAPH_NAME="Lambda RTC"
|
||||
TIMEOUT_SECONDS=20
|
||||
LOGSEQ_BIN="${LOGSEQ_BIN:-logseq}"
|
||||
|
||||
fail() {
|
||||
printf 'error: %s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat >&2 <<'EOF'
|
||||
Usage: list-today-todo-tasks.sh
|
||||
|
||||
List TODO task blocks from today's Journal Page in the Lambda RTC graph after
|
||||
verifying that sync is open and idle.
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ $# -ne 0 ]]; then
|
||||
usage
|
||||
fail "expected no arguments"
|
||||
fi
|
||||
|
||||
today_journal_day="$(
|
||||
node -e '
|
||||
const now = new Date();
|
||||
const yyyy = String(now.getFullYear());
|
||||
const mm = String(now.getMonth() + 1).padStart(2, "0");
|
||||
const dd = String(now.getDate()).padStart(2, "0");
|
||||
console.log(`${yyyy}${mm}${dd}`);
|
||||
'
|
||||
)"
|
||||
|
||||
assess_sync_status() {
|
||||
node -e '
|
||||
const fs = require("fs");
|
||||
|
||||
function fail(message) {
|
||||
console.error(message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(fs.readFileSync(0, "utf8"));
|
||||
} catch (error) {
|
||||
fail(`sync status did not return valid JSON: ${error.message}`);
|
||||
}
|
||||
|
||||
if (payload.status !== "ok") {
|
||||
fail(`sync status returned non-ok status: ${JSON.stringify(payload)}`);
|
||||
}
|
||||
|
||||
const data = payload.data;
|
||||
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
||||
fail("sync status missing object data");
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(data, "last-error") && data["last-error"] != null) {
|
||||
fail(`sync status reports last-error: ${JSON.stringify(data["last-error"])}`);
|
||||
}
|
||||
|
||||
const wsState = data["ws-state"];
|
||||
const graphId = data["graph-id"];
|
||||
|
||||
if (wsState !== "open" || typeof graphId !== "string" || graphId.length === 0) {
|
||||
console.log("need-start");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const pendingLocal = data["pending-local"];
|
||||
const pendingServer = data["pending-server"];
|
||||
if (typeof pendingLocal !== "number" || !Number.isFinite(pendingLocal)) {
|
||||
fail("sync status pending-local must be a number");
|
||||
}
|
||||
if (typeof pendingServer !== "number" || !Number.isFinite(pendingServer)) {
|
||||
fail("sync status pending-server must be a number");
|
||||
}
|
||||
|
||||
const state = pendingLocal === 0 && pendingServer === 0 ? "complete" : "pending";
|
||||
console.log([state, wsState, pendingLocal, pendingServer].join("\t"));
|
||||
'
|
||||
}
|
||||
|
||||
validate_and_print_tasks() {
|
||||
node -e '
|
||||
const fs = require("fs");
|
||||
const taskUuidsFile = process.env.TASK_UUIDS_FILE;
|
||||
|
||||
function fail(message) {
|
||||
console.error(message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(fs.readFileSync(0, "utf8"));
|
||||
} catch (error) {
|
||||
fail(`query did not return valid JSON: ${error.message}`);
|
||||
}
|
||||
|
||||
if (payload.status !== "ok") {
|
||||
fail(`query returned non-ok status: ${JSON.stringify(payload)}`);
|
||||
}
|
||||
|
||||
const result = payload.data && payload.data.result;
|
||||
if (!Array.isArray(result)) {
|
||||
fail("query result missing result array");
|
||||
}
|
||||
|
||||
if (typeof taskUuidsFile !== "string" || taskUuidsFile.length === 0) {
|
||||
fail("TASK_UUIDS_FILE is required");
|
||||
}
|
||||
|
||||
if (result.length === 0) {
|
||||
console.log("No TODO tasks found on today\u0027s Journal Page.");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(`Found ${result.length} TODO task(s) on today\u0027s Journal Page:`);
|
||||
const uuids = [];
|
||||
result.forEach((task, index) => {
|
||||
if (!task || typeof task !== "object" || Array.isArray(task)) {
|
||||
fail(`query result item ${index + 1} is not an object`);
|
||||
}
|
||||
|
||||
const rawUuid = task["block/uuid"];
|
||||
const title = task["block/title"];
|
||||
if (typeof rawUuid !== "string" || rawUuid.length === 0) {
|
||||
fail(`query result item ${index + 1} is missing block/uuid`);
|
||||
}
|
||||
if (typeof title !== "string" || title.length === 0) {
|
||||
fail(`query result item ${index + 1} is missing block/title`);
|
||||
}
|
||||
|
||||
const uuid = rawUuid.toLowerCase();
|
||||
console.log(`${index + 1}. ${title}`);
|
||||
console.log(` uuid: ${uuid}`);
|
||||
uuids.push(uuid);
|
||||
});
|
||||
|
||||
fs.writeFileSync(taskUuidsFile, `${uuids.join("\n")}\n`);
|
||||
'
|
||||
}
|
||||
|
||||
run_status() {
|
||||
"$LOGSEQ_BIN" sync status --graph "$GRAPH_NAME" --output json
|
||||
}
|
||||
|
||||
status_json="$(run_status)" || fail "sync status command failed"
|
||||
assessment="$(printf '%s' "$status_json" | assess_sync_status)" || fail "sync status returned invalid state"
|
||||
|
||||
if [[ "$assessment" == "need-start" ]]; then
|
||||
"$LOGSEQ_BIN" sync start --graph "$GRAPH_NAME" >/dev/null || fail "sync start command failed"
|
||||
fi
|
||||
|
||||
deadline=$((SECONDS + TIMEOUT_SECONDS))
|
||||
while true; do
|
||||
status_json="$(run_status)" || fail "sync status command failed"
|
||||
assessment="$(printf '%s' "$status_json" | assess_sync_status)" || fail "sync status returned invalid state"
|
||||
|
||||
if [[ "$assessment" == complete$'\t'* ]]; then
|
||||
IFS=$'\t' read -r _ ws_state pending_local pending_server <<<"$assessment"
|
||||
printf 'today-journal-day: %s\n' "$today_journal_day" >&2
|
||||
printf 'sync-gate: ws-state=%s pending-local=%s pending-server=%s\n' \
|
||||
"$ws_state" "$pending_local" "$pending_server" >&2
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ "$assessment" == "need-start" ]]; then
|
||||
fail "sync did not open after sync start"
|
||||
fi
|
||||
|
||||
if (( SECONDS >= deadline )); then
|
||||
fail "sync status polling timed out before queues settled"
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
query='[:find [(pull ?e [:db/id :block/uuid :block/title :block/updated-at]) ...]
|
||||
:in $ ?journal-day
|
||||
:where
|
||||
[?page :block/journal-day ?journal-day]
|
||||
[?e :block/page ?page]
|
||||
[?e :logseq.property/status ?status]
|
||||
[?status :db/ident :logseq.property/status.todo]
|
||||
[?e :block/title]]'
|
||||
|
||||
query_json="$("$LOGSEQ_BIN" query --graph "$GRAPH_NAME" --query "$query" --inputs "[$today_journal_day]" --output json)" \
|
||||
|| fail "query command failed"
|
||||
|
||||
task_uuids_file="$(mktemp)"
|
||||
trap 'rm -f "$task_uuids_file"' EXIT
|
||||
|
||||
printf '%s' "$query_json" | TASK_UUIDS_FILE="$task_uuids_file" validate_and_print_tasks
|
||||
|
||||
if [[ -s "$task_uuids_file" ]]; then
|
||||
printf '\nBlock trees:\n'
|
||||
task_index=1
|
||||
while IFS= read -r uuid; do
|
||||
if [[ -z "$uuid" ]]; then
|
||||
continue
|
||||
fi
|
||||
printf '\n--- Task %s: %s ---\n' "$task_index" "$uuid"
|
||||
"$LOGSEQ_BIN" show --graph "$GRAPH_NAME" --uuid "$uuid" --level 100 \
|
||||
|| fail "show command failed for task $uuid"
|
||||
task_index=$((task_index + 1))
|
||||
done <"$task_uuids_file"
|
||||
fi
|
||||
Reference in New Issue
Block a user