@possumtech/rummy 0.2.7 → 0.3.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/.env.example +12 -3
- package/EXCEPTIONS.md +46 -0
- package/PLUGINS.md +454 -197
- package/SPEC.md +284 -93
- package/migrations/001_initial_schema.sql +57 -70
- package/package.json +16 -10
- package/service.js +1 -1
- package/src/agent/AgentLoop.js +254 -70
- package/src/agent/ContextAssembler.js +18 -4
- package/src/agent/KnownStore.js +156 -23
- package/src/agent/ProjectAgent.js +5 -4
- package/src/agent/ResponseHealer.js +21 -1
- package/src/agent/TurnExecutor.js +393 -115
- package/src/agent/XmlParser.js +92 -39
- package/src/agent/known_checks.sql +5 -4
- package/src/agent/known_queries.sql +4 -3
- package/src/agent/known_store.sql +45 -15
- package/src/agent/loops.sql +63 -0
- package/src/agent/runs.sql +7 -7
- package/src/agent/schemes.sql +5 -2
- package/src/agent/tokens.js +6 -21
- package/src/agent/turns.sql +13 -4
- package/src/hooks/Hooks.js +18 -0
- package/src/hooks/PluginContext.js +14 -10
- package/src/hooks/RummyContext.js +30 -10
- package/src/hooks/ToolRegistry.js +83 -19
- package/src/llm/LlmProvider.js +27 -8
- package/src/llm/OpenAiClient.js +20 -0
- package/src/llm/OpenRouterClient.js +24 -2
- package/src/llm/XaiClient.js +47 -2
- package/src/plugins/ask_user/README.md +4 -4
- package/src/plugins/ask_user/ask_user.js +8 -7
- package/src/plugins/ask_user/ask_userDoc.js +29 -0
- package/src/plugins/budget/BudgetGuard.js +74 -0
- package/src/plugins/budget/README.md +43 -0
- package/src/plugins/budget/budget.js +79 -0
- package/src/plugins/cp/README.md +5 -4
- package/src/plugins/cp/cp.js +16 -12
- package/src/plugins/cp/cpDoc.js +29 -0
- package/src/plugins/current/README.md +4 -4
- package/src/plugins/current/current.js +12 -10
- package/src/plugins/engine/engine.sql +5 -10
- package/src/plugins/engine/turn_context.sql +13 -13
- package/src/plugins/env/README.md +3 -4
- package/src/plugins/env/env.js +8 -7
- package/src/plugins/env/envDoc.js +29 -0
- package/src/plugins/file/README.md +9 -12
- package/src/plugins/file/file.js +34 -45
- package/src/plugins/get/README.md +2 -2
- package/src/plugins/get/get.js +28 -11
- package/src/plugins/get/getDoc.js +41 -0
- package/src/plugins/hedberg/docs.md +0 -9
- package/src/plugins/hedberg/hedberg.js +4 -6
- package/src/plugins/hedberg/matcher.js +1 -1
- package/src/plugins/hedberg/normalize.js +28 -0
- package/src/plugins/hedberg/patterns.js +31 -33
- package/src/plugins/hedberg/sed.js +17 -10
- package/src/plugins/helpers.js +2 -2
- package/src/plugins/index.js +93 -28
- package/src/plugins/instructions/README.md +6 -2
- package/src/plugins/instructions/instructions.js +21 -5
- package/src/plugins/instructions/preamble.md +9 -5
- package/src/plugins/known/README.md +10 -7
- package/src/plugins/known/known.js +33 -23
- package/src/plugins/known/knownDoc.js +33 -0
- package/src/plugins/mv/README.md +5 -4
- package/src/plugins/mv/mv.js +16 -12
- package/src/plugins/mv/mvDoc.js +31 -0
- package/src/plugins/persona/persona.js +78 -0
- package/src/plugins/previous/README.md +2 -2
- package/src/plugins/previous/previous.js +12 -8
- package/src/plugins/progress/progress.js +44 -12
- package/src/plugins/prompt/README.md +5 -5
- package/src/plugins/prompt/prompt.js +23 -19
- package/src/plugins/rm/README.md +4 -4
- package/src/plugins/rm/rm.js +29 -12
- package/src/plugins/rm/rmDoc.js +30 -0
- package/src/plugins/rpc/README.md +15 -28
- package/src/plugins/rpc/rpc.js +63 -107
- package/src/plugins/set/README.md +13 -12
- package/src/plugins/set/set.js +82 -21
- package/src/plugins/set/setDoc.js +45 -0
- package/src/plugins/sh/README.md +4 -4
- package/src/plugins/sh/sh.js +8 -7
- package/src/plugins/sh/shDoc.js +29 -0
- package/src/plugins/{skills/skills.js → skill/skill.js} +12 -54
- package/src/plugins/summarize/README.md +6 -5
- package/src/plugins/summarize/summarize.js +7 -6
- package/src/plugins/summarize/summarizeDoc.js +33 -0
- package/src/plugins/telemetry/telemetry.js +20 -8
- package/src/plugins/think/README.md +20 -0
- package/src/plugins/think/think.js +5 -0
- package/src/plugins/unknown/README.md +5 -5
- package/src/plugins/unknown/unknown.js +11 -8
- package/src/plugins/unknown/unknownDoc.js +31 -0
- package/src/plugins/update/README.md +3 -8
- package/src/plugins/update/update.js +7 -6
- package/src/plugins/update/updateDoc.js +33 -0
- package/src/server/ClientConnection.js +3 -5
- package/src/server/RpcRegistry.js +52 -4
- package/src/sql/v_model_context.sql +31 -39
- package/src/sql/v_run_log.sql +3 -3
- package/src/agent/prompt_queue.sql +0 -39
- package/src/plugins/ask_user/docs.md +0 -2
- package/src/plugins/cp/docs.md +0 -2
- package/src/plugins/env/docs.md +0 -2
- package/src/plugins/get/docs.md +0 -6
- package/src/plugins/known/docs.md +0 -3
- package/src/plugins/mv/docs.md +0 -2
- package/src/plugins/rm/docs.md +0 -4
- package/src/plugins/set/docs.md +0 -4
- package/src/plugins/sh/docs.md +0 -2
- package/src/plugins/skills/README.md +0 -25
- package/src/plugins/store/README.md +0 -20
- package/src/plugins/store/docs.md +0 -5
- package/src/plugins/store/store.js +0 -52
- package/src/plugins/summarize/docs.md +0 -4
- package/src/plugins/unknown/docs.md +0 -5
- package/src/plugins/update/docs.md +0 -4
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
-- INIT: create_v_model_context
|
|
2
2
|
CREATE VIEW IF NOT EXISTS v_model_context AS
|
|
3
3
|
WITH
|
|
4
|
-
|
|
4
|
+
visible AS (
|
|
5
5
|
SELECT
|
|
6
6
|
ke.run_id
|
|
7
7
|
, ke.id
|
|
8
8
|
, ke.path
|
|
9
9
|
, ke.body
|
|
10
10
|
, ke.scheme
|
|
11
|
-
, ke.
|
|
11
|
+
, ke.status
|
|
12
|
+
, ke.fidelity
|
|
12
13
|
, ke.turn
|
|
13
14
|
, ke.updated_at
|
|
14
15
|
, ke.attributes
|
|
15
16
|
, ke.tokens AS tokens_full
|
|
16
17
|
, CASE
|
|
17
|
-
--
|
|
18
|
-
WHEN ke.
|
|
18
|
+
-- Archived entries not in context
|
|
19
|
+
WHEN ke.fidelity = 'archive' THEN NULL
|
|
20
|
+
-- 202 Accepted (proposed) hidden until resolved
|
|
21
|
+
WHEN ke.status = 202 THEN NULL
|
|
19
22
|
-- Audit schemes (model_visible = 0) hidden
|
|
20
23
|
WHEN s.model_visible = 0 THEN NULL
|
|
21
|
-
--
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
WHEN ke.state = 'stored' THEN NULL
|
|
25
|
-
-- Result/structural states are visible at full fidelity
|
|
26
|
-
WHEN ke.state IN ('pass', 'error', 'warn', 'pattern', 'read', 'info', 'summary') THEN 'full'
|
|
27
|
-
ELSE NULL
|
|
28
|
-
END AS fidelity
|
|
24
|
+
-- Everything else visible at its fidelity
|
|
25
|
+
ELSE ke.fidelity
|
|
26
|
+
END AS visible_fidelity
|
|
29
27
|
FROM known_entries AS ke
|
|
30
28
|
JOIN schemes AS s ON s.name = COALESCE(ke.scheme, 'file')
|
|
31
|
-
WHERE ke.state NOT IN ('proposed')
|
|
32
29
|
),
|
|
33
30
|
projected AS (
|
|
34
31
|
SELECT
|
|
@@ -36,38 +33,37 @@ projected AS (
|
|
|
36
33
|
, id
|
|
37
34
|
, path
|
|
38
35
|
, scheme
|
|
39
|
-
,
|
|
40
|
-
, fidelity
|
|
36
|
+
, status
|
|
37
|
+
, visible_fidelity AS fidelity
|
|
41
38
|
, turn
|
|
42
39
|
, updated_at
|
|
43
40
|
, attributes
|
|
44
41
|
, CASE
|
|
45
|
-
WHEN
|
|
42
|
+
WHEN visible_fidelity IN ('full', 'summary') THEN body
|
|
46
43
|
ELSE ''
|
|
47
44
|
END AS body
|
|
45
|
+
-- Four roles: data, logging, unknown, prompt.
|
|
46
|
+
-- These are structural — see PluginContext.CATEGORIES.
|
|
47
|
+
-- 'tool' is internal (model_visible=0 in practice).
|
|
48
|
+
-- Default is 'logging' — plugins opt into 'data' explicitly.
|
|
48
49
|
, CASE
|
|
49
|
-
WHEN scheme IS NULL
|
|
50
|
-
WHEN scheme
|
|
51
|
-
WHEN scheme IN ('
|
|
52
|
-
WHEN scheme IN ('http', 'https') THEN 'file_index'
|
|
53
|
-
WHEN scheme IN ('known', 'skill') AND state = 'full' THEN 'known'
|
|
54
|
-
WHEN scheme IN ('known', 'skill') THEN 'known_index'
|
|
50
|
+
WHEN scheme IS NULL THEN 'data'
|
|
51
|
+
WHEN scheme IN ('http', 'https') THEN 'data'
|
|
52
|
+
WHEN scheme IN ('known', 'skill') THEN 'data'
|
|
55
53
|
WHEN scheme = 'unknown' THEN 'unknown'
|
|
56
|
-
WHEN scheme
|
|
57
|
-
WHEN scheme = 'summarize' THEN 'structural'
|
|
58
|
-
WHEN scheme = 'update' THEN 'structural'
|
|
54
|
+
WHEN scheme = 'prompt' THEN 'prompt'
|
|
59
55
|
WHEN scheme = 'tool' THEN 'tool'
|
|
60
|
-
ELSE '
|
|
56
|
+
ELSE 'logging'
|
|
61
57
|
END AS category
|
|
62
|
-
FROM
|
|
63
|
-
WHERE
|
|
58
|
+
FROM visible
|
|
59
|
+
WHERE visible_fidelity IS NOT NULL
|
|
64
60
|
)
|
|
65
61
|
SELECT
|
|
66
62
|
run_id
|
|
67
63
|
, path
|
|
68
64
|
, scheme
|
|
69
65
|
, fidelity
|
|
70
|
-
,
|
|
66
|
+
, status
|
|
71
67
|
, body
|
|
72
68
|
, attributes
|
|
73
69
|
, category
|
|
@@ -77,18 +73,14 @@ SELECT
|
|
|
77
73
|
ORDER BY
|
|
78
74
|
CASE category
|
|
79
75
|
WHEN 'tool' THEN 1
|
|
80
|
-
WHEN '
|
|
81
|
-
WHEN '
|
|
82
|
-
WHEN '
|
|
83
|
-
WHEN '
|
|
84
|
-
|
|
85
|
-
WHEN 'structural' THEN 4
|
|
86
|
-
WHEN 'unknown' THEN 5
|
|
87
|
-
WHEN 'prompt' THEN 6
|
|
88
|
-
ELSE 6
|
|
76
|
+
WHEN 'data' THEN 2
|
|
77
|
+
WHEN 'logging' THEN 3
|
|
78
|
+
WHEN 'unknown' THEN 4
|
|
79
|
+
WHEN 'prompt' THEN 5
|
|
80
|
+
ELSE 5
|
|
89
81
|
END
|
|
90
82
|
, CASE scheme WHEN 'skill' THEN 0 ELSE 1 END
|
|
91
|
-
, CASE
|
|
83
|
+
, CASE fidelity
|
|
92
84
|
WHEN 'index' THEN 0
|
|
93
85
|
WHEN 'summary' THEN 1
|
|
94
86
|
ELSE 2
|
package/src/sql/v_run_log.sql
CHANGED
|
@@ -4,8 +4,8 @@ SELECT
|
|
|
4
4
|
ke.run_id
|
|
5
5
|
, ke.path
|
|
6
6
|
, ke.body
|
|
7
|
-
, ke.
|
|
8
|
-
, COALESCE(ke.scheme,
|
|
7
|
+
, ke.status
|
|
8
|
+
, COALESCE(ke.scheme, 'file') AS tool
|
|
9
9
|
, COALESCE(
|
|
10
10
|
json_extract(ke.attributes, '$.command')
|
|
11
11
|
, json_extract(ke.attributes, '$.file')
|
|
@@ -17,7 +17,7 @@ FROM known_entries AS ke
|
|
|
17
17
|
JOIN schemes AS s ON s.name = COALESCE(ke.scheme, 'file')
|
|
18
18
|
WHERE
|
|
19
19
|
ke.scheme IS NOT NULL
|
|
20
|
-
AND ke.
|
|
20
|
+
AND ke.status != 202
|
|
21
21
|
AND s.category NOT IN ('knowledge', 'file')
|
|
22
22
|
AND ke.scheme NOT IN ('system', 'reasoning', 'model', 'content')
|
|
23
23
|
ORDER BY ke.id;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
-- PREP: enqueue_prompt
|
|
2
|
-
INSERT INTO prompt_queue (run_id, mode, model, prompt, config)
|
|
3
|
-
VALUES (:run_id, :mode, :model, :prompt, :config)
|
|
4
|
-
RETURNING id;
|
|
5
|
-
|
|
6
|
-
-- PREP: claim_next_prompt
|
|
7
|
-
UPDATE prompt_queue
|
|
8
|
-
SET status = 'active'
|
|
9
|
-
WHERE
|
|
10
|
-
id = (
|
|
11
|
-
SELECT
|
|
12
|
-
id
|
|
13
|
-
FROM prompt_queue
|
|
14
|
-
WHERE run_id = :run_id AND status = 'pending'
|
|
15
|
-
ORDER BY id
|
|
16
|
-
LIMIT 1
|
|
17
|
-
)
|
|
18
|
-
RETURNING id, run_id, mode, model, prompt, config;
|
|
19
|
-
|
|
20
|
-
-- PREP: complete_prompt
|
|
21
|
-
UPDATE prompt_queue
|
|
22
|
-
SET status = 'completed', result = :result
|
|
23
|
-
WHERE id = :id;
|
|
24
|
-
|
|
25
|
-
-- PREP: abort_active_prompt
|
|
26
|
-
UPDATE prompt_queue
|
|
27
|
-
SET status = 'aborted'
|
|
28
|
-
WHERE run_id = :run_id AND status = 'active';
|
|
29
|
-
|
|
30
|
-
-- PREP: get_pending_prompts
|
|
31
|
-
SELECT id, mode, model, prompt, status, created_at
|
|
32
|
-
FROM prompt_queue
|
|
33
|
-
WHERE run_id = :run_id AND status IN ('pending', 'active')
|
|
34
|
-
ORDER BY id;
|
|
35
|
-
|
|
36
|
-
-- PREP: reset_active_prompts
|
|
37
|
-
UPDATE prompt_queue
|
|
38
|
-
SET status = 'pending'
|
|
39
|
-
WHERE status = 'active';
|
package/src/plugins/cp/docs.md
DELETED
package/src/plugins/env/docs.md
DELETED
package/src/plugins/get/docs.md
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
## <get>[path/to/file]</get> - Load a file or entry into context
|
|
2
|
-
Example: <get>docs/example.txt</get>
|
|
3
|
-
Example: <get>known://auth_flow</get>
|
|
4
|
-
* Entries at state="index" or state="summary" are promoted to full content.
|
|
5
|
-
* Use "known://" paths to recall stored information.
|
|
6
|
-
* When irrelevant or resolved, use <store/> to remove from context.
|
package/src/plugins/mv/docs.md
DELETED
package/src/plugins/rm/docs.md
DELETED
package/src/plugins/set/docs.md
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
## <set path="[path/to/file]">[edit]</set> - Edit a file or entry
|
|
2
|
-
Example: <set path="src/config.js">s/base_url = http:\/\/localhost/base_url = http:\/\/0.0.0.0/g s/port = 3000/port = 8080/g</set>
|
|
3
|
-
* All editing syntaxes supported: s/old/new/, {"search":"old","replace":"new"}, SEARCH/REPLACE blocks
|
|
4
|
-
* Do not use <sh/> or <env/> to read, create, update, or delete files or entries
|
package/src/plugins/sh/docs.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# skills
|
|
2
|
-
|
|
3
|
-
Manages skills and personas via RPC methods. Skills are stackable per-run entries; personas are exclusive per-run configuration.
|
|
4
|
-
|
|
5
|
-
## Registration
|
|
6
|
-
|
|
7
|
-
- **No tool handler** — registers RPC methods on `hooks.rpc.registry`.
|
|
8
|
-
|
|
9
|
-
## RPC Methods
|
|
10
|
-
|
|
11
|
-
### Skills
|
|
12
|
-
- `skill/add` — Load a skill from `config/skills/{name}.md` into the run as a `skill://` entry at full state.
|
|
13
|
-
- `skill/remove` — Remove a skill entry from a run.
|
|
14
|
-
- `getSkills` — List active skills on a run.
|
|
15
|
-
- `listSkills` — List available skill files from disk.
|
|
16
|
-
|
|
17
|
-
### Personas
|
|
18
|
-
- `persona/set` — Set persona on a run. Load from `config/personas/{name}.md` by name, pass raw text, or clear by omitting both.
|
|
19
|
-
- `listPersonas` — List available persona files from disk.
|
|
20
|
-
|
|
21
|
-
## Behavior
|
|
22
|
-
|
|
23
|
-
- Skills stack: multiple skills can be active on a run simultaneously as separate `skill://` entries.
|
|
24
|
-
- Personas are exclusive: setting a persona replaces the previous one (stored as a run column, not an entry).
|
|
25
|
-
- File paths resolve from `RUMMY_HOME` environment variable.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# store
|
|
2
|
-
|
|
3
|
-
Demotes entries from active context to stored (background) state.
|
|
4
|
-
|
|
5
|
-
## Registration
|
|
6
|
-
|
|
7
|
-
- **Tool**: `store`
|
|
8
|
-
- **Modes**: ask, act
|
|
9
|
-
- **Category**: ask
|
|
10
|
-
- **Handler**: Matches entries by pattern, demotes them via `demoteByPattern`, and records the result.
|
|
11
|
-
|
|
12
|
-
## Projection
|
|
13
|
-
|
|
14
|
-
Shows `store {path}`.
|
|
15
|
-
|
|
16
|
-
## Behavior
|
|
17
|
-
|
|
18
|
-
- Pattern queries (globs or body filters) produce a summary of matched paths.
|
|
19
|
-
- Exact path queries report "{path} stored" or "{path} not found".
|
|
20
|
-
- Stored entries remain in the database but are excluded from model context.
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { storePatternResult } from "../helpers.js";
|
|
3
|
-
|
|
4
|
-
export default class Store {
|
|
5
|
-
#core;
|
|
6
|
-
|
|
7
|
-
constructor(core) {
|
|
8
|
-
this.#core = core;
|
|
9
|
-
core.registerScheme({ validStates: ["full", "stored", "pattern"] });
|
|
10
|
-
core.on("handler", this.handler.bind(this));
|
|
11
|
-
core.on("full", this.full.bind(this));
|
|
12
|
-
core.on("summary", this.summary.bind(this));
|
|
13
|
-
const docs = readFileSync(new URL("./docs.md", import.meta.url), "utf8");
|
|
14
|
-
core.filter("instructions.toolDocs", async (content) =>
|
|
15
|
-
content ? `${content}\n\n${docs}` : docs,
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async handler(entry, rummy) {
|
|
20
|
-
const { entries: store, sequence: turn, runId } = rummy;
|
|
21
|
-
const target = entry.attributes.path;
|
|
22
|
-
const bodyFilter = entry.attributes.body || null;
|
|
23
|
-
const isPattern = bodyFilter || target.includes("*");
|
|
24
|
-
const matches = await store.getEntriesByPattern(runId, target, bodyFilter);
|
|
25
|
-
await store.demoteByPattern(runId, target, bodyFilter);
|
|
26
|
-
|
|
27
|
-
if (isPattern) {
|
|
28
|
-
await storePatternResult(
|
|
29
|
-
store,
|
|
30
|
-
runId,
|
|
31
|
-
turn,
|
|
32
|
-
"store",
|
|
33
|
-
target,
|
|
34
|
-
bodyFilter,
|
|
35
|
-
matches,
|
|
36
|
-
);
|
|
37
|
-
} else {
|
|
38
|
-
const paths = matches.map((m) => m.path).join(", ");
|
|
39
|
-
const body =
|
|
40
|
-
matches.length > 0 ? `${paths} stored` : `${target} not found`;
|
|
41
|
-
await store.upsert(runId, turn, entry.resultPath, body, "stored");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
full(entry) {
|
|
46
|
-
return `# store ${entry.attributes.path || entry.path}`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
summary(entry) {
|
|
50
|
-
return this.full(entry);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
## <unknown>[what you need to learn]</unknown> - Track open questions
|
|
2
|
-
Example: <unknown>contents of answer.txt</unknown>
|
|
3
|
-
Example: <unknown>which database adapter is configured</unknown>
|
|
4
|
-
* Use get, env, or ask_user to investigate unknowns
|
|
5
|
-
* When irrelevant or resolved, use <rm/> to remove from context.
|