@point-seven-studio/jq-deck 0.3.1 → 0.3.2
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.mjs +544 -95
- package/dist/jq-deck.mjs +544 -95
- package/dist/types/cli.d.ts +2 -0
- package/package.json +1 -1
package/dist/jq-deck.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
5
|
import { createServer } from "http";
|
|
6
|
-
import
|
|
6
|
+
import path7 from "path";
|
|
7
7
|
|
|
8
8
|
// ../agents/dist/index.mjs
|
|
9
9
|
import { execFile as execFile2 } from "child_process";
|
|
@@ -15,6 +15,155 @@ import { promisify as promisify2 } from "util";
|
|
|
15
15
|
import { execFile } from "child_process";
|
|
16
16
|
import { promisify } from "util";
|
|
17
17
|
import os from "os";
|
|
18
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
19
|
+
import os3 from "os";
|
|
20
|
+
import path2 from "path";
|
|
21
|
+
var EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
22
|
+
function looksLikeACheck(command) {
|
|
23
|
+
return /\b(test|tests|jest|vitest|pytest|mocha|lint|eslint|ruff|tsc|typecheck|type-check|mypy|pyright|check|build|cargo (test|check|clippy)|go (test|vet))\b/i.test(command);
|
|
24
|
+
}
|
|
25
|
+
var CODE_FILE = /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|go|rs|java|kt|swift|c|h|cc|cpp|hpp|cs|php|sql|sh|bash|zsh|json|ya?ml|toml|css|scss|less|html?|vue|svelte|tf|proto|gradle|xml|ini|cfg|conf|lock)$|(^|\/)(Dockerfile|Makefile|\.env[\w.]*)$/i;
|
|
26
|
+
var NOT_PROJECT = /^(\/tmp\/|\/private\/tmp\/|\/var\/folders\/|\/dev\/|\$)|(^|\/)\.claude\/|(^|\/)(node_modules|dist|build|out|coverage)\/|(^|\/)[._]?(tmp|temp|scratch)[\w.-]*(\/|$)|_tmp_|\.tmp\b/i;
|
|
27
|
+
function isCodePath(file) {
|
|
28
|
+
const clean = file.trim().replace(/^['"]|['"]$/g, "");
|
|
29
|
+
const name = clean.split("/").pop() || "";
|
|
30
|
+
if (/^[_.]/.test(name) && !/^\.env/.test(name)) return false;
|
|
31
|
+
return CODE_FILE.test(clean) && !NOT_PROJECT.test(clean);
|
|
32
|
+
}
|
|
33
|
+
function codePaths(text) {
|
|
34
|
+
return (text.match(/[~$\w@.{}\/-]+/g) || []).filter(isCodePath);
|
|
35
|
+
}
|
|
36
|
+
function maskQuotes(text) {
|
|
37
|
+
return text.replace(/'[^']*'|"(?:[^"\\]|\\.)*"/g, (quoted) => quoted[0] + "x".repeat(Math.max(0, quoted.length - 2)) + quoted[0]);
|
|
38
|
+
}
|
|
39
|
+
function splitHeredocs(command) {
|
|
40
|
+
const bodies = [];
|
|
41
|
+
const lines = command.split("\n");
|
|
42
|
+
const shell = [];
|
|
43
|
+
for (let i = 0; i < lines.length; i++) {
|
|
44
|
+
shell.push(lines[i]);
|
|
45
|
+
const tag = /<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/.exec(lines[i])?.[2];
|
|
46
|
+
if (!tag) continue;
|
|
47
|
+
const body = [];
|
|
48
|
+
i += 1;
|
|
49
|
+
while (i < lines.length && lines[i].trim() !== tag) body.push(lines[i++]);
|
|
50
|
+
bodies.push(body.join("\n"));
|
|
51
|
+
}
|
|
52
|
+
return { shell: shell.join("\n"), bodies };
|
|
53
|
+
}
|
|
54
|
+
function segments(shell) {
|
|
55
|
+
const masked = maskQuotes(shell);
|
|
56
|
+
const parts = [];
|
|
57
|
+
let from = 0;
|
|
58
|
+
for (const cut of [...masked.matchAll(/&&|\|\||;|\||\n/g), null]) {
|
|
59
|
+
const to = cut ? cut.index : masked.length;
|
|
60
|
+
const text = shell.slice(from, to).trim();
|
|
61
|
+
if (text) parts.push({ text, bare: masked.slice(from, to).trim() });
|
|
62
|
+
from = cut ? to + cut[0].length : to;
|
|
63
|
+
}
|
|
64
|
+
return parts;
|
|
65
|
+
}
|
|
66
|
+
function shellSegments(command) {
|
|
67
|
+
return segments(splitHeredocs(command).shell).map((part) => part.text);
|
|
68
|
+
}
|
|
69
|
+
var WRITES_A_FILE = /\bopen\([^)]*,\s*['"][wax]b?\+?['"]|\.write_text\(|\.write_bytes\(|\bwriteFile(Sync)?\(|\bappendFile(Sync)?\(|\bfs\.(rename|unlink|rm|cp|copyFile)(Sync)?\(|\bshutil\.(copy|move|rmtree)/;
|
|
70
|
+
function shellEdit(command) {
|
|
71
|
+
const { shell, bodies } = splitHeredocs(command);
|
|
72
|
+
const written = bodies.filter((body) => WRITES_A_FILE.test(body)).join("\n");
|
|
73
|
+
for (const { text, bare } of segments(shell)) {
|
|
74
|
+
const writer = /^(sudo\s+)?(sed|perl)\b.*\s-[a-zA-Z]*i/.test(bare) || /^(sudo\s+)?(mv|cp|rm|patch|tee)\s/.test(bare) || /^git\s+(apply|mv|rm)\b/.test(bare);
|
|
75
|
+
if (writer && codePaths(text).length) return text;
|
|
76
|
+
for (const hit of bare.matchAll(/(^|[^0-9&>=-])>>?\s*/g)) {
|
|
77
|
+
const target = /^\S+/.exec(text.slice(hit.index + hit[0].length))?.[0] ?? "";
|
|
78
|
+
if (isCodePath(target)) return text;
|
|
79
|
+
}
|
|
80
|
+
if (/^(python3?|node|ruby|perl|deno|bun)\b/.test(bare) && (written || WRITES_A_FILE.test(text)) && codePaths(`${written}
|
|
81
|
+
${text}`).length) return text;
|
|
82
|
+
}
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
function ruleText(command) {
|
|
86
|
+
const words = (shellSegments(command)[0] || command).trim().split(/\s+/);
|
|
87
|
+
const kept = [];
|
|
88
|
+
for (const word of words.slice(0, 3)) {
|
|
89
|
+
if (kept.length && /[\/$<>'"=]|^\d/.test(word)) break;
|
|
90
|
+
kept.push(word);
|
|
91
|
+
}
|
|
92
|
+
return kept.join(" ").slice(0, 60);
|
|
93
|
+
}
|
|
94
|
+
var MAX_RULES = 200;
|
|
95
|
+
var MAX_TEXT = 80;
|
|
96
|
+
function parseConfig(raw) {
|
|
97
|
+
const o = raw && typeof raw === "object" ? raw : {};
|
|
98
|
+
const rules = (Array.isArray(o.rules) ? o.rules : []).filter((r) => !!r && typeof r === "object" && typeof r.tree === "string" && typeof r.text === "string" && (r.kind === "check" || r.kind === "not-edit")).map((r) => ({ tree: r.tree, kind: r.kind, text: r.text.trim().slice(0, MAX_TEXT) })).filter((r) => r.text.length >= 2 && r.tree).slice(0, MAX_RULES);
|
|
99
|
+
const muted = (Array.isArray(o.muted) ? o.muted : []).filter((t) => typeof t === "string" && !!t).slice(0, MAX_RULES);
|
|
100
|
+
const dismissed = {};
|
|
101
|
+
if (o.dismissed && typeof o.dismissed === "object") {
|
|
102
|
+
for (const [id, at] of Object.entries(o.dismissed).slice(0, 500)) if (typeof at === "string") dismissed[id] = at;
|
|
103
|
+
}
|
|
104
|
+
return { rules, muted, dismissed };
|
|
105
|
+
}
|
|
106
|
+
function rulesFor(config, tree) {
|
|
107
|
+
const mine = config.rules.filter((r) => r.tree === "*" || r.tree === tree);
|
|
108
|
+
return { checks: mine.filter((r) => r.kind === "check").map((r) => r.text), notEdits: mine.filter((r) => r.kind === "not-edit").map((r) => r.text) };
|
|
109
|
+
}
|
|
110
|
+
var blocks = (rec) => Array.isArray(rec.message?.content) ? rec.message.content.filter((b) => !!b && typeof b === "object") : [];
|
|
111
|
+
function isPrompt(rec) {
|
|
112
|
+
if (rec.type !== "user" || rec.isSidechain) return false;
|
|
113
|
+
const content = rec.message?.content;
|
|
114
|
+
return typeof content === "string" ? content.trim() !== "" : blocks(rec).some((b) => b.type === "text" || b.type === "image");
|
|
115
|
+
}
|
|
116
|
+
var short = (command, max = 120) => {
|
|
117
|
+
const one = redactSecrets(command.replace(/\s+/g, " ").trim()).text;
|
|
118
|
+
return one.length > max ? one.slice(0, max).trimEnd() + "\u2026" : one;
|
|
119
|
+
};
|
|
120
|
+
function deriveTurnCheckDetail(records, rules = {}) {
|
|
121
|
+
const extraChecks = rules.checks ?? [];
|
|
122
|
+
const notEdits = rules.notEdits ?? [];
|
|
123
|
+
const isCheck = (command) => looksLikeACheck(command) || extraChecks.some((text) => command.includes(text));
|
|
124
|
+
let start = -1;
|
|
125
|
+
for (let i = records.length - 1; i >= 0; i--) {
|
|
126
|
+
if (records[i] && isPrompt(records[i])) {
|
|
127
|
+
start = i;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
let step = 0;
|
|
132
|
+
let lastEdit = -1;
|
|
133
|
+
let edit = null;
|
|
134
|
+
const shell = [];
|
|
135
|
+
const errored = /* @__PURE__ */ new Set();
|
|
136
|
+
for (const rec of records.slice(start + 1)) {
|
|
137
|
+
if (!rec || rec.isSidechain) continue;
|
|
138
|
+
for (const block of blocks(rec)) {
|
|
139
|
+
step += 1;
|
|
140
|
+
if (block.type === "tool_result" && block.is_error === true && block.tool_use_id) errored.add(block.tool_use_id);
|
|
141
|
+
if (block.type !== "tool_use" || !block.name) continue;
|
|
142
|
+
if (EDIT_TOOLS.has(block.name)) {
|
|
143
|
+
const file = block.input?.file_path ?? block.input?.notebook_path;
|
|
144
|
+
if (typeof file === "string" && !isCodePath(file)) continue;
|
|
145
|
+
lastEdit = step;
|
|
146
|
+
edit = { via: "tool", text: block.name };
|
|
147
|
+
} else if (block.name === "Bash" && typeof block.input?.command === "string") {
|
|
148
|
+
const command = block.input.command;
|
|
149
|
+
const check = isCheck(command);
|
|
150
|
+
shell.push({ step, id: block.id, command, check });
|
|
151
|
+
const changed = check || rules.shellEdits === false ? "" : shellEdit(command);
|
|
152
|
+
if (changed && !notEdits.some((text) => changed.includes(text) || command.includes(text))) {
|
|
153
|
+
lastEdit = step;
|
|
154
|
+
edit = { via: "shell", text: changed };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (lastEdit < 0 || !edit) return { result: start >= 0 ? "no-edits" : "unknown", via: null, evidence: null };
|
|
160
|
+
const after = shell.filter((c) => c.step > lastEdit);
|
|
161
|
+
const checks = after.filter((c) => c.check);
|
|
162
|
+
const last = checks[checks.length - 1];
|
|
163
|
+
const result = !last ? "unchecked" : last.id && errored.has(last.id) ? "failed" : "checked";
|
|
164
|
+
const evidence = result === "unchecked" || result === "failed" ? { via: edit.via, edit: edit.via === "shell" ? short(edit.text) : edit.text, after: [...new Set(after.filter((c) => !c.check).map((c) => short(c.command, 80)))].slice(-6) } : null;
|
|
165
|
+
return { result, via: edit.via, evidence };
|
|
166
|
+
}
|
|
18
167
|
var META_RECORD_TYPES = /* @__PURE__ */ new Set([
|
|
19
168
|
"last-prompt",
|
|
20
169
|
"pr-link",
|
|
@@ -142,6 +291,13 @@ function buildStatusRow(opts) {
|
|
|
142
291
|
question_redacted = redacted;
|
|
143
292
|
blocked_question = text.length > QUESTION_MAX_CHARS ? text.slice(0, QUESTION_MAX_CHARS).trimEnd() + "\u2026" : text;
|
|
144
293
|
}
|
|
294
|
+
const saidDone = substantive?.type === "assistant" && substantive.message?.stop_reason === "end_turn";
|
|
295
|
+
const detail = saidDone ? deriveTurnCheckDetail(records, opts.turnCheck) : null;
|
|
296
|
+
let turn_check = detail?.result ?? null;
|
|
297
|
+
if (turn_check === "unchecked" || turn_check === "failed") {
|
|
298
|
+
if (opts.turnCheck?.muted || opts.turnCheck?.dismissedAt && opts.turnCheck.dismissedAt === activity) turn_check = "dismissed";
|
|
299
|
+
}
|
|
300
|
+
if (detail && opts.onTurnDetail) opts.onTurnDetail(detail);
|
|
145
301
|
return {
|
|
146
302
|
machine,
|
|
147
303
|
product: workingTree.split("/").filter(Boolean).pop() || workingTree,
|
|
@@ -156,7 +312,9 @@ function buildStatusRow(opts) {
|
|
|
156
312
|
ends_with_question: rawText ? endsWithQuestion(rawText) : false,
|
|
157
313
|
blocked_question,
|
|
158
314
|
question_redacted,
|
|
159
|
-
question_allowed: allowed
|
|
315
|
+
question_allowed: allowed,
|
|
316
|
+
turn_check,
|
|
317
|
+
turn_check_via: detail?.via ?? null
|
|
160
318
|
};
|
|
161
319
|
}
|
|
162
320
|
function parsePs(stdout) {
|
|
@@ -348,7 +506,7 @@ var execFileAsync2 = promisify2(execFile2);
|
|
|
348
506
|
function defaultProjectsDir() {
|
|
349
507
|
return path.join(process.env.CLAUDE_CONFIG_DIR || path.join(os2.homedir(), ".claude"), "projects");
|
|
350
508
|
}
|
|
351
|
-
var TAIL_RECORDS =
|
|
509
|
+
var TAIL_RECORDS = 200;
|
|
352
510
|
async function findTranscripts(dir, out = []) {
|
|
353
511
|
let entries;
|
|
354
512
|
try {
|
|
@@ -462,7 +620,11 @@ async function collectRows(opts = {}) {
|
|
|
462
620
|
const rawCwd = [...records].reverse().find((r) => r?.cwd)?.cwd || "";
|
|
463
621
|
const tree = rawCwd ? await repoRoot(rawCwd) : "";
|
|
464
622
|
const pid = tree ? cwdToPid.get(tree) ?? null : null;
|
|
623
|
+
const config = opts.turnCheck;
|
|
624
|
+
let evidence = null;
|
|
465
625
|
const row3 = buildStatusRow({
|
|
626
|
+
turnCheck: config ? { ...rulesFor(config, tree), muted: config.muted.includes(tree), dismissedAt: config.dismissed[path.basename(file, ".jsonl")] ?? null } : void 0,
|
|
627
|
+
onTurnDetail: (detail) => evidence = detail.evidence,
|
|
466
628
|
machine,
|
|
467
629
|
records,
|
|
468
630
|
workingTreeOverride: tree || void 0,
|
|
@@ -472,7 +634,11 @@ async function collectRows(opts = {}) {
|
|
|
472
634
|
allowlist: opts.questionTrees ?? [],
|
|
473
635
|
now
|
|
474
636
|
});
|
|
475
|
-
if (row3)
|
|
637
|
+
if (row3) {
|
|
638
|
+
if (config && row3.turn_check !== "dismissed" && (row3.turn_check === "unchecked" || row3.turn_check === "failed") && config.dismissed[row3.session_id] === row3.last_activity_at) row3.turn_check = "dismissed";
|
|
639
|
+
rows.push(row3);
|
|
640
|
+
if (evidence && opts.onEvidence) opts.onEvidence(row3.session_id, evidence);
|
|
641
|
+
}
|
|
476
642
|
} catch {
|
|
477
643
|
}
|
|
478
644
|
}
|
|
@@ -485,7 +651,8 @@ async function collectRows(opts = {}) {
|
|
|
485
651
|
}
|
|
486
652
|
var prevNet = /* @__PURE__ */ new Map();
|
|
487
653
|
async function snapshot(opts = {}) {
|
|
488
|
-
const
|
|
654
|
+
const turn_check = {};
|
|
655
|
+
const sessions = await collectRows(opts.evidence ? { ...opts, onEvidence: (id, e) => turn_check[id] = e } : opts);
|
|
489
656
|
let host = null;
|
|
490
657
|
let bottleneck = null;
|
|
491
658
|
if (opts.sample !== false) {
|
|
@@ -516,7 +683,9 @@ async function snapshot(opts = {}) {
|
|
|
516
683
|
bottleneck = null;
|
|
517
684
|
}
|
|
518
685
|
}
|
|
519
|
-
|
|
686
|
+
const snap = { machine: opts.machine ?? os2.hostname(), generated_at: new Date(opts.now ?? Date.now()).toISOString(), sessions, host, bottleneck };
|
|
687
|
+
if (opts.evidence) snap.local = { turn_check };
|
|
688
|
+
return snap;
|
|
520
689
|
}
|
|
521
690
|
var esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
522
691
|
function ago(iso, now) {
|
|
@@ -550,18 +719,44 @@ function groupByTree(rows) {
|
|
|
550
719
|
rows: list2.sort((a, b) => (b.last_activity_at || "").localeCompare(a.last_activity_at || ""))
|
|
551
720
|
})).sort((a, b) => Number(needs(b.rows)) - Number(needs(a.rows)) || latest(b.rows).localeCompare(latest(a.rows)));
|
|
552
721
|
}
|
|
553
|
-
|
|
722
|
+
var hidden = (fields) => Object.entries(fields).map(([name, value]) => `<input type="hidden" name="${name}" value="${esc(value)}">`).join("");
|
|
723
|
+
var form = (m, fields, label) => `<form method="post" action="/turn-check">${hidden({ token: m.token, ...fields })}<button type="submit">${esc(label)}</button></form>`;
|
|
724
|
+
function whyPanel(r, evidence, m) {
|
|
725
|
+
const how = evidence.via === "shell" ? `<code>${esc(evidence.edit)}</code>, a shell command` : `the ${esc(evidence.edit)} tool`;
|
|
726
|
+
const verdict = r.turn_check === "failed" ? "The last check after it failed." : "No check ran after it.";
|
|
727
|
+
const after = evidence.after.length ? `<p>It ran these afterwards. If one of them is how this project checks its work, say so:</p><ul class="cmds">${evidence.after.map((command) => {
|
|
728
|
+
const text = ruleText(command);
|
|
729
|
+
return `<li><code>${esc(command)}</code>${text.length >= 2 ? form(m, { action: "add-rule", kind: "check", tree: r.working_tree, text }, `Count "${text}" as a check here`) : ""}</li>`;
|
|
730
|
+
}).join("")}</ul>` : "";
|
|
731
|
+
const notEdit = evidence.via === "shell" && ruleText(evidence.edit).length >= 2 ? form(m, { action: "add-rule", kind: "not-edit", tree: r.working_tree, text: ruleText(evidence.edit) }, `"${ruleText(evidence.edit)}" does not edit code here`) : "";
|
|
732
|
+
return `<details class="why"><summary>Why, and is it wrong?</summary><p>The last edit was ${how}. ${verdict}</p>${after}<div class="acts">${notEdit}` + form(m, { action: "dismiss", session: r.session_id }, "Dismiss this one") + form(m, { action: "mute", tree: r.working_tree }, "Never label this tree") + "</div></details>";
|
|
733
|
+
}
|
|
734
|
+
function sessionRow(r, now, evidence, manage) {
|
|
554
735
|
const attention = deriveAttention(r.state, r.waiting);
|
|
555
736
|
const badge = attention === "needs-you" ? '<span class="b need">waiting on a person</span>' : attention === "abandoned" ? '<span class="b old">asked, then left</span>' : "";
|
|
737
|
+
const check = r.turn_check === "unchecked" ? '<span class="b need">stopped without running a check</span>' : r.turn_check === "failed" ? '<span class="b bad">stopped after a failed check</span>' : "";
|
|
556
738
|
const res = r.cpu_pct != null || r.rss_mb != null ? `<span class="mut">${r.cpu_pct ?? "?"}% cpu \xB7 ${r.rss_mb ?? "?"} MB</span>` : "";
|
|
557
739
|
const question = r.blocked_question ? `<pre>${esc(r.blocked_question)}${r.question_redacted ? "\n[a secret-shaped string was removed]" : ""}</pre>` : attention !== "none" && !r.question_allowed ? '<p class="mut q">Question text is off for this tree.</p>' : "";
|
|
558
|
-
|
|
740
|
+
const why = check && evidence && manage ? whyPanel(r, evidence, manage) : "";
|
|
741
|
+
return `<li><span class="s ${r.state}">${r.state}</span> <span class="mut">${esc(r.branch || "no branch")} \xB7 active ${ago(r.last_activity_at, now)} ago</span> ${[badge, check].filter(Boolean).join('<span class="mut"> \xB7 </span>')} ${res}${question}${why}</li>`;
|
|
742
|
+
}
|
|
743
|
+
function correctionsPanel(snap, m) {
|
|
744
|
+
const { rules, muted, dismissed } = m.config;
|
|
745
|
+
const items = [
|
|
746
|
+
...rules.map((rule, index) => `<li><span>${rule.kind === "check" ? "Counts as a check" : "Does not edit code"}: <code>${esc(rule.text)}</code> <span class="mut">in ${esc(rule.tree === "*" ? "every tree" : rule.tree)}</span></span>${form(m, { action: "remove-rule", index: String(index) }, "Remove")}</li>`),
|
|
747
|
+
...muted.map((tree) => `<li><span>Never labelled: <span class="mut">${esc(tree)}</span></span>${form(m, { action: "unmute", tree }, "Label it again")}</li>`),
|
|
748
|
+
...Object.keys(dismissed).map((session) => {
|
|
749
|
+
const row3 = snap.sessions.find((r) => r.session_id === session);
|
|
750
|
+
return `<li><span>Dismissed: <span class="mut">${esc(row3 ? `${row3.product} \xB7 ${row3.branch || "no branch"}` : `session ${session.slice(0, 8)}`)}</span></span>${form(m, { action: "undismiss", session }, "Undo")}</li>`;
|
|
751
|
+
})
|
|
752
|
+
];
|
|
753
|
+
return '<section class="card fix"><h2>Your corrections to the check label</h2>' + (items.length ? `<ul>${items.join("")}</ul>` : '<p class="mut pad">None yet. A label you think is wrong has a "Why, and is it wrong?" link under it.</p>') + '<p class="mut pad">Saved in <code>~/.jq/config.json</code> on this machine. This is the only file JQ Agents writes.</p></section>';
|
|
559
754
|
}
|
|
560
|
-
function renderPage(snap, now = Date.now()) {
|
|
755
|
+
function renderPage(snap, now = Date.now(), manage) {
|
|
561
756
|
const t = totals(snap.sessions);
|
|
562
757
|
const b = snap.bottleneck;
|
|
563
758
|
const chip = !b ? '<p class="mut">Host not sampled.</p>' : b.kind === "none" ? "" : `<p class="chip">${b.kind === "unknown" ? "Could not tell what this machine is short of." : `Bottleneck: ${esc(b.kind)}${b.reason ? ` (${esc(b.reason)})` : ""}`}</p>`;
|
|
564
|
-
const trees = groupByTree(snap.sessions).map((g) => `<section class="card"><h2>${esc(g.product)} <span class="mut">${esc(g.tree)}</span></h2><ul>${g.rows.map((r) => sessionRow(r, now)).join("")}</ul></section>`).join("");
|
|
759
|
+
const trees = groupByTree(snap.sessions).map((g) => `<section class="card"><h2>${esc(g.product)} <span class="mut">${esc(g.tree)}</span></h2><ul>${g.rows.map((r) => sessionRow(r, now, snap.local?.turn_check[r.session_id], manage)).join("")}</ul></section>`).join("");
|
|
565
760
|
return `<!doctype html>
|
|
566
761
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
567
762
|
<title>JQ Agents</title>
|
|
@@ -576,8 +771,14 @@ h1{font-size:24px;margin:0}h2{font-size:15px;margin:0;padding:10px 12px;word-bre
|
|
|
576
771
|
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;margin:10px 0;overflow:hidden}
|
|
577
772
|
ul{list-style:none;margin:0;padding:0}li{border-top:1px solid var(--line);padding:8px 12px}
|
|
578
773
|
.s{font-size:11px;font-weight:700;text-transform:uppercase;border-radius:4px;padding:1px 6px;border:1px solid var(--line)}.s.live{color:var(--ok)}.s.dead{color:var(--mut)}
|
|
579
|
-
.b{font-size:12px;font-weight:600}.b.need{color:var(--need)}.b.old{color:var(--mut)}
|
|
774
|
+
.b{font-size:12px;font-weight:600}.b.need{color:var(--need)}.b.old{color:var(--mut)}.b.bad{color:var(--bad)}
|
|
580
775
|
.chip{border:1px solid var(--line);border-radius:8px;padding:6px 10px;font-size:13px}
|
|
776
|
+
.why{margin:6px 0 2px;font-size:13px}.why summary{cursor:pointer;color:var(--mut);font-size:12px}.why p{margin:6px 0}
|
|
777
|
+
code{font:12px ui-monospace,Menlo,monospace;background:var(--well);border-radius:4px;padding:1px 4px;word-break:break-all}
|
|
778
|
+
.cmds{border:1px solid var(--line);border-radius:8px}.cmds li,.fix li{display:flex;flex-wrap:wrap;gap:6px 10px;align-items:center;justify-content:space-between}
|
|
779
|
+
.acts{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}form{margin:0}
|
|
780
|
+
button{font:600 12px system-ui,sans-serif;color:var(--fg);background:var(--card);border:1px solid var(--line);border-radius:6px;padding:5px 10px;min-height:30px;cursor:pointer}
|
|
781
|
+
button:hover{border-color:var(--mut)}button:focus-visible{outline:2px solid var(--fg);outline-offset:2px}.pad{margin:0;padding:8px 12px}
|
|
581
782
|
pre{white-space:pre-wrap;word-break:break-word;background:var(--well);margin:8px 0 2px;padding:10px;border-radius:8px;font-size:12px}.q{margin:6px 0 0}
|
|
582
783
|
</style></head><body><main>
|
|
583
784
|
<h1>JQ Agents</h1>
|
|
@@ -585,12 +786,29 @@ pre{white-space:pre-wrap;word-break:break-word;background:var(--well);margin:8px
|
|
|
585
786
|
<div class="tot"><div><b>${t.needs_you}</b><span class="mut">waiting on a person</span></div><div><b>${t.abandoned}</b><span class="mut">asked, then left</span></div><div><b>${t.live}</b><span class="mut">live</span></div><div><b>${t.sessions}</b><span class="mut">sessions in ${t.trees} ${t.trees === 1 ? "tree" : "trees"}</span></div></div>
|
|
586
787
|
${chip}
|
|
587
788
|
${trees || '<p class="mut">No session has been active in the window read.</p>'}
|
|
789
|
+
${manage ? correctionsPanel(snap, manage) : ""}
|
|
588
790
|
</main></body></html>`;
|
|
589
791
|
}
|
|
792
|
+
function defaultConfigFile() {
|
|
793
|
+
return process.env.JQ_CONFIG || path2.join(os3.homedir(), ".jq", "config.json");
|
|
794
|
+
}
|
|
795
|
+
function readAll(file) {
|
|
796
|
+
if (!existsSync2(file)) return {};
|
|
797
|
+
const parsed = JSON.parse(readFileSync(file, "utf-8"));
|
|
798
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${file} does not hold a JSON object`);
|
|
799
|
+
return parsed;
|
|
800
|
+
}
|
|
801
|
+
function readTurnCheckConfig(file = defaultConfigFile()) {
|
|
802
|
+
try {
|
|
803
|
+
return parseConfig(readAll(file).turnCheck);
|
|
804
|
+
} catch {
|
|
805
|
+
return parseConfig(null);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
590
808
|
|
|
591
809
|
// ../crosstalk/dist/index.mjs
|
|
592
|
-
import { existsSync as
|
|
593
|
-
import
|
|
810
|
+
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
811
|
+
import path3 from "path";
|
|
594
812
|
var BOARD = "board";
|
|
595
813
|
var DAY_MS = 864e5;
|
|
596
814
|
function ageDays(sentAt, now) {
|
|
@@ -822,17 +1040,17 @@ function parseMessage(filename, raw, recipient, acked) {
|
|
|
822
1040
|
};
|
|
823
1041
|
}
|
|
824
1042
|
function names(dir) {
|
|
825
|
-
if (!
|
|
826
|
-
return readdirSync(dir).filter((n) => statSync(
|
|
1043
|
+
if (!existsSync3(dir)) return [];
|
|
1044
|
+
return readdirSync(dir).filter((n) => statSync(path3.join(dir, n)).isDirectory());
|
|
827
1045
|
}
|
|
828
1046
|
function readMailbox(root) {
|
|
829
|
-
if (!
|
|
1047
|
+
if (!existsSync3(path3.join(root, "inbox"))) throw new Error(`not a crosstalk mailbox (no inbox/ folder): ${root}`);
|
|
830
1048
|
const byKey = /* @__PURE__ */ new Map();
|
|
831
1049
|
for (const [base, acked] of [["inbox", false], ["archive", true]]) {
|
|
832
|
-
for (const name of names(
|
|
833
|
-
const dir =
|
|
1050
|
+
for (const name of names(path3.join(root, base))) {
|
|
1051
|
+
const dir = path3.join(root, base, name);
|
|
834
1052
|
for (const file of readdirSync(dir).filter((f) => f.endsWith(".md"))) {
|
|
835
|
-
const row22 = parseMessage(file,
|
|
1053
|
+
const row22 = parseMessage(file, readFileSync2(path3.join(dir, file), "utf8"), name, acked);
|
|
836
1054
|
const key = `${name}/${file}`;
|
|
837
1055
|
const prev = byKey.get(key);
|
|
838
1056
|
if (!prev || acked && !prev.acked) byKey.set(key, { id: key, ...row22 });
|
|
@@ -912,9 +1130,9 @@ function buildReport(root, now = Date.now()) {
|
|
|
912
1130
|
}
|
|
913
1131
|
|
|
914
1132
|
// ../groundcrew/dist/index.mjs
|
|
915
|
-
import { existsSync as
|
|
916
|
-
import
|
|
917
|
-
import
|
|
1133
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
1134
|
+
import os4 from "os";
|
|
1135
|
+
import path4 from "path";
|
|
918
1136
|
var DOCS = "https://code.claude.com/docs/en";
|
|
919
1137
|
var MEMORY_LINE_TARGET = 200;
|
|
920
1138
|
var MEMORY_LINE_FAIL = 400;
|
|
@@ -926,6 +1144,136 @@ function deniesSecrets(rule) {
|
|
|
926
1144
|
function allowsEveryCommand(rule) {
|
|
927
1145
|
return /^Bash(\(\s*(\*|:\*|\*\*)?\s*\))?$/.test(rule.trim());
|
|
928
1146
|
}
|
|
1147
|
+
var COMMAND_HEADS = new Set(
|
|
1148
|
+
"git gh npm npx pnpm yarn bun node deno python python3 pip pip3 uv poetry cargo go make docker kubectl helm terraform aws gcloud az psql mysql sqlite3 redis-cli curl wget ssh scp rsync rm mv cp chmod chown sudo kill pkill brew apt railway vercel netlify fly heroku firebase wrangler tsc eslint ruff prettier dprint jest vitest pytest nx turbo gradle mvn dotnet rails rake bundle composer php launchctl systemctl".split(" ")
|
|
1149
|
+
);
|
|
1150
|
+
var NEVER_WORDS = /\b(never|do not|don['’]t|must not|mustn['’]t|not allowed|forbidden|prohibited)\b/i;
|
|
1151
|
+
var ASK_WORDS = /\bask\b[^.]{0,40}\b(first|before)\b|\bgo-ahead\b|\bwithout (asking|approval|permission|confirmation)\b|\b(needs?|requires?|get|wait for) [^.]{0,30}\b(approval|confirmation|sign-off|say-so)\b|\bconfirm (first|before)\b/i;
|
|
1152
|
+
var BARE_COMMANDS = /\b(git (?:push|reset --hard|reset|rebase|merge|commit|clean|stash)|gh (?:pr|issue|release|repo) [a-z]+|npm publish|rm -rf)\b/g;
|
|
1153
|
+
var restrictionKind = (text) => ASK_WORDS.test(text) ? "ask" : NEVER_WORDS.test(text) ? "never" : null;
|
|
1154
|
+
function commandStart(span) {
|
|
1155
|
+
const words = span.trim().replace(/^\$\s+/, "").split(/\s+/);
|
|
1156
|
+
if (!COMMAND_HEADS.has(words[0])) return "";
|
|
1157
|
+
const kept = [words[0]];
|
|
1158
|
+
for (const word of words.slice(1, 3)) {
|
|
1159
|
+
if (!/^(--?[a-z][a-z-]*|[a-z0-9][a-z0-9:_-]*)$/i.test(word)) break;
|
|
1160
|
+
kept.push(word);
|
|
1161
|
+
}
|
|
1162
|
+
return kept.join(" ");
|
|
1163
|
+
}
|
|
1164
|
+
function findRestrictedCommands(text, file) {
|
|
1165
|
+
const found = [];
|
|
1166
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1167
|
+
const add = (kind, command, line) => {
|
|
1168
|
+
if (!command || seen.has(command)) return;
|
|
1169
|
+
seen.add(command);
|
|
1170
|
+
found.push({ file, line, kind, command });
|
|
1171
|
+
};
|
|
1172
|
+
const commandsIn = (part) => {
|
|
1173
|
+
const spans = [...part.matchAll(/`([^`]+)`/g)].flatMap((m) => m[1].split("/").map(commandStart));
|
|
1174
|
+
const bare = [...part.replace(/`[^`]*`/g, " ").matchAll(BARE_COMMANDS)].map((m) => m[1]);
|
|
1175
|
+
return [...spans, ...bare].filter(Boolean);
|
|
1176
|
+
};
|
|
1177
|
+
const readBlock = (block2, line, inherited) => {
|
|
1178
|
+
let matched = false;
|
|
1179
|
+
for (const sentence of block2.split(/(?<=[.!?:])\s+|\s[—–]\s|;\s/)) {
|
|
1180
|
+
const kind = restrictionKind(sentence);
|
|
1181
|
+
if (!kind) continue;
|
|
1182
|
+
matched = true;
|
|
1183
|
+
const at = sentence.search(kind === "ask" ? ASK_WORDS : NEVER_WORDS);
|
|
1184
|
+
for (const command of commandsIn(kind === "ask" ? sentence : sentence.slice(at))) add(kind, command, line);
|
|
1185
|
+
}
|
|
1186
|
+
if (!matched && inherited) for (const command of commandsIn(block2)) add(inherited, command, line);
|
|
1187
|
+
};
|
|
1188
|
+
let headingKind = null;
|
|
1189
|
+
let block = "";
|
|
1190
|
+
let blockLine = 0;
|
|
1191
|
+
let blockIsItem = false;
|
|
1192
|
+
let fenced = false;
|
|
1193
|
+
const flush = () => {
|
|
1194
|
+
if (block) readBlock(block, blockLine, blockIsItem ? headingKind : null);
|
|
1195
|
+
block = "";
|
|
1196
|
+
};
|
|
1197
|
+
text.split("\n").forEach((raw, index) => {
|
|
1198
|
+
if (/^\s*(```|~~~)/.test(raw)) {
|
|
1199
|
+
flush();
|
|
1200
|
+
fenced = !fenced;
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
if (fenced) return;
|
|
1204
|
+
if (/^#{1,6}\s/.test(raw)) {
|
|
1205
|
+
flush();
|
|
1206
|
+
headingKind = restrictionKind(raw);
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
if (!raw.trim()) return flush();
|
|
1210
|
+
const startsItem = /^\s*([-*+]|\d+[.)])\s/.test(raw) || /^\s*\|/.test(raw);
|
|
1211
|
+
if (startsItem) flush();
|
|
1212
|
+
if (!block) {
|
|
1213
|
+
blockLine = index + 1;
|
|
1214
|
+
blockIsItem = startsItem;
|
|
1215
|
+
}
|
|
1216
|
+
block += (block ? " " : "") + raw.trim();
|
|
1217
|
+
});
|
|
1218
|
+
flush();
|
|
1219
|
+
return found;
|
|
1220
|
+
}
|
|
1221
|
+
function ruleCovers(rule, command) {
|
|
1222
|
+
const trimmed = rule.trim();
|
|
1223
|
+
if (allowsEveryCommand(trimmed)) return true;
|
|
1224
|
+
const inner = /^Bash\((.*)\)$/.exec(trimmed)?.[1];
|
|
1225
|
+
if (inner === void 0) return false;
|
|
1226
|
+
const pattern = inner.replace(/:\*$/, " *").trim();
|
|
1227
|
+
const regex = new RegExp("^" + pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*") + "$");
|
|
1228
|
+
return regex.test(command) || regex.test(`${command} x`);
|
|
1229
|
+
}
|
|
1230
|
+
var NO_PROMPT_MODES = /* @__PURE__ */ new Set(["bypassPermissions", "auto"]);
|
|
1231
|
+
function proseFindings(facts) {
|
|
1232
|
+
const files = facts.settings;
|
|
1233
|
+
const covers = (rules, command) => rules.some((rule) => ruleCovers(rule, command));
|
|
1234
|
+
const [deny, ask, allow] = [all(files, (f) => f.deny), all(files, (f) => f.ask), all(files, (f) => f.allow)];
|
|
1235
|
+
const noPrompt = files.some((f) => f.defaultMode !== null && NO_PROMPT_MODES.has(f.defaultMode));
|
|
1236
|
+
return (facts.restricted ?? []).map((r) => {
|
|
1237
|
+
const enforced = covers(deny, r.command) || r.kind === "ask" && covers(ask, r.command);
|
|
1238
|
+
const state = enforced ? "enforced" : covers(allow, r.command) || noPrompt ? "allowed" : r.kind === "ask" ? "prompt" : "open";
|
|
1239
|
+
return { ...r, state };
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
var nameFinding = (f) => `"${f.command}" (${f.kind === "ask" ? "ask first" : "never"}, ${f.file} line ${f.line})`;
|
|
1243
|
+
var listFindings = (findings, limit = 4) => findings.slice(0, limit).map(nameFinding).join("; ") + (findings.length > limit ? `; and ${findings.length - limit} more` : "");
|
|
1244
|
+
function proseChecks(facts) {
|
|
1245
|
+
const source = `${DOCS}/permissions.md`;
|
|
1246
|
+
const base = { id: "prose-rules", group: "guardrails", title: "Rules in the instructions have a permission rule behind them", source };
|
|
1247
|
+
const findings = proseFindings(facts);
|
|
1248
|
+
if (!findings.length) {
|
|
1249
|
+
return [
|
|
1250
|
+
{
|
|
1251
|
+
...base,
|
|
1252
|
+
status: "info",
|
|
1253
|
+
detail: 'No instruction file names a command to never run, or to ask about first. Only a command written out, such as "git push", is found.',
|
|
1254
|
+
fix: ""
|
|
1255
|
+
}
|
|
1256
|
+
];
|
|
1257
|
+
}
|
|
1258
|
+
const allowed = findings.filter((f) => f.state === "allowed");
|
|
1259
|
+
const open2 = findings.filter((f) => f.state === "open");
|
|
1260
|
+
const prompt = findings.filter((f) => f.state === "prompt");
|
|
1261
|
+
const enforced = findings.filter((f) => f.state === "enforced");
|
|
1262
|
+
const parts = [];
|
|
1263
|
+
if (allowed.length) parts.push(`The instructions restrict ${plural2(allowed.length, "command")} that an allow rule or the permission mode lets run without asking: ${listFindings(allowed)}.`);
|
|
1264
|
+
if (open2.length) parts.push(`${plural2(open2.length, "command")} the instructions say never to run ${open2.length === 1 ? "has" : "have"} no deny rule: ${listFindings(open2)}.`);
|
|
1265
|
+
if (prompt.length) parts.push(`${plural2(prompt.length, "ask-first command")} ${prompt.length === 1 ? "is" : "are"} held only by the default prompt, which one "don't ask again" removes: ${listFindings(prompt, 3)}.`);
|
|
1266
|
+
if (enforced.length) parts.push(`${plural2(enforced.length, "restricted command")} ${enforced.length === 1 ? "has" : "have"} a rule behind ${enforced.length === 1 ? "it" : "them"}.`);
|
|
1267
|
+
const needsLook = allowed.length > 0 || open2.length > 0;
|
|
1268
|
+
return [
|
|
1269
|
+
{
|
|
1270
|
+
...base,
|
|
1271
|
+
status: needsLook ? "warn" : "pass",
|
|
1272
|
+
detail: parts.join(" ") + (needsLook ? " This check reads words, so confirm each line means what it found." : ""),
|
|
1273
|
+
fix: needsLook ? `The docs say "Permission rules are enforced by Claude Code, not by the model", and that instructions "shape what Claude tries to do, but they don't change these rules". Add a deny rule for a command the instructions forbid and an ask rule for one they say to ask about, and remove an allow rule that contradicts them.` : ""
|
|
1274
|
+
}
|
|
1275
|
+
];
|
|
1276
|
+
}
|
|
929
1277
|
function memoryChecks(facts) {
|
|
930
1278
|
const source = `${DOCS}/memory.md`;
|
|
931
1279
|
if (!facts.memory.length) {
|
|
@@ -1104,13 +1452,13 @@ function guardrailChecks(facts) {
|
|
|
1104
1452
|
}
|
|
1105
1453
|
return checks;
|
|
1106
1454
|
}
|
|
1107
|
-
function
|
|
1455
|
+
function looksLikeACheck2(command) {
|
|
1108
1456
|
return /\b(test|tests|jest|vitest|pytest|mocha|lint|eslint|ruff|tsc|typecheck|type-check|mypy|pyright|check|build|cargo (test|check|clippy)|go (test|vet))\b/i.test(command);
|
|
1109
1457
|
}
|
|
1110
1458
|
function verificationChecks(facts) {
|
|
1111
1459
|
const files = facts.settings;
|
|
1112
|
-
const allowed = all(files, (f) => f.allow.filter((rule) => /^Bash\(/.test(rule) &&
|
|
1113
|
-
const hooked = all(files, (f) => f.hookCommands.filter((h) =>
|
|
1460
|
+
const allowed = all(files, (f) => f.allow.filter((rule) => /^Bash\(/.test(rule) && looksLikeACheck2(rule)));
|
|
1461
|
+
const hooked = all(files, (f) => f.hookCommands.filter((h) => looksLikeACheck2(h.command)));
|
|
1114
1462
|
const stopEvents = [...new Set(all(files, (f) => f.hookEvents.filter((event) => event === "Stop" || event === "SubagentStop")))].sort();
|
|
1115
1463
|
const unscoped = facts.subagentFiles.filter((agent) => !agent.limitsTools).map((agent) => agent.name);
|
|
1116
1464
|
const checks = [
|
|
@@ -1176,6 +1524,10 @@ function promptFor(check, facts) {
|
|
|
1176
1524
|
const rules = facts.secretFiles.length ? facts.secretFiles.map((file) => `Read(./${file})`).join(", ") : "Read(./.env), Read(./secrets/**)";
|
|
1177
1525
|
return `Add deny rules to the permissions.deny array in .claude/settings.json so that Claude Code cannot read secret files: ${rules}. Keep every rule that is already in the file. Show me the diff before you save it, and tell me how to confirm afterwards that a read of one of these files is refused.`;
|
|
1178
1526
|
}
|
|
1527
|
+
case "prose-rules": {
|
|
1528
|
+
const findings = proseFindings(facts).filter((f) => f.state === "allowed" || f.state === "open");
|
|
1529
|
+
return `My instruction files restrict these commands, and no permission rule enforces it: ${findings.map(nameFinding).join("; ")}. First read each line and tell me if it really restricts that command. For each one that does, propose a rule for the permissions in .claude/settings.json: a deny rule where the instructions say never, an ask rule where they say to ask first. If an allow rule in any settings file approves one of these commands, show me that rule and say whether to remove it. Keep every other rule. Show me the diff before you save it, and tell me how to confirm afterwards that each rule works.`;
|
|
1530
|
+
}
|
|
1179
1531
|
case "broad-allow":
|
|
1180
1532
|
return "My Claude Code settings hold an allow rule that approves every shell command. Find it in the settings files, then list the shell commands this project really needs, such as its test, lint and build commands. Propose scoped allow rules for those to replace the blanket rule. Show me the diff before you save it.";
|
|
1181
1533
|
case "sandbox":
|
|
@@ -1190,9 +1542,80 @@ function promptFor(check, facts) {
|
|
|
1190
1542
|
return "";
|
|
1191
1543
|
}
|
|
1192
1544
|
}
|
|
1545
|
+
var LAYER_OF = {
|
|
1546
|
+
"memory-exists": "guides",
|
|
1547
|
+
"memory-length": "guides",
|
|
1548
|
+
skills: "guides",
|
|
1549
|
+
"legacy-commands": "guides",
|
|
1550
|
+
hooks: "sensors",
|
|
1551
|
+
"verify-command": "sensors",
|
|
1552
|
+
"stop-check": "loop",
|
|
1553
|
+
"auto-memory-index": "memory",
|
|
1554
|
+
"allow-rules": "permissions",
|
|
1555
|
+
"subagents-and-mcp": "permissions",
|
|
1556
|
+
"deny-secrets": "permissions",
|
|
1557
|
+
"broad-allow": "permissions",
|
|
1558
|
+
"default-mode": "permissions",
|
|
1559
|
+
sandbox: "permissions",
|
|
1560
|
+
reach: "permissions",
|
|
1561
|
+
managed: "permissions",
|
|
1562
|
+
"prose-rules": "permissions",
|
|
1563
|
+
"subagent-scope": "permissions",
|
|
1564
|
+
retention: "observability"
|
|
1565
|
+
};
|
|
1566
|
+
function layerOf(id) {
|
|
1567
|
+
return LAYER_OF[id.split(":")[0]] ?? "guides";
|
|
1568
|
+
}
|
|
1569
|
+
var LAYERS = [
|
|
1570
|
+
{
|
|
1571
|
+
key: "guides",
|
|
1572
|
+
title: "Guides",
|
|
1573
|
+
what: "What steers the agent before it works: instructions, rules and skills.",
|
|
1574
|
+
unchecked: "It does not judge what the instructions say, only how long they are."
|
|
1575
|
+
},
|
|
1576
|
+
{
|
|
1577
|
+
key: "sensors",
|
|
1578
|
+
title: "Sensors",
|
|
1579
|
+
what: "What checks the work: tests, linters and hooks the agent can run.",
|
|
1580
|
+
unchecked: "It does not see your CI, so it cannot tell a check that always fails from one that works."
|
|
1581
|
+
},
|
|
1582
|
+
{
|
|
1583
|
+
key: "loop",
|
|
1584
|
+
title: "Loop",
|
|
1585
|
+
what: "What sends the agent back when the work is not done.",
|
|
1586
|
+
unchecked: "It does not look at retry or spending limits for runs with no person present."
|
|
1587
|
+
},
|
|
1588
|
+
{
|
|
1589
|
+
key: "memory",
|
|
1590
|
+
title: "Memory",
|
|
1591
|
+
what: "What carries over from one session to the next.",
|
|
1592
|
+
unchecked: "It does not look for handoff notes or a record of decisions."
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
key: "permissions",
|
|
1596
|
+
title: "Permissions",
|
|
1597
|
+
what: "What the agent may do without asking, and what it may never do.",
|
|
1598
|
+
unchecked: "It finds a restricted command only when the instructions write it out, as in git push. It does not understand a rule in plain words."
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
key: "observability",
|
|
1602
|
+
title: "Observability",
|
|
1603
|
+
what: "What a person can see of what the agent did.",
|
|
1604
|
+
unchecked: "It does not look for cost tracking or alerts."
|
|
1605
|
+
}
|
|
1606
|
+
];
|
|
1193
1607
|
function runChecks(facts) {
|
|
1194
|
-
const checks = [...memoryChecks(facts), ...automationChecks(facts), ...guardrailChecks(facts), ...verificationChecks(facts)];
|
|
1195
|
-
return checks.map((check) => ({ ...check, prompt: promptFor(check, facts) }));
|
|
1608
|
+
const checks = [...memoryChecks(facts), ...automationChecks(facts), ...guardrailChecks(facts), ...proseChecks(facts), ...verificationChecks(facts)];
|
|
1609
|
+
return checks.map((check) => ({ ...check, layer: layerOf(check.id), prompt: promptFor(check, facts) }));
|
|
1610
|
+
}
|
|
1611
|
+
function layerSummary(checks) {
|
|
1612
|
+
return LAYERS.map(({ key, title }) => {
|
|
1613
|
+
const mine = checks.filter((c) => c.layer === key);
|
|
1614
|
+
const count = (status) => mine.filter((c) => c.status === status).length;
|
|
1615
|
+
const [pass, warn, fail, info] = [count("pass"), count("warn"), count("fail"), count("info")];
|
|
1616
|
+
const state = fail ? "fix" : warn ? "look" : pass ? "good" : info ? "facts" : "none";
|
|
1617
|
+
return { layer: key, title, pass, warn, fail, info, state };
|
|
1618
|
+
});
|
|
1196
1619
|
}
|
|
1197
1620
|
function summarize2(checks) {
|
|
1198
1621
|
const count = (status) => checks.filter((c) => c.status === status).length;
|
|
@@ -1204,8 +1627,8 @@ var SECRET_NAMES = /^(\.env(\..+)?|secrets?(\..+)?|credentials(\..+)?|.*\.pem|id
|
|
|
1204
1627
|
var NOT_SECRET = /\.(example|sample|template)$/i;
|
|
1205
1628
|
var SECRET_DEPTH = 3;
|
|
1206
1629
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "vendor", "coverage"]);
|
|
1207
|
-
var home = () =>
|
|
1208
|
-
var configDir = () => process.env.CLAUDE_CONFIG_DIR ||
|
|
1630
|
+
var home = () => os4.homedir();
|
|
1631
|
+
var configDir = () => process.env.CLAUDE_CONFIG_DIR || path4.join(home(), ".claude");
|
|
1209
1632
|
var tilde = (file) => file.startsWith(home()) ? `~${file.slice(home().length)}` : file;
|
|
1210
1633
|
function canRead(project) {
|
|
1211
1634
|
try {
|
|
@@ -1217,23 +1640,29 @@ function canRead(project) {
|
|
|
1217
1640
|
}
|
|
1218
1641
|
function readJson(file) {
|
|
1219
1642
|
try {
|
|
1220
|
-
return JSON.parse(
|
|
1643
|
+
return JSON.parse(readFileSync3(file, "utf-8"));
|
|
1221
1644
|
} catch {
|
|
1222
1645
|
return null;
|
|
1223
1646
|
}
|
|
1224
1647
|
}
|
|
1225
1648
|
function countFiles(dir, test) {
|
|
1226
|
-
if (!
|
|
1649
|
+
if (!existsSync4(dir)) return 0;
|
|
1227
1650
|
let total = 0;
|
|
1228
1651
|
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
1229
|
-
if (entry.isDirectory()) total += countFiles(
|
|
1652
|
+
if (entry.isDirectory()) total += countFiles(path4.join(dir, entry.name), test);
|
|
1230
1653
|
else if (test(entry.name)) total += 1;
|
|
1231
1654
|
}
|
|
1232
1655
|
return total;
|
|
1233
1656
|
}
|
|
1657
|
+
function markdownFiles(dir) {
|
|
1658
|
+
if (!existsSync4(dir)) return [];
|
|
1659
|
+
return readdirSync2(dir, { withFileTypes: true }).flatMap(
|
|
1660
|
+
(entry) => entry.isDirectory() ? markdownFiles(path4.join(dir, entry.name)) : entry.name.endsWith(".md") ? [path4.join(dir, entry.name)] : []
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1234
1663
|
function findSecretFiles(root, relative, depth) {
|
|
1235
|
-
const dir =
|
|
1236
|
-
if (depth > SECRET_DEPTH || !
|
|
1664
|
+
const dir = path4.join(root, relative);
|
|
1665
|
+
if (depth > SECRET_DEPTH || !existsSync4(dir)) return [];
|
|
1237
1666
|
const found = [];
|
|
1238
1667
|
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
1239
1668
|
const here = relative ? `${relative}/${entry.name}` : entry.name;
|
|
@@ -1257,13 +1686,13 @@ function hookCommands(hooks) {
|
|
|
1257
1686
|
return found;
|
|
1258
1687
|
}
|
|
1259
1688
|
function subagentFiles(dir) {
|
|
1260
|
-
if (!
|
|
1689
|
+
if (!existsSync4(dir)) return [];
|
|
1261
1690
|
const found = [];
|
|
1262
1691
|
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
1263
|
-
const file =
|
|
1692
|
+
const file = path4.join(dir, entry.name);
|
|
1264
1693
|
if (entry.isDirectory()) found.push(...subagentFiles(file));
|
|
1265
1694
|
else if (entry.name.endsWith(".md")) {
|
|
1266
|
-
const frontmatter = /^---\n([\s\S]*?)\n---/.exec(
|
|
1695
|
+
const frontmatter = /^---\n([\s\S]*?)\n---/.exec(readFileSync3(file, "utf-8"))?.[1] ?? "";
|
|
1267
1696
|
found.push({ name: entry.name.replace(/\.md$/, ""), limitsTools: /^(tools|disallowedTools)\s*:/m.test(frontmatter) });
|
|
1268
1697
|
}
|
|
1269
1698
|
}
|
|
@@ -1273,20 +1702,25 @@ var isMarkdown = (name) => name.endsWith(".md");
|
|
|
1273
1702
|
var strings = (value) => Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
1274
1703
|
function gather(project) {
|
|
1275
1704
|
const filesRead = [];
|
|
1276
|
-
const label = (file) => file.startsWith(project +
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1279
|
-
|
|
1705
|
+
const label = (file) => file.startsWith(project + path4.sep) ? file.slice(project.length + 1) : tilde(file);
|
|
1706
|
+
const restricted = [];
|
|
1707
|
+
const memoryFile = (file, instructions = true) => {
|
|
1708
|
+
if (!existsSync4(file) || !statSync2(file).isFile()) return null;
|
|
1709
|
+
const text = readFileSync3(file, "utf-8");
|
|
1280
1710
|
filesRead.push(label(file));
|
|
1711
|
+
if (instructions) restricted.push(...findRestrictedCommands(text, label(file)));
|
|
1281
1712
|
return { label: label(file), lines: text.split("\n").length - (text.endsWith("\n") ? 1 : 0), bytes: Buffer.byteLength(text) };
|
|
1282
1713
|
};
|
|
1283
1714
|
const memory = [
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
].map(memoryFile).filter((file) => file !== null);
|
|
1715
|
+
path4.join(project, "CLAUDE.md"),
|
|
1716
|
+
path4.join(project, ".claude", "CLAUDE.md"),
|
|
1717
|
+
path4.join(project, "CLAUDE.local.md"),
|
|
1718
|
+
path4.join(project, "AGENTS.md"),
|
|
1719
|
+
path4.join(configDir(), "CLAUDE.md")
|
|
1720
|
+
].map((file) => memoryFile(file)).filter((file) => file !== null);
|
|
1721
|
+
for (const dir of [path4.join(project, ".claude", "rules"), path4.join(configDir(), "rules")]) {
|
|
1722
|
+
for (const file of markdownFiles(dir)) restricted.push(...findRestrictedCommands(readFileSync3(file, "utf-8"), label(file)));
|
|
1723
|
+
}
|
|
1290
1724
|
const settingsFile = (scope, file) => {
|
|
1291
1725
|
const json = readJson(file);
|
|
1292
1726
|
if (!json) return null;
|
|
@@ -1310,12 +1744,12 @@ function gather(project) {
|
|
|
1310
1744
|
const managed = process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : process.platform === "win32" ? "C:\\Program Files\\ClaudeCode\\managed-settings.json" : "/etc/claude-code/managed-settings.json";
|
|
1311
1745
|
const settings = [
|
|
1312
1746
|
settingsFile("managed", managed),
|
|
1313
|
-
settingsFile("local",
|
|
1314
|
-
settingsFile("project",
|
|
1315
|
-
settingsFile("user",
|
|
1747
|
+
settingsFile("local", path4.join(project, ".claude", "settings.local.json")),
|
|
1748
|
+
settingsFile("project", path4.join(project, ".claude", "settings.json")),
|
|
1749
|
+
settingsFile("user", path4.join(configDir(), "settings.json"))
|
|
1316
1750
|
].filter((file) => file !== null);
|
|
1317
|
-
const projectMcp = readJson(
|
|
1318
|
-
const userConfig = readJson(
|
|
1751
|
+
const projectMcp = readJson(path4.join(project, ".mcp.json"));
|
|
1752
|
+
const userConfig = readJson(path4.join(home(), ".claude.json"));
|
|
1319
1753
|
const userServers = Object.keys(userConfig?.mcpServers || {}).length + Object.keys(userConfig?.projects?.[project]?.mcpServers || {}).length;
|
|
1320
1754
|
if (projectMcp) filesRead.push(".mcp.json");
|
|
1321
1755
|
if (userConfig) filesRead.push("~/.claude.json (MCP server names only)");
|
|
@@ -1325,21 +1759,22 @@ function gather(project) {
|
|
|
1325
1759
|
facts: {
|
|
1326
1760
|
platform: process.platform,
|
|
1327
1761
|
memory,
|
|
1328
|
-
ruleFiles: countFiles(
|
|
1329
|
-
autoMemoryIndex: memoryFile(
|
|
1762
|
+
ruleFiles: countFiles(path4.join(project, ".claude", "rules"), isMarkdown) + countFiles(path4.join(configDir(), "rules"), isMarkdown),
|
|
1763
|
+
autoMemoryIndex: memoryFile(path4.join(configDir(), "projects", encoded, "memory", "MEMORY.md"), false),
|
|
1330
1764
|
settings,
|
|
1331
1765
|
skills: {
|
|
1332
|
-
project: countFiles(
|
|
1333
|
-
user: countFiles(
|
|
1766
|
+
project: countFiles(path4.join(project, ".claude", "skills"), (name) => name === "SKILL.md"),
|
|
1767
|
+
user: countFiles(path4.join(configDir(), "skills"), (name) => name === "SKILL.md")
|
|
1334
1768
|
},
|
|
1335
1769
|
subagents: {
|
|
1336
|
-
project: countFiles(
|
|
1337
|
-
user: countFiles(
|
|
1770
|
+
project: countFiles(path4.join(project, ".claude", "agents"), isMarkdown),
|
|
1771
|
+
user: countFiles(path4.join(configDir(), "agents"), isMarkdown)
|
|
1338
1772
|
},
|
|
1339
|
-
subagentFiles: [...subagentFiles(
|
|
1340
|
-
legacyCommands: countFiles(
|
|
1773
|
+
subagentFiles: [...subagentFiles(path4.join(project, ".claude", "agents")), ...subagentFiles(path4.join(configDir(), "agents"))],
|
|
1774
|
+
legacyCommands: countFiles(path4.join(project, ".claude", "commands"), isMarkdown),
|
|
1341
1775
|
mcpServers: { project: Object.keys(projectMcp?.mcpServers || {}).length, user: userServers },
|
|
1342
|
-
secretFiles: findSecretFiles(project, "", 0).sort()
|
|
1776
|
+
secretFiles: findSecretFiles(project, "", 0).sort(),
|
|
1777
|
+
restricted
|
|
1343
1778
|
}
|
|
1344
1779
|
};
|
|
1345
1780
|
}
|
|
@@ -1401,6 +1836,19 @@ function fixCard(check) {
|
|
|
1401
1836
|
return `<section class="check s-${check.status}" id="${id}"><h3>${dot(check.status)}${esc3(check.title)}<span class="word">${status.word}</span></h3><p>${esc3(check.detail)}</p>${check.fix ? `<p class="fix"><b>What to change:</b> ${esc3(check.fix)}</p>` : ""}${prompt}<p class="src mut">Rests on ${sourceLink(check)}</p></section>`;
|
|
1402
1837
|
}
|
|
1403
1838
|
var row2 = (check) => `<li>${dot(check.status)}<b>${esc3(check.title)}<span class="mut"> \xB7 ${STATUS[check.status].word}</span></b><span class="d">${esc3(check.detail)}</span><span class="src mut">${sourceLink(check)}</span></li>`;
|
|
1839
|
+
var LAYER_DOT = { fix: "fail", look: "warn", good: "pass", facts: "info", none: "info" };
|
|
1840
|
+
function layerCount(row22) {
|
|
1841
|
+
const judged = row22.pass + row22.warn + row22.fail;
|
|
1842
|
+
if (judged) return `${row22.pass} of ${judged} good`;
|
|
1843
|
+
return row22.info ? "facts only" : "no check ran";
|
|
1844
|
+
}
|
|
1845
|
+
function layerPanel(checks) {
|
|
1846
|
+
const rows = layerSummary(checks).map((row22) => {
|
|
1847
|
+
const about = LAYERS.find((l) => l.key === row22.layer);
|
|
1848
|
+
return `<li>${dot(LAYER_DOT[row22.state])}<b>${about.title}<span class="mut"> \xB7 ${layerCount(row22)}</span></b><span class="d">${esc3(about.what)} <span class="mut">${esc3(about.unchecked)}</span></span></li>`;
|
|
1849
|
+
});
|
|
1850
|
+
return `<h2>Your harness, layer by layer</h2><p class="mut">An agent is a model and what surrounds it. These are six parts of what surrounds it, with what the checks below found in each.</p><ul class="rows">${rows.join("")}</ul>`;
|
|
1851
|
+
}
|
|
1404
1852
|
function renderPage3(report2) {
|
|
1405
1853
|
const { summary } = report2;
|
|
1406
1854
|
const judged = summary.pass + summary.warn + summary.fail;
|
|
@@ -1413,33 +1861,33 @@ function renderPage3(report2) {
|
|
|
1413
1861
|
const rest = mine.filter((c) => !needsFix(c));
|
|
1414
1862
|
return `<h2>${GROUP_TITLE[group.key]}</h2><p class="mut">${group.intro}</p>${mine.filter(needsFix).map(fixCard).join("")}` + (rest.length ? `<ul class="rows">${rest.map(row2).join("")}</ul>` : "");
|
|
1415
1863
|
}).join("");
|
|
1416
|
-
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>JQ Groundcrew: ${esc3(report2.project)}</title><style>${CSS}</style></head><body><main><h1>JQ Groundcrew</h1><p class="mut">The setup check for Claude Code. How it is set up for <code>${esc3(report2.project)}</code>. Read ${esc3(report2.generatedAt)}. Refresh to read again.</p><div class="score"><div class="tile"><b>${summary.fail}</b><span>to fix</span></div><div class="tile"><b>${summary.warn}</b><span>to look at</span></div><div class="tile"><b>${summary.pass}</b><span>good</span></div><div class="tile"><b>${summary.score}%</b><span>of ${judged} checks pass</span></div></div><div class="bar" role="img" aria-label="${summary.fail} to fix, ${summary.warn} to look at, ${summary.pass} good">${bar}</div>` + todo + groups + `<footer><p>This page was made on your machine from the files below, and it loads nothing, so nothing left the machine. Its one script copies a prompt to your clipboard when you press Copy. It read settings and counted
|
|
1864
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>JQ Groundcrew: ${esc3(report2.project)}</title><style>${CSS}</style></head><body><main><h1>JQ Groundcrew</h1><p class="mut">The setup check for Claude Code. How it is set up for <code>${esc3(report2.project)}</code>. Read ${esc3(report2.generatedAt)}. Refresh to read again.</p><div class="score"><div class="tile"><b>${summary.fail}</b><span>to fix</span></div><div class="tile"><b>${summary.warn}</b><span>to look at</span></div><div class="tile"><b>${summary.pass}</b><span>good</span></div><div class="tile"><b>${summary.score}%</b><span>of ${judged} checks pass</span></div></div><div class="bar" role="img" aria-label="${summary.fail} to fix, ${summary.warn} to look at, ${summary.pass} good">${bar}</div>` + todo + layerPanel(report2.checks) + groups + `<footer><p>This page was made on your machine from the files below, and it loads nothing, so nothing left the machine. Its one script copies a prompt to your clipboard when you press Copy. It read settings and your instruction files, and counted the rest. It did not read the contents of any secret file, and it read no session transcript.</p><p>A suggested prompt asks Claude Code to show its plan or its diff first. Read that before you approve it.</p><ul>${report2.filesRead.map((file) => `<li><code>${esc3(file)}</code></li>`).join("")}</ul><p>Each check names the page of Anthropic\u2019s Claude Code documentation it rests on. The documentation was checked on 2026-11-14 and can change.</p></footer></main><script>${COPY_SCRIPT}</script></body></html>
|
|
1417
1865
|
`;
|
|
1418
1866
|
}
|
|
1419
1867
|
function report(project) {
|
|
1420
1868
|
const { facts, filesRead } = gather(project);
|
|
1421
1869
|
const checks = runChecks(facts);
|
|
1422
|
-
return { project: tilde(project), generatedAt: (/* @__PURE__ */ new Date()).toLocaleString("en-US"), filesRead, checks, summary: summarize2(checks) };
|
|
1870
|
+
return { project: tilde(project), generatedAt: (/* @__PURE__ */ new Date()).toLocaleString("en-US"), filesRead, checks, summary: summarize2(checks), layers: layerSummary(checks) };
|
|
1423
1871
|
}
|
|
1424
1872
|
|
|
1425
1873
|
// src/collect.ts
|
|
1426
|
-
import { existsSync as
|
|
1427
|
-
import
|
|
1874
|
+
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
|
|
1875
|
+
import path6 from "path";
|
|
1428
1876
|
|
|
1429
1877
|
// src/deck.ts
|
|
1430
1878
|
import { createHash } from "crypto";
|
|
1431
|
-
import { existsSync as
|
|
1432
|
-
import
|
|
1433
|
-
import
|
|
1434
|
-
var expandHome = (p) => p === "~" || p.startsWith("~/") ?
|
|
1435
|
-
function
|
|
1436
|
-
return
|
|
1879
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
1880
|
+
import os5 from "os";
|
|
1881
|
+
import path5 from "path";
|
|
1882
|
+
var expandHome = (p) => p === "~" || p.startsWith("~/") ? path5.join(os5.homedir(), p.slice(1)) : p;
|
|
1883
|
+
function defaultConfigFile2() {
|
|
1884
|
+
return path5.join(os5.homedir(), ".jq", "config.json");
|
|
1437
1885
|
}
|
|
1438
1886
|
function loadConfig(file) {
|
|
1439
|
-
if (!
|
|
1887
|
+
if (!existsSync5(file)) return {};
|
|
1440
1888
|
let raw;
|
|
1441
1889
|
try {
|
|
1442
|
-
raw = JSON.parse(
|
|
1890
|
+
raw = JSON.parse(readFileSync4(file, "utf8"));
|
|
1443
1891
|
} catch (e) {
|
|
1444
1892
|
throw new Error(`cannot read ${file}: ${e?.message || e}`);
|
|
1445
1893
|
}
|
|
@@ -1449,7 +1897,7 @@ function loadConfig(file) {
|
|
|
1449
1897
|
if (typeof r.mailbox === "string") out.mailbox = expandHome(r.mailbox);
|
|
1450
1898
|
if (r.names && typeof r.names === "object" && !Array.isArray(r.names)) {
|
|
1451
1899
|
out.names = {};
|
|
1452
|
-
for (const [k, v] of Object.entries(r.names)) if (typeof v === "string") out.names[k] =
|
|
1900
|
+
for (const [k, v] of Object.entries(r.names)) if (typeof v === "string") out.names[k] = path5.resolve(expandHome(v));
|
|
1453
1901
|
}
|
|
1454
1902
|
if (Array.isArray(r.report)) out.report = r.report.filter((q) => typeof q === "string");
|
|
1455
1903
|
if (Array.isArray(r.sendQuestions)) out.sendQuestions = r.sendQuestions.filter((q) => typeof q === "string").map(expandHome);
|
|
@@ -1458,11 +1906,11 @@ function loadConfig(file) {
|
|
|
1458
1906
|
}
|
|
1459
1907
|
function findMailbox(opts) {
|
|
1460
1908
|
const named = opts.flag || opts.config || opts.env;
|
|
1461
|
-
if (named) return
|
|
1462
|
-
let dir =
|
|
1909
|
+
if (named) return path5.resolve(expandHome(named));
|
|
1910
|
+
let dir = path5.resolve(opts.cwd);
|
|
1463
1911
|
for (; ; ) {
|
|
1464
|
-
if (
|
|
1465
|
-
const up =
|
|
1912
|
+
if (existsSync5(path5.join(dir, ".crosstalk"))) return dir;
|
|
1913
|
+
const up = path5.dirname(dir);
|
|
1466
1914
|
if (up === dir) return null;
|
|
1467
1915
|
dir = up;
|
|
1468
1916
|
}
|
|
@@ -1561,8 +2009,8 @@ function originIn(config) {
|
|
|
1561
2009
|
}
|
|
1562
2010
|
function under(tree, folders) {
|
|
1563
2011
|
return folders.some((f) => {
|
|
1564
|
-
const folder =
|
|
1565
|
-
return tree === folder || tree.startsWith(folder +
|
|
2012
|
+
const folder = path5.resolve(expandHome(f));
|
|
2013
|
+
return tree === folder || tree.startsWith(folder + path5.sep);
|
|
1566
2014
|
});
|
|
1567
2015
|
}
|
|
1568
2016
|
function reportable(r, only) {
|
|
@@ -1570,7 +2018,7 @@ function reportable(r, only) {
|
|
|
1570
2018
|
const e = entry.trim();
|
|
1571
2019
|
if (!e) return false;
|
|
1572
2020
|
if (e.toLowerCase() === r.name.toLowerCase() || !!r.remote && e.toLowerCase() === r.remote.toLowerCase()) return true;
|
|
1573
|
-
return /^[~/.]/.test(e) &&
|
|
2021
|
+
return /^[~/.]/.test(e) && path5.resolve(expandHome(e)) === r.tree;
|
|
1574
2022
|
});
|
|
1575
2023
|
}
|
|
1576
2024
|
function teamReport(o, only = null, sendQuestions = []) {
|
|
@@ -1595,10 +2043,10 @@ function teamReport(o, only = null, sendQuestions = []) {
|
|
|
1595
2043
|
|
|
1596
2044
|
// src/collect.ts
|
|
1597
2045
|
function looksLikeProject(dir) {
|
|
1598
|
-
return [".git", ".claude", "CLAUDE.md"].some((f) =>
|
|
2046
|
+
return [".git", ".claude", "CLAUDE.md"].some((f) => existsSync6(path6.join(dir, f)));
|
|
1599
2047
|
}
|
|
1600
2048
|
function checkSetup(tree) {
|
|
1601
|
-
if (!
|
|
2049
|
+
if (!existsSync6(tree)) return { error: "the folder is gone" };
|
|
1602
2050
|
if (!canRead(tree)) return { error: "the folder cannot be read" };
|
|
1603
2051
|
try {
|
|
1604
2052
|
return { summary: summarize2(runChecks(gather(tree).facts)) };
|
|
@@ -1608,15 +2056,15 @@ function checkSetup(tree) {
|
|
|
1608
2056
|
}
|
|
1609
2057
|
function remoteOf(tree) {
|
|
1610
2058
|
try {
|
|
1611
|
-
let gitDir =
|
|
2059
|
+
let gitDir = path6.join(tree, ".git");
|
|
1612
2060
|
if (statSync3(gitDir).isFile()) {
|
|
1613
|
-
const m = /^gitdir:\s*(.+)$/m.exec(
|
|
2061
|
+
const m = /^gitdir:\s*(.+)$/m.exec(readFileSync5(gitDir, "utf8"));
|
|
1614
2062
|
if (!m) return null;
|
|
1615
|
-
gitDir =
|
|
1616
|
-
const common =
|
|
1617
|
-
if (
|
|
2063
|
+
gitDir = path6.resolve(tree, m[1].trim());
|
|
2064
|
+
const common = path6.join(gitDir, "commondir");
|
|
2065
|
+
if (existsSync6(common)) gitDir = path6.resolve(gitDir, readFileSync5(common, "utf8").trim());
|
|
1618
2066
|
}
|
|
1619
|
-
return originIn(
|
|
2067
|
+
return originIn(readFileSync5(path6.join(gitDir, "config"), "utf8"));
|
|
1620
2068
|
} catch {
|
|
1621
2069
|
return null;
|
|
1622
2070
|
}
|
|
@@ -1636,7 +2084,7 @@ async function collectOverview(opts) {
|
|
|
1636
2084
|
if (opts.mailbox) {
|
|
1637
2085
|
try {
|
|
1638
2086
|
waiting = waitingBoard(readMailbox(opts.mailbox), opts.now ?? Date.now());
|
|
1639
|
-
inboxes = readdirSync3(
|
|
2087
|
+
inboxes = readdirSync3(path6.join(opts.mailbox, "inbox"), { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== BOARD).map((e) => e.name);
|
|
1640
2088
|
} catch (e) {
|
|
1641
2089
|
mailNote = String(e?.message || e);
|
|
1642
2090
|
}
|
|
@@ -1760,7 +2208,7 @@ function parseArgs(argv, env = {}) {
|
|
|
1760
2208
|
sendQuestions: null,
|
|
1761
2209
|
port: DEFAULT_PORT,
|
|
1762
2210
|
mailbox: null,
|
|
1763
|
-
config: env.JQ_DECK_CONFIG ||
|
|
2211
|
+
config: env.JQ_DECK_CONFIG || defaultConfigFile2(),
|
|
1764
2212
|
questionTrees: env.JQ_AGENTS_QUESTION_TREES ? list(env.JQ_AGENTS_QUESTION_TREES) : null,
|
|
1765
2213
|
probe: false,
|
|
1766
2214
|
sample: true,
|
|
@@ -1807,17 +2255,18 @@ function reportList(a, fromConfig) {
|
|
|
1807
2255
|
function buildContext(a, env, cwd, version) {
|
|
1808
2256
|
const config = loadConfig(expandHome(a.config));
|
|
1809
2257
|
return {
|
|
2258
|
+
configFile: expandHome(a.config),
|
|
1810
2259
|
port: a.port,
|
|
1811
2260
|
version,
|
|
1812
2261
|
probe: a.probe,
|
|
1813
2262
|
sample: a.sample,
|
|
1814
2263
|
report: a.watch ? reportList(a, config.report) : null,
|
|
1815
|
-
sendQuestions: a.watch ? (a.sendQuestions ?? config.sendQuestions ?? []).map((t) =>
|
|
2264
|
+
sendQuestions: a.watch ? (a.sendQuestions ?? config.sendQuestions ?? []).map((t) => path7.resolve(expandHome(t))) : [],
|
|
1816
2265
|
deck: {
|
|
1817
2266
|
mailbox: findMailbox({ flag: a.mailbox, config: config.mailbox, env: env.CROSSTALK_DIR, cwd }),
|
|
1818
2267
|
names: config.names,
|
|
1819
2268
|
// Off unless asked for: question text is a session's own words.
|
|
1820
|
-
questionTrees: (a.questionTrees ?? config.questions ?? []).map((t) =>
|
|
2269
|
+
questionTrees: (a.questionTrees ?? config.questions ?? []).map((t) => path7.resolve(expandHome(t))),
|
|
1821
2270
|
maxAgeDays: a.maxAgeDays,
|
|
1822
2271
|
cwd
|
|
1823
2272
|
}
|
|
@@ -1837,7 +2286,7 @@ async function handle(url, host, ctx, overview2 = collectOverview) {
|
|
|
1837
2286
|
return html(renderShell(await overview2(ctx.deck), tab, u.searchParams.get("repo"), ctx.version));
|
|
1838
2287
|
}
|
|
1839
2288
|
if (u.pathname === "/raw/sessions") {
|
|
1840
|
-
return html(renderPage(await snapshot({ questionTrees: ctx.deck.questionTrees, maxAgeDays: ctx.deck.maxAgeDays, projectsDir: ctx.deck.projectsDir, sockDir: ctx.deck.sockDir, probe: ctx.probe, sample: ctx.sample })));
|
|
2289
|
+
return html(renderPage(await snapshot({ questionTrees: ctx.deck.questionTrees, maxAgeDays: ctx.deck.maxAgeDays, projectsDir: ctx.deck.projectsDir, sockDir: ctx.deck.sockDir, probe: ctx.probe, sample: ctx.sample, turnCheck: readTurnCheckConfig(ctx.configFile) })));
|
|
1841
2290
|
}
|
|
1842
2291
|
if (u.pathname === "/raw/setup") {
|
|
1843
2292
|
const row3 = (await overview2(ctx.deck)).repos.find((r) => r.id === u.searchParams.get("repo"));
|
|
@@ -1906,7 +2355,7 @@ async function run2(argv, version) {
|
|
|
1906
2355
|
}
|
|
1907
2356
|
|
|
1908
2357
|
// src/main.ts
|
|
1909
|
-
var VERSION = true ? "0.3.
|
|
2358
|
+
var VERSION = true ? "0.3.2" : "dev";
|
|
1910
2359
|
var HELP = `JQ Deck ${VERSION}: one page for your Claude Code sessions, their setup and their mail.
|
|
1911
2360
|
|
|
1912
2361
|
jq-deck open the page at http://127.0.0.1:${DEFAULT_PORT}
|