@oyasmi/pipiclaw 0.7.4 → 0.7.6

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 (59) hide show
  1. package/README.md +5 -1
  2. package/dist/agent/channel-runner.js +14 -0
  3. package/dist/agent/commands.d.ts +1 -1
  4. package/dist/agent/commands.js +6 -0
  5. package/dist/agent/job-manager.d.ts +79 -0
  6. package/dist/agent/job-manager.js +241 -0
  7. package/dist/agent/prompt-builder.js +13 -4
  8. package/dist/memory/review-log.d.ts +1 -1
  9. package/dist/memory/task-digest.d.ts +21 -0
  10. package/dist/memory/task-digest.js +66 -0
  11. package/dist/runtime/bootstrap.js +13 -1
  12. package/dist/runtime/dingtalk.d.ts +1 -0
  13. package/dist/runtime/dingtalk.js +6 -2
  14. package/dist/runtime/event-commands.d.ts +5 -0
  15. package/dist/runtime/event-commands.js +2 -2
  16. package/dist/runtime/task-commands.d.ts +6 -0
  17. package/dist/runtime/task-commands.js +133 -0
  18. package/dist/settings.d.ts +7 -0
  19. package/dist/settings.js +13 -0
  20. package/dist/shared/task-ledger.d.ts +53 -0
  21. package/dist/shared/task-ledger.js +149 -0
  22. package/dist/tools/bash.d.ts +12 -0
  23. package/dist/tools/bash.js +67 -1
  24. package/dist/tools/config.d.ts +15 -0
  25. package/dist/tools/config.js +37 -0
  26. package/dist/tools/edit.js +0 -0
  27. package/dist/tools/event-manage.d.ts +35 -0
  28. package/dist/tools/event-manage.js +238 -0
  29. package/dist/tools/grep.d.ts +19 -0
  30. package/dist/tools/grep.js +262 -0
  31. package/dist/tools/index.js +5 -0
  32. package/dist/tools/job.d.ts +13 -0
  33. package/dist/tools/job.js +92 -0
  34. package/dist/tools/memory-manage.d.ts +24 -0
  35. package/dist/tools/memory-manage.js +150 -0
  36. package/dist/tools/read.js +103 -16
  37. package/dist/tools/registry.d.ts +7 -1
  38. package/dist/tools/registry.js +54 -17
  39. package/dist/tools/session-search.js +4 -1
  40. package/dist/tools/skill-manage.d.ts +12 -5
  41. package/dist/tools/skill-manage.js +113 -15
  42. package/dist/tools/task-manage.d.ts +43 -0
  43. package/dist/tools/task-manage.js +226 -0
  44. package/dist/tools/web-cache.d.ts +11 -0
  45. package/dist/tools/web-cache.js +62 -0
  46. package/dist/tools/web-fetch.d.ts +3 -0
  47. package/dist/tools/web-fetch.js +70 -5
  48. package/dist/tui/app.js +2 -0
  49. package/dist/tui/commands.d.ts +1 -0
  50. package/dist/tui/commands.js +3 -0
  51. package/dist/tui/turn-controller.d.ts +1 -0
  52. package/dist/tui/turn-controller.js +1 -0
  53. package/package.json +1 -1
  54. package/dist/tools/memory-save.d.ts +0 -16
  55. package/dist/tools/memory-save.js +0 -42
  56. package/dist/tools/skill-list.d.ts +0 -18
  57. package/dist/tools/skill-list.js +0 -86
  58. package/dist/tools/skill-view.d.ts +0 -13
  59. package/dist/tools/skill-view.js +0 -44
