pi-soly 2.1.3 → 2.1.4

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.
Files changed (3) hide show
  1. package/core.ts +37 -1
  2. package/index.ts +8 -2
  3. package/package.json +1 -1
package/core.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  import * as fs from "node:fs";
17
17
  import * as os from "node:os";
18
18
  import * as path from "node:path";
19
+ import { fileURLToPath } from "node:url";
19
20
 
20
21
  // Shared leaf utilities now live in util.ts; re-exported here so existing
21
22
  // `import { ... } from "./core.ts"` call sites keep working unchanged.
@@ -58,7 +59,8 @@ export type RuleSource =
58
59
  | "phase-soly"
59
60
  | "project-agents"
60
61
  | "global-agents"
61
- | "phase-agents";
62
+ | "phase-agents"
63
+ | "built-in";
62
64
 
63
65
  export interface RuleFrontmatter {
64
66
  description?: string;
@@ -259,6 +261,40 @@ function loadRulesFromSource(spec: SourceSpec): RuleFile[] {
259
261
  return rules;
260
262
  }
261
263
 
264
+ /**
265
+ * Resolve the path to the extension's `built-in-rules/` directory. Lives
266
+ * at `<package>/built-in-rules/` relative to the compiled module. We use
267
+ * `fileURLToPath(import.meta.url)` so this works whether the package is
268
+ * loaded directly from source (Bun, tsx) or from compiled output.
269
+ *
270
+ * `here` is the directory containing this core.ts file (i.e. the package
271
+ * root for source, the package root for compiled output too — both files
272
+ * live alongside package.json), so we don't need to traverse up.
273
+ */
274
+ export function builtInRulesDir(): string {
275
+ const here = path.dirname(fileURLToPath(import.meta.url));
276
+ return path.resolve(here, "built-in-rules");
277
+ }
278
+
279
+ /**
280
+ * Load every markdown rule from the extension's `built-in-rules/` directory.
281
+ * These rules ship with the soly extension and are always present in the
282
+ * system prompt. Source spec uses priority=10 (highest), so a user rule at
283
+ * the same relPath is silently dropped into `overridden[]` — built-in
284
+ * rules win by design. `sourceLabel: "soly"` makes them visible in
285
+ * `/rules list` so users know which rules come from the package itself.
286
+ */
287
+ export function loadBuiltInRules(): RuleFile[] {
288
+ const dir = builtInRulesDir();
289
+ if (!fs.existsSync(dir)) return [];
290
+ return loadRulesFromSource({
291
+ dir,
292
+ source: "built-in",
293
+ sourceLabel: "soly",
294
+ priority: 10,
295
+ });
296
+ }
297
+
262
298
  export function loadAllRules(sources: SourceSpec[]): {
263
299
  rules: RuleFile[];
264
300
  overridden: string[];
package/index.ts CHANGED
@@ -34,6 +34,8 @@ import {
34
34
  extractFilePathsFromPrompt,
35
35
  formatTok,
36
36
  loadAllRules,
37
+ builtInRulesDir,
38
+ loadBuiltInRules,
37
39
  loadPhaseRules,
38
40
  loadProjectState,
39
41
  matchesGlob,
@@ -441,10 +443,14 @@ export default function solyExtension(pi: ExtensionAPI) {
441
443
  // Project rules always beat global rules. `.agents/rules.local/` is
442
444
  // gitignored — for personal overrides on top of the project's rules.
443
445
  // `.agents/rules/` is the vendor-neutral project-level convention.
446
+ // Built-in rules ship with the extension (priority=10 — highest) and
447
+ // can't be overridden: a user rule at the same relPath is dropped
448
+ // silently into the `overridden[]` list (see loadAllRules).
444
449
  ruleSources = [
445
- { dir: path.join(ctx.cwd, ".agents", "rules.local"), source: "project-agents", sourceLabel: "local", priority: 5 },
446
- { dir: path.join(ctx.cwd, ".agents", "rules"), source: "project-agents", sourceLabel: "agents", priority: 3 },
450
+ { dir: builtInRulesDir(), source: "built-in", sourceLabel: "soly", priority: 10 },
447
451
  { dir: path.join(os.homedir(), ".agents", "rules"), source: "global-agents", sourceLabel: "agents", priority: 1 },
452
+ { dir: path.join(ctx.cwd, ".agents", "rules"), source: "project-agents", sourceLabel: "agents", priority: 3 },
453
+ { dir: path.join(ctx.cwd, ".agents", "rules.local"), source: "project-agents", sourceLabel: "local", priority: 5 },
448
454
  ];
449
455
  refreshRules();
450
456
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-soly",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Project management + workflow framework for pi-coding-agent. Plans, state, MANDATORY rules, self-review, multi-question picker, native footer + welcome chrome — one npm install, zero config. The LLM drives the workflow inline via the soly_workflow tool — no external subagent plugin.",
5
5
  "type": "module",
6
6
  "main": "index.ts",