@lawaty/lacode 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/agents.js CHANGED
@@ -30,6 +30,7 @@ var ORPHAN_TMP_MS = 60 * 1e3;
30
30
  var CATALOG_TTL_MS = 10 * 60 * 1e3;
31
31
  var STUCK_MIN_AGE_MS = 5 * 60 * 1e3;
32
32
  var STUCK_IDLE_MS = 3 * 60 * 1e3;
33
+ var MAX_CLAIM_AGE_MS = 30 * 60 * 1e3;
33
34
  var HANG_COOLDOWN_MS = 10 * 60 * 1e3;
34
35
  var UNAVAILABLE_COOLDOWN_MS = 60 * 1e3;
35
36
  var MAX_SLOTS = 4;
@@ -73,15 +74,9 @@ Every question of the form "what does this file do", "where is X handled", or
73
74
  that proves it. Never one whole refactor handed over in a single piece \u2014
74
75
  see \`# Task size\` below.
75
76
 
76
- The agents you spawn are the pooled \`explore\` / \`implement\` / \`context\`
77
- bases. **Always spawn the BARE base name and let the plugin choose the slot;
78
- never name a \`-N\` variant** (\`explore-1\`..\`explore-4\`, \`implement-1\`..,
79
- \`context-1\`..). The plugin owns which model every pooled spawn runs on: it
80
- picks the next slot from the pool's weights, current load and cooldowns, and
81
- rewrites your spawn to that variant for you. Naming a variant bypasses that
82
- decision, defeats failover, and can pin work to a cooling or unhealthy model.
83
- If you catch yourself choosing a slot number, you are doing the plugin's job \u2014
84
- spawn \`explore\` and let it decide.
77
+ Spawn the BARE pooled base \u2014 \`explore\`, \`implement\` or \`context\`. The pool
78
+ refuses a \`-N\` variant, and a refusal means spawn the bare base, never a
79
+ different number.
85
80
 
86
81
  # When the pool is unavailable
87
82
 
@@ -201,10 +196,8 @@ When you need to understand the codebase:
201
196
  2. Invoke @explore with specific, focused instructions (e.g. "read src/auth.ts", "grep for 'migration' in *.py files", "list the src/ directory")
202
197
  3. @explore will return its findings \u2014 you process them and plan accordingly
203
198
 
204
- Always spawn the BARE pooled base (\`explore\`, \`implement\`, \`context\`) and let
205
- the plugin choose the slot. Never name a \`-N\` variant (\`explore-1\`..\`explore-4\`);
206
- doing so bypasses the pool's weights, load and cooldowns, which is the one thing
207
- the plugin exists to decide.
199
+ Spawn the BARE pooled base (\`explore\`, \`implement\`, \`context\`); the pool
200
+ refuses \`-N\` variants, and a refusal means spawn the bare base, not another number.
208
201
 
209
202
  If the pool cannot serve a spawn \u2014 every slot cooling or exhausted, or repeated
210
203
  failures \u2014 do NOT fall back to reading or planning from your own inspection.
@@ -462,6 +455,30 @@ You own exactly these five files and nothing else:
462
455
  during work that are not already recorded in the project's own decision
463
456
  log. Concise; variable length.
464
457
 
458
+ A sixth file sits in the same directory and is not yours:
459
+ \`.opencode/context/manager.md\`. It is the client's own statement of intent
460
+ \u2014 what is being worked on, what comes next, what they have settled, and
461
+ what every agent should keep in mind. It deliberately says nothing about
462
+ where code lives: your five files and the source itself are the only
463
+ authority on that, and this file never contradicts them. It has no fixed
464
+ schema \u2014 read the whole file, because every heading in it is direction.
465
+
466
+ You never create, edit, rename, or delete it \u2014 not at bootstrap, not in an
467
+ update, not in a review, and not when a run of your own concludes the work
468
+ has moved on. The client edits it, or asks a live agent to edit it on
469
+ their explicit instruction. Either way it is their hand, never yours.
470
+
471
+ Read it before you write anything. Its \`## Current\` and \`## Next\`
472
+ sections tell you what is actually being worked on, and \`## Confirmed\`
473
+ tells you which of your facts the client has ratified. A fact you are
474
+ writing that appears under \`## Confirmed\` may be stated plainly, without
475
+ a confidence marker; anything else follows your normal rules \u2014 infer
476
+ carefully, mark uncertainty. Never copy its content into the five files.
477
+
478
+ A missing or empty section is not an instruction. It means the client has
479
+ not said, not that you may assume anything \u2014 proceed exactly as you would
480
+ without the file.
481
+
465
482
  Never create, modify, or delete anything outside \`.opencode/context/\`. The
466
483
  \`edit\` permission enforces this. Do not attempt to work around it with bash.
467
484
 
@@ -496,6 +513,11 @@ Then write the five files. For each significant subsystem, give a short
496
513
  reason. This is the single most valuable thing you produce: where an agent
497
514
  should open its editor next.
498
515
 
516
+ manager.md is created for the client by the plugin, not by you; if it is
517
+ missing anyway, mention once in your final report that they can add it
518
+ themselves to record what is being worked on, what comes next, and what
519
+ they have ratified. Never create it.
520
+
499
521
  # Incremental update
500
522
 
501
523
  Trigger: \`.opencode/context/\` exists and work has just been done here.
@@ -523,6 +545,14 @@ that is already stated in another context file \u2014 one fact has one home, and
523
545
  the other files link to it. If nothing material changed, make no edits and
524
546
  report "no update needed".
525
547
 
548
+ Before editing, re-read manager.md: its \`## Current\` and \`## Next\`
549
+ sections tell you what the client is actually working on, and its
550
+ \`## Confirmed\` section settles which of your facts are ratified. If what
551
+ you are about to write would place the code somewhere the client never
552
+ described, trust the code, make the edit the code justifies, and report
553
+ the gap in your final message \u2014 never reconcile the two sides silently,
554
+ and never edit manager.md to close it.
555
+
526
556
  # Minimal exploration
527
557
 
528
558
  Default shape:
@@ -617,9 +647,14 @@ Audit the five files for:
617
647
  - duplicated information \u2014 one canonical place per fact
618
648
  - missing canonical entry points for significant subsystems
619
649
  - unsupported assumptions \u2014 anything unmarked that you cannot verify
650
+ - manager.md, if present: is \`## Current\` and \`## Next\` still true of
651
+ recent work, is every \`## Confirmed\` entry still true of the code, has
652
+ it outgrown roughly 150 lines \u2014 report findings, but never edit, prune,
653
+ or reorganize it; that is the client's call
620
654
 
621
- Fix problems only in \`.opencode/context/\`. Never modify source code during a
622
- review. Report what you found, what you fixed, and what you could not verify.
655
+ Fix problems only in the five files you own \u2014 never in manager.md, which
656
+ belongs to the client. Never modify source code during a review. Report
657
+ what you found, what you fixed, and what you could not verify.
623
658
 
624
659
  # Reporting
625
660
 
@@ -637,7 +672,9 @@ Finish with a short report:
637
672
  "edit": {
638
673
  "*": "deny",
639
674
  "*/.opencode/context/**": "allow",
640
- ".opencode/context/**": "allow"
675
+ ".opencode/context/**": "allow",
676
+ "*/.opencode/context/manager.md": "deny",
677
+ ".opencode/context/manager.md": "deny"
641
678
  },
642
679
  "bash": {
643
680
  "*": "deny",
package/dist/commands.js CHANGED
@@ -19,7 +19,13 @@ Remember: write conclusions, not inventories. Link to the project's existing
19
19
  documentation instead of duplicating it.
20
20
 
21
21
  Report what you created or updated, what you deliberately left out, and
22
- anything that contradicts the code or existing docs.`
22
+ anything that contradicts the code or existing docs.
23
+
24
+ If \`.opencode/context/manager.md\` does not exist, mention in your final
25
+ report that the client can add it themselves \u2014 their own file with
26
+ \`## Current\`, \`## Next\`, \`## Confirmed\` and \`## Instructions\` \u2014 for what
27
+ is being worked on, what comes next, what they have ratified, and standing
28
+ direction. Never create it.`
23
29
  },
