taskquoin 0.0.0-stage → 2026.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/LICENSE +55 -0
  3. package/README.md +227 -2
  4. package/SECURITY.md +26 -0
  5. package/adapters/git/src/git.js +250 -0
  6. package/adapters/git/src/index.js +1 -0
  7. package/adapters/hooks-claude/src/canonical.js +45 -0
  8. package/adapters/hooks-claude/src/index.js +2 -0
  9. package/adapters/hooks-claude/src/main.js +58 -0
  10. package/adapters/hooks-claude/src/payload.js +40 -0
  11. package/adapters/host-probe/src/index.js +2 -0
  12. package/adapters/host-probe/src/ollama.js +18 -0
  13. package/adapters/host-probe/src/probe.js +107 -0
  14. package/adapters/local-tool/src/fingerprint.js +56 -0
  15. package/adapters/local-tool/src/index.js +4 -0
  16. package/adapters/local-tool/src/local-tool.js +22 -0
  17. package/adapters/local-tool/src/sandboxed.js +105 -0
  18. package/adapters/local-tool/src/scan.js +52 -0
  19. package/adapters/memory-claude-mem/src/claude-mem.js +115 -0
  20. package/adapters/memory-claude-mem/src/index.js +1 -0
  21. package/adapters/process-runner/src/index.js +1 -0
  22. package/adapters/process-runner/src/runner.js +123 -0
  23. package/adapters/runtime-api/src/capabilities.json +116 -0
  24. package/adapters/runtime-api/src/executor.js +131 -0
  25. package/adapters/runtime-api/src/index.js +1 -0
  26. package/adapters/runtime-claude/src/capabilities.json +375 -0
  27. package/adapters/runtime-claude/src/command.js +34 -0
  28. package/adapters/runtime-claude/src/executor.js +162 -0
  29. package/adapters/runtime-claude/src/index.js +4 -0
  30. package/adapters/runtime-claude/src/permissions.js +76 -0
  31. package/adapters/runtime-claude/src/stream.js +60 -0
  32. package/adapters/runtime-codex/src/capabilities.json +192 -0
  33. package/adapters/runtime-codex/src/command.js +36 -0
  34. package/adapters/runtime-codex/src/executor.js +83 -0
  35. package/adapters/runtime-codex/src/index.js +4 -0
  36. package/adapters/runtime-codex/src/scratch.js +32 -0
  37. package/adapters/runtime-codex/src/stream.js +39 -0
  38. package/adapters/runtime-opencode/src/capabilities.json +149 -0
  39. package/adapters/runtime-opencode/src/config.js +33 -0
  40. package/adapters/runtime-opencode/src/credentials.js +130 -0
  41. package/adapters/runtime-opencode/src/executor.js +127 -0
  42. package/adapters/runtime-opencode/src/facts.js +43 -0
  43. package/adapters/runtime-opencode/src/hosts.js +16 -0
  44. package/adapters/runtime-opencode/src/hosts.json +3 -0
  45. package/adapters/runtime-opencode/src/index.js +6 -0
  46. package/adapters/runtime-opencode/src/mounts.js +58 -0
  47. package/adapters/runtime-opencode/src/stream.js +63 -0
  48. package/adapters/skill-store/src/index.js +1 -0
  49. package/adapters/skill-store/src/skill-store.js +162 -0
  50. package/adapters/store-fs/src/index.js +2 -0
  51. package/adapters/store-fs/src/store.js +201 -0
  52. package/adapters/store-fs/src/trusted-dir.js +37 -0
  53. package/apps/cli/src/console.js +432 -0
  54. package/apps/cli/src/dashboard-approve.js +259 -0
  55. package/apps/cli/src/dashboard-data.js +424 -0
  56. package/apps/cli/src/dashboard.js +500 -0
  57. package/apps/cli/src/history.js +35 -0
  58. package/apps/cli/src/home.js +18 -0
  59. package/apps/cli/src/i18n/en.js +527 -0
  60. package/apps/cli/src/i18n/index.js +90 -0
  61. package/apps/cli/src/i18n/languages.js +25 -0
  62. package/apps/cli/src/i18n/locales/ar.json +526 -0
  63. package/apps/cli/src/i18n/locales/de.json +505 -0
  64. package/apps/cli/src/i18n/locales/es.json +505 -0
  65. package/apps/cli/src/i18n/locales/fa.json +505 -0
  66. package/apps/cli/src/i18n/locales/fr.json +505 -0
  67. package/apps/cli/src/i18n/locales/he.json +505 -0
  68. package/apps/cli/src/i18n/locales/hi.json +505 -0
  69. package/apps/cli/src/i18n/locales/id.json +491 -0
  70. package/apps/cli/src/i18n/locales/it.json +505 -0
  71. package/apps/cli/src/i18n/locales/ja.json +491 -0
  72. package/apps/cli/src/i18n/locales/ko.json +491 -0
  73. package/apps/cli/src/i18n/locales/nl.json +505 -0
  74. package/apps/cli/src/i18n/locales/pl.json +512 -0
  75. package/apps/cli/src/i18n/locales/pt-BR.json +505 -0
  76. package/apps/cli/src/i18n/locales/ru.json +512 -0
  77. package/apps/cli/src/i18n/locales/th.json +491 -0
  78. package/apps/cli/src/i18n/locales/tr.json +505 -0
  79. package/apps/cli/src/i18n/locales/uk.json +512 -0
  80. package/apps/cli/src/i18n/locales/vi.json +491 -0
  81. package/apps/cli/src/i18n/locales/zh-CN.json +491 -0
  82. package/apps/cli/src/i18n/locales/zh-TW.json +491 -0
  83. package/apps/cli/src/i18n/width.js +40 -0
  84. package/apps/cli/src/layout.js +18 -0
  85. package/apps/cli/src/main.js +830 -0
  86. package/apps/cli/src/preferences.js +46 -0
  87. package/apps/cli/src/runtime-notices.js +41 -0
  88. package/apps/cli/src/safe-text.js +3 -0
  89. package/apps/cli/src/shortcut.js +82 -0
  90. package/apps/cli/src/skills-cli.js +112 -0
  91. package/apps/cli/src/tui/caps.js +31 -0
  92. package/apps/cli/src/tui/components/agent-list.js +58 -0
  93. package/apps/cli/src/tui/components/approval-center.js +145 -0
  94. package/apps/cli/src/tui/components/approval.js +95 -0
  95. package/apps/cli/src/tui/components/dashboard-frame.js +293 -0
  96. package/apps/cli/src/tui/components/diff-viewer.js +549 -0
  97. package/apps/cli/src/tui/components/event-viewer.js +46 -0
  98. package/apps/cli/src/tui/components/help-panel.js +59 -0
  99. package/apps/cli/src/tui/components/home.js +185 -0
  100. package/apps/cli/src/tui/components/logo.js +67 -0
  101. package/apps/cli/src/tui/components/panel.js +70 -0
  102. package/apps/cli/src/tui/components/status-bar.js +96 -0
  103. package/apps/cli/src/tui/components/timeline.js +120 -0
  104. package/apps/cli/src/tui/keys.js +139 -0
  105. package/apps/cli/src/tui/neutral.js +68 -0
  106. package/apps/cli/src/tui/screen.js +111 -0
  107. package/apps/cli/src/tui/text.js +165 -0
  108. package/apps/cli/src/tui/tokens.js +89 -0
  109. package/apps/cli/src/tui/view.js +64 -0
  110. package/apps/cli/src/upgrade-check.js +86 -0
  111. package/apps/cli/src/upgrade-cli.js +168 -0
  112. package/apps/cli/src/workflow-cli.js +674 -0
  113. package/package.json +29 -4
  114. package/packages/application/src/index.js +8 -0
  115. package/packages/application/src/lib/digest.js +7 -0
  116. package/packages/application/src/ports/memory.js +1 -0
  117. package/packages/application/src/ports/runtime-executor.js +1 -0
  118. package/packages/application/src/projection/run-view.js +194 -0
  119. package/packages/application/src/projection/squad-view.js +33 -0
  120. package/packages/application/src/use-cases/prepare-run.js +68 -0
  121. package/packages/application/src/workflow/feature-governed.js +420 -0
  122. package/packages/application/src/workflow/gate-signals.js +40 -0
  123. package/packages/application/src/workflow/prompts.js +81 -0
  124. package/packages/config/src/config.js +372 -0
  125. package/packages/config/src/index.js +1 -0
  126. package/packages/domain/src/capabilities.js +13 -0
  127. package/packages/domain/src/capability-matrix.js +63 -0
  128. package/packages/domain/src/enforcement.js +95 -0
  129. package/packages/domain/src/index.js +4 -0
  130. package/packages/domain/src/policy.js +32 -0
  131. package/packages/rules/src/glob.js +47 -0
  132. package/packages/rules/src/index.js +5 -0
  133. package/packages/rules/src/inherit.js +19 -0
  134. package/packages/rules/src/lists.js +41 -0
  135. package/packages/rules/src/rules.js +79 -0
  136. package/packages/rules/src/shell.js +83 -0
  137. package/packages/skills/src/index.js +1 -0
  138. package/packages/skills/src/skills.js +108 -0
  139. package/skills/code-review/SKILL.md +51 -0
  140. package/skills/egm-design/LICENSE +202 -0
  141. package/skills/egm-design/SKILL.md +68 -0
  142. package/skills/egm-design/references/feature-spec-standard.md +39 -0
  143. package/skills/egm-implementation-readiness/LICENSE +202 -0
  144. package/skills/egm-implementation-readiness/SKILL.md +67 -0
  145. package/skills/egm-implementation-readiness/references/implementation-readiness-standard.md +37 -0
  146. package/skills/first-party.lock.json +10 -0
  147. package/skills/planning-contract/SKILL.md +51 -0
  148. package/skills/ponytail/LICENSE +21 -0
  149. package/skills/ponytail/SKILL.md +56 -0
  150. package/skills/security-review/SKILL.md +58 -0
  151. package/skills/tdd/SKILL.md +52 -0
  152. package/skills/unslop/LICENSE +396 -0
  153. package/skills/unslop/SKILL.md +239 -0
  154. package/skills/unslop/references/cjk.md +34 -0
  155. package/skills/unslop/references/effects.md +113 -0
  156. package/skills/unslop/references/refs.md +17 -0
  157. package/skills/unslop/references/rtl.md +111 -0
  158. package/skills/unslop/references/signs.md +122 -0
  159. package/skills/unslop/references/tokens.md +139 -0
  160. package/skills/unslop/references/visuals.md +84 -0
