@lawaty/lacode 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,109 @@
1
+ // src/commands.ts
2
+ var COMMANDS = {
3
+ "context-init": {
4
+ description: "Bootstrap the repository context map (.opencode/context/) via the context-manager agent.",
5
+ agent: "context-manager",
6
+ subtask: true,
7
+ template: `Bootstrap the repository context map.
8
+
9
+ If \`.opencode/context/\` already exists, do NOT start over \u2014 verify and refresh
10
+ it in place (correct stale entries, fill gaps) using the review procedure in
11
+ your system prompt.
12
+
13
+ Otherwise follow the bootstrap procedure in your system prompt: progressive
14
+ exploration (README \u2192 existing docs \u2192 manifests \u2192 top-level structure \u2192 build
15
+ and framework config \u2192 entry points \u2192 selective source), then write the five
16
+ context files inside their size targets.
17
+
18
+ Remember: write conclusions, not inventories. Link to the project's existing
19
+ documentation instead of duplicating it.
20
+
21
+ Report what you created or updated, what you deliberately left out, and
22
+ anything that contradicts the code or existing docs.`
23
+ },
24
+ "context-update": {
25
+ description: "Incrementally update .opencode/context/ after recent work via the context-manager agent.",
26
+ agent: "context-manager",
27
+ subtask: true,
28
+ template: `Incremental context update.
29
+
30
+ Focus: $ARGUMENTS
31
+
32
+ If no focus was given, establish the recent work yourself (git status, git
33
+ diff, git log) and start from those changed files plus their immediate
34
+ architectural neighborhood.
35
+
36
+ Follow the incremental-update procedure in your system prompt: update a
37
+ context file only if this work introduced or revealed information that will
38
+ materially help future agents \u2014 a new boundary or module, a new or moved
39
+ canonical entry point, a changed workflow, a new convention, an architectural
40
+ decision, a new dependency between subsystems, a renamed or moved subsystem,
41
+ or a previously undocumented invariant.
42
+
43
+ Do not edit documentation just because source files changed. No
44
+ timestamp-only edits. If nothing material changed, make no edits and report
45
+ "no update needed".`
46
+ },
47
+ "context-review": {
48
+ description: "Audit .opencode/context/ for staleness, contradictions, excess size, duplication, and missing entry points.",
49
+ agent: "context-manager",
50
+ subtask: true,
51
+ template: `Context review.
52
+
53
+ Everything outside \`.opencode/context/\` is read-only for this run. Do not
54
+ modify source code under any circumstances.
55
+
56
+ Audit the five context files for:
57
+
58
+ - stale information \u2014 verify claims against the actual code
59
+ - contradictions between context files, or between the map and the code
60
+ - excessive size \u2014 consolidate toward the per-file targets in your system
61
+ prompt
62
+ - duplicated information \u2014 one canonical place per fact; link to the
63
+ project's own docs rather than restating them
64
+ - missing canonical entry points for significant subsystems
65
+ - unsupported assumptions \u2014 anything stated as fact that you cannot verify,
66
+ or that lacks a confidence marker
67
+
68
+ Fix what you find in \`.opencode/context/\` only, then report: findings, fixes,
69
+ and anything you could not verify.`
70
+ }
71
+ };
72
+ function applyCommands(cfg, commands = COMMANDS) {
73
+ const target = cfg.command ??= {};
74
+ const added = [];
75
+ const kept = [];
76
+ for (const [name, def] of Object.entries(commands)) {
77
+ if (target[name] !== void 0) {
78
+ kept.push(name);
79
+ continue;
80
+ }
81
+ target[name] = JSON.parse(JSON.stringify(def));
82
+ added.push(name);
83
+ }
84
+ return { added, kept };
85
+ }
86
+ var STANDING_INSTRUCTION = `## Repository context map
87
+
88
+ This project may keep a navigation map in \`.opencode/context/\`. Before broad
89
+ exploration, check whether it exists (\`ls .opencode/context\` \u2014 never the \`glob\`
90
+ tool, which skips hidden directories). If it does, read only the file relevant to
91
+ the task \u2014 architecture.md, contexts.md, conventions.md, workflows.md,
92
+ decisions.md \u2014 then start from the canonical entry points it lists.
93
+
94
+ Source code is authoritative: if the map disagrees with the code, trust the code,
95
+ say so, and never edit source to match the map. Never edit \`.opencode/context/\`
96
+ yourself \u2014 the context-manager agent owns it. Say in your final report if your
97
+ work revealed something that belongs in the map.`;
98
+ function applyInstructions(cfg) {
99
+ const existing = cfg.instructions;
100
+ if (Array.isArray(existing) && existing.length > 0) return { added: false };
101
+ cfg.instructions = [STANDING_INSTRUCTION];
102
+ return { added: true };
103
+ }
104
+ export {
105
+ COMMANDS,
106
+ STANDING_INSTRUCTION,
107
+ applyCommands,
108
+ applyInstructions
109
+ };