@lawaty/lacode 0.4.1 → 0.5.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/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;
@@ -45,6 +46,9 @@ var USER_MODELS_PATH = join2(USER_CONFIG_DIR, "pool.json");
45
46
  var USER_MODELS_TXT = join2(USER_CONFIG_DIR, "pool.txt");
46
47
  var CHILD_MEMORY_MS = 30 * 6e4;
47
48
 
49
+ // src/lib/manager-directive.ts
50
+ var MANAGER_AGENT_NAME = "manager";
51
+
48
52
  // src/agents.ts
49
53
  var POOLED_BASES = ["explore", "implement", "context"];
50
54
  var AGENTS = {
@@ -454,6 +458,30 @@ You own exactly these five files and nothing else:
454
458
  during work that are not already recorded in the project's own decision
455
459
  log. Concise; variable length.
456
460
 
461
+ A sixth file sits in the same directory and is not yours:
462
+ \`.opencode/context/manager.md\`. It is the client's own statement of intent
463
+ \u2014 what is being worked on, what comes next, what they have settled, and
464
+ what every agent should keep in mind. It deliberately says nothing about
465
+ where code lives: your five files and the source itself are the only
466
+ authority on that, and this file never contradicts them. It has no fixed
467
+ schema \u2014 read the whole file, because every heading in it is direction.
468
+
469
+ You never create, edit, rename, or delete it \u2014 not at bootstrap, not in an
470
+ update, not in a review, and not when a run of your own concludes the work
471
+ has moved on. The client edits it, or asks a live agent to edit it on
472
+ their explicit instruction. Either way it is their hand, never yours.
473
+
474
+ Read it before you write anything. Its \`## Current\` and \`## Next\`
475
+ sections tell you what is actually being worked on, and \`## Confirmed\`
476
+ tells you which of your facts the client has ratified. A fact you are
477
+ writing that appears under \`## Confirmed\` may be stated plainly, without
478
+ a confidence marker; anything else follows your normal rules \u2014 infer
479
+ carefully, mark uncertainty. Never copy its content into the five files.
480
+
481
+ A missing or empty section is not an instruction. It means the client has
482
+ not said, not that you may assume anything \u2014 proceed exactly as you would
483
+ without the file.
484
+
457
485
  Never create, modify, or delete anything outside \`.opencode/context/\`. The
458
486
  \`edit\` permission enforces this. Do not attempt to work around it with bash.
459
487
 
@@ -488,6 +516,11 @@ Then write the five files. For each significant subsystem, give a short
488
516
  reason. This is the single most valuable thing you produce: where an agent
489
517
  should open its editor next.
490
518
 
519
+ manager.md is created for the client by the plugin, not by you; if it is
520
+ missing anyway, mention once in your final report that they can add it
521
+ themselves to record what is being worked on, what comes next, and what
522
+ they have ratified. Never create it.
523
+
491
524
  # Incremental update
492
525
 
493
526
  Trigger: \`.opencode/context/\` exists and work has just been done here.
@@ -515,6 +548,14 @@ that is already stated in another context file \u2014 one fact has one home, and
515
548
  the other files link to it. If nothing material changed, make no edits and
516
549
  report "no update needed".
517
550
 
551
+ Before editing, re-read manager.md: its \`## Current\` and \`## Next\`
552
+ sections tell you what the client is actually working on, and its
553
+ \`## Confirmed\` section settles which of your facts are ratified. If what
554
+ you are about to write would place the code somewhere the client never
555
+ described, trust the code, make the edit the code justifies, and report
556
+ the gap in your final message \u2014 never reconcile the two sides silently,
557
+ and never edit manager.md to close it.
558
+
518
559
  # Minimal exploration
519
560
 
520
561
  Default shape:
@@ -609,9 +650,14 @@ Audit the five files for:
609
650
  - duplicated information \u2014 one canonical place per fact
610
651
  - missing canonical entry points for significant subsystems
611
652
  - unsupported assumptions \u2014 anything unmarked that you cannot verify
653
+ - manager.md, if present: is \`## Current\` and \`## Next\` still true of
654
+ recent work, is every \`## Confirmed\` entry still true of the code, has
655
+ it outgrown roughly 150 lines \u2014 report findings, but never edit, prune,
656
+ or reorganize it; that is the client's call
612
657
 
613
- Fix problems only in \`.opencode/context/\`. Never modify source code during a
614
- review. Report what you found, what you fixed, and what you could not verify.
658
+ Fix problems only in the five files you own \u2014 never in manager.md, which
659
+ belongs to the client. Never modify source code during a review. Report
660
+ what you found, what you fixed, and what you could not verify.
615
661
 
616
662
  # Reporting
617
663
 
@@ -629,7 +675,9 @@ Finish with a short report:
629
675
  "edit": {
630
676
  "*": "deny",
631
677
  "*/.opencode/context/**": "allow",
632
- ".opencode/context/**": "allow"
678
+ ".opencode/context/**": "allow",
679
+ "*/.opencode/context/manager.md": "deny",
680
+ ".opencode/context/manager.md": "deny"
633
681
  },
634
682
  "bash": {
635
683
  "*": "deny",
@@ -677,6 +725,68 @@ Finish with a short report:
677
725
  }
678
726
  }
679
727
  };
728
+ var MANAGER_AGENT = {
729
+ description: "Records and edits the client's .opencode/context/manager.md. Run only by the /manager-directive command; no agent or subagent can spawn it.",
730
+ mode: "subagent",
731
+ hidden: true,
732
+ temperature: 0.1,
733
+ prompt: `# Role
734
+
735
+ You maintain one file and nothing else: \`.opencode/context/manager.md\`, the
736
+ client's own statement of intent. You are not a coding agent and you touch no
737
+ other path.
738
+
739
+ You are run only by the \`/manager-directive\` command. The client tells you what
740
+ they want recorded or changed in the file; you apply that to the file and report
741
+ what you changed. You have no permission to edit anything else, and you need
742
+ none.
743
+
744
+ # The file
745
+
746
+ It records what is being worked on (\`## Current\`), what comes next
747
+ (\`## Next\`), what the client has ratified (\`## Confirmed\`), and standing
748
+ direction (\`## Instructions\`). The client may use any headings \u2014 every heading
749
+ is direction, and the four above are a convenience, not a schema.
750
+
751
+ # How to apply a directive
752
+
753
+ - Do what the client asked. "Append", "rewrite Current", "move X to Confirmed",
754
+ "add a heading" all mean exactly that; a bare sentence goes under the most
755
+ fitting existing heading, and you create one only if none fits.
756
+ - Never invent facts, never record your own inference as the client's, and never
757
+ tidy, reorder or delete content the client did not ask you to touch.
758
+ - \`## Current\` is rewritten, not appended to, so it does not become a running
759
+ history.
760
+ - Keep the file concise. If it is growing past roughly 150 lines, say so.
761
+
762
+ # Reporting
763
+
764
+ Report briefly what you changed and where. Do not edit any other file.`,
765
+ permission: {
766
+ // Read is scoped to the one file too: the directive is about manager.md, and
767
+ // nothing else is any of this agent's business.
768
+ read: {
769
+ "*": "deny",
770
+ ".opencode/context/manager.md": "allow",
771
+ "*/.opencode/context/manager.md": "allow"
772
+ },
773
+ glob: "deny",
774
+ grep: "deny",
775
+ list: "deny",
776
+ edit: {
777
+ "*": "deny",
778
+ ".opencode/context/manager.md": "allow",
779
+ "*/.opencode/context/manager.md": "allow"
780
+ },
781
+ bash: "deny",
782
+ webfetch: "deny",
783
+ websearch: "deny",
784
+ question: "allow",
785
+ task: {
786
+ "*": "deny"
787
+ }
788
+ }
789
+ };
680
790
  function buildAgentSet() {
681
791
  const set = { ...AGENTS };
682
792
  for (const base of POOLED_BASES) {
@@ -692,6 +802,7 @@ function buildAgentSet() {
692
802
  set[`${base}-${slot}`] = variant;
693
803
  }
694
804
  }
805
+ set[MANAGER_AGENT_NAME] = MANAGER_AGENT;
695
806
  return set;
696
807
  }