24
30
  "context-update": {
25
31
  description: "Incrementally update .opencode/context/ after recent work via the context agent.",
@@ -50,8 +56,9 @@ timestamp-only edits. If nothing material changed, make no edits and report
50
56
  subtask: true,
51
57
  template: `Context review.
52
58
 
53
- Everything outside \`.opencode/context/\` is read-only for this run. Do not
54
- modify source code under any circumstances.
59
+ Everything outside the five context files is read-only for this run \u2014
60
+ including \`manager.md\`, which belongs to the client. Do not modify source
61
+ code under any circumstances.
55
62
 
56
63
  Audit the five context files for:
57
64
 
@@ -64,6 +71,9 @@ Audit the five context files for:
64
71
  - missing canonical entry points for significant subsystems
65
72
  - unsupported assumptions \u2014 anything stated as fact that you cannot verify,
66
73
  or that lacks a confidence marker
74
+ - \`manager.md\`, if present: is \`## Current\` and \`## Next\` still true of
75
+ recent work, is every \`## Confirmed\` entry still true of the code, has it
76
+ outgrown roughly 150 lines \u2014 report findings, but never edit it
67
77
 
68
78
  Fix what you find in \`.opencode/context/\` only, then report: findings, fixes,
69
79
  and anything you could not verify.`
@@ -94,7 +104,8 @@ Print one PASS/FAIL line per check below, with the exact fix for any FAIL.
94
104
  trap: an id that is a valid gateway route but is NOT in the plugin's
95
105
  \`omniroute.models\` allowlist fails with
96
106
  \`ProviderModelNotFoundError: Model not found\`; the fix is to add that id to
97
- the \`models\` array, or use the always-registered \`auto\`.
107
+ the \`models\` array, or set it as \`combo\` \u2014 the combo id is registered
108
+ whether or not the gateway advertises it, so it needs no allowlist entry.
98
109
 
99
110
  Change nothing. Print a final one-line summary of failures.`
100
111
  }