@@ -0,0 +1,259 @@
1
+ /**
2
+ * The dashboard's approval form (skill rule 1, "approvals are typed, never pressed"; ADR-0015 unchanged). No key
3
+ * approves: the form only collects what the human types and hands it, once, to the existing `approve` path — the
4
+ * 12 characters typed go to `--expect`, the name is recorded as `<name> (via taskquoin dashboard)`.
5
+ * - Nothing typed before the form is on screen counts: `typeAhead()` drops it, and `key()` before `open()` too.
6
+ * - Each `key(chunk)` is one input event. Only a chunk holding a single Enter submits; a paste or a chunk of several
7
+ * keys (type-ahead, an unbracketed paste) appends its text and never submits.
8
+ * - The binding is read again when the form opens, when the hash step starts and after the last keystroke (the
9
+ * submitting Enter): absent, another gate or another hash refuses (`stale`) and nothing is approved.
10
+ * - Esc and Ctrl+C cancel while something is being typed; after `sent` they only close the view (an approval may
11
+ * already be recorded: the screen never says "nothing was approved" then).
12
+ * The name is trimmed and capped at 64 characters, never starts with `/` or `-`, kept in memory by the caller (`onName`), never read from the OS.
13
+ *
14
+ * The approval itself is the existing CLI path, in its own process (spec §6): `spawnApprove` starts
15
+ * `taskquoin approve <run> <gate> --expect=<typed> --as="<name> (via taskquoin dashboard)"` detached, its output in a
16
+ * private log file (never a pipe: quitting the dashboard must not kill the run with EPIPE). Whether it approved is
17
+ * what the control store records (`approvalRecorded`), never its exit code.
18
+ */
19
+ import { spawn as nodeSpawn } from 'node:child_process';
20
+ import { closeSync, fstatSync, mkdtempSync, openSync, readSync } from 'node:fs';
21
+ import { tmpdir } from 'node:os';
22
+ import { join } from 'node:path';
23
+ import { keyDecoder } from "./tui/keys.js";
24
+ import { neutralize } from "./tui/neutral.js";
25
+ import { renderApprovalCenter } from "./tui/components/approval-center.js";
26
+ export const VIA_DASHBOARD = ' (via taskquoin dashboard)';
27
+ export const NAME_MAX = 64;
28
+ export const HASH_LEN = 12;
29
+ const PASTE_START = '\x1b[200~', PASTE_END = '\x1b[201~';
30
+ const chars = (s) => [...s];
31
+ /** The name as recorded: trimmed, at most 64 characters (code points). */
32
+ export const cleanName = (s) => chars(s.trim()).slice(0, NAME_MAX).join('').trim();
33
+ export function approvalForm(o) {
34
+ const now = o.now ?? (() => new Date());
35
+ const decoder = keyDecoder();
36
+ let opened = false;
37
+ let step = { step: 'not-waiting' };
38
+ // A name the session kept: only one that could have been typed (no control, bidi or invisible character); else asked again.
39
+ const given = o.approver !== undefined && neutralize(o.approver, { singleLine: true }).marked === 0 ? cleanName(o.approver) : '';
40
+ let name = given !== '' && !given.startsWith('/') && !given.startsWith('-') ? given : undefined;
41
+ let reReadAt;
42
+ let sentOnce = false;
43
+ let dropPaste = false; // a bracketed paste begun before the form was on screen: its end is dropped too
44
+ const same = (p, shown) => p !== undefined && p.gate === o.gate && p.binding === shown.binding;
45
+ /** The hash step, from a binding read now. */
46
+ const toHash = () => {
47
+ const p = o.pending();
48
+ reReadAt = now().toISOString();
49
+ if (!p || p.gate !== o.gate)
50
+ return { step: 'not-waiting' };
51
+ return { step: 'hash', shown: { binding: p.binding, at: reReadAt }, text: '' };
52
+ };
53
+ const nameKey = (s, k, multi) => {
54
+ const { error: _e, ...plain } = s;
55
+ // the field never starts with a space and holds at most 64 characters: what is kept is what is recorded
56
+ const append = (text) => ({ ...plain, text: chars((s.text + text).trimStart()).slice(0, NAME_MAX).join('') });
57
+ switch (k.name) {
58
+ case 'char': return append(k.ch);
59
+ case 'paste': {
60
+ if (dropPaste) {
61
+ dropPaste = false;
62
+ return s;
63
+ }
64
+ if (neutralize(k.text, { singleLine: true }).marked > 0)
65
+ return { ...plain, error: 'controls' };
66
+ return append(k.text);
67
+ }
68
+ case 'backspace': return { ...plain, text: chars(s.text).slice(0, -1).join('') };
69
+ case 'unknown': return k.seq.startsWith('\x1b') ? s : { ...plain, error: 'controls' };
70
+ case 'enter': {
71
+ if (multi)
72
+ return s; // an Enter inside a chunk of several keys never submits
73
+ const typed = cleanName(s.text);
74
+ if (typed === '')
75
+ return { step: 'cancelled' };
76
+ if (typed.startsWith('/'))
77
+ return { step: 'name', text: '', error: 'slash' };
78
+ if (typed.startsWith('-'))
79
+ return { step: 'name', text: '', error: 'dash' }; // never read as an option by taskquoin approve
80
+ name = typed;
81
+ o.onName?.(typed);
82
+ return toHash();
83
+ }
84
+ default: return s;
85
+ }
86
+ };
87
+ let handed; // what approve() returned, awaited by key() once the state is `sent`
88
+ const hashKey = (s, k, multi) => {
89
+ const { error: _e, ...plain } = s;
90
+ const append = (text) => ({ ...plain, text: chars(s.text + text).slice(0, HASH_LEN).join('') });
91
+ switch (k.name) {
92
+ case 'char': return append(k.ch);
93
+ case 'paste': {
94
+ if (dropPaste) {
95
+ dropPaste = false;
96
+ return s;
97
+ }
98
+ const text = k.text.replace(/[\r\n]/g, '').trim();
99
+ if (neutralize(text, { singleLine: true }).marked > 0)
100
+ return { ...plain, error: 'controls' };
101
+ return append(text);
102
+ }
103
+ case 'backspace': return { ...plain, text: chars(s.text).slice(0, -1).join('') };
104
+ case 'unknown': return k.seq.startsWith('\x1b') ? s : { ...plain, error: 'controls' };
105
+ case 'enter': {
106
+ if (multi)
107
+ return s;
108
+ const typed = s.text.trim().toLowerCase();
109
+ if (typed === '')
110
+ return { step: 'cancelled' };
111
+ // after the last keystroke: what is approved is what was shown, or nothing
112
+ const p = o.pending();
113
+ reReadAt = now().toISOString();
114
+ if (!same(p, s.shown))
115
+ return { step: 'stale', shown: s.shown, ...(p ? { now: p } : {}) };
116
+ if (typed !== s.shown.binding.slice(0, HASH_LEN).toLowerCase())
117
+ return { ...plain, text: '', error: 'mismatch' };
118
+ if (sentOnce || name === undefined)
119
+ return s;
120
+ sentOnce = true;
121
+ const as = name + VIA_DASHBOARD;
122
+ step = { step: 'sent', shown: s.shown, as };
123
+ handed = o.approve(o.runId, o.gate, typed, as);
124
+ return step;
125
+ }
126
+ default: return s;
127
+ }
128
+ };
129
+ /** Dropped. The decoder still reads it, so a bracketed paste it began is known, and dropped whole when it ends. */
130
+ const typeAhead = (chunk) => {
131
+ decoder.feed(chunk);
132
+ decoder.flush();
133
+ const start = chunk.lastIndexOf(PASTE_START), end = chunk.lastIndexOf(PASTE_END);
134
+ if (start > end)
135
+ dropPaste = true;
136
+ else if (end >= 0)
137
+ dropPaste = false;
138
+ };
139
+ return {
140
+ open() {
141
+ opened = true;
142
+ const p = o.pending();
143
+ reReadAt = now().toISOString();
144
+ if (!p || p.gate !== o.gate) {
145
+ step = { step: 'not-waiting' };
146
+ return;
147
+ }
148
+ step = name === undefined ? { step: 'name', text: '' } : { step: 'hash', shown: { binding: p.binding, at: reReadAt }, text: '' };
149
+ },
150
+ typeAhead,
151
+ async key(chunk) {
152
+ if (!opened) {
153
+ typeAhead(chunk);
154
+ return;
155
+ }
156
+ const keys = [...decoder.feed(chunk), ...decoder.flush()].flatMap((c) => c.keys);
157
+ const multi = keys.length > 1;
158
+ for (const k of keys) {
159
+ const s = step;
160
+ if (s.step !== 'name' && s.step !== 'hash')
161
+ return; // after the form: the caller closes the view, nothing is re-sent
162
+ if (k.name === 'esc' || k.name === 'ctrl-c') {
163
+ step = { step: 'cancelled' };
164
+ return;
165
+ }
166
+ step = s.step === 'name' ? nameKey(s, k, multi) : hashKey(s, k, multi);
167
+ }
168
+ // every state change above is synchronous; only what approve() returned is waited for
169
+ if (handed !== undefined) {
170
+ const h = handed;
171
+ handed = undefined;
172
+ await h;
173
+ }
174
+ },
175
+ refresh() {
176
+ if (step.step !== 'hash')
177
+ return;
178
+ const p = o.pending();
179
+ reReadAt = now().toISOString();
180
+ step = { ...step, changed: !same(p, step.shown) };
181
+ },
182
+ state: () => structuredClone(step),
183
+ approver: () => name,
184
+ render(caps, height = caps.rows, outcome) {
185
+ return renderApprovalCenter(step, { ...o.context(), gate: o.gate, ...(name !== undefined ? { approver: name } : {}), ...(reReadAt !== undefined ? { reReadAt } : {}), ...(outcome ? { outcome } : {}) }, caps, height);
186
+ },
187
+ };
188
+ }
189
+ /** The last bytes of a log, cut at a line start, each line neutralised (log profile, one line each). */
190
+ function tailOf(path, maxBytes) {
191
+ let fd;
192
+ try {
193
+ fd = openSync(path, 'r');
194
+ const size = fstatSync(fd).size, len = Math.min(size, Math.max(0, maxBytes));
195
+ const buf = Buffer.alloc(len);
196
+ readSync(fd, buf, 0, len, size - len);
197
+ let lines = buf.toString('utf8').split(/\r?\n/);
198
+ if (len < size)
199
+ lines = lines.slice(1); // the first line was cut
200
+ while (lines.length && lines.at(-1).trim() === '')
201
+ lines.pop();
202
+ return lines.map((l) => neutralize(l, { profile: 'log', singleLine: true }).text).join('\n');
203
+ }
204
+ catch {
205
+ return '';
206
+ }
207
+ finally {
208
+ if (fd !== undefined)
209
+ closeSync(fd);
210
+ }
211
+ }
212
+ /**
213
+ * Starts `taskquoin approve` in its own process: argv exactly `[entry, 'approve', runId, gate, '--expect=<expect>',
214
+ * '--as=<as>']` (one element per option, so a value is never read as an option; no shell), detached, stdin ignored, stdout and stderr to `approve.log` (0600, `wx`) in a fresh 0700
215
+ * directory; the descriptor is closed here once the child has it; `unref()` so the dashboard can quit while it runs.
216
+ */
217
+ export function spawnApprove(o) {
218
+ const dir = mkdtempSync(join(tmpdir(), 'taskquoin-approve-'));
219
+ const logPath = join(dir, 'approve.log');
220
+ const fd = openSync(logPath, 'wx', 0o600);
221
+ let child;
222
+ try {
223
+ child = (o.spawn ?? nodeSpawn)(o.node, [o.entry, 'approve', o.runId, o.gate, `--expect=${o.expect}`, `--as=${o.as}`], { cwd: o.cwd, detached: true, stdio: ['ignore', fd, fd], env: { ...o.env, NO_COLOR: '1', TASKQUOIN_NO_SETUP: '1' } });
224
+ }
225
+ finally {
226
+ closeSync(fd);
227
+ }
228
+ const exited = new Promise((resolve) => {
229
+ child.once('exit', (code, signal) => { resolve({ code, signal }); });
230
+ child.once('error', () => { resolve({ code: null, signal: null }); });
231
+ });
232
+ child.unref();
233
+ if (child.pid === undefined)
234
+ throw new Error('taskquoin approve could not be started');
235
+ return { pid: child.pid, logPath, exited, tail: (maxBytes = 4096) => tailOf(logPath, maxBytes) };
236
+ }
237
+ /** The approval the store holds for this send, when there is one: its time. Records already there before (`before`) do not count. */
238
+ export function approvalRecord(state, events, sent, before) {
239
+ const node = sent.gate === 'plan' ? 'approve-plan' : 'approve-commit';
240
+ const as = sent.as.trim();
241
+ const byUs = (by) => typeof by === 'string' && by.trim() === as;
242
+ const match = (e) => e.type === 'approval' && e.node === node && e.binding === sent.binding && byUs(e.approvedBy);
243
+ const found = events.filter(match), old = before ? before.events.filter(match).length : 0;
244
+ if (found.length > old) {
245
+ const ts = found.at(-1).ts;
246
+ return typeof ts === 'string' ? { at: ts } : {};
247
+ }
248
+ const rec = state?.approvals?.[node];
249
+ if (!rec || rec.binding !== sent.binding || !byUs(rec.approvedBy))
250
+ return undefined;
251
+ const prev = before?.state?.approvals?.[node];
252
+ if (prev && prev.binding === rec.binding && prev.approvedBy === rec.approvedBy && prev.at === rec.at)
253
+ return undefined;
254
+ return typeof rec.at === 'string' ? { at: rec.at } : {};
255
+ }
256
+ /** True when the store records this approval: an `approval` event for the gate's node, the binding and `approvedBy === as`, or `state.approvals[node]` with both. */
257
+ export function approvalRecorded(state, events, sent, before) {
258
+ return approvalRecord(state, events, sent, before) !== undefined;
259
+ }