@bonesofspring/ai-rules 0.2.65 → 0.2.66
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/CHANGELOG.md +34 -0
- package/README.md +19 -11
- package/bin/lib/engine-scripts.js +38 -7
- package/bin/lib/engine-upgrade.js +5 -2
- package/bin/lib/seed-ai-local-team.js +6 -3
- package/docs/OPENCODE.md +17 -9
- package/docs/TEAM-DB.md +52 -13
- package/docs/TOKEN-ECONOMY.md +79 -0
- package/package.json +7 -2
- package/presets/_shared/ai-local/scripts/dump-output.mjs +371 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +82 -2
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +3 -1
- package/presets/_shared/core/architecture/feature-delivery-workflow.md +4 -0
- package/presets/_shared/core/quality/context-and-iteration.md +1 -0
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/mol/agents/task-analyst.md +1 -1
- package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/next/agents/task-analyst.md +1 -1
- package/presets/claude/next/commands/README.md +1 -1
- package/presets/claude/next/commands/task.md +1 -1
- package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/next/team/README.md +7 -3
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/agents/task-analyst.md +1 -1
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/commands/README.md +1 -1
- package/presets/cursor/next/commands/task.md +1 -1
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +3 -1
- package/presets/cursor/next/team/README.md +7 -3
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -1
- package/presets/mavis/next/commands/README.md +1 -1
- package/presets/mavis/next/commands/task.md +1 -1
- package/presets/mavis/next/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/next/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/next/team/README.md +7 -3
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -1
- package/presets/opencode/next/commands/README.md +1 -1
- package/presets/opencode/next/commands/task.md +1 -1
- package/presets/opencode/next/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/next/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/next/team/README.md +7 -3
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/plugins/task-status/README.md +23 -11
- package/presets/opencode/plugins/task-status/details-data.ts +64 -46
- package/presets/opencode/plugins/task-status/details.tsx +12 -2
- package/presets/opencode/plugins/task-status/format.ts +16 -0
- package/presets/opencode/plugins/task-status/prompt-text.ts +37 -0
- package/presets/opencode/plugins/task-status/task-view.ts +241 -177
- package/presets/opencode/plugins/task-status/tui.tsx +57 -15
- package/presets/opencode/plugins/task-status/types.ts +74 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/agents/task-analyst.md +1 -1
- package/presets/zcode/next/commands/README.md +1 -1
- package/presets/zcode/next/commands/task.md +1 -1
- package/presets/zcode/next/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/next/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/next/team/README.md +7 -3
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/_shared/ai-local/scripts/upstream-research.mjs +0 -2964
- package/presets/claude/next/commands/upstream-research.md +0 -23
- package/presets/claude/next/team/upstream/config.json +0 -31
- package/presets/claude/next/team/upstream/digest-template.md +0 -55
- package/presets/claude/next/team/upstream/jobs.json +0 -34
- package/presets/claude/next/team/upstream/opencode.json +0 -34
- package/presets/claude/next/team/upstream/projects.json +0 -4
- package/presets/claude/next/team/upstream/prompt.md +0 -77
- package/presets/claude/next/team/upstream/signatures.json +0 -9
- package/presets/cursor/next/commands/upstream-research.md +0 -23
- package/presets/cursor/next/team/upstream/config.json +0 -31
- package/presets/cursor/next/team/upstream/digest-template.md +0 -55
- package/presets/cursor/next/team/upstream/jobs.json +0 -34
- package/presets/cursor/next/team/upstream/opencode.json +0 -34
- package/presets/cursor/next/team/upstream/projects.json +0 -4
- package/presets/cursor/next/team/upstream/prompt.md +0 -77
- package/presets/cursor/next/team/upstream/signatures.json +0 -9
- package/presets/mavis/next/commands/upstream-research.md +0 -18
- package/presets/mavis/next/team/upstream/config.json +0 -31
- package/presets/mavis/next/team/upstream/digest-template.md +0 -55
- package/presets/mavis/next/team/upstream/jobs.json +0 -34
- package/presets/mavis/next/team/upstream/opencode.json +0 -34
- package/presets/mavis/next/team/upstream/projects.json +0 -4
- package/presets/mavis/next/team/upstream/prompt.md +0 -77
- package/presets/mavis/next/team/upstream/signatures.json +0 -9
- package/presets/opencode/next/commands/upstream-research.md +0 -26
- package/presets/opencode/next/team/upstream/config.json +0 -31
- package/presets/opencode/next/team/upstream/digest-template.md +0 -55
- package/presets/opencode/next/team/upstream/jobs.json +0 -34
- package/presets/opencode/next/team/upstream/opencode.json +0 -34
- package/presets/opencode/next/team/upstream/projects.json +0 -4
- package/presets/opencode/next/team/upstream/prompt.md +0 -77
- package/presets/opencode/next/team/upstream/signatures.json +0 -9
- package/presets/zcode/next/commands/upstream-research.md +0 -26
- package/presets/zcode/next/team/upstream/config.json +0 -31
- package/presets/zcode/next/team/upstream/digest-template.md +0 -55
- package/presets/zcode/next/team/upstream/jobs.json +0 -34
- package/presets/zcode/next/team/upstream/opencode.json +0 -34
- package/presets/zcode/next/team/upstream/projects.json +0 -4
- package/presets/zcode/next/team/upstream/prompt.md +0 -77
- package/presets/zcode/next/team/upstream/signatures.json +0 -9
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Externalize a command's output into the task directory.
|
|
3
|
+
*
|
|
4
|
+
* Reads stdin (or `--input <file>`), writes the bytes to
|
|
5
|
+
* `.ai.local/team/tasks/<slug>/outputs/<id>.txt` under a 2 097 152-byte cap,
|
|
6
|
+
* and prints a bounded head plus the path and one `grep -n` hint. The full
|
|
7
|
+
* output stays on disk, where the team-db projection indexes it, so an agent
|
|
8
|
+
* searches the stored file instead of reading it or re-running the command.
|
|
9
|
+
*
|
|
10
|
+
* The cap is applied while streaming: memory stays at one chunk plus the 8 KiB
|
|
11
|
+
* head, whatever the input size. The bytes are copied raw — no decode, no
|
|
12
|
+
* re-encode — so a binary dump is stored as-is (and skipped by the projection).
|
|
13
|
+
*
|
|
14
|
+
* Invocation: dump-output.mjs [--task <slug>] [--label <text>] [--input <file>]
|
|
15
|
+
* [--root <team-dir>]
|
|
16
|
+
*
|
|
17
|
+
* Exit codes: 0 ok (including empty or truncated input), 2 usage or containment
|
|
18
|
+
* refusal, 1 write failure. The task comes from `--task`, else TEAM_TASK_SLUG.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import fs from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
|
|
25
|
+
export const MAX_BYTES = 2 * 1024 * 1024;
|
|
26
|
+
|
|
27
|
+
const HEAD_LINES = 40;
|
|
28
|
+
const HEAD_BYTES = 8 * 1024;
|
|
29
|
+
const HEAD_LINE_BYTES = 400;
|
|
30
|
+
const LABEL_MAX = 32;
|
|
31
|
+
const SLUG_MAX = 48;
|
|
32
|
+
const CHUNK_BYTES = 64 * 1024;
|
|
33
|
+
const COLLISION_SCAN_LIMIT = 1000;
|
|
34
|
+
const CREATE_ATTEMPTS = COLLISION_SCAN_LIMIT + 1;
|
|
35
|
+
const TERM_MAX = 64;
|
|
36
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
37
|
+
/** A token a shell can carry inside single quotes: no `'`, `"`, `$`, or backtick. */
|
|
38
|
+
const GREP_TOKEN_RE = /^[\p{L}\p{N}][\p{L}\p{N}_-]*$/u;
|
|
39
|
+
|
|
40
|
+
const USAGE = `usage:
|
|
41
|
+
dump-output.mjs [--task <slug>] [--label <text>] [--input <file>] [--root <team-dir>]
|
|
42
|
+
|
|
43
|
+
Reads a command's stdout (or --input) and writes it to
|
|
44
|
+
.ai.local/team/tasks/<slug>/outputs/<id>.txt under a ${MAX_BYTES}-byte cap, then prints
|
|
45
|
+
at most ${HEAD_LINES} head lines, the byte count, the path, and one grep hint.
|
|
46
|
+
|
|
47
|
+
--task <slug> task slug; defaults to TEAM_TASK_SLUG
|
|
48
|
+
--label <text> suffix in the output name (lowercased, [^a-z0-9]+ -> -)
|
|
49
|
+
--input <file> read this file instead of stdin
|
|
50
|
+
--root <dir> team root; defaults to .ai.local/team under the current directory
|
|
51
|
+
|
|
52
|
+
Exit codes: 0 ok (including empty or truncated input), 2 usage or containment
|
|
53
|
+
refusal, 1 write failure.`;
|
|
54
|
+
|
|
55
|
+
const usageFail = (message) => {
|
|
56
|
+
const error = new Error(message);
|
|
57
|
+
error.exitCode = 2;
|
|
58
|
+
throw error;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Filename-safe label: lowercase, every non-alphanumeric run becomes `-`, no
|
|
63
|
+
* leading/trailing `-`, capped so the id stays a readable filename.
|
|
64
|
+
*/
|
|
65
|
+
export function sanitizeLabel(value) {
|
|
66
|
+
if (typeof value !== 'string') return '';
|
|
67
|
+
return value
|
|
68
|
+
.toLowerCase()
|
|
69
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
70
|
+
.replace(/^-+/, '')
|
|
71
|
+
.slice(0, LABEL_MAX)
|
|
72
|
+
.replace(/-+$/, '');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const sanitizeSlug = (value) => {
|
|
76
|
+
if (typeof value !== 'string') return '';
|
|
77
|
+
if (/[/\\]/.test(value) || value.includes('..') || value.startsWith('.')) return '';
|
|
78
|
+
const slug = value
|
|
79
|
+
.toLowerCase()
|
|
80
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
81
|
+
.replace(/^-+|-+$/g, '');
|
|
82
|
+
if (slug.length === 0 || slug.length > SLUG_MAX || !SLUG_RE.test(slug)) return '';
|
|
83
|
+
return slug;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** The first free `<id>.txt`, `<id>-2.txt`, `<id>-3.txt`, … — never an existing file. */
|
|
87
|
+
export function resolveOutputPath({ outputsDir, id }) {
|
|
88
|
+
const first = path.join(outputsDir, `${id}.txt`);
|
|
89
|
+
if (!fs.existsSync(first)) return first;
|
|
90
|
+
for (let suffix = 2; suffix <= COLLISION_SCAN_LIMIT; suffix += 1) {
|
|
91
|
+
const candidate = path.join(outputsDir, `${id}-${suffix}.txt`);
|
|
92
|
+
if (!fs.existsSync(candidate)) return candidate;
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`no free name for ${id}.txt in ${outputsDir}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const utcStamp = () =>
|
|
98
|
+
new Date()
|
|
99
|
+
.toISOString()
|
|
100
|
+
.replace(/[-:]/g, '')
|
|
101
|
+
.replace(/\.\d{3}Z$/, 'Z');
|
|
102
|
+
|
|
103
|
+
const parseArgs = (argv) => {
|
|
104
|
+
const flags = {};
|
|
105
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
106
|
+
const token = argv[index];
|
|
107
|
+
if (token === '--help' || token === '-h') return { help: true, flags };
|
|
108
|
+
if (!token.startsWith('--')) usageFail(`unexpected argument "${token}"`);
|
|
109
|
+
const [name, inline] = token.slice(2).split('=');
|
|
110
|
+
if (!['task', 'label', 'input', 'root'].includes(name)) usageFail(`unknown flag --${name}`);
|
|
111
|
+
if (inline !== undefined) {
|
|
112
|
+
flags[name] = inline;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const next = argv[index + 1];
|
|
116
|
+
if (next === undefined || next.startsWith('--')) usageFail(`flag --${name} needs a value`);
|
|
117
|
+
flags[name] = next;
|
|
118
|
+
index += 1;
|
|
119
|
+
}
|
|
120
|
+
return { help: false, flags };
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const assertNotSymlink = (target, label) => {
|
|
124
|
+
let stats;
|
|
125
|
+
try {
|
|
126
|
+
stats = fs.lstatSync(target);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (error.code === 'ENOENT') return;
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
// The projection walk skips symlinks, so anything written through one is
|
|
132
|
+
// invisible to `team-db search` — refuse instead of dumping into a dead end.
|
|
133
|
+
if (stats.isSymbolicLink()) usageFail(`refusing a symlinked ${label}: ${target}`);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const assertReadableFile = (file) => {
|
|
137
|
+
let stats;
|
|
138
|
+
try {
|
|
139
|
+
stats = fs.statSync(file);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
return usageFail(`--input ${file} is not readable (${error.code ?? error.message})`);
|
|
142
|
+
}
|
|
143
|
+
if (!stats.isFile()) return usageFail(`--input ${file} is not a regular file`);
|
|
144
|
+
try {
|
|
145
|
+
fs.accessSync(file, fs.constants.R_OK);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return usageFail(`--input ${file} is not readable (${error.code ?? error.message})`);
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const assertContained = (outputsDir, file) => {
|
|
153
|
+
const resolvedDir = path.resolve(outputsDir);
|
|
154
|
+
const resolvedFile = path.resolve(file);
|
|
155
|
+
const expected = path.join(resolvedDir, path.basename(file));
|
|
156
|
+
if (resolvedFile !== expected || !resolvedFile.startsWith(`${resolvedDir}${path.sep}`)) {
|
|
157
|
+
usageFail(`refusing to write outside ${resolvedDir}: ${file}`);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const createOutput = (outputsDir, baseId) => {
|
|
162
|
+
for (let attempt = 0; attempt < CREATE_ATTEMPTS; attempt += 1) {
|
|
163
|
+
const file = resolveOutputPath({ outputsDir, id: baseId });
|
|
164
|
+
assertContained(outputsDir, file);
|
|
165
|
+
try {
|
|
166
|
+
// `wx` closes the race between resolveOutputPath and the create: a file
|
|
167
|
+
// that appeared in between is a collision, never an overwrite.
|
|
168
|
+
return { file, fd: fs.openSync(file, 'wx') };
|
|
169
|
+
} catch (error) {
|
|
170
|
+
if (error.code !== 'EEXIST') throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
throw new Error(
|
|
174
|
+
`could not create a unique name for ${baseId}.txt in ${outputsDir} after ${CREATE_ATTEMPTS} attempts (every candidate was taken by a concurrent writer)`,
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const writeAll = (fd, buffer) => {
|
|
179
|
+
let offset = 0;
|
|
180
|
+
while (offset < buffer.length) {
|
|
181
|
+
offset += fs.writeSync(fd, buffer, offset, buffer.length - offset);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Stream the source into the file: the head is collected up to 8 KiB and 40
|
|
187
|
+
* lines, the body stops at the cap. Reading stops at the first chunk past the
|
|
188
|
+
* cap, so a 1 GB dump costs one chunk of extra work, not 1 GB of I/O.
|
|
189
|
+
*/
|
|
190
|
+
async function copyInto(source, fd) {
|
|
191
|
+
let written = 0;
|
|
192
|
+
let truncated = false;
|
|
193
|
+
let headBytes = 0;
|
|
194
|
+
let headNewlines = 0;
|
|
195
|
+
let headCut = false;
|
|
196
|
+
const headChunks = [];
|
|
197
|
+
for await (const chunk of source) {
|
|
198
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), 'utf8');
|
|
199
|
+
if (buffer.length === 0) continue;
|
|
200
|
+
if (headNewlines < HEAD_LINES) {
|
|
201
|
+
const room = HEAD_BYTES - headBytes;
|
|
202
|
+
if (room > 0) {
|
|
203
|
+
const slice = buffer.subarray(0, room);
|
|
204
|
+
headChunks.push(slice);
|
|
205
|
+
headBytes += slice.length;
|
|
206
|
+
for (let index = 0; index < slice.length; index += 1) {
|
|
207
|
+
if (slice[index] === 0x0a) headNewlines += 1;
|
|
208
|
+
}
|
|
209
|
+
if (slice.length < buffer.length && headNewlines < HEAD_LINES) headCut = true;
|
|
210
|
+
} else {
|
|
211
|
+
headCut = true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (written >= MAX_BYTES) {
|
|
215
|
+
truncated = true;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
const slice = buffer.subarray(0, MAX_BYTES - written);
|
|
219
|
+
writeAll(fd, slice);
|
|
220
|
+
written += slice.length;
|
|
221
|
+
if (slice.length < buffer.length) {
|
|
222
|
+
truncated = true;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { written, truncated, head: Buffer.concat(headChunks), headCut };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Drop a code point the cap split, so the head never shows a replacement char. */
|
|
230
|
+
const trimPartialUtf8 = (buffer) => {
|
|
231
|
+
let index = buffer.length;
|
|
232
|
+
let trailing = 0;
|
|
233
|
+
while (index > 0 && trailing < 3 && (buffer[index - 1] & 0xc0) === 0x80) {
|
|
234
|
+
index -= 1;
|
|
235
|
+
trailing += 1;
|
|
236
|
+
}
|
|
237
|
+
if (index === 0) return buffer;
|
|
238
|
+
const lead = buffer[index - 1];
|
|
239
|
+
const expected = lead >= 0xf0 ? 4 : lead >= 0xe0 ? 3 : lead >= 0xc0 ? 2 : 1;
|
|
240
|
+
return buffer.length - (index - 1) < expected ? buffer.subarray(0, index - 1) : buffer;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const cutLine = (text, partial) => {
|
|
244
|
+
const buffer = Buffer.from(text, 'utf8');
|
|
245
|
+
if (!partial && buffer.length <= HEAD_LINE_BYTES) return { text, bytes: buffer.length };
|
|
246
|
+
let end = Math.min(buffer.length, HEAD_LINE_BYTES - 3);
|
|
247
|
+
while (end > 0 && (buffer[end] & 0xc0) === 0x80) end -= 1;
|
|
248
|
+
return { text: `${buffer.subarray(0, end).toString('utf8')}…`, bytes: end + 3 };
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const formatHead = ({ head, headCut }) => {
|
|
252
|
+
const text = (headCut ? trimPartialUtf8(head) : head).toString('utf8');
|
|
253
|
+
const partialTail = headCut && !text.endsWith('\n');
|
|
254
|
+
const lines = text.split('\n');
|
|
255
|
+
if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop();
|
|
256
|
+
const printed = [];
|
|
257
|
+
let total = 0;
|
|
258
|
+
for (let index = 0; index < lines.length && printed.length < HEAD_LINES; index += 1) {
|
|
259
|
+
const line = cutLine(lines[index].replace(/\r$/, ''), partialTail && index === lines.length - 1);
|
|
260
|
+
if (total + line.bytes + 1 > HEAD_BYTES) break;
|
|
261
|
+
printed.push(line.text);
|
|
262
|
+
total += line.bytes + 1;
|
|
263
|
+
}
|
|
264
|
+
return printed;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/** A usable first search term: the first head token a shell cannot break on. */
|
|
268
|
+
const grepTerm = (lines, fallback) => {
|
|
269
|
+
for (const line of lines) {
|
|
270
|
+
for (const token of line.split(/\s+/)) {
|
|
271
|
+
if (token.length >= 2 && GREP_TOKEN_RE.test(token)) return token.slice(0, TERM_MAX);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return fallback;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const realpathOr = (value) => {
|
|
278
|
+
try {
|
|
279
|
+
return fs.realpathSync(value);
|
|
280
|
+
} catch {
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const displayPath = (file) => {
|
|
286
|
+
// Both sides go through realpath: a `--root` under a symlinked prefix (`/var`
|
|
287
|
+
// on macOS) is the same directory as the physical cwd, not "outside" it.
|
|
288
|
+
const target = path.resolve(file);
|
|
289
|
+
const relative = path.relative(realpathOr(path.resolve(process.cwd())), realpathOr(target));
|
|
290
|
+
const inside = relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
291
|
+
return (inside ? relative : target).split(path.sep).join('/');
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
async function main(argv) {
|
|
295
|
+
const { help, flags } = parseArgs(argv);
|
|
296
|
+
if (help) {
|
|
297
|
+
process.stdout.write(`${USAGE}\n`);
|
|
298
|
+
return 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const slug = sanitizeSlug(flags.task ?? process.env.TEAM_TASK_SLUG ?? '');
|
|
302
|
+
if (slug === '') {
|
|
303
|
+
usageFail('a task slug is required: --task <slug> or TEAM_TASK_SLUG (letters, digits, "-", max 48 chars)');
|
|
304
|
+
}
|
|
305
|
+
const root = flags.root ? path.resolve(flags.root) : path.join(process.cwd(), '.ai.local', 'team');
|
|
306
|
+
const inputPath = typeof flags.input === 'string' && flags.input !== '' ? path.resolve(flags.input) : null;
|
|
307
|
+
// Validate before touching the tree, so a usage refusal writes nothing.
|
|
308
|
+
if (inputPath) assertReadableFile(inputPath);
|
|
309
|
+
|
|
310
|
+
const taskDir = path.join(root, 'tasks', slug);
|
|
311
|
+
const outputsDir = path.join(taskDir, 'outputs');
|
|
312
|
+
assertNotSymlink(taskDir, 'task directory');
|
|
313
|
+
assertNotSymlink(outputsDir, 'outputs directory');
|
|
314
|
+
fs.mkdirSync(outputsDir, { recursive: true });
|
|
315
|
+
|
|
316
|
+
const baseId = [utcStamp(), sanitizeLabel(flags.label)].filter(Boolean).join('-');
|
|
317
|
+
const { file, fd } = createOutput(outputsDir, baseId);
|
|
318
|
+
let result;
|
|
319
|
+
try {
|
|
320
|
+
result = await copyInto(
|
|
321
|
+
inputPath ? fs.createReadStream(inputPath, { highWaterMark: CHUNK_BYTES }) : process.stdin,
|
|
322
|
+
fd,
|
|
323
|
+
);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
try {
|
|
326
|
+
fs.closeSync(fd);
|
|
327
|
+
} catch {
|
|
328
|
+
/* the write failure is the finding */
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
fs.unlinkSync(file);
|
|
332
|
+
} catch {
|
|
333
|
+
/* a partial file is already the failure being reported */
|
|
334
|
+
}
|
|
335
|
+
throw error;
|
|
336
|
+
}
|
|
337
|
+
fs.closeSync(fd);
|
|
338
|
+
|
|
339
|
+
const printed = displayPath(file);
|
|
340
|
+
if (result.written === 0) {
|
|
341
|
+
process.stdout.write('empty input; nothing to externalize\n');
|
|
342
|
+
process.stdout.write(`path: ${printed}\n`);
|
|
343
|
+
return 0;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const head = formatHead(result);
|
|
347
|
+
process.stdout.write('head:\n');
|
|
348
|
+
for (const line of head) process.stdout.write(`${line}\n`);
|
|
349
|
+
process.stdout.write(`bytes: ${result.written} (cap ${MAX_BYTES}, truncated: ${result.truncated ? 'yes' : 'no'})\n`);
|
|
350
|
+
process.stdout.write(`path: ${printed}\n`);
|
|
351
|
+
process.stdout.write(`grep -n '${grepTerm(head, baseId)}' ${printed}\n`);
|
|
352
|
+
return 0;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const invokedDirectly = (() => {
|
|
356
|
+
if (!process.argv[1]) return false;
|
|
357
|
+
try {
|
|
358
|
+
return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
359
|
+
} catch {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
})();
|
|
363
|
+
|
|
364
|
+
if (invokedDirectly) {
|
|
365
|
+
try {
|
|
366
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
367
|
+
} catch (error) {
|
|
368
|
+
process.stderr.write(`dump-output: ${error.message}\n`);
|
|
369
|
+
process.exitCode = typeof error.exitCode === 'number' ? error.exitCode : 1;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Commands:
|
|
5
5
|
* init [--root <team-dir>] [--rebuild] create or migrate the database
|
|
6
6
|
* check [--root <team-dir>] report schema, fingerprint, integrity
|
|
7
|
+
* search <query> [--limit <n>] [--json] [--root <team-dir>]
|
|
8
|
+
* query the projection, read-only
|
|
7
9
|
* sync [--root <team-dir>] [--slug <slug>] [--quiet] [--json]
|
|
8
10
|
* [--maintain] [--prune] [--vacuum] [--rebuild | --no-rebuild]
|
|
9
11
|
* [--deadline-ms <n>] project files into the database
|
|
@@ -66,7 +68,7 @@ import {
|
|
|
66
68
|
openTeamDb,
|
|
67
69
|
teamDbFail,
|
|
68
70
|
} from './team-db-schema.mjs';
|
|
69
|
-
import { deleteTaskProjection, describeSyncResult, syncProjection, syncTrackerProjection } from './team-db-project.mjs';
|
|
71
|
+
import { deleteTaskProjection, describeSyncResult, searchProjection, syncProjection, syncTrackerProjection } from './team-db-project.mjs';
|
|
70
72
|
import {
|
|
71
73
|
isLeaseFresh,
|
|
72
74
|
runJobsCommand,
|
|
@@ -78,6 +80,7 @@ import { runTrackerCommand } from './team-db-tracker.mjs';
|
|
|
78
80
|
const USAGE = `usage:
|
|
79
81
|
team-db.mjs init [--root <team-dir>] [--rebuild]
|
|
80
82
|
team-db.mjs check [--root <team-dir>]
|
|
83
|
+
team-db.mjs search <query> [--limit <n>] [--json] [--root <team-dir>]
|
|
81
84
|
team-db.mjs sync [--root <team-dir>] [--slug <slug>] [--quiet] [--json]
|
|
82
85
|
[--maintain] [--prune] [--vacuum] [--rebuild | --no-rebuild]
|
|
83
86
|
[--deadline-ms <n>]
|
|
@@ -129,6 +132,7 @@ const VALUE_FLAGS = new Set([
|
|
|
129
132
|
'item',
|
|
130
133
|
'link',
|
|
131
134
|
'run',
|
|
135
|
+
'limit',
|
|
132
136
|
]);
|
|
133
137
|
const BOOLEAN_FLAGS = new Set([
|
|
134
138
|
'quiet',
|
|
@@ -147,10 +151,11 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
147
151
|
'ready',
|
|
148
152
|
'claim',
|
|
149
153
|
]);
|
|
150
|
-
const COMMANDS = new Set(['init', 'check', 'sync', 'delete', 'migrate-tasks', 'serve', 'jobs', 'schedule', 'tracker', 'task-run', 'ui']);
|
|
154
|
+
const COMMANDS = new Set(['init', 'check', 'search', 'sync', 'delete', 'migrate-tasks', 'serve', 'jobs', 'schedule', 'tracker', 'task-run', 'ui']);
|
|
151
155
|
const ALLOWED_FLAGS = {
|
|
152
156
|
init: new Set(['root', 'rebuild']),
|
|
153
157
|
check: new Set(['root']),
|
|
158
|
+
search: new Set(['root', 'limit', 'json']),
|
|
154
159
|
sync: new Set(['root', 'slug', 'quiet', 'json', 'maintain', 'prune', 'vacuum', 'rebuild', 'no-rebuild', 'deadline-ms']),
|
|
155
160
|
delete: new Set(['root', 'slug', 'json']),
|
|
156
161
|
'migrate-tasks': new Set(['root', 'quiet', 'json', 'rebuild', 'no-rebuild']),
|
|
@@ -216,6 +221,13 @@ const parseArgs = (argv) => {
|
|
|
216
221
|
for (let index = 0; index < rest.length; index += 1) {
|
|
217
222
|
const token = rest[index];
|
|
218
223
|
if (!token.startsWith('--')) {
|
|
224
|
+
// `search <query>` is the only command with a free-text positional; a
|
|
225
|
+
// second one falls through to the unexpected-argument refusal below, and a
|
|
226
|
+
// query that starts with `--` is refused as an unknown flag.
|
|
227
|
+
if (command === 'search' && positionals.length === 0) {
|
|
228
|
+
positionals.push(token);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
219
231
|
// `jobs <verb> [id]`, `tracker <verb> [id|entryId]` and `ui <verb>` are the
|
|
220
232
|
// only commands with positional arguments.
|
|
221
233
|
const verbs = POSITIONAL_VERBS[command];
|
|
@@ -302,6 +314,73 @@ const runCheck = (flags) => {
|
|
|
302
314
|
return 0;
|
|
303
315
|
};
|
|
304
316
|
|
|
317
|
+
const SEARCH_DEFAULT_LIMIT = 5;
|
|
318
|
+
const SEARCH_MAX_LIMIT = 20;
|
|
319
|
+
const SNIPPET_MAX_BYTES = 800;
|
|
320
|
+
|
|
321
|
+
const collapseSpace = (value) => String(value ?? '').replace(/\s+/g, ' ').trim();
|
|
322
|
+
|
|
323
|
+
/** One hit's snippet: single-spaced, cut at 800 bytes on a UTF-8 boundary including the `…`. */
|
|
324
|
+
const snippetOf = (value) => {
|
|
325
|
+
const collapsed = collapseSpace(value);
|
|
326
|
+
const buffer = Buffer.from(collapsed, 'utf8');
|
|
327
|
+
if (buffer.length <= SNIPPET_MAX_BYTES) {
|
|
328
|
+
return { snippet: collapsed, snippetBytes: buffer.length, snippetTruncated: false };
|
|
329
|
+
}
|
|
330
|
+
let end = SNIPPET_MAX_BYTES - 3;
|
|
331
|
+
while (end > 0 && (buffer[end] & 0xc0) === 0x80) end -= 1;
|
|
332
|
+
const snippet = `${buffer.subarray(0, end).toString('utf8')}…`;
|
|
333
|
+
return { snippet, snippetBytes: Buffer.byteLength(snippet, 'utf8'), snippetTruncated: true };
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Read-only answer from the existing FTS5 projection: `searchProjection` owns
|
|
338
|
+
* the query (FTS5 `MATCH`, escaped `LIKE` fallback) and never builds SQL from
|
|
339
|
+
* the input, so this verb adds a CLI shape and a byte cap, nothing else.
|
|
340
|
+
*/
|
|
341
|
+
const runSearch = (flags, positionals) => {
|
|
342
|
+
const query = (positionals[0] ?? '').trim();
|
|
343
|
+
if (query === '') teamDbFail('E_USAGE', `search needs a query\n${USAGE}`, 3);
|
|
344
|
+
let limit = SEARCH_DEFAULT_LIMIT;
|
|
345
|
+
if (flags.limit !== undefined) {
|
|
346
|
+
limit = Number(flags.limit);
|
|
347
|
+
if (!Number.isInteger(limit)) teamDbFail('E_USAGE', '--limit must be an integer', 3);
|
|
348
|
+
limit = Math.max(1, Math.min(SEARCH_MAX_LIMIT, limit));
|
|
349
|
+
}
|
|
350
|
+
if (isKillSwitchSet(process.env)) {
|
|
351
|
+
disabledLine();
|
|
352
|
+
return 1;
|
|
353
|
+
}
|
|
354
|
+
if (!isSqliteAvailable(process.env)) {
|
|
355
|
+
unavailableLine();
|
|
356
|
+
return 1;
|
|
357
|
+
}
|
|
358
|
+
const handle = openTeamDb({ teamRoot: teamRootFrom(flags), readOnly: true });
|
|
359
|
+
let hits;
|
|
360
|
+
try {
|
|
361
|
+
hits = searchProjection(handle.db, query, { limit }).map((row) => ({
|
|
362
|
+
taskSlug: row.taskSlug,
|
|
363
|
+
doc_path: row.doc_path,
|
|
364
|
+
kind: row.kind,
|
|
365
|
+
...snippetOf(row.snippet),
|
|
366
|
+
}));
|
|
367
|
+
} finally {
|
|
368
|
+
handle.db.close();
|
|
369
|
+
}
|
|
370
|
+
if (flags.json) {
|
|
371
|
+
process.stdout.write(`${JSON.stringify(hits)}\n`);
|
|
372
|
+
return 0;
|
|
373
|
+
}
|
|
374
|
+
if (hits.length === 0) {
|
|
375
|
+
process.stdout.write(`team-db: no matches for "${query}"\n`);
|
|
376
|
+
return 0;
|
|
377
|
+
}
|
|
378
|
+
for (const hit of hits) {
|
|
379
|
+
process.stdout.write(`${hit.taskSlug} ${hit.doc_path} ${hit.kind} ${hit.snippet}\n`);
|
|
380
|
+
}
|
|
381
|
+
return 0;
|
|
382
|
+
};
|
|
383
|
+
|
|
305
384
|
const runSync = (flags) => {
|
|
306
385
|
if (cannotProject(process.env)) return 0;
|
|
307
386
|
if (flags.rebuild && flags['no-rebuild']) teamDbFail('E_USAGE', '--rebuild and --no-rebuild are exclusive', 3);
|
|
@@ -592,6 +671,7 @@ export async function runCli(argv) {
|
|
|
592
671
|
}
|
|
593
672
|
if (command === 'init') return runInit(flags);
|
|
594
673
|
if (command === 'check') return runCheck(flags);
|
|
674
|
+
if (command === 'search') return runSearch(flags, positionals);
|
|
595
675
|
if (command === 'delete') return runDelete(flags);
|
|
596
676
|
if (command === 'migrate-tasks') return runMigrateTasks(flags);
|
|
597
677
|
if (command === 'serve') return runServe(flags);
|
|
@@ -145,7 +145,7 @@ Replanning is a **named, auditable operation** — never a silent reorder. Trigg
|
|
|
145
145
|
|
|
146
146
|
## Context budget & checkpoint/resume
|
|
147
147
|
|
|
148
|
-
Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
|
|
148
|
+
Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
|
|
149
149
|
|
|
150
150
|
## Self-review & context hygiene
|
|
151
151
|
|
|
@@ -212,6 +212,8 @@ Additional states: `blocked` — a step (or a parallel producer) cannot proceed;
|
|
|
212
212
|
|
|
213
213
|
On each `subagentStop`, the hook reconciles `status.state` from the completing producer's terminal `artifact-manifest.json` receipt (`completed` \| `changes_requested` \| `validation_failed`) when agents left lifecycle fields untouched. Parent orchestrators must wait for that handoff before invoking the next step.
|
|
214
214
|
|
|
215
|
+
**A dispatch is not a completion.** When the host hands back a session handle, a job id, or control before the specialist's turn ends, the step is still open: do not dispatch the next step, do not report the step done, and do not run the chain hook until the specialist reports back and the hook records the receipt. A background handle is a start signal only.
|
|
216
|
+
|
|
215
217
|
## Pipeline step options
|
|
216
218
|
|
|
217
219
|
| Field | Use |
|
|
@@ -12,6 +12,10 @@ Typical feature with data and UI. Concrete directories and rule stems — in the
|
|
|
12
12
|
6. **Tests** — unit for mappers / non-trivial logic; e2e/UI per stack convention.
|
|
13
13
|
7. **Completion** — stack post-change gate (lint/build) + package/toolchain rules. When the current WP spans **more than one** layer or module, `implementation.md` includes a **Code Map** (3–8 annotated repo-relative paths) and **Suggested Review Order** (`concern | path:line | ≤15 word note`). Omit both for a single-file or single-layer WP.
|
|
14
14
|
|
|
15
|
+
## Context hygiene
|
|
16
|
+
|
|
17
|
+
A command whose output can exceed ~4 KB — a test run, a build/lint log, `git log`, a diff — is piped through `.ai.local/scripts/dump-output.mjs --task <slug>` instead of being read whole. Work from its ≤40-line head and the stored file (grep it or use `team-db.mjs search`), and when that output informed a decision, record the repo-relative `outputs/…` path in `implementation.md` or `validation-report.md`; a `code-reviewer` may ask for that path. Do not read the whole output into context.
|
|
18
|
+
|
|
15
19
|
## Iterative refinement loop
|
|
16
20
|
|
|
17
21
|
Every stage runs the named loop **draft → evaluate against named criteria → refine**:
|
|
@@ -6,6 +6,7 @@ Stack-agnostic. Keep each run inside a bounded context, checkpoint progress to d
|
|
|
6
6
|
|
|
7
7
|
- Work in **bounded waves** (one artifact class across the target surface) rather than one target across all classes; a wave must fit comfortably in context.
|
|
8
8
|
- **Mechanical waves** (generation, embed sync, drift re-checks) are delegated to **repo scripts** — spend tokens reading the gate output, not re-deriving the transformation.
|
|
9
|
+
- A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`.
|
|
9
10
|
- Split work before the context overflows; do not carry state in the chat that belongs on disk.
|
|
10
11
|
|
|
11
12
|
## Checkpoint & resume
|
|
@@ -49,7 +49,7 @@ Decompose as a **dependency graph**: each task carries `dependsOn[]`, the edges
|
|
|
49
49
|
|
|
50
50
|
<!-- shared-core: quality/context-and-iteration.md -->
|
|
51
51
|
|
|
52
|
-
Work in bounded waves; delegate mechanical waves to repo scripts. **Checkpoint** progress to `.memlog.md` and record produced paths on the `implementation` manifest entry `authoritativePaths`, so a run can resume from `artifact-manifest.json` + `.memlog.md` without re-deriving state. Refine with the named loop **draft → evaluate against named criteria → refine**.
|
|
52
|
+
Work in bounded waves; delegate mechanical waves to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. **Checkpoint** progress to `.memlog.md` and record produced paths on the `implementation` manifest entry `authoritativePaths`, so a run can resume from `artifact-manifest.json` + `.memlog.md` without re-deriving state. Refine with the named loop **draft → evaluate against named criteria → refine**.
|
|
53
53
|
|
|
54
54
|
## Self-review & context hygiene
|
|
55
55
|
|
|
@@ -156,7 +156,7 @@ Replanning is a **named, auditable operation** — never a silent reorder. Trigg
|
|
|
156
156
|
|
|
157
157
|
## Context budget & checkpoint/resume
|
|
158
158
|
|
|
159
|
-
Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
|
|
159
|
+
Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
|
|
160
160
|
|
|
161
161
|
## Self-review & context hygiene
|
|
162
162
|
|
|
@@ -223,6 +223,8 @@ Additional states: `blocked` — a step (or a parallel producer) cannot proceed;
|
|
|
223
223
|
|
|
224
224
|
On each `subagentStop`, the hook reconciles `status.state` from the completing producer's terminal `artifact-manifest.json` receipt (`completed` \| `changes_requested` \| `validation_failed`) when agents left lifecycle fields untouched. Parent orchestrators must wait for that handoff before invoking the next step.
|
|
225
225
|
|
|
226
|
+
**A dispatch is not a completion.** When the host hands back a session handle, a job id, or control before the specialist's turn ends, the step is still open: do not dispatch the next step, do not report the step done, and do not run the chain hook until the specialist reports back and the hook records the receipt. A background handle is a start signal only.
|
|
227
|
+
|
|
226
228
|
## Pipeline step options
|
|
227
229
|
|
|
228
230
|
| Field | Use |
|
|
@@ -49,7 +49,7 @@ Decompose as a **dependency graph**: each task carries `dependsOn[]`, the edges
|
|
|
49
49
|
|
|
50
50
|
<!-- shared-core: quality/context-and-iteration.md -->
|
|
51
51
|
|
|
52
|
-
Work in bounded waves; delegate mechanical waves to repo scripts. **Checkpoint** progress to `.memlog.md` and record produced paths on the `implementation` manifest entry `authoritativePaths`, so a run can resume from `artifact-manifest.json` + `.memlog.md` without re-deriving state. Refine with the named loop **draft → evaluate against named criteria → refine**.
|
|
52
|
+
Work in bounded waves; delegate mechanical waves to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. **Checkpoint** progress to `.memlog.md` and record produced paths on the `implementation` manifest entry `authoritativePaths`, so a run can resume from `artifact-manifest.json` + `.memlog.md` without re-deriving state. Refine with the named loop **draft → evaluate against named criteria → refine**.
|
|
53
53
|
|
|
54
54
|
## Self-review & context hygiene
|
|
55
55
|
|
|
@@ -19,6 +19,10 @@ Typical feature with data and UI. Concrete directories and rule stems — in the
|
|
|
19
19
|
6. **Tests** — unit for mappers / non-trivial logic; e2e/UI per stack convention.
|
|
20
20
|
7. **Completion** — stack post-change gate (lint/build) + package/toolchain rules. When the current WP spans **more than one** layer or module, `implementation.md` includes a **Code Map** (3–8 annotated repo-relative paths) and **Suggested Review Order** (`concern | path:line | ≤15 word note`). Omit both for a single-file or single-layer WP.
|
|
21
21
|
|
|
22
|
+
## Context hygiene
|
|
23
|
+
|
|
24
|
+
A command whose output can exceed ~4 KB — a test run, a build/lint log, `git log`, a diff — is piped through `.ai.local/scripts/dump-output.mjs --task <slug>` instead of being read whole. Work from its ≤40-line head and the stored file (grep it or use `team-db.mjs search`), and when that output informed a decision, record the repo-relative `outputs/…` path in `implementation.md` or `validation-report.md`; a `code-reviewer` may ask for that path. Do not read the whole output into context.
|
|
25
|
+
|
|
22
26
|
## Iterative refinement loop
|
|
23
27
|
|
|
24
28
|
Every stage runs the named loop **draft → evaluate against named criteria → refine**:
|
|
@@ -156,7 +156,7 @@ Replanning is a **named, auditable operation** — never a silent reorder. Trigg
|
|
|
156
156
|
|
|
157
157
|
## Context budget & checkpoint/resume
|
|
158
158
|
|
|
159
|
-
Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
|
|
159
|
+
Work in bounded waves (one artifact class across the target surface). **Checkpoint** each completed wave to `.memlog.md` (`## <date>` + an `event:` line) and record the produced paths on the `implementation` manifest entry (`authoritativePaths`). That checkpoint is the hook `writeStatus` path: it rewrites `.ai.local/team/tasks/<slug>/focus.md`. `focus.md` is a view, not the system of record. It lists slug, pipeline step index, authoritative paths for incomplete manifest ids, the last `.memlog.md` `event:` line, the next gate, one decomposition ready-set line, and one archive index line, and it stays under 100 lines. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record. A resumed run (`/task-continue`) reads `focus.md` first, then `artifact-manifest.json` and `.memlog.md`, and continues at the first stage whose exit criteria are unmet — never re-derive state from the chat. A completed manifest entry keeps id, status, and `authoritativePaths`, and the default resume read omits that entry's markdown body; closing it appends one new `.memlog.md` event: line, moves the bulky body to `.ai.local/team/tasks/<slug>/archive/YYYY-MM-DD/`, and leaves earlier memlog lines, the human-readable slug and artifact ids, and the manifest entry in place, with no Beads hash ids and no Taskmaster tags. Mechanical waves (generation, embed sync) are delegated to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. An **interrupted producer** (tool abort, killed session) is resumed, not restarted: run the stack's compile gate on the working tree first, and when it is red hand the failing output to the same producer with a `fix and finish` brief instead of starting a second parallel attempt. When the host runtime writes no `status.json` (manual-hook hosts such as OpenCode), the resume checkpoint is `artifact-manifest.json` + `.memlog.md`; never gate a resume on a file the runtime does not produce. See **context-and-iteration** for the budget, checkpoint, resume, and refinement loop.
|
|
160
160
|
|
|
161
161
|
## Self-review & context hygiene
|
|
162
162
|
|
|
@@ -223,6 +223,8 @@ Additional states: `blocked` — a step (or a parallel producer) cannot proceed;
|
|
|
223
223
|
|
|
224
224
|
On each `subagentStop`, the hook reconciles `status.state` from the completing producer's terminal `artifact-manifest.json` receipt (`completed` \| `changes_requested` \| `validation_failed`) when agents left lifecycle fields untouched. Parent orchestrators must wait for that handoff before invoking the next step.
|
|
225
225
|
|
|
226
|
+
**A dispatch is not a completion.** When the host hands back a session handle, a job id, or control before the specialist's turn ends, the step is still open: do not dispatch the next step, do not report the step done, and do not run the chain hook until the specialist reports back and the hook records the receipt. A background handle is a start signal only.
|
|
227
|
+
|
|
226
228
|
## Pipeline step options
|
|
227
229
|
|
|
228
230
|
| Field | Use |
|
|
@@ -49,7 +49,7 @@ Decompose as a **dependency graph**: each task carries `dependsOn[]`, the edges
|
|
|
49
49
|
|
|
50
50
|
<!-- shared-core: quality/context-and-iteration.md -->
|
|
51
51
|
|
|
52
|
-
Work in bounded waves; delegate mechanical waves to repo scripts. **Checkpoint** progress to `.memlog.md` and record produced paths on the `implementation` manifest entry `authoritativePaths`, so a run can resume from `artifact-manifest.json` + `.memlog.md` without re-deriving state. Refine with the named loop **draft → evaluate against named criteria → refine**.
|
|
52
|
+
Work in bounded waves; delegate mechanical waves to repo scripts. A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. **Checkpoint** progress to `.memlog.md` and record produced paths on the `implementation` manifest entry `authoritativePaths`, so a run can resume from `artifact-manifest.json` + `.memlog.md` without re-deriving state. Refine with the named loop **draft → evaluate against named criteria → refine**.
|
|
53
53
|
|
|
54
54
|
## Self-review & context hygiene
|
|
55
55
|
|