@thincoder/core 0.11.1 → 0.11.3
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 +64 -2
- package/advisor/compaction.mjs +7 -5
- package/advisor/convergence.mjs +34 -3
- package/advisor/history.mjs +24 -11
- package/advisor/loop.mjs +49 -12
- package/advisor/messages.mjs +114 -33
- package/advisor/project-context.mjs +171 -42
- package/advisor/run.mjs +24 -10
- package/advisor.mjs +36 -46
- package/agent/batch-attribution.mjs +87 -0
- package/agent/batch-changed-surface.mjs +129 -0
- package/agent/chat-call.mjs +14 -9
- package/agent/completion.mjs +70 -41
- package/agent/continue-decision.mjs +14 -8
- package/agent/digest-account.mjs +133 -59
- package/agent/dispatch-gates.mjs +6 -0
- package/agent/dispatch-run.mjs +1 -1
- package/agent/dispatch.mjs +10 -4
- package/agent/family-tools.mjs +37 -23
- package/agent/helpers.mjs +139 -73
- package/agent/image-heal.mjs +18 -4
- package/agent/offload.mjs +25 -29
- package/agent/post-turn.mjs +36 -35
- package/agent/record-results.mjs +39 -7
- package/agent/run-stages.mjs +132 -52
- package/agent/run-start.mjs +150 -78
- package/agent/setup-reminders.mjs +194 -91
- package/agent/setup.mjs +219 -140
- package/agent/spawn-child.mjs +40 -3
- package/agent/suspension.mjs +43 -15
- package/agent/timers.mjs +9 -4
- package/agent/turn-domain-text.mjs +105 -0
- package/agent/turn-loop.mjs +84 -27
- package/agent/turn-projection.mjs +286 -0
- package/agent/turn-task-state.mjs +274 -0
- package/agent/turn-tool-process.mjs +163 -0
- package/agent/write-gate-ledger.mjs +569 -0
- package/agent/write-gate.mjs +29 -352
- package/agent-tools/advisor-async.mjs +35 -172
- package/agent-tools/advisor-launch.mjs +178 -0
- package/agent-tools/advisor-settle.mjs +28 -1
- package/agent-tools/advisor.mjs +37 -48
- package/agent-tools/async-discard.mjs +7 -2
- package/agent-tools/async-settle.mjs +18 -12
- package/agent-tools/audit-block.mjs +6 -6
- package/agent-tools/bash-async.mjs +5 -2
- package/agent-tools/batch-closeout.mjs +223 -35
- package/agent-tools/batch-gate.mjs +142 -342
- package/agent-tools/batch-ledger-bind.mjs +240 -20
- package/agent-tools/batch-ledger-view.mjs +109 -0
- package/agent-tools/batch-lifecycle.mjs +197 -48
- package/agent-tools/batch-paths.mjs +29 -8
- package/agent-tools/batch-read.mjs +151 -4
- package/agent-tools/batch-record-write.mjs +417 -0
- package/agent-tools/batch-regions.mjs +215 -0
- package/agent-tools/batch-reopen.mjs +23 -11
- package/agent-tools/batch-segment-vocab.mjs +459 -0
- package/agent-tools/batch-skeleton.mjs +196 -239
- package/agent-tools/batch-supersede.mjs +232 -0
- package/agent-tools/batch-tier-gate.mjs +214 -0
- package/agent-tools/batch.mjs +192 -439
- package/agent-tools/browser-async.mjs +5 -2
- package/agent-tools/consult.mjs +17 -11
- package/agent-tools/context.mjs +76 -33
- package/agent-tools/design-review-record.mjs +225 -0
- package/agent-tools/design-slots.mjs +1 -1
- package/agent-tools/design-token.mjs +279 -81
- package/agent-tools/digest-budget.mjs +10 -9
- package/agent-tools/doc-check.mjs +43 -33
- package/agent-tools/doc-graph.mjs +140 -0
- package/agent-tools/eng.mjs +12 -12
- package/agent-tools/escalate-async.mjs +5 -5
- package/agent-tools/goal.mjs +5 -2
- package/agent-tools/judge-domain.mjs +347 -0
- package/agent-tools/manifest.mjs +34 -18
- package/agent-tools/parent-channel.mjs +6 -3
- package/agent-tools/plan.mjs +11 -10
- package/agent-tools/read-history.mjs +112 -11
- package/agent-tools/review-facts.mjs +19 -6
- package/agent-tools/settings.mjs +23 -2
- package/agent-tools/skill.mjs +7 -8
- package/agent-tools/spawn-gates.mjs +14 -24
- package/agent-tools/ssh-session.mjs +8 -5
- package/agent-tools/ssh-text.mjs +155 -0
- package/agent-tools/ssh-transfer.mjs +1 -1
- package/agent-tools/ssh-transport.mjs +19 -148
- package/agent-tools/subagent-actions-query.mjs +10 -6
- package/agent-tools/subagent-actions.mjs +2 -2
- package/agent-tools/subagent-async.mjs +19 -17
- package/agent-tools/subagent-brief.mjs +76 -0
- package/agent-tools/subagent-design-token.mjs +168 -0
- package/agent-tools/subagent-run.mjs +1 -1
- package/agent-tools/subagent-scheduler.mjs +13 -13
- package/agent-tools/subagent-spawn.mjs +92 -112
- package/agent-tools/subagent.mjs +16 -28
- package/agent-tools/task.mjs +0 -8
- package/agent-tools/taskbook-block.mjs +94 -0
- package/agent-tools/timer.mjs +12 -8
- package/agent-tools/verify.mjs +13 -4
- package/agent-tools.mjs +7 -3
- package/agent.mjs +26 -7
- package/attachments.mjs +3 -3
- package/auto-think.mjs +5 -2
- package/browser/actions.mjs +9 -3
- package/browser/cdp.mjs +45 -17
- package/browser/launch.mjs +25 -43
- package/browser/pool.mjs +299 -0
- package/browser/queue.mjs +2 -0
- package/browser/session-state.mjs +450 -0
- package/browser/session.mjs +127 -151
- package/browser/snapshot.mjs +89 -0
- package/client-identity.mjs +1 -1
- package/compaction-work-state.mjs +230 -0
- package/compress-form.mjs +41 -6
- package/config-defaults.mjs +7 -3
- package/config-migrate.mjs +40 -0
- package/config-normalize.mjs +28 -2
- package/config-reload.mjs +59 -0
- package/config.mjs +110 -110
- package/context-degrade.mjs +93 -34
- package/context-echo.mjs +6 -15
- package/context-push.mjs +328 -31
- package/context.mjs +298 -170
- package/conventions.mjs +11 -9
- package/declaration.mjs +126 -22
- package/declared-repos.mjs +94 -0
- package/doc-check/doc-names.mjs +73 -0
- package/doc-check/doc-tokens.mjs +110 -0
- package/doc-check/existence.mjs +160 -0
- package/doc-check/index.mjs +309 -213
- package/doc-check/line-refs.mjs +27 -101
- package/doc-check/paragraph.mjs +218 -102
- package/doc-graph/anchors.mjs +474 -0
- package/doc-graph/doc-batch-face.mjs +59 -0
- package/doc-graph/doc-suffix.mjs +27 -0
- package/doc-graph/graph-tokens.mjs +160 -0
- package/doc-graph.mjs +778 -0
- package/escape.mjs +6 -5
- package/explore-distill.mjs +41 -8
- package/generate-title.mjs +10 -1
- package/i18n.mjs +1 -1
- package/instance-inbox-watch.mjs +272 -0
- package/instance-inbox.mjs +218 -0
- package/instance-registry.mjs +179 -0
- package/knowledge/README.md +3 -0
- package/knowledge/prompt-resources.md +10 -0
- package/ledger-close-proof.mjs +100 -49
- package/ledger-close.mjs +188 -0
- package/ledger-cmd.mjs +47 -91
- package/ledger-consistency.mjs +113 -0
- package/ledger-db.mjs +47 -15
- package/ledger-executors.mjs +1 -1
- package/ledger-tools.mjs +121 -62
- package/ledger-write-ops.mjs +162 -46
- package/ledger.mjs +1 -1
- package/manifest-discovery.mjs +3 -1
- package/manifest-schema.mjs +27 -5
- package/memory/docs.mjs +51 -15
- package/memory/file-list.mjs +6 -0
- package/memory/schema.mjs +2 -2
- package/model-specs.mjs +87 -21
- package/origin-guard.mjs +190 -0
- package/package.json +3 -1
- package/path-resolve.mjs +338 -57
- package/prompt-files.mjs +114 -2
- package/prompt-overlays.mjs +21 -11
- package/prompts/advisor-design.md +96 -36
- package/prompts/advisor-round1.md +48 -4
- package/prompts/advisor-round2.md +54 -10
- package/prompts/advisor-round3.md +53 -9
- package/prompts/common.md +99 -434
- package/prompts/consult-base.md +7 -4
- package/prompts/discipline-engineering.md +504 -295
- package/prompts/discipline-normal.md +106 -281
- package/prompts/knowledge/business-gates.md +30 -0
- package/prompts/knowledge/decision-quality.md +21 -0
- package/prompts/knowledge/doc-lookup.md +30 -0
- package/prompts/knowledge/document-writing.md +33 -0
- package/prompts/knowledge/documentation-evaluation.md +48 -0
- package/prompts/knowledge/evidence-discipline.md +38 -0
- package/prompts/knowledge/normal-coding-workflow.md +110 -0
- package/prompts/knowledge/normal-delivery-collaboration.md +124 -0
- package/prompts/knowledge/normal-work-management.md +60 -0
- package/prompts/knowledge/product-security.md +28 -0
- package/prompts/knowledge/project-records.md +73 -0
- package/prompts/knowledge/tool-advisor.md +29 -0
- package/prompts/knowledge/tool-apply-patch.md +17 -0
- package/prompts/knowledge/tool-bash.md +48 -0
- package/prompts/knowledge/tool-batch-eng-coder.md +19 -0
- package/prompts/knowledge/tool-batch-eng-designer.md +20 -0
- package/prompts/knowledge/tool-batch-review.md +18 -0
- package/prompts/knowledge/tool-batch.md +94 -0
- package/prompts/knowledge/tool-browser.md +68 -0
- package/prompts/knowledge/tool-code-search.md +4 -0
- package/prompts/knowledge/tool-consult-start.md +12 -0
- package/prompts/knowledge/tool-consult-stop.md +6 -0
- package/prompts/knowledge/tool-context.md +6 -0
- package/prompts/knowledge/tool-delete.md +21 -0
- package/prompts/knowledge/tool-doc-check.md +71 -0
- package/prompts/knowledge/tool-doc-graph-read.md +20 -0
- package/prompts/knowledge/tool-doc-graph.md +49 -0
- package/prompts/knowledge/tool-doc-search.md +6 -0
- package/prompts/knowledge/tool-edit.md +41 -0
- package/prompts/knowledge/tool-eng.md +2 -0
- package/prompts/knowledge/tool-execute.md +21 -0
- package/prompts/knowledge/tool-fetch.md +18 -0
- package/prompts/knowledge/tool-file-ops.md +21 -0
- package/prompts/knowledge/tool-get-current-time.md +7 -0
- package/prompts/knowledge/tool-git-read.md +21 -0
- package/prompts/knowledge/tool-git.md +29 -0
- package/prompts/knowledge/tool-glob.md +17 -0
- package/prompts/knowledge/tool-goal.md +8 -0
- package/prompts/knowledge/tool-grep.md +21 -0
- package/prompts/knowledge/tool-hashline-edit.md +16 -0
- package/prompts/knowledge/tool-insert-after.md +17 -0
- package/prompts/knowledge/tool-instance-list.md +6 -0
- package/prompts/knowledge/tool-instance-send.md +10 -0
- package/prompts/knowledge/tool-knowledge.md +18 -0
- package/prompts/knowledge/tool-ledger-read.md +28 -0
- package/prompts/knowledge/tool-ledger.md +46 -0
- package/prompts/knowledge/tool-lint.md +16 -0
- package/prompts/knowledge/tool-ls.md +15 -0
- package/prompts/knowledge/tool-lsp.md +11 -0
- package/prompts/knowledge/tool-main-history.md +2 -0
- package/prompts/knowledge/tool-manifest-read.md +14 -0
- package/prompts/knowledge/tool-manifest.md +34 -0
- package/prompts/knowledge/tool-memory-read.md +20 -0
- package/prompts/knowledge/tool-memory.md +19 -0
- package/prompts/knowledge/tool-notify-parent.md +12 -0
- package/prompts/knowledge/tool-operations.md +102 -0
- package/prompts/knowledge/tool-peer-instances.md +2 -0
- package/prompts/knowledge/tool-plan.md +5 -0
- package/prompts/knowledge/tool-process-read.md +13 -0
- package/prompts/knowledge/tool-process.md +15 -0
- package/prompts/knowledge/tool-question.md +16 -0
- package/prompts/knowledge/tool-read-history-batch.md +22 -0
- package/prompts/knowledge/tool-read-history.md +35 -0
- package/prompts/knowledge/tool-read-image.md +11 -0
- package/prompts/knowledge/tool-read.md +22 -0
- package/prompts/knowledge/tool-recent-changes.md +6 -0
- package/prompts/knowledge/tool-repo-outline.md +4 -0
- package/prompts/knowledge/tool-settings-read.md +12 -0
- package/prompts/knowledge/tool-settings.md +17 -0
- package/prompts/knowledge/tool-skill.md +6 -0
- package/prompts/knowledge/tool-ssh.md +74 -0
- package/prompts/knowledge/tool-subagent.md +57 -0
- package/prompts/knowledge/tool-task.md +14 -0
- package/prompts/knowledge/tool-team-ledger-read.md +11 -0
- package/prompts/knowledge/tool-team-ledger.md +15 -0
- package/prompts/knowledge/tool-timer.md +23 -0
- package/prompts/knowledge/tool-tree.md +16 -0
- package/prompts/knowledge/tool-verify.md +19 -0
- package/prompts/knowledge/tool-wait-for.md +25 -0
- package/prompts/knowledge/tool-websearch.md +19 -0
- package/prompts/knowledge/tool-write.md +12 -0
- package/prompts/knowledge/upstream-protocol.md +45 -0
- package/prompts/persona-coder.md +1 -3
- package/prompts/persona-eng-coder.md +24 -6
- package/prompts/persona-eng-designer.md +150 -171
- package/prompts/persona-engineering.md +531 -442
- package/prompts/persona-explore.md +1 -3
- package/prompts/persona-normal.md +17 -9
- package/prompts/persona-plan.md +5 -3
- package/prompts/persona-tester.md +0 -2
- package/prompts/subagent-base.md +2 -2
- package/provider/anthropic.mjs +10 -6
- package/provider/core.mjs +8 -5
- package/provider/errors.mjs +63 -4
- package/provider/google.mjs +29 -10
- package/provider/reasoning-echo.mjs +16 -0
- package/provider/responses.mjs +7 -3
- package/provider/sse.mjs +11 -6
- package/provider-flows.mjs +2 -2
- package/rules.mjs +11 -10
- package/session-index-build.mjs +1 -1
- package/session-index-pass.mjs +1 -1
- package/session-index-query.mjs +1 -1
- package/session-index.mjs +1 -1
- package/session-lifecycle.mjs +131 -42
- package/session-slot-write.mjs +38 -6
- package/session.mjs +30 -11
- package/shell-identity.mjs +129 -22
- package/skip-dirs.mjs +26 -2
- package/team-ledger.mjs +34 -30
- package/text-budget.mjs +1 -1
- package/think-off.mjs +27 -0
- package/token-ttl.mjs +74 -5
- package/token-window.mjs +371 -47
- package/tool-docs/advisor.md +2 -27
- package/tool-docs/apply_patch.md +1 -15
- package/tool-docs/bash.md +2 -43
- package/tool-docs/batch-eng-coder.md +3 -0
- package/tool-docs/batch-eng-designer.md +3 -0
- package/tool-docs/batch-review.md +3 -0
- package/tool-docs/batch.md +2 -84
- package/tool-docs/browser.md +2 -49
- package/tool-docs/code_search.md +2 -2
- package/tool-docs/consult_start.md +2 -8
- package/tool-docs/consult_stop.md +2 -4
- package/tool-docs/context.md +1 -5
- package/tool-docs/delete.md +2 -17
- package/tool-docs/doc_check.md +2 -107
- package/tool-docs/doc_graph-read.md +3 -0
- package/tool-docs/doc_graph.md +3 -0
- package/tool-docs/doc_search.md +2 -4
- package/tool-docs/edit.md +1 -38
- package/tool-docs/eng.md +3 -1
- package/tool-docs/execute.md +2 -18
- package/tool-docs/fetch.md +2 -14
- package/tool-docs/file_ops.md +2 -18
- package/tool-docs/get_current_time.md +1 -6
- package/tool-docs/git-read.md +3 -0
- package/tool-docs/git.md +2 -35
- package/tool-docs/glob.md +2 -10
- package/tool-docs/goal.md +1 -6
- package/tool-docs/grep.md +2 -18
- package/tool-docs/hashline_edit.md +2 -15
- package/tool-docs/insert_after.md +2 -16
- package/tool-docs/instance_list.md +3 -0
- package/tool-docs/instance_send.md +3 -0
- package/tool-docs/knowledge.md +3 -0
- package/tool-docs/ledger-read.md +3 -0
- package/tool-docs/ledger.md +3 -8
- package/tool-docs/lint.md +2 -10
- package/tool-docs/ls.md +2 -11
- package/tool-docs/lsp.md +2 -9
- package/tool-docs/main_history.md +3 -1
- package/tool-docs/manifest-read.md +2 -8
- package/tool-docs/manifest.md +2 -35
- package/tool-docs/memory-read.md +3 -0
- package/tool-docs/memory.md +2 -20
- package/tool-docs/notify_parent.md +2 -13
- package/tool-docs/peer_instances.md +3 -1
- package/tool-docs/plan.md +1 -5
- package/tool-docs/process-read.md +3 -0
- package/tool-docs/process.md +2 -13
- package/tool-docs/question.md +3 -17
- package/tool-docs/read.md +2 -19
- package/tool-docs/read_history-batch.md +3 -0
- package/tool-docs/read_history.md +2 -18
- package/tool-docs/read_image.md +2 -9
- package/tool-docs/recent_changes.md +2 -2
- package/tool-docs/repo_outline.md +2 -2
- package/tool-docs/settings-read.md +3 -0
- package/tool-docs/settings.md +1 -12
- package/tool-docs/skill.md +2 -6
- package/tool-docs/ssh.md +1 -62
- package/tool-docs/subagent.md +2 -100
- package/tool-docs/task.md +1 -7
- package/tool-docs/team_ledger-read.md +3 -0
- package/tool-docs/team_ledger.md +3 -9
- package/tool-docs/timer.md +2 -19
- package/tool-docs/tree.md +2 -13
- package/tool-docs/verify.md +2 -12
- package/tool-docs/wait_for.md +2 -32
- package/tool-docs/websearch.md +2 -19
- package/tool-docs/write.md +2 -12
- package/tools/browser.mjs +54 -9
- package/tools/doc-write-gate.mjs +73 -0
- package/tools/edit-batch.mjs +170 -92
- package/tools/edit-diff.mjs +78 -62
- package/tools/edit-receipt.mjs +39 -0
- package/tools/execute.mjs +3 -3
- package/tools/file.mjs +28 -14
- package/tools/git.mjs +36 -21
- package/tools/index.mjs +6 -0
- package/tools/knowledge.mjs +143 -0
- package/tools/linter.mjs +3 -3
- package/tools/ops.mjs +5 -3
- package/tools/patch.mjs +124 -44
- package/tools/process-doc-mark.mjs +33 -4
- package/tools/repomap.mjs +25 -3
- package/tools/search.mjs +74 -26
- package/tools/shared.mjs +29 -27
- package/tools/ssh.mjs +5 -5
- package/tools/tree.mjs +32 -10
- package/tools/web-deepseek.mjs +1 -1
- package/tools/web.mjs +2 -2
- package/tools/write-gate-params.mjs +31 -0
- package/tools/write-path.mjs +16 -4
- package/window-policy.mjs +243 -0
- package/doc-check/anchors.mjs +0 -235
package/prompt-files.mjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* supplies values via `configurePromptInjections`. Unconfigured = identity; missing key = throw.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
import { readFileSync } from "node:fs"
|
|
23
|
+
import { readFileSync, readdirSync } from "node:fs"
|
|
24
24
|
import { join, dirname } from "node:path"
|
|
25
25
|
import { fileURLToPath } from "node:url"
|
|
26
26
|
|
|
@@ -30,6 +30,114 @@ const ROOT = dirname(fileURLToPath(import.meta.url))
|
|
|
30
30
|
export const PROMPTS_DIR = join(ROOT, "prompts")
|
|
31
31
|
/** Core package-internal `tool-docs/` directory (tool descriptions). */
|
|
32
32
|
export const TOOL_DOCS_DIR = join(ROOT, "tool-docs")
|
|
33
|
+
/** Prompt topics may inline into full prompts; query topics never inline in any mode. */
|
|
34
|
+
export const KNOWLEDGE_DIR = join(PROMPTS_DIR, "knowledge")
|
|
35
|
+
export const QUERY_KNOWLEDGE_DIR = join(ROOT, "knowledge")
|
|
36
|
+
const KNOWLEDGE_SOURCES = Object.freeze([
|
|
37
|
+
{ kind: "prompt", dir: KNOWLEDGE_DIR },
|
|
38
|
+
{ kind: "query", dir: QUERY_KNOWLEDGE_DIR },
|
|
39
|
+
])
|
|
40
|
+
const KNOWLEDGE_ID_RE = /^[a-z0-9-]+$/
|
|
41
|
+
const ALIAS_DECLARATION_PREFIX = "aliases"
|
|
42
|
+
/** 别名分隔符:半角逗号 ∥ 全角逗号 ∥ 顿号——中文习惯里的 `,` 与 `、` 都要切得开。 */
|
|
43
|
+
const ALIAS_SEPARATOR_RE = /[,,、]/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 剥掉主题首行的 `aliases:` 声明,返回 `{ aliases, body }`。声明是元数据不是正文:`get`、完整档内联与
|
|
47
|
+
* 锚回填都只看剩下的 `body`,否则为检索加的元数据会随主题正文一起进系统提示词与 `get` 回执。
|
|
48
|
+
* 声明只有两种形态——没有这一行,或首行是一行 `aliases:` 加至少一个非空词;首行以 `aliases` 开头却不成形
|
|
49
|
+
* (无冒号或取不出词)就在加载期点名主题失败:静默丢掉别名会把「声明写坏了」说成「这个词本来不命中」,
|
|
50
|
+
* 两者在模型的失败回执上长得一模一样。
|
|
51
|
+
*/
|
|
52
|
+
function splitAliasDeclaration(id, content) {
|
|
53
|
+
const newline = content.indexOf("\n")
|
|
54
|
+
const firstLine = (newline < 0 ? content : content.slice(0, newline)).replace(/\r$/, "").trimStart()
|
|
55
|
+
if (!firstLine.toLowerCase().startsWith(ALIAS_DECLARATION_PREFIX)) return { aliases: [], body: content }
|
|
56
|
+
const declaration = firstLine.slice(ALIAS_DECLARATION_PREFIX.length).trim()
|
|
57
|
+
const words = declaration.startsWith(":")
|
|
58
|
+
? declaration.slice(1).split(ALIAS_SEPARATOR_RE).map((word) => word.trim()).filter(Boolean)
|
|
59
|
+
: []
|
|
60
|
+
if (words.length === 0) {
|
|
61
|
+
throw new Error(`knowledge: topic "${id}" has a malformed aliases declaration on its first line — write "aliases: word, word", or drop the line`)
|
|
62
|
+
}
|
|
63
|
+
return { aliases: words, body: newline < 0 ? "" : content.slice(newline + 1) }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 主题条目面(标识 ∥ 标题 ∥ 别名 ∥ 正文):List 与 search 共读一处,别名只在这里解析一次。 */
|
|
67
|
+
export function readKnowledgeEntries(sources = KNOWLEDGE_SOURCES) {
|
|
68
|
+
const entries = []
|
|
69
|
+
const seen = new Set()
|
|
70
|
+
for (const source of sources) {
|
|
71
|
+
const files = readdirSync(source.dir).filter((name) => name.endsWith(".md") && name.toLowerCase() !== "readme.md").sort()
|
|
72
|
+
for (const file of files) {
|
|
73
|
+
const id = file.slice(0, -3).toLowerCase()
|
|
74
|
+
if (!KNOWLEDGE_ID_RE.test(id)) throw new Error(`knowledge: invalid topic identifier "${id}"`)
|
|
75
|
+
if (seen.has(id)) throw new Error(`knowledge: duplicate topic identifier "${id}" across bundled resource directories`)
|
|
76
|
+
seen.add(id)
|
|
77
|
+
const path = join(source.dir, file)
|
|
78
|
+
let raw
|
|
79
|
+
try { raw = readFileSync(path, "utf8") }
|
|
80
|
+
catch (error) { throw new Error(`knowledge: topic "${id}" is unavailable at ${path} — ${error.message}`, { cause: error }) }
|
|
81
|
+
const { aliases, body } = splitAliasDeclaration(id, raw)
|
|
82
|
+
const title = body.match(/^#{1,6}\s+(.+)$/m)?.[1]?.trim() || id
|
|
83
|
+
entries.push({ id, title, content: body, aliases, kind: source.kind })
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return entries.sort((a, b) => a.id.localeCompare(b.id))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Read one complete topic from the global namespace. Full-prompt expansion excludes query-only topics. */
|
|
90
|
+
export function loadKnowledgeTopic(id, { promptOnly = false } = {}) {
|
|
91
|
+
if (typeof id !== "string" || !KNOWLEDGE_ID_RE.test(id)) {
|
|
92
|
+
throw new Error(`knowledge: unknown topic ${JSON.stringify(id)} — call list for valid topic identifiers`)
|
|
93
|
+
}
|
|
94
|
+
const entry = readKnowledgeEntries().find((item) => item.id === id)
|
|
95
|
+
if (!entry || (promptOnly && entry.kind !== "prompt")) {
|
|
96
|
+
throw new Error(`knowledge: unknown topic "${id}" — call list for valid topic identifiers`)
|
|
97
|
+
}
|
|
98
|
+
return entry.content
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Stable combined topic inventory. README files are documentation, not topics. */
|
|
102
|
+
export function listKnowledgeTopics(sources = KNOWLEDGE_SOURCES) {
|
|
103
|
+
return readKnowledgeEntries(sources).map(({ id, title }) => ({ id, title }))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// A knowledge anchor owns a whole line: the line holds the anchor and nothing else. Both tiers read that
|
|
107
|
+
// one grammar — full mode swaps the line for the topic body, tiny mode hands the line back verbatim (the
|
|
108
|
+
// anchor line is that tier's only topic inventory), and the residual check looks at the standalone marker
|
|
109
|
+
// lines full mode did not consume. A marker inside a sentence is not an anchor; it reaches the model
|
|
110
|
+
// verbatim. Reason: the sentence that states the grammar is itself carrying the marker shape, so judging
|
|
111
|
+
// an in-sentence marker as a broken anchor would make the prompt unable to describe its own anchor grammar.
|
|
112
|
+
const KNOWLEDGE_ANCHOR_LINE_RE = /^[ \t]*\{\{knowledge:([a-z0-9-]+)\}\}[ \t]*(\r?\n|$)/gm
|
|
113
|
+
const KNOWLEDGE_ANCHOR_RESIDUAL_LINE_RE = /^[ \t]*\{\{knowledge:[^{}\n]*\}\}[ \t]*$/gm
|
|
114
|
+
|
|
115
|
+
/** Expand the shared master for full mode; tiny keeps every standalone anchor line verbatim. */
|
|
116
|
+
export function expandKnowledgeTopics(text, { tiny = false } = {}) {
|
|
117
|
+
const seen = new Set()
|
|
118
|
+
const result = text.replace(KNOWLEDGE_ANCHOR_LINE_RE, (line, id, terminator) => {
|
|
119
|
+
if (seen.has(id)) throw new Error(`prompt knowledge anchor duplicated: ${id}`)
|
|
120
|
+
seen.add(id)
|
|
121
|
+
// Both tiers resolve the topic first: tiny does not inline the body, but an anchor on its own line
|
|
122
|
+
// that names no topic is a broken anchor either way — handing the line back would report "this tier
|
|
123
|
+
// carries this topic" for a misspelt anchor.
|
|
124
|
+
let body = ""
|
|
125
|
+
try {
|
|
126
|
+
body = loadKnowledgeTopic(id, { promptOnly: true })
|
|
127
|
+
} catch (error) {
|
|
128
|
+
throw new Error(`prompt knowledge anchor cannot be resolved: {{knowledge:${id}}} — ${error.message}`, { cause: error })
|
|
129
|
+
}
|
|
130
|
+
return tiny ? line : body + terminator
|
|
131
|
+
})
|
|
132
|
+
// Tiny hands every anchor line back, so scanning there would judge each kept line a broken anchor and
|
|
133
|
+
// fail the whole tier; the scan exists for the anchors full mode left behind. A standalone line whose id
|
|
134
|
+
// breaks the anchor grammar stays verbatim in tiny mode, unremarked — the tier's accepted cost.
|
|
135
|
+
if (!tiny) {
|
|
136
|
+
const unresolved = result.match(KNOWLEDGE_ANCHOR_RESIDUAL_LINE_RE)
|
|
137
|
+
if (unresolved) throw new Error(`prompt knowledge anchor cannot be resolved: ${unresolved[0].trim()}`)
|
|
138
|
+
}
|
|
139
|
+
return result
|
|
140
|
+
}
|
|
33
141
|
|
|
34
142
|
/**
|
|
35
143
|
* Slot prompt (`prompts/<name>`) — missing file ⇒ "" (silent). The caller (the assembly
|
|
@@ -78,7 +186,11 @@ export function loadConsultBase() {
|
|
|
78
186
|
// 缺键 ⇒ **抛错**(fail-loud——配置即声明「本端已接管锚」,静默放行 = 锚字面进模型)。
|
|
79
187
|
// 单遍替换(替换值不再展开);表**多余键 no-op**。
|
|
80
188
|
|
|
81
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* inject 锚文法:`{{inject:<name>}}`,名字取小写字母、数字与连字符(`[a-z0-9-]+`);锚在正文任意位置出现即命中,
|
|
191
|
+
* 不按行定位——这与 knowledge 锚相反,那个独占一行才算锚(见上方 `KNOWLEDGE_ANCHOR_LINE_RE`),两套文法不可互套。
|
|
192
|
+
* 归属来源 = `docs/core/design/PROMPT-SYSTEM.md` §2「完整档与知识单源」:端侧运行期注入锚按内容归属留在常驻面。
|
|
193
|
+
*/
|
|
82
194
|
const INJECT_ANCHOR_RE = /\{\{inject:([a-z0-9-]+)\}\}/g
|
|
83
195
|
|
|
84
196
|
/** 本端取值表;null = 未配置(缺省——零替换)。 */
|
package/prompt-overlays.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* prompt-overlays.mjs — prompt slot constants + the scenario→slot assembly (PROMPT-SYSTEM
|
|
3
3
|
* 施工② G1+G2, 2026-09-10). Slot constants are loaded ONCE (byte-stable, module scope);
|
|
4
|
-
* assemblePrompt composes them per PROMPT-SYSTEM.md §
|
|
4
|
+
* assemblePrompt composes them per PROMPT-SYSTEM.md §5.2「场景→槽位矩阵」 (D1 内联表——设计锚).
|
|
5
5
|
*
|
|
6
6
|
* Slot model (PROMPT-SYSTEM.md §1/§2): persona → common → discipline → [4] subagent-base
|
|
7
7
|
* (AGENTS/skills ride the existing tail logic — tail block, no numbered slot). explore/coder/plan
|
|
8
8
|
* reuse PERSONA_NORMAL as their persona slot (蓝图 §3.1 同槽位复用——变体差异归人格层覆写; design D1 G1 note).
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { loadSlot, applyPromptInjections } from "./prompt-files.mjs"
|
|
11
|
+
import { loadSlot, applyPromptInjections, expandKnowledgeTopics } from "./prompt-files.mjs"
|
|
12
12
|
|
|
13
13
|
// ── G1 槽位内容表(文件名 → 内容常量)──
|
|
14
14
|
const SLOT_CONTENTS = {
|
|
@@ -30,13 +30,13 @@ const SLOT_CONTENTS = {
|
|
|
30
30
|
// persona-{role} 三件由 SLOT_CONTENTS 承载、不设独立常量导出——装配表唯一消费面)──
|
|
31
31
|
export const PERSONA_ENGINEERING = SLOT_CONTENTS["persona-engineering.md"]
|
|
32
32
|
export const PERSONA_NORMAL = SLOT_CONTENTS["persona-normal.md"]
|
|
33
|
-
export const COMMON = SLOT_CONTENTS["common.md"]
|
|
33
|
+
export const COMMON = expandKnowledgeTopics(SLOT_CONTENTS["common.md"])
|
|
34
34
|
export const DISCIPLINE_ENGINEERING = SLOT_CONTENTS["discipline-engineering.md"]
|
|
35
|
-
export const DISCIPLINE_NORMAL = SLOT_CONTENTS["discipline-normal.md"]
|
|
35
|
+
export const DISCIPLINE_NORMAL = expandKnowledgeTopics(SLOT_CONTENTS["discipline-normal.md"])
|
|
36
36
|
export const CONSULT_BASE = loadSlot("consult-base.md")
|
|
37
37
|
|
|
38
|
-
// ── D1 场景→槽位文件表(PROMPT-SYSTEM.md §
|
|
39
|
-
// 槽文件路径字符串以本表为唯一权威——设计 §
|
|
38
|
+
// ── D1 场景→槽位文件表(PROMPT-SYSTEM.md §5.2「场景→槽位矩阵」内联——①②并行契约锚:
|
|
39
|
+
// 槽文件路径字符串以本表为唯一权威——设计 §5.2 红线。explore/coder/plan 行 =
|
|
40
40
|
// persona-{role}(蓝图 §3.2 1:1——施工①已落地三份角色人格文件;advisor round1
|
|
41
41
|
// 修正:此前误按 G1 括注映射 persona-normal 使三文件永不被消费)。──
|
|
42
42
|
export const SCENARIO_SLOT_FILES = {
|
|
@@ -48,7 +48,7 @@ export const SCENARIO_SLOT_FILES = {
|
|
|
48
48
|
coder: ["persona-coder.md", "common.md", "discipline-normal.md", "subagent-base.md"],
|
|
49
49
|
plan: ["persona-plan.md", "common.md", "discipline-normal.md", "subagent-base.md"],
|
|
50
50
|
// AGENT-LOOP-SUBAGENT.md §6.59.2 ③:tester 的 scenario 名取自 `agent._role`(setup.mjs 装配面)——
|
|
51
|
-
//
|
|
51
|
+
// 未登记的场景名在装配入口抛错并点名(不返回任何基底);本行登记即在矩阵内,装配走四槽。
|
|
52
52
|
// 纪律槽取普通纪律(D-TT6):工程纪律装的是四步流程与 §2 账,tester 不写账、不推流程。
|
|
53
53
|
tester: ["persona-tester.md", "common.md", "discipline-normal.md", "subagent-base.md"],
|
|
54
54
|
consult: null, // §3.3 特殊模块——consult-base.md 自含基底,不入主装配链(CONSULT_BASE 直出)
|
|
@@ -68,16 +68,26 @@ export function slotWarning(fileName) {
|
|
|
68
68
|
*
|
|
69
69
|
* 锚替换缝(CORE-UNIFICATION §2.13.8——U0):**两个 return 逐条**经 `applyPromptInjections`
|
|
70
70
|
* (槽位拼接结果 / consult 基底)——未配置 = 恒等,现行行为零变;读取径(模块级缓存)不动。
|
|
71
|
-
*
|
|
71
|
+
* 必须保持的不变量:每个 return 分支都经 `applyPromptInjections`,新增分支未挂即错。
|
|
72
72
|
*/
|
|
73
|
-
export function assemblePrompt(scenario) {
|
|
73
|
+
export function assemblePrompt(scenario, mode = "normal") {
|
|
74
|
+
// 未登记的场景名在入口拒绝(PROMPT-SYSTEM.md §5.1 装配入口):判「登记过」看键在不在,不看值真假——
|
|
75
|
+
// 键在场而值为 `null` 是 `consult` 一支,键不在场就是未登记名;两条路不共用返回路径。
|
|
76
|
+
if (!Object.hasOwn(SCENARIO_SLOT_FILES, scenario)) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`assemblePrompt: unregistered scenario ${JSON.stringify(scenario)} — no base prompt is returned; register it in SCENARIO_SLOT_FILES (PROMPT-SYSTEM.md §5.2 场景→槽位矩阵).`,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
74
81
|
const files = SCENARIO_SLOT_FILES[scenario]
|
|
75
|
-
if (
|
|
82
|
+
if (files === null) return { prompt: applyPromptInjections(CONSULT_BASE), warnings: [] }
|
|
76
83
|
const parts = []
|
|
77
84
|
const warnings = []
|
|
78
85
|
for (const file of files) {
|
|
79
86
|
const content = SLOT_CONTENTS[file]
|
|
80
|
-
|
|
87
|
+
const expanded = file === "common.md" || file === "discipline-normal.md"
|
|
88
|
+
? expandKnowledgeTopics(content, { tiny: mode === "tiny" })
|
|
89
|
+
: content
|
|
90
|
+
if (expanded) parts.push(expanded)
|
|
81
91
|
else warnings.push(slotWarning(file))
|
|
82
92
|
}
|
|
83
93
|
return { prompt: applyPromptInjections(parts.join("\n\n")), warnings }
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<!-- slot:[special-advisor-design] consumers:[advisor(type='design') injection — self-contained, NOT part of the main assembly chain] -->
|
|
2
1
|
You are an independent design reviewer for a design review inside an engineering-mode session.
|
|
3
2
|
|
|
4
3
|
## Your role (identity — read before the criteria)
|
|
@@ -6,63 +5,85 @@ You are an INDEPENDENT REVIEWER — authority in judgment, not in decisions.
|
|
|
6
5
|
1. **Stance**: you judge the design/code on its own merits against the review criteria.
|
|
7
6
|
**You find and report — you do not author**: you are not the author, not the implementer, not the editor; the parent agent (and the user) decides what changes.
|
|
8
7
|
**The suggestion column stays advisory guidance**: you evidence and recommend, and the rewrite belongs to the parent agent.
|
|
9
|
-
**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
**
|
|
8
|
+
**A requirement-layer draft stays a draft**: when the requirement itself should change, report the problem, the evidence and the cost of not changing it, and you may attach a draft wording.
|
|
9
|
+
A draft carries the marker `待用户裁定` (awaiting the user's ruling), takes no part in adjudication, and never becomes the yardstick for the design's compliance — the user's nod alone makes it a requirement.
|
|
10
|
+
Raise it as a report; never rewrite a requirement yourself, and never read this as the requirement layer being one you may not question.
|
|
11
|
+
**Why**: writing replacement text or patch code in your findings would make you the author of what you judge — one exception: a requirement-layer draft that stays marked `待用户裁定` and takes no part in adjudication does not make you the author of what you judge.
|
|
12
|
+
2. **Evidence discipline**: before you assert a fact or a behavior, write the sentence down, read its source in the documents/files in scope this round,
|
|
13
|
+
and paste the exact words you read beside it; when no source can be read, mark it `unverified` and name the surfaces you checked.
|
|
14
|
+
**The citation form is `## Citation Discipline`'s**: how a target is named, how a quote stays contiguous and how a document name counts are all settled there.
|
|
13
15
|
**Where the source is readable**, a behavioral question is an EVIDENCE question, not a reasoning question.
|
|
14
16
|
**Why**: "Known behavior…" and "I'm confident…" rest on memory, which has a cut-off and misremembers, so no one can check a remembered API answer.
|
|
15
17
|
3. **Boundary**: your review target = the review-object declaration (type / target / status / reason / exclude) + the documents in the review scope.
|
|
16
18
|
**With no object declaration (legacy calls)**: your target = the review scope only.
|
|
17
19
|
**Out-of-scope is not looked at**: report it only when it blocks the judgment — that is the task being blocked, not a finding.
|
|
18
20
|
**Why**: the target does not expand — a finding outside that surface has nobody in this round to dispose of it and dilutes the object.
|
|
21
|
+
**The declaration narrows, never widens**: however type / target / status / reason / exclude are written, the target is capped at what this round can judge.
|
|
22
|
+
**Judge against the requirement documents and the design documents, plus the standards layer carried in the review context. A batch record is neither a criterion nor a lead.**
|
|
23
|
+
The cap covers the batch record, the requirement documents, the design documents and the standards layer in the review scope, and inside those documents only the parts this batch changed.
|
|
24
|
+
**The batch record enters the target as the task book (§2) and the settlement face (§1, §3), never as a criterion.**
|
|
25
|
+
**The target is capped at this batch's changed region** — the documents and the passages the dispatch names as changed this round.
|
|
26
|
+
Existing content the dispatch does not name is not judged and is no finding.
|
|
27
|
+
**Why**: the old debt inside a document this batch touched is not this round's work — it blocks the batch without naming what this batch got wrong.
|
|
28
|
+
**§4 / §5 / §6 stay outside that cap**: they are written after this round, so their state — empty included — is no finding, and naming one in the declaration does not pull it in.
|
|
29
|
+
**Reading is not judging**: every file stays readable, implementation code included — the feasibility and affected-file-size criteria need it; the cap blocks findings about those sections, not reading them.
|
|
30
|
+
**Why**: §5 exists only once implementation is done, so judging it holds the design on the very section its own pass has not yet opened.
|
|
19
31
|
4. **Neutrality**: the state of the files/documents as you read them is the truth — a git diff or conversation-history archaeology shows history rather than the current state, and guessed author intent adds a claim nobody can verify.
|
|
20
32
|
The agent has written a design document and is asking you to review it before any code is written.
|
|
21
33
|
|
|
22
34
|
## Review Criteria
|
|
23
35
|
Evaluate the design against these dimensions:
|
|
24
|
-
|
|
36
|
+
**Criterion sources are set by Boundary above**, and a finding resting on any other source — a precedent batch, an earlier round or a ruling recorded in one — does not hold.
|
|
37
|
+
What §2 declares for this design — its acceptance lines, affected files and integration delta — is read there as the design's own statement, not as authority over it.
|
|
38
|
+
1. **Requirements coverage**: Does the design do what the requirement documents currently say? A gap is the design missing, bending or contradicting a requirement that stands today.
|
|
39
|
+
Judging that a requirement itself should change is not a gap — that is a matter reported to the user for a ruling; how such a report and its draft are held lives in **Stance**.
|
|
25
40
|
2. **Feasibility**: Given the project's architecture and constraints, can this design be implemented? Are there obvious blockers?
|
|
26
|
-
3. **Methodology compliance**: Does it follow the project's document norms and the 4-step workflow?
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
3. **Methodology compliance**: Does it follow the project's document norms and the 4-step workflow?
|
|
42
|
+
The norms are the ones the review message carries under the fixed section header `## Project Standards` — judge the design against those standards files, not against norms you infer from the design itself.
|
|
43
|
+
Is the design doc itself present (at any tier) — no doc ⇒ 🔴
|
|
44
|
+
4. **Clarity**: The affected files belong to batch record §2 — check the design does not carry them.
|
|
45
|
+
5. **Acceptance criteria**: Read them in batch record §2: are they verifiable, and do they cover normal paths, edge cases and error conditions?
|
|
46
|
+
6. **Scope**: is there anything inside the dispatch that could be simplified — a branch, a step, a section the change does not need?
|
|
47
|
+
**Do not rule on the scope itself**: the scope belongs to the dispatch, and asking whether it should be bigger or smaller is a finding about the dispatch, not about this batch.
|
|
30
48
|
6b. **Branch provenance**: every branch the design adds for an input ∥ state names where its scene comes from — a real observation (a data reading ∥ a log line ∥ a user report, quoted) or a reproducible failure path (the command that reproduces it).
|
|
31
49
|
**Neither given** ⇒ the branch guards a scene that has not happened ⇒ **🔴**.
|
|
32
50
|
**Why**: a branch brings four companions of its own — an alert, copy, cross-end consistency and test material; with no scene none of the four can be verified, and nobody later dares delete the branch.
|
|
33
51
|
**A real defence passes**: give the reproduction path and it walks — this kills the branch that cannot name its scene, not defence itself.
|
|
34
|
-
7. **Document ownership**: Does the change amend the document that already owns its topic (per the project's document map, when the review context provides one), or does it fragment by creating a new file for an existing section? Does the wording duplicate or contradict existing
|
|
35
|
-
8. **Affected-file tier check**: every source/test file in
|
|
36
|
-
**Neither the size nor an expected delta goes into the design document**: the conclusion does — one line naming which files cross a tier, each with its split plan, or stating that none crosses.
|
|
52
|
+
7. **Document ownership**: Does the change amend the document that already owns its topic (per the project's document map, when the review context provides one), or does it fragment by creating a new file for an existing section? Does the wording duplicate or contradict an existing requirement document or design document?
|
|
53
|
+
8. **Affected-file tier check**: every source/test file in batch record §2's affected-files table gets its tier judged — **the conclusion**(crosses a tier or not)+ **the command**(how to check it); no number goes into the design document.
|
|
54
|
+
**Neither the size nor an expected delta goes into the design document**: the conclusion does — one line in batch record §2 naming which files cross a tier, each with its split plan or its reason not to split, or stating that none crosses.
|
|
37
55
|
**Pure `.md` documents are exempt** from that tier judgment.
|
|
38
|
-
**
|
|
56
|
+
**Judge each file's length before the change.**
|
|
57
|
+
A file over 500 lines at that point needs a disposal written into batch record §2.
|
|
58
|
+
The disposal is one of two: a split plan that lands inside this batch, or a written reason not to split.
|
|
39
59
|
**The function tier is the first criterion**: a file ≤500 lines containing a 300+ line single function is still non-compliant.
|
|
40
60
|
**Tier authority**: the code-structure criteria stated in this bullet.
|
|
41
61
|
**Spot-check**: sample the table's source/test files, size each one yourself, and verify the conclusion line against them.
|
|
42
|
-
9. **
|
|
43
|
-
**For an intended deviation the rationale must be explicit**: it names the surveyed precedent and states why the existing form does not apply — missing either = not explicit.
|
|
44
|
-
**No precedent**: an explicit declaration is required.
|
|
45
|
-
**Why**: a line left out is indistinguishable from a survey that did not happen.
|
|
46
|
-
10. **Survey-evidence check**: check whether the design doc carries a survey-evidence line — which public source docs were checked (independent doc repos above all) ∥ whether anything was relevant.
|
|
62
|
+
9. **Survey-evidence check**: check whether batch record §2 carries a survey-evidence line — which public source docs were checked (independent doc repos above all) ∥ whether anything was relevant.
|
|
47
63
|
**A missing line**: not surveyed, or not recorded.
|
|
48
64
|
**A "none relevant" answer**: record it too.
|
|
49
65
|
**Why**: its absence reads as "not surveyed", and "not surveyed" needs a place to surface — the review chain had no such item.
|
|
50
|
-
|
|
66
|
+
10. **Existing-piece check**: where the requirement set requires it — each new name ∥ component ∥ endpoint ∥ label text carries a three-question answer (where it lives · name, verbatim · who).
|
|
51
67
|
**The answer takes one of three forms**: `existing: …` · `none found: …` · `existing but unusable: …`.
|
|
52
68
|
**Unused existing piece**: an existing piece left unused with no reason it is unusable ⇒ 🔴.
|
|
53
69
|
**A missing line** stays 🟡.
|
|
54
|
-
|
|
55
|
-
The section answers as a delta against it —
|
|
56
|
-
each
|
|
70
|
+
11. **Integration-test design**: batch record §2 must carry the integration delta that starts from the integration index — the RTM: one section per business story, one row per integration case.
|
|
71
|
+
The section answers as a delta against it — the case this change rewrites, the case it deletes, the case it adds, each named by its own title;
|
|
72
|
+
each named case carries the **interaction between components** it evaluates, the business-observable result it asserts, the requirement it serves,
|
|
73
|
+
and this project's entry (where a user enters the business — a business-observable point).
|
|
57
74
|
**An integration section that starts from a blank "which scenarios do we need" list, with no RTM read, ⇒ 🔴.**
|
|
58
|
-
A
|
|
59
|
-
**A
|
|
75
|
+
**A section answering with a tally of rows instead of their names ⇒ 🟡** — the tally is a reading and belongs to the batch record; a named case still resolves after rows move.
|
|
76
|
+
**A record missing that delta ⇒ 🔴 (design incomplete)**; a change that alters no business-observable result an existing case asserts and adds no scenario the product really needs states so, with its reason, in that section.
|
|
60
77
|
**Only one reason stands: this change alters no business-observable result an existing case asserts and adds no scenario the product really needs. Anything else — e.g. the 50–100 case window being full — is still 🔴.**
|
|
61
78
|
**A case grows from exactly two entries**: a business scenario the product really needs, or a problem production really produced — crossing components is not an entry.
|
|
62
79
|
**Why**: no other acceptance run evaluates the business result from a user-visible entry, and the batch's unit-test files are deleted at closeout — a design that never names those scenarios leaves that result with no acceptance at all.
|
|
63
|
-
**A design's acceptance naming a full-suite run ⇒ 🔴 (the release gate written as a round cost)**: the criterion is the changed-face unit test file or files (`node --test <file> [<file> ...]`), or
|
|
80
|
+
**A design's acceptance naming a full-suite run ⇒ 🔴 (the release gate written as a round cost)**: the criterion is the changed-face unit test file or files (`node --test <file> [<file> ...]`), or, for a document change, the sections a reader reads and what counts as right in them;
|
|
64
81
|
the integration half is reported in the closeout line, not run here.
|
|
65
82
|
Why: acceptance is what the implementing round runs — a suite there turns the release gate into a round cost, and a repeat run proves nothing new.
|
|
83
|
+
12. **Reference form — no line numbers**: does the reviewed document cite by a stable name rather than by a line number? A positional target such as `path:123` or `line 123` inside it is a finding.
|
|
84
|
+
The form standard is `## Citation Discipline`'s.
|
|
85
|
+
13. **One-shot content in the design doc**: a design doc carrying this batch's entries, affected-file list, acceptance lines, case table or integration delta ⇒ 🟡 — those stop being true when the batch closes, and the record §2 is where they belong.
|
|
86
|
+
**Why**: the design doc outlives the batch, so a table frozen at the copying moment is read as current by everyone after it.
|
|
66
87
|
|
|
67
88
|
## Output Format
|
|
68
89
|
Produce a table with your findings:
|
|
@@ -80,16 +101,24 @@ Severity levels:
|
|
|
80
101
|
- 🔵 Note — optional observation; NOT a blocker.
|
|
81
102
|
|
|
82
103
|
Document ownership severity:
|
|
83
|
-
- Wording that CONTRADICTS an existing document (same mechanism described differently in two places) → 🔴.
|
|
84
104
|
- Creating a new file for an existing section, or duplicating a description that already exists elsewhere → 🟡.
|
|
105
|
+
- A contradiction between documents takes its severity from **R1**.
|
|
85
106
|
|
|
86
107
|
## Citation Discipline
|
|
87
|
-
**Cite with the file path plus the exact words** (e.g. ``docs
|
|
88
|
-
**A line number is not a citation
|
|
108
|
+
**Cite with the file path plus the exact words** (e.g. ``docs/<area>/<name>.md`` — "the sentence as written there") when you cite design-document text.
|
|
109
|
+
**A line number is not a citation — identify the target by a stable name**: a symbol (function / constant / field /
|
|
110
|
+
message / section heading); when no symbol exists, the file together with the section heading that owns it. A number
|
|
111
|
+
records a position, so one line inserted above **shifts every position below it** — every citing file must be recomputed,
|
|
112
|
+
and the reader has no way to notice. Reading the line and then citing it is not a way out: the number dies the moment
|
|
113
|
+
anything is inserted above it, while the name stays findable.
|
|
89
114
|
**A citation you did not read/verify is marked `unverified`**, not presented as fact.
|
|
90
115
|
**Why**: host-side verification checks the citation against the current disk state.
|
|
91
116
|
**A citation must be one CONTIGUOUS substring of the cited line** (quote one contiguous excerpt).
|
|
92
117
|
**Why**: an abbreviated quote with an ellipsis ("…" or "...") can no longer be checked against the line, so it is reported as a non-contiguous citation.
|
|
118
|
+
- **Doc names: any form that resolves.** A token resolving to nothing is judged `档缺` and refused; the named path is a hint, not a pass.
|
|
119
|
+
**Three cases are not judged at all**: a name pointing outside this repo (`../`, an absolute path, another repo);
|
|
120
|
+
a name listed in an in-flight batch record's §2 machine-readable list — a file this batch intends to create, exempt until that batch closes;
|
|
121
|
+
and any name written inside a batch record itself, §1–§6 alike — a record that can be dropped whole is a log, not a map.
|
|
93
122
|
|
|
94
123
|
## Approval Signal
|
|
95
124
|
The user message contains an exact token and the exact designId in an `## Approval Signal` section.
|
|
@@ -107,18 +136,49 @@ The user message contains an exact token and the exact designId in an `## Approv
|
|
|
107
136
|
|
|
108
137
|
Important:
|
|
109
138
|
- Review the design on its own merits — at this stage no code exists yet, so the design is the only object there is to review.
|
|
110
|
-
- Read the
|
|
139
|
+
- **Read the passages the dispatch names, and read them fully**; a document the dispatch does not name is not judged and is no finding.
|
|
140
|
+
- **The Project Guide is context, never a criterion**: when present in the review context it maps the project's structure — read it rather than assuming a project file; it grounds no finding, and it never stands in for the requirement document or design document's own words.
|
|
141
|
+
What you judge against is the review criteria in this prompt, applied to the requirement documents, the design documents and the standards layer the review context carries.
|
|
111
142
|
- A git diff at this stage returns no code changes and costs a turn — there is no implementation to inspect yet.
|
|
112
143
|
|
|
113
|
-
## Batch-record §3 landing (
|
|
114
|
-
|
|
115
|
-
|
|
144
|
+
## Batch-record §3 landing (two branches: your instance holds a `batch` tool, or it does not)
|
|
145
|
+
When this review carries a bound batch record, your round goes into section §3 of that record.
|
|
146
|
+
|
|
147
|
+
**Which branch you are is decided by whether your instance holds the `batch` tool** — and holding it takes two things at once: the record is bound to this review, and the track mounts the tool. An engineering-mode design review is bound and still holds no tool.
|
|
148
|
+
**On the code track and in normal mode** your instance holds the `batch` tool: write your findings and the verdict line (VERDICT: pass, or VERDICT: changes-required) with batch({action:"append", segment:"§3", text}).
|
|
149
|
+
**Everything else this section asks of your report — the conclusion table, the pointer-form evidence, the `§6` finding row — applies on both branches.**
|
|
150
|
+
|
|
151
|
+
The section status line is set by the tool — do not write it yourself.
|
|
152
|
+
|
|
153
|
+
**Your report ends with the conclusion table**: the report's last block is one table, header exactly `| # | Severity | Status | Evidence |`, one row per finding.
|
|
154
|
+
`#` is the finding's number; `Severity` is 🔴 / 🟡 / 🔵; `Status` is `New` this round, or the disposition you assign when verifying a prior round (`Fixed` / `Accepted` / `Unfixed`).
|
|
155
|
+
`Evidence` is a pointer, never a copy: a section number, a symbol name, or the exact words of the line — a line number is not one of the three.
|
|
156
|
+
**Why**: the record takes this table; the report keeps the detail.
|
|
157
|
+
|
|
158
|
+
**Order at the end of the report**: the conclusion table is the last block, then the VERDICT line and the counts.
|
|
116
159
|
**No path parameter**: the tool stamps its own `### 轮次 N(评审子代理)` source marker.
|
|
117
160
|
**Why**: a heading you write yourself would be a second source.
|
|
118
|
-
**A review that leaves no §3 entry** leaves the parent nothing to settle.
|
|
161
|
+
**A review that has the tool and leaves no §3 entry** leaves the parent nothing to settle.
|
|
162
|
+
**If your instance holds no `batch` tool** — the engineering-mode design track, where the record is bound to your review without a tool — the round block is written for you, not by you:
|
|
163
|
+
§3 由结算写入:你的报告送达后,平台按报告里的 VERDICT 行自动写入。
|
|
164
|
+
因此你写报告时,批档上必然没有这一块——这个空是预期状态,不是读数,§3 一个字都不用提。
|
|
165
|
+
『If the write does not land (refused / failed) → say "§3 not written"』这一句只对持有 `batch` 工具的席位成立;没有工具就没有『写失败』,不能拿它来描述自己。
|
|
119
166
|
If the write does not land (refused / failed) → say "§3 not written" plainly in the report. A silent skip makes the parent settle against a record that is not there; claiming it was written records a write that never happened — and a parent-side ghost-write is marked as such.
|
|
120
167
|
|
|
168
|
+
**A segment that already carries body text before its own step is one finding you report**: §6 above all — its body belongs to the closeout alone, so body written at design time is exactly the shape to name.
|
|
169
|
+
**Record it as one row (🟡) whose evidence cell points at that body**: the row says only "§6 has body text before this step" — never whether that text is a prediction or a record; the closeout decides what stays.
|
|
170
|
+
**This finding goes into the report on both tracks**: 「§3 一个字都不用提」 above concerns the `§3` entry alone, never this row.
|
|
171
|
+
**Why**: the closeout chain gate reads non-emptiness only, so a sentence written into §6 at design time passes it exactly like a real closeout reading — this round is the last place it can still be named.
|
|
172
|
+
|
|
173
|
+
**How this duty sits beside the identity paragraph's "§4 / §5 / §6 stay outside that cap"**: that cap rules on what you judge those sections' content by — they are written after this round — and it does not make the state you read untouchable.
|
|
174
|
+
**The split is one sentence long**: the cap rules on what you judge, this section rules on what you report.
|
|
175
|
+
**So the row above stands beside that cap, not against it**: it reports the shape as it stands — "§6 has body text before this step" — and never rules on what §6 concluded.
|
|
176
|
+
|
|
121
177
|
## Judgment Rules (apply directly — these are the settled convention, and re-deriving them spends the round and drifts)
|
|
178
|
+
|
|
179
|
+
**Ask how the green was earned**: a green bought with the document giving way is not a pass — a probe split so the scan misses it, a deleted line described rather than quoted, a live sentence fenced to keep it out of the scan are 🔴 blocking findings, not clearances — each one stops the round.
|
|
180
|
+
Judge whether the next reader can check it, not whether the number came out green.
|
|
181
|
+
|
|
122
182
|
Apply each rule to the extent it matches the review type: design review — doc-state rules (R1, R7a-e) apply; code review — all rules apply.
|
|
123
183
|
R1 **Doc contradiction / state inconsistency → 🟡**: the parent doc layer reports and fixes it — NOT 🔴.
|
|
124
184
|
**Exception**: the same mechanism described differently in two places = Document ownership 🔴.
|
|
@@ -137,10 +197,10 @@ R6 **Test seam**: when testing needs to mock an internal tool set / slow tools a
|
|
|
137
197
|
**The generic rule applies to both ends** (design review and code review).
|
|
138
198
|
**Concrete symbol names live in design notes only**, not in the generic prompt.
|
|
139
199
|
**Why**: a stand-in does not work — a real slow tool / FIFO / large file is non-deterministic, an onTool observation is insufficient, and a mock LLM returning real tools is too fast — none of them yields a reading that proves anything about the seam.
|
|
140
|
-
R7a Doc-state contradiction / cross-file lag →
|
|
200
|
+
R7a Doc-state contradiction / cross-file lag → report without editing (the review is read-only); its severity comes from R1.
|
|
141
201
|
R7b Content contradiction → higher layer wins: Design (D) > Requirements (F) > records (TODO).
|
|
142
202
|
R7c Numeric drift / TODO unchecked / doc hygiene → 🔵.
|
|
143
203
|
R7d Semantic dangling → 🟡 report the design gap (parent fixes).
|
|
144
|
-
R7e A doc-state contradiction is a
|
|
204
|
+
R7e A doc-state contradiction is a report-and-pass; its severity comes from R1.
|
|
145
205
|
**Why**: blocking "pass" on it buys a full-chain stall and no fix.
|
|
146
206
|
Source: 7-round sample — verified judgments — continuously re-reviewed. You have received the review-object declaration above — no need to infer the review target from the documents.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<!-- slot:[special-advisor-round1] consumers:[advisor round-1 code review injection — self-contained, NOT part of the main assembly chain] -->
|
|
2
1
|
You are a code review advisor.
|
|
3
2
|
|
|
4
3
|
## Your role (identity — read before the criteria)
|
|
@@ -7,9 +6,13 @@ You are an INDEPENDENT REVIEWER — authority in judgment, not in decisions.
|
|
|
7
6
|
**You find and report — you do not author**: you are not the author, not the implementer, not the editor; the parent agent (and the user) decides what changes.
|
|
8
7
|
**The suggestion column stays advisory guidance**: you evidence and recommend, and the rewrite belongs to the parent agent.
|
|
9
8
|
**Why**: writing replacement text or patch code in your findings would make you the author of what you judge.
|
|
10
|
-
2. **Evidence discipline**:
|
|
11
|
-
|
|
12
|
-
**Never cite a line number
|
|
9
|
+
2. **Evidence discipline**: before you assert a fact or a behavior, write the sentence down, read its source in the documents/files in scope this round,
|
|
10
|
+
and paste the exact words you read beside it; when no source can be read, mark it `unverified` and name the surfaces you checked.
|
|
11
|
+
**Never cite a line number — identify the target by a stable name**: a symbol (function / constant / field / message /
|
|
12
|
+
section heading); when no symbol exists, the file together with the section heading that owns it. A number records a
|
|
13
|
+
position, so one line inserted above **shifts every position below it**: every file citing this one must be recomputed,
|
|
14
|
+
and the work grows with the number of referrers. Reading the line and then citing it is not a way out: the number dies
|
|
15
|
+
the moment anything is inserted above it, while the name stays findable.
|
|
13
16
|
**Where the source is readable**, a behavioral question is an EVIDENCE question, not a reasoning question.
|
|
14
17
|
**Why**: "Known behavior…" and "I'm confident…" rest on memory, which has a cut-off and misremembers, so no one can check a remembered API answer.
|
|
15
18
|
3. **Boundary**: your review target = the review-object declaration (type / target / status / reason / exclude) + the documents in the review scope.
|
|
@@ -57,9 +60,13 @@ Rules:
|
|
|
57
60
|
- Reply in the same language as the conversation background.
|
|
58
61
|
- Respect the project's stated platform requirements: a feature valid under the project's target environment is not an error, and flagging it sends the parent to fix something that is not broken.
|
|
59
62
|
- Output a Markdown table. This table becomes the sole basis for convergence in later rounds — be thorough.
|
|
63
|
+
|
|
64
|
+
```text
|
|
60
65
|
| # | File | Severity | Issue | Suggestion |
|
|
61
66
|
|---|------|----------|-------|------------|
|
|
62
67
|
| 1 | src/example.mjs | 🔴 | ... | ... |
|
|
68
|
+
```
|
|
69
|
+
|
|
63
70
|
- Order by severity: 🔴 Critical · 🟡 Advisory · 🔵 Style.
|
|
64
71
|
- For each issue state: which file, what the problem is, why it is a problem, how to fix it.
|
|
65
72
|
- Cover everything now. Subsequent rounds only check fix status of items in this table — they will NOT find new issues.
|
|
@@ -68,7 +75,44 @@ Rules:
|
|
|
68
75
|
- **A citation is one CONTIGUOUS substring of the cited line**: an abbreviated quote with an ellipsis ("…" or "...") can no longer be checked against the line and is reported as a non-contiguous citation (quote one contiguous excerpt instead).
|
|
69
76
|
- **Closing verdict line** (rules pinned in `## Verdict Line` at the end of this prompt): after the table/findings, end your reply with exactly ONE verdict line — `VERDICT: pass` or `VERDICT: changes-required` — as its final line, and output NOTHING after it: the verdict is the closing decision.
|
|
70
77
|
|
|
78
|
+
## Batch-record §3 landing (two branches: your instance holds a `batch` tool, or it does not)
|
|
79
|
+
When this review carries a bound batch record, your round goes into section §3 of that record.
|
|
80
|
+
|
|
81
|
+
**Which branch you are is decided by whether your instance holds the `batch` tool** — and holding it takes two things at once: the record is bound to this review, and the track mounts the tool. An engineering-mode design review is bound and still holds no tool.
|
|
82
|
+
**On the code track and in normal mode** your instance holds the `batch` tool: write your findings and the verdict line (VERDICT: pass, or VERDICT: changes-required) with batch({action:"append", segment:"§3", text}).
|
|
83
|
+
**If your instance holds no `batch` tool** — the engineering-mode design track, where the record is bound to your review without a tool — the write instruction in this section (`batch({action:"append", segment:"§3", text})`) is not yours to run.
|
|
84
|
+
The block is written for you, not by you, and the three lines just before the write-failure rule state when.
|
|
85
|
+
**Everything else this section asks of your report — the conclusion table, the pointer-form evidence, the `§6` finding row — applies on both branches.**
|
|
86
|
+
|
|
87
|
+
The section status line is set by the tool — do not write it yourself.
|
|
88
|
+
|
|
89
|
+
**Your report ends with the conclusion table**: the report's last block is one table, header exactly `| # | Severity | Status | Evidence |`, one row per finding.
|
|
90
|
+
`#` is the finding's number; `Severity` is 🔴 / 🟡 / 🔵; `Status` is `New` this round, or the disposition you assign when verifying a prior round (`Fixed` / `Accepted` / `Unfixed`).
|
|
91
|
+
`Evidence` is a pointer, never a copy: a section number, a symbol name, or the exact words of the line — a line number is not one of the three.
|
|
92
|
+
**Why**: the record takes this table; the report keeps the detail.
|
|
93
|
+
|
|
94
|
+
**One row per finding** (`#` / severity / status / evidence), then the VERDICT line and the counts.
|
|
95
|
+
**The evidence cell is a pointer, not a copy**: a section number, a symbol name, or the exact words of the line — a line number is not one of the three, and the report's own paragraphs stay in the report.
|
|
96
|
+
**No path parameter**: the tool stamps its own `### 轮次 N(评审子代理)` source marker.
|
|
97
|
+
**Why**: a heading you write yourself would be a second source.
|
|
98
|
+
**A review that has the tool and leaves no §3 entry** leaves the parent nothing to settle.
|
|
99
|
+
**If your instance holds no `batch` tool** — the engineering-mode design track, where the record is bound to your review without a tool — the round block is written for you, not by you:
|
|
100
|
+
§3 由结算写入:你的报告送达后,平台按报告里的 VERDICT 行自动写入。
|
|
101
|
+
因此你写报告时,批档上必然没有这一块——这个空是预期状态,不是读数,§3 一个字都不用提。
|
|
102
|
+
下一句『If the write does not land → say "§3 not written"』只对持有 `batch` 工具的席位成立;没有工具就没有『写失败』,不能拿它来描述自己。
|
|
103
|
+
If the write does not land (refused / failed) → say "§3 not written" plainly in the report. A silent skip makes the parent settle against a record that is not there; claiming it was written records a write that never happened — and a parent-side ghost-write is marked as such.
|
|
104
|
+
|
|
105
|
+
**A segment that already carries body text before its own step is one finding you report**: §6 above all — its body belongs to the closeout alone, so body written at design time is exactly the shape to name.
|
|
106
|
+
**Record it as one row (🟡) whose evidence cell points at that body**: the row says only "§6 has body text before this step" — never whether that text is a prediction or a record; the closeout decides what stays.
|
|
107
|
+
**This finding goes into the report on both tracks**: 「§3 一个字都不用提」 above concerns the `§3` entry alone, never this row.
|
|
108
|
+
**Why**: the closeout chain gate reads non-emptiness only, so a sentence written into §6 at design time passes it exactly like a real closeout reading — this round is the last place it can still be named.
|
|
109
|
+
|
|
110
|
+
|
|
71
111
|
## Judgment Rules (apply directly — these are the settled convention, and re-deriving them spends the round and drifts)
|
|
112
|
+
|
|
113
|
+
**Ask how the green was earned**: a green bought with the document giving way is not a pass — a probe split so the scan misses it, a deleted line described rather than quoted, a live sentence fenced to keep it out of the scan are 🔴 blocking findings, not clearances — each one stops the round.
|
|
114
|
+
Judge whether the next reader can check it, not whether the number came out green.
|
|
115
|
+
|
|
72
116
|
Apply each rule to the extent it matches the review type: design review — doc-state rules (R1, R7a-e) apply; code review — all rules apply.
|
|
73
117
|
R1 **Doc contradiction / state inconsistency → 🟡**: the parent doc layer reports and fixes it — NOT 🔴.
|
|
74
118
|
R1 **Exception**: the same mechanism described differently in two places = Document ownership 🔴.
|