@topce/pizx 0.3.0 → 0.4.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/README.md +51 -0
- package/dist/cli.js +87 -4
- package/dist/cli.js.map +4 -4
- package/dist/index.js +90 -4
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113,6 +113,37 @@ function pickModel(preferred) {
|
|
|
113
113
|
return models[0];
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// src/skill-loader.ts
|
|
117
|
+
import { readFile } from "node:fs/promises";
|
|
118
|
+
import { homedir as homedir2 } from "node:os";
|
|
119
|
+
import { join as join2 } from "node:path";
|
|
120
|
+
var SKILL_PATHS = [
|
|
121
|
+
".pi/skills",
|
|
122
|
+
".agents/skills",
|
|
123
|
+
"skills",
|
|
124
|
+
join2(homedir2(), ".pi", "agent", "skills"),
|
|
125
|
+
join2(homedir2(), ".codewhale", "skills"),
|
|
126
|
+
join2(homedir2(), ".claude", "skills")
|
|
127
|
+
];
|
|
128
|
+
async function loadSkillContent(name) {
|
|
129
|
+
for (const base of SKILL_PATHS) {
|
|
130
|
+
const candidate = join2(base, name, "SKILL.md");
|
|
131
|
+
try {
|
|
132
|
+
return await readFile(candidate, "utf-8");
|
|
133
|
+
} catch {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
async function loadSkillContents(names) {
|
|
139
|
+
const map = /* @__PURE__ */ new Map();
|
|
140
|
+
for (const name of names) {
|
|
141
|
+
const content = await loadSkillContent(name);
|
|
142
|
+
if (content) map.set(name, content);
|
|
143
|
+
}
|
|
144
|
+
return map;
|
|
145
|
+
}
|
|
146
|
+
|
|
116
147
|
// src/patterns/types.ts
|
|
117
148
|
var PatternOutput = class {
|
|
118
149
|
constructor(text, startTime = Date.now(), endTime = Date.now()) {
|
|
@@ -243,16 +274,32 @@ async function confirmPhase(description, opts) {
|
|
|
243
274
|
async function ask(prompt, opts = {}) {
|
|
244
275
|
const model = pickModel(opts.model);
|
|
245
276
|
if (!model) throw new Error("pizx/patterns: No AI models configured. Run `pi auth login` first.");
|
|
277
|
+
let systemPrompt = opts.system;
|
|
278
|
+
if (opts.skills && opts.skills.length > 0) {
|
|
279
|
+
const skillMap = await loadSkillContents(opts.skills);
|
|
280
|
+
if (skillMap.size > 0) {
|
|
281
|
+
const skillBlocks = [];
|
|
282
|
+
for (const [name, content] of skillMap) {
|
|
283
|
+
skillBlocks.push(`Skill context (${name}):
|
|
284
|
+
${content}`);
|
|
285
|
+
}
|
|
286
|
+
const skillContext = skillBlocks.join("\n\n");
|
|
287
|
+
systemPrompt = systemPrompt ? `${systemPrompt}
|
|
288
|
+
|
|
289
|
+
${skillContext}` : skillContext;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
246
292
|
const t0 = Date.now();
|
|
247
293
|
const result = await completeSimple(
|
|
248
294
|
model,
|
|
249
295
|
{
|
|
250
|
-
systemPrompt
|
|
296
|
+
systemPrompt,
|
|
251
297
|
messages: [{ role: "user", content: prompt, timestamp: Date.now() }]
|
|
252
298
|
},
|
|
253
299
|
{
|
|
254
300
|
maxTokens: opts.maxTokens ?? 4096,
|
|
255
301
|
reasoning: opts.thinkingLevel ?? "medium",
|
|
302
|
+
thinkingBudgets: opts.thinkingBudgets,
|
|
256
303
|
timeoutMs: opts.timeoutMs,
|
|
257
304
|
maxRetries: opts.maxRetries
|
|
258
305
|
}
|
|
@@ -2648,8 +2695,11 @@ var defaults16 = {
|
|
|
2648
2695
|
maxTokens: 4096
|
|
2649
2696
|
};
|
|
2650
2697
|
function makeContext(pieces, args, opts) {
|
|
2698
|
+
const systemParts = [];
|
|
2699
|
+
if (opts.system) systemParts.push(opts.system);
|
|
2700
|
+
if (opts.appendSystemPrompt) systemParts.push(opts.appendSystemPrompt);
|
|
2651
2701
|
return {
|
|
2652
|
-
systemPrompt:
|
|
2702
|
+
systemPrompt: systemParts.length > 0 ? systemParts.join("\n\n") : void 0,
|
|
2653
2703
|
messages: [
|
|
2654
2704
|
{
|
|
2655
2705
|
role: "user",
|
|
@@ -2663,6 +2713,7 @@ function makeOpts(opts) {
|
|
|
2663
2713
|
return {
|
|
2664
2714
|
maxTokens: opts.maxTokens,
|
|
2665
2715
|
reasoning: opts.thinkingLevel,
|
|
2716
|
+
thinkingBudgets: opts.thinkingBudgets,
|
|
2666
2717
|
timeoutMs: opts.timeoutMs,
|
|
2667
2718
|
maxRetries: opts.maxRetries
|
|
2668
2719
|
};
|
|
@@ -2752,7 +2803,10 @@ function configurePi(opts) {
|
|
|
2752
2803
|
}
|
|
2753
2804
|
|
|
2754
2805
|
// src/pi-agent.ts
|
|
2755
|
-
import {
|
|
2806
|
+
import {
|
|
2807
|
+
createAgentSession as createAgentSession2,
|
|
2808
|
+
DefaultResourceLoader
|
|
2809
|
+
} from "@earendil-works/pi-coding-agent";
|
|
2756
2810
|
var _agentDefaults = {
|
|
2757
2811
|
quiet: false,
|
|
2758
2812
|
maxTurns: 10
|
|
@@ -2784,14 +2838,43 @@ var AgentOutput = class {
|
|
|
2784
2838
|
var AgentPromise = class extends Promise {
|
|
2785
2839
|
};
|
|
2786
2840
|
var _sharedSession = null;
|
|
2841
|
+
function createLoader(opts) {
|
|
2842
|
+
const hasSystem = opts.system !== void 0;
|
|
2843
|
+
const hasAppend = opts.appendSystemPrompt !== void 0;
|
|
2844
|
+
const hasSkills = opts.skills && opts.skills.length > 0;
|
|
2845
|
+
if (!hasSystem && !hasAppend && !hasSkills) return void 0;
|
|
2846
|
+
return new DefaultResourceLoader({
|
|
2847
|
+
cwd: opts.cwd ?? process.cwd(),
|
|
2848
|
+
agentDir: "",
|
|
2849
|
+
systemPrompt: opts.system,
|
|
2850
|
+
appendSystemPrompt: opts.appendSystemPrompt ? [opts.appendSystemPrompt] : void 0
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2787
2853
|
async function getSession(opts) {
|
|
2788
2854
|
if (_sharedSession && !opts.model) return _sharedSession;
|
|
2789
2855
|
try {
|
|
2856
|
+
const loader = createLoader(opts);
|
|
2857
|
+
if (opts.skills && opts.skills.length > 0 && loader) {
|
|
2858
|
+
const skillMap = await loadSkillContents(opts.skills);
|
|
2859
|
+
const skillPaths = [];
|
|
2860
|
+
for (const [name] of skillMap) {
|
|
2861
|
+
for (const base of SKILL_PATHS) {
|
|
2862
|
+
skillPaths.push({
|
|
2863
|
+
path: `${base}/${name}`,
|
|
2864
|
+
metadata: { source: "pizx", scope: "project", origin: "top-level" }
|
|
2865
|
+
});
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
if (skillPaths.length > 0) {
|
|
2869
|
+
loader.extendResources({ skillPaths });
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2790
2872
|
const result = await createAgentSession2({
|
|
2791
2873
|
cwd: opts.cwd,
|
|
2792
2874
|
thinkingLevel: opts.thinkingLevel,
|
|
2793
2875
|
tools: opts.tools,
|
|
2794
|
-
excludeTools: opts.excludeTools
|
|
2876
|
+
excludeTools: opts.excludeTools,
|
|
2877
|
+
resourceLoader: loader
|
|
2795
2878
|
});
|
|
2796
2879
|
_sharedSession = result.session;
|
|
2797
2880
|
return _sharedSession;
|
|
@@ -2895,6 +2978,7 @@ export {
|
|
|
2895
2978
|
PipelineOutput,
|
|
2896
2979
|
PipelineStageResult,
|
|
2897
2980
|
RalphOutput,
|
|
2981
|
+
SKILL_PATHS,
|
|
2898
2982
|
SubagentOutput,
|
|
2899
2983
|
SubagentResult,
|
|
2900
2984
|
ThreadMessage,
|
|
@@ -2903,6 +2987,8 @@ export {
|
|
|
2903
2987
|
configureAgent,
|
|
2904
2988
|
configurePi,
|
|
2905
2989
|
createPatternTag,
|
|
2990
|
+
loadSkillContent,
|
|
2991
|
+
loadSkillContents,
|
|
2906
2992
|
\u0391,
|
|
2907
2993
|
\u0392,
|
|
2908
2994
|
\u0393,
|