@@ -35,6 +35,8 @@ export async function dispatch(input, deps) {
35
35
  return { kind: "reply", text: deps.renderUsage(command.args) };
36
36
  case "events":
37
37
  return { kind: "reply", text: await deps.runEvents(command.args) };
38
+ case "tasks":
39
+ return { kind: "reply", text: await deps.runTasks(command.args) };
38
40
  case "stop":
39
41
  return { kind: "stop" };
40
42
  case "steer":
@@ -56,6 +58,7 @@ export const TUI_SLASH_COMMANDS = [
56
58
  { name: "status", description: "Show model, context and run state" },
57
59
  { name: "usage", description: "Show LLM cost for this channel", argumentHint: "[7d|month]" },
58
60
  { name: "events", description: "Manage scheduled events", argumentHint: "<list|show|delete|history>" },
61
+ { name: "tasks", description: "View the task ledger (read-only)", argumentHint: "[show <id>|archive]" },
59
62
  { name: "model", description: "Show or switch the model", argumentHint: "[provider/model]" },
60
63
  { name: "new", description: "Start a new session" },
61
64
  { name: "compact", description: "Compact the session context", argumentHint: "[instructions]" },
@@ -22,6 +22,7 @@ export interface TurnControllerDeps {
22
22
  renderHelp: () => string;
23
23
  renderUsage: (args: string) => string;
24
24
  runEvents: (args: string) => Promise<string>;
25
+ runTasks: (args: string) => Promise<string>;
25
26
  /** Static bits the status renderer needs alongside the live run state. */
26
27
  statusInfo: {
27
28
  version: string;
@@ -35,6 +35,7 @@ export class TurnController {
35
35
  renderHelp: deps.renderHelp,
36
36
  renderUsage: deps.renderUsage,
37
37
  runEvents: deps.runEvents,
38
+ runTasks: deps.runTasks,
38
39
  renderStatus: () => renderStatus({
39
40
  state: { running: this.running, currentTaskText: this.currentTaskText, runner: this.deps.runner },
40
41
  version: deps.statusInfo.version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,16 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import { Type } from "typebox";
3
- import type { MemoryCandidateStore } from "../memory/candidates.js";
4
- import { type ChannelMemoryQueue } from "../memory/channel-maintenance-queue.js";
5
- declare const memorySaveSchema: Type.TObject<{
6
- content: Type.TString;
7
- kind: Type.TOptional<Type.TUnion<[Type.TLiteral<"preference">, Type.TLiteral<"fact">, Type.TLiteral<"decision">, Type.TLiteral<"constraint">, Type.TLiteral<"open-loop">]>>;
8
- }>;
9
- export interface MemorySaveToolOptions {
10
- channelId: string;
11
- channelDir: string;
12
- memoryCandidateStore: MemoryCandidateStore;
13
- channelMemoryQueue?: ChannelMemoryQueue;
14
- }
15
- export declare function createMemorySaveTool(options: MemorySaveToolOptions): AgentTool<typeof memorySaveSchema>;
16
- export {};
@@ -1,42 +0,0 @@
1
- import { Type } from "typebox";
2
- import { getDefaultChannelMemoryQueue } from "../memory/channel-maintenance-queue.js";
3
- import { applyChannelMemoryOps, getChannelMemoryPath } from "../memory/files.js";
4
- const memorySaveSchema = Type.Object({
5
- content: Type.String({
6
- description: "The durable fact to remember, as a single self-contained, keyword-rich sentence. Write it so future keyword search can find it.",
7
- }),
8
- kind: Type.Optional(Type.Union([
9
- Type.Literal("preference"),
10
- Type.Literal("fact"),
11
- Type.Literal("decision"),
12
- Type.Literal("constraint"),
13
- Type.Literal("open-loop"),
14
- ], { description: "What kind of durable memory this is." })),
15
- });
16
- export function createMemorySaveTool(options) {
17
- const queue = options.channelMemoryQueue ?? getDefaultChannelMemoryQueue();
18
- return {
19
- name: "memory_save",
20
- label: "memory_save",
21
- description: "Save a durable fact to this channel's long-term MEMORY.md immediately. Use when the user explicitly asks you to remember something (a preference, decision, constraint, or long-running commitment), so it survives restarts and future sessions. Do not use for transient task state — that is captured automatically.",
22
- parameters: memorySaveSchema,
23
- execute: async (_toolCallId, { content, kind }) => {
24
- const trimmed = content.trim();
25
- if (!trimmed) {
26
- return {
27
- content: [{ type: "text", text: "No content provided; nothing was saved." }],
28
- details: { kind: "memory_save", saved: false },
29
- };
30
- }
31
- // Serialize through the shared channel memory queue so this never races with
32
- // background consolidation/maintenance on the same channel's files.
33
- const result = await queue.run(options.channelId, () => applyChannelMemoryOps(options.channelDir, [{ op: "add", content: trimmed }]));
34
- // Make the new memory recallable within this same turn.
35
- options.memoryCandidateStore.invalidate(getChannelMemoryPath(options.channelDir));
36
- return {
37
- content: [{ type: "text", text: `Saved to channel memory${kind ? ` (${kind})` : ""}.` }],
38
- details: { kind: "memory_save", saved: result.added > 0 },
39
- };
40
- },
41
- };
42
- }
@@ -1,18 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import { Type } from "typebox";
3
- declare const skillListSchema: Type.TObject<{
4
- label: Type.TString;
5
- }>;
6
- export interface WorkspaceSkillSummary {
7
- name: string;
8
- description: string;
9
- path: string;
10
- warning?: string;
11
- }
12
- export interface SkillListToolOptions {
13
- workspaceDir: string;
14
- workspacePath: string;
15
- }
16
- export declare function listWorkspaceSkills(options: SkillListToolOptions): Promise<WorkspaceSkillSummary[]>;
17
- export declare function createSkillListTool(options: SkillListToolOptions): AgentTool<typeof skillListSchema>;
18
- export {};
@@ -1,86 +0,0 @@
1
- import { readdir, readFile, stat } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { Type } from "typebox";
4
- import { validateSkillFrontmatter, validateSkillName } from "./skill-security.js";
5
- const skillListSchema = Type.Object({
6
- label: Type.String({ description: "Brief description of why you're listing workspace skills (shown to user)" }),
7
- });
8
- function extractDescription(content) {
9
- const match = content.replace(/\r\n/g, "\n").match(/^---\n([\s\S]*?)\n---/);
10
- if (!match) {
11
- return "";
12
- }
13
- for (const line of (match[1] ?? "").split("\n")) {
14
- const fieldMatch = line.match(/^description:\s*(.*)$/);
15
- if (fieldMatch) {
16
- return fieldMatch[1].replace(/^["']|["']$/g, "").trim();
17
- }
18
- }
19
- return "";
20
- }
21
- function isNodeError(error) {
22
- return error instanceof Error && "code" in error;
23
- }
24
- export async function listWorkspaceSkills(options) {
25
- const skillsDir = join(options.workspaceDir, "skills");
26
- let names;
27
- try {
28
- names = await readdir(skillsDir);
29
- }
30
- catch (error) {
31
- if (isNodeError(error) && error.code === "ENOENT") {
32
- return [];
33
- }
34
- throw error;
35
- }
36
- const summaries = [];
37
- for (const name of names.sort()) {
38
- const nameValidation = validateSkillName(name);
39
- if (!nameValidation.ok) {
40
- continue;
41
- }
42
- const skillDir = join(skillsDir, name);
43
- const skillStats = await stat(skillDir).catch(() => null);
44
- if (!skillStats?.isDirectory()) {
45
- continue;
46
- }
47
- const skillPath = join(skillDir, "SKILL.md");
48
- let content;
49
- try {
50
- const skillFileStats = await stat(skillPath);
51
- if (!skillFileStats.isFile()) {
52
- continue;
53
- }
54
- content = await readFile(skillPath, "utf-8");
55
- }
56
- catch (error) {
57
- if (isNodeError(error) && error.code === "ENOENT") {
58
- continue;
59
- }
60
- throw error;
61
- }
62
- const validation = validateSkillFrontmatter(content, name);
63
- summaries.push({
64
- name,
65
- description: extractDescription(content),
66
- path: `${options.workspacePath}/skills/${name}/SKILL.md`,
67
- warning: validation.ok ? undefined : validation.error,
68
- });
69
- }
70
- return summaries;
71
- }
72
- export function createSkillListTool(options) {
73
- return {
74
- name: "skill_list",
75
- label: "skill_list",
76
- description: "List workspace-level Pipiclaw skills that can be viewed or managed.",
77
- parameters: skillListSchema,
78
- execute: async () => {
79
- const skills = await listWorkspaceSkills(options);
80
- return {
81
- content: [{ type: "text", text: JSON.stringify({ skills }) }],
82
- details: { kind: "skill_list", count: skills.length },
83
- };
84
- },
85
- };
86
- }
@@ -1,13 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import { Type } from "typebox";
3
- declare const skillViewSchema: Type.TObject<{
4
- label: Type.TString;
5
- name: Type.TString;
6
- filePath: Type.TOptional<Type.TString>;
7
- }>;
8
- export interface SkillViewToolOptions {
9
- workspaceDir: string;
10
- workspacePath: string;
11
- }
12
- export declare function createSkillViewTool(options: SkillViewToolOptions): AgentTool<typeof skillViewSchema>;
13
- export {};
@@ -1,44 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { Type } from "typebox";
4
- import { resolveSkillPath, resolveSkillSupportingFile } from "./skill-security.js";
5
- import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
6
- const skillViewSchema = Type.Object({
7
- label: Type.String({ description: "Brief description of why you're viewing this skill (shown to user)" }),
8
- name: Type.String({ description: "Workspace skill name" }),
9
- filePath: Type.Optional(Type.String({
10
- description: "Optional file path inside the skill directory. Defaults to SKILL.md. Supporting files must be under references/, templates/, scripts/, or assets/.",
11
- })),
12
- });
13
- function toWorkspacePath(options, hostPath) {
14
- if (hostPath.startsWith(options.workspaceDir)) {
15
- return `${options.workspacePath}${hostPath.slice(options.workspaceDir.length)}`;
16
- }
17
- return hostPath;
18
- }
19
- export function createSkillViewTool(options) {
20
- return {
21
- name: "skill_view",
22
- label: "skill_view",
23
- description: "View a workspace-level skill SKILL.md file or an allowed supporting file.",
24
- parameters: skillViewSchema,
25
- execute: async (_toolCallId, { name, filePath }) => {
26
- const skillDir = resolveSkillPath(options.workspaceDir, name);
27
- const targetPath = filePath ? resolveSkillSupportingFile(skillDir, filePath) : join(skillDir, "SKILL.md");
28
- const workspacePath = toWorkspacePath(options, targetPath);
29
- const content = await readFile(targetPath, "utf-8");
30
- // Return the raw file content (not JSON-escaped) with a small header, and cap it
31
- // with the shared truncation limits so a large supporting file cannot flood context.
32
- const truncation = truncateHead(content);
33
- let body = truncation.content;
34
- if (truncation.truncated) {
35
- body += `\n\n[Truncated at ${formatSize(DEFAULT_MAX_BYTES)}. Use the read tool on ${workspacePath} to page through the rest.]`;
36
- }
37
- const text = `Skill: ${name}\nPath: ${workspacePath}\n\n${body}`;
38
- return {
39
- content: [{ type: "text", text }],
40
- details: { kind: "skill_view", name, path: workspacePath, truncated: truncation.truncated },
41
- };
42
- },
43
- };
44
- }