projectkeeper 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/LICENSE +21 -0
- package/README.md +283 -2
- package/README.zh-CN.md +285 -0
- package/THIRD_PARTY_NOTICES.md +53 -0
- package/bin/pk.mjs +6 -0
- package/bin/postinstall.mjs +5 -0
- package/bin/strip-types.mjs +28 -0
- package/package.json +68 -4
- package/patches/README.md +111 -0
- package/patches/pi-ai-0.85.0.ts +122 -0
- package/patches/pi-ai-0.87.1.ts +122 -0
- package/scripts/apply-pi-streaming-patch.ts +86 -0
- package/skills/clerk/coverage/SKILL.md +35 -0
- package/skills/clerk/cross-check/SKILL.md +118 -0
- package/skills/clerk/deepen-dispatch/SKILL.md +69 -0
- package/skills/clerk/lane-follow-up/SKILL.md +94 -0
- package/skills/clerk/lane-plan/SKILL.md +107 -0
- package/skills/clerk/lane-slot/SKILL.md +113 -0
- package/skills/clerk/lane-topic/SKILL.md +116 -0
- package/skills/clerk/orientation/SKILL.md +160 -0
- package/skills/clerk/reconcile/SKILL.md +77 -0
- package/skills/clerk/skeleton-dispatch/SKILL.md +43 -0
- package/skills/clerk/spot-check/SKILL.md +52 -0
- package/skills/clerk/synthesis/SKILL.md +65 -0
- package/skills/table-follow-up/SKILL.md +42 -0
- package/src/cli.ts +319 -0
- package/src/codemap/README.md +13 -0
- package/src/codemap/engines.ts +102 -0
- package/src/codemap/facts.ts +504 -0
- package/src/context/agent-entry.ts +232 -0
- package/src/context/ask.ts +97 -0
- package/src/context/assemble.ts +1058 -0
- package/src/context/code-source.ts +103 -0
- package/src/context/k-briefs.ts +114 -0
- package/src/context/lineage.ts +100 -0
- package/src/context/object-brief.ts +300 -0
- package/src/context/owner-words.ts +191 -0
- package/src/context/pack-fixture.ts +342 -0
- package/src/context/project-rules.ts +160 -0
- package/src/intake/intake.ts +392 -0
- package/src/intake/material-rules.ts +166 -0
- package/src/intake/removal.ts +316 -0
- package/src/intake/skipped.ts +72 -0
- package/src/keeper/adjustment.ts +565 -0
- package/src/keeper/bounds/boundary.ts +509 -0
- package/src/keeper/bounds/command.ts +1665 -0
- package/src/keeper/bounds/paths.ts +164 -0
- package/src/keeper/bounds/reads.ts +718 -0
- package/src/keeper/bounds/shell-write-guard.ts +521 -0
- package/src/keeper/capabilities.ts +136 -0
- package/src/keeper/clerk-steps.ts +151 -0
- package/src/keeper/clerk-tools.ts +1424 -0
- package/src/keeper/conversation.ts +253 -0
- package/src/keeper/evidence.ts +662 -0
- package/src/keeper/fake-provider.ts +132 -0
- package/src/keeper/held.ts +15 -0
- package/src/keeper/history-tools.ts +163 -0
- package/src/keeper/jobs/answering.ts +53 -0
- package/src/keeper/key-check.ts +105 -0
- package/src/keeper/ledger-tools.ts +295 -0
- package/src/keeper/link-check.ts +185 -0
- package/src/keeper/merge.ts +260 -0
- package/src/keeper/note-origin.ts +56 -0
- package/src/keeper/numbers-check.ts +102 -0
- package/src/keeper/open-in-pi.ts +57 -0
- package/src/keeper/organize/absence.ts +266 -0
- package/src/keeper/organize/carried-on.ts +214 -0
- package/src/keeper/organize/clerk-coverage.ts +293 -0
- package/src/keeper/organize/clerk-prompts.ts +132 -0
- package/src/keeper/organize/clerk.ts +1395 -0
- package/src/keeper/organize/coverage-gate.ts +19 -0
- package/src/keeper/organize/coverage-tools.ts +765 -0
- package/src/keeper/organize/entries.ts +153 -0
- package/src/keeper/organize/entry-gate.ts +289 -0
- package/src/keeper/organize/fill-tools.ts +718 -0
- package/src/keeper/organize/follow-up.ts +280 -0
- package/src/keeper/organize/generation-check.ts +504 -0
- package/src/keeper/organize/graph.ts +230 -0
- package/src/keeper/organize/lane-tools.ts +289 -0
- package/src/keeper/organize/looked-tools.ts +54 -0
- package/src/keeper/organize/materials.ts +243 -0
- package/src/keeper/organize/owner-lines.ts +493 -0
- package/src/keeper/organize/place-tools.ts +216 -0
- package/src/keeper/organize/placement-inference.ts +1045 -0
- package/src/keeper/organize/placement-time.ts +320 -0
- package/src/keeper/organize/placing.ts +821 -0
- package/src/keeper/organize/positioning.ts +33 -0
- package/src/keeper/organize/readiness.ts +47 -0
- package/src/keeper/organize/reading.ts +401 -0
- package/src/keeper/organize/round-blocks.ts +65 -0
- package/src/keeper/organize/round-news.ts +164 -0
- package/src/keeper/organize/round-open.ts +586 -0
- package/src/keeper/organize/schedule-state.ts +39 -0
- package/src/keeper/organize/schedule.ts +137 -0
- package/src/keeper/organize/service.ts +409 -0
- package/src/keeper/organize/skills.ts +116 -0
- package/src/keeper/organize/slots.ts +85 -0
- package/src/keeper/organize/stage-gate.ts +175 -0
- package/src/keeper/organize/stage-tools.ts +471 -0
- package/src/keeper/organize/standing-notes.ts +141 -0
- package/src/keeper/organize/table-follow-up.ts +330 -0
- package/src/keeper/organize/takeover-clerk.ts +832 -0
- package/src/keeper/organize/takeover-state.ts +103 -0
- package/src/keeper/organize/takeover.ts +216 -0
- package/src/keeper/organize/update-pending.ts +535 -0
- package/src/keeper/organize/workbench-placement.ts +92 -0
- package/src/keeper/own-keys.ts +114 -0
- package/src/keeper/owner-text.ts +165 -0
- package/src/keeper/project-folder.ts +334 -0
- package/src/keeper/prompts.ts +101 -0
- package/src/keeper/references.ts +177 -0
- package/src/keeper/relook/compose.ts +120 -0
- package/src/keeper/relook/prompts.ts +36 -0
- package/src/keeper/roles.ts +259 -0
- package/src/keeper/round-tools.ts +227 -0
- package/src/keeper/route.ts +148 -0
- package/src/keeper/rules.ts +97 -0
- package/src/keeper/runtime.ts +1858 -0
- package/src/keeper/scope-tools.ts +194 -0
- package/src/keeper/sendback-text.ts +83 -0
- package/src/keeper/step-timing.ts +207 -0
- package/src/keeper/testing/clerk-script.ts +212 -0
- package/src/keeper/testing/streaming-arguments.ts +57 -0
- package/src/keeper/tools.ts +2340 -0
- package/src/keeper/utterance-tools.ts +64 -0
- package/src/keeper/verbatim.ts +397 -0
- package/src/ledger/adapters.ts +186 -0
- package/src/ledger/arrangements.ts +257 -0
- package/src/ledger/blame.ts +58 -0
- package/src/ledger/code-engine-child.ts +69 -0
- package/src/ledger/code-engine.ts +548 -0
- package/src/ledger/code.ts +607 -0
- package/src/ledger/docs.ts +294 -0
- package/src/ledger/git-read.ts +321 -0
- package/src/ledger/index.ts +1850 -0
- package/src/ledger/item-range.ts +16 -0
- package/src/ledger/lines.ts +328 -0
- package/src/ledger/numbering.ts +269 -0
- package/src/ledger/ranges.ts +74 -0
- package/src/ledger/rebuild-worker.ts +15 -0
- package/src/ledger/rebuild.ts +387 -0
- package/src/ledger/repo-scan.ts +181 -0
- package/src/ledger/schema.ts +450 -0
- package/src/ledger/sessions.ts +134 -0
- package/src/ledger/text-scan.ts +466 -0
- package/src/ledger/time.ts +185 -0
- package/src/ledger/ts-symbols.ts +180 -0
- package/src/ledger/views.ts +377 -0
- package/src/mcp/server.ts +127 -0
- package/src/mcp/tools.ts +187 -0
- package/src/model/ids.ts +23 -0
- package/src/model/k-types.ts +912 -0
- package/src/model/time.ts +85 -0
- package/src/model/types.ts +1382 -0
- package/src/model/views-k.ts +707 -0
- package/src/model/vocab.ts +269 -0
- package/src/process/analysis.ts +79 -0
- package/src/process/breakpoint-candidates.ts +383 -0
- package/src/process/breakpoints.ts +746 -0
- package/src/process/claim-check.ts +295 -0
- package/src/process/delivery-links.ts +52 -0
- package/src/process/facts.ts +487 -0
- package/src/process/generations.ts +138 -0
- package/src/process/index.ts +243 -0
- package/src/process/integration.ts +128 -0
- package/src/process/placement.ts +107 -0
- package/src/process/plan.ts +276 -0
- package/src/process/sendbacks.ts +244 -0
- package/src/process/text.ts +185 -0
- package/src/process/units.ts +543 -0
- package/src/process/unnumbered.ts +431 -0
- package/src/process/work.ts +884 -0
- package/src/scope/candidates.ts +86 -0
- package/src/scope/decisions.ts +229 -0
- package/src/scope/discover.ts +741 -0
- package/src/scope/ignore.ts +126 -0
- package/src/scope/ignored-place.ts +93 -0
- package/src/scope/skip.ts +161 -0
- package/src/scope/toolchain.ts +180 -0
- package/src/scope/worktree.ts +187 -0
- package/src/server/api.ts +549 -0
- package/src/server/app.ts +595 -0
- package/src/server/drafts-api.ts +170 -0
- package/src/server/folders-api.ts +243 -0
- package/src/server/graph-view.ts +639 -0
- package/src/server/http.ts +224 -0
- package/src/server/k-agent-api.ts +56 -0
- package/src/server/k-rounds-d99.ts +91 -0
- package/src/server/k-views.ts +405 -0
- package/src/server/keeper-page.ts +446 -0
- package/src/server/keys-api.ts +239 -0
- package/src/server/project-folder-api.ts +104 -0
- package/src/server/vendor.ts +14 -0
- package/src/server/workbench-content.ts +561 -0
- package/src/sources/anchor.ts +129 -0
- package/src/sources/files.ts +267 -0
- package/src/sources/gitobs.ts +41 -0
- package/src/sources/history.ts +231 -0
- package/src/sources/scan-worker.ts +10 -0
- package/src/sources/sessions/locate.ts +292 -0
- package/src/sources/sessions/read.ts +346 -0
- package/src/sources/sessions/scope.ts +42 -0
- package/src/sources/sessions/utterances.ts +223 -0
- package/src/sources/watch.ts +215 -0
- package/src/store/json-file.ts +50 -0
- package/src/store/paths.ts +39 -0
- package/src/store/project-store.ts +295 -0
- package/src/store/versions.ts +172 -0
- package/src/store/workspace.ts +216 -0
- package/src/table/check.ts +333 -0
- package/src/table/follow-up-tools.ts +30 -0
- package/src/table/follow-up.ts +344 -0
- package/src/table/import.ts +610 -0
- package/src/table/project-home.ts +61 -0
- package/src/table/sessions.ts +168 -0
- package/src/table/takeover.ts +483 -0
- package/src/util/git-check.ts +29 -0
- package/src/util/git.ts +411 -0
- package/src/util/own-ts.ts +15 -0
- package/src/util/paths.ts +225 -0
- package/template/FILLING-IN.md +148 -0
- package/template/examples/papertrail.json +747 -0
- package/template/projectkeeper.schema.json +1001 -0
- package/ui/app.js +1135 -0
- package/ui/failures.js +82 -0
- package/ui/flyout.js +120 -0
- package/ui/folder-chooser.js +264 -0
- package/ui/glossary.js +156 -0
- package/ui/graph-fit.js +157 -0
- package/ui/graph-material.js +61 -0
- package/ui/graph-palette.js +109 -0
- package/ui/graph-tools.js +62 -0
- package/ui/graph.js +1712 -0
- package/ui/index.html +31 -0
- package/ui/k/code-view.js +230 -0
- package/ui/k/draft-view.js +93 -0
- package/ui/k/k-views.css +224 -0
- package/ui/k/round-tree.js +450 -0
- package/ui/k/scope-k.js +159 -0
- package/ui/k-data.js +118 -0
- package/ui/k-fold.js +106 -0
- package/ui/k-process.css +302 -0
- package/ui/k-process.js +934 -0
- package/ui/keeper-activity.js +175 -0
- package/ui/keeper-view.js +801 -0
- package/ui/keeper.css +101 -0
- package/ui/key-order.js +62 -0
- package/ui/list-fold.js +67 -0
- package/ui/markdown.d.ts +21 -0
- package/ui/markdown.js +472 -0
- package/ui/placement.d.ts +92 -0
- package/ui/placement.js +445 -0
- package/ui/popover-place.d.ts +16 -0
- package/ui/popover-place.js +89 -0
- package/ui/popover.js +198 -0
- package/ui/project-folder.js +37 -0
- package/ui/shell-state.js +40 -0
- package/ui/strip-rows.js +171 -0
- package/ui/styles.css +492 -0
- package/ui/theme-pick.js +36 -0
- package/ui/theme.js +74 -0
- package/ui/themes/LICENSE.md +13 -0
- package/ui/themes/README.md +44 -0
- package/ui/themes/TOKENS.md +291 -0
- package/ui/themes/a1/board.css +1557 -0
- package/ui/themes/a1/pk.css +392 -0
- package/ui/themes/b1/board.css +1163 -0
- package/ui/themes/b1/pk.css +218 -0
- package/ui/themes/d2/board.css +518 -0
- package/ui/themes/d2/pk.css +243 -0
- package/ui/themes/guard.css +73 -0
- package/ui/themes/i1/board.css +776 -0
- package/ui/themes/i1/pk.css +223 -0
- package/ui/themes/manifest.json +13 -0
- package/ui/views.js +2796 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Keeper agent's capability table (Spec §8.1, §8.3; CKC-03 AC-1, AC-14, AC-25–AC-31), shown in `Keeper` → `Keeper
|
|
3
|
+
* agent`. It says what the program on this build does, not what is planned: each row names what provides it — pi as it
|
|
4
|
+
* comes, a ProjectKeeper tool, the ledger, the TypeScript language service, or ProjectKeeper's own adapter around pi — and a
|
|
5
|
+
* row that is not available says which steps that affects. Nothing here is claimed that pi does not have: what
|
|
6
|
+
* ProjectKeeper adds says so in `provider` and `source`, and `native` says what `Open in pi` (the pi installed on the
|
|
7
|
+
* machine, without ProjectKeeper's tools or patch) has of it.
|
|
8
|
+
*/
|
|
9
|
+
import { LEFT_NOTE } from './bounds/shell-write-guard.ts';
|
|
10
|
+
|
|
11
|
+
export type CapabilityProvider = 'pi built-in' | 'ProjectKeeper tool' | 'The ledger' | 'TypeScript language service' | 'ProjectKeeper adapter' | 'Not provided';
|
|
12
|
+
|
|
13
|
+
export interface Capability {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/** Where it is used in the workbench, and by which steps. */
|
|
16
|
+
readonly workbench: string;
|
|
17
|
+
/** What native pi (`Open in pi`) has of it. */
|
|
18
|
+
readonly native: string;
|
|
19
|
+
readonly available: boolean;
|
|
20
|
+
/** What provides it, in one of the fixed words (CKC-03 AC-31). */
|
|
21
|
+
readonly provider: CapabilityProvider;
|
|
22
|
+
/** How it is provided, in a sentence; the table shows it after the name. */
|
|
23
|
+
readonly source: string;
|
|
24
|
+
/** For a row that is not available: which steps that affects, and how. */
|
|
25
|
+
readonly affects: string | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The model jobs of a round as D99 runs it (clerk.ts `ROUND_STEPS`), as the table names them. */
|
|
29
|
+
const EVERY_STEP = 'every job — each job of a round (the session drafts, the main agent through its stages, each lane it sends, the synthesis, the spot-check), investigations, answers, requests and re-looks';
|
|
30
|
+
|
|
31
|
+
export const PI_CAPABILITIES: readonly Capability[] = [
|
|
32
|
+
// ── pi as it comes (Spec §8.1's first table) ──
|
|
33
|
+
{ name: 'Conversation: streaming output, tool calls', workbench: 'Keeper conversation', native: 'Native', available: true, provider: 'pi built-in', source: 'pi, as it comes', affects: null },
|
|
34
|
+
{
|
|
35
|
+
name: 'Built-in tools: read, write, edit, bash (and PowerShell on Windows), grep, find, ls',
|
|
36
|
+
workbench: `All on in ${EVERY_STEP}; none removed. Autonomous work that changes project content is shown in the Keeper view`,
|
|
37
|
+
native: 'Native; grep, find and ls are off in pi\'s own defaults',
|
|
38
|
+
available: true, provider: 'pi built-in',
|
|
39
|
+
source: 'pi\'s own tools, all turned on for every job (settings defaultTools). ProjectKeeper\'s adapter keeps them inside the project: a read boundary on read, grep, find, ls and edit, shell commands checked before they run and their changes to the project undone as the shell row says, shell without credential variables',
|
|
40
|
+
affects: null,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Shell commands on the project: what the boundary refuses, and what it undoes on a live project and on a controlled trial',
|
|
44
|
+
workbench: `Every shell command in ${EVERY_STEP}. A refused command, and one whose changes were undone, is a step marked as an error with the reason and the paths; when something changed while a command ran, not by it, the step's result starts with “${LEFT_NOTE}” and the paths it left`,
|
|
45
|
+
native: 'Not in native pi: Open in pi runs shell commands as they are given',
|
|
46
|
+
available: true, provider: 'ProjectKeeper adapter',
|
|
47
|
+
source: 'ProjectKeeper\'s shell boundary. Refused before a command runs: reading outside the project; a path that cannot be worked out beforehand (a variable, a command substitution, eval, code piped into an interpreter); redirecting into the project, and writing into it with tee, cp, mv, rm, touch, mkdir, rmdir, truncate or sed -i, projectkeeper/ included; git commands that change the repository; Git-ignored and Excluded paths. '
|
|
48
|
+
+ 'Undone after it runs, on a live project (a home that watches its projects, where the owner and agents write at the same time): only what the command itself names as its writes — its redirection targets, the value of an output option (--output, sort -o …), the operands of the commands above — and every other change is left as it is and named on the step, including one the command made through a program or a script, which cannot be told from another writer\'s. '
|
|
49
|
+
+ 'On a controlled trial (settings.watchProjects false: nobody else writes there): every change to the working tree that git status or the directory scan shows. '
|
|
50
|
+
+ 'Never, on either: the index, HEAD, refs or anything else in .git, nor what a commit made while the command ran',
|
|
51
|
+
affects: null,
|
|
52
|
+
},
|
|
53
|
+
{ name: 'Sessions: save, resume, name', workbench: 'Session switch in the conversation', native: 'Native', available: true, provider: 'pi built-in', source: 'pi, as it comes', affects: null },
|
|
54
|
+
{ name: 'Branching: tree navigation, fork, clone', workbench: 'Branch in the conversation', native: 'Native', available: true, provider: 'pi built-in', source: 'pi, as it comes', affects: null },
|
|
55
|
+
{ name: 'Compaction: automatic and manual', workbench: 'Long sessions continue', native: 'Native', available: true, provider: 'pi built-in', source: 'pi, as it comes', affects: null },
|
|
56
|
+
{ name: 'Steering, queued follow-ups, abort', workbench: 'Send while answering; Stop', native: 'Native', available: true, provider: 'pi built-in', source: 'pi, as it comes', affects: null },
|
|
57
|
+
{ name: 'Model and thinking level; provider login or API key', workbench: 'Keeper → Model provider', native: 'Native (/login, /model)', available: true, provider: 'pi built-in', source: 'pi, as it comes; backups and extra keys are ProjectKeeper\'s settings', affects: null },
|
|
58
|
+
{ name: 'Project instruction files, skills, prompt templates, extensions, pi packages', workbench: 'Loaded the native way for the project directory', native: 'Native', available: true, provider: 'pi built-in', source: 'pi, as it comes', affects: null },
|
|
59
|
+
{ name: 'Themes', workbench: 'Not applicable', native: 'Native', available: true, provider: 'pi built-in', source: 'pi, as it comes', affects: null },
|
|
60
|
+
{ name: 'Usage and cost reporting', workbench: 'Usage, Keeper activity', native: 'Native', available: true, provider: 'pi built-in', source: 'pi\'s session statistics', affects: null },
|
|
61
|
+
|
|
62
|
+
// ── what the clerk method needs (Spec §8.1 "书记员需要的能力"; CKC-03 AC-25–AC-31) ──
|
|
63
|
+
{
|
|
64
|
+
name: 'Querying the ledger: commits and merges, document versions and their sections, supersession lines, numbers, verdicts, execution arrangements, a word across all history, file references, sessions and the owner\'s words, how something got here',
|
|
65
|
+
workbench: `The pk_ledger_* tools, in ${EVERY_STEP}; a round's first step brings the ledger up to date`,
|
|
66
|
+
native: 'Not in native pi',
|
|
67
|
+
available: true, provider: 'The ledger',
|
|
68
|
+
source: 'The project\'s ledger (one SQLite file in its assets, rebuilt from git, the documents and the session logs), read through the pk_ledger_* tools',
|
|
69
|
+
affects: null,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Code references in TypeScript and JavaScript: file level, and symbol level (references, implementations, callers, callees)',
|
|
73
|
+
workbench: `File-level dependencies of every file in the ledger; symbol level on demand with pk_ledger_symbol, compiler-exact, in ${EVERY_STEP}. Project scope says the same level per language`,
|
|
74
|
+
native: 'Not in native pi',
|
|
75
|
+
available: true, provider: 'TypeScript language service',
|
|
76
|
+
source: 'File level: the ledger, through the TypeScript pre-parser. Symbol level: the TypeScript language service over the current checkout',
|
|
77
|
+
affects: null,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'Code references in every other language the code engine reads (Dart, Python, Kotlin, Swift, Go, Java, C/C++ and the rest): file level, and symbol level (references, implementations, callers, callees)',
|
|
81
|
+
workbench: `File-level dependencies of every such file in the ledger; symbol level on demand with pk_ledger_symbol, each hit with how it was resolved and whether it counts, in ${EVERY_STEP}. Nothing to set up in the project. Project scope and pk_ledger_coverage say per language what was resolved and where references went unresolved; a residue judged by references there is recorded Inferred (pk_write_territory)`,
|
|
82
|
+
native: 'Not in native pi',
|
|
83
|
+
available: true, provider: 'The ledger',
|
|
84
|
+
source: 'The ledger\'s general code engine, @colbymchenry/codegraph (pinned), indexing a snapshot of the current version kept next to the ledger — never in the project; only references it resolved through an import, a path, a qualified name, a function reference or an instance method count',
|
|
85
|
+
affects: null,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'Code references in languages neither reads (CSS, HTML, shell scripts, SQL …)',
|
|
89
|
+
workbench: 'The file tree and sizes only; no dependencies. Project scope lists each language with its level',
|
|
90
|
+
native: 'Not in native pi',
|
|
91
|
+
available: false, provider: 'Not provided',
|
|
92
|
+
source: 'Neither the TypeScript compiler nor the code engine reads their references',
|
|
93
|
+
affects: 'On such code, the code-state sweep and the cross-check read dependencies by hand; a residue judged by references there is recorded Inferred (pk_write_territory)',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'Each job of a round and each lane in a fresh session, in parallel',
|
|
97
|
+
workbench: 'A round\'s main agent, each lane it sends, the session drafts and the spot-check run as jobs of their own in new pi sessions — the lanes as many at once as the keys allow (Parallel jobs per key); they hand over through the workbench\'s positions and the round\'s documents, never a shared session',
|
|
98
|
+
native: 'One session at a time',
|
|
99
|
+
available: true, provider: 'ProjectKeeper adapter',
|
|
100
|
+
source: 'The Keeper runtime: a new pi session per job, nothing forked from another',
|
|
101
|
+
affects: null,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'Delegating a local investigation (sub-agent)',
|
|
105
|
+
workbench: 'The conversation, answers, requests, product re-looks and a round\'s synthesis send focused investigations',
|
|
106
|
+
native: 'Not in native pi (pi has no sub-agents of its own)',
|
|
107
|
+
available: true, provider: 'ProjectKeeper tool',
|
|
108
|
+
source: 'pk_investigate: a focused pi session of its own whose conclusion and sources return to the job that sent it; it is a child of that job in Keeper activity',
|
|
109
|
+
affects: null,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'Model and thinking level per step',
|
|
113
|
+
workbench: 'Keeper → Model provider, for each model step of a round (session drafts, the main agent, each lane, the synthesis — which, left unset, runs on what the main agent is set to — and the spot-check; and for rounds of the earlier method, where each step was a job of its own: orientation, skeleton, sweeps, cross-check); the model and the thinking level a job actually ran on are in Keeper activity',
|
|
114
|
+
native: 'One model per session (/model)',
|
|
115
|
+
available: true, provider: 'ProjectKeeper adapter',
|
|
116
|
+
source: 'The workspace setting steps, applied when a step\'s pi session is created; the thinking level the model accepted is recorded',
|
|
117
|
+
affects: null,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'Long output: long judgements and tool calls with long arguments',
|
|
121
|
+
workbench: `In ${EVERY_STEP}: long tool arguments stream in whole; a call whose arguments did not arrive as complete JSON never runs — any tool, pi's write included — and the model is told to send it again; a last reply cut at the output limit, or the same call refused the same way in 8 turns in a row with nothing else run in them, ends the job Failed with the step and the reason in Keeper activity (calls refused together in one turn count once each); the reply is kept as written`,
|
|
122
|
+
native: 'Upstream behaviour: Open in pi runs the pi installed on the machine, without ProjectKeeper\'s patch',
|
|
123
|
+
available: true, provider: 'ProjectKeeper adapter',
|
|
124
|
+
source: 'ProjectKeeper\'s patch of pi-ai 0.87.1 (scripts/apply-pi-streaming-patch.ts, applied at npm install) and the runtime\'s rules for how a job ends',
|
|
125
|
+
affects: null,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'Time and usage per step',
|
|
129
|
+
workbench: 'Keeper activity and the round tree: each job\'s time split into generation, tools, queue, parse & retry and other, and its tokens; a round sums its steps',
|
|
130
|
+
native: 'Usage per session',
|
|
131
|
+
available: true, provider: 'ProjectKeeper adapter',
|
|
132
|
+
source: 'The Keeper runtime stamps pi\'s events as they arrive (StepTimer); usage from pi\'s session statistics',
|
|
133
|
+
affects: null,
|
|
134
|
+
},
|
|
135
|
+
{ name: 'MCP servers', workbench: 'Not provided by pi itself; an extension may add it', native: 'Only through an extension', available: false, provider: 'Not provided', source: 'pi has no built-in MCP; nothing in ProjectKeeper adds it', affects: 'No step and no workbench control depends on it' },
|
|
136
|
+
];
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which step of a round of the clerk method writes which of the clerk method's own positions (Spec v3.0 §3.3
|
|
3
|
+
* “跨对象的记录由哪一步写”). One table for both sides: a writer refuses a step not listed for it (clerk-tools.ts), and
|
|
4
|
+
* a step is offered exactly the writers that list it (roles.ts `STEP_WRITES`), so a step is never offered a writer
|
|
5
|
+
* that then refuses it, nor denied a correction the writer allows. The spot-check corrects through the same writers,
|
|
6
|
+
* on records that already exist.
|
|
7
|
+
*/
|
|
8
|
+
import type { ClerkStage, RoundDocKind, RoundStepKind, SlotKind } from '../model/k-types.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The round documents each step writes; a round document is written by the step listed for its kind. The synthesis
|
|
12
|
+
* (D103: a job of its own) writes the round's Result; the spot-check, which checks every claim of it, corrects a Result
|
|
13
|
+
* that is there (clerk-tools.ts `pk_write_round_doc`).
|
|
14
|
+
*/
|
|
15
|
+
export const DOCS_BY_STEP: Readonly<Partial<Record<RoundStepKind, readonly RoundDocKind[]>>> = {
|
|
16
|
+
orientation: ['Questions', 'Brief', 'History map'],
|
|
17
|
+
dig: ['Report'],
|
|
18
|
+
'cross-check': ['Adoption'],
|
|
19
|
+
synthesis: ['Result'],
|
|
20
|
+
'spot-check': ['Spot check', 'Result'],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const CLERK_WRITER_STEPS = {
|
|
24
|
+
pk_write_session_draft: ['session-drafts'],
|
|
25
|
+
pk_write_layers: ['orientation', 'spot-check'],
|
|
26
|
+
pk_write_generation: ['orientation', 'skeleton', 'cross-check', 'spot-check'],
|
|
27
|
+
pk_write_round_doc: Object.keys(DOCS_BY_STEP) as RoundStepKind[],
|
|
28
|
+
pk_write_patch: ['skeleton', 'cross-check', 'spot-check'],
|
|
29
|
+
pk_number: ['skeleton'],
|
|
30
|
+
pk_link_process: ['skeleton', 'cross-check'],
|
|
31
|
+
pk_confirm: ['cross-check', 'spot-check'],
|
|
32
|
+
pk_suggest_sendback: ['cross-check', 'synthesis'],
|
|
33
|
+
pk_tag_six: ['cross-check', 'synthesis', 'spot-check'],
|
|
34
|
+
pk_confirm_note: ['synthesis'],
|
|
35
|
+
pk_write_territory: ['cross-check', 'spot-check'],
|
|
36
|
+
pk_record_spot_check: ['spot-check'],
|
|
37
|
+
} as const satisfies Readonly<Record<string, readonly RoundStepKind[]>>;
|
|
38
|
+
|
|
39
|
+
export type ClerkWriter = keyof typeof CLERK_WRITER_STEPS;
|
|
40
|
+
|
|
41
|
+
/** The clerk method's writers a step is offered. */
|
|
42
|
+
export function clerkWritersOf(step: RoundStepKind | string): ClerkWriter[] {
|
|
43
|
+
return (Object.keys(CLERK_WRITER_STEPS) as ClerkWriter[]).filter((t) => (CLERK_WRITER_STEPS[t] as readonly string[]).includes(step));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The steps of a round in the method's order (§3.3); D99's main agent and its lanes last, so each has its own model setting
|
|
48
|
+
* (CKC-23 AC-11). D103: `synthesis` is a step of its own again; left unset, it runs on what `main` is set to (`STEP_SETTING_AS`).
|
|
49
|
+
*/
|
|
50
|
+
export const ROUND_STEP_KINDS = ['ledger', 'session-drafts', 'orientation', 'skeleton', 'dig', 'cross-check', 'process', 'synthesis', 'spot-check', 'main', 'lane'] as const satisfies readonly RoundStepKind[];
|
|
51
|
+
/** The program's steps: the ledger (§1.16) and the process with its breakpoints (§2.12). Every other step runs a model. */
|
|
52
|
+
export const PROGRAM_STEP_KINDS: readonly RoundStepKind[] = ['ledger', 'process'];
|
|
53
|
+
export const MODEL_STEP_KINDS: readonly RoundStepKind[] = ROUND_STEP_KINDS.filter((k) => !PROGRAM_STEP_KINDS.includes(k));
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A step whose model setting, left unset, is another step's (D103): the synthesis runs on what the main agent is set to,
|
|
57
|
+
* so a home whose settings were written before the synthesis had a session of its own keeps running it on the same model.
|
|
58
|
+
*/
|
|
59
|
+
export const STEP_SETTING_AS: Readonly<Partial<Record<RoundStepKind, RoundStepKind>>> = { synthesis: 'main' };
|
|
60
|
+
|
|
61
|
+
/** A step's model setting as it takes effect: its own, each part it leaves unset taken from the step it defaults to. */
|
|
62
|
+
export function stepSettingOf<T extends { readonly model?: string; readonly thinking?: string }>(steps: Readonly<Partial<Record<string, T>>> | null | undefined, kind: RoundStepKind): { readonly model?: string; readonly thinking?: string } | undefined {
|
|
63
|
+
const own = steps?.[kind];
|
|
64
|
+
const as = STEP_SETTING_AS[kind];
|
|
65
|
+
const from = as ? steps?.[as] : undefined;
|
|
66
|
+
if (!own && !from) return undefined;
|
|
67
|
+
const model = own?.model ?? from?.model;
|
|
68
|
+
const thinking = own?.thinking ?? from?.thinking;
|
|
69
|
+
return { ...(model ? { model } : {}), ...(thinking ? { thinking } : {}) };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** pi's thinking levels (`ThinkingLevel`), for the per-step setting (CKC-03 AC-29). */
|
|
73
|
+
export const THINKING_LEVELS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const;
|
|
74
|
+
|
|
75
|
+
// ───────────────────────── D99: the main agent's stages and the lanes' slots (W0 contract) ─────────────────────────
|
|
76
|
+
|
|
77
|
+
/** The trunk's writers from before the clerk method (roles.ts `TRUNK_WRITES`), named here for the D99 tables. */
|
|
78
|
+
const TRUNK = ['pk_write_reference', 'pk_write_thread', 'pk_write_area', 'pk_relate', 'pk_write_mark', 'pk_merge_work_items', 'pk_record_carry_out', 'pk_check_decisions', 'pk_set_used_as'] as const;
|
|
79
|
+
|
|
80
|
+
/** Tools the main agent has in every stage (D99): moving between stages, where the round stands, its lanes. */
|
|
81
|
+
export const MAIN_ALWAYS = ['pk_stage', 'pk_round_state', 'pk_lanes'] as const;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* What the main agent writes in each stage (D99; Spec §3.3 "谁写什么"). Its session is offered the union; a writer
|
|
85
|
+
* refuses outside the stages that list it (gate at call time, E148 D-a). Round documents by kind follow `DOCS_BY_STAGE`.
|
|
86
|
+
* D103: the main agent writes nothing in the synthesis — it hands over, and the synthesis job writes what the stage wrote
|
|
87
|
+
* (`SYNTHESIS_WRITERS`).
|
|
88
|
+
*/
|
|
89
|
+
export const STAGE_WRITERS: Readonly<Record<ClerkStage, readonly string[]>> = {
|
|
90
|
+
orientation: ['pk_write_rule', 'pk_classify_scope', 'pk_set_used_as', 'pk_write_organizing_plan', 'pk_write_layers', 'pk_write_generation', 'pk_generation_candidate', 'pk_write_round_doc'],
|
|
91
|
+
skeleton: ['pk_write_round_doc', 'pk_send_lanes', 'pk_fill_from_table', 'pk_fill_from_headings', 'pk_fill_from_bold', 'pk_account_entries'],
|
|
92
|
+
reconcile: [...TRUNK, 'pk_judge_owner_lines', 'pk_write_rule', 'pk_number', 'pk_link_process', 'pk_write_patch', 'pk_write_generation', 'pk_generation_candidate', 'pk_place_range', 'pk_fill_from_table', 'pk_fill_from_headings', 'pk_fill_from_bold', 'pk_account_entries'],
|
|
93
|
+
dig: ['pk_write_round_doc', 'pk_send_lanes'],
|
|
94
|
+
coverage: ['pk_coverage_check', 'pk_account_material', 'pk_account_entries', 'pk_write_round_doc', 'pk_send_lanes'],
|
|
95
|
+
'cross-check': [...TRUNK, 'pk_judge_owner_lines', 'pk_write_rule', 'pk_account_entries', 'pk_confirm', 'pk_link_process', 'pk_write_patch', 'pk_write_generation', 'pk_generation_candidate', 'pk_place_range', 'pk_suggest_sendback', 'pk_tag_six', 'pk_write_territory', 'pk_write_round_doc'],
|
|
96
|
+
synthesis: [],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* What the synthesis job writes (D103; Spec §3.3 the stage table's 合成 row: note, the six things, `Suggested` send-backs,
|
|
101
|
+
* area understanding, the round's Result). What the main agent's synthesis stage wrote before it — the notes, the
|
|
102
|
+
* judgement record and relations it reached, the rules note, marks, an investigation, send-backs, the six things, the
|
|
103
|
+
* round's Result — and the two D103 gives the synthesis: area understanding (`pk_write_area`, which the stage did not
|
|
104
|
+
* offer), and `pk_confirm_note`, the result "still holds" for a note standing from an earlier round (standing-notes.ts).
|
|
105
|
+
* roles.ts offers exactly these (`STEP_WRITES.synthesis`).
|
|
106
|
+
*/
|
|
107
|
+
export const SYNTHESIS_WRITERS = ['pk_write_note', 'pk_close_note', 'pk_record_judgement', 'pk_assess_relation', 'pk_ask_owner_about_rules', 'pk_write_mark', 'pk_investigate', 'pk_suggest_sendback', 'pk_tag_six', 'pk_write_round_doc', 'pk_write_area', 'pk_confirm_note'] as const;
|
|
108
|
+
/** What the synthesis job is offered besides its writers and the reads every step has: where the round stands, counted, and one list at a time. */
|
|
109
|
+
export const SYNTHESIS_ALWAYS = ['pk_round_state'] as const;
|
|
110
|
+
|
|
111
|
+
/** The round documents the main agent writes in each stage (D99). */
|
|
112
|
+
export const DOCS_BY_STAGE: Readonly<Record<ClerkStage, readonly RoundDocKind[]>> = {
|
|
113
|
+
orientation: ['Questions', 'Brief', 'History map'],
|
|
114
|
+
skeleton: ['Brief'],
|
|
115
|
+
reconcile: [],
|
|
116
|
+
dig: ['Brief'],
|
|
117
|
+
coverage: ['Brief'],
|
|
118
|
+
'cross-check': ['Adoption'],
|
|
119
|
+
synthesis: [],
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** What a lane may write, by the slot kind it was given (D99, E148 D-d); `reference:<category>` is checked by category too. */
|
|
123
|
+
export const SLOT_WRITERS: Readonly<Record<'reference' | Exclude<SlotKind, `reference:${string}`>, readonly string[]>> = {
|
|
124
|
+
// DA: `pk_judge_owner_lines` is the Owner's words lane's (stage-gate.ts checks the category, as for the items).
|
|
125
|
+
reference: ['pk_write_reference', 'pk_judge_owner_lines', 'pk_fill_from_table', 'pk_fill_from_headings', 'pk_fill_from_bold', 'pk_place_range'],
|
|
126
|
+
threads: ['pk_write_thread', 'pk_number', 'pk_merge_work_items', 'pk_record_carry_out', 'pk_fill_from_table', 'pk_place_range'],
|
|
127
|
+
links: ['pk_link_process'],
|
|
128
|
+
territories: ['pk_write_territory'],
|
|
129
|
+
patches: ['pk_write_patch'],
|
|
130
|
+
generations: ['pk_write_generation', 'pk_generation_candidate'],
|
|
131
|
+
relations: ['pk_relate', 'pk_place_range'],
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/** What every lane may write whatever its slots (D99): its own Report, and where it looked for a missing step. */
|
|
135
|
+
export const LANE_ALWAYS = ['pk_write_round_doc', 'pk_record_looked'] as const;
|
|
136
|
+
/** The round document a lane writes. */
|
|
137
|
+
export const LANE_DOCS: readonly RoundDocKind[] = ['Report'];
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The main agent's stages in each kind of round, in order (D99; Spec §3.3, §3.7, §3.8). D103: its session ends after its
|
|
141
|
+
* last check — the reconciling of a first usable round, the cross-check of a deepening and a Follow up — with a handover
|
|
142
|
+
* to the synthesis, which runs in a session of its own.
|
|
143
|
+
*/
|
|
144
|
+
export const ROUND_STAGES: Readonly<Record<'First usable' | 'Deepen' | 'Follow up', readonly ClerkStage[]>> = {
|
|
145
|
+
'First usable': ['orientation', 'skeleton', 'reconcile'],
|
|
146
|
+
Deepen: ['orientation', 'dig', 'coverage', 'cross-check'],
|
|
147
|
+
'Follow up': ['orientation', 'skeleton', 'reconcile', 'dig', 'coverage', 'cross-check'],
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/** What the main agent hands the round over to with `pk_stage` once its last stage is done (D103): the synthesis. */
|
|
151
|
+
export const HANDOVER_TO: ClerkStage = 'synthesis';
|