ptbk 0.119.0-16 → 0.119.0-21
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/README.md +27 -9
- package/dist/book/commitments.d.ts +38 -10
- package/dist/book/commitments.js +61 -17
- package/dist/book/commitments.js.map +1 -1
- package/dist/book/convert.d.ts +36 -0
- package/dist/book/convert.js +156 -0
- package/dist/book/convert.js.map +1 -0
- package/dist/book/parse.d.ts +50 -13
- package/dist/book/parse.js +132 -45
- package/dist/book/parse.js.map +1 -1
- package/dist/book/references.d.ts +12 -4
- package/dist/book/references.js +34 -9
- package/dist/book/references.js.map +1 -1
- package/dist/book/write.d.ts +42 -0
- package/dist/book/write.js +74 -0
- package/dist/book/write.js.map +1 -0
- package/dist/browser/browser.d.ts +122 -12
- package/dist/browser/browser.js +372 -21
- package/dist/browser/browser.js.map +1 -1
- package/dist/browser/recording.d.ts +3 -3
- package/dist/browser/recording.js +5 -5
- package/dist/browser/recording.js.map +1 -1
- package/dist/chats/chat-book.d.ts +105 -0
- package/dist/chats/chat-book.js +180 -0
- package/dist/chats/chat-book.js.map +1 -0
- package/dist/chats/conversation.d.ts +54 -0
- package/dist/chats/conversation.js +188 -0
- package/dist/chats/conversation.js.map +1 -0
- package/dist/chats/local.d.ts +46 -0
- package/dist/chats/local.js +184 -0
- package/dist/chats/local.js.map +1 -0
- package/dist/chats/migration.d.ts +12 -0
- package/dist/chats/migration.js +62 -0
- package/dist/chats/migration.js.map +1 -0
- package/dist/chats/service.d.ts +81 -0
- package/dist/chats/service.js +122 -0
- package/dist/chats/service.js.map +1 -0
- package/dist/chats/store.d.ts +132 -0
- package/dist/chats/store.js +181 -0
- package/dist/chats/store.js.map +1 -0
- package/dist/chats/task-chats.d.ts +52 -0
- package/dist/chats/task-chats.js +96 -0
- package/dist/chats/task-chats.js.map +1 -0
- package/dist/cli/chats.d.ts +45 -0
- package/dist/cli/chats.js +108 -0
- package/dist/cli/chats.js.map +1 -0
- package/dist/cli/commands/add.js +32 -22
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/answer.d.ts +2 -1
- package/dist/cli/commands/answer.js +35 -41
- package/dist/cli/commands/answer.js.map +1 -1
- package/dist/cli/commands/ask.d.ts +7 -0
- package/dist/cli/commands/ask.js +37 -0
- package/dist/cli/commands/ask.js.map +1 -0
- package/dist/cli/commands/boilerplates.js +14 -3
- package/dist/cli/commands/boilerplates.js.map +1 -1
- package/dist/cli/commands/chat.d.ts +9 -0
- package/dist/cli/commands/chat.js +89 -0
- package/dist/cli/commands/chat.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts +3 -1
- package/dist/cli/commands/dashboard.js +41 -3
- package/dist/cli/commands/dashboard.js.map +1 -1
- package/dist/cli/commands/find.js +6 -8
- package/dist/cli/commands/find.js.map +1 -1
- package/dist/cli/commands/fix.js +4 -6
- package/dist/cli/commands/fix.js.map +1 -1
- package/dist/cli/commands/init.d.ts +0 -1
- package/dist/cli/commands/init.js +38 -38
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/lint.js +16 -2
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/list.js +21 -13
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/migrate.d.ts +2 -1
- package/dist/cli/commands/migrate.js +70 -24
- package/dist/cli/commands/migrate.js.map +1 -1
- package/dist/cli/commands/pause.d.ts +8 -0
- package/dist/cli/commands/pause.js +40 -0
- package/dist/cli/commands/pause.js.map +1 -0
- package/dist/cli/commands/plan.js +6 -9
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/recover.js +7 -3
- package/dist/cli/commands/recover.js.map +1 -1
- package/dist/cli/commands/restart.d.ts +3 -1
- package/dist/cli/commands/restart.js +74 -18
- package/dist/cli/commands/restart.js.map +1 -1
- package/dist/cli/commands/resume.d.ts +8 -0
- package/dist/cli/commands/resume.js +15 -0
- package/dist/cli/commands/resume.js.map +1 -0
- package/dist/cli/commands/run.js +6 -9
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/start.js +40 -36
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.d.ts +2 -1
- package/dist/cli/commands/status.js +5 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/stop.d.ts +3 -1
- package/dist/cli/commands/stop.js +18 -8
- package/dist/cli/commands/stop.js.map +1 -1
- package/dist/cli/commands/verify.js +7 -7
- package/dist/cli/commands/verify.js.map +1 -1
- package/dist/cli/common.d.ts +13 -0
- package/dist/cli/common.js +22 -0
- package/dist/cli/common.js.map +1 -1
- package/dist/cli/engine-delegation.d.ts +14 -0
- package/dist/cli/engine-delegation.js +46 -0
- package/dist/cli/engine-delegation.js.map +1 -0
- package/dist/cli/lifecycle.d.ts +40 -0
- package/dist/cli/lifecycle.js +71 -0
- package/dist/cli/lifecycle.js.map +1 -0
- package/dist/cli/registry.js +113 -31
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli/service-view.d.ts +14 -2
- package/dist/cli/service-view.js +46 -5
- package/dist/cli/service-view.js.map +1 -1
- package/dist/cli/sources.js +5 -8
- package/dist/cli/sources.js.map +1 -1
- package/dist/cli/spec.js +1 -1
- package/dist/cli/spec.js.map +1 -1
- package/dist/common/app-data.d.ts +9 -0
- package/dist/common/app-data.js +20 -0
- package/dist/common/app-data.js.map +1 -0
- package/dist/common/errors.d.ts +2 -0
- package/dist/common/errors.js.map +1 -1
- package/dist/common/time.d.ts +6 -0
- package/dist/common/time.js +9 -0
- package/dist/common/time.js.map +1 -1
- package/dist/engine/agenda.d.ts +213 -43
- package/dist/engine/agenda.js +846 -260
- package/dist/engine/agenda.js.map +1 -1
- package/dist/engine/executor.d.ts +23 -7
- package/dist/engine/executor.js +131 -84
- package/dist/engine/executor.js.map +1 -1
- package/dist/engine/generated.d.ts +21 -1
- package/dist/engine/generated.js +36 -21
- package/dist/engine/generated.js.map +1 -1
- package/dist/engine/preview.js +10 -10
- package/dist/engine/preview.js.map +1 -1
- package/dist/engine/prompt.d.ts +16 -4
- package/dist/engine/prompt.js +22 -4
- package/dist/engine/prompt.js.map +1 -1
- package/dist/engine/routing.js +28 -4
- package/dist/engine/routing.js.map +1 -1
- package/dist/engine/snapshot.d.ts +178 -29
- package/dist/engine/state.d.ts +40 -13
- package/dist/engine/state.js +20 -5
- package/dist/engine/state.js.map +1 -1
- package/dist/engine/task-trace.d.ts +35 -7
- package/dist/engine/task-trace.js +74 -15
- package/dist/engine/task-trace.js.map +1 -1
- package/dist/engine/team.d.ts +20 -7
- package/dist/engine/team.js +30 -24
- package/dist/engine/team.js.map +1 -1
- package/dist/engine/traces.d.ts +1 -1
- package/dist/engine/traces.js +1 -1
- package/dist/expert/_main.md +67 -52
- package/dist/expert/agents/_index.md +11 -13
- package/dist/expert/agents/chatter.md +31 -0
- package/dist/expert/agents/consistency.md +6 -11
- package/dist/expert/agents/core-agents.md +9 -7
- package/dist/expert/agents/expert.md +2 -2
- package/dist/expert/agents/fixer.md +24 -0
- package/dist/expert/agents/learning.md +1 -1
- package/dist/expert/agents/non-agents.md +6 -4
- package/dist/expert/agents/teacher.md +1 -1
- package/dist/expert/agents/visual-identity.md +4 -4
- package/dist/expert/book-language/_index.md +9 -8
- package/dist/expert/book-language/commitments/_index.md +23 -3
- package/dist/expert/book-language/commitments/agent.md +11 -0
- package/dist/expert/book-language/commitments/chat-member.md +7 -0
- package/dist/expert/book-language/commitments/chat-message.md +11 -0
- package/dist/expert/book-language/commitments/chat-status.md +7 -0
- package/dist/expert/book-language/commitments/chat.md +11 -0
- package/dist/expert/book-language/commitments/entity.md +9 -0
- package/dist/expert/book-language/commitments/from.md +1 -1
- package/dist/expert/book-language/commitments/goal.md +6 -2
- package/dist/expert/book-language/commitments/link.md +9 -0
- package/dist/expert/book-language/commitments/task-depends-on.md +1 -1
- package/dist/expert/book-language/commitments/task-parent.md +1 -1
- package/dist/expert/book-language/commitments/task.md +7 -3
- package/dist/expert/book-language/commitments/team.md +1 -1
- package/dist/expert/book-language/inheritance.md +2 -2
- package/dist/expert/book-language/references.md +20 -24
- package/dist/expert/book-language/syntax.md +54 -11
- package/dist/expert/cli/acceptance.md +59 -24
- package/dist/expert/cli/api.md +23 -9
- package/dist/expert/cli/authoring.md +6 -4
- package/dist/expert/cli/autonomous-operation.md +3 -3
- package/dist/expert/cli/browser.md +29 -18
- package/dist/expert/cli/channels.md +5 -7
- package/dist/expert/cli/chat-ui.md +32 -0
- package/dist/expert/cli/chats.md +59 -0
- package/dist/expert/cli/cli.md +44 -26
- package/dist/expert/cli/configuration.md +3 -3
- package/dist/expert/cli/controls.md +13 -7
- package/dist/expert/cli/dashboard-details.md +23 -0
- package/dist/expert/cli/dashboard-layout.md +19 -12
- package/dist/expert/cli/dashboard.md +12 -8
- package/dist/expert/cli/execution.md +8 -6
- package/dist/expert/cli/first-task.md +4 -4
- package/dist/expert/cli/generated-names.md +44 -0
- package/dist/expert/cli/git-persistence.md +19 -17
- package/dist/expert/cli/global-dashboard.md +33 -0
- package/dist/expert/cli/goal-discovery.md +1 -1
- package/dist/expert/cli/help.md +1 -1
- package/dist/expert/cli/initialization-ui.md +2 -0
- package/dist/expert/cli/initialization.md +9 -7
- package/dist/expert/cli/interactive-ui.md +9 -5
- package/dist/expert/cli/locking.md +21 -0
- package/dist/expert/cli/migration.md +22 -6
- package/dist/expert/cli/process-modes.md +21 -13
- package/dist/expert/cli/recovery.md +8 -6
- package/dist/expert/cli/recurrence.md +1 -1
- package/dist/expert/cli/rich-input.md +2 -2
- package/dist/expert/cli/service-lifecycle.md +57 -0
- package/dist/expert/cli/start.md +2 -2
- package/dist/expert/cli/status-view.md +16 -12
- package/dist/expert/cli/task-books.md +11 -15
- package/dist/expert/cli/task-identity.md +8 -10
- package/dist/expert/cli/task-markdown.md +6 -10
- package/dist/expert/cli/task-origins.md +3 -1
- package/dist/expert/cli/task-relationships.md +5 -9
- package/dist/expert/cli/team.md +17 -7
- package/dist/expert/cli/terminal.md +20 -12
- package/dist/expert/cli/trace-configuration.md +1 -1
- package/dist/expert/cli/traces.md +19 -23
- package/dist/expert/cli/user-interactions.md +14 -26
- package/dist/expert/cli/workspace.md +15 -9
- package/dist/expert/concepts/engine-and-project.md +11 -0
- package/dist/expert/concepts/project-model.md +39 -0
- package/dist/expert/dictionary.md +21 -15
- package/dist/harness/plugins/claude-code/index.js +1 -0
- package/dist/harness/plugins/claude-code/index.js.map +1 -1
- package/dist/harness/plugins/cline/index.js +1 -0
- package/dist/harness/plugins/cline/index.js.map +1 -1
- package/dist/harness/plugins/openai-codex/index.js +1 -0
- package/dist/harness/plugins/openai-codex/index.js.map +1 -1
- package/dist/harness/plugins/opencode/index.js +1 -0
- package/dist/harness/plugins/opencode/index.js.map +1 -1
- package/dist/harness/types.d.ts +3 -1
- package/dist/project/agents.d.ts +29 -81
- package/dist/project/agents.js +48 -267
- package/dist/project/agents.js.map +1 -1
- package/dist/project/books.d.ts +150 -0
- package/dist/project/books.js +253 -0
- package/dist/project/books.js.map +1 -0
- package/dist/project/config.js +2 -2
- package/dist/project/config.js.map +1 -1
- package/dist/project/defaults.d.ts +35 -6
- package/dist/project/defaults.js +73 -40
- package/dist/project/defaults.js.map +1 -1
- package/dist/project/expert.js +18 -10
- package/dist/project/expert.js.map +1 -1
- package/dist/project/git.d.ts +4 -3
- package/dist/project/git.js +16 -5
- package/dist/project/git.js.map +1 -1
- package/dist/project/setup.d.ts +4 -1
- package/dist/project/setup.js +26 -6
- package/dist/project/setup.js.map +1 -1
- package/dist/service/actions.d.ts +34 -10
- package/dist/service/actions.js +51 -19
- package/dist/service/actions.js.map +1 -1
- package/dist/service/control.d.ts +53 -1
- package/dist/service/control.js +64 -4
- package/dist/service/control.js.map +1 -1
- package/dist/service/discovery.d.ts +133 -0
- package/dist/service/discovery.js +138 -0
- package/dist/service/discovery.js.map +1 -0
- package/dist/service/host.d.ts +8 -1
- package/dist/service/host.js +65 -18
- package/dist/service/host.js.map +1 -1
- package/dist/service/http.d.ts +3 -0
- package/dist/service/http.js +26 -6
- package/dist/service/http.js.map +1 -1
- package/dist/service/launcher.d.ts +66 -13
- package/dist/service/launcher.js +78 -18
- package/dist/service/launcher.js.map +1 -1
- package/dist/service/records.d.ts +12 -2
- package/dist/service/records.js +19 -5
- package/dist/service/records.js.map +1 -1
- package/dist/service/spa/app.css +83 -2
- package/dist/service/spa/app.js +393 -72
- package/dist/service/supervisor.js +7 -1
- package/dist/service/supervisor.js.map +1 -1
- package/dist/service/worker.js +14 -5
- package/dist/service/worker.js.map +1 -1
- package/dist/tasks/authoring.d.ts +3 -5
- package/dist/tasks/authoring.js +6 -7
- package/dist/tasks/authoring.js.map +1 -1
- package/dist/tasks/book-task.d.ts +18 -10
- package/dist/tasks/book-task.js +27 -23
- package/dist/tasks/book-task.js.map +1 -1
- package/dist/tasks/eligibility.d.ts +15 -7
- package/dist/tasks/eligibility.js +41 -14
- package/dist/tasks/eligibility.js.map +1 -1
- package/dist/tasks/identity.d.ts +41 -15
- package/dist/tasks/identity.js +100 -31
- package/dist/tasks/identity.js.map +1 -1
- package/dist/tasks/markdown.d.ts +7 -14
- package/dist/tasks/markdown.js +15 -29
- package/dist/tasks/markdown.js.map +1 -1
- package/dist/tasks/model.d.ts +20 -4
- package/dist/tasks/model.js +17 -0
- package/dist/tasks/model.js.map +1 -1
- package/dist/tasks/sources.d.ts +7 -2
- package/dist/tasks/sources.js +46 -35
- package/dist/tasks/sources.js.map +1 -1
- package/dist/ui/chat-client.d.ts +70 -0
- package/dist/ui/chat-client.js +209 -0
- package/dist/ui/chat-client.js.map +1 -0
- package/dist/ui/dashboard.d.ts +8 -5
- package/dist/ui/dashboard.js +227 -86
- package/dist/ui/dashboard.js.map +1 -1
- package/dist/ui/details.d.ts +64 -0
- package/dist/ui/details.js +175 -0
- package/dist/ui/details.js.map +1 -0
- package/dist/ui/global-dashboard.d.ts +59 -0
- package/dist/ui/global-dashboard.js +307 -0
- package/dist/ui/global-dashboard.js.map +1 -0
- package/dist/ui/status-view.d.ts +7 -0
- package/dist/ui/status-view.js +94 -36
- package/dist/ui/status-view.js.map +1 -1
- package/package.json +1 -1
- package/dist/engine/requests.d.ts +0 -111
- package/dist/engine/requests.js +0 -173
- package/dist/engine/requests.js.map +0 -1
- package/dist/expert/book-language/commitments/task-id.md +0 -9
- package/dist/tasks/prepare.d.ts +0 -33
- package/dist/tasks/prepare.js +0 -90
- package/dist/tasks/prepare.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Promptbook (`ptbk`)
|
|
2
2
|
|
|
3
|
-
Promptbook operates readable **agents** and **
|
|
3
|
+
Promptbook operates readable **agents**, **tasks** and **chats** over a Git project. All three are Books in one language: each starts with `AGENT <name>`, `TASK <name>` or `CHAT <name>`, and that name is its identity. Agents have lasting roles, goals and rules; tasks are bounded work; chats are persistent conversations between you and an agent. Once started, the agenda runs unattended: it executes one task at a time, routes unassigned tasks through Manager, verifies every result with your project check and commits it together with its completion record (`PTBK: <task name>` plus a `Task-Name` trailer). When the backlog is empty, agents with goals are asked whether new work is useful; Fixer keeps the project itself healthy. When something genuinely needs a person, the responsible agent asks you in a chat.
|
|
4
4
|
|
|
5
5
|
This repository publishes exactly one npm package, `ptbk`, which installs the `ptbk` command. It requires Node.js 22.13+ (Node 22 line) or 24+, npm 10+ and Git.
|
|
6
6
|
|
|
@@ -15,18 +15,23 @@ npm install --save-dev ptbk
|
|
|
15
15
|
npx ptbk --version
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Global and local installations are independent; every project keeps using the installation that started it, including after restarts.
|
|
18
|
+
Global and local installations are independent; every project keeps using the installation that started it, including after restarts. A dashboard or status opened with another ptbk version shows the service through its own installation.
|
|
19
19
|
|
|
20
20
|
## Use
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
ptbk init # describe your project, answer a few setup questions; the agenda then starts in the background
|
|
24
24
|
ptbk dashboard # live terminal view and controls (Q leaves, the service keeps running)
|
|
25
|
-
ptbk
|
|
26
|
-
ptbk
|
|
27
|
-
ptbk
|
|
28
|
-
ptbk
|
|
29
|
-
ptbk
|
|
25
|
+
ptbk dashboard --global # every running project engine on this computer, from any directory
|
|
26
|
+
ptbk status # one snapshot: agents waiting for you, current work, queue, connection
|
|
27
|
+
ptbk chat # talk with Chatter (Enter) or choose another agent; Ctrl+C closes only the chat
|
|
28
|
+
ptbk ask "What is left?" # quick question to one agent, saved as a chat
|
|
29
|
+
ptbk answer # answer agents that wait for you
|
|
30
|
+
ptbk add "Improve CSV export" # creates and commits a task; Manager assigns it
|
|
31
|
+
ptbk list "{{Improve CSV export — 2026-10-18 01:25:00}}" # one task: its trace, browser video and commits
|
|
32
|
+
ptbk pause # no new task starts; the current one finishes first (ptbk resume continues)
|
|
33
|
+
ptbk stop # graceful stop after the current task (stays stopped after reboot); -F stops now
|
|
34
|
+
ptbk restart # graceful restart: exactly one replacement with the same configuration
|
|
30
35
|
ptbk start # start an initialized, cloned or stopped project
|
|
31
36
|
ptbk run --limit 1 # finite run with one agent/harness configuration
|
|
32
37
|
```
|
|
@@ -37,8 +42,21 @@ Run `ptbk help` for all commands and `ptbk help <command>` for one command's opt
|
|
|
37
42
|
|
|
38
43
|
- **Unattended setup:** `ptbk init --non-interactive --installation local --harness openai-codex --check "npm test" --intent-file brief.md --attach mockup.png` (`--no-start` only prepares the project).
|
|
39
44
|
- **Harnesses:** OpenAI Codex and Claude Code are featured; GitHub Copilot, Cline, OpenCode, Gemini CLI and Qwen Code are also supported. They are installed globally and use their own login.
|
|
40
|
-
- **Files:** agents in `agents/` (core Adam, Manager and
|
|
41
|
-
- **
|
|
45
|
+
- **Files:** agents in `agents/` (core Adam, Manager, Teacher, Fixer and Chatter in `agents/.core/`), tasks in `tasks/` (Books or Markdown), chats in `chats/`, specifications in `specs/`, per-task audit evidence in `traces/<task-file-basename>/`, configuration in `ptbk.json`, runtime state in the Git-ignored `.ptbk/`.
|
|
46
|
+
- **Books:** every Book opens with one declaration, then commitments, e.g.
|
|
47
|
+
|
|
48
|
+
```book
|
|
49
|
+
TASK Improve CSV export — 2026-10-18 01:25:00
|
|
50
|
+
GOAL Preserve column names and quote cells with commas or newlines.
|
|
51
|
+
TASK AGENT @Developer
|
|
52
|
+
LINK {{Discuss CSV requirements — 2026-10-18 01:24:00}}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
A commitment keyword is a complete line-initial uppercase word sequence of at least three letters (so a name must not begin with an all-uppercase word: `AGENT Ceo`, not `AGENT CEO`); descriptions go under commitments such as `GOAL`, `PERSONA` or `NOTE`. New tasks and chats get generated names — a readable title plus the creation date/time, distinct from every other name. Books in the former syntax (a plain name line, `ENTITY`) are reported and converted only by `ptbk migrate`.
|
|
56
|
+
- **Names, references and traces:** `@Name` and `{{Multi Word Name}}` (the older `{Name}` still reads) reference any Book through one resolver: built-ins (`@Void`, `@Null`, `@Expert`, `@User`), then `agents/`, `tasks/`, `chats/`, the rest of the project and finally Git-ignored content; a same-name copy is shadowed and reported, never merged or renamed. Commits carry `Task-Name`/`Chat-Name` trailers and each task's evidence lives in `traces/<task-file-basename>/` — the task's source filename without `.book` (e.g. `tasks/2026-10-19-1205-browser-repair.book` → `traces/2026-10-19-1205-browser-repair/`), with the declared name and source revision recorded inside: the consolidated harness output (`harness.log`), events (`events.jsonl`) and, when the task used the project browser, its video (`video/`, sign-in steps excluded). `ptbk.json` `traces.commit` (default off: `traces/` is ignored), `traces.ignoreVideos` (default on) and `traces.recordVideo` (default on) are chosen on init's Traces screen. With `ffmpeg` on PATH videos are H.264 MP4, otherwise Motion-JPEG MOV.
|
|
57
|
+
- **Chats:** a new chat goes to **Chatter**, the project's conversational guide (Enter), unless you choose another agent; Chatter consults the right specialists for you (attributed, linked consultation chats) and creates ordinary tasks only when you ask for work. Every message you or an agent write is committed (`PTBK: Chat - <name>`); reading never commits. A correction in a chat can schedule an ordinary Teacher task. Questions, sign-in requests and failure decisions from running tasks are chats started by the responsible agent (dashboard key `A`, `ptbk answer`); the task resumes on a valid answer. The dashboards start chats with `C` (terminal) or **New chat** (browser).
|
|
58
|
+
- **Browser:** agents share one browser per project. Profiles: the dedicated Promptbook profile shared by your projects (default; one project at a time), an isolated project profile in `.ptbk/`, your own Chrome profile, or a custom path (`browser.profile`: `global`, `isolated`, `user` or a path).
|
|
59
|
+
- **Service lifecycle:** a running engine is `running`, `pausing`, `pause` or `stopping`. Pause and stop let the current task finish without starting another one; `ptbk resume` cancels a pending pause, stop or restart; `ptbk stop --force` (`-F`) interrupts owned work immediately (recoverable). The dashboards and browser expose the same controls; leaving a dashboard never stops the service, and any number of dashboards can watch one engine. Execution details (agent, harness, model, thinking level) and browser details (profile, health, recheck/retry/restart) are collapsible panels (`E`/`B` in the terminal).
|
|
42
60
|
- **Remote access:** `ptbk start` serves a dashboard on `127.0.0.1` and publishes it through a Cloudflare quick tunnel; devices must pair with a single-use link shown in the local terminal (`ptbk access pair`). Use `--no-tunnel` for local-only access or `--no-server` for neither.
|
|
43
61
|
- **Presentation:** pretty terminal UI by default; `--raw` (or redirected output) gives plain text without prompts. `--non-interactive` never asks questions.
|
|
44
62
|
- **Commits:** every mutating workflow commits its own changes with a `PTBK: ` subject; `--no-commit` is the explicit exception.
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which document kinds a commitment belongs to.
|
|
2
|
+
* Which document kinds a commitment belongs to (`both` = agents and tasks, `chat` = chats, `any` = every kind).
|
|
3
3
|
*
|
|
4
4
|
* @private Book language
|
|
5
5
|
*/
|
|
6
|
-
export type CommitmentScope = 'agent' | 'task' | 'both';
|
|
6
|
+
export type CommitmentScope = 'agent' | 'task' | 'both' | 'chat' | 'any';
|
|
7
7
|
/**
|
|
8
8
|
* How a commitment's content is interpreted.
|
|
9
9
|
*
|
|
10
|
+
* - `declaration`: the opening type-and-name commitment (`AGENT`, `TASK`, `CHAT`); its content is the name
|
|
10
11
|
* - `instruction`: repeatable multi-line natural-language content
|
|
11
12
|
* - `control`: single-value control field (its value is the first line)
|
|
12
13
|
* - `repeatable-control`: control field that may appear several times (e.g. `TASK DONE`, `TASK DEPENDS ON`)
|
|
13
14
|
* - `flag`: marker without required content (e.g. `CLOSED`)
|
|
15
|
+
* - `historical`: former syntax kept only to diagnose and convert old sources (`ENTITY`)
|
|
14
16
|
*
|
|
15
17
|
* @private Book language
|
|
16
18
|
*/
|
|
17
|
-
export type CommitmentKind = 'instruction' | 'control' | 'repeatable-control' | 'flag';
|
|
19
|
+
export type CommitmentKind = 'declaration' | 'instruction' | 'control' | 'repeatable-control' | 'flag' | 'historical';
|
|
18
20
|
/**
|
|
19
21
|
* Definition of one canonical commitment with its aliases.
|
|
20
22
|
*
|
|
@@ -31,6 +33,8 @@ export type CommitmentDefinition = {
|
|
|
31
33
|
readonly kind: CommitmentKind;
|
|
32
34
|
/** Short description used by help, Expert and diagnostics. */
|
|
33
35
|
readonly description: string;
|
|
36
|
+
/** Not a documented commitment: an unknown complete keyword preserved for round-tripping and diagnosed. */
|
|
37
|
+
readonly unknown?: boolean;
|
|
34
38
|
};
|
|
35
39
|
/**
|
|
36
40
|
* Every recognized commitment.
|
|
@@ -39,14 +43,38 @@ export type CommitmentDefinition = {
|
|
|
39
43
|
*/
|
|
40
44
|
export declare const COMMITMENTS: readonly CommitmentDefinition[];
|
|
41
45
|
/**
|
|
42
|
-
*
|
|
46
|
+
* The commitment kind a compound withdrawal names (`DELETE RULE` → `RULE`), if any.
|
|
43
47
|
*
|
|
44
|
-
*
|
|
48
|
+
* @private Book language
|
|
49
|
+
*/
|
|
50
|
+
export declare function withdrawnKeyword(written: string): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* A commitment keyword found at the beginning of a line.
|
|
53
|
+
*
|
|
54
|
+
* @private Book language
|
|
55
|
+
*/
|
|
56
|
+
export type KeywordMatch = {
|
|
57
|
+
/** Definition of the complete keyword (a synthetic `unknown` definition for undocumented keywords). */
|
|
58
|
+
readonly definition: CommitmentDefinition;
|
|
59
|
+
/** Keyword as written (complete uppercase word sequence). */
|
|
60
|
+
readonly written: string;
|
|
61
|
+
/** Content after the keyword on the same line (trimmed). */
|
|
62
|
+
readonly content: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Recognizes a commitment at the beginning of a line by the common boundary rule.
|
|
66
|
+
*
|
|
67
|
+
* The keyword is the maximal sequence of all-uppercase words at column zero, separated by spaces, with at least three
|
|
68
|
+
* letters in total. A word containing lowercase letters, digits, punctuation or a reference begins the content; once
|
|
69
|
+
* content begins, later uppercase words belong to it. The complete keyword is looked up as a whole: an unknown keyword
|
|
70
|
+
* is never shortened to a known prefix (`TASK SOMETHING` is not `TASK`).
|
|
71
|
+
*
|
|
72
|
+
* @private Book language
|
|
73
|
+
*/
|
|
74
|
+
export declare function matchCommitmentKeyword(line: string): KeywordMatch | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Whether a line would start a commitment (writers escape such lines in literal content).
|
|
45
77
|
*
|
|
46
78
|
* @private Book language
|
|
47
79
|
*/
|
|
48
|
-
export declare function
|
|
49
|
-
definition: CommitmentDefinition;
|
|
50
|
-
written: string;
|
|
51
|
-
content: string;
|
|
52
|
-
} | undefined;
|
|
80
|
+
export declare function startsCommitment(line: string): boolean;
|
package/dist/book/commitments.js
CHANGED
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
* @private Book language
|
|
5
5
|
*/
|
|
6
6
|
export const COMMITMENTS = [
|
|
7
|
+
{ keyword: 'AGENT', aliases: [], scope: 'agent', kind: 'declaration', description: 'Opening declaration of an agent: `AGENT <name>`.' },
|
|
8
|
+
{ keyword: 'TASK', aliases: [], scope: 'task', kind: 'declaration', description: 'Opening declaration of a task: `TASK <name>`.' },
|
|
9
|
+
{ keyword: 'CHAT', aliases: [], scope: 'chat', kind: 'declaration', description: 'Opening declaration of a chat: `CHAT <name>`.' },
|
|
10
|
+
{ keyword: 'ENTITY', aliases: ['ENTITY AGENT', 'ENTITY TASK', 'ENTITY CHAT'], scope: 'any', kind: 'historical', description: 'Former kind declaration after a plain name line; convert with `ptbk migrate`.' },
|
|
11
|
+
{ keyword: 'LINK', aliases: ['LINKS'], scope: 'any', kind: 'repeatable-control', description: 'Directed reference to another agent, task or chat (no scheduling or authority).' },
|
|
12
|
+
{ keyword: 'CHAT MEMBER', aliases: [], scope: 'chat', kind: 'repeatable-control', description: 'Participant of a chat (`@User` and one agent, or two agents of a task).' },
|
|
13
|
+
{ keyword: 'CHAT MESSAGE', aliases: [], scope: 'chat', kind: 'instruction', description: 'One durable message: `CHAT MESSAGE <sender> <timestamp>` followed by its text.' },
|
|
14
|
+
{ keyword: 'CHAT STATUS', aliases: [], scope: 'chat', kind: 'control', description: '`open`, `waiting-for-user` or `resolved`.' },
|
|
7
15
|
{ keyword: 'PERSONA', aliases: ['PERSONAE'], scope: 'agent', kind: 'instruction', description: 'Role and identity of the agent.' },
|
|
8
|
-
{ keyword: 'GOAL', aliases: ['GOALS'], scope: '
|
|
16
|
+
{ keyword: 'GOAL', aliases: ['GOALS'], scope: 'both', kind: 'instruction', description: "An agent's lasting objective (also used for goal discovery), or a task's bounded work and intended result." },
|
|
9
17
|
{ keyword: 'RULE', aliases: ['RULES'], scope: 'both', kind: 'instruction', description: 'Behavioral constraint (task rules apply only to that task).' },
|
|
10
18
|
{ keyword: 'KNOWLEDGE', aliases: [], scope: 'agent', kind: 'instruction', description: 'Inline knowledge or a reference to relevant material.' },
|
|
11
19
|
{ keyword: 'STYLE', aliases: ['STYLES'], scope: 'agent', kind: 'instruction', description: 'Style of communication or output.' },
|
|
@@ -22,11 +30,10 @@ export const COMMITMENTS = [
|
|
|
22
30
|
{ keyword: 'TEAM', aliases: [], scope: 'agent', kind: 'instruction', description: 'Whom the agent may consult and when.' },
|
|
23
31
|
{ keyword: 'OPEN', aliases: [], scope: 'agent', kind: 'instruction', description: 'Permits learning, optionally with natural-language limits.' },
|
|
24
32
|
{ keyword: 'CLOSED', aliases: [], scope: 'agent', kind: 'flag', description: 'Prohibits automatic learning changes.' },
|
|
25
|
-
{ keyword: 'NOTE', aliases: ['NOTES', 'COMMENT', 'NONCE', 'TODO'], scope: '
|
|
33
|
+
{ keyword: 'NOTE', aliases: ['NOTES', 'COMMENT', 'NONCE', 'TODO'], scope: 'any', kind: 'instruction', description: 'Non-executable commentary.' },
|
|
26
34
|
{ keyword: 'DELETE', aliases: ['CANCEL', 'DISCARD', 'REMOVE'], scope: 'agent', kind: 'instruction', description: 'Withdraws an identified earlier commitment.' },
|
|
27
35
|
{ keyword: 'DICTIONARY', aliases: [], scope: 'agent', kind: 'instruction', description: 'Terminology for the role\'s work.' },
|
|
28
|
-
{ keyword: 'TASK', aliases: [], scope: 'task', kind: 'control', description: '
|
|
29
|
-
{ keyword: 'TASK ID', aliases: [], scope: 'task', kind: 'control', description: 'Stable reference key, distinct from the title.' },
|
|
36
|
+
{ keyword: 'TASK ID', aliases: [], scope: 'task', kind: 'control', description: 'Legacy historical metadata; never identity (the task name is).' },
|
|
30
37
|
{ keyword: 'TASK AGENT', aliases: [], scope: 'task', kind: 'control', description: 'Responsible agent.' },
|
|
31
38
|
{ keyword: 'TASK HARNESS', aliases: [], scope: 'task', kind: 'control', description: 'Required execution harness.' },
|
|
32
39
|
{ keyword: 'TASK MODEL', aliases: [], scope: 'task', kind: 'control', description: 'Required model.' },
|
|
@@ -46,27 +53,64 @@ export const COMMITMENTS = [
|
|
|
46
53
|
/**
|
|
47
54
|
* Lookup from every accepted keyword spelling to its definition.
|
|
48
55
|
*/
|
|
49
|
-
const KEYWORD_LOOKUP = new Map(
|
|
56
|
+
const KEYWORD_LOOKUP = new Map([
|
|
57
|
+
...COMMITMENTS.flatMap((definition) => [definition.keyword, ...definition.aliases].map((keyword) => [keyword, definition])),
|
|
58
|
+
// `DELETE RULE …` is one complete keyword: the withdrawal names the kind of the commitment it withdraws.
|
|
59
|
+
...COMMITMENTS.filter((definition) => definition.kind === 'instruction' && definition.keyword !== 'DELETE').flatMap((target) => ['DELETE', 'CANCEL', 'DISCARD', 'REMOVE'].flatMap((withdraw) => [target.keyword, ...target.aliases].map((keyword) => [`${withdraw} ${keyword}`, COMMITMENTS.find((definition) => definition.keyword === 'DELETE')]))),
|
|
60
|
+
]);
|
|
50
61
|
/**
|
|
51
|
-
*
|
|
62
|
+
* The commitment kind a compound withdrawal names (`DELETE RULE` → `RULE`), if any.
|
|
63
|
+
*
|
|
64
|
+
* @private Book language
|
|
65
|
+
*/
|
|
66
|
+
export function withdrawnKeyword(written) {
|
|
67
|
+
const [, ...rest] = written.trim().split(/\s+/);
|
|
68
|
+
if (!rest.length)
|
|
69
|
+
return undefined;
|
|
70
|
+
const target = KEYWORD_LOOKUP.get(rest.join(' '));
|
|
71
|
+
return target && target.keyword !== 'DELETE' ? target.keyword : undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One all-uppercase word of a commitment keyword (letters only; digits, punctuation or lowercase begin content).
|
|
75
|
+
*/
|
|
76
|
+
const KEYWORD_WORD = /^\p{Lu}[\p{Lu}\p{M}]*$/u;
|
|
77
|
+
/**
|
|
78
|
+
* Fewest letters a complete keyword needs (so `A`, `I` or `AI` starting prose never begin a commitment).
|
|
52
79
|
*/
|
|
53
|
-
const
|
|
80
|
+
const MIN_KEYWORD_LETTERS = 3;
|
|
54
81
|
/**
|
|
55
|
-
* Recognizes a commitment at the beginning of a line.
|
|
82
|
+
* Recognizes a commitment at the beginning of a line by the common boundary rule.
|
|
56
83
|
*
|
|
57
|
-
* The keyword
|
|
84
|
+
* The keyword is the maximal sequence of all-uppercase words at column zero, separated by spaces, with at least three
|
|
85
|
+
* letters in total. A word containing lowercase letters, digits, punctuation or a reference begins the content; once
|
|
86
|
+
* content begins, later uppercase words belong to it. The complete keyword is looked up as a whole: an unknown keyword
|
|
87
|
+
* is never shortened to a known prefix (`TASK SOMETHING` is not `TASK`).
|
|
58
88
|
*
|
|
59
89
|
* @private Book language
|
|
60
90
|
*/
|
|
61
91
|
export function matchCommitmentKeyword(line) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
if (!/^\p{Lu}/u.test(line))
|
|
93
|
+
return undefined;
|
|
94
|
+
const words = [];
|
|
95
|
+
let offset = 0;
|
|
96
|
+
for (const word of line.matchAll(/\S+/g)) {
|
|
97
|
+
if (!KEYWORD_WORD.test(word[0]))
|
|
98
|
+
break;
|
|
99
|
+
words.push(word[0]);
|
|
100
|
+
offset = word.index + word[0].length;
|
|
69
101
|
}
|
|
70
|
-
|
|
102
|
+
const keyword = words.join(' ');
|
|
103
|
+
if (keyword.replace(/\s/g, '').length < MIN_KEYWORD_LETTERS)
|
|
104
|
+
return undefined;
|
|
105
|
+
const definition = KEYWORD_LOOKUP.get(keyword) ?? { keyword, aliases: [], scope: 'any', kind: 'instruction', description: 'Unknown commitment (preserved without effect).', unknown: true };
|
|
106
|
+
return { definition, written: line.slice(0, offset), content: line.slice(offset).trim() };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Whether a line would start a commitment (writers escape such lines in literal content).
|
|
110
|
+
*
|
|
111
|
+
* @private Book language
|
|
112
|
+
*/
|
|
113
|
+
export function startsCommitment(line) {
|
|
114
|
+
return matchCommitmentKeyword(line) !== undefined;
|
|
71
115
|
}
|
|
72
116
|
//# sourceMappingURL=commitments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitments.js","sourceRoot":"","sources":["../../src/book/commitments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commitments.js","sourceRoot":"","sources":["../../src/book/commitments.ts"],"names":[],"mappings":"AAyCA;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAoC;IACxD,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,kDAAkD,EAAE;IACvI,EAAE,OAAO,EAAE,MAAM,EAAE,O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AO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AAC9F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IACzC,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type EntityKind } from './parse.js';
|
|
2
|
+
/**
|
|
3
|
+
* Conventional folder of a source, the documented context former syntax relied on for its kind.
|
|
4
|
+
*
|
|
5
|
+
* @private Book conversion
|
|
6
|
+
*/
|
|
7
|
+
export type LegacyLocation = 'agents' | 'tasks' | 'chats' | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Outcome of converting one source.
|
|
10
|
+
*
|
|
11
|
+
* @private Book conversion
|
|
12
|
+
*/
|
|
13
|
+
export type BookConversion = {
|
|
14
|
+
readonly kind: 'unchanged';
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'converted';
|
|
17
|
+
readonly entity: EntityKind;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly content: string;
|
|
20
|
+
readonly notes: readonly string[];
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'blocked';
|
|
23
|
+
readonly reason: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Converts a Book in former syntax into the canonical form, preserving its name, content, links and history.
|
|
27
|
+
*
|
|
28
|
+
* Former syntax: a plain name line (kind from `ENTITY` or, as documented then, the conventional folder), `ENTITY`
|
|
29
|
+
* lines, a `TASK <name>` header followed by an introduction, and text after one-line controls. Descriptive text without
|
|
30
|
+
* an owner moves under GOAL (tasks), PERSONA (agents, where it was part of the role) or NOTE (chats); lines the new
|
|
31
|
+
* boundary rule would read as commitments are escaped literally. The name is kept exactly (no new date); an ambiguous
|
|
32
|
+
* kind or a name that cannot follow a keyword blocks the conversion instead of guessing.
|
|
33
|
+
*
|
|
34
|
+
* @private Book conversion
|
|
35
|
+
*/
|
|
36
|
+
export declare function convertLegacyBook(source: string, location: LegacyLocation): BookConversion;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { COMMITMENTS, matchCommitmentKeyword } from './commitments.js';
|
|
2
|
+
import { fenceMarker, parseBook } from './parse.js';
|
|
3
|
+
import { DECLARATION_KEYWORD, declarationName, renderCommitment } from './write.js';
|
|
4
|
+
/**
|
|
5
|
+
* Keyword spellings the former parser recognized, longest first (it matched known keywords as prefixes).
|
|
6
|
+
*/
|
|
7
|
+
const FORMER_KEYWORDS = COMMITMENTS.filter((definition) => definition.kind !== 'declaration' || definition.keyword === 'TASK')
|
|
8
|
+
.flatMap((definition) => [definition.keyword, ...definition.aliases])
|
|
9
|
+
.sort((a, b) => b.length - a.length);
|
|
10
|
+
/**
|
|
11
|
+
* How the former parser read a line: a known keyword followed by whitespace or the end of the line.
|
|
12
|
+
*/
|
|
13
|
+
function formerMatch(line) {
|
|
14
|
+
for (const keyword of FORMER_KEYWORDS) {
|
|
15
|
+
if (!line.startsWith(keyword))
|
|
16
|
+
continue;
|
|
17
|
+
const rest = line.slice(keyword.length);
|
|
18
|
+
if (rest !== '' && !/^\s/.test(rest))
|
|
19
|
+
continue;
|
|
20
|
+
return { keyword, content: rest.trim() };
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Canonical keyword of a known spelling (alias resolved).
|
|
26
|
+
*/
|
|
27
|
+
function canonicalKeyword(written) {
|
|
28
|
+
return COMMITMENTS.find((definition) => definition.keyword === written || definition.aliases.includes(written))?.keyword ?? written;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Commitment that receives descriptive text without an owner in former syntax.
|
|
32
|
+
*/
|
|
33
|
+
const DESCRIPTION_KEYWORD = { task: 'GOAL', agent: 'PERSONA', chat: 'NOTE' };
|
|
34
|
+
/**
|
|
35
|
+
* Converts a Book in former syntax into the canonical form, preserving its name, content, links and history.
|
|
36
|
+
*
|
|
37
|
+
* Former syntax: a plain name line (kind from `ENTITY` or, as documented then, the conventional folder), `ENTITY`
|
|
38
|
+
* lines, a `TASK <name>` header followed by an introduction, and text after one-line controls. Descriptive text without
|
|
39
|
+
* an owner moves under GOAL (tasks), PERSONA (agents, where it was part of the role) or NOTE (chats); lines the new
|
|
40
|
+
* boundary rule would read as commitments are escaped literally. The name is kept exactly (no new date); an ambiguous
|
|
41
|
+
* kind or a name that cannot follow a keyword blocks the conversion instead of guessing.
|
|
42
|
+
*
|
|
43
|
+
* @private Book conversion
|
|
44
|
+
*/
|
|
45
|
+
export function convertLegacyBook(source, location) {
|
|
46
|
+
const document = parseBook(source);
|
|
47
|
+
if (document.kind === 'empty')
|
|
48
|
+
return { kind: 'unchanged' };
|
|
49
|
+
const legacy = document.legacy;
|
|
50
|
+
const formerTaskHeader = !document.declaredKind && /^TASK\s/.test(document.lines[document.headerLine] ?? '');
|
|
51
|
+
if (!legacy && !formerTaskHeader)
|
|
52
|
+
return { kind: 'unchanged' };
|
|
53
|
+
if (legacy?.uppercaseName)
|
|
54
|
+
return { kind: 'blocked', reason: `the name "${document.name}" starts with an all-uppercase word, which cannot follow a declaration keyword; choose a representable spelling (e.g. "${declarationName(document.name)}") and edit the first line explicitly` };
|
|
55
|
+
// Kind: the canonical declaration, else ENTITY, else the documented folder convention.
|
|
56
|
+
const header = document.lines[document.headerLine];
|
|
57
|
+
const former = formerMatch(header);
|
|
58
|
+
let entity = document.declaredKind ?? (former?.keyword === 'TASK' ? 'task' : undefined);
|
|
59
|
+
if (legacy?.entity === 'conflict' || legacy?.entity === 'unsupported')
|
|
60
|
+
return { kind: 'blocked', reason: 'its ENTITY declarations are contradictory or unsupported; state the kind explicitly' };
|
|
61
|
+
if (legacy?.entity) {
|
|
62
|
+
if (entity && entity !== legacy.entity)
|
|
63
|
+
return { kind: 'blocked', reason: `its header declares a ${entity} but ENTITY says ${legacy.entity}` };
|
|
64
|
+
entity = legacy.entity;
|
|
65
|
+
}
|
|
66
|
+
const folderKind = location === 'agents' ? 'agent' : location === 'tasks' ? 'task' : location === 'chats' ? 'chat' : undefined;
|
|
67
|
+
if (!entity)
|
|
68
|
+
entity = folderKind;
|
|
69
|
+
if (!entity)
|
|
70
|
+
return { kind: 'blocked', reason: 'its kind is unknown (no ENTITY and not in agents/, tasks/ or chats/); start it with AGENT, TASK or CHAT explicitly' };
|
|
71
|
+
if (folderKind && legacy?.entity && folderKind !== legacy.entity)
|
|
72
|
+
return { kind: 'blocked', reason: `it declares a ${legacy.entity} but lies in ${location}/; move it or state the kind explicitly` };
|
|
73
|
+
const name = former?.keyword === 'TASK' && !document.declaredKind ? former.content : document.name;
|
|
74
|
+
if (!name)
|
|
75
|
+
return { kind: 'blocked', reason: 'it has no name' };
|
|
76
|
+
if (declarationName(name) !== name.replace(/\s+/g, ' ').trim())
|
|
77
|
+
return { kind: 'blocked', reason: `the name "${name}" needs an explicit spelling decision` };
|
|
78
|
+
// Re-read the body as the former parser did: only known keywords started commitments.
|
|
79
|
+
const notes = [];
|
|
80
|
+
const loose = [];
|
|
81
|
+
const body = [];
|
|
82
|
+
let fence;
|
|
83
|
+
let section;
|
|
84
|
+
let introduction = true;
|
|
85
|
+
const escapeContent = (line, message) => {
|
|
86
|
+
// Former message bodies already used the backslash escape; other content did not.
|
|
87
|
+
if (!message && line.startsWith('\\'))
|
|
88
|
+
return `\\${line}`;
|
|
89
|
+
if (!message && fenceMarker(line) === undefined && matchCommitmentKeyword(line))
|
|
90
|
+
return `\\${line}`;
|
|
91
|
+
if (message && !line.startsWith('\\') && matchCommitmentKeyword(line))
|
|
92
|
+
return `\\${line}`;
|
|
93
|
+
return line;
|
|
94
|
+
};
|
|
95
|
+
for (let index = document.headerLine + 1; index < document.lines.length; index++) {
|
|
96
|
+
const line = document.lines[index];
|
|
97
|
+
const marker = fenceMarker(line);
|
|
98
|
+
const match = fence || marker ? undefined : formerMatch(line);
|
|
99
|
+
if (fence) {
|
|
100
|
+
if (marker && marker[0] === fence[0] && marker.length >= fence.length && line.trim() === marker)
|
|
101
|
+
fence = undefined;
|
|
102
|
+
}
|
|
103
|
+
else if (marker)
|
|
104
|
+
fence = marker;
|
|
105
|
+
if (match) {
|
|
106
|
+
introduction = false;
|
|
107
|
+
const keyword = canonicalKeyword(match.keyword);
|
|
108
|
+
const definition = COMMITMENTS.find((item) => item.keyword === keyword);
|
|
109
|
+
const single = definition.kind === 'control' || definition.kind === 'repeatable-control' || definition.kind === 'flag' || definition.kind === 'historical';
|
|
110
|
+
section = { keyword, single, message: keyword === 'CHAT MESSAGE' };
|
|
111
|
+
if (keyword === 'ENTITY') {
|
|
112
|
+
notes.push('removed the redundant ENTITY declaration');
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (keyword === 'TASK') {
|
|
116
|
+
// A later legacy `TASK …` line never declared anything; keep its text as content.
|
|
117
|
+
loose.push(match.content);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const reread = matchCommitmentKeyword(line);
|
|
121
|
+
if (reread && !reread.definition.unknown && reread.definition.keyword === keyword && reread.content === match.content)
|
|
122
|
+
body.push(line);
|
|
123
|
+
else
|
|
124
|
+
body.push(...renderCommitment(match.keyword, match.content));
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (introduction || section?.single) {
|
|
128
|
+
if (line.trim() || loose.length)
|
|
129
|
+
loose.push(fence || marker ? line : line);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
body.push(fence || marker ? line : escapeContent(line, Boolean(section?.message)));
|
|
133
|
+
}
|
|
134
|
+
while (loose.length && !loose[loose.length - 1].trim())
|
|
135
|
+
loose.pop();
|
|
136
|
+
const description = loose.join('\n').trim();
|
|
137
|
+
const lines = [`${DECLARATION_KEYWORD[entity]} ${name.replace(/\s+/g, ' ').trim()}`];
|
|
138
|
+
if (description) {
|
|
139
|
+
lines.push(...renderCommitment(DESCRIPTION_KEYWORD[entity], description));
|
|
140
|
+
notes.push(`moved descriptive text under ${DESCRIPTION_KEYWORD[entity]}`);
|
|
141
|
+
}
|
|
142
|
+
while (body.length && !body[0].trim())
|
|
143
|
+
body.shift();
|
|
144
|
+
if (body.length && entity !== 'chat' && description)
|
|
145
|
+
lines.push('');
|
|
146
|
+
lines.push(...body);
|
|
147
|
+
while (lines.length && !lines[lines.length - 1].trim())
|
|
148
|
+
lines.pop();
|
|
149
|
+
const content = `${lines.join(document.newline)}${document.newline}`;
|
|
150
|
+
const check = parseBook(content);
|
|
151
|
+
if (check.kind !== entity || check.name !== name.replace(/\s+/g, ' ').trim()) {
|
|
152
|
+
return { kind: 'blocked', reason: `the converted Book would not read back as the same ${entity} (${check.diagnostics.map((diagnostic) => diagnostic.message).join(' ')})` };
|
|
153
|
+
}
|
|
154
|
+
return { kind: 'converted', entity, name: check.name, content, notes };
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/book/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAmB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAmBpF;;GAEG;AACH,MAAM,eAAe,GAAsB,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,aAAa,IAAI,UAAU,CAAC,OAAO,KAAK,MAAM,CAAC;KAC5I,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;KACpE,IAAI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,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IACrE,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,sDAAsD,MAAM,KAAK,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IAChL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC3E,CAAC"}
|
package/dist/book/parse.d.ts
CHANGED
|
@@ -18,38 +18,66 @@ export type BookDiagnostic = {
|
|
|
18
18
|
* @private Book language
|
|
19
19
|
*/
|
|
20
20
|
export type BookCommitment = {
|
|
21
|
-
/** Canonical keyword of the commitment (alias resolved). */
|
|
21
|
+
/** Canonical keyword of the commitment (alias resolved; the complete written keyword when unknown). */
|
|
22
22
|
readonly keyword: string;
|
|
23
23
|
/** Keyword spelling written in the source. */
|
|
24
24
|
readonly written: string;
|
|
25
|
-
/** Definition of the commitment. */
|
|
25
|
+
/** Definition of the commitment (`unknown` for undocumented keywords). */
|
|
26
26
|
readonly definition: CommitmentDefinition;
|
|
27
27
|
/** Content on the keyword's own line. */
|
|
28
28
|
readonly value: string;
|
|
29
|
-
/** Full content including continuation lines (trimmed). */
|
|
29
|
+
/** Full content including continuation lines (trimmed; escaped literal lines unescaped). */
|
|
30
30
|
readonly body: string;
|
|
31
|
-
/** Continuation lines only (trimmed). */
|
|
31
|
+
/** Continuation lines only (trimmed; escaped literal lines unescaped). */
|
|
32
32
|
readonly continuation: string;
|
|
33
33
|
/** 0-based index of the keyword line. */
|
|
34
34
|
readonly startLine: number;
|
|
35
35
|
/** 0-based index after the last continuation line. */
|
|
36
36
|
readonly endLine: number;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* The three project entity kinds a Book can define.
|
|
40
|
+
*
|
|
41
|
+
* @private Book language
|
|
42
|
+
*/
|
|
43
|
+
export type EntityKind = 'agent' | 'task' | 'chat';
|
|
44
|
+
/**
|
|
45
|
+
* Details of a source written in a former syntax (plain name line, `ENTITY`, introduction text), recorded only to
|
|
46
|
+
* diagnose it and to prepare an explicitly requested conversion; it never makes the source a valid Book.
|
|
47
|
+
*
|
|
48
|
+
* @private Book language
|
|
49
|
+
*/
|
|
50
|
+
export type LegacySource = {
|
|
51
|
+
/** The first line is a plain name instead of an `AGENT|TASK|CHAT <name>` declaration. */
|
|
52
|
+
readonly plainHeader: boolean;
|
|
53
|
+
/** Kind stated by historical `ENTITY` lines (`conflict` when they disagree, `unsupported` for another value). */
|
|
54
|
+
readonly entity?: EntityKind | 'conflict' | 'unsupported';
|
|
55
|
+
/** The name starts with an all-uppercase word, so it cannot follow a keyword without a spelling decision. */
|
|
56
|
+
readonly uppercaseName?: boolean;
|
|
57
|
+
/** Text between the opening line and the first commitment (a former introduction), as 0-based line range. */
|
|
58
|
+
readonly introduction?: {
|
|
59
|
+
readonly start: number;
|
|
60
|
+
readonly end: number;
|
|
61
|
+
readonly text: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
38
64
|
/**
|
|
39
65
|
* A parsed Book document.
|
|
40
66
|
*
|
|
41
67
|
* @private Book language
|
|
42
68
|
*/
|
|
43
69
|
export type BookDocument = {
|
|
44
|
-
/**
|
|
45
|
-
readonly kind:
|
|
46
|
-
/**
|
|
70
|
+
/** Entity kind declared by the opening commitment; `invalid` without a valid declaration, `empty` for no text. */
|
|
71
|
+
readonly kind: EntityKind | 'empty' | 'invalid';
|
|
72
|
+
/** The entity's display name: the content of the opening declaration (or a legacy plain name line). */
|
|
47
73
|
readonly name: string;
|
|
48
|
-
/**
|
|
74
|
+
/** Kind declared by the opening `AGENT`, `TASK` or `CHAT` commitment. */
|
|
75
|
+
readonly declaredKind?: EntityKind;
|
|
76
|
+
/** Former syntax found in the source (diagnosed; converted only by `ptbk migrate`). */
|
|
77
|
+
readonly legacy?: LegacySource;
|
|
78
|
+
/** 0-based index of the opening line. */
|
|
49
79
|
readonly headerLine: number;
|
|
50
|
-
/**
|
|
51
|
-
readonly intro: string;
|
|
52
|
-
/** Commitments in source order. */
|
|
80
|
+
/** Commitments after the opening declaration, in source order. */
|
|
53
81
|
readonly commitments: readonly BookCommitment[];
|
|
54
82
|
/** Problems found while reading. */
|
|
55
83
|
readonly diagnostics: readonly BookDiagnostic[];
|
|
@@ -59,9 +87,18 @@ export type BookDocument = {
|
|
|
59
87
|
readonly newline: '\n' | '\r\n';
|
|
60
88
|
};
|
|
61
89
|
/**
|
|
62
|
-
*
|
|
90
|
+
* Detects a fence opener/closer (``` or ~~~).
|
|
91
|
+
*
|
|
92
|
+
* @private Book language
|
|
93
|
+
*/
|
|
94
|
+
export declare function fenceMarker(line: string): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Reads a Book: the opening `AGENT <name>`, `TASK <name>` or `CHAT <name>` declaration and the commitments after it.
|
|
63
97
|
*
|
|
64
|
-
*
|
|
98
|
+
* One grammar for every kind: a commitment starts at column zero with a complete uppercase keyword (at least three
|
|
99
|
+
* letters); its content continues until the next commitment. The location of the file never supplies the kind. Fenced
|
|
100
|
+
* blocks and lines escaped with a leading backslash are literal content. Former syntax (a plain name line, `ENTITY`,
|
|
101
|
+
* an introduction under the name) is diagnosed and recorded for explicit conversion, never silently accepted.
|
|
65
102
|
*
|
|
66
103
|
* @private Book language
|
|
67
104
|
*/
|