thumbgate 1.39.1 → 1.40.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/.claude-plugin/plugin.json +1 -1
- package/.well-known/llms.txt +2 -2
- package/.well-known/mcp/server-card.json +1 -1
- package/README.md +5 -4
- package/adapters/claude/.mcp.json +6 -2
- package/adapters/codex/config.toml +5 -0
- package/adapters/forge/forge.yaml +4 -4
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/mcp/server-stdio.js +82 -7
- package/adapters/opencode/opencode.json +1 -1
- package/bin/cli.js +128 -15
- package/config/brand-standards.json +131 -0
- package/config/gates/default.json +18 -1
- package/config/github-about.json +1 -1
- package/config/mcp-allowlists.json +16 -3
- package/config/merge-quality-checks.json +1 -0
- package/config/post-deploy-marketing-pages.json +3 -3
- package/config/schemas/task-outcome-receipt.schema.json +9 -0
- package/openapi/openapi.yaml +7 -3
- package/package.json +98 -31
- package/public/about.html +2 -2
- package/public/admin.html +771 -0
- package/public/agent-manager.html +3 -3
- package/public/agents-cost-savings.html +1 -1
- package/public/ai-malpractice-prevention.html +12 -12
- package/public/architecture.html +0 -1
- package/public/assets/diagrams/decision.svg +3 -3
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
- package/public/blog/git-at-agent-scale.html +2 -2
- package/public/blog/inside-your-boundary.html +1 -1
- package/public/blog/process-over-outcome-gates.html +1 -1
- package/public/case-studies.html +1 -2
- package/public/codex-enterprise.html +1 -1
- package/public/codex-plugin.html +1 -1
- package/public/dashboard.html +773 -481
- package/public/diagnostic.html +8 -3
- package/public/enterprise-governance.html +26 -174
- package/public/eval-scorecard.html +3 -4
- package/public/eval-scorecard.json +2 -2
- package/public/evaluations.html +0 -1
- package/public/founders.html +3 -3
- package/public/gaming-playbook.html +4 -4
- package/public/guide.html +3 -5
- package/public/index.html +181 -205
- package/public/install.html +12 -11
- package/public/js/buyer-intent.js +49 -8
- package/public/lessons.html +103 -46
- package/public/numbers.html +32 -33
- package/public/operator-framework.html +44 -72
- package/public/peter.html +3 -3
- package/public/platform-partners.html +1 -1
- package/public/pricing.html +61 -327
- package/public/pro.html +3 -1
- package/public/project-switcher.js +76 -0
- package/public/whitepaper.html +1 -2
- package/scripts/activation-quickstart.js +15 -3
- package/scripts/activation-tracker.js +280 -3
- package/scripts/agent-action-inventory.js +235 -143
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-readiness.js +36 -6
- package/scripts/agentic-prompt-pipelines.js +901 -0
- package/scripts/analytics-report.js +363 -0
- package/scripts/analytics-window.js +7 -1
- package/scripts/async-job-runner.js +66 -11
- package/scripts/audit-trail.js +37 -24
- package/scripts/auto-context-packs.js +249 -0
- package/scripts/auto-promote-gates.js +37 -27
- package/scripts/backfill-lesson-scopes.js +122 -0
- package/scripts/billing-setup.js +137 -0
- package/scripts/billing.js +889 -132
- package/scripts/bot-detection.js +112 -0
- package/scripts/brand-standards-gate.js +571 -0
- package/scripts/chatgpt-ads-readiness-pack.js +1 -1
- package/scripts/check-update.js +236 -0
- package/scripts/cli-schema.js +1 -1
- package/scripts/commercial-offer.js +2 -2
- package/scripts/contextfs.js +9 -3
- package/scripts/conversion-rate-stats.js +442 -0
- package/scripts/cost-cli.js +147 -0
- package/scripts/creator-campaigns.js +239 -0
- package/scripts/cross-encoder-reranker.js +4 -0
- package/scripts/cuda-gate-batch.js +560 -0
- package/scripts/daemon-manager.js +108 -0
- package/scripts/dashboard-chat.js +11 -0
- package/scripts/dashboard.js +576 -169
- package/scripts/decision-journal.js +7 -4
- package/scripts/delegation-runtime.js +1036 -0
- package/scripts/dispatch-brief.js +159 -0
- package/scripts/distribution-surfaces.js +110 -0
- package/scripts/docker-sandbox-planner.js +3 -3
- package/scripts/egm-goldfish-packet.js +95 -0
- package/scripts/embeddinggemma-adapter.js +407 -0
- package/scripts/export-dpo-pairs.js +12 -7
- package/scripts/feedback-aggregate.js +4 -0
- package/scripts/feedback-attribution.js +6 -4
- package/scripts/feedback-history-distiller.js +18 -6
- package/scripts/feedback-loop.js +255 -89
- package/scripts/feedback-paths.js +8 -1
- package/scripts/feedback-sanitizer.js +5 -0
- package/scripts/feedback-scope.js +106 -0
- package/scripts/feedback-session.js +8 -2
- package/scripts/filesystem-search.js +13 -8
- package/scripts/financial-control-plane.js +707 -45
- package/scripts/funnel-analytics.js +35 -0
- package/scripts/gate-semantic-layer.js +292 -0
- package/scripts/gate-stats.js +8 -2
- package/scripts/gates-engine.js +694 -230
- package/scripts/generate-eval-scorecard.js +0 -1
- package/scripts/harness-tool-names.js +31 -5
- package/scripts/hybrid-feedback-context.js +5 -2
- package/scripts/implementation-notes.js +241 -0
- package/scripts/intent-router.js +518 -0
- package/scripts/intervention-policy.js +2 -1
- package/scripts/latency-budget.js +164 -0
- package/scripts/lesson-canonical.js +2 -2
- package/scripts/lesson-db.js +55 -14
- package/scripts/lesson-graph.js +2 -1
- package/scripts/lesson-retrieval.js +95 -9
- package/scripts/lesson-search.js +86 -22
- package/scripts/lesson-synthesis.js +21 -5
- package/scripts/mailer/index.js +17 -1
- package/scripts/mailer/resend-mailer.js +213 -179
- package/scripts/mcp-writeguard.js +158 -0
- package/scripts/migrate-project-scope.js +209 -0
- package/scripts/model-candidates.js +414 -0
- package/scripts/openrouter-armor-partnership-diode.js +2419 -0
- package/scripts/operational-dashboard.js +172 -0
- package/scripts/operational-integrity.js +436 -3
- package/scripts/operational-summary.js +190 -0
- package/scripts/operator-artifacts.js +622 -0
- package/scripts/optimize-context.js +17 -0
- package/scripts/override-audit.js +2 -0
- package/scripts/owner-admin.js +338 -0
- package/scripts/pr-manager.js +194 -1
- package/scripts/predictive-insights.js +449 -0
- package/scripts/profound-aeo-citation-engine.js +583 -0
- package/scripts/progressive-signoff.js +260 -0
- package/scripts/project-catalog.js +243 -0
- package/scripts/project-dashboard.js +61 -0
- package/scripts/project-evidence.js +172 -0
- package/scripts/project-identity.js +182 -0
- package/scripts/project-scope.js +381 -0
- package/scripts/prompt-guard.js +446 -52
- package/scripts/proof-report.js +232 -0
- package/scripts/provider-action-normalizer.js +14 -6
- package/scripts/pulse.js +80 -0
- package/scripts/rate-limiter.js +41 -0
- package/scripts/rrsi-doctor.js +2698 -0
- package/scripts/secret-redaction.js +171 -25
- package/scripts/secret-scanner.js +101 -42
- package/scripts/self-protection.js +2 -2
- package/scripts/seo-gsd.js +14 -14
- package/scripts/session-context-dedupe.js +66 -0
- package/scripts/session-report.js +120 -0
- package/scripts/settings-hierarchy.js +4 -2
- package/scripts/statusline-meta.js +34 -23
- package/scripts/subagent-profiles.js +79 -0
- package/scripts/task-outcomes.js +29 -2
- package/scripts/telemetry-analytics.js +238 -13
- package/scripts/third-author-cli.js +118 -0
- package/scripts/third-author-governance.js +437 -0
- package/scripts/thumbgate-dream.js +878 -0
- package/scripts/thumbgate-search.js +23 -9
- package/scripts/tool-kpi-tracker.js +5 -2
- package/scripts/tool-registry.js +42 -1
- package/scripts/triage-savings-calculator.js +1 -1
- package/scripts/vector-store.js +4 -1
- package/scripts/verified-lessons.js +270 -0
- package/scripts/verify-marketing-pages-deployed.js +2 -2
- package/scripts/workflow-sentinel.js +29 -10
- package/server.json +2 -2
- package/skills/thumbgate-daily-discoveries/SKILL.md +25 -41
- package/src/api/server.js +2371 -451
- package/src/feedback.js +21 -0
- package/src/hermes-sync-plane.js +2 -1
- package/src/index.js +2 -0
- package/src/lesson-search.js +9 -0
- package/src/mckinsey-top-company-ai-coding.js +493 -0
- package/src/mcp/server.js +3 -0
- package/src/mcp-writeguard.js +772 -11
- package/src/openshell-lovable-engine.js +1475 -0
- package/src/task-outcome.js +3 -0
- package/config/evals/agent-safety-eval.json +0 -447
- package/config/evals/retrieval-ranking-golden.json +0 -522
- package/config/progressive/01-wire-only.json +0 -11
- package/config/progressive/02-dashboard-empty-ok.json +0 -10
- package/config/progressive/03-one-lesson.json +0 -10
- package/config/progressive/04-warn-fires.json +0 -11
- package/config/progressive/05-strict-optional.json +0 -11
- package/config/progressive/README.md +0 -15
- package/public/assets/diagrams/agent-integration.png +0 -0
- package/public/assets/diagrams/thumbgate-architecture.png +0 -0
- package/scripts/install-thumbgate-daily-publish-launchd.sh +0 -83
- package/scripts/thumbgate-daily-discoveries-publish.js +0 -461
- package/scripts/thumbgate-daily-discoveries-publish.sh +0 -18
|
@@ -174,7 +174,6 @@ function renderScorecard(input) {
|
|
|
174
174
|
<a href="/eval-scorecard">Scorecard</a>
|
|
175
175
|
<a href="/evaluations">Evaluations</a>
|
|
176
176
|
<a href="/case-studies">Case studies</a>
|
|
177
|
-
<a href="/numbers">Numbers</a>
|
|
178
177
|
<a href="/pricing">Pricing</a>
|
|
179
178
|
</nav>
|
|
180
179
|
<main class="container">
|
|
@@ -21,9 +21,16 @@ const TOOL_NAME_MAP = new Map(Object.entries({
|
|
|
21
21
|
apply_diff: 'Edit',
|
|
22
22
|
insert_content: 'Edit',
|
|
23
23
|
search_and_replace: 'Edit',
|
|
24
|
-
// OpenCode / generic MCP
|
|
24
|
+
// OpenCode / Codex / Windows / generic MCP
|
|
25
25
|
bash: 'Bash',
|
|
26
26
|
shell: 'Bash',
|
|
27
|
+
shell_command: 'Bash',
|
|
28
|
+
exec_command: 'Bash',
|
|
29
|
+
local_shell: 'Bash',
|
|
30
|
+
'container.exec': 'Bash',
|
|
31
|
+
powershell: 'Bash',
|
|
32
|
+
pwsh: 'Bash',
|
|
33
|
+
terminal: 'Bash',
|
|
27
34
|
run_command: 'Bash',
|
|
28
35
|
edit_file: 'Edit',
|
|
29
36
|
write_file: 'Write',
|
|
@@ -48,14 +55,26 @@ function canonicalizeToolName(toolName) {
|
|
|
48
55
|
return TOOL_NAME_MAP.get(raw) || TOOL_NAME_MAP.get(raw.toLowerCase()) || raw;
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
function formatCommandArgvToken(item) {
|
|
59
|
+
const text = String(item ?? '');
|
|
60
|
+
if (!text) return '""';
|
|
61
|
+
if (!/[\s"'|&;<>()`\\]/.test(text)) return text;
|
|
62
|
+
return `"${text.replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function normalizeCommandValue(value) {
|
|
66
|
+
if (!Array.isArray(value)) return value;
|
|
67
|
+
return value.map((item) => formatCommandArgvToken(item)).join(' ');
|
|
68
|
+
}
|
|
69
|
+
|
|
51
70
|
function canonicalizeToolInput(toolInput) {
|
|
52
71
|
if (!toolInput || typeof toolInput !== 'object' || Array.isArray(toolInput)) return toolInput || {};
|
|
53
72
|
const out = {};
|
|
54
73
|
for (const [key, value] of Object.entries(toolInput)) {
|
|
55
74
|
const canonicalKey = ARG_KEY_MAP.get(key) || key;
|
|
56
|
-
|
|
57
|
-
if (canonicalKey
|
|
58
|
-
out[canonicalKey] = value;
|
|
75
|
+
if (key !== canonicalKey && (value === undefined || toolInput[canonicalKey] !== undefined)) continue;
|
|
76
|
+
if (out[canonicalKey] !== undefined) continue;
|
|
77
|
+
out[canonicalKey] = canonicalKey === 'command' ? normalizeCommandValue(value) : value;
|
|
59
78
|
}
|
|
60
79
|
return out;
|
|
61
80
|
}
|
|
@@ -67,4 +86,11 @@ function canonicalizeToolCall(toolName, toolInput) {
|
|
|
67
86
|
};
|
|
68
87
|
}
|
|
69
88
|
|
|
70
|
-
module.exports = {
|
|
89
|
+
module.exports = {
|
|
90
|
+
canonicalizeToolCall,
|
|
91
|
+
canonicalizeToolName,
|
|
92
|
+
canonicalizeToolInput,
|
|
93
|
+
normalizeCommandValue,
|
|
94
|
+
TOOL_NAME_MAP,
|
|
95
|
+
ARG_KEY_MAP,
|
|
96
|
+
};
|
|
@@ -328,7 +328,9 @@ function buildHybridState(opts) {
|
|
|
328
328
|
const { selectRecordsForScope } = require('./memory-scope-readiness');
|
|
329
329
|
if (o.requireScope && !o.scope) throw new Error('Scoped hybrid state requires scope');
|
|
330
330
|
const readEntries = file => {
|
|
331
|
-
const rows =
|
|
331
|
+
const rows = o.projectKey != null
|
|
332
|
+
? require('./project-catalog').readProjectRows(path.dirname(file), path.basename(file), { projectKey: o.projectKey }).slice(-HYBRID_JSONL_READ_LIMIT)
|
|
333
|
+
: readJsonl(file, HYBRID_JSONL_READ_LIMIT);
|
|
332
334
|
return o.scope ? selectRecordsForScope(rows, o.scope, { includeShared: o.includeShared !== false }).allowed : rows;
|
|
333
335
|
};
|
|
334
336
|
const feedbackEntries = readEntries(feedbackLogPath);
|
|
@@ -927,7 +929,7 @@ function evaluatePretool(toolName, toolInput, opts) {
|
|
|
927
929
|
if ((o.requireScope && !o.scope) || (o.scope && !graph.scopeKey(o.scope))) throw new Error('Scoped hybrid evaluation requires complete scope');
|
|
928
930
|
const graphScope = o.scope ? JSON.stringify([graph.scopeKey(o.scope), o.includeShared !== false]) : null;
|
|
929
931
|
const provenance = graph.graphProvenance({ feedbackDir: getHybridPaths(o).graphFeedbackDir });
|
|
930
|
-
if (artifact && provenance !== 'unavailable' && (artifact.graphProvenance || null) === provenance && (artifact.graphScope || null) === graphScope) {
|
|
932
|
+
if (o.projectKey == null && artifact && provenance !== 'unavailable' && (artifact.graphProvenance || null) === provenance && (artifact.graphScope || null) === graphScope) {
|
|
931
933
|
const result = evaluateCompiledGuards(artifact, toolName, toolInput);
|
|
932
934
|
if (result.mode !== 'allow') return result;
|
|
933
935
|
|
|
@@ -943,6 +945,7 @@ function evaluatePretool(toolName, toolInput, opts) {
|
|
|
943
945
|
|
|
944
946
|
// Slow path: build live state (also used when compiled guards are stale)
|
|
945
947
|
const state = buildHybridState({
|
|
948
|
+
projectKey: o.projectKey,
|
|
946
949
|
scope: o.scope,
|
|
947
950
|
requireScope: o.requireScope,
|
|
948
951
|
includeShared: o.includeShared,
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
|
|
7
|
+
const REPO_ROOT = path.resolve(__dirname, '..');
|
|
8
|
+
const DEFAULT_DIR = path.join(REPO_ROOT, '.thumbgate');
|
|
9
|
+
const MARKDOWN_NAME = 'implementation-notes.md';
|
|
10
|
+
const JSONL_NAME = 'implementation-notes.jsonl';
|
|
11
|
+
|
|
12
|
+
function resolvePaths({ dir } = {}) {
|
|
13
|
+
const base = dir ? path.resolve(dir) : DEFAULT_DIR;
|
|
14
|
+
return {
|
|
15
|
+
dir: base,
|
|
16
|
+
markdownPath: path.join(base, MARKDOWN_NAME),
|
|
17
|
+
jsonlPath: path.join(base, JSONL_NAME),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function ensureDir(dir) {
|
|
22
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function normalizeText(value) {
|
|
26
|
+
if (value === null || value === undefined) return '';
|
|
27
|
+
return String(value).trim();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function noteId(record) {
|
|
31
|
+
const seed = `${record.timestamp}|${record.tool}|${record.decision}|${record.rationale}`;
|
|
32
|
+
return `note_${crypto.createHash('sha256').update(seed).digest('hex').slice(0, 12)}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function renderMarkdownEntry(record) {
|
|
36
|
+
const lines = [
|
|
37
|
+
`### ${record.id} — ${record.timestamp}`,
|
|
38
|
+
'',
|
|
39
|
+
`- **Tool**: ${record.tool || '(unspecified)'}`,
|
|
40
|
+
`- **Decision**: ${record.decision || '(none)'}`,
|
|
41
|
+
];
|
|
42
|
+
if (record.rationale) lines.push(`- **Rationale**: ${record.rationale}`);
|
|
43
|
+
if (record.signal && record.signal !== 'info') lines.push(`- **Signal**: ${record.signal}`);
|
|
44
|
+
if (record.specSection) lines.push(`- **Spec section**: ${record.specSection}`);
|
|
45
|
+
if (record.tags && record.tags.length) lines.push(`- **Tags**: ${record.tags.join(', ')}`);
|
|
46
|
+
lines.push('');
|
|
47
|
+
return lines.join('\n');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function appendNote({ tool, decision, rationale, signal, specSection, tags, timestamp, dir } = {}) {
|
|
51
|
+
const decisionText = normalizeText(decision);
|
|
52
|
+
if (!decisionText) {
|
|
53
|
+
throw new Error('appendNote: decision is required');
|
|
54
|
+
}
|
|
55
|
+
const paths = resolvePaths({ dir });
|
|
56
|
+
ensureDir(paths.dir);
|
|
57
|
+
|
|
58
|
+
const record = {
|
|
59
|
+
timestamp: timestamp || new Date().toISOString(),
|
|
60
|
+
tool: normalizeText(tool) || 'unspecified',
|
|
61
|
+
decision: decisionText,
|
|
62
|
+
rationale: normalizeText(rationale),
|
|
63
|
+
signal: normalizeText(signal) || 'info',
|
|
64
|
+
specSection: normalizeText(specSection),
|
|
65
|
+
tags: Array.isArray(tags) ? tags.map(normalizeText).filter(Boolean) : [],
|
|
66
|
+
};
|
|
67
|
+
record.id = noteId(record);
|
|
68
|
+
|
|
69
|
+
if (!fs.existsSync(paths.markdownPath)) {
|
|
70
|
+
fs.writeFileSync(
|
|
71
|
+
paths.markdownPath,
|
|
72
|
+
'# Implementation Notes\n\nAuto-captured agent decisions, tradeoffs, and ambiguities. ' +
|
|
73
|
+
'Promote high-value entries to durable lessons via `thumbgate notes promote <id>`.\n\n',
|
|
74
|
+
'utf8',
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
fs.appendFileSync(paths.markdownPath, renderMarkdownEntry(record), 'utf8');
|
|
78
|
+
fs.appendFileSync(paths.jsonlPath, `${JSON.stringify(record)}\n`, 'utf8');
|
|
79
|
+
|
|
80
|
+
return record;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function listNotes({ dir, limit = 20 } = {}) {
|
|
84
|
+
const paths = resolvePaths({ dir });
|
|
85
|
+
if (!fs.existsSync(paths.jsonlPath)) return [];
|
|
86
|
+
const raw = fs.readFileSync(paths.jsonlPath, 'utf8');
|
|
87
|
+
const records = raw
|
|
88
|
+
.split('\n')
|
|
89
|
+
.filter(Boolean)
|
|
90
|
+
.map((line) => {
|
|
91
|
+
try {
|
|
92
|
+
return JSON.parse(line);
|
|
93
|
+
} catch (_err) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
return records.slice(-Math.max(1, Number(limit) || 20));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function findNote({ id, dir }) {
|
|
102
|
+
if (!id) return null;
|
|
103
|
+
const paths = resolvePaths({ dir });
|
|
104
|
+
if (!fs.existsSync(paths.jsonlPath)) return null;
|
|
105
|
+
const raw = fs.readFileSync(paths.jsonlPath, 'utf8');
|
|
106
|
+
for (const line of raw.split('\n').filter(Boolean)) {
|
|
107
|
+
try {
|
|
108
|
+
const record = JSON.parse(line);
|
|
109
|
+
if (record.id === id) return record;
|
|
110
|
+
} catch (_err) {
|
|
111
|
+
// ignore malformed lines
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function promoteToLesson({ id, dir, capture }) {
|
|
118
|
+
const record = findNote({ id, dir });
|
|
119
|
+
if (!record) {
|
|
120
|
+
throw new Error(`promoteToLesson: no note with id ${id}`);
|
|
121
|
+
}
|
|
122
|
+
if (typeof capture !== 'function') {
|
|
123
|
+
throw new Error('promoteToLesson: capture function required (inject the feedback-capture module to keep this module dependency-free)');
|
|
124
|
+
}
|
|
125
|
+
const result = capture({
|
|
126
|
+
feedback: record.signal === 'down' ? 'down' : record.signal === 'up' ? 'up' : 'down',
|
|
127
|
+
context: `[implementation-note ${record.id}] ${record.decision}`,
|
|
128
|
+
whatWentWrong: record.signal === 'down' ? record.rationale || record.decision : '',
|
|
129
|
+
whatWorked: record.signal === 'up' ? record.rationale || record.decision : '',
|
|
130
|
+
whatToChange: record.specSection ? `Update spec section: ${record.specSection}` : '',
|
|
131
|
+
tags: ['implementation-note', ...(record.tags || [])],
|
|
132
|
+
sourceNoteId: record.id,
|
|
133
|
+
});
|
|
134
|
+
return { noteId: record.id, captureResult: result };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function parseCliArgs(argv) {
|
|
138
|
+
const args = { _: [] };
|
|
139
|
+
for (const raw of argv) {
|
|
140
|
+
if (raw.startsWith('--')) {
|
|
141
|
+
const [key, value] = raw.slice(2).split('=');
|
|
142
|
+
if (value === undefined) args[key] = true;
|
|
143
|
+
else if (key === 'tags') args[key] = value.split(',').map((t) => t.trim()).filter(Boolean);
|
|
144
|
+
else args[key] = value;
|
|
145
|
+
} else {
|
|
146
|
+
args._.push(raw);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return args;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function cli(argv = process.argv.slice(3)) {
|
|
153
|
+
const subcommand = argv[0];
|
|
154
|
+
const rest = argv.slice(1);
|
|
155
|
+
const args = parseCliArgs(rest);
|
|
156
|
+
|
|
157
|
+
switch (subcommand) {
|
|
158
|
+
case 'append': {
|
|
159
|
+
const record = appendNote({
|
|
160
|
+
tool: args.tool,
|
|
161
|
+
decision: args.decision,
|
|
162
|
+
rationale: args.rationale,
|
|
163
|
+
signal: args.signal,
|
|
164
|
+
specSection: args['spec-section'] || args.section,
|
|
165
|
+
tags: args.tags,
|
|
166
|
+
dir: args.dir,
|
|
167
|
+
});
|
|
168
|
+
console.log(JSON.stringify(record, null, 2));
|
|
169
|
+
return record;
|
|
170
|
+
}
|
|
171
|
+
case 'list': {
|
|
172
|
+
const records = listNotes({ dir: args.dir, limit: args.limit });
|
|
173
|
+
if (args.json) {
|
|
174
|
+
console.log(JSON.stringify(records, null, 2));
|
|
175
|
+
} else if (records.length === 0) {
|
|
176
|
+
console.log('No implementation notes yet. Capture one via: thumbgate notes append --decision="..."');
|
|
177
|
+
} else {
|
|
178
|
+
for (const r of records) {
|
|
179
|
+
console.log(`${r.id} [${r.signal}] ${r.tool} ${r.decision.slice(0, 80)}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return records;
|
|
183
|
+
}
|
|
184
|
+
case 'show': {
|
|
185
|
+
const id = args._[0] || args.id;
|
|
186
|
+
const record = findNote({ id, dir: args.dir });
|
|
187
|
+
if (!record) {
|
|
188
|
+
console.error(`No note with id ${id}`);
|
|
189
|
+
process.exitCode = 1;
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
console.log(JSON.stringify(record, null, 2));
|
|
193
|
+
return record;
|
|
194
|
+
}
|
|
195
|
+
case 'promote': {
|
|
196
|
+
const id = args._[0] || args.id;
|
|
197
|
+
let capture;
|
|
198
|
+
try {
|
|
199
|
+
({ captureFeedback: capture } = require(path.join(REPO_ROOT, 'scripts', 'capture-feedback')));
|
|
200
|
+
} catch (_err) {
|
|
201
|
+
capture = (payload) => {
|
|
202
|
+
console.log('[notes promote] (no capture-feedback module wired) payload:');
|
|
203
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
204
|
+
return { dryRun: true };
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const result = promoteToLesson({ id, dir: args.dir, capture });
|
|
208
|
+
console.log(JSON.stringify(result, null, 2));
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
default:
|
|
212
|
+
console.log('Usage: thumbgate notes <append|list|show|promote> [flags]');
|
|
213
|
+
console.log('');
|
|
214
|
+
console.log(' append Append an implementation note.');
|
|
215
|
+
console.log(' --decision="..." (required) --tool=<name> --rationale="..."');
|
|
216
|
+
console.log(' --signal=info|up|down --spec-section=<id> --tags=a,b,c');
|
|
217
|
+
console.log(' list Show recent notes. --json for raw, --limit=N to cap.');
|
|
218
|
+
console.log(' show Show a single note by id.');
|
|
219
|
+
console.log(' promote Promote a note to a durable lesson via capture-feedback.');
|
|
220
|
+
console.log('');
|
|
221
|
+
console.log('Storage: .thumbgate/implementation-notes.{md,jsonl} (gitignored).');
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function isCliInvocation(argv = process.argv) {
|
|
227
|
+
return path.resolve(argv[1] || '') === path.resolve(__filename);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (isCliInvocation()) {
|
|
231
|
+
cli(process.argv.slice(2));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
module.exports = {
|
|
235
|
+
appendNote,
|
|
236
|
+
listNotes,
|
|
237
|
+
findNote,
|
|
238
|
+
promoteToLesson,
|
|
239
|
+
cli,
|
|
240
|
+
resolvePaths,
|
|
241
|
+
};
|