697
808
  function applyAgents(cfg, agents = buildAgentSet(), opts = {}) {
@@ -711,6 +822,7 @@ function applyAgents(cfg, agents = buildAgentSet(), opts = {}) {
711
822
  }
712
823
  export {
713
824
  AGENTS,
825
+ MANAGER_AGENT,
714
826
  POOLED_BASES,
715
827
  applyAgents,
716
828
  buildAgentSet
package/dist/commands.js CHANGED
@@ -1,3 +1,6 @@
1
+ // src/lib/manager-directive.ts
2
+ var MANAGER_AGENT_NAME = "manager";
3
+
1
4
  // src/commands.ts
2
5
  var COMMANDS = {
3
6
  "context-init": {
@@ -19,7 +22,13 @@ Remember: write conclusions, not inventories. Link to the project's existing
19
22
  documentation instead of duplicating it.
20
23
 
21
24
  Report what you created or updated, what you deliberately left out, and
22
- anything that contradicts the code or existing docs.`
25
+ anything that contradicts the code or existing docs.
26
+
27
+ If \`.opencode/context/manager.md\` does not exist, mention in your final
28
+ report that the client can add it themselves \u2014 their own file with
29
+ \`## Current\`, \`## Next\`, \`## Confirmed\` and \`## Instructions\` \u2014 for what
30
+ is being worked on, what comes next, what they have ratified, and standing
31
+ direction. Never create it.`
23
32
  },
24
33
  "context-update": {
25
34
  description: "Incrementally update .opencode/context/ after recent work via the context agent.",
@@ -50,8 +59,9 @@ timestamp-only edits. If nothing material changed, make no edits and report
50
59
  subtask: true,
51
60
  template: `Context review.
52
61
 
53
- Everything outside \`.opencode/context/\` is read-only for this run. Do not
54
- modify source code under any circumstances.
62
+ Everything outside the five context files is read-only for this run \u2014
63
+ including \`manager.md\`, which belongs to the client. Do not modify source
64
+ code under any circumstances.
55
65
 
56
66
  Audit the five context files for:
57
67
 
@@ -64,9 +74,22 @@ Audit the five context files for:
64
74
  - missing canonical entry points for significant subsystems
65
75
  - unsupported assumptions \u2014 anything stated as fact that you cannot verify,
66
76
  or that lacks a confidence marker
77
+ - \`manager.md\`, if present: is \`## Current\` and \`## Next\` still true of
78
+ recent work, is every \`## Confirmed\` entry still true of the code, has it
79
+ outgrown roughly 150 lines \u2014 report findings, but never edit it
67
80
 
68
81
  Fix what you find in \`.opencode/context/\` only, then report: findings, fixes,
69
82
  and anything you could not verify.`
83
+ },
84
+ "manager-directive": {
85
+ description: "Apply a client instruction to .opencode/context/manager.md. Client-only \u2014 runs the manager agent, the only writer of that file.",
86
+ agent: MANAGER_AGENT_NAME,
87
+ subtask: true,
88
+ template: `Apply this instruction to \`.opencode/context/manager.md\`, and edit only that file:
89
+
90
+ $ARGUMENTS
91
+
92
+ Follow the rules for the file in your system prompt, then report what you changed.`
70
93
  },
71
94
  "lacode-doctor": {
72
95
  description: "Check the LaCode setup \u2014 pool slots, model resolution, and the OmniRoute gateway. Report only; changes nothing.",
@@ -94,7 +117,8 @@ Print one PASS/FAIL line per check below, with the exact fix for any FAIL.
94
117
  trap: an id that is a valid gateway route but is NOT in the plugin's
95
118
  \`omniroute.models\` allowlist fails with
96
119
  \`ProviderModelNotFoundError: Model not found\`; the fix is to add that id to
97
- the \`models\` array, or use the always-registered \`auto\`.
120
+ the \`models\` array, or set it as \`combo\` \u2014 the combo id is registered
121
+ whether or not the gateway advertises it, so it needs no allowlist entry.
98
122
 
99
123
  Change nothing. Print a final one-line summary of failures.`
100
124
  }
@@ -113,26 +137,49 @@ function applyCommands(cfg, commands = COMMANDS) {
113
137
  }
114
138
  return { added, kept };
115
139
  }
140
+ var INSTRUCTION_MARKER = "<!-- lacode:context-map-instruction:v1 -->";
141
+ var INSTRUCTION_OPT_OUT = "<!-- lacode:context-map-instruction:off -->";
116
142
  var STANDING_INSTRUCTION = `## Repository context map
117
143
 
118
144
  This project may keep a navigation map in \`.opencode/context/\`. Before broad
119
145
  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.`;
146
+ tool, which skips hidden directories). If \`manager.md\` exists there, read it
147
+ first: it is the client's own statement of intent \u2014 what is being worked on,
148
+ what comes next, \`## Confirmed\` lists what the client has ratified, and
149
+ \`## Instructions\` holds standing managerial directions. It outranks every
150
+ other context file and every inference of yours about what matters right now.
151
+ It says nothing about where code lives, so it cannot contradict the code;
152
+ treat its \`## Confirmed\` entries as settled decisions, not as a licence to
153
+ skip reading the code. Any heading in it is direction, so read the whole
154
+ file rather than only the sections above. The rest of the map remains usable,
155
+ just unratified where \`## Confirmed\` does not cover it. Then read only the
156
+ file relevant to the task \u2014 \`architecture.md\`, \`contexts.md\`,
157
+ \`conventions.md\`, \`workflows.md\`, \`decisions.md\` \u2014 and start from the
158
+ canonical entry points it lists.
159
+
160
+ Source code is authoritative: if the map disagrees with the code,
161
+ trust the code and say so; never edit source to match it.
162
+ Never edit the five context files yourself \u2014 the context agent owns them.
163
+ \`manager.md\` is the client's own file and the context agent is explicitly
164
+ permission-denied from writing it. You may write it only when the client
165
+ explicitly asks you to in this conversation, and then only what they asked
166
+ for; never on your own initiative, and never to "keep it up to date". Say in
167
+ your final report if your work revealed something that belongs to the map, or
168
+ if \`manager.md\` and the code disagree.`;
128
169
  function applyInstructions(cfg) {
129
- const existing = cfg.instructions;
130
- if (Array.isArray(existing) && existing.length > 0) return { added: false };
131
- cfg.instructions = [STANDING_INSTRUCTION];
170
+ const existing = Array.isArray(cfg.instructions) ? cfg.instructions : [];
171
+ const texts = existing.filter((e) => typeof e === "string");
172
+ if (texts.some((e) => e.includes(INSTRUCTION_OPT_OUT))) return { added: false };
173
+ if (texts.some((e) => e.includes(INSTRUCTION_MARKER))) return { added: false };
174
+ cfg.instructions = [...existing, `${INSTRUCTION_MARKER}
175
+
176
+ ${STANDING_INSTRUCTION}`];
132
177
  return { added: true };
133
178
  }
134
179
  export {
135
180
  COMMANDS,
181
+ INSTRUCTION_MARKER,
182
+ INSTRUCTION_OPT_OUT,
136
183
  STANDING_INSTRUCTION,
137
184
  applyCommands,
138
185
  applyInstructions