@@ -113,26 +124,49 @@ function applyCommands(cfg, commands = COMMANDS) {
113
124
  }
114
125
  return { added, kept };
115
126
  }
127
+ var INSTRUCTION_MARKER = "<!-- lacode:context-map-instruction:v1 -->";
128
+ var INSTRUCTION_OPT_OUT = "<!-- lacode:context-map-instruction:off -->";
116
129
  var STANDING_INSTRUCTION = `## Repository context map
117
130
 
118
131
  This project may keep a navigation map in \`.opencode/context/\`. Before broad
119
132
  exploration, check whether it exists (\`ls .opencode/context\` \u2014 never the \`glob\`
120
- tool, which skips hidden directories). If it does, read only the file relevant to
121
- the task \u2014 architecture.md, contexts.md, conventions.md, workflows.md,
122
- decisions.md \u2014 then start from the canonical entry points it lists.
123
-
124
- Source code is authoritative: if the map disagrees with the code, trust the code,
125
- say so, and never edit source to match the map. Never edit \`.opencode/context/\`
126
- yourself \u2014 the context agent owns it. Say in your final report if your
127
- work revealed something that belongs in the map.`;
133
+ tool, which skips hidden directories). If \`manager.md\` exists there, read it
134
+ first: it is the client's own statement of intent \u2014 what is being worked on,
135
+ what comes next, \`## Confirmed\` lists what the client has ratified, and
136
+ \`## Instructions\` holds standing managerial directions. It outranks every
137
+ other context file and every inference of yours about what matters right now.
138
+ It says nothing about where code lives, so it cannot contradict the code;
139
+ treat its \`## Confirmed\` entries as settled decisions, not as a licence to
140
+ skip reading the code. Any heading in it is direction, so read the whole
141
+ file rather than only the sections above. The rest of the map remains usable,
142
+ just unratified where \`## Confirmed\` does not cover it. Then read only the
143
+ file relevant to the task \u2014 \`architecture.md\`, \`contexts.md\`,
144
+ \`conventions.md\`, \`workflows.md\`, \`decisions.md\` \u2014 and start from the
145
+ canonical entry points it lists.
146
+
147
+ Source code is authoritative: if the map disagrees with the code,
148
+ trust the code and say so; never edit source to match it.
149
+ Never edit the five context files yourself \u2014 the context agent owns them.
150
+ \`manager.md\` is the client's own file and the context agent is explicitly
151
+ permission-denied from writing it. You may write it only when the client
152
+ explicitly asks you to in this conversation, and then only what they asked
153
+ for; never on your own initiative, and never to "keep it up to date". Say in
154
+ your final report if your work revealed something that belongs to the map, or
155
+ if \`manager.md\` and the code disagree.`;
128
156
  function applyInstructions(cfg) {
129
- const existing = cfg.instructions;
130
- if (Array.isArray(existing) && existing.length > 0) return { added: false };
131
- cfg.instructions = [STANDING_INSTRUCTION];
157
+ const existing = Array.isArray(cfg.instructions) ? cfg.instructions : [];
158
+ const texts = existing.filter((e) => typeof e === "string");
159
+ if (texts.some((e) => e.includes(INSTRUCTION_OPT_OUT))) return { added: false };
160
+ if (texts.some((e) => e.includes(INSTRUCTION_MARKER))) return { added: false };
161
+ cfg.instructions = [...existing, `${INSTRUCTION_MARKER}
162
+
163
+ ${STANDING_INSTRUCTION}`];
132
164
  return { added: true };
133
165
  }
134
166
  export {
135
167
  COMMANDS,
168
+ INSTRUCTION_MARKER,
169
+ INSTRUCTION_OPT_OUT,
136
170
  STANDING_INSTRUCTION,
137
171
  applyCommands,
138
172
  applyInstructions