@phi-code-admin/phi-code 0.68.0 → 0.70.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/agents/code.md +7 -0
- package/agents/explore.md +7 -0
- package/agents/review.md +5 -1
- package/extensions/phi/memory.ts +27 -4
- package/extensions/phi/orchestrator.ts +51 -5
- package/package.json +2 -2
package/agents/code.md
CHANGED
|
@@ -39,3 +39,10 @@ Use this context to understand the project scope and build on previous work. Do
|
|
|
39
39
|
2. **What was done**: Concise implementation summary
|
|
40
40
|
3. **Verification**: What you checked (compilation, tests, edge cases)
|
|
41
41
|
4. **Concerns**: Any TODOs, limitations, or risks
|
|
42
|
+
|
|
43
|
+
## Constraints
|
|
44
|
+
- Write ONE file per tool call — never combine multiple files in a single response
|
|
45
|
+
- Keep each file under 500 lines — split into modules if needed
|
|
46
|
+
- Files containing JSX/TSX syntax MUST use .tsx extension, not .ts
|
|
47
|
+
- Pure TypeScript files use .ts extension
|
|
48
|
+
- When using React/Ink components, ALWAYS use .tsx
|
package/agents/explore.md
CHANGED
|
@@ -31,6 +31,13 @@ Use the project context to focus your analysis on what matters. Avoid duplicatin
|
|
|
31
31
|
- **Read-only**: You NEVER modify files
|
|
32
32
|
- **Time-efficient**: Focus on what the task asks. Don't analyze the entire codebase if only one module matters
|
|
33
33
|
|
|
34
|
+
## Ontology Rules
|
|
35
|
+
- After adding entities, ALWAYS create relations between them
|
|
36
|
+
- Relation types: "uses", "contains", "depends_on", "implements", "extends"
|
|
37
|
+
- Example: Project "finance-tracker" --uses--> Library "ink"
|
|
38
|
+
- A knowledge graph without relations is just a flat list — useless
|
|
39
|
+
- Create at minimum: project→uses→each library, project→contains→each module
|
|
40
|
+
|
|
34
41
|
## Output Format
|
|
35
42
|
|
|
36
43
|
Structure your findings for maximum utility to downstream agents:
|
package/agents/review.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: review
|
|
3
3
|
description: Senior code reviewer. Audits quality, security, performance, and correctness.
|
|
4
|
-
tools: read, grep, find, ls, bash, memory_search, memory_write, ontology_add
|
|
4
|
+
tools: read, write, grep, find, ls, bash, memory_search, memory_write, ontology_add
|
|
5
5
|
model: default
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -34,6 +34,10 @@ Focus your review on the files mentioned in previous task results. Don't audit t
|
|
|
34
34
|
- **Read-only**: You NEVER modify files. You report findings for the code agent to fix
|
|
35
35
|
- **Focused scope**: Review what was changed, not the entire project
|
|
36
36
|
|
|
37
|
+
## File Writing
|
|
38
|
+
- Use the `write` tool to create review reports and documentation
|
|
39
|
+
- NEVER use `bash` with `cat > file` as a workaround — always use the `write` tool directly
|
|
40
|
+
|
|
37
41
|
## Output Format
|
|
38
42
|
|
|
39
43
|
### 🔴 Critical / High
|
package/extensions/phi/memory.ts
CHANGED
|
@@ -254,15 +254,38 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
254
254
|
if (!p.from || !p.to || !p.relationType) {
|
|
255
255
|
return { content: [{ type: "text", text: "Relation requires 'from', 'to', and 'relationType'" }], isError: true };
|
|
256
256
|
}
|
|
257
|
+
|
|
258
|
+
// Try finding source entity by ID first, then by name
|
|
259
|
+
let sourceEntity = sigmaMemory.ontology.findEntity({ id: p.from })[0];
|
|
260
|
+
if (!sourceEntity) {
|
|
261
|
+
// Try finding by name (case-insensitive)
|
|
262
|
+
const allEntities = sigmaMemory.ontology.findEntity({});
|
|
263
|
+
sourceEntity = allEntities.find(e => e.name.toLowerCase() === p.from.toLowerCase());
|
|
264
|
+
if (!sourceEntity) {
|
|
265
|
+
return { content: [{ type: "text", text: `Source entity not found: ${p.from}` }], isError: true };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Try finding target entity by ID first, then by name
|
|
270
|
+
let targetEntity = sigmaMemory.ontology.findEntity({ id: p.to })[0];
|
|
271
|
+
if (!targetEntity) {
|
|
272
|
+
// Try finding by name (case-insensitive)
|
|
273
|
+
const allEntities = sigmaMemory.ontology.findEntity({});
|
|
274
|
+
targetEntity = allEntities.find(e => e.name.toLowerCase() === p.to.toLowerCase());
|
|
275
|
+
if (!targetEntity) {
|
|
276
|
+
return { content: [{ type: "text", text: `Target entity not found: ${p.to}` }], isError: true };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
257
280
|
const id = sigmaMemory.ontology.addRelation({
|
|
258
|
-
from:
|
|
259
|
-
to:
|
|
281
|
+
from: sourceEntity.id,
|
|
282
|
+
to: targetEntity.id,
|
|
260
283
|
type: p.relationType,
|
|
261
284
|
properties: p.properties || {},
|
|
262
285
|
});
|
|
263
286
|
return {
|
|
264
|
-
content: [{ type: "text", text: `Relation added: \`${
|
|
265
|
-
details: { id, from:
|
|
287
|
+
content: [{ type: "text", text: `Relation added: \`${sourceEntity.name}\` → **${p.relationType}** → \`${targetEntity.name}\` — ID: \`${id}\`` }],
|
|
288
|
+
details: { id, from: sourceEntity.id, to: targetEntity.id, type: p.relationType },
|
|
266
289
|
};
|
|
267
290
|
}
|
|
268
291
|
return { content: [{ type: "text", text: "Type must be 'entity' or 'relation'" }], isError: true };
|
|
@@ -548,7 +548,12 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
|
|
|
548
548
|
|
|
549
549
|
**Step 4:** Write your findings to \`.phi/plans/explore-${ts}.md\`
|
|
550
550
|
|
|
551
|
-
|
|
551
|
+
**Knowledge Graph:**
|
|
552
|
+
After your analysis, use \`ontology_add\` to save key project entities AND their relations:
|
|
553
|
+
- Add entities for: the project, each major library, each module/directory
|
|
554
|
+
- Add relations between them: "uses", "contains", "depends_on", "implements"
|
|
555
|
+
- Example: entity "finance-tracker" (type: Project) → relation "uses" → entity "ink" (type: Library)
|
|
556
|
+
- ALWAYS create relations — entities without relations are useless
|
|
552
557
|
|
|
553
558
|
**Format for the project brief:**
|
|
554
559
|
\`\`\`markdown
|
|
@@ -578,6 +583,11 @@ After your analysis, use \`ontology_add\` to save key project entities (files, m
|
|
|
578
583
|
agent: loadAgentDef("plan"),
|
|
579
584
|
instruction: `You are the PLAN agent. Design the architecture and create a detailed task list.
|
|
580
585
|
|
|
586
|
+
**Context Retrieval:**
|
|
587
|
+
1. Use \`ontology_query\` to retrieve all entities and relations from Phase 1
|
|
588
|
+
2. Use \`memory_search\` with project-relevant keywords to find existing notes
|
|
589
|
+
3. Use this knowledge to inform your plan
|
|
590
|
+
|
|
581
591
|
**Project Request:** ${description}
|
|
582
592
|
|
|
583
593
|
**Step 1:** Read \`.phi/plans/brief-*.md\` (created by the explore phase)
|
|
@@ -604,13 +614,20 @@ After your analysis, use \`ontology_add\` to save key project entities (files, m
|
|
|
604
614
|
## Task 2: [Task Title] [agent-type]
|
|
605
615
|
- [ ] Implementation details
|
|
606
616
|
- Dependencies: Task 1
|
|
607
|
-
|
|
617
|
+
\`\`\`
|
|
618
|
+
|
|
619
|
+
Before finishing, use \`memory_write\` to save your plan summary with relevant tags for future reference.`,
|
|
608
620
|
},
|
|
609
621
|
{
|
|
610
622
|
key: "code", label: "💻 Phase 3 — CODE", model: code.preferred, fallback: code.fallback,
|
|
611
623
|
agent: loadAgentDef("code"),
|
|
612
624
|
instruction: `You are the CODE agent. Implement the complete project.
|
|
613
625
|
|
|
626
|
+
**Context Retrieval:**
|
|
627
|
+
1. Use \`memory_search\` with project keywords to find notes from previous phases
|
|
628
|
+
2. Use \`ontology_query\` to understand the project structure and dependencies
|
|
629
|
+
3. Use this context to guide implementation
|
|
630
|
+
|
|
614
631
|
**Project Request:** ${description}
|
|
615
632
|
|
|
616
633
|
**Step 1:** Read \`.phi/plans/brief-*.md\` for project context
|
|
@@ -639,13 +656,25 @@ After your analysis, use \`ontology_add\` to save key project entities (files, m
|
|
|
639
656
|
|
|
640
657
|
## Implementation Notes
|
|
641
658
|
[Any important decisions or changes made]
|
|
642
|
-
|
|
659
|
+
\`\`\`
|
|
660
|
+
|
|
661
|
+
After implementation, use \`memory_write\` to save a summary of what was built, patterns used, and any issues encountered.
|
|
662
|
+
|
|
663
|
+
**CRITICAL RULES:**
|
|
664
|
+
- Write ONE file per tool call — NEVER combine multiple files in a single response
|
|
665
|
+
- Keep each file under 500 lines. If longer, split into modules
|
|
666
|
+
- After writing each file, verify it exists with \`ls\` before proceeding`,
|
|
643
667
|
},
|
|
644
668
|
{
|
|
645
669
|
key: "test", label: "🧪 Phase 4 — TEST", model: test.preferred, fallback: test.fallback,
|
|
646
670
|
agent: loadAgentDef("test"),
|
|
647
671
|
instruction: `You are the TEST agent. Verify the implementation.
|
|
648
672
|
|
|
673
|
+
**Context Retrieval:**
|
|
674
|
+
1. Use \`memory_search\` to find implementation notes from the CODE phase
|
|
675
|
+
2. Use \`ontology_query\` to understand the project architecture
|
|
676
|
+
3. Use this context to focus your testing
|
|
677
|
+
|
|
649
678
|
**Project Request:** ${description}
|
|
650
679
|
|
|
651
680
|
**Step 1:** Read \`.phi/plans/todo-*.md\` to know what was planned
|
|
@@ -677,13 +706,26 @@ After your analysis, use \`ontology_add\` to save key project entities (files, m
|
|
|
677
706
|
**CRITICAL RULES:**
|
|
678
707
|
- NEVER run a server with \`&\` without cleanup. Always use: \`timeout 15 bash -c 'node src/index.js & PID=$!; sleep 2; curl ...; kill $PID'\`
|
|
679
708
|
- ALWAYS kill background processes after testing
|
|
680
|
-
- If a test hangs, use \`timeout\` to prevent deadlock
|
|
709
|
+
- If a test hangs, use \`timeout\` to prevent deadlock
|
|
710
|
+
- NEVER put tool calls inside thinking blocks. Always use the proper JSON tool call format
|
|
711
|
+
- NEVER modify source code permanently for testing. Use environment variables: \`PORT=3001 node server.js\` instead of editing files
|
|
712
|
+
- NEVER create .env files with fake credentials. Use inline env vars: \`API_KEY=test node server.js\`
|
|
713
|
+
- For port conflicts on Windows, use: \`netstat -ano | findstr :PORT\` and \`taskkill /PID <pid> /F\`
|
|
714
|
+
- For port conflicts on Linux/Mac, use: \`lsof -ti:PORT | xargs kill -9\`
|
|
715
|
+
- Always clean up after tests: kill background processes, remove temp files
|
|
716
|
+
|
|
717
|
+
After testing, use \`memory_write\` to save test results, bugs found, and lessons learned.`,
|
|
681
718
|
},
|
|
682
719
|
{
|
|
683
720
|
key: "review", label: "🔍 Phase 5 — REVIEW", model: review.preferred, fallback: review.fallback,
|
|
684
721
|
agent: loadAgentDef("review"),
|
|
685
722
|
instruction: `You are the REVIEW agent. Final quality review.
|
|
686
723
|
|
|
724
|
+
**Context Retrieval:**
|
|
725
|
+
1. Use \`memory_search\` to find all notes from previous phases (explore, plan, code, test)
|
|
726
|
+
2. Use \`ontology_query\` to understand the full project architecture
|
|
727
|
+
3. Review all \`.phi/plans/*.md\` files for complete context
|
|
728
|
+
|
|
687
729
|
**Project Request:** ${description}
|
|
688
730
|
|
|
689
731
|
**Step 1:** Read all \`.phi/plans/*.md\` files
|
|
@@ -723,7 +765,11 @@ After your analysis, use \`ontology_add\` to save key project entities (files, m
|
|
|
723
765
|
✅ Project ready for production / ❌ Issues need resolution
|
|
724
766
|
\`\`\`
|
|
725
767
|
|
|
726
|
-
After your review, use \`memory_write\` to save
|
|
768
|
+
After your review, use \`memory_write\` to save:
|
|
769
|
+
- Key lessons learned about this project type
|
|
770
|
+
- Patterns that worked well
|
|
771
|
+
- Common mistakes to avoid in future projects
|
|
772
|
+
Tag the note with relevant keywords for vector search.`,
|
|
727
773
|
},
|
|
728
774
|
];
|
|
729
775
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phi-code-admin/phi-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.0",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"phi-code-tui": "^0.56.3",
|
|
62
62
|
"proper-lockfile": "^4.1.2",
|
|
63
63
|
"sigma-agents": "^0.1.6",
|
|
64
|
-
"sigma-memory": "0.2.
|
|
64
|
+
"sigma-memory": "0.2.1",
|
|
65
65
|
"sigma-skills": "^0.1.2",
|
|
66
66
|
"strip-ansi": "^7.1.0",
|
|
67
67
|
"undici": "^7.19.1